274 lines
15 KiB
JavaScript
274 lines
15 KiB
JavaScript
$(document).ready(function () {
|
|
$(document).on('click', ".openAction", function () {
|
|
var id = $(this).data('index');
|
|
|
|
if (window.matchMedia('(max-width: 767px)').matches) {
|
|
$(this).next().find(".operations-btns").slideToggle(500);
|
|
$(".operations-btns").not($(this).next().find(".operations-btns")).slideUp(500);
|
|
}
|
|
|
|
loadEmployeeAjax(id);
|
|
$(`.openAction`).removeClass('active');
|
|
$(this).addClass('active');
|
|
});
|
|
|
|
loadDataAjax();
|
|
});
|
|
|
|
function loadDataAjax() {
|
|
var html = "";
|
|
var index = 0;
|
|
$.ajax({
|
|
async: false,
|
|
contentType: 'charset=utf-8',
|
|
dataType: 'json',
|
|
type: 'GET',
|
|
url: loadWorkshopSettingsDataAjax,
|
|
headers: { "RequestVerificationToken": `${antiForgeryToken}` },
|
|
success: function (response) {
|
|
var responseData = response.data;
|
|
|
|
if (responseData.groupSettings.length > 0) {
|
|
responseData.groupSettings.forEach(function(item, indexItem) {
|
|
index = index + 1;
|
|
|
|
html += `
|
|
<div class="p-2 rounded-3 d-flex align-items-center justify-content-between w-100 btnPosition openAction ${
|
|
indexItem === 0 ? 'active' : ''}" data-index="${item.id}">
|
|
<div class="width1">
|
|
<span class="d-none" id="groupSettingsId">${item.id}</span>
|
|
<span class="row-index1">${index}</span>
|
|
</div>
|
|
|
|
<div class="title-group1 width2">
|
|
<p class="m-0 d-block d-md-none">نام گروه:</p>
|
|
<p class="m-0">${item.groupName}</p>
|
|
</div>
|
|
<div class="title-group1 text-center d-none d-md-block width3">`;
|
|
|
|
if (item.workshopShiftStatus === 0) {
|
|
item.rollCallWorkshopShifts.forEach(function (itemShifts) {
|
|
html += `
|
|
<p class="m-0 time-set-title">
|
|
<span style="width: 46px;display: inline-block;">${itemShifts.startTime}</span>
|
|
الی
|
|
<span style="width: 46px;display: inline-block;">${itemShifts.endTime}</span>
|
|
</p>
|
|
`;
|
|
});
|
|
} else {
|
|
html += `<p class="m-0 time-set-title">`;
|
|
if (item.irregularShift.workshopIrregularShifts === 1) {
|
|
html += `<span>12-24</span>`;
|
|
} else if (item.irregularShift.workshopIrregularShifts === 2) {
|
|
html += `<span>24-24</span>`;
|
|
} else if (item.irregularShift.workshopIrregularShifts === 3) {
|
|
html += `<span>12-36</span>`;
|
|
} else if (item.irregularShift.workshopIrregularShifts === 4) {
|
|
html += `<span>24-48</span>`;
|
|
}
|
|
|
|
html += `</p>`;
|
|
}
|
|
|
|
html += `</div>
|
|
<div class="title-group1 text-center d-none d-md-block width4">
|
|
<p class="m-0 d-block d-md-none text-center">حقوق</p>
|
|
<p class="m-0">
|
|
${item.salary.toLocaleString() !== 0 ? item.salary.toLocaleString() + ` ریال` : `-`}
|
|
</p>
|
|
</div>
|
|
<div class="d-flex align-items-center justify-content-end gap-1 width5">
|
|
<button type="button" class="btn-setting" onclick="showModalGroupSetting(${item.id})">
|
|
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke="#475569" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z" />
|
|
<path stroke-linecap="round" stroke="#475569" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="operation-div w-100 d-block d-md-none" style="margin: -5px 0 0 0;">
|
|
<div class="operations-btns px-2" id="loadEmployeeItemsMobile_${item.id}">
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
if (indexItem === 0) {
|
|
loadEmployeeAjax(item.id);
|
|
}
|
|
});
|
|
|
|
$('#ajaxDataMain').html(html);
|
|
} else {
|
|
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>`;
|
|
|
|
$('#ajaxDataMain').html(htmlEmpty);
|
|
$('#loadAccountItems').html(htmlEmpty);
|
|
}
|
|
},
|
|
failure: function (response) {
|
|
console.log(5, response);
|
|
}
|
|
});
|
|
}
|
|
|
|
function loadEmployeeAjax(groupSettingId) {
|
|
var htmlEmployee = "";
|
|
$(`#loadEmployeeItemsMobile_${groupSettingId}`).html('');
|
|
|
|
var indexEmployee = 1;
|
|
$.ajax({
|
|
async: false,
|
|
contentType: 'charset=utf-8',
|
|
dataType: 'json',
|
|
type: 'GET',
|
|
url: loadEmployeesGroupAjax,
|
|
data: { 'groupId': groupSettingId },
|
|
headers: { "RequestVerificationToken": `${antiForgeryToken}` },
|
|
success: function (response) {
|
|
var responseDataEmployee = response.data;
|
|
|
|
if (response.success) {
|
|
if (responseDataEmployee.length > 0) {
|
|
htmlEmployee += `
|
|
<div>
|
|
<div class="col-12 col-md-6 col-lg-3 mt-2 mb-2">
|
|
<input type="text" class="form-control" id="searchEmployee" placeholder="جستجو ..." />
|
|
</div>
|
|
</div>`;
|
|
|
|
responseDataEmployee.forEach(function (itemEmployee) {
|
|
if (itemEmployee.isSettingChanged === true) {
|
|
isSettingChangedGlobal = true;
|
|
}
|
|
|
|
htmlEmployee += `<div></div>
|
|
<div class="my-1 Rtable-row align-items-center position-relative itemResultEmployee">
|
|
<div class="Rtable-cell width1 widthMobile1">
|
|
<div class="Rtable-cell--content">
|
|
<span class="d-flex justify-content-center row-index2">
|
|
${indexEmployee++}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="Rtable-cell width2 widthMobile2">
|
|
<div class="Rtable-cell--heading d-none">نام پرسنل:</div>
|
|
<div class="Rtable-cell--content">
|
|
<div class="d-flex d-md-none">نام پرسنل:</div>
|
|
<div class="itemEmployeeName">${itemEmployee.name} </div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="Rtable-cell width3 widthMobile2 text-center d-none d-md-block">
|
|
<div class="Rtable-cell--heading d-none">ساعت کاری:</div>
|
|
<div class="Rtable-cell--content d-flex text-center">
|
|
<div class="d-flex d-md-none mx-1">ساعت کاری: </div>
|
|
<div class="w-100">`;
|
|
if (itemEmployee.workshopShiftStatus === 0) {
|
|
itemEmployee.rollCallWorkshopShifts.forEach(function (itemEmployeeShifts) {
|
|
htmlEmployee += `
|
|
<p class="m-0 time-set-title">
|
|
<span style="width: 46px;display: inline-block;text-align: center;">${itemEmployeeShifts.startTime}</span>
|
|
الی
|
|
<span style="width: 46px;display: inline-block;text-align: center;">${itemEmployeeShifts.endTime}</span>
|
|
</p>`;
|
|
});
|
|
} else {
|
|
htmlEmployee += `<p class="m-0 time-set-title">`;
|
|
if (itemEmployee.irregularShift.workshopIrregularShifts === 1) {
|
|
htmlEmployee += `<span>12-24</span>`;
|
|
} else if (itemEmployee.irregularShift.workshopIrregularShifts === 2) {
|
|
htmlEmployee += `<span>24-24</span>`;
|
|
} else if (itemEmployee.irregularShift.workshopIrregularShifts === 3) {
|
|
htmlEmployee += `<span>12-36</span>`;
|
|
} else if (itemEmployee.irregularShift.workshopIrregularShifts === 4) {
|
|
htmlEmployee += `<span>24-48</span>`;
|
|
}
|
|
|
|
htmlEmployee += `</p>`;
|
|
}
|
|
|
|
htmlEmployee += `</div></div>
|
|
</div>
|
|
|
|
<div class="Rtable-cell width4 d-md-block d-none">
|
|
<div class="Rtable-cell--heading">حقوق</div>
|
|
<div class="Rtable-cell--content">
|
|
${itemEmployee.salary.toLocaleString() !== 0 ? itemEmployee.salary.toLocaleString() + ` ریال` : `-`}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="Rtable-cell width5 d-md-block d-none">
|
|
<div class="Rtable-cell--heading">مرخصی مجاز</div>
|
|
<div class="Rtable-cell--content text-center">
|
|
${itemEmployee.leavePermittedDays}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-flex align-items-center justify-content-end gap-1 width6 widthMobile3">
|
|
<button type="button" class="btn-setting" onclick="showModalGroupEmployeeSetting(${itemEmployee.id}, ${itemEmployee.employeeId})">
|
|
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke="#475569" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z" />
|
|
<path stroke-linecap="round" stroke="#475569" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>`;
|
|
});
|
|
|
|
$('#loadAccountItems').html(htmlEmployee);
|
|
$(`#loadEmployeeItemsMobile_${groupSettingId}`).append(htmlEmployee);
|
|
|
|
} else {
|
|
isSettingChangedGlobal = 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>`;
|
|
|
|
$('#loadAccountItems').html(htmlEmpty);
|
|
$(`#loadEmployeeItemsMobile_${groupSettingId}`).html(htmlEmpty);
|
|
}
|
|
}
|
|
},
|
|
failure: function (response) {
|
|
console.log(5, response);
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).on('keyup', '#searchEmployee', function () {
|
|
var value = $(this).val().toLowerCase();
|
|
var indexEmployee = 1;
|
|
$('.itemResultEmployee').filter(function () {
|
|
var employeeFName = $(this).find('.itemEmployeeName').text().toLowerCase();
|
|
|
|
if (employeeFName.includes(value)) {
|
|
$(this).show();
|
|
$(this).find('.row-index2').text(indexEmployee++);
|
|
} else {
|
|
$(this).hide();
|
|
}
|
|
});
|
|
});
|
|
|
|
function showModalGroupSetting(groupId) {
|
|
window.location.href = `#showmodal=/Client/Company/CustomizeCheckout/Grouping?groupId=${groupId}&handler=GroupingSetting`;
|
|
}
|
|
|
|
function showModalGroupEmployeeSetting(id, employeeIds) {
|
|
if (!Array.isArray(employeeIds)) {
|
|
employeeIds = [employeeIds];
|
|
}
|
|
var employeeIdListStr = employeeIds.map(employeeId => `employeeId=${employeeId}`).join('&');
|
|
|
|
window.location.href = `#showmodal=/Client/Company/CustomizeCheckout/Grouping?customizeEmployeeId=${id}&${employeeIdListStr}&handler=GroupingEmployeeSetting`;
|
|
} |