Files
Backend-Api/ServiceHost/wwwroot/AssetsClient/pages/EmployeesBankInfo/js/Index.js
2025-02-09 20:36:53 +03:30

435 lines
21 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
$(document).ready(function () {
let $checkAll = $("#checkAll2");
let $checkboxes = $(".foo");
$checkAll.on("change", function () {
$checkboxes.prop("checked", this.checked);
});
$checkboxes.on("change", function () {
let allChecked = $checkboxes.length === $checkboxes.filter(":checked").length;
let someChecked = $checkboxes.filter(":checked").length > 0;
$checkAll.prop("checked", allChecked);
$checkAll.prop("indeterminate", !allChecked && someChecked);
});
});
var searchName = '';
var searchBank = '';
$(document).ready(function () {
loadEmployeeBankList();
ajaxPersonals();
ajaxBanks();
$(".select2OptionIndex").select2({
language: "fa",
dir: "rtl"
});
$(".select2OptionIndexMobile").select2({
language: "fa",
dir: "rtl",
dropdownParent: $('#searchModal'),
templateResult: function (data, container) {
if (data.element) {
$(container).addClass($(data.element).attr("class"));
}
return data.text;
}
});
//******************** انتخاب همه ی چک باکس ها ********************
$(".checkAll").change(function () {
//let dataValYear = $('#year').val();
//let dataValMonth = $('#month').val();
//let dataValPersonel = Number($('#employeeId').val());
//if ((dataValYear == '' || dataValMonth == '') && dataValPersonel == 0) {
//$('#dropdown-year').addClass("errored");
//$('#dropdown-month').addClass("errored");
//$(this).prop('checked', false);
//$('.alert-msg').show();
//$('.alert-msg p').text('جهت انتخاب گروهی قراردادها ابتدا میبایست سال و ماه مورد نظر را انتخاب نمائید.');
//setTimeout(function () {
// $('.alert-msg').hide();
// $('.alert-msg p').text('');
// $('#dropdown-year').removeClass("errored");
// $('#dropdown-month').removeClass("errored");
//},
//3500);
//} else {
//loadAllToPrint();
$('input:checkbox').not(this).prop('checked', this.checked);
//}
});
//******************** انتخاب همه ی چک باکس ها ********************
});
$(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-search-click, .btn-search-click-mobile', function () {
let isMobile = $(this).hasClass('btn-search-click-mobile');
searchName = isMobile ? $('#employeeSelectIndexMobile') : $('#employeeSelectIndex');
searchBank = $('#bankSelectIndex');
$('.btn-clear-filter').removeClass('disable');
if (searchName.val() === "0" && searchBank.val() === "0") {
$('.btn-clear-filter').addClass('disable');
}
if (isMobile) {
$('#searchModal').modal('hide');
}
$('#EmployeeBankListAjax').html('');
loadEmployeeBankList();
});
$(document).on('click', '.btn-clear-filter', function () {
window.location.reload();
});
// همگام‌سازی متن ورودی برای موبایل و دسکتاپ
$('.d-none.d-md-block .employeeName').on('input', function () {
var desktopInput = $(this).val();
$('#searchModal .employeeName').val(desktopInput);
});
$('#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) {
// loadFineList();
//}
if ($(this).scrollTop() > 100) {
$('.goToTop').show().fadeIn();
} else {
$('.goToTop').fadeOut().hide();
}
});
function loadEmployeeBankList() {
var searchViewModel = {
'EmployeeId': $('#employeeSelectIndex').val(),
'BankId': $('#bankSelectIndex').val(),
}
var html = '';
var index = 0;
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: employeeBankInfoListLoadDataAjax,
data: searchViewModel,
headers: { "RequestVerificationToken": antiForgeryToken },
success: function (response) {
var responseData = response.data;
if (response.success) {
if (responseData.length > 0) {
responseData.forEach(function (item) {
index++;
html += `<div></div>
<div class="Rtable-row align-items-center openAction ${item.isBlack === "true" ? `withdraw` : ``
}" id="Employees">
<div class="Rtable-cell width1 widthNumberCustom1">
<label for="${index}" class="Rtable-cell--content prevent-select">
<span class="d-flex justify-content-between align-items-center" style="width: 45px">
<input id="${index}" type="checkbox" class="form-check-input foo" name="foo" value="${item.Id}">
<div class="row-number">
${index}
</div>
</span>
</label>
</div>
<div class="Rtable-cell justify-content-start width2">
<div class="Rtable-cell--content text-start">${item.employeeName}</div>
</div>
<div class="Rtable-cell d-md-flex justify-content-center d-none width3">
<div class="Rtable-cell--content">${item.personnelCode}</div>
</div>
<div class="Rtable-cell d-md-block d-none width4 text-center">
<div class="Rtable-cell--content text-center">${item.totalBankAccountsCount}</div>
</div>
<div class="Rtable-cell d-md-block d-none width5">
<div class="Rtable-cell--content d-flex gap-1" style="white-space: nowrap;overflow: hidden !important;text-overflow: ellipsis;">`;
item.bankPicturesList.forEach(function (itemBank, index) {
html += `<img class="bankIcon" src="/Client/Company/EmployeesBankInfo/Index?handler=ShowPicture&filePath=${itemBank}"/>`;
});
html += `</div>
</div>
<div class="Rtable-cell width6">
<div class="Rtable-cell--content align-items-center justify-content-end d-flex text-end">
<button class="btn-edit position-relative d-md-block d-none" style="width: auto;" onclick="openEditEmployeeBankModal(${item.employeeId})">
<span class="mx-1 d-block">جزئیات</span>
</button>
<button onclick="deleteEmployeeBankModal(${item.employeeId})" type="button" class="btn-delete d-md-block d-none">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 22 22" fill="none" stroke="currentColor">
<path d="M8.70825 13.2915L8.70825 10.5415" stroke-width="1.5" stroke-linecap="round" />
<path d="M13.2917 13.2915L13.2917 10.5415" stroke-width="1.5" stroke-linecap="round" />
<path d="M2.75 5.9585H19.25V5.9585C18.122 5.9585 17.558 5.9585 17.1279 6.17946C16.7561 6.3704 16.4536 6.67297 16.2626 7.04469C16.0417 7.47488 16.0417 8.03886 16.0417 9.16683V13.8752C16.0417 15.7608 16.0417 16.7036 15.4559 17.2894C14.8701 17.8752 13.9273 17.8752 12.0417 17.8752H9.95833C8.07271 17.8752 7.12991 17.8752 6.54412 17.2894C5.95833 16.7036 5.95833 15.7608 5.95833 13.8752V9.16683C5.95833 8.03886 5.95833 7.47488 5.73737 7.04469C5.54643 6.67297 5.24386 6.3704 4.87214 6.17946C4.44195 5.9585 3.87797 5.9585 2.75 5.9585V5.9585Z" stroke-width="1.5" stroke-linecap="round" />
<path d="M8.70841 3.20839C8.70841 3.20839 9.16675 2.2915 11.0001 2.2915C12.8334 2.2915 13.2917 3.20817 13.2917 3.20817" stroke-width="1.5" stroke-linecap="round" />
</svg>
<span class="mx-1">حذف</span>
</button>
<button type="button" class="btn-operation-more btn-open-div position-relative d-md-none d-block">
<span class="align-items-center d-flex justify-content-center">
<span class="mx-1">عملیات</span>
<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>
</div>
</div>
<div class="operation-div w-100">
<div class="operations-btns">
<div class="row p-0">
<div class="d-flex align-items-center justify-content-between">
<span class="span1">شماره پرسنلی:</span>
<span class="span1">${item.personnelCode}</span>
</div>
<div class="d-flex align-items-center justify-content-between">
<span class="span1">تعداد کارت ثبت شده:</span>
<span class="span1">${item.totalBankAccountsCount}</span>
</div>
<div class="d-flex justify-content-between align-item-center">
<span class="span1">بانک:</span>
<span class="span1 text">`;
item.bankPicturesList.forEach(function (itemBank, index) {
html += `<img class="bankIcon" src="/Client/Company/EmployeesBankInfo/Index?handler=ShowPicture&filePath=${itemBank}"/>${index !== item.bankPicturesList.length - 1 ? '، ' : ''}`;
});
html += `</span>
</div>
<div class="col-md-12 col-12 text-center">
<button onclick="openEditEmployeeBankModal(${item.employeeId})" class="btn-edit position-relative">
<svg width="20" height="20" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.6027 6.838L5.85304 13.5876C5.84201 13.5987 5.83107 13.6096 5.8202 13.6204C5.65773 13.7825 5.5139 13.9261 5.41254 14.1051C5.31117 14.2841 5.2621 14.4813 5.20667 14.704C5.20296 14.7189 5.19923 14.7339 5.19545 14.7491L4.5813 17.2057C4.57908 17.2145 4.57686 17.2234 4.57462 17.2323C4.53537 17.389 4.49347 17.5564 4.47972 17.6969C4.46458 17.8516 4.46811 18.1127 4.67752 18.3221L5.03035 17.9693L4.67752 18.3221C4.88693 18.5315 5.14799 18.535 5.30272 18.5199C5.44326 18.5062 5.6106 18.4643 5.76728 18.425C5.77622 18.4228 5.78512 18.4205 5.79398 18.4183L8.25057 17.8042C8.26569 17.8004 8.28069 17.7967 8.29558 17.793C8.51832 17.7375 8.71549 17.6885 8.89452 17.5871C9.07356 17.4857 9.21708 17.3419 9.37921 17.1794C9.39005 17.1686 9.40097 17.1576 9.412 17.1466L16.1616 10.397L16.1849 10.3737C16.4983 10.0603 16.7684 9.79025 16.9556 9.54492C17.1562 9.282 17.3081 8.98958 17.3081 8.6292C17.3081 8.26759 17.1541 7.97384 16.9522 7.71001C16.7633 7.46303 16.4905 7.1903 16.1731 6.87292L16.1499 6.84972L16.1267 6.82652C15.8093 6.5091 15.5366 6.23634 15.2896 6.04738C15.0258 5.84553 14.732 5.69156 14.3704 5.69156C14.01 5.69156 13.7176 5.84345 13.4547 6.04405C13.2094 6.23123 12.9393 6.5013 12.6259 6.81474L12.6027 6.838Z" stroke-width="1.5" stroke="#4DA9D1" />
<path d="M11.9939 7.20397L14.8457 5.30273L17.6976 8.15459L15.7964 11.0064L11.9939 7.20397Z" fill="#4DA9D1" />
</svg>
<span class="mx-1">جزئیات</span>
</button>
<button onclick="deleteEmployeeBankModal(${item.employeeId})" type="button" class="btn-delete">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 22 22" fill="none" stroke="currentColor">
<path d="M8.70825 13.2915L8.70825 10.5415" stroke-width="1.5" stroke-linecap="round" />
<path d="M13.2917 13.2915L13.2917 10.5415" stroke-width="1.5" stroke-linecap="round" />
<path d="M2.75 5.9585H19.25V5.9585C18.122 5.9585 17.558 5.9585 17.1279 6.17946C16.7561 6.3704 16.4536 6.67297 16.2626 7.04469C16.0417 7.47488 16.0417 8.03886 16.0417 9.16683V13.8752C16.0417 15.7608 16.0417 16.7036 15.4559 17.2894C14.8701 17.8752 13.9273 17.8752 12.0417 17.8752H9.95833C8.07271 17.8752 7.12991 17.8752 6.54412 17.2894C5.95833 16.7036 5.95833 15.7608 5.95833 13.8752V9.16683C5.95833 8.03886 5.95833 7.47488 5.73737 7.04469C5.54643 6.67297 5.24386 6.3704 4.87214 6.17946C4.44195 5.9585 3.87797 5.9585 2.75 5.9585V5.9585Z" stroke-width="1.5" stroke-linecap="round" />
<path d="M8.70841 3.20839C8.70841 3.20839 9.16675 2.2915 11.0001 2.2915C12.8334 2.2915 13.2917 3.20817 13.2917 3.20817" stroke-width="1.5" stroke-linecap="round" />
</svg>
<span class="mx-1">حذف</span>
</button>
</div>
</div>
</div>
</div>`;
});
$('#EmployeeBankListAjax').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>`;
$('#EmployeeBankListAjax').append(html);
}
}
},
failure: function (response) {
console.log(response);
}
});
}
function ajaxPersonals() {
$.ajax({
url: employeeListAjax,
type: 'GET',
success: function (response) {
if (response.success) {
var employees = response.data;
var employeeOptionsHtml = '<option value="0">انتخاب پرسنل ...</option>';
employees.forEach(function (employee) {
employeeOptionsHtml += `<option value="${employee.id}">${employee.employeeFullName}</option>`;
});
$('#employeeSelectIndex').html(employeeOptionsHtml);
$('#employeeSelectIndexMobile').html(employeeOptionsHtml);
} else {
$('.alert-msg').show();
$('.alert-msg p').text(response.message);
setTimeout(function () {
$('.alert-msg').hide();
$('.alert-msg p').text('');
}, 3500);
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
}
});
}
function ajaxBanks() {
$.ajax({
url: bankListAjax,
type: 'GET',
success: function (response) {
if (response.success) {
var banks = response.data;
var bankOptionsHtml = '<option value="0">انتخاب بانک ...</option>';
banks.forEach(function (bank) {
bankOptionsHtml += `<option value="${bank.id}">${bank.bankName}</option>`;
});
$('#bankSelectIndex').html(bankOptionsHtml);
//$('#employeeSelectIndexMobile').html(employeeOptionsHtml);
} else {
$('.alert-msg').show();
$('.alert-msg p').text(response.message);
setTimeout(function () {
$('.alert-msg').hide();
$('.alert-msg p').text('');
}, 3500);
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
}
});
}
function openCreateEmployeeBankModal() {
var goTo = `/Client/Company/EmployeesBankInfo/Index?handler=Create`;
AjaxUrlContentModal(goTo);
//window.location.href = goTo;
}
function openEditEmployeeBankModal(employeeId) {
var goTo = `/Client/Company/EmployeesBankInfo/Index?handler=Details&employeeId=${employeeId}`;
AjaxUrlContentModal(goTo);
//window.location.href = goTo;
}
function deleteEmployeeBankModal(id) {
swal({
title: "آیا از تمامی حذف این حساب اطمینان دارید؟",
text: "",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بله",
cancelButtonText: "خیر",
closeOnConfirm: true,
closeOnCancel: true
}, function (isConfirm) {
if (isConfirm) {
removeByEmployeeId(id);
}
});
}
function removeByEmployeeId(id) {
$.ajax({
async: false,
dataType: 'json',
type: 'POST',
url: removeByEmployeeIdAjax,
headers: { "RequestVerificationToken": antiForgeryToken },
data: { employeeId: Number(id) },
success: function (response) {
if (response.success) {
$('.alert-success-msg').show();
$('.alert-success-msg p').text(response.message);
setTimeout(function () {
$('.alert-success-msg').hide();
$('.alert-success-msg p').text('');
}, 2000);
$('#EmployeeBankListAjax').html('');
loadEmployeeBankList();
} 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 downloadExcelAll() {
if (!($('.foo:checkbox').is(":checked"))) {
$('.alert-msg').show();
$('.alert-msg p').text('هیچ موردی انتخاب نشده است.');
setTimeout(function () {
$('.alert-msg').hide();
$('.alert-msg p').text('');
}, 3500);
return;
}
var idlist = "";
$('.foo').each(function () {
if ($(this).is(":checked")) {
var a = $(this).val();
var b = a + "+";
idlist += b;
}
});
var filterArray = [];
$("input[name='filter[]']:checked").each(function () {
filterArray.push($(this).val());
});
if (idlist !== "") {
//var url = CheckoutExcelAllUrl + "&idList=" + idlist;
var url = CheckoutExcelAllUrl + "&idList=" + encodeURIComponent(idlist);
filterArray.forEach(function (filter) {
url += "&filter=" + encodeURIComponent(filter);
});
window.open(url, "_blank");
}
}