289 lines
15 KiB
JavaScript
289 lines
15 KiB
JavaScript
var pageIndexJs = 0;
|
||
var mode = false;
|
||
var searchName = '';
|
||
|
||
var svgPending =
|
||
`<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<path d="M11 19.25C15.5563 19.25 19.25 15.5563 19.25 11C19.25 6.44365 15.5563 2.75 11 2.75C6.44365 2.75 2.75 6.44365 2.75 11C2.75 15.5563 6.44365 19.25 11 19.25Z" fill="#FDBA74" />
|
||
<path d="M11.4166 14.6667C11.4166 14.8968 11.2301 15.0833 10.9999 15.0833C10.7698 15.0833 10.5833 14.8968 10.5833 14.6667C10.5833 14.4365 10.7698 14.25 10.9999 14.25C11.2301 14.25 11.4166 14.4365 11.4166 14.6667Z" fill="white" stroke="white" />
|
||
<path d="M11 11.916V6.41602V11.916Z" fill="white" />
|
||
<path d="M11 11.916V6.41602" stroke="white" stroke-width="1.5" stroke-linecap="round" />
|
||
</svg>`;
|
||
|
||
var svgReject =
|
||
`<svg width="22" height="22" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="9" cy="9" r="6.75" fill="#F87171"></circle><path d="M12 6L6 12" stroke="white" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"></path>\r\n <path d="M6 6L12 12" stroke="white" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"></path>\r\n </svg>`;
|
||
var svgConfirmed =
|
||
`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<circle cx="12" cy="12" r="8" fill="#A3E635" />
|
||
<path d="M9.5 12L11.3939 13.8939C11.4525 13.9525 11.5475 13.9525 11.6061 13.8939L15.5 10" stroke="white" stroke-width="1.2" stroke-linecap="round" />
|
||
</svg>`;
|
||
var borderSubmitted = "#FFD700"; // Example color for submitted
|
||
var borderRejected = "#FF4500"; // Example color for rejected
|
||
var borderConfirmed = "#32CD32"; // Example color for confirmed
|
||
|
||
$(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;
|
||
$('#personnelDocumentsAjax').html('');
|
||
$('.employeeName').val('');
|
||
loadPersonnelDocuments(mode, searchName = '');
|
||
});
|
||
|
||
$('img').each(function () {
|
||
if ($(this).attr('src') === "/AdminNew/Company/EmployeesDocumentsManagement/EmployeesList?handler=ShowPicture&filePath=") {
|
||
$(this).attr('src', '/assetsclient/images/pd-image.png');
|
||
}
|
||
});
|
||
|
||
// Define your SVGs
|
||
//var svgSubmitted = `<svg ... ><!-- Your SVG for submitted --></svg>`;
|
||
//var svgRejected = `<svg ... ><!-- Your SVG for rejected --></svg>`;
|
||
//var svgConfirmed = `<svg ... ><!-- Your SVG for confirmed --></svg>`;
|
||
|
||
// Loop through each span with the class 'checkSvg'
|
||
$(".checkSvg").each(function () {
|
||
var status = $(this).data("status");
|
||
var parent = $(this).closest(".imageHolder");
|
||
|
||
if (status === "submittedbyadmin") {
|
||
$(this).html(svgPending);
|
||
parent.css("border", `1px solid ${borderSubmitted}`);
|
||
} else if (status === "rejected") {
|
||
$(this).html(svgReject);
|
||
parent.css("border", `1px solid ${borderRejected}`);
|
||
} else if (status === "confirmed") {
|
||
$(this).html(svgConfirmed);
|
||
parent.css("border", `1px solid ${borderConfirmed}`);
|
||
}
|
||
});
|
||
|
||
|
||
$('#taeed').on('click', function () {
|
||
mode = true;
|
||
console.log('Mode is set to:', mode);
|
||
});
|
||
|
||
// Event listner for the 'all' button
|
||
$('#all').on('click', function () {
|
||
mode = false;
|
||
console.log('Mode is set to:', mode);
|
||
});
|
||
});
|
||
|
||
$(document).on('click', ".openAction", function () {
|
||
let clickedButton = $(event.target).closest(".btn-pd-more");
|
||
if (clickedButton.length === 0) {
|
||
$(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 html = '';
|
||
|
||
$.ajax({
|
||
async: false,
|
||
contentType: 'charset=utf-8',
|
||
dataType: 'json',
|
||
type: 'GET',
|
||
url: employeeDocumentsAjaxLoadData,
|
||
data: { workshopId: workshopId, confirmedOnly:mode, employeeName: searchName ,'pageIndex': pageIndexJs },
|
||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||
success: function (response) {
|
||
var personnelDocumentsData = response.data;
|
||
|
||
if (response.isSuccedded) {
|
||
personnelDocumentsData.forEach(function (item) {
|
||
//foreach (var item in @Model.Employees.PersonnelInfoViewModels)
|
||
var n = pageIndexJs + 1;
|
||
|
||
pageIndexJs++;
|
||
html += `<div></div>
|
||
<div class="Rtable-row align-items-center openAction ${item.isBlack === "true" ? `withdraw` : ``}" id="Employees">
|
||
<div class="Rtable-cell width1">
|
||
<div class="Rtable-cell--content">
|
||
<span class="d-flex justify-content-center table-number">
|
||
${n}
|
||
<div class="d-none idPersonnel">test</div>
|
||
</span>
|
||
</div>
|
||
</div>
|
||
<div class="Rtable-cell d-md-block d-none width2">
|
||
${item.employerFullName}
|
||
</div>
|
||
<div class="Rtable-cell d-md-block d-none width3">
|
||
${item.workshopName}
|
||
</div>
|
||
<div class="Rtable-cell width4">
|
||
<div class="text-start">${item.employeeFullName}</div>
|
||
</div>
|
||
<div class="Rtable-cell d-md-block d-none width5 text-center">
|
||
${item.submittedItemsCount}
|
||
</div>
|
||
<div class="Rtable-cell d-md-block d-none width6 text-center">
|
||
|
||
</div>
|
||
|
||
<div class="Rtable-cell d-md-block d-none width7 text-center">
|
||
|
||
</div>
|
||
|
||
<div class="Rtable-cell width8 text-end">
|
||
<div class="Rtable-cell--content d-flex justify-content-end">
|
||
<button type="button" class="btn-pd-more" onclick="openPersonnelDocsUploadModal(Number(${
|
||
item.employeeId}))">
|
||
<span class="mx-1 align-items-center d-flex justify-content-start">
|
||
عملیات بیشتر
|
||
<span class="d-none d-sm-block">
|
||
<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>
|
||
|
||
</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 images px-1 ">
|
||
<div class="row justify-content-between gap-2 m-auto px-0 align-items-center col-12 images">
|
||
<div class="col imageHolder position-relative ${item.employeePicture.statusString}">
|
||
<span class="position-absolute checkSvg" data-status="${item.employeePicture.statusString}"></span>
|
||
<img class="operation-image " src="${showPictureUrl + `&filePath=` + (item.employeePicture.picturePath ? item.employeePicture.picturePath : "")}" alt="عکس پرسنل"/>
|
||
</div>
|
||
<div class="col imageHolder position-relative ${item.employeePicture.statusString}">
|
||
<span class="position-absolute checkSvg" data-status="${item.nationalCardFront.statusString}"></span>
|
||
<img class="operation-image " src="${showPictureUrl + `&filePath=` + (item.nationalCardFront.picturePath ? item.nationalCardFront.picturePath : "")}" alt="عکس کارت ملی رو" />
|
||
</div>
|
||
<div class="col imageHolder position-relative ${item.employeePicture.statusString}">
|
||
<span class="position-absolute checkSvg" data-status="${item.nationalCardRear.statusString}"></span>
|
||
<img class="operation-image " src="${showPictureUrl + `&filePath=` + (item.nationalCardRear.picturePath ? item.nationalCardRear.picturePath : "")}" alt="عکس کارت ملی پشت" />
|
||
</div>
|
||
<div class="col imageHolder position-relative ${item.employeePicture.statusString} ${item.gender=="زن"? 'd-none' :''}">
|
||
<span class="position-absolute checkSvg" data-status="${item.militaryServiceCard.statusString}"></span>
|
||
<img class="operation-image " style="display:${item.gender == "زن" ? "none" : ""};" src="${showPictureUrl + `&filePath=` + (item.militaryServiceCard.picturePath ? item.militaryServiceCard.picturePath : "")}" alt="عکس کارت پایان خدمت" />
|
||
</div>
|
||
<div class="col imageHolder position-relative ${item.employeePicture.statusString}">
|
||
<span class="position-absolute checkSvg" data-status="${item.idCardPage1.statusString}"></span>
|
||
<img class="operation-image" src="${showPictureUrl + `&filePath=` + (item.idCardPage1.picturePath ? item.idCardPage1.picturePath : "")}" alt="عکس شناسنامه صفحه1" />
|
||
</div>
|
||
<div class="col imageHolder position-relative ${item.employeePicture.statusString}">
|
||
<span class="position-absolute checkSvg" data-status="${item.idCardPage2.statusString}"></span>
|
||
<img class="operation-image " src="${showPictureUrl + `&filePath=` + (item.idCardPage2.picturePath ? item.idCardPage2.picturePath : "")}" alt="عکس شناسنامه صفحه2" />
|
||
</div>
|
||
<div class="col imageHolder position-relative ${item.employeePicture.statusString}">
|
||
<span class="position-absolute checkSvg" data-status="${item.idCardPage3.statusString}"></span>
|
||
<img class="operation-image " src="${showPictureUrl + `&filePath=` + (item.idCardPage3.picturePath ? item.idCardPage3.picturePath : "")}" alt="عکس شناسنامه صفحه3" />
|
||
</div>
|
||
<div class="col imageHolder position-relative ${item.employeePicture.statusString}">
|
||
<span class="position-absolute checkSvg" data-status="${item.idCardPage4.statusString}"></span>
|
||
<img class="operation-image " src="${showPictureUrl + `&filePath=` + (item.idCardPage4.picturePath ? item.idCardPage4.picturePath : "")}" alt="عکس شناسنامه صفحه4" />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;
|
||
});
|
||
|
||
pageIndexJs += response.pageIndex;
|
||
$('#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);
|
||
}
|
||
|
||
|
||
},
|
||
failure: function (response) {
|
||
console.log(response);
|
||
}
|
||
});
|
||
}
|
||
|
||
function openPersonnelDocsUploadModal(id) {
|
||
var goTo = `#showmodal=/AdminNew/Company/EmployeesDocumentsManagement/EmployeesList?workshopId=${workshopId}&employeeId=${id}&handler=DetailsPersonnelModal`;
|
||
window.location.href = goTo;
|
||
}
|
||
|
||
function updateIndexesRows() {
|
||
let index = 1;
|
||
|
||
$(`.Rtable-cell--content .table-number`).each(function () {
|
||
$(this).text(index++);
|
||
});
|
||
} |