Files
Backend-Api/ServiceHost/wwwroot/AssetsAdminNew/RollCall/js/CurrentDay.js

252 lines
11 KiB
JavaScript

$(document).ready(function () {
$('.loadingButton').on('click', function () {
var button = $(this);
var loadingDiv = button.find('.loading');
loadingDiv.show();
});
$(document).on('click', ".openAction", function () {
$(this).next().find(".operations-btns").slideToggle(500);
$(".operations-btns").not($(this).next().find(".operations-btns")).slideUp(500);
});
$(document).on('click', ".btnRollCallStatus", function () {
var index = $(this).index();
$('.btnRollCallStatus').removeClass('active');
$(this).addClass('active');
});
loadRollCallStatus('all');
loadRollCallCount();
// --------------------------------------------- search
$('#search').on('keyup', function () {
let searchValue = $(this).val().toLowerCase();
$('.employee-row').filter(function () {
$(this).toggle($(this).find('.employee-name').text().toLowerCase().includes(searchValue));
});
$('.absenceItem-row').filter(function () {
$(this).toggle($(this).find('.employee-name').text().toLowerCase().includes(searchValue));
});
$('.leaveItem-row').filter(function () {
$(this).toggle($(this).find('.employee-name').text().toLowerCase().includes(searchValue));
});
updateIndexes();
if ($(this).val().length > 0) {
$('#clear-search').removeClass('d-none').addClass('d-flex');
} else {
$('#clear-search').removeClass('d-flex').addClass('d-none');
}
});
$('#clear-search').on('click', function () {
$('#search').val('');
$('.employee-row, .absenceItem-row, .leaveItem-row').show();
updateIndexes();
$(this).removeClass('d-flex').addClass('d-none');
});
function updateIndexes() {
let index = 1;
$('.employee-row:visible .table-number').each(function () {
$(this).text(index++);
});
$('.absenceItem-row:visible .table-number').each(function () {
$(this).text(index++);
});
$('.leaveItem-row:visible .table-number').each(function () {
$(this).text(index++);
});
}
});
function loadRollCallCount() {
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
data: { workshopId: wpId },
url: `${loadRollCallAbsentLeaveCountAjax}`,
headers: { "RequestVerificationToken": `${antiForgeryToken}` },
success: function (response) {
$('#leaveCount').text(response.leaveEmployeesCount);
$('#absentCount').text(response.absentEmployeesCount);
},
failure: function (response) {
console.log(response);
}
});
}
function loadRollCallStatus(type) {
var index = 1;
var html = '';
let colorDivStyle = '';
switch (type) {
case "leave":
colorDivStyle = "leaveItem";
break;
case "absent":
colorDivStyle = "absenceItem";
break;
default:
colorDivStyle = "";
}
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: `${loadRollCallMoreAjax}`,
data: {
type: type,
workshopId: wpId
},
headers: { "RequestVerificationToken": `${antiForgeryToken}` },
success: function (response) {
console.log(response);
var responseData = response.data;
if (responseData.length > 0) {
responseData.forEach(function (item) {
// html += `<div class="Rtable-row Rtable-row--head align-items-center">
// <div class="Rtable-cell column-heading d-block width1">ردیف</div>
// <div class="Rtable-cell column-heading d-block width6">تاریخ ایجاد</div>
// <div class="Rtable-cell column-heading d-block width3">تاریخ سررسید</div>
// <div class="Rtable-cell column-heading d-block width4">طرف حساب</div>
// <div class="Rtable-cell column-heading d-block width5">عنوان وظیفه</div>
// <div class="Rtable-cell column-heading d-block width7 text-end">عملیات</div>
//</div>`;
html += `<div></div>
<div class="Rtable-row align-items-center position-relative openAction ${colorDivStyle}">
<div class="Rtable-cell width1" style="width:5%">
<div class="Rtable-cell--heading d-none">
ردیف
</div>
<div class="Rtable-cell--content">
<div class="d-flex justify-content-center align-items-center table-number">
${index++}
</div>
</div>
</div>
<div class="Rtable-cell width2" style="width:30%">
<div class="Rtable-cell--content text-start" style="overflow:hidden; display: inline; text-overflow: ellipsis; white-space: nowrap; line-height: 30px;">
${item.employeeFullName}
</div>
</div>`;
if (type !== "all") {
html += `<div class="Rtable-cell width2" style="width:5%">
<div class="Rtable-cell--content text-start" style="overflow:hidden; display: inline; text-overflow: ellipsis; white-space: nowrap; line-height: 30px;">
<div class="">شماره پرسنلی: ${item.personnelCode}</div>
</div>
</div>`;
}
if (type === "all") {
html += `<div class="width3" style="width:1%;border-right: 1px dashed #CACACA;padding: 7px;">-</div>`;
html += `<div class="width3" style="width:18%">`;
item.rollCallTimesList.forEach(function (itemTime) {
html += `<div style="direction: ltr;" class="Rtable-cell--content d-block text-center">
<div>${itemTime.startDate}</div>
</div>`;
});
html += `</div>`;
html += `<div class="width4" style="width:18%">`;
item.rollCallTimesList.forEach(function (itemTime) {
html += `<div style="direction: ltr;" class="Rtable-cell--content d-block text-center">
<div>${itemTime.endDate == null ? "-" : itemTime.endDate}</div>
</div>`;
});
html += `</div>`;
html += `<div class="width3" style="width:1%;border-left: 1px dashed #CACACA;padding: 7px;">-</div>`;
html += `<div class="Rtable-cell d-md-none d-block width6 text-end" style="width:10%">
<button class="btn-rollcall-more position-relative">
<span class="align-items-center d-flex justify-content-center">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16" fill="currentColor">
<circle cx="8.4001" cy="8.39922" r="1.2" transform="rotate(90 8.4001 8.39922)"/>
<circle cx="8.4001" cy="4.39922" r="1.2" transform="rotate(90 8.4001 4.39922)"/>
<circle cx="8.4001" cy="12.3992" r="1.2" transform="rotate(90 8.4001 12.3992)"/>
</svg>
</span>
</button>
</div>`;
}
html += `</div>`;
if (type === "all") {
const hasLastEndDate = item.rollCallTimesList.map(itemTime => itemTime.endDate).filter(endDate => endDate === null).pop() !== undefined;
html += `<div class="operation-div d-md-none d-block w-100">
<div class="operations-btns rollcall-operations-mobile">
<div class="row align-items-center">
<div class="col-6">
<div class="d-md-none d-flex align-items-center position-relative">
<div class="Rtable-cell--content">
شماره پرسنل: ${item.personnelCode}
</div>
</div>
</div>
<div class="col-6">
<div class="d-md-none d-flex align-items-center position-relative">
<div class="Rtable-cell--content">
مجموع ساعات کارکرد: ${hasLastEndDate
? `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 12L18.1254 16.1694C18.6725 16.5418 19 17.1608 19 17.8227V20.5C19 20.7761 18.7761 21 18.5 21H5.5C5.22386 21 5 20.7761 5 20.5V17.8227C5 17.1608 5.32746 16.5418 5.87462 16.1694L12 12ZM12 12L18.1254 7.83062C18.6725 7.45819 19 6.83917 19 6.17729V3.5C19 3.22386 18.7761 3 18.5 3H5.5C5.22386 3 5 3.22386 5 3.5V6.17729C5 6.83917 5.32746 7.45819 5.87462 7.83062L12 12Z" stroke="#13AEAE" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M15 20.2071V20.85C15 20.9328 14.9328 21 14.85 21H9.15C9.06716 21 9 20.9328 9 20.85V20.2071C9 20.0745 9.05268 19.9473 9.14645 19.8536L11.4343 17.5657C11.7467 17.2533 12.2533 17.2533 12.5657 17.5657L14.8536 19.8536C14.9473 19.9473 15 20.0745 15 20.2071Z" fill="#13AEAE"/>
<path d="M12 11L17 8H7L12 11Z" fill="#13AEAE"/>
<path d="M12 18V12" stroke="#13AEAE" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`
: `${item.totalWorkingHours}`
}
</div>
</div>
</div>
</div>
</div>
</div>
</div>`;
}
});
} else {
html += `<div class="text-center bg-white d-flex align-items-center justify-content-center">
<div class="">
<img src="/assetsclient/images/empty.png" alt="" class="img-fluid" />
<h5>اطلاعاتی وجود ندارد.</h5>
</div>
</div>`;
}
$('#loadRollCallTypeAjax').html(html);
},
failure: function (response) {
console.log(response);
}
});
}