AutoExtention-startworkcheck merged
This commit is contained in:
@@ -848,6 +848,9 @@
|
||||
var alertModalAjax = '@Url.Page("./AutoExtension", "AlertModal")';
|
||||
var clockAjax = '@Url.Page("./AutoExtension", "Clock")';
|
||||
var createContractAjax = '@Url.Page("./AutoExtension", "CreateContract")';
|
||||
var EmployeesStartedWorkInSelectedPeriodAjaxUrl = '@Url.Page("./AutoExtension", "EmployeesStartedWorkInSelectedPeriod")';
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script src="~/AssetsAdmin/page/Workshop/js/AutoExtension.js"></script>
|
||||
|
||||
@@ -167,6 +167,50 @@ public class AutoExtensionModel : PageModel
|
||||
//Correction();
|
||||
}
|
||||
|
||||
public IActionResult OnPostEmployeesStartedWorkInSelectedPeriod(long workshopId, string startDate, string endDate, bool manualDate)
|
||||
{
|
||||
var start = startDate.ToGeorgianDateTime();
|
||||
var end = ($"{startDate.FindeEndOfMonth()}").ToGeorgianDateTime();
|
||||
if (manualDate)
|
||||
end = endDate.ToGeorgianDateTime();
|
||||
if (start >= end)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
founded = false,
|
||||
error = true
|
||||
});
|
||||
}
|
||||
var leftWorkSerchModel = new LeftWorkSearchModel
|
||||
{
|
||||
WorkshopId = workshopId
|
||||
};
|
||||
var leftWorkList = _leftWorkApplication.search(leftWorkSerchModel);
|
||||
|
||||
if (leftWorkList.Count > 0)
|
||||
{
|
||||
var res = leftWorkList.Where(x => x.StartWorkDateGr <= end && x.StartWorkDateGr > start).ToList();
|
||||
if (res.Count > 0)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
founded = true,
|
||||
leftWorkList = res,
|
||||
error = false
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
founded = false,
|
||||
error = false
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
public IActionResult OnGetContractStatus(long employeeId, long workshopId, string employeeName, string workshopname)
|
||||
{
|
||||
var command = new ContractStatusViewModel();
|
||||
|
||||
@@ -180,7 +180,7 @@ $('#firstCheckBtn').on('click',
|
||||
$('#datatable tbody tr').each(function (i) {
|
||||
let chekbox = $(this).find("input[name=selectItem]");
|
||||
if (chekbox.is(":checked") == true) {
|
||||
employeeId = $(this).attr("data-employeeId");;
|
||||
employeeId = $(this).attr("data-employeeId");
|
||||
start = $(this).find("input[name=contarctStart]").val();
|
||||
startObj = $(this).find("input[name=contarctStart]");
|
||||
end = $(this).find("input[name=contractEnd]").val();
|
||||
@@ -701,7 +701,12 @@ $("#start").keyup(function () {
|
||||
$(this).addClass("errored");
|
||||
} else {
|
||||
$(this).removeClass("errored");
|
||||
$(".sdate").val(value);
|
||||
var endDate = $("#end").val();
|
||||
if (endDate.length == 10) {
|
||||
|
||||
SetStartAndEndDate(value, endDate, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -713,7 +718,11 @@ $("#end").keyup(function () {
|
||||
$(this).addClass("errored");
|
||||
} else {
|
||||
$(this).removeClass("errored");
|
||||
$(".edate").val(value);
|
||||
var startDate = $("#start").val();
|
||||
if (startDate.length == 10) {
|
||||
|
||||
SetStartAndEndDate(startDate, value,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -745,18 +754,21 @@ $(".edate").keyup(function () {
|
||||
$('#monthSelected').on('change',
|
||||
function () {
|
||||
|
||||
|
||||
const year = $("select[name=yearSelected]").val();
|
||||
const month = $(this).val();
|
||||
if (year === "0") {
|
||||
$("select[name=yearSelected]").addClass("errored");
|
||||
}
|
||||
if (year != "0" && month != "0") {
|
||||
|
||||
const selectedDate = year + "/" + month + "/01";
|
||||
const endDate = DateComputing(selectedDate);
|
||||
$(".sdate").val(selectedDate);
|
||||
$(".edate").val(endDate);
|
||||
$('.sdate').removeClass("errored");
|
||||
$('.edate').removeClass("errored");
|
||||
|
||||
|
||||
SetStartAndEndDate(selectedDate, endDate,false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@@ -768,15 +780,65 @@ $("select[name=yearSelected]").on('change',
|
||||
if (year != "0" && month != "0") {
|
||||
const selectedDate = year + "/" + month + "/01";
|
||||
const endDate = DateComputing(selectedDate);
|
||||
$(".sdate").val(selectedDate);
|
||||
$(".edate").val(endDate);
|
||||
$('.sdate').removeClass("errored");
|
||||
$('.edate').removeClass("errored");
|
||||
SetStartAndEndDate(selectedDate, endDate,false);
|
||||
|
||||
$("select[name=yearSelected]").removeClass("errored");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
function SetStartAndEndDate(selectedDate, endDate, manualDate) {
|
||||
const workshopId = Number($('#workshopId').val());
|
||||
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
url: EmployeesStartedWorkInSelectedPeriodAjaxUrl,
|
||||
data: { "workshopId": workshopId, "startDate": selectedDate, "endDate": endDate, "manualDate": manualDate },
|
||||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||||
|
||||
success: function (response) {
|
||||
if (response.founded && !response.error) {
|
||||
|
||||
$('#datatable tbody tr').each(function (i) {
|
||||
let selectedTr = $(this);
|
||||
let employeeIdInList = selectedTr.attr("data-employeeId");
|
||||
console.log('employeeIdInList' + employeeIdInList);
|
||||
selectedTr.find(".sdate").val(selectedDate);
|
||||
selectedTr.find(".edate").val(endDate);
|
||||
response.leftWorkList.forEach(function (el) {
|
||||
if (el.employeeId == employeeIdInList) {
|
||||
|
||||
$('.sdate').removeClass("errored");
|
||||
selectedTr.find(".sdate").val(el.startWorkDate);
|
||||
selectedTr.find(".edate").val(endDate);
|
||||
$('.edate').removeClass("errored");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
} else if (!response.founded && !response.error) {
|
||||
$(".sdate").val(selectedDate);
|
||||
$('.sdate').removeClass("errored");
|
||||
$(".edate").val(endDate);
|
||||
$('.edate').removeClass("errored");
|
||||
|
||||
|
||||
} else if (!response.founded && response.error) {
|
||||
|
||||
$('#end').addClass("errored");
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
failure: function (response) {
|
||||
console.log(5, response);
|
||||
|
||||
}
|
||||
}); //endOf Ajax
|
||||
}
|
||||
function DateComputing(selectedDate) {
|
||||
var persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g],
|
||||
arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g],
|
||||
|
||||
Reference in New Issue
Block a user