552 lines
21 KiB
JavaScript
552 lines
21 KiB
JavaScript
|
|
$(document).ready(function () {
|
|
$('.myLinkSign').click(function (event) {
|
|
signAjax(event, this);
|
|
});
|
|
});
|
|
|
|
function signAjax(event, element) {
|
|
event.preventDefault();
|
|
|
|
|
|
if ($(element).find('input[name="unsigned"]').length > 0) { // اگر بایگانی نبود بود به ابایگانی اضافه شود
|
|
swal({
|
|
title: "آیا نسخه قرارداد منتخب را به بایگانی اضافه می کنید؟",
|
|
text: "",
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "بله",
|
|
cancelButtonText: "خیر",
|
|
closeOnConfirm: true
|
|
},
|
|
function (isConfirm) {
|
|
if (isConfirm) {
|
|
const signId = Number($(element).find('input[name="unsigned"]').val());
|
|
var contractNoTd = $(`td[data-signId = '${signId}']`);
|
|
|
|
$.ajax({
|
|
contentType: 'charset=utf-8',
|
|
dataType: 'json',
|
|
type: 'GET',
|
|
url: signAjaxUrl,
|
|
headers: { "RequestVerificationToken": antiForgeryToken },
|
|
data: { "Id": signId },
|
|
success: function (response) {
|
|
|
|
if (response.isSuccedded) {
|
|
$(element).find('span').replaceWith('<span class="hasSignature"> موجود </span>');
|
|
|
|
// تغییر name در تگ input
|
|
$(element).find('input[name="unsigned"]').attr('name', 'signed');
|
|
$(contractNoTd).removeClass("hasNoSignature").addClass("hasSignature");
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else if ($(element).find('input[name="signed"]').length > 0) { //اگر بایگانی شده بود از بایگانی حذف شود
|
|
swal({
|
|
title: "آیا قرارداد منتخب را از بایگانی حذف می کنید؟",
|
|
text: "",
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "بله",
|
|
cancelButtonText: "خیر",
|
|
closeOnConfirm: true
|
|
},
|
|
function (isConfirm) {
|
|
if (isConfirm) {
|
|
const unsignId = Number($(element).find('input[name="signed"]').val());
|
|
var contractNoTd = $(`td[data-signId = '${unsignId}']`);
|
|
$.ajax({
|
|
contentType: 'charset=utf-8',
|
|
dataType: 'json',
|
|
type: 'GET',
|
|
url: unSignAjax,
|
|
headers: { "RequestVerificationToken": antiForgeryToken },
|
|
data: { "Id": unsignId },
|
|
success: function (response) {
|
|
|
|
if (response.isSuccedded) {
|
|
$(element).find('span').replaceWith('<span class="hasNoSignature"> ناموجود </span>');
|
|
|
|
// تغییر name در تگ input
|
|
$(element).find('input[name="signed"]').attr('name', 'unsigned');
|
|
$(contractNoTd).removeClass("hasSignature").addClass("hasNoSignature");
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//function hasContract(element) {
|
|
// if ($(element).hasClass("hasSignature")){
|
|
// $(element).removeClass("hasSignature").addClass("hasNoSignature");
|
|
// $(element).text("ناموجود");
|
|
// $(element).parent().next().addClass("hasNoSignature");
|
|
// }else{
|
|
// $(element).removeClass("hasNoSignature").addClass("hasSignature");
|
|
// $(element).text("موجود");
|
|
// $(element).parent().next().removeClass("hasNoSignature");
|
|
// }
|
|
|
|
//}
|
|
$(".activateContract-td span").on('click',
|
|
function () {
|
|
hasContract($(this));
|
|
});
|
|
$('.activer').on('change',
|
|
function (e) {
|
|
e.preventDefault();
|
|
$('.search').click();
|
|
|
|
});
|
|
$('#datatable').find("tbody tr").each(function () {
|
|
const cols = $(this).find(".BalanceDouble").val();
|
|
if (cols > 0) {
|
|
$(this).find(".BalanceDoubleTd").css("color", "red");
|
|
} else {
|
|
$(this).find(".BalanceDoubleTd").css("color", "#009300");
|
|
}
|
|
});
|
|
|
|
//var a = window.location.href;
|
|
//var res = a.split("#")[1];
|
|
//if (res == "false") {
|
|
// $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', " ابتدا یکی از فیلد های کارگاه، کارفرما، پرسنل را انتخاب نموده و سپس جستجو را بزنید ");
|
|
//}
|
|
|
|
|
|
|
|
//if (document.getElementById("activing").selectedIndex == 1) {
|
|
// $('.deact').remove();
|
|
// $('.act').append(
|
|
// ' <a class="btn btn-success pull-right m-rl-5 rad react" onclick="reActiveAll()">' + '<i class="fa faSize fa-rotate-left"></i>' + ' </a>'
|
|
// );
|
|
//}
|
|
//if (document.getElementById("activing").selectedIndex == 2) {
|
|
// $('.deact').remove();
|
|
|
|
|
|
//}
|
|
$('.persianDateInputa').persianDatepicker({
|
|
format: 'YYYY/MM/DD',
|
|
initialValueType: 'persian',
|
|
initialValue: false,
|
|
/* 'position': [-270, 25],*/
|
|
autoClose: true,
|
|
|
|
calendar: {
|
|
persian: {
|
|
leapYearMode: 'astronomical'
|
|
}
|
|
}
|
|
|
|
});
|
|
$('.persianDateInputb').persianDatepicker({
|
|
format: 'YYYY/MM/DD',
|
|
initialValueType: 'persian',
|
|
|
|
initialValue: false,
|
|
/*'position': [-270, 25],*/
|
|
autoClose: true,
|
|
|
|
calendar: {
|
|
persian: {
|
|
leapYearMode: 'astronomical'
|
|
}
|
|
}
|
|
});
|
|
|
|
$(".datepicker-container").hide();
|
|
$(document).ready(function () {
|
|
$('#datatable').dataTable({
|
|
"lengthMenu": [[25, 10, 50, 100, -1], [25, 10, 50, 100, "All"]]
|
|
});
|
|
$(".datepicker-container").hide();
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function removeOneCheckout(aTag) {
|
|
swal({
|
|
title: "توجه داشته باشید با تایید این پیام قرارداد مورد نظر بطور کامل از بانک اطلاعات حذف می شود ",
|
|
text: "",
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "تایید",
|
|
cancelButtonText: "خیر",
|
|
closeOnConfirm: false
|
|
},
|
|
function (isConfirm) {
|
|
if (isConfirm) {
|
|
/* $("a.dell").click();*/
|
|
const inputTag = aTag.querySelector('input[name="checkoutId"]');
|
|
const chekoutId = inputTag.value;
|
|
let url3b = '';
|
|
const u2 = `&id=${chekoutId}`;
|
|
url3b = url3b + u2;
|
|
const url2b = removeOneCheckoutUrl;
|
|
window.location.href = url2b + url3b;
|
|
} else {
|
|
}
|
|
});
|
|
}
|
|
|
|
function deactiveOneCheckout(Id, Balance) {
|
|
|
|
swal({
|
|
title: "توجه داشته باشید با تایید این پیام قرارداد مورد نظر غیر فعال می شود ",
|
|
text: "",
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "تایید",
|
|
cancelButtonText: "خیر",
|
|
closeOnConfirm: false,
|
|
customClass: "disableSwall"
|
|
},
|
|
function (isConfirm) {
|
|
if (isConfirm) {
|
|
let url3b = '';
|
|
const u2 = `&id=${Id}`;
|
|
const u3 = `&balance=${Balance}`;
|
|
url3b = url3b + u2 + u3;
|
|
const url2b = deactiveOneCheckoutUrl;
|
|
window.location.href = url2b + url3b;
|
|
} else {
|
|
}
|
|
});
|
|
}
|
|
|
|
function reActiveAll() {
|
|
if (document.getElementById("checkSelect").checked == false) {
|
|
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', " هیچ قراردادی انتخاب نشده است ");
|
|
} else {
|
|
if (document.getElementById("sercheCheck").value == "false") {
|
|
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', " لطفا در قسمت جستجوی قرارداد حداقل یکی از فیلدهای کارکاه یا پرسنل را انتخاب نموده و سپس جستجو را کلیک کنید ");
|
|
|
|
} else if (document.getElementById("sercheCheck").value == "true") {
|
|
swal({
|
|
title: "آیا فعال نمودن این قراردادها اطمینان دارید؟",
|
|
text: "",
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "بله",
|
|
cancelButtonText: "خیر",
|
|
closeOnConfirm: false
|
|
},
|
|
function (isConfirm) {
|
|
if (isConfirm) {
|
|
checkboxes2 = document.getElementsByName('foo');
|
|
let url3b = '';
|
|
for (var i2 = 0, n2 = checkboxes2.length; i2 < n2; i2++) {
|
|
if (checkboxes2[i2].checked == true) {
|
|
const u2 = `&ids=${checkboxes2[i2].value}`;
|
|
url3b = url3b + u2;
|
|
}
|
|
}
|
|
const url2b = reActiveAllUrl;
|
|
window.location.href = url2b + url3b;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
$(window).on('resize',
|
|
function () {
|
|
if ($(window).width() < 768) {
|
|
locateButtonContainerMobile();
|
|
}
|
|
if ($(window).width() > 768) {
|
|
locateButtonContainer();
|
|
}
|
|
});
|
|
$(document).on("click",
|
|
function (event) {
|
|
const target = $(event.target);
|
|
if (!target.closest(".buttons-container").length && !target.is(".employee-operations") && !target.is("#LeftWorkInsuranceForm") && !target.is("#LeftWorkInsuranceForm *") && !target.is("#LeftWorkForm") && !target.is("#LeftWorkForm *") && !target.is("#LeftWorkInsuranceForm #closing") && !target.is("#LeftWorkForm #close") && !target.is("#LeftWorkInsuranceForm .close") && !target.is("#LeftWorkForm .close") && !target.is("#LeftWorkInsuranceForm #btnSaveData") && !target.is("#LeftWorkForm #btnSaveData")
|
|
) {
|
|
$(".buttons-container").removeClass("active").addClass("reverse");
|
|
$(".more-buttons").removeClass("active");
|
|
setTimeout(function () {
|
|
$(".buttons-container").removeClass("reverse").css("display", "none");
|
|
},
|
|
200);
|
|
}
|
|
});
|
|
$(".employee-operations").on("click",
|
|
function () {
|
|
if ($(window).width() < 768) {
|
|
locateButtonContainerMobile();
|
|
}
|
|
if ($(window).width() > 768) {
|
|
locateButtonContainer();
|
|
}
|
|
var buttonsContainer = $(this).next(".buttons-container");
|
|
if (buttonsContainer.hasClass("active")) {
|
|
buttonsContainer.removeClass("active").addClass("reverse");
|
|
$(this).closest(".more-buttons").removeClass("active");
|
|
setTimeout(function () {
|
|
buttonsContainer.removeClass("reverse").css("display", "none");
|
|
},
|
|
200);
|
|
} else {
|
|
buttonsContainer.removeClass("reverse").addClass("active").css("display", "flex");
|
|
$(this).closest(".more-buttons").addClass("active");
|
|
}
|
|
|
|
$(".buttons-container").not(buttonsContainer).removeClass("active reverse").css("display", "none");
|
|
$(".more-buttons").not($(this).closest(".more-buttons")).removeClass("active");
|
|
});
|
|
|
|
function locateButtonContainer() {
|
|
const beforePosition = $(".screen-view .employee-operations").position();
|
|
const containerWidth = $('.screen-view .buttons-container').outerWidth();
|
|
const containerHeight = $('.screen-view .buttons-container').outerHeight();
|
|
const containerLeft = beforePosition.left + $(".screen-view .employee-operations").outerWidth() + 20;
|
|
const containerTop = beforePosition.top + ($(".screen-view .employee-operations").outerHeight() / 2) - (containerHeight / 2);
|
|
$('.screen-view .buttons-container').css({
|
|
left: containerLeft,
|
|
top: containerTop
|
|
});
|
|
}
|
|
|
|
function locateButtonContainerMobile() {
|
|
const beforePosition = $(".mobile-view .employee-operations").position();
|
|
const containerWidth = $('.mobile-view .buttons-container').outerWidth();
|
|
const containerHeight = $('.mobile-view .buttons-container').outerHeight();
|
|
const containerLeft = beforePosition.left + $(".mobile-view .employee-operations").outerWidth() + 25;
|
|
const containerTop = beforePosition.top + ($(".mobile-view .employee-operations").outerHeight() / 2) - (containerHeight / 2);
|
|
$('.mobile-view .buttons-container').css({
|
|
left: containerLeft,
|
|
top: containerTop
|
|
});
|
|
}
|
|
|
|
|
|
function showAmount(element) {
|
|
|
|
if ($(element).hasClass("fa-eye-slash")) {
|
|
$(element).removeClass("fa-eye-slash");
|
|
$(element).addClass("fa-eye");
|
|
$('.amount').css("visibility", "hidden");
|
|
} else if ($(element).hasClass("fa-eye")) {
|
|
$(element).removeClass("fa-eye");
|
|
$(element).addClass("fa-eye-slash");
|
|
$('.amount').css("visibility", "visible");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
function showTooltip(id) {
|
|
|
|
|
|
// var id= $(this).attr("id").replace("p_","");
|
|
|
|
|
|
console.log($(`tooltip_${id}`).hasClass('show'));
|
|
|
|
|
|
if ($(`tooltip_${id}`).hasClass('show')) {
|
|
$(`tooltip_${id}`).removeClass('show');
|
|
$(`tooltip_${id}`).css({ 'visibility': 'hidden' });
|
|
} else {
|
|
$(`tooltip_${id}`).addClass('show');
|
|
$(`tooltip_${id}`).css({ 'visibility': 'visible' });
|
|
}
|
|
}
|
|
|
|
|
|
function block(id) {
|
|
$('.sweet-alert').removeClass("successSwall");
|
|
$('.sweet-alert').removeClass("errorSwall");
|
|
swal({
|
|
title: "آیا از مسدود کردن این طرف حساب مطمئن هستید؟",
|
|
text: "",
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "بله",
|
|
cancelButtonText: "خیر",
|
|
closeOnConfirm: true,
|
|
closeOnCancel: true
|
|
},
|
|
function (isConfirm) {
|
|
if (isConfirm) {
|
|
|
|
$.ajax({
|
|
async: false,
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
url: blockAjax,
|
|
headers: { "RequestVerificationToken": antiForgeryToken },
|
|
data: { "id": id },
|
|
success: function (response) {
|
|
// console.log(response);
|
|
if (response.isSuccedded) {
|
|
bloked(id, response.blockTimes);
|
|
|
|
} else {
|
|
|
|
swal({
|
|
title: response.message,
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
//confirmButtonText: "بستن",
|
|
cancelButtonText: "بستن",
|
|
closeOnConfirm: false,
|
|
closeOnCancel: true,
|
|
customClass: "errorSwall"
|
|
});
|
|
}
|
|
},
|
|
failure: function (response) {
|
|
console.log(5, response);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
function bloked(id, blocktime) {
|
|
const blocked = `<a onclick="disableBlock(${id},${blocktime})" class="btn btn-inverse unblock pull-left rad btn-table" permission="10114" style="margin-left:5px" class="btn pull-right btn-danger btn-table">
|
|
<span class="blockCount">${blocktime}</span>
|
|
<i class="fa fa-minus-circle"></i><span>آنبلاک</span></a>`;
|
|
|
|
|
|
$(`#blockspan${id}`).html('');
|
|
$(`#blockspan${id}`).append(blocked);
|
|
$(`.blockingTr${id}`).addClass("blockTr");
|
|
$(`.blockingTr${id}`).addClass("progress-bar-striped");
|
|
$(`.extention${id}`).addClass("disabled");
|
|
$(`.deactive${id}`).addClass("disabled");
|
|
$(`.edit${id}`).addClass("disabled");
|
|
$(`.delete${id}`).addClass("disabled");
|
|
|
|
}
|
|
|
|
function disableBlock(id, blocktime) {
|
|
$('.sweet-alert').removeClass("successSwall");
|
|
$('.sweet-alert').removeClass("errorSwall");
|
|
|
|
|
|
swal({
|
|
title: "آیا میخواهید این طرف حساب را از حالت مسدود خارج نمایید؟ ",
|
|
text: "",
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "بله",
|
|
cancelButtonText: "خیر",
|
|
closeOnConfirm: true,
|
|
closeOnCancel: true
|
|
},
|
|
function (isConfirm) {
|
|
if (isConfirm) {
|
|
|
|
$.ajax({
|
|
async: false,
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
url: disableBlockAjax,
|
|
headers: { "RequestVerificationToken": antiForgeryToken },
|
|
data: { "id": id },
|
|
success: function (response) {
|
|
//console.log(response);
|
|
if (response.isSuccedded) {
|
|
$(`.blockingTr${id}`).removeClass("blockTr");
|
|
$(`.blockingTr${id}`).removeClass("progress-bar-striped");
|
|
$(`.extention${id}`).removeClass("disabled");
|
|
$(`.deactive${id}`).removeClass("disabled");
|
|
$(`.edit${id}`).removeClass("disabled");
|
|
$(`.delete${id}`).removeClass("disabled");
|
|
if (response.blockTimes == 1) {
|
|
const orange = `<a onclick="block(${id})" class="btn btn-inverse bgOrange pull-left rad btn-table" permission="10114" style="margin-left:5px" class="btn pull-right btn-danger btn-table">
|
|
<span class="blockCount">${response.blockTimes}</span> <i class="fa fa-minus-circle"></i><span>بلاک کردن</span></a>`;
|
|
$(`#blockspan${id}`).html('');
|
|
$(`#blockspan${id}`).append(orange);
|
|
|
|
|
|
} else if (response.blockTimes >= 2) {
|
|
const red = `<a onclick="block(${id})" class="btn btn-inverse bgRed pull-left rad btn-table" permission="10114" style="margin-left:5px" class="btn pull-right btn-danger btn-table">
|
|
<span class="blockCount">${response.blockTimes}</span> <i class="fa fa-minus-circle"></i><span>بلاک کردن</span></a>`;
|
|
|
|
$(`#blockspan${id}`).html('');
|
|
$(`#blockspan${id}`).append(red);
|
|
|
|
|
|
}
|
|
swal({
|
|
title: response.message,
|
|
text: "",
|
|
type: "success",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
confirmButtonText: "بستن",
|
|
//cancelButtonText: "خیر",
|
|
closeOnConfirm: true,
|
|
customClass: "successSwall"
|
|
},
|
|
function (isConfirm) {
|
|
if (isConfirm) {
|
|
$("#btnSearch").click();
|
|
}
|
|
});
|
|
|
|
} else {
|
|
|
|
swal({
|
|
title: response.message,
|
|
// text: "برای حذف قرارداد، ابتدا تیک مربوط به امضای قرارداد را حذف نمایید.",
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#DD6B55",
|
|
//confirmButtonText: "بستن",
|
|
cancelButtonText: "بستن",
|
|
closeOnConfirm: false,
|
|
closeOnCancel: true,
|
|
customClass: "errorSwall"
|
|
});
|
|
}
|
|
},
|
|
failure: function (response) {
|
|
console.log(5, response);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
}
|