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

382 lines
26 KiB
JavaScript

var pageIndexJs = 0;
var pageIndex = 0;
var mode = 'active';
var searchName = '';
$(document).ready(function () {
loadPersonnelDocuments(mode, searchName);
$(document).on('click', '.btnTabPD', function () {
mode = $(this).data('mode');
$('.btnTabPD').removeClass('active');
$(this).addClass('active');
$('.btn-clear-filter').addClass('disable');
pageIndexJs = 0;
pageIndex = 0;
$('#personnelDocumentsAjax').html('');
$('.employeeName').val('');
loadPersonnelDocuments(mode, searchName = '');
});
checkImage();
});
$(document).on('click', ".openAction", function () {
if (window.matchMedia('(max-width: 767px)').matches) {
$(this).next().find(".operations-btns").slideToggle(500);
$(".operations-btns").not($(this).next().find(".operations-btns")).slideUp(500);
}
});
$(document).on('click', '.btn-uploadingPD, .btn-uploadingPD-mobile', function () {
var id = $(this).attr('id').split('_')[1];
openPersonnelDocsUploadModal(id);
});
$(document).on('click', '.btn-search-click, .btn-search-click-mobile', function () {
pageIndexJs = 0;
$('#personnelDocumentsAjax').html('');
$('.btn-clear-filter').removeClass('disable');
searchName = $('.employeeName').val().trim();
if (searchName == "") {
$('.btn-clear-filter').addClass('disable');
}
$('#searchModal').modal('hide');
loadPersonnelDocuments(mode, searchName);
});
$(document).on('click', '.btn-clear-filter', function () {
pageIndexJs = 0;
$('#personnelDocumentsAjax').html('');
$('.btn-clear-filter').addClass('disable');
$('.employeeName').val('');
$('#searchModal').modal('hide');
loadPersonnelDocuments(mode, searchName = '');
});
// When typing in the desktop search
$('.d-none.d-md-block .employeeName').on('input', function () {
var desktopInput = $(this).val();
$('#searchModal .employeeName').val(desktopInput);
});
// When typing in the mobile search
$('#searchModal .employeeName').on('input', function () {
var mobileInput = $(this).val();
$('.d-none.d-md-block .employeeName').val(mobileInput);
});
$('.goToTop').on('click',function () {
$('html, body').animate({ scrollTop: 0 }, 360);
return false;
});
$(window).scroll(function () {
if ($(window).scrollTop() + $(window).height() > $(document).height() - 600) {
loadPersonnelDocuments(mode, searchName);
}
if ($(this).scrollTop() > 100) {
$('.goToTop').show().fadeIn();
} else {
$('.goToTop').fadeOut().hide();
}
});
function loadPersonnelDocuments(mode, searchName) {
var b = pageIndexJs % 30;
var html = '';
if (b === 0) {
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: employeeDocumentsAjaxLoadData,
data: { workshopId: workshopId, searchMode: mode, employeeName: searchName, 'pageIndex': pageIndex },
headers: { "RequestVerificationToken": antiForgeryToken },
success: function (response) {
var personnelDocumentsData = response.data;
if (response.isSuccedded) {
personnelDocumentsData.forEach(function (item) {
var n = pageIndexJs + 1;
html += `<div></div>
<div class="Rtable-row align-items-center openAction ${item.isBlack === "true"
? `withdraw`
: ``}" id="Employees">
<div class="Rtable-cell width1" style="margin-left:3px; ">
<div class="Rtable-cell--content">
<span class="d-flex justify-content-center">
${n}
<div class="d-none idPersonnel">${item.employeeId}</div>
</span>
</div>
</div>
<div class="Rtable-cell width2">
<div class="Rtable-cell--content d-flex align-items-center justify-content-start">
<div class="documentFileBox d-md-none d-block" data-indexList="0">`;
if (item.employeePicture.picturePath && (item.employeePicture.statusString !== "unsubmitted" && item.employeePicture.statusString !== "rejected")) {
html += `<img id="employeePicture_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.employeePicture.picturePath ? item.employeePicture.picturePath : "")}" class="preview-image uploaded">`;
} else {
html += `<img id="employeePicture_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/>`;
}
html += `</div>
<div class="text-start">${item.employeeFullName}</div>
</div>
</div>
<div class="Rtable-cell d-md-block d-none width3">
<div class="Rtable-cell--content d-flex align-items-center justify-content-center">
<div class="documentFileBox" data-indexList="0">`;
if (item.employeePicture.picturePath && (item.employeePicture.statusString !== "unsubmitted" && item.employeePicture.statusString !== "rejected")) {
html += `<img id="employeePicture_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.employeePicture.picturePath ? item.employeePicture.picturePath : "")}" class="preview-image uploaded">`;
} else {
html += `<img id="employeePicture_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/>`;
}
html += `</div>
</div>
</div>
<div class="Rtable-cell d-md-block d-none width4">
<div class="Rtable-cell--content d-flex align-items-center justify-content-center">`;
if (item.nationalCardFront.picturePath && (item.nationalCardFront.statusString !== "unsubmitted" && item.nationalCardFront.statusString !== "rejected")) {
html += `<div class="documentFileBox" data-indexList="1"><img id="nationalCardFront_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.nationalCardFront.picturePath ? item.nationalCardFront.picturePath : "")}" class="preview-image uploaded"></div>`;
} else {
html += `<div class="documentFileBox" data-indexList="1"><img id="nationalCardFront_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
if (item.nationalCardRear.picturePath) {
html += `<div class="documentFileBox" data-indexList="2"><img id="nationalCardRear_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.nationalCardRear.picturePath ? item.nationalCardRear.picturePath : "")}" class="preview-image uploaded"></div>`;
} else {
html += `<div class="documentFileBox" data-indexList="2"><img id="nationalCardRear_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
html += `</div>
</div>
<div class="Rtable-cell d-md-block d-none width5">
<div class="Rtable-cell--content d-flex align-items-center justify-content-center">
<div class="documentFileBox" data-indexList="3">`;
if (item.militaryServiceCard.picturePath && (item.militaryServiceCard.statusString !== "unsubmitted" && item.militaryServiceCard.statusString !== "rejected")) {
html += `<img id="militaryServiceCard_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.militaryServiceCard.picturePath ? item.militaryServiceCard.picturePath : "")}" class="preview-image uploaded">`;
} else {
html += `<img id="militaryServiceCard_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/>`;
}
html += `</div>
</div>
</div>
<div class="Rtable-cell d-md-block d-none width6">
<div class="Rtable-cell--content d-flex align-items-center justify-content-center">`;
if (item.idCardPage1.picturePath && (item.idCardPage1.statusString !== "unsubmitted" && item.idCardPage1.statusString !== "rejected")) {
html += `<div class="documentFileBox" data-indexList="4"><img id="idCardPage1_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage1.picturePath ? item.idCardPage1.picturePath : "")}" class="preview-image uploaded"></div>`;
} else {
html += `<div class="documentFileBox" data-indexList="4"><img id="idCardPage1_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
if (item.idCardPage2.picturePath && (item.idCardPage2.statusString !== "unsubmitted" && item.idCardPage2.statusString !== "rejected")) {
html += `<div class="documentFileBox" data-indexList="5"><img id="idCardPage2_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage2.picturePath ? item.idCardPage2.picturePath : "")}" class="preview-image uploaded"></div>`;
} else {
html += `<div class="documentFileBox" data-indexList="5"><img id="idCardPage2_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
if (item.idCardPage3.picturePath && (item.idCardPage3.statusString !== "unsubmitted" && item.idCardPage3.statusString !== "rejected")) {
html += `<div class="documentFileBox" data-indexList="6"><img id="idCardPage3_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage3.picturePath ? item.idCardPage3.picturePath : "")}" class="preview-image uploaded"></div>`;
} else {
html += `<div class="documentFileBox" data-indexList="6"><img id="idCardPage3_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
if (item.idCardPage4.picturePath && (item.idCardPage4.statusString !== "unsubmitted" && item.idCardPage4.statusString !== "rejected")) {
html += `<div class="documentFileBox" data-indexList="7"><img id="idCardPage4_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage4.picturePath ? item.idCardPage4.picturePath : "")}" class="preview-image uploaded"></div>`;
} else {
html += `<div class="documentFileBox" data-indexList="7"><img id="idCardPage4_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/></div>`;
}
html += `</div>
</div>
<div class="Rtable-cell d-md-block d-none width7">
<div class="Rtable-cell--content text-end">
<button id="editPD_${item.employeeId
}_desktop" class="btn-uploadingPD position-relative">
<span class="mx-1">بارگزاری مدارک</span>
</button>
</div>
</div>
<div class="Rtable-cell d-md-none d-block width7">
<div class="Rtable-cell--content d-flex justify-content-end">
<button type="button" class="btn-pd-more d-md-none d-block position-relative">
<span> </span>
<span> </span>
<span> </span>
<span> </span>
<span class="mx-1 align-items-center d-flex justify-content-center">
<p class="my-0 mx-1">عملیات بیشتر</p>
<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>
<circle cx="8.4001" cy="4.39922" r="1.2" transform="rotate(90 8.4001 4.39922)"></circle>
<circle cx="8.4001" cy="12.3992" r="1.2" transform="rotate(90 8.4001 12.3992)"></circle>
</svg>
</span>
</button>
</div>
</div>
</div>
<div class="operation-div w-100" style="margin: 0 0 0 0;">
<div class="operations-btns">
<div class="container-fluid px-0">
<div class="row g-2">
<div class="col-6 text-center">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.employeePicture.picturePath && (item.employeePicture.statusString !== "unsubmitted" && item.employeePicture.statusString !== "rejected")) {
html += `<img id="employeePicture_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.employeePicture.picturePath ? item.employeePicture.picturePath : "")}" class="preview-image uploaded">`;
} 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 class="col-6 text-center">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.nationalCardFront.picturePath && (item.nationalCardFront.statusString !== "unsubmitted" && item.nationalCardFront.statusString !== "rejected")) {
html += `<img id="nationalCardFront_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.nationalCardFront.picturePath ? item.nationalCardFront.picturePath : "")}" class="preview-image uploaded">`;
} 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 class="col-6 text-center">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.nationalCardRear.picturePath && (item.nationalCardRear.statusString !== "unsubmitted" && item.nationalCardRear.statusString !== "rejected")) {
html += `<img id="nationalCardRear_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.nationalCardRear.picturePath ? item.nationalCardRear.picturePath : "")}" class="preview-image uploaded">`;
} else {
html += `<img id="nationalCardRear_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/>`;
}
html += `</div>
<div class="txtMonilePD">کارت ملی پشت</div>
</div>
</div>
<div class="col-6 text-center">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.militaryServiceCard.picturePath && (item.militaryServiceCard.statusString !== "unsubmitted" && item.militaryServiceCard.statusString !== "rejected")) {
html += `<img id="militaryServiceCard_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.militaryServiceCard.picturePath ? item.militaryServiceCard.picturePath : "")}" class="preview-image uploaded">`;
} 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 class="col-6 text-center">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.idCardPage1.picturePath && (item.idCardPage1.statusString !== "unsubmitted" && item.idCardPage1.statusString !== "rejected")) {
html += `<img id="idCardPage1_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage1.picturePath ? item.idCardPage1.picturePath : "")}" class="preview-image uploaded">`;
} else {
html += `<img id="idCardPage1_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/>`;
}
html += `</div>
<div class="txtMonilePD">شناسنامه صفحه اول</div>
</div>
</div>
<div class="col-6 text-center">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.idCardPage2.picturePath && (item.idCardPage2.statusString !== "unsubmitted" && item.idCardPage2.statusString !== "rejected")) {
html += `<img id="idCardPage2_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage2.picturePath ? item.idCardPage2.picturePath : "")}" class="preview-image uploaded">`;
} else {
html += `<img id="idCardPage2_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/>`;
}
html += `</div>
<div class="txtMonilePD">شناسنامه صفحه دوم</div>
</div>
</div>
<div class="col-6 text-center">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.idCardPage3.picturePath && (item.idCardPage3.statusString !== "unsubmitted" && item.idCardPage3.statusString !== "rejected")) {
html += `<img id="idCardPage3_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage3.picturePath ? item.idCardPage3.picturePath : "")}" class="preview-image uploaded">`;
} else {
html += `<img id="idCardPage3_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/>`;
}
html += `</div>
<div class="txtMonilePD">شناسنامه صفحه سوم</div>
</div>
</div>
<div class="col-6 text-center">
<div class="d-flex align-items-center justify-content-start">
<div class="documentFileBox">`;
if (item.idCardPage4.picturePath && (item.idCardPage4.statusString !== "unsubmitted" && item.idCardPage4.statusString !== "rejected")) {
html += `<img id="idCardPage4_${item.employeeId}" src="${showPictureUrl + `&filePath=` + (item.idCardPage4.picturePath ? item.idCardPage4.picturePath : "")}" class="preview-image uploaded">`;
} else {
html += `<img id="idCardPage4_${item.employeeId}" src="/assetsclient/images/pd-image.png" class="preview-image"/>`;
}
html += `</div>
<div class="txtMonilePD">شناسنامه صفحه چهارم</div>
</div>
</div>
<div class="col-12 text-center">
<div class="d-flex align-items-center justify-content-center">
<button id="editPD_${item.employeeId}_mobile" class="btn-uploadingPD-mobile position-relative">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 22 22" fill="none" stroke="currentColor">
<path d="M12.0433 6.49955L12.0214 6.52145L5.53808 13.0047C5.52706 13.0158 5.51612 13.0267 5.50525 13.0375C5.34278 13.1996 5.19895 13.3432 5.09758 13.5222L5.5266 13.7651L5.09758 13.5222C4.99622 13.7012 4.94714 13.8984 4.89171 14.1211C4.88801 14.136 4.88427 14.151 4.88049 14.1662L4.30029 16.4869L4.78351 16.6077L4.30029 16.4869C4.29808 16.4958 4.29585 16.5047 4.29361 16.5136C4.25437 16.6703 4.21246 16.8377 4.19871 16.9782C4.18357 17.1329 4.1871 17.394 4.39651 17.6034C4.60592 17.8128 4.86698 17.8163 5.02171 17.8012C5.16225 17.7875 5.32958 17.7456 5.48627 17.7063C5.49521 17.7041 5.50411 17.7018 5.51297 17.6996L7.83376 17.1194C7.84888 17.1156 7.86388 17.1119 7.87878 17.1082C8.10151 17.0528 8.29868 17.0037 8.47772 16.9023C8.65675 16.801 8.80027 16.6571 8.9624 16.4947C8.97324 16.4838 8.98416 16.4729 8.99519 16.4618L15.4785 9.97855L15.5004 9.95666C15.796 9.6611 16.0507 9.40638 16.2296 9.17534C16.4208 8.9284 16.5695 8.65435 16.5843 8.31531C16.5862 8.27179 16.5862 8.22821 16.5843 8.18469C16.5695 7.84565 16.4208 7.5716 16.2296 7.32466C16.0507 7.09362 15.796 6.8389 15.5004 6.54334L15.4785 6.52145L15.4566 6.49954C15.161 6.20396 14.9063 5.94922 14.6753 5.77034C14.4283 5.57917 14.1543 5.43041 13.8152 5.41564C13.7717 5.41374 13.7281 5.41374 13.6846 5.41564C13.3456 5.43041 13.0715 5.57917 12.8246 5.77034C12.5935 5.94922 12.3388 6.20396 12.0433 6.49955Z" />
<path d="M11.4583 6.87484L14.2083 5.0415L16.9583 7.7915L15.1249 10.5415L11.4583 6.87484Z" />
</svg>
<span class="mx-1">ویرایش</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>`;
pageIndexJs++;
});
pageIndexJs = pageIndex + response.pageIndex;
pageIndex = pageIndexJs;
$('#personnelDocumentsAjax').append(html);
} 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>`;
$('#personnelDocumentsAjax').append(html);
}
checkImage();
},
failure: function (response) {
console.log(response);
}
});
}
}
function openPersonnelDocsUploadModal(id) {
var goTo = `#showmodal=/AdminNew/Company/EmployeesDocuments/EmployeeList?workshopId=${workshopId}&employeeId=${id}&handler=CreateUploadDocument`;
window.location.href = goTo;
}
function checkImage() {
$('.documentFileBox').each(function () {
if ($(this).find('img.uploaded').length > 0) {
// Add the highlighted-border class to the documentFileBox
$(this).addClass('highlighted-border');
}
});
}