217 lines
7.5 KiB
JavaScript
217 lines
7.5 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', {
|
|
delimiters: ['/', '/'],
|
|
blocks: [4, 2, 2],
|
|
numericOnly: true
|
|
});
|
|
|
|
// 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);
|
|
}
|
|
});
|
|
}
|
|
|
|
var getChangedGlobal = false;
|
|
function ajaxConfirm() {
|
|
var isYesCheck = $('#YesConfirm').is(':checked');
|
|
if (isYesCheck) {
|
|
getChangedGlobal = true;
|
|
//$('#ConfirmModal').show();
|
|
} else {
|
|
getChangedGlobal = false;
|
|
//postChangeEditGroup();
|
|
}
|
|
|
|
$('#ConfirmModal').show();
|
|
saveDataLocal();
|
|
employeeList();
|
|
}
|
|
|
|
|
|
function employeeList() {
|
|
var htmlEmployeeList = ``;
|
|
var isChange = $('.modal2:checked').val();
|
|
|
|
$.ajax({
|
|
async: false,
|
|
contentType: 'charset=utf-8',
|
|
dataType: 'json',
|
|
type: 'GET',
|
|
url: ajaxEmployeesForRecalculateValuesUrl,
|
|
data: { 'groupId': groupId, 'getChanged': getChangedGlobal },
|
|
headers: { "RequestVerificationToken": `${antiForgeryToken}` },
|
|
success: function (response) {
|
|
var employeeList = response.data;
|
|
var index = 1;
|
|
if (response.success) {
|
|
if (employeeList.length > 0) {
|
|
employeeList.forEach(function(item) {
|
|
htmlEmployeeList +=
|
|
`<div class="TaleRowCell d-flex w-100 justify-content-between align-items-center px-2 " style="background: #F1FFFF; height: 45px; border-radius: 7px;border: 1px solid #D2D2D2">
|
|
<div class="d-flex align-items-center gap-3 noselect">
|
|
<span class="btn-card noselect">${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}" />
|
|
|
|
<div class="d-flex align-items-center justify-content-center gap-1">
|
|
<input type="text" class="form-control m-0 py-0 dateInput"
|
|
name="FromDate[]"
|
|
value=""
|
|
style="width: 110px; height: 30px; text-align: center; font-size: 14px; color: #5C5C5C; font-weight: 500; border: 2px solid #C6C6C6; direction: ltr" />
|
|
|
|
<div class="d-flex align-items-center justify-content-center cusRemove">
|
|
<svg width="21" height="21" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
<rect width="16.5" height="16.5" transform="translate(0.25 0.214844)" fill="#F2B3B3"/>
|
|
<path d="M6.78125 10.1836L6.78125 8.12109" stroke="#F63D3D" stroke-linecap="round"/>
|
|
<path d="M10.2188 10.1836L10.2187 8.12109" stroke="#F63D3D" stroke-linecap="round"/>
|
|
<path d="M2.3125 4.68359H14.6875V4.68359C14.3101 4.68359 14.1214 4.68359 13.9635 4.70899C13.1117 4.84606 12.4437 5.514 12.3066 6.36588C12.2812 6.52372 12.2812 6.71243 12.2812 7.08984V9.83984C12.2812 11.5137 12.2812 12.3506 11.8116 12.9088C11.7378 12.9965 11.6566 13.0776 11.5689 13.1514C11.0107 13.6211 10.1738 13.6211 8.5 13.6211V13.6211C6.82618 13.6211 5.98926 13.6211 5.43109 13.1514C5.34339 13.0776 5.2622 12.9965 5.18842 12.9088C4.71875 12.3506 4.71875 11.5137 4.71875 9.83984V7.08984C4.71875 6.71243 4.71875 6.52372 4.69335 6.36588C4.55628 5.514 3.88835 4.84606 3.03647 4.70899C2.87862 4.68359 2.68992 4.68359 2.3125 4.68359V4.68359Z" stroke="#F63D3D" stroke-linecap="round"/>
|
|
<path d="M6.78125 2.62126C6.78125 2.62126 7.125 1.93359 8.5 1.93359C9.875 1.93359 10.2188 2.62109 10.2188 2.62109" stroke="#F63D3D" stroke-linecap="round"/>
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
});
|
|
|
|
$('#employeeTable').html(htmlEmployeeList);
|
|
|
|
|
|
$('.dateInput').each(function() {
|
|
new Cleave(this,
|
|
{
|
|
delimiters: ['/', '/'],
|
|
blocks: [4, 2, 2],
|
|
numericOnly: true
|
|
});
|
|
// new Cleave(this, {
|
|
// date: true,
|
|
// datePattern: ['Y', 'm', 'd']
|
|
// });
|
|
|
|
$(this).val(dateNow);
|
|
});
|
|
} else {
|
|
$('#ConfirmModal').hide();
|
|
ajaxSaveSubmit();
|
|
}
|
|
|
|
}
|
|
},
|
|
failure: function (response) {
|
|
console.log(5, response);
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#initialDateInput').on('input', function () {
|
|
$('.dateInput').mask('0000/00/00');
|
|
//new Cleave('.dateInput', {
|
|
// delimiters: ['/', '/'],
|
|
// blocks: [4, 2, 2],
|
|
// numericOnly: true
|
|
//});
|
|
// new Cleave('.dateInput', {
|
|
// date: true,
|
|
// datePattern: ['Y', 'm', 'd']
|
|
// });
|
|
$('.dateInput').val($(this).val());
|
|
});
|
|
|
|
$(document).on('click', '.cusRemove', function () {
|
|
$(this).closest('.TaleRowCell').remove();
|
|
updateRowIndexes();
|
|
});
|
|
|
|
function updateRowIndexes() {
|
|
$('.btn-card').each(function (index) {
|
|
$(this).text(index + 1);
|
|
});
|
|
}
|
|
function updateListEmployeeOrderByCheckout(paidIds = []) {
|
|
const rows = [];
|
|
|
|
$('#employeeTable .TaleRowCell').each(function () {
|
|
const $row = $(this);
|
|
const employeeId = parseInt($row.find('input[name="EmployeeId[]"]').val());
|
|
const isPaid = paidIds.includes(employeeId);
|
|
|
|
if (isPaid) {
|
|
$row.addClass('hasPaySlip');
|
|
} else {
|
|
$row.removeClass('hasPaySlip');
|
|
}
|
|
|
|
rows.push({ element: $row, isPaid });
|
|
});
|
|
|
|
rows.sort((a, b) => b.isPaid - a.isPaid);
|
|
|
|
$('#employeeTable').empty();
|
|
rows.forEach(({ element }) => {
|
|
$('#employeeTable').append(element);
|
|
});
|
|
|
|
updateRowIndexes();
|
|
} |