Files
Backend-Api/ServiceHost/wwwroot/AssetsAdminNew/WorkFlow/js/EmployeesDocuments.js
2025-02-18 16:16:33 +03:30

493 lines
25 KiB
JavaScript

var lengthMenu = 0;
var loadFunctionDocumentsAwaitingUpload = true;
var loadFunctionCut = true;
var loadFunctionLunchBreak = true;
var loadFunctionUndefined = true;
var loadFunctionOverlappingLeaves = true;
loadMenuAnime();
$(document).ready(function () {
//CountWorkFlowOfAbsentAndCut();
loadWorkshopsWithDocumentsAwaitingUpload();
$("#clickDocumentsAwaitingUploadTab").click(function () {
//$('.cutWorkFlowLists, .lunchBreakWorkFlowLists, .undefinedWorkFlowLists, .overlappingLeavesLists').fadeOut(200, function () {
// $('.DocumentsAwaitingUploadWorkFlowLists').fadeIn(200);
//});
if (loadFunctionDocumentsAwaitingUpload) {
loadWorkshopsWithDocumentsAwaitingUpload();
}
});
});
function loadMenuAnime() {
var tabsNewAnim = $('#navbar-animmenu');
var selectorNewAnim = $('#navbar-animmenu').find('li').length;
var activeItemNewAnim = tabsNewAnim.find('.active');
var activeHeightNewAnimHeight = activeItemNewAnim.innerHeight();
var itemPosNewAnimTop = activeItemNewAnim.position();
$(".verti-selector").css({
"top": itemPosNewAnimTop.top + "px",
"height": activeHeightNewAnimHeight + "px"
});
$('.active').each(function () {
var targetForm = $(this).data('target');
$('#' + targetForm).show();
});
if (lengthMenu === 1) {
if ($('.main-navbar li').hasClass('lastRole')) {
$('.verti-selector .top').addClass('last-role');
$('#hideCircle').css('border-radius', '25px 0 0 0');
} else {
$('.verti-selector .top').removeClass('last-role');
$('#hideCircle').css('border-radius', '0 0 0 0');
}
}
$("#navbar-animmenu").on("click", "li", function (e) {
if ($(this).hasClass('lastRole')) {
//$('.verti-selector .top').addClass('last-role');
$('#hideCircle').css('border-radius', '25px 0 0 0');
} else {
//$('.verti-selector .top').removeClass('last-role');
$('#hideCircle').css('border-radius', '0 0 0 0');
}
$('#navbar-animmenu ul li').removeClass("active");
$(this).addClass('active');
var activeHeightNewAnimHeight = $(this).innerHeight();
var itemPosNewAnimTop = $(this).position();
$(".verti-selector").css({
"top": itemPosNewAnimTop.top + "px",
"height": activeHeightNewAnimHeight + "px"
});
$('.form-section').hide();
$('.accountListHead').text($(this).find('a').text());
var targetForm = $(this).data('target');
$('#' + targetForm).show();
});
//$("#navbar-animmenu").on("click", "li", function (e) {
// var targetForm = $(this).data('target');
// $('#navbar-animmenu ul li').removeClass("active");
// $(this).addClass('active');
// var activeHeightNewAnimHeight = $(this).innerHeight();
// var itemPosNewAnimTop = $(this).position();
// $(".verti-selector").stop(true, true).animate({
// "top": itemPosNewAnimTop.top + "px",
// "height": activeHeightNewAnimHeight + "px"
// }, 300); // انیمیشن با مدت زمان 300 میلی‌ثانیه
// $('.form-section').fadeOut(200);
// $('#' + targetForm).fadeIn(300); // انیمیشن تغییر صفحه
//});
}
$(document).on('click', ".openActionMain", function () {
$('.toggle').not($(this).find('.toggle')).removeClass('open');
$(this).next().find(".operations-btns-main").slideToggle(500);
$(".operations-btns-main").not($(this).next().find(".operations-btns-main")).slideUp(500);
$(this).find('.toggle').toggleClass('open');
});
$(document).on('click', ".openAction", function () {
if (window.matchMedia('(max-width: 768px)').matches) {
$(this).next().find(".operations-btns").slideToggle(500);
$(".operations-btns").not($(this).next().find(".operations-btns")).slideUp(500);
}
});
async function loadWorkshopsWithDocumentsAwaitingUpload() {
$('#CountDocumentsAwaitingUploadLoading').show();
var mainIndexNum = 1;
var html = ``;
$.ajax({
//async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: loadWorkshopsWithDocumentsAwaitingUploadUrl,
headers: { "RequestVerificationToken": antiForgeryToken },
success: function (response) {
var data = response.data;
$('#loadingSkeletonDocumentsAwaitingUpload').hide();
if (response.success) {
if (data.length > 0) {
data.forEach(function (item) {
html += `
<div id="Main_${item.workshopId}" class="Rtable-row Rtable-row--head align-items-center d-flex sticky openActionMain" onclick="loadByWorkshopIdWithItemsForAdminWorkFlow('${item.workshopId}')" style="background: #58B3B3;border: none !important; cursor: pointer; ">
<div class="col-2 col-md-4 text-start">
<div class="Rtable-cell width1">
<div class="Rtable-cell--content">
<span class="d-flex justify-content-center align-items-center justify-content-center table-number" style="background: #deffff;margin: 0 10px 0 0;">
${mainIndexNum++}
</span>
</div>
</div>
</div>
<div class="col-8 col-md-4 text-center d-flex">
<div class="col-4 text-center">
<div class="Rtable-cell column-heading text-end">
<span>${item.workshopName}</span>
</div>
</div>
<div class="col-4 text-start">
<div class="Rtable-cell column-heading text-center justify-content-center">
<span>${item.employerName}</span>
</div>
</div>
<div class="col-4 text-center">
<div class="Rtable-cell column-heading text-center justify-content-center">
<span id="EmployeeCountOfWorkshop_${item.workshopId}" class="number-of-count">${item.uploadItemsCount}</span>
</div>
</div>
</div>
<div class="col-2 col-md-4 text-end">
<span class="toggle">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15 18L9 12L15 6" stroke-width="2" stroke-linecap="round" />
</svg>
</span>
</div>
</div>`;
html += `<div class="w-100 operation-div">
<div id="DocumentsAwaitingUpload_${item.workshopId}" class="operations-btns-main workshopID_${item.workshopId}" style="padding: 1px 10px 0 10px; background: rgb(255, 255, 255); box-shadow: none;width: 100%;">
</div></div>`;
});
} else {
html += `<div class="container-fluid">
<div class="row p-lg-2 p-auto">
<div class="text-center bg-white d-flex align-items-center justify-content-center w-100">
<div class="">
<img src="/assetsclient/images/empty.png" alt="" class="img-fluid" />
<h5>اطلاعاتی وجود ندارد.</h5>
</div>
</div>
</div>
</div>`;
}
$('#loadDocumentsAwaitingUploadWorkFlow').html(html);
loadFunctionDocumentsAwaitingUpload = false;
}
},
failure: function (response) {
console.log(response);
}
});
}
function loadByWorkshopIdWithItemsForAdminWorkFlow(id) {
var html = ``;
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: loadByWorkshopIdWithItemsForAdminWorkFlowUrl,
data: { 'workshopId': id },
headers: { "RequestVerificationToken": antiForgeryToken },
success: function (response) {
var data = response.data;
if (response.success) {
if (data.length > 0) {
data.forEach(function (item, i) {
html += `<div></div>
<div class="Rtable-row align-items-center position-relative workflow-list employee-row" data-employee-id="${item.employeeId}">
<div class="Rtable-cell width1">
<div class="Rtable-cell--heading d-none">
ردیف
</div>
<div class="Rtable-cell--content">
<span class="d-flex justify-content-center align-items-center justify-content-center table-number">
${i + 1}
</span>
</div>
</div>
<div class="Rtable-cell width2">
<div class="Rtable-cell--heading d-none">نام پرسنل</div>
<div class="Rtable-cell--content employee-name">
${item.employeeFullName}
<p class="m-0 mt-2 d-block d-md-none"></p>
</div>
</div>
<div class="Rtable-cell width3 d-none d-md-block">
<div class="Rtable-cell--content text-center">
<div class="d-flex justify-content-center ms-1">
<div>
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.employeePicture.picturePath) {
html += `<img id="employeePicture_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.employeePicture.picturePath ? item.employeePicture.picturePath : "")}" class="preview-image">`;
} else {
html += `<img id="employeePicture_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/ >`;
}
html += `</div>
<div class="txtMonilePD">عکس پرسنلی</div>
</div>
</div>
</div>
</div>
</div>
<div class="Rtable-cell width4 d-none d-md-block">
<div class="Rtable-cell--content text-center">
<div class="d-flex justify-content-center gap-1 ms-1">
<div>
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.nationalCardFront.picturePath) {
html += `<img id="nationalCardFront_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.nationalCardFront.picturePath ? item.nationalCardFront.picturePath : "")}" class="preview-image">`;
} else {
html += `<img id="nationalCardFront_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/>`;
}
html += `</div>
<div class="txtMonilePD">کارت ملی رو</div>
</div>
</div>
<div>
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.nationalCardRear.picturePath) {
html += `<div class="documentFileBox"><img id="nationalCardRear_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.nationalCardRear.picturePath ? item.nationalCardRear.picturePath : "")}" class="preview-image"></div>`;
} else {
html += `<div class="documentFileBox"><img id="nationalCardRear_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
html += `</div>
<div class="txtMonilePD">کارت ملی پشت</div>
</div>
</div>
</div>
</div>
</div>
<div class="Rtable-cell width5 d-none d-md-block">
<div class="Rtable-cell--content text-center">
<div class="d-flex justify-content-center ms-1">
<div>
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.militaryServiceCard.picturePath) {
html += `<img id="militaryServiceCard_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.militaryServiceCard.picturePath ? item.militaryServiceCard.picturePath : "")}" class="preview-image">`;
} else {
html += `<img id="militaryServiceCard_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/>`;
}
html += `</div>
<div class="txtMonilePD">کارت پایان خدمت</div>
</div>
</div>
</div>
</div>
</div>
<div class="Rtable-cell width6 d-none d-md-block">
<div class="Rtable-cell--content text-center">
<div class="d-md-none d-none">پیغام: </div>
<div class="d-flex justify-content-center gap-1 ms-1">
<div class="">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.idCardPage1.picturePath) {
html += `<div class="documentFileBox"><img id="idCardPage1_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage1.picturePath ? item.idCardPage1.picturePath : "")}" class="preview-image"></div>`;
} else {
html += `<div class="documentFileBox"><img id="idCardPage1_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
html += `</div>
<div class="txtMonilePD">شناسنامه صفحه اول</div>
</div>
</div>
<div class="">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.idCardPage2.picturePath) {
html += `<div class="documentFileBox"><img id="idCardPage2_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage2.picturePath ? item.idCardPage2.picturePath : "")}" class="preview-image"></div>`;
} else {
html += `<div class="documentFileBox"><img id="idCardPage2_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
html += `</div>
<div class="txtMonilePD">شناسنامه صفحه دوم</div>
</div>
</div>
<div class="">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.idCardPage3.picturePath) {
html += `<div class="documentFileBox"><img id="idCardPage3_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage3.picturePath ? item.idCardPage3.picturePath : "")}" class="preview-image"></div>`;
} else {
html += `<div class="documentFileBox"><img id="idCardPage3_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
html += `</div>
<div class="txtMonilePD">شناسنامه صفحه سوم</div>
</div>
</div>
<div class="">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.idCardPage4.picturePath) {
html += `<div class="documentFileBox"><img id="idCardPage4_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage4.picturePath ? item.idCardPage4.picturePath : "")}" class="preview-image"></div>`;
} else {
html += `<div class="documentFileBox"><img id="idCardPage4_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
html += `</div>
<div class="txtMonilePD">شناسنامه صفحه چهارم</div>
</div>
</div>
</div>
</div>
</div>
<div class="Rtable-cell position-relative width7 bg-filter d-flex justify-content-end">
<div class="Rtable-cell--content text-center d-block d-md-flex align-items-center gap-1 h-100">
<button class="btn-workflow-rollcall-edit position-relative" onclick="showModalEmployeeDocuments(${item.employeeId}, '${id}')">
<span class="mx-1">عملیات</span>
</button>
</div>
</div>
</div>`;
});
} else {
html += `<div class="container-fluid">
<div class="row p-lg-2 p-auto">
<div class="text-center bg-white d-flex align-items-center justify-content-center w-100">
<div class="">
<img src="/assetsclient/images/empty.png" alt="" class="img-fluid" />
<h5>اطلاعاتی وجود ندارد.</h5>
</div>
</div>
</div>
</div>`;
}
$(`.workshopID_${id}`).html(html);
}
},
failure: function (response) {
console.log(response);
}
});
}
function showModalEmployeeDocuments(employeeId, workshopId) {
var goTo = `#showmodal=/AdminNew/Company/WorkFlow/EmployeesDocuments?handler=CreateUploadDocument&workshopId=${workshopId}&employeeId=${employeeId}`;
window.location.href = goTo;
}
async function CountWorkFlow() {
$.ajax({
dataType: 'json',
type: 'Get',
url: loadCountWorkFlowOfAbsentAndCut,
headers: { "RequestVerificationToken": antiForgeryToken },
success: function (response) {
if (response.success) {
$('.spinner-grow').hide();
if (response.dataAbsent === 0) {
$('#CountAbsent').hide();
$('#CountAbsentMobile').hide();
} else {
$('#CountAbsent').show();
$('#CountAbsentMobile').show();
$('#CountAbsent').text(response.dataAbsent);
$('#CountAbsentMobile').text(response.dataAbsent);
}
if (response.dataCut === 0) {
$('#CountCut').hide();
$('#CountCutMobile').hide();
} else {
$('#CountCut').show();
$('#CountCutMobile').show();
$('#CountCut').text(response.dataCut);
$('#CountCutMobile').text(response.dataCut);
}
if (response.dataLunchBreak === 0) {
$('#CountLunchBreak').hide();
$('#CountLunchBreakMobile').hide();
} else {
$('#CountLunchBreak').show();
$('#CountLunchBreakMobile').show();
$('#CountLunchBreak').text(response.dataLunchBreak);
$('#CountLunchBreakMobile').text(response.dataLunchBreak);
}
if (response.dataUndefined === 0) {
$('#CountUndefined').hide();
$('#CountUndefinedMobile').hide();
} else {
$('#CountUndefined').show();
$('#CountUndefinedMobile').show();
$('#CountUndefined').text(response.dataUndefined);
$('#CountUndefinedMobile').text(response.dataUndefined);
}
if (response.dataOverlappingLeave === 0) {
$('#CountOverlappingLeave').hide();
$('#CountOverlappingLeaveMobile').hide();
} else {
$('#CountOverlappingLeave').show();
$('#CountOverlappingLeaveMobile').show();
$('#CountOverlappingLeave').text(response.dataOverlappingLeave);
$('#CountOverlappingLeaveMobile').text(response.dataOverlappingLeave);
}
} else {
$('.alert-msg').show();
$('.alert-msg p').text(response.message);
setTimeout(function () {
$('.alert-msg').hide();
$('.alert-msg p').text('');
}, 3500);
}
},
error: function (err) {
console.log(err);
}
});
}
function updateIndexesWorkFlow(dateDiv) {
let index = 1;
$(`#${dateDiv} .employee-row:visible .table-number`).each(function () {
$(this).text(index++);
});
}
function updateMainWorkFlow() {
let index = 1;
$(`#loadDocumentsAwaitingUploadWorkFlow .Rtable-cell.width1 .table-number`).each(function () {
$(this).text(index++);
});
}