DateChange LeftWorkCheck Completed

This commit is contained in:
SamSys
2025-05-15 17:30:51 +03:30
parent 986092135f
commit ee2adf1c13
2 changed files with 61 additions and 26 deletions

View File

@@ -167,10 +167,20 @@ public class AutoExtensionModel : PageModel
//Correction();
}
public IActionResult OnPostEmployeesStartedWorkInSelectedPeriod(long workshopId, string startDate)
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
@@ -186,7 +196,7 @@ public class AutoExtensionModel : PageModel
{
founded = true,
leftWorkList = res,
error = false
});
}
@@ -196,6 +206,7 @@ public class AutoExtensionModel : PageModel
return new JsonResult(new
{
founded = false,
error = false
});

View File

@@ -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,7 +754,7 @@ $(".edate").keyup(function () {
$('#monthSelected').on('change',
function () {
console.log("ok");
const year = $("select[name=yearSelected]").val();
const month = $(this).val();
if (year === "0") {
@@ -757,12 +766,8 @@ $('#monthSelected').on('change',
const endDate = DateComputing(selectedDate);
/* SetStartAndEndDate(selectedDate, endDate);*/
SetStartAndEndDate(selectedDate, endDate,false);
$(".sdate").val(selectedDate);
$(".edate").val(endDate);
$('.sdate').removeClass("errored");
$('.edate').removeClass("errored");
}
@@ -775,39 +780,58 @@ $("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) {
const workshopId = Number $(".sdate").val(selectedDate);
$(".edate").val(endDate);
$('.sdate').removeClass("errored");
$('.edate').removeClass("errored");($('#workshopId').val());
function SetStartAndEndDate(selectedDate, endDate, manualDate) {
const workshopId = Number($('#workshopId').val());
$.ajax({
dataType: 'json',
type: 'POST',
url: EmployeesStartedWorkInSelectedPeriodAjaxUrl,
data: { "workshopId": workshopId, "startDate": selectedDate },
data: { "workshopId": workshopId, "startDate": selectedDate, "endDate": endDate, "manualDate": manualDate },
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
success: function (response) {
if (response.funded) {
if (response.founded && !response.error) {
$('#datatable tbody tr').each(function (i) {
let employeeId = $(this).attr("data-employeeId");
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 {
} 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);