Files
Backend-Api/ServiceHost/wwwroot/AssetsAdmin/page/ContractingParty/js/index.js
2025-05-13 19:27:47 +03:30

1106 lines
51 KiB
JavaScript

$(document).ready(function () {
if($("#empSearch").val()=="0")
$("#empSearch").val('');
})
$(document).ready(function () {
$('#datatable').dataTable({
"lengthMenu": [[25, 10, 50, 100, -1], [25, 10, 50, 100, "All"]]
});
});
$(document).ready(function () {
$('#datatable2').dataTable();
});
$("#myTab a").click(function (e) {
e.preventDefault();
$(this).tab('show');
});
$("#myTab2 a").click(function (e) {
e.preventDefault();
$(this).tab('show');
});
// store the currently selected tab in the hash value
$("ul.nav-tabs > li > a").on("shown.bs.tab", function (e) {
var id = $(e.target).attr("href").substr(1);
window.location.hash = id;
});
// on load of the page: switch to the currently selected tab
var hash = window.location.hash;
$('#myTab a[href="' + hash + '"]').tab('show', 'active');
var hash2 = window.location.hash;
$('#myTab2 a[href="' + hash2 + '"]').tab('show', 'active');
var container = $('#emp');
var searchBox = $('#empSearch');
var hiddenInputVal = $('.sendEmployeeId');
var searchResul = $('.searchResult');
var mixContainerAndSerchResult = $('#emp , .searchResult');
container.hide();
var liList;
var liPointer;
let count = 0;
//close search Employee when click on body
$(document).on('click', function (event) {
if (!$(event.target).closest(container).length) {
container.hide();
}
});
//select option by mouse
function selectItem(id, employeeFullName) {
searchBox.val(employeeFullName);
hiddenInputVal.val(id);
container.hide();
searchBox.addClass("selectedOption");
};
//search by Ajax
searchBox.on('keyup keypress',
function (e) {
$(".form-control").removeClass("selectedOption");
$("#empSearchNationalcode").val('');
$("#empSearchContractingPartyID").val('');
$("#SearchModel2_RepresentativeName").val('');
$("#SearchModel2_Nationalcode").val('');
if($(this).val()=='')
{
$("#SearchModel_EmployeeId").val("0");
$("#SearchModel_EmployeeName").val('');
}
//stop submit form with enter
var keyCode = e.keyCode || e.which;
if (keyCode === 13) {
e.preventDefault();
if (count> 0 && count <= liList.length) {
liPointer.click();
}
return false;
}
searchBox.removeClass("selectedOption");
let searchText = $(this).val();
hiddenInputVal.val(0);
if (searchText.length > 1) {
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: contractPartyListAjaxUrl,
data: { "searchText": searchText },
headers: { "RequestVerificationToken": $(antiForgeryToken).val() },
success: function (response) {
$(".opt").remove();
if (response.mylist.length > 0) {//result Founded
$(".noResult").remove();
container.show();
$.each(response.mylist,
function (i, item) {
let li = `<li data-employeeId="${item.id}" class="btn btn-block opt" onclick="selectItem(${item.id}, '${item.lName}');" >${item.lName}</li>`;
searchResul.append(li);
});
} else {//result NotFounded
$(".noResult").remove();
container.show();
let noResult = `<li class="btn btn-block noResult">نتیجه ای یافت نشد</li>`;
searchResul.append(noResult);
}
}// endOfSuccess
}); //endOfAjax
} else {
container.hide();
count = 0;
}
//keyboard Arrow Key Select And Enter
liList = $('#emp ul li');
mixContainerAndSerchResult.animate({
scrollTop: $(liList.eq(0)).offset().top - container.offset().top + container.scrollTop()
},
50);
if (e.which === 40) {// if ArrowUp
if (count > 0 && count <= liList.length) {
liPointer.removeClass('keyboardSelected');
console.log(count + "plusOne");
liList.eq(count).addClass('keyboardSelected');
liPointer = liList.eq(count);
if (count > 4) {
//ScrollDown
mixContainerAndSerchResult.animate({
scrollTop: $(liPointer).offset().top - container.offset().top + container.scrollTop()
},
50);
}
count += 1;
} else {
liList.eq(0).addClass("keyboardSelected");
liPointer = liList.eq(0);
count = 1;
}
} else if (e.which === 38) {//if ArrowDown
if (count > 0 && count <= liList.length) {
liPointer.removeClass('keyboardSelected');
count -= 1;
liList.eq(count).addClass('keyboardSelected');
liPointer = liList.eq(count);
//ScrollUp
mixContainerAndSerchResult.animate({
scrollTop: $(liPointer).offset().top - container.offset().top + container.scrollTop()
},
50);
}
}
});
$("#empSearchContractingPartyID").keypress(function (event) {
$(".form-control").removeClass("selectedOption");
$("#empSearchNationalcode").val('');
$("#SearchModel2_Nationalcode").val('');
$("#empSearch").val('');
$("#SearchModel2_EmployeeName").val('');
$("#SearchModel2_id").val('0');
if (event.keyCode === 13) {
if ($("#SearchModel2_RepresentativeId").val() == "0")
$("#SearchModel2_RepresentativeName").val($(this).val())
$("#btnSearch").click();
}
});
$("#empSearch").keypress(function (event) {
$(".form-control").removeClass("selectedOption");
$("#empSearchNationalcode").val('');
$("#empSearchContractingPartyID").val('');
$("#SearchModel2_RepresentativeName").val('');
$("#SearchModel2_Nationalcode").val('');
if (event.keyCode === 13) {
if ( $("#SearchModel2_id").val() == "0")
$("#SearchModel2_EmployeeName").val($("#empSearch").val())
$("#btnSearch").click();
}
});
var containerContracting = $('#empContractingPartyID');
var searchBoxContracting = $('#empSearchContractingPartyID');
var hiddenInputValContracting = $('.sendContractingPartyID');
var searchResulContracting = $('.searchResultContractingPartyID');
var mixContainerAndSerchResultContracting = $('#empContractingPartyID , .searchResultContractingPartyID');
containerContracting.hide();
var liListContracting;
var liPointerContracting;
let countContracting = 0;
//close searchBoxContracting Employee when click on body
$(document).on('click', function (event) {
if (!$(event.target).closest(containerContracting).length) {
containerContracting.hide();
}
});
//select option by mouse
function selectItemContracting(id, employeeFullName) {
searchBoxContracting.val(employeeFullName);
hiddenInputValContracting.val(id);
containerContracting.hide();
searchBoxContracting.addClass("selectedOption");
};
//searchBoxContracting by Ajax
searchBoxContracting.on('keyup keypress',
function (e) {
$(".form-control").removeClass("selectedOption");
$("#empSearchNationalcode").val('');
$("#empSearch").val('');
$("#SearchModel2_EmployeeName").val('');
$("#SearchModel2_id").val('0');
$("#SearchModel2_Nationalcode").val('');
if($(this).val()=='')
{
$("#SearchModel_RepresentativeId").val("0");
$("#SearchModel_RepresentativeName").val('');
}
//stop submit form with enter
var keyCode = e.keyCode || e.which;
if (keyCode === 13) {
e.preventDefault();
if (countContracting > 0 && countContracting <= liListContracting.length) {
liPointerContracting.click();
}
return false;
}
searchBoxContracting.removeClass("selectedOption");
let searchText = $(this).val();
hiddenInputValContracting.val(0);
if (searchText.length > 1) {
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: representativeListAjaxUrl,
data: { "searchText": searchText },
headers: { "RequestVerificationToken": $(antiForgeryToken).val() },
success: function (response) {
$(".opt").remove();
if (response.mylist.length > 0) {//result Founded
$(".noResult").remove();
containerContracting.show();
$.each(response.mylist,
function (i, item) {
let li = `<li data-id="${item.id}" class="btn btn-block opt" onclick="selectItemContracting(${item.id}, '${item.fullName}');" >${item.fullName}</li>`;
searchResulContracting.append(li);
});
} else {//result NotFounded
$(".noResult").remove();
containerContracting.show();
let noResult = `<li class="btn btn-block noResult" style="background-color: #ffffff;border-radius: 10px;text-align: right;padding: 2px 5px">نتیجه ای یافت نشد</li>`;
searchResulContracting.append(noResult);
}
}// endOfSuccess
}); //endOfAjax
} else {
containerContracting.hide();
countContracting = 0;
}
//keyboard Arrow Key Select And Enter
liListContracting = $('#empContractingPartyID ul li');
mixContainerAndSerchResultContracting.animate({
scrollTop: $(liListContracting.eq(0)).offset().top - containerContracting.offset().top + containerContracting.scrollTop()
},
50);
if (e.which === 40) {// if ArrowUp
if (countContracting > 0 && countContracting <= liListContracting.length) {
liPointerContracting.removeClass('keyboardSelected');
console.log(countContracting + "plusOne");
liListContracting.eq(countContracting).addClass('keyboardSelected');
liPointerContracting = liListContracting.eq(countContracting);
if (countContracting > 4) {
//ScrollDown
mixContainerAndSerchResultContracting.animate({
scrollTop: $(liPointerContracting).offset().top - containerContracting.offset().top + containerContracting.scrollTop()
},
50);
}
countContracting += 1;
} else {
liListContracting.eq(0).addClass("keyboardSelected");
liPointerContracting = liListContracting.eq(0);
countContracting = 1;
}
} else if (e.which === 38) {//if ArrowDown
if (countContracting > 0 && countContracting <= liListContracting.length) {
liPointerContracting.removeClass('keyboardSelected');
countContracting -= 1;
liListContracting.eq(countContracting).addClass('keyboardSelected');
liPointerContracting = liListContracting.eq(countContracting);
//ScrollUp
mixContainerAndSerchResultContracting.animate({
scrollTop: $(liPointerContracting).offset().top - containerContracting.offset().top + containerContracting.scrollTop()
},
50);
}
}
});
var containerNationalcode = $('#empNationalcode');
var searchBoxNationalcode = $('#empSearchNationalcode');
var hiddenInputValNationalcode = $('.sendNationalcode');
var searchResulNationalcode = $('.searchResultNationalcode');
var mixContainerAndSerchResultNationalcode = $('#empNationalcode , .searchResultNationalcode');
containerNationalcode.hide();
var liListNationalcode;
var liPointerNationalcode;
let countNationalcode = 0;
//close searchBoxNationalcode Employee when click on body
$(document).on('click', function (event) {
if (!$(event.target).closest(containerNationalcode).length) {
containerNationalcode.hide();
}
});
//select option by mouse
function selectItemNationalcode(id, nationalcode) {
searchBoxNationalcode.val(nationalcode);
hiddenInputValNationalcode.val(nationalcode);
containerNationalcode.hide();
searchBoxNationalcode.addClass("selectedOption");
};
//searchBoxNationalcode by Ajax
searchBoxNationalcode.on('keyup keypress',
function (e) {
$(".form-control").removeClass("selectedOption");
$("#empSearchContractingPartyID").val('');
$("#SearchModel2_RepresentativeName").val('');
$("#empSearch").val('');
$("#SearchModel2_EmployeeName").val('');
$("#SearchModel2_id").val('0');
if($(this).val()=='')
{
$("#SearchModel2_Nationalcode").val("");
$("#empSearchNationalcode").val('');
}
//stop submit form with enter
var keyCode = e.keyCode || e.which;
if (keyCode === 13) {
e.preventDefault();
if (countNationalcode > 0 && countNationalcode <= liListNationalcode.length) {
liPointerNationalcode.click();
}
return false;
}
searchBoxNationalcode.removeClass("selectedOption");
let searchText = $(this).val();
hiddenInputValNationalcode.val(0);
if (searchText.length > 1) {
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: personalContractingPartyNationalcodeAjaxUrl,
data: { "searchText": searchText },
headers: { "RequestVerificationToken": $(antiForgeryToken).val() },
success: function (response) {
$(".opt").remove();
if (response.mylist.length > 0) {//result Founded
$(".noResult").remove();
containerNationalcode.show();
$.each(response.mylist,
function (i, item) {
let li = `<li data-id="${item.id}" class="btn btn-block opt" onclick="selectItemNationalcode(${item.id}, '${item.nationalcode}');" >${item.nationalcode}</li>`;
searchResulNationalcode.append(li);
});
} else {//result NotFounded
$(".noResult").remove();
containerNationalcode.show();
let noResult = `<li class="btn btn-block noResult" style="background-color: #ffffff;border-radius: 10px;text-align: right;padding: 2px 5px">نتیجه ای یافت نشد</li>`;
searchResulNationalcode.append(noResult);
}
}// endOfSuccess
}); //endOfAjax
} else {
containerNationalcode.hide();
countNationalcode = 0;
}
//keyboard Arrow Key Select And Enter
liListNationalcode = $('#empNationalcode ul li');
mixContainerAndSerchResultNationalcode.animate({
scrollTop: $(liListNationalcode.eq(0)).offset().top - containerNationalcode.offset().top + containerNationalcode.scrollTop()
},
50);
if (e.which === 40) {// if ArrowUp
if (countNationalcode > 0 && countNationalcode <= liListNationalcode.length) {
liPointerNationalcode.removeClass('keyboardSelected');
console.log(countNationalcode + "plusOne");
liListNationalcode.eq(countNationalcode).addClass('keyboardSelected');
liPointerNationalcode = liListNationalcode.eq(countNationalcode);
if (countNationalcode > 4) {
//ScrollDown
mixContainerAndSerchResultNationalcode.animate({
scrollTop: $(liPointerNationalcode).offset().top - containerNationalcode.offset().top + containerNationalcode.scrollTop()
},
50);
}
countNationalcode += 1;
} else {
liListNationalcode.eq(0).addClass("keyboardSelected");
liPointerNationalcode = liListNationalcode.eq(0);
countNationalcode = 1;
}
} else if (e.which === 38) {//if ArrowDown
if (countNationalcode > 0 && countNationalcode <= liListNationalcode.length) {
liPointerNationalcode.removeClass('keyboardSelected');
countNationalcode -= 1;
liListNationalcode.eq(countNationalcode).addClass('keyboardSelected');
liPointerNationalcode = liListNationalcode.eq(countNationalcode);
//ScrollUp
mixContainerAndSerchResultNationalcode.animate({
scrollTop: $(liPointerNationalcode).offset().top - containerNationalcode.offset().top + containerNationalcode.scrollTop()
},
50);
}
}
});
$("#empSearchNationalcode").keypress(function (event) {
// console.log(123);
if (event.keyCode === 13) {
$(".form-control").removeClass("selectedOption");
$("#empSearchContractingPartyID").val('');
$("#empSearch").val('');
$("#SearchModel2_RepresentativeName").val('');
$("#SearchModel2_EmployeeName").val('');
$("#SearchModel2_id").val('0');
$("#SearchModel2_Nationalcode").val($("#empSearchNationalcode").val());
$("#btnSearch").click();
}
});
$(".btn-searchContractingParties").click(function () {
if ($("#SearchModel2_EmployeeId").val() == "0" || $("#SearchModel2_EmployeeId").val() == "")
$("#SearchModel2_EmployeeName").val($("#empSearch").val());
if ($("#SearchModel2_RepresentativeId").val() == "0" || $("#SearchModel2_RepresentativeId").val() == "")
$("#SearchModel2_RepresentativeName").val($("#empSearchContractingPartyID").val());
if ($("#empSearchNationalcode").val() != "0" && $("#empSearchNationalcode").val() != "")
$("#SearchModel2_Nationalcode").val($("#empSearchNationalcode").val());
if($("#empSearch").val()=="0")
$("#empSearch").val('');
$("#btnSearch").click();
});
function remove(id,hasInstitutionContract,hasEmployer) {
console.log(hasInstitutionContract);
//اگر همزمان در تب جدید قرارداد غیر فعال شو، پیغاماشتابه نمایش داده میشود
// if(hasInstitutionContract=="True")
// {
// swal({
// title: "حذف این طرف حساب به دلیل دارا بودن قرارداد مالی امکان پذیر نمی باشد.",
// text: "در صورت تمایل به حذف یا غیر فعال سازی این طرف حساب، می بایست کلیه عملیات مربوط به این طرف حساب را حذف نمایید.",
// type: "warning",
// showCancelButton: true,
// confirmButtonColor: "#DD6B55",
// //confirmButtonText: "بستن",
// cancelButtonText: "بستن",
// closeOnConfirm: false,
// closeOnCancel: true,
// customClass: "errorSwall"
// });
// }
// else
// {
$('.sweet-alert').removeClass("successSwall");
$('.sweet-alert').removeClass("errorSwall");
swal({
title: hasEmployer>0? "توجه داشته باشید حذف کامل از دیتابیس میسر نمی باشد،اما با تایید این پیام این طرف حساب و کلیه عملیات مربوط به آن غیرفعال می گردد.":"توجه داشته باشید با تایید این پیام، اطلاعات لیست مورد نظر بطور کامل از بانک اطلاعاتی حذف خواهد شد.",
text: "",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بله",
cancelButtonText: "خیر",
closeOnConfirm: false,
closeOnCancel: true,
customClass: "questionSwall"
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
async: false,
dataType: 'json',
type: 'POST',
url: deletePersonalContractingPartiesAjaxUrl,
headers: { "RequestVerificationToken": $(antiForgeryToken).val() },
data: { "id": id },
success: function (response) {
if (response.isSuccedded) {
swal({
title: "حذف با موفقیت انجام شد.",
text: "",
type: "success",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بستن",
//cancelButtonText: "خیر",
closeOnConfirm: true,
customClass: "successSwall"
},
function (isConfirm) {
if (isConfirm) {
window.location.href = indexUrl ;
}
});
}
else{
if(response.message=="DeActive")
{
swal({
title: "غیرفعال شدن این طرف حساب با موفقیت انجام شد.",
text: "به منظور حذف از دیتابیس باید کلیه عملیات مربوط به این طرف حساب را حذف نمایید.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بستن",
cancelButtonText: "بستن",
closeOnConfirm: true,
closeOnCancel: true,
customClass: "warningSwall2"
},
function (isConfirm) {
if (isConfirm) {
window.location.href = indexUrl;
}
});
}
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 removeHasInstitutionContract(id,hasInstitutionContract,hasEmployer) {
$('.sweet-alert').removeClass("successSwall");
$('.sweet-alert').removeClass("errorSwall");
//اگر همزمان در تب جدید قرارداد غیر فعال شو، پیغاماشتابه نمایش داده میشود
// if(hasInstitutionContract=="True")
// {
// swal({
// title: "حذف این طرف حساب به دلیل دارا بودن قرارداد مالی امکان پذیر نمی باشد.",
// text: "در صورت تمایل به حذف یا غیر فعال سازی این طرف حساب، می بایست کلیه عملیات مربوط به این طرف حساب را حذف نمایید.",
// type: "warning",
// showCancelButton: true,
// confirmButtonColor: "#DD6B55",
// //confirmButtonText: "بستن",
// cancelButtonText: "بستن",
// closeOnConfirm: false,
// closeOnCancel: true,
// customClass: "errorSwall"
// });
// }
// else
// {
$.ajax({
async: false,
dataType: 'json',
type: 'POST',
url: checkHasContractAjaxUrl,
headers: { "RequestVerificationToken": $(antiForgeryToken).val() },
data: { "id": id },
success: function (response) {
if (response.isSuccedded) {
removePersonalContractingParties(id);
}
else{
swal({
title: "حذف این طرف حساب به دلیل دارا بودن قرارداد مالی امکان پذیر نمی باشد.",
text: "در صورت تمایل به حذف یا غیر فعال سازی این طرف حساب، می بایست کلیه عملیات مربوط به این طرف حساب را حذف نمایید.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
//confirmButtonText: "بستن",
cancelButtonText: "بستن",
closeOnConfirm: false,
closeOnCancel: true,
customClass: "errorSwall"
});
}
},
failure: function (response) {
console.log(5, response)
}
});
}
function removePersonalContractingParties(id){
$('.sweet-alert').removeClass("successSwall");
$('.sweet-alert').removeClass("errorSwall");
$.ajax({
async: false,
dataType: 'json',
type: 'POST',
url: deletePersonalContractingPartiesAjaxUrl,
headers: { "RequestVerificationToken": $(antiForgeryToken).val() },
data: { "id": id },
success: function (response) {
if (response.isSuccedded) {
swal({
title: "حذف با موفقیت انجام شد.",
text: "",
type: "success",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بستن",
//cancelButtonText: "خیر",
closeOnConfirm: true,
customClass: "successSwall"
},
function (isConfirm) {
if (isConfirm) {
window.location.href = indexUrl ;
}
});
}
else{
if(response.message=="DeActive")
{
swal({
title: "غیرفعال شدن این طرف حساب با موفقیت انجام شد.",
text: "به منظور حذف از دیتابیس باید کلیه عملیات مربوط به این طرف حساب را حذف نمایید.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بستن",
cancelButtonText: "بستن",
closeOnConfirm: true,
closeOnCancel: true,
customClass: "warningSwall2"
},
function (isConfirm) {
if (isConfirm) {
window.location.href = indexUrl;
}
});
}
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 acitve(id) {
$('.sweet-alert').removeClass("successSwall");
$('.sweet-alert').removeClass("errorSwall");
swal({
title: "آیا از فعال کردن این طرف حساب مطمئن هستید؟",
text: "",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بله",
cancelButtonText: "خیر",
closeOnConfirm: false,
closeOnCancel: true
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
async: false,
dataType: 'json',
type: 'POST',
url: activePersonalContractingPartiesAjaxUrl,
headers: { "RequestVerificationToken": $(antiForgeryToken).val() },
data: { "id": id },
success: function (response) {
// console.log(response);
if (response.isSuccedded) {
swal({
title: response.message,
text: "",
type: "success",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بستن",
//cancelButtonText: "خیر",
closeOnConfirm: true,
customClass: "successSwall"
},
function (isConfirm) {
if (isConfirm) {
window.location.href = indexUrl;
// $("#btnSearch").click();
}
});
}
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 block(id) {
$('.sweet-alert').removeClass("successSwall");
$('.sweet-alert').removeClass("errorSwall");
swal({
title: "آیا از مسدود کردن این طرف حساب مطمئن هستید؟",
text: "",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بله",
cancelButtonText: "خیر",
closeOnConfirm: false,
closeOnCancel: true
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
async: false,
dataType: 'json',
type: 'POST',
url: blockPersonalContractingPartiesAjaxUrl,
headers: { "RequestVerificationToken": $(antiForgeryToken).val() },
data: { "id": id },
success: function (response) {
// console.log(response);
if (response.isSuccedded) {
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,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
//confirmButtonText: "بستن",
cancelButtonText: "بستن",
closeOnConfirm: false,
closeOnCancel: true,
customClass: "errorSwall"
});
}
},
failure: function (response) {
console.log(5, response)
}
});
}
});
}
function disableBlock(id,blocktime) {
$('.sweet-alert').removeClass("successSwall");
$('.sweet-alert').removeClass("errorSwall");
if(blocktime==2){
swal({
title: "آخرین حد مجاز برای خارج کردن از حالت مسدود 2 بار می باشد.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
//confirmButtonText: "بستن",
cancelButtonText: "بستن",
closeOnConfirm: false,
closeOnCancel: true,
customClass: "errorSwall"
});
}
else{
swal({
title: "آیا میخواهید این طرف حساب را از حالت مسدود خارج نمایید؟ ",
text: "",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بله",
cancelButtonText: "خیر",
closeOnConfirm: false,
closeOnCancel: true
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
async: false,
dataType: 'json',
type: 'POST',
url: disableBlockPersonalContractingPartiesAjaxUrl,
headers: { "RequestVerificationToken": $(antiForgeryToken).val() },
data: { "id": id },
success: function (response) {
//console.log(response);
if (response.isSuccedded) {
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)
}
});
}
});}
}
$(window).on('resize', function () {
if ($(window).width() < 768) {
locateButtonContainerMobile();
}
//if ($(window).width() > 768) {
// locateButtonContainer();
//}
});
$(document).on("click", function (event) {
var target = $(event.target);
if (!target.closest(".buttons-container").length
&& !target.is(".employee-operations")
&& !target.is("#createContractingParty")
&& !target.is("#createContractingParty *")
&& !target.is("#ContractingPartyDetails")
&& !target.is("#ContractingPartyDetails *")
&& !target.is("#ContractingPartyEdit")
&& !target.is("#ContractingPartyEdit *")
&& !target.is("#insertLegal")
&& !target.is("#insertLegal *")
&& !target.is("#legalDetails")
&& !target.is("#legalDetails *")
&& !target.is("#legalEdit")
&& !target.is("#legalEdit *")
) {
$(".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() {
// var beforePosition = $(".screen-view .employee-operations").position();
// var containerWidth = $('.screen-view .buttons-container').outerWidth();
// var containerHeight = $('.screen-view .buttons-container').outerHeight();
// var containerLeft = beforePosition.left + $(".screen-view .employee-operations").outerWidth() + 20;
// var containerTop = beforePosition.top + ($(".screen-view .employee-operations").outerHeight() / 2) - (containerHeight / 2);
// $('.screen-view .buttons-container').css({
// left: containerLeft,
// top: containerTop
// });
//}
function locateButtonContainerMobile() {
var beforePosition = $(".mobile-view .employee-operations").position();
var containerWidth = $('.mobile-view .buttons-container').outerWidth();
var containerHeight = $('.mobile-view .buttons-container').outerHeight();
var containerLeft = beforePosition.left + $(".mobile-view .employee-operations").outerWidth() + 25;
var containerTop = beforePosition.top + ($(".mobile-view .employee-operations").outerHeight() / 2) - (containerHeight / 2) ;
$('.mobile-view .buttons-container').css({
left: containerLeft,
top: containerTop
});
}
function removeByEmployer(id){
$('.sweet-alert').removeClass("successSwall");
$('.sweet-alert').removeClass("errorSwall");
swal({
title: "توجه داشته باشید با تایید این پیام، اطلاعات لیست مورد نظر بطور کامل از بانک اطلاعاتی حذف خواهد شد.",
text: "",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "بله",
cancelButtonText: "خیر",
closeOnConfirm: false,
closeOnCancel: true
}, function (isConfirm) {
if (isConfirm) {
swal({
title: "حذف کامل از دیتابیس میسر نمی باشد،اما این طرف حساب غیرفعال می گردد.",
text: "به منظور حذف از دیتابیس باید کلیه عملیات مربوط به این طرف حساب را حذف نمایید.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
//confirmButtonText: "بستن",
cancelButtonText: "بستن",
closeOnConfirm: false,
closeOnCancel: true,
customClass: "errorSwall"
});
}
});
}