Files
Backend-Api/ServiceHost/wwwroot/AssetsClient/pages/RollCall/js/ConfirmEmployeeChange.js
2025-04-30 14:55:38 +03:30

132 lines
3.8 KiB
JavaScript

$(document).ready(function () {
$(".closeConfirmModal").on("click", function () {
$('#ConfirmEmployeeModal').hide();
});
$(".closeConfirmModal2").on("click", function () {
$('#ConfirmModal').hide();
});
// const cleave = new Cleave('.dateInput', {
// date: true,
// datePattern: ['Y', 'm', 'd'],
// });
new Cleave('.dateInput', {
date: true,
datePattern: ['Y', 'm', 'd']
});
loadEmployeeIsChangeAjax();
});
function loadEmployeeIsChangeAjax() {
var GID = $('#CommandID').val();
var htmlEmployeeItem = '';
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: loadEmployeesGroupAjax,
data: { 'groupId': Number(GID) },
headers: { "RequestVerificationToken": `${antiForgeryToken}` },
success: function (response) {
var responseDataEmployee = response.data;
if (response.success) {
if (responseDataEmployee.length > 0) {
responseDataEmployee.forEach(function (itemEmployee) {
if (itemEmployee.isShiftChanged) {
isShiftChanged = true;
htmlEmployeeItem += `<li>${itemEmployee.name}</li>`;
htmlEmployeeItem += `<input type="hidden" name="SelectedEmployeeIds[]" value="${itemEmployee.employeeId}" />`;
}
});
$('#loadEmployeeItem').html(htmlEmployeeItem);
} else {
isShiftChanged = false;
var htmlEmpty = `<div class="text-center bg-white card py-5 d-flex align-items-center justify-content-center">
<div class="">
<img src="/assetsclient/images/empty.png" alt="" class="img-fluid" />
<h5>اطلاعاتی وجود ندارد.</h5>
</div>
</div>`;
$('#loadEmployeeItem').html(htmlEmpty);
}
}
},
failure: function (response) {
console.log(5, response);
}
});
}
function ajaxConfirm() {
$('#ConfirmModal').show();
employeeList();
}
function employeeList() {
var htmlEmployeeList = ``;
var isChange = $('.modal2:checked').val();
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: ajaxEmployeesHaveToChangeUrl,
data: { 'groupId': groupId, 'isChange': isChange },
headers: { "RequestVerificationToken": `${antiForgeryToken}` },
success: function (response) {
var employeeList = response.data;
var index = 1;
if (response.success) {
employeeList.forEach(function (item) {
htmlEmployeeList += `<div class="TaleRowCell d-flex w-100 justify-content-between align-items-center px-3 " style="background: #F1FFFF; height: 49px; border-radius: 5px">
<div class="d-flex align-items-center gap-3">
<span class="btn-card">${index++}</span>
<span style="color: #0B5959; font-size: 14px; font-weight: 400; text-align: right">${item.name}</span>
</div>
<input type="hidden" name="EmployeeId[]" value="${item.employeeId}" />
<input type="text" class="form-control m-0 py-0 dateInput"
name="FromDate[]"
value=""
style="width: 120px; height: 36px; text-align: center; font-size: 16px; color: #5C5C5C; font-weight: 500; border: 2px solid #C6C6C6; direction: ltr" />
</div>`;
});
$('#employeeTable').html(htmlEmployeeList);
$('.dateInput').each(function () {
new Cleave(this, {
date: true,
datePattern: ['Y', 'm', 'd']
});
$(this).val(dateNow);
});
}
},
failure: function (response) {
console.log(5, response);
}
});
}
$('#initialDateInput').on('input', function () {
new Cleave('.dateInput', {
date: true,
datePattern: ['Y', 'm', 'd']
});
$('.dateInput').val($(this).val());
});