From d99e69fa5bfa1ca0ebf86b3582620ea203d1bbcd Mon Sep 17 00:00:00 2001 From: SamSys Date: Tue, 13 May 2025 21:28:05 +0330 Subject: [PATCH] Revert "seperate left work and leftwork insurance" This reverts commit da738054df0f0b80923720ccd9958816adf79784. --- .../Pages/Company/Employees/LeftWork.cshtml | 2249 +++++++++++++- .../Employees/LeftWorkInsurance.cshtml | 2635 ++++++++++++++++- .../AssetsAdmin/page/Employee/leftWork.js | 2225 -------------- .../page/Employee/leftWorkInsurance.js | 2611 ---------------- 4 files changed, 4853 insertions(+), 4867 deletions(-) delete mode 100644 ServiceHost/wwwroot/AssetsAdmin/page/Employee/leftWork.js delete mode 100644 ServiceHost/wwwroot/AssetsAdmin/page/Employee/leftWorkInsurance.js diff --git a/ServiceHost/Areas/Admin/Pages/Company/Employees/LeftWork.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Employees/LeftWork.cshtml index 619d18b2..1bffde8c 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Employees/LeftWork.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Employees/LeftWork.cshtml @@ -519,18 +519,2239 @@ else - - \ No newline at end of file + \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Company/Employees/LeftWorkInsurance.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Employees/LeftWorkInsurance.cshtml index e297ebdd..082c2416 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Employees/LeftWorkInsurance.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Employees/LeftWorkInsurance.cshtml @@ -263,6 +263,7 @@ + 1 @@ -455,22 +456,2622 @@ - -@{ - - -} + \ No newline at end of file diff --git a/ServiceHost/wwwroot/AssetsAdmin/page/Employee/leftWork.js b/ServiceHost/wwwroot/AssetsAdmin/page/Employee/leftWork.js deleted file mode 100644 index c9cf8b31..00000000 --- a/ServiceHost/wwwroot/AssetsAdmin/page/Employee/leftWork.js +++ /dev/null @@ -1,2225 +0,0 @@ - -var list = []; -$(document).ready(function () { - if (leftWorkGroups == null || (leftWorkGroups != null && leftWorkGroups.length == 0)) { - disabledJob(); - } - - PermissionIds.forEach(function (item) { - list.push(item); - }); - - handleScroll(); - isActived(); - handleCompanyScroll(); - disappearIcon(); - checkPremision(); - - - $('.activated').click(function () { - if (!$(this).prop('checked')) { - $(this).siblings("div").addClass("actived"); - - } else { - $(this).siblings("div").removeClass("actived"); - } - }); - - const navTitle = $('.nav-title'); - if (navTitle.text().trim() === 'نام شرکت') { - navTitle.addClass("disactive"); - $('.position-code').prop('disabled', true); - } - $(".select-city").select2({ - allowClear: true - }); - - //adding / between dates - $(".date").mask("0000/00/00"); - - //this function is for disabling the first tab and adding a new row to the table of the first tab - checkcountRow(); - - //this code adds a new tab(with the content in it)... - const addTab = (counter) => { - var workshopId = $('#input1').val(); - var workshopName = $('#input1 option:selected').text(); - //the data in each tab... - const newTab = $(`
#تاریخ شروع بکارتاریخ آخرین روز کاریتاریخ ترک کارروزهای کارکرد
1
2
3
4
5
در صورت تمایل به محاسبه ی عناوین ذیل در فیش حقوقی، گزینه های موردنظر را فعال نمایید
سنوات
عیدی و پاداش
مزد و مرخصی
`); - $(".tab-content").prepend(newTab); - isActived(); - $('.activated').click(function () { - if (!$(this).prop('checked')) { - $(this).siblings("div").addClass("actived"); - - } else { - $(this).siblings("div").removeClass("actived"); - } - - }); - $(".edit-icon").unbind('click').on("click", - function (e) { - editDate(this); - e.preventDefault(); - }); - - const endDateInput = newTab.find('.end-date'); - const startDateInput = newTab.find('.start-date'); - getPersonelCode(workshopId); - getWorkshopInformation(workshopId); - - $(".date").keyup(function () { - const value = $(this).val(); - const lengthValue = value.length; - const id = $(this).attr('id'); - if (lengthValue == 10) { - if (!dateValidCheck(this)) { - $(this).addClass("errored"); - } else { - $(this).removeClass("errored"); - - if (id == 'last-day-' + counter) { - setDate(value, `last - day - ${counter} `, `end - date - ${counter} `, true); - } else if (id == 'end-date-' + counter) { - setDate(value, `end - date - ${counter} `, `end - date - ${counter} `, false); - } - } - } - }); - - }; - - //this code handles the first button(for adding new tabs) - $(function () { - var counter = 1; - $('#save1').on('click', - function (e) { - e.preventDefault(); - if ($('#input1').val() != '0') { - $("#IsDelete").val('false'); - var workshopId = $('#input1').val(); - var workshopname = $('#input1 option:selected').text(); - let navLink = $('.nav-link'); - let navTitle = navLink.find('.nav-title'); - - //if there was only one tab... - if (navTitle.text().trim() === 'نام شرکت') { - $('#tab-1').attr("data-workshopId", workshopId); - $('#tab-1').attr("data-workshopname", workshopname); - navTitle.text($('#input1 option:selected').text()); - navTitle.attr("data-workshopid", workshopId); - navLink.find('.trash-icon').attr("onclick", `deleteLeftwork(this, ${workshopId})`); - navTitle.removeClass("disactive"); - navTitle.addClass("active"); - $('#input1').val('0').trigger('change'); - getPersonelCode(workshopId); - getWorkshopInformation(workshopId); - } else { - counter++; - $("#nav-title1").removeClass("active"); - $('.position-name').prop('disabled', false); - $('.setContract').prop('disabled', false); - const newTitle = $('#input1 option:selected').text(); - const newworkshopId = $('#input1 option:selected').val(); - var $existingTitle = false; - $('.nav-title').each(function () { - if ($(this).attr("data-workshopid") == newworkshopId) { - $existingTitle = true; - } - }); - if ($existingTitle) { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - swal({ - title: 'شرکت انتخاب شده در لیست وجود دارد.', - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - return; - } else { - addTab(counter); - const newTabLink = $(`< a href = "#tab${counter}" class="nav-link" >${newTitle} `); - $(".nav-tabs").prepend(newTabLink); - handleCompanyScroll(); - // tooltip for when the title of the tabs are long - $(function () { - $('.nav-title').tooltip({ - container: 'body', - fontFamily: 'IranSans', - background: 'grey', - placement: 'top', - offset: { x: 300, y: 20 }, - trigger: 'hover', - html: true, - title: function () { - return `< span style = "font-family: IranSans, sans-serif;" > ${$(this).text()} `; - } - }); - }); - - // Add the click event listener to the new tab link - newTabLink.on('click', - function (e) { - e.preventDefault(); - const $tab = $(this); - const target = $tab.attr('href'); - $('.nav-tabs .nav-link, .tab-pane').removeClass('active'); - $tab.addClass('active'); - $(target).addClass('active'); - disableSaveBtn(); - disableInput(); - }); - newTabLink.trigger('click'); - } - $('.table-content').addClass('hide-scrollbar'); - $('#input1').val('0').trigger('change'); - }; - } - - handleScroll(); - $(".workDate-table .trash-icon").on("mouseenter", - function () { - $(this).animate({ left: "-2px" }, 50) - .animate({ left: "2px" }, 50) - .animate({ left: "0px" }, 50); - }); - checkPremision(); - - }); - - }); - - //this code handles the second button(for adding data in the first tabs table) - $(function () { - $('#save').on('click', - function (e) { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - e.preventDefault(); - $("#editLeftDate").val(''); - $("#editEndDate").val(''); - let activeTabPane = $('.tab-pane.active'); - let date1 = $('#startDate1').val(); - let date2 = $('#lastDay1').val(); - let date3 = $('#endDate1').val(); - let editIcon = activeTabPane.find(".edit-icon"); - let deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - activeTabPane.find(".date").removeClass("blinking"); - let positionCode = $('.position-code').val(); - let positionName = $(".position-name").val(); - if (positionCode == "") { - $('.position-code').addClass("errored"); - } else { - $('.position-code').removeClass("errored"); - } - - if (positionName == "") { - $('.custom-select').addClass("errored"); - } else { - $('.custom-select').removeClass("errored"); - } - - if (positionName == 0) { - $('.position-name').addClass("errored"); - } else { - $('.position-name').addClass("errored"); - } - if (date1 != '' && !checkLength($('#startDate1').val(), 10)) { - if (!dateValidCheckByValue($('#startDate1'))) { - $('#startDate1').addClass("errored"); - } else { - $('#startDate1').removeClass("errored"); - } - } - if (date2 != '' && !checkLength($('#lastDay1').val(), 10)) { - if (!dateValidCheckByValue($('#lastDay1'))) { - $('#lastDay1').addClass("errored"); - } else { - $('#lastDay1').removeClass("errored"); - } - } - if (date3 != '' && !checkLength($('#endDate1').val(), 10)) { - if (!dateValidCheckByValue($('#endDate1'))) { - $('#endDate1').addClass("errored"); - } else { - $('#endDate1').removeClass("errored"); - } - } - var editable = false; - if ($('#endDate1').val() != '' && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) { - var workshopId = activeTabPane.attr("data-workshopid"); - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: '/Admin/Company/Employees?handler=CheckEditLeftWork', - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": $('#endDate1').val(), "type": 2 }, - success: function (response) { - // console.log(response); - if (response.isSuccedded == true) { - addRow(date1, date2, date3); - handleScroll(); - disableInput(); - disableSaveBtn(); - - $('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } else { - let message = ''; - let titleAlert = ''; - - - if (response.message == "AfterContracts") { - titleAlert = "امکان ثبت تاریخ ترک کار وجود ندارد"; - message = "در صورت تمایل به ثبت تاریخ ترک کار این پرسنل، می بایست تصفیه حساب آتی را حذف نمود."; - } else if (response.message == "NoContracts") { - titleAlert = "امکان ثبت تاریخ ترک کار وجود ندارد"; - message = 'در صورتی می توان ترک کار را ثبت نمود که پرسنل در تاریخ مورد نظر دارای قرارداد باشد.'; - } else //if (response.message == "HasCheckout") - { - titleAlert = "امکان ثبت تاریخ ترک کار وجود ندارد"; - message = response.message; //"در صورت تمایل به ثبت تاریخ، تصفیه حساب مورد نظر را حذف نمایید."; - } - - swal({ - title: titleAlert, //$("#editLeftDate").val() != '' ? "امکان ویرایش تاریخ وجود ندارد" : "امکان ثبت تاریخ وجود ندارد", - text: message, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - } - }, - error: function (response) { - console.log(5, response); - } - }); - } else if ($('#startDate1').val() != '' && !$('#startDate1').hasClass('errored')) { - addRow(date1, date2, date3); - handleScroll(); - disableInput(); - disableSaveBtn(); - - $('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } - }); - }); - - - // Add the click event listener to the new tab link - $('.nav-tabs .nav-link').on('click', - function (e) { - e.preventDefault(); - updateRowNumbers(); - const $tab = $(this); - const target = $tab.attr('href'); - $('.nav-tabs .nav-link, .tab-pane').removeClass('active'); - $tab.addClass('active'); - $(target).addClass('active'); - disableInput(); - handleScroll(); - disableSaveBtn(); - }); - checkPremision(); -}); -$(document).on('keyup', - function (event) { - if (event.key === 'Enter' || event.key === 'Tab') { - employerDiagnose(); - } - }); - -function vibratingAnimation(element) { - $(element).animate({ left: "-2px" }, 50) - .animate({ left: "2px" }, 50) - .animate({ left: "0px" }, 50); -} - -function startDateEdit(element) { - const deletedRow = $(element).closest('tr'); - deletedRow.find('td:eq(1)').text(""); - deletedRow.find('td:eq(6)').text(""); - disableInput(); - disableSaveBtn(); - disappearIcon(); - checkPremision(); -} - -function endDateEdit(element) { - const deletedRow = $(element).closest('tr'); - deletedRow.find('td:eq(3)').text(""); - deletedRow.find('td:eq(4)').text(""); - disableInput(); - disableSaveBtn(); - disappearIcon(); - checkPremision(); -} - -$(".edit-date , .edit-icon").on("mouseenter", - function () { - vibratingAnimation(this); - }); - -function disappearIcon() { - const activeTabPane = $('.tab-pane.active'); - const table = activeTabPane.find('.workDate-table'); - table.find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)').text(); - const rowEndDate = row.find('td:eq(4)').text(); - if (rowStartDate == "") { - row.find('td:eq(2) a').addClass("d-none"); - } else { - row.find('td:eq(2) a').removeClass("d-none"); - } - if (rowEndDate == "") { - row.find('td:eq(5) a').addClass("d-none"); - } else { - row.find('td:eq(5) a').removeClass("d-none"); - } - }); -} - - -function editDate(element) { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - $("#editLeftDate").val(''); - $("#editEndDate").val(''); - $("#editStartDate").val(''); - let activeTabPane = $('.tab-pane.active'); - var workshopId = activeTabPane.attr("data-workshopid"); - var row = $(element).closest('tr'); - var id = row.attr('data-id'); - var rowIndex = $(element).closest('tr').index(); - var colIndex = $(element).closest('td').index(); - $("#deleteIndex").val(''); - $("#editIndex").val(row.find('td:eq(0)').text()); - - if (colIndex == 2) { - let startDateText = row.find('td:eq(1)').text(); - if (id != "0" && id != 'undefined' && startDateText != '') { - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: '/Admin/Company/Employees?handler=CheckEditLeftWork', - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": startDateText, "type": 1 }, - success: function (response) { - console.log(response); - if (response.isSuccedded == true) { - $("#editStartDate").val(startDateText); - activeTabPane.find(".input2").val(startDateText).addClass("blinking"); - row.find('td:eq(1)').text(""); - disableInput(); - disableSaveBtn(); - const editIcon = activeTabPane.find(".edit-icon"); - const deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.addClass("disabled-edit"); - editIcon.addClass("disabled-edit"); - } else { - - swal({ - title: "امکان ویرایش تاریخ وجود ندارد", - text: response.message, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - row.find('td:eq(1)').addClass("emptyStart"); - - } - }, - error: function (response) { - console.log(5, response); - } - }); - } else { - let startDateText = row.find('td:eq(1)').text(); - $("#editStartDate").val(startDateText); - activeTabPane.find(".input2").val(startDateText).addClass("blinking"); - row.find('td:eq(1)').text(""); - disableInput(); - disableSaveBtn(); - let editIcon = activeTabPane.find(".edit-icon"); - let deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.addClass("disabled-edit"); - editIcon.addClass("disabled-edit"); - } - } else if (colIndex == 5) { - let lastDateText = row.find('td:eq(3)').text(); - let endDateText = row.find('td:eq(4)').text(); - if (id != "0" && id != 'undefined' && endDateText != '') { - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: '/Admin/Company/Employees?handler=CheckEditLeftWork', - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": endDateText, "type": 2 }, - success: function (response) { - // console.log(response); - if (response.isSuccedded == true) { - - $("#editLeftDate").val(lastDateText); - $("#editEndDate").val(endDateText); - activeTabPane.find(".input3").val(lastDateText).addClass("blinking"); - activeTabPane.find(".input4").val(endDateText).addClass("blinking"); - row.find('td:eq(3)').text(""); - row.find('td:eq(4)').text(""); - disableInput(); - disableSaveBtn(); - const editIcon = activeTabPane.find(".edit-icon"); - const deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.addClass("disabled-edit"); - editIcon.addClass("disabled-edit"); - } else { - let message = ''; - let titleAlert = ''; - - - if (response.message == "AfterContracts") { - titleAlert = "امکان ثبت تاریخ ترک کار وجود ندارد"; - message = "در صورت تمایل به ثبت تاریخ ترک کار این پرسنل، می بایست قراردادهای آتی را حذف نمود.";; - } else if (response.message == "NoContracts") { - titleAlert = "امکان ثبت تاریخ ترک کار وجود ندارد"; - message = 'در صورتی می توان ترک کار را ثبت نمود که پرسنل در تاریخ مورد نظر دارای قرارداد باشد.'; - } else //if (response.message == "HasCheckout") - { - titleAlert = "امکان ثبت تاریخ ترک کار وجود ندارد"; - message = response.message; //"در صورت تمایل به ثبت تاریخ، تصفیه حساب مورد نظر را حذف نمایید."; - } - - - swal({ - title: titleAlert, //$("#editLeftDate").val() != '' ? "امکان ویرایش تاریخ وجود ندارد" : "امکان ثبت تاریخ وجود ندارد", - text: message, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - - - // swal({ - // title: "امکان ویرایش تاریخ وجود ندارد", - // text: "در صورت تمایل به ویرایش تاریخ می بایست کلیه قراردادهای تنظیمی این پرسنل حذف گردد.", - // type: "warning", - // showCancelButton: true, - // confirmButtonColor: "#DD6B55", - // //confirmButtonText: "بستن", - // cancelButtonText: "بستن", - // closeOnConfirm: false, - // customClass: "errorSwall" - // }); - const tr = $(activeTabPane).find('.workDate-table tbody tr'); - row.find('td:eq(3)').addClass("emptyStart"); - row.find('td:eq(4)').addClass("emptyStart"); - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - } - }, - error: function (response) { - console.log(5, response); - } - }); - } else { - $("#editLeftDate").val(lastDateText); - $("#editEndDate").val(endDateText); - activeTabPane.find(".input3").val(lastDateText).addClass("blinking"); - activeTabPane.find(".input4").val(endDateText).addClass("blinking"); - row.find('td:eq(3)').text(""); - row.find('td:eq(4)').text(""); - disableInput(); - disableSaveBtn(); - let editIcon = activeTabPane.find(".edit-icon"); - let deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.addClass("disabled-edit"); - editIcon.addClass("disabled-edit"); - } - } - -} - -$(".edit-icon").unbind('click').on("click", - function (e) { - editDate(this); - }); - -handleCompanyScroll(); -//this code checks the rows, if there are empty rows,they will be filled, and if there is none, a new row will be added -let addRow = (date1, date2, date3) => { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - - let activeTabPane = $('.tab-pane.active'); - let table = activeTabPane.find('.workDate-table'); - let startHasClass = activeTabPane.find('.input2').hasClass('blinking'); - let conflictFound = false; - table.find("tbody tr").each(function (rowIndex) { - - let row = $(this); - let iconShown = row.find('td:eq(2) a').hasClass("d-none"); - let rowStartDate = row.find('td:eq(1)').text(); - let rowEndDate = row.find('td:eq(4)').text(); - const $existingDate1 = row.find(`td: eq(1): contains("${date1}")`); - - - var index = ''; - if ($("#deleteIndex").val() != '') { - index = $("#deleteIndex").val(); - } else if ($("#editIndex").val() != '') - index = $("#editIndex").val(); - else { - index = rowIndex + 1; - } - - console.log(index); - - let trNumber = table.find(`tr: eq(${index})`); - let firstTd = trNumber.find('td:eq(1)').text(); - let lastTd = trNumber.find('td:eq(4)').text(); - - - if (date1 != '' && $existingDate1.length > 0) { - swal({ - title: `تاریخ شروع وارد شده قبلا در ردیف ${index} وارد شده است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return; - } - const $existingDate2 = row.find(`td: eq(4): contains("${date1}")`); - if (date1 != '' && $existingDate2.length > 0) { - swal({ - title: `تاریخ شروع وارد شده با تاریخ پایان در ردیف ${index} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return; - } - const $existingDate3 = row.find(`td: eq(4): contains("${date3}")`); - if (date3 != '' && $existingDate3.length > 0) { - swal({ - title: `تاریخ پایان وارد شده قبلا در ردیف ${index} وارد شده است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return; - } - const $existingDate4 = row.find(`td: eq(1): contains("${date3}")`); - if (date3 != '' && $existingDate4.length > 0) { - swal({ - title: `تاریخ پایان وارد شده با تاریخ شروع در ردیف ${index} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#endDate1').addClass("errored"); - conflictFound = true; - return; - } - const $existingDate5 = row.find(`td: eq(1): contains("${date2}")`); - if (date2 != '' && $existingDate5.length > 0) { - swal({ - title: `تاریخ آخرین روز کاری وارد شده با تاریخ شروع در ردیف ${index} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return; - } - - if (rowStartDate != '' && date3 != '' && date3 > rowStartDate && date3 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - swal({ - title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return false; - } - - if (rowStartDate != '' && date3 != '' && rowEndDate == '' && date3 < rowStartDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - swal({ - title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return false; - } - - if (rowStartDate != '' && date1 != '' && date1 > rowStartDate && date1 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return false; - } - //جدید - if (rowStartDate != '' && rowEndDate != '' && date1 != '' && date1 < rowStartDate && date1 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return false; - } - // - if (rowStartDate != '' && rowEndDate != '' && date1 != '' && date1 < rowEndDate && date1 >= rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date1 != '' && rowStartDate != '' && date1 > rowStartDate && date1 < rowEndDate) { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date3 != '' && rowStartDate != '' && date3 > rowStartDate && date3 < rowEndDate) { - swal({ - title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && lastTd != '' && date1 != '' && date1 > lastTd) { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && firstTd != '' && date3 != '' && date3 < firstTd) { - // $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.'); - swal({ - title: `تاریخ پایان با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return false; - } - }); - if (!conflictFound) { - // //let emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - //var index= $("#editIndex").val(); - - // let emptyRow = null; - // if (index == '') - // emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - // else - // emptyRow=table.find('tr:eq('+index+')'); - var index = ''; - if ($("#editIndex").val() != '') - index = $("#editIndex").val(); - else if ($("#deleteIndex").val() != '') - index = $("#deleteIndex").val(); - - let emptyRow = null; - if (index == '') - emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - else - emptyRow = table.find(`tr: eq(${index})`); - - - if (emptyRow.length > 0) { - - if (date1 != '') - emptyRow.children('td:eq(1)').text(date1); - if (date2 != '') - emptyRow.children('td:eq(3)').text(date2); - if (date3 != '') - emptyRow.children('td:eq(4)').text(date3); - //emptyRow.children('td:eq(5)').text("_"); - emptyRow.children('td:eq(6)').text("_"); - disappearIcon(); - checkPremision(); - $("#editIndex").val(''); - $("#deleteIndex").val(''); - } - if (emptyRow.length === 0 && !conflictFound) { - let rowCount = table.find("tbody tr").length; - let newRow = `< tr data - id="0" >${rowCount + 1}${date1 - }${date2}${date3 - } _ `; - table.find("tbody").append(newRow); - disableInput(); - disableSaveBtn(); - disappearIcon(); - checkPremision(); - } - $(".edit-date , .edit-icon").on("mouseenter", - function () { - vibratingAnimation(this); - }); - //$(".edit-date.first-edit").on("click", function () { - // startDateEdit(this) - //}); - //$(".edit-date.second-edit").on("click", function () { - // endDateEdit(this) - //}); - sortDates(); - updateRowNumbers(); - - $('#startDate1').val(""); - $('#lastDay1').val(""); - $('#endDate1').val(""); - } - -}; - - -//this code is like addRow for the tabs except the first tab -let addRow2 = (counter, date1, date2, date3) => { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - - const activeTabPane = $('.tab-pane.active'); - const table = activeTabPane.find('.workDate-table'); - const tableRow = table.find('tbody tr'); - const emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - const startDate = activeTabPane.find('.input2'); - const lastDay = activeTabPane.find('.input3'); - const endDate = activeTabPane.find('.input4'); - let conflictFound = false; - tableRow.each(function (rowIndex) { - - let row = $(this); - let iconShown = row.find('td:eq(2) a').hasClass("d-none"); - let rowStartDate = row.find('td:eq(1)').text(); - let rowEndDate = row.find('td:eq(4)').text(); - const $existingDate1 = row.find(`td: eq(1): contains("${date1}")`); - - var index = ''; - if ($("#deleteIndex").val() != '') { - index = $("#deleteIndex").val(); - } else if ($("#editIndex").val() != '') - index = $("#editIndex").val(); - else { - index = rowIndex + 1; - } - - let trNumber = table.find(`tr: eq(${index})`); - let firstTd = trNumber.find('td:eq(1)').text(); - let lastTd = trNumber.find('td:eq(4)').text(); - - if (date1 != '' && $existingDate1.length > 0) { - swal({ - title: `تاریخ شروع وارد شده قبلا در ردیف ${index} وارد شده است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return; - } - const $existingDate2 = row.find(`td: eq(4): contains("${date1}")`); - if (date1 != '' && $existingDate2.length > 0) { - swal({ - title: `تاریخ شروع وارد شده با تاریخ پایان در ردیف ${index} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return; - } - const $existingDate3 = row.find(`td: eq(4): contains("${date2}")`); - if (date2 != '' && $existingDate3.length > 0) { - swal({ - title: `تاریخ پایان وارد شده قبلا در ردیف ${index} وارد شده است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - lastDay.addClass("errored"); - conflictFound = true; - return; - } - - const $existingDate4 = row.find(`td: eq(1): contains("${date2}")`); - if (date2 != '' && $existingDate4.length > 0) { - swal({ - title: `تاریخ آخرین روز کاری وارد شده با تاریخ شروع در ردیف ${index} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - lastDay.addClass("errored"); - conflictFound = true; - return; - } - const $existingDate5 = row.find(`td: eq(1): contains("${date3}")`); - if (date3 != '' && $existingDate5.length > 0) { - swal({ - title: `تاریخ پایان وارد شده با تاریخ شروع در ردیف ${index} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - endDate.addClass("errored"); - conflictFound = true; - return; - } - - if (rowStartDate != '' && date2 != '' && date2 > rowStartDate && date2 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - swal({ - title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - lastDay.addClass("errored"); - conflictFound = true; - return false; - } - //جدید - if (rowStartDate != '' && rowEndDate != '' && date1 != '' && date1 < rowStartDate && date1 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return false; - } - // - if (rowStartDate != '' && date1 != '' && date1 > rowStartDate && date1 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return false; - } - - if (rowStartDate != '' && date2 != '' && rowEndDate == '' && date2 < rowStartDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - swal({ - title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - lastDay.addClass("errored"); - conflictFound = true; - return false; - } - if (rowStartDate != '' && rowEndDate != '' && date1 != '' && date1 < rowEndDate && date1 >= rowStartDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date1 != '' && rowStartDate != '' && date1 > rowStartDate && date1 < rowEndDate) { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date3 != '' && rowStartDate != '' && date3 > rowStartDate && date3 < rowEndDate) { - swal({ - title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && lastTd != '' && date1 != '' && date1 > lastTd) { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - lastDay.addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && firstTd != '' && date3 != '' && date3 < firstTd) { - swal({ - title: `تاریخ پایان با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - lastDay.addClass("errored"); - conflictFound = true; - return false; - } - }); - if (!conflictFound) { - let index = ''; - if ($("#editIndex").val() != '') - index = $("#editIndex").val(); - else if ($("#deleteIndex").val() != '') - index = $("#deleteIndex").val(); - // let emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - let emptyRow = null; - if (index == '') - emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - else - emptyRow = table.find(`tr: eq(${index})`); - - if (emptyRow.length > 0) { - if (date1 != '') - emptyRow.children('td:eq(1)').text(date1); - if (date2 != '') - emptyRow.children('td:eq(3)').text(date2); - if (date3 != '') - emptyRow.children('td:eq(4)').text(date3); - //emptyRow.children('td:eq(5)').text("_"); - emptyRow.children('td:eq(6)').text("_"); - } - if (emptyRow.length === 0) { - const rowCount = table.find("tbody tr").length; - const newRow = `< tr data - id="0" >${rowCount + 1}${date1 - }${date2}${date3 - } _ `; - table.find("tbody").append(newRow); - disableInput(); - disableSaveBtn(); - - } - sortDates(); - updateRowNumbers(); - disappearIcon(); - checkPremision(); - - $("#editIndex").val(''); - $("#deleteIndex").val(''); - } - $(".edit-date , .edit-icon").on("mouseenter", - function () { - vibratingAnimation(this); - }); - - -}; - -//this code checks the row number -let updateRowNumbers = () => { - const activeTabPane = $('.tab-pane.active'); - const rows = activeTabPane.find(".workDate-table tbody").find("tr"); - rows.each(function (index) { - $(this).find("td:first-child").text(index + 1); - }); -}; - -//this code sorts the table based on the second date column in descending order -function sortDates() { - const activeTabPane = $('.tab-pane.active'); - const table = activeTabPane.find('.workDate-table'); - const rows = table.find('tr:gt(0)').toArray(); - rows.sort(function (a, b) { - const date1a = new Date($(a).find('td:eq(1)').text().replace(/\//g, '-')); - const date1b = new Date($(b).find('td:eq(1)').text().replace(/\//g, '-')); - return date1b - date1a; - }); - for (let i = 0; i < rows.length; i++) { - table.append(rows[i]); - } -} - -//date keyup for tab-1 -$(".date").keyup(function () { - const value = $(this).val(); - const lengthValue = value.length; - const id = $(this).attr('id'); - if (lengthValue == 10) { - if (!dateValidCheck(this)) { - $(this).addClass("errored"); - } else { - $(this).removeClass("errored"); - - if (id == 'lastDay1') { - setDate(value, 'lastDay1', 'endDate1', true); - } else if (id == 'endDate1') { - setDate(value, 'endDate1', 'lastDay1', false); - } - } - } -}); -//date keyup for tab-except1 -$(".date").keyup(function () { - const value = $(this).val(); - const lengthValue = value.length; - const activeTabPane = $('.tab-pane.active'); - const startDate = activeTabPane.find('.input2'); - const lastDay = activeTabPane.find('.input3'); - const endDate = activeTabPane.find('.input4'); - const endDateId = endDate.attr('id'); - const lastDateId = lastDay.attr('id'); - const id = $(this).attr('id'); - - if (lengthValue == 10) { - if (!dateValidCheck(this)) { - $(this).addClass("errored"); - } else { - $(this).removeClass("errored"); - - if (id == lastDateId) { - setDate(value, lastDateId, endDateId, true); - } else if (id == endDateId) { - setDate(value, endDateId, lastDateId, false); - } - } - } -}); - -function setDate(value, fieldIdInput, fieldIdResult, islastDay) { - let urlPost = ''; - if (islastDay == true) { - urlPost = AfterDateurl; - } else { - urlPost = BeforeDateurl; - } - $.ajax({ - /* contentType: 'charset=utf-8',*/ - dataType: 'json', - type: 'POST', - url: urlPost, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "date": value }, - success: function (response) { - - - $(`#${fieldIdResult} `).val(response.resultDate); - }, - failure: function (response) { - //console.log(5, response); - } - - }); -} - - -$("#btnSaveData").click(function () { - $(".input-send-data").remove(); - - $(".tab-pane").each(function (i) { - var workshopid = $(this).attr("data-workshopid"); - var workshopName = $(this).attr("data-workshopName"); - const employeeId = modelEmployeeId; - const personnelCode = $(this).find('input.position-code'); - var jobId = $(this).find('.ul-search').find('span.value').attr('data-value'); //$(this).find('.select-city').val(); - var includeStatus = $(this).find('input[type=checkbox]').is(":checked"); - var addBonusesPay = $(this).find('input.addbonusespay').is(":checked"); - var addYearsPay = $(this).find('input.addyearspay').is(":checked"); - var addLeavePay = $(this).find('input.addleavepay').is(":checked"); - - const haspersonelcode = personnelCode.attr("data-haspersonelcode"); - - if (haspersonelcode.toLowerCase() != "true") { - $("#divAppendData").append(`< input class="input-send-data" type = "hidden" name = "PersonnelCode[${i}].HasPersonelCode" id = "PersonnelCode_${i - }__HasPersonelCode" value="false" />`); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - } else { - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - } - var index2 = 0; - $(this).find('table tr').each(function (x) { - const leftWorkDate = $(this).find('td:eq(4)').text().trim(); - const startWorkDate = $(this).find('td:eq(1)').text().trim(); - const employeeId = modelEmployeeId; - const id = $(this).attr('data-id'); - // console.log(leftWorkDate); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - if (startWorkDate != '') { - - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - - //$("#divAppendData").append(''); - index2 = index2 + 1; - } - }); - }); - - //check if all the rows have start date if they have end date - let conflictFound = false; - $('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText == '' && rowEndDateText != '') { - rowStartDate.addClass("emptyStart"); - conflictFound = true; - } - }); - if (!conflictFound) { - $("#createLeftWork").submit(); - } - - // $('#sendData').click(); -}); -$('#createLeftWork').submit(function (e) { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - e.preventDefault(); - e.stopImmediatePropagation(); - $.ajax({ - type: "POST", - url: $(this).attr('action'), - data: $(this).serialize(), - success: function (response) { - // console.log(response); - if (response.flag == 'list') { - let result = ''; - $("#resultdiv").html(result); - $("#result-modal").modal('show'); - } else { - if (response.endResult.isSuccedded == true) { - - swal({ - title: response.endResult.message, - text: "", - type: "success", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: "بستن", - //cancelButtonText: "خیر", - closeOnConfirm: true, - customClass: "successSwall" - }); - // $("#MainModal").modal('hide'); - // $('.btn-search1').click(); - } else { - swal({ - title: response.endResult.message, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - } - } - } - - }); - return false; -}); - -function checkcountRow() { - $(".tab-pane").each(function () { - const tab = $(this); - const table = $(this).find('table'); - table.find('tr').each(function (x) { - const leftWorkDate = $(this).find('td:eq(4)').text().trim(); - const startWorkDate = $(this).find('td:eq(1)').text().trim(); - disableInput(); - disableSaveBtn(); - }); - - const trCount = $(this).find('table tr').length - 1; - const newRowNumber = 5 - trCount; - if (trCount < 5) { - for (let index = 0; index < newRowNumber; index++) { - const newRow = `${trCount + index + 1 - }`; - table.find("tbody").append(newRow); - disappearIcon(); - checkPremision(); - } - - } - }); - sortDates(); - handleScroll(); - -} - -//this function handles the show or hide of the scrollbar -function handleScroll() { - const activeTabPane = $('.tab-pane.active'); - const rows = activeTabPane.find(".workDate-table tbody").find("tr"); - const rowCount = rows.length; - const content = activeTabPane.find('.table-content'); - if (rowCount > 5) { - content.removeClass('hide-scrollbar'); - } else { - content.addClass('hide-scrollbar'); - } -} - -function isActived() { - const activeTabPane = $('.tab-pane.active'); - const checked = activeTabPane.find('.activated'); - checked.each(function () { - if (!checked.prop('checked')) { - $(this).siblings("div").addClass("actived"); - - } else { - $(this).siblings("div").removeClass("actived"); - } - }); -} - -//this function handles the show or hide of the scrollbar of the company titles -function handleCompanyScroll() { - if ($('.nav-tabs a').length <= 4) { - $('.nav-tabs').addClass('hide-scrollbar'); - } else { - $('.nav-tabs').removeClass('hide-scrollbar'); - } -} - -function disableSaveBtn() { - const activeTabPane = $('.tab-pane'); - const table = activeTabPane.find(".workDate-table tbody").get(0); - const navLink = $('.nav-link'); - const navTitle = navLink.find('.nav-title'); - const firstColumnData = Array.from(table.rows) - .map(row => row.cells[1].textContent.trim()) - .filter(cellValue => cellValue !== ""); - const secondColumnData = Array.from(table.rows) - .map(row => row.cells[3].textContent.trim()) - .filter(cellValue => cellValue !== ""); - const thirdColumnData = Array.from(table.rows) - .map(row => row.cells[4].textContent.trim()) - .filter(cellValue => cellValue !== ""); - if (navTitle.text().trim() === 'نام شرکت') { - $("#save1").removeClass("buttonDeactived"); - } else if (firstColumnData.length > secondColumnData.length) { - $("#save1").addClass("buttonDeactived"); - } else if (firstColumnData.length == 0 && secondColumnData.length == 0) { - $("#save1").addClass("buttonDeactived"); - } else { - $("#save1").removeClass("buttonDeactived"); - } -} - -// this function disable/enable the input fields based on the data in the table -function disableInput() { - let activeTabPane = $('.tab-pane.active'); - let table = activeTabPane.find(".workDate-table tbody").get(0); - let navLink = $('.nav-link'); - let navTitle = navLink.find('.nav-title'); - - let firstColumnData = Array.from(table.rows) - .map(row => row.cells[1].textContent.trim()) - .filter(cellValue => cellValue !== ""); - - let secondColumnData = Array.from(table.rows) - .map(row => row.cells[3].textContent.trim()) - .filter(cellValue => cellValue !== ""); - - let thirdColumnData = Array.from(table.rows) - .map(row => row.cells[4].textContent.trim()) - .filter(cellValue => cellValue !== ""); - - if (navTitle.text().trim() === 'نام شرکت') { - disabledJob(); - activeTabPane.find('.input2').prop('disabled', true); - activeTabPane.find('.input3').prop('disabled', true); - activeTabPane.find('.input4').prop('disabled', true); - if (!activeTabPane.find('.input2').hasClass('blinking')) { - activeTabPane.find('.input2').val(''); - } else if (!$('.input3').hasClass('blinking')) { - activeTabPane.find('.input3').val(''); - } else if (!$('.input4').hasClass('blinking')) { - activeTabPane.find('.input4').val(''); - } - - activeTabPane.find('.position-name').prop('disabled', true); - // $('.position-code').prop('disabled', true); - activeTabPane.find('.setContract').prop('disabled', true); - activeTabPane.find('.options-check').addClass('disactived'); - } else if (firstColumnData.length > secondColumnData.length) { - removeDisabledJob(); - activeTabPane.find('.input2').prop('disabled', true); - activeTabPane.find('.input2').val(''); - activeTabPane.find('.input3').prop('disabled', false); - activeTabPane.find('.input4').prop('disabled', false); - } else { - removeDisabledJob(); - activeTabPane.find('.input3').val(''); - activeTabPane.find('.input4').val(''); - activeTabPane.find('.input2').prop('disabled', false); - activeTabPane.find('.input3').prop('disabled', true); - activeTabPane.find('.input4').prop('disabled', true); - activeTabPane.find('.position-name').prop('disabled', false); - // $('.position-code').prop('disabled', false); - activeTabPane.find('.setContract').prop('disabled', false); - activeTabPane.find('.options-check').removeClass('disactived'); - } - - var haspersonelcode = activeTabPane.find('input.position-code').attr("data-haspersonelcode"); - //console.log(haspersonelcode); - if (haspersonelcode.toLowerCase() == "true" || haspersonelcode == '') { - activeTabPane.find('input.position-code').prop('disabled', true); - } else { - activeTabPane.find('input.position-code').prop('disabled', false); - } -} - -// tooltip for when the title of the tabs are long -$(function () { - $('.nav-title').tooltip({ - container: 'body', - fontFamily: 'IranSans', - background: 'grey', - placement: 'top', - offset: { x: 150, y: 20 }, - trigger: 'hover', - html: true, - title: function () { - return `${$(this).text()}`; - } - }); -}); - -//this code controls the trash icon -$(".workDate-table .trash-icon").on("mouseenter", - function () { - $(this).animate({ left: "-4px" }, 50) - .animate({ left: "4px" }, 50) - .animate({ left: "0px" }, 50); - }); - -function deleteLeftwork(element, workshopId) { - swal({ - title: "توجه داشته باشید با تایید این پیام، اطلاعات لیست مورد نظر بطور کامل از بانک اطلاعاتی حذف خواهد شد.", - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: "بله", - cancelButtonText: "خیر", - closeOnConfirm: false, - closeOnCancel: true - }, - function (isConfirm) { - if (isConfirm) { - const newItem = $(element).attr('newitem'); - var result = false; - if (newItem == null) { - $("#IsDelete").val('true'); - //result=deleteWorkshop(workshopId); - deleteWorkshop(workshopId).then(function (res) { - result = res; - afterDeleteWorkshop(element, workshopId, result, newItem); - }).catch(function (error) { - console.error(error); - }); - } else { - afterDeleteWorkshop(element, workshopId, result, newItem); - } - disableInput(); - disableSaveBtn(); - - } - }); -} - -//the save button in the new tab... -//$('.save').click(function (e) { -// $("#editStartDate").val(''); -// $("#editLeftDate").val(''); -// $("#editEndDate").val(''); -// e.preventDefault(); -// saveData(); -// let activeTabPane = $('.tab-pane.active'); -// let editIcon = activeTabPane.find(".edit-icon"); -// let deleteIcon = activeTabPane.find(".edit-date"); -// deleteIcon.removeClass("disabled-edit"); -// editIcon.removeClass("disabled-edit"); -// activeTabPane.find(".date").removeClass("blinking"); -//}); -function saveData() { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - $("#editStartDate").val(''); - $("#editLeftDate").val(''); - $("#editEndDate").val(''); - let activeTabPane = $('.tab-pane.active'); - let editIcon = activeTabPane.find(".edit-icon"); - let deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - activeTabPane.find(".date").removeClass("blinking"); - let startDate = activeTabPane.find('.input2'); - let lastDay = activeTabPane.find('.input3'); - let endDate = activeTabPane.find('.input4'); - let startValue = startDate.val(); - let lastValue = lastDay.val(); - let endValue = endDate.val(); - let dateId = startDate.attr('id'); - let number = dateId.match(/\d+/)[0]; - if (startValue != '' && !checkLength(startDate.val(), 10)) { - if (!dateValidCheckByValue(startDate)) { - startDate.addClass("errored"); - } else { - startDate.removeClass("errored"); - } - } - if (lastValue != '' && !checkLength(lastDay.val(), 10)) { - if (!dateValidCheckByValue(startDate)) { - lastDay.addClass("errored"); - } else { - lastDay.removeClass("errored"); - } - } - if (endValue != '' && !checkLength(endDate.val(), 10)) { - if (!dateValidCheckByValue(endDate)) { - endDate.addClass("errored"); - } else { - endDate.removeClass("errored"); - } - } - - if (!activeTabPane.find('.date').hasClass('errored')) { - - if (lastDay.val() != '' && !lastDay.hasClass('errored') && !endDate.hasClass('errored')) { - var workshopId = activeTabPane.attr("data-workshopid"); - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: '/Admin/Company/Employees?handler=CheckEditLeftWork', - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": endValue, "type": 2 }, - success: function (response) { - // console.log(response); - if (response.isSuccedded == true) { - addRow2(number, startValue, lastValue, endValue); - activeTabPane.find('.input2').val(''); - disableInput(); - disableSaveBtn(); - handleScroll(); - - $('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } else { - let message = ''; - let titleAlert = ''; - - - if (response.message == "AfterContracts") { - titleAlert = "امکان ثبت تاریخ ترک کار وجود ندارد"; - message = "در صورت تمایل به ثبت تاریخ ترک کار این پرسنل، می بایست قراردادهای آتی را حذف نمود.";; - } else if (response.message == "NoContracts") { - titleAlert = "امکان ثبت تاریخ ترک کار وجود ندارد"; - message = 'در صورتی می توان ترک کار را ثبت نمود که پرسنل در تاریخ مورد نظر دارای قرارداد باشد.'; - } else //if (response.message == "HasCheckout") - { - titleAlert = "امکان ثبت تاریخ ترک کار وجود ندارد"; - message = response.message; //"در صورت تمایل به ثبت تاریخ، تصفیه حساب مورد نظر را حذف نمایید."; - } - - - swal({ - title: titleAlert, //$("#editLeftDate").val() != '' ? "امکان ویرایش تاریخ وجود ندارد" : "امکان ثبت تاریخ وجود ندارد", - text: message, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - } - }, - error: function (response) { - console.log(5, response); - } - }); - } else if (startDate.val() != '' && !startDate.hasClass('errored')) { - addRow2(number, startValue, lastValue, endValue); - activeTabPane.find('.input2').val(''); - disableInput(); - disableSaveBtn(); - handleScroll(); - - $('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } - - } - -} - -var timer = null; -// $('body').on('keyup', '.select2-search__field', function () { -// clearTimeout(timer); -// timer = setTimeout(jobListByText, 1000); -// }); - - -function getPersonelCode(workshopId) { - - const employeeId = modelEmployeeId; - // var workshopId=$("#input1").val(); - - $.ajax({ - /* contentType: 'charset=utf-8',*/ - dataType: 'json', - type: 'POST', - url: GetPersonelCodeurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": Number(workshopId), "employeeId": Number(employeeId) }, - success: function (response) { - console.log(response); - const inputCode = $('.tab-pane.active').find("input.position-code"); - inputCode.val(response.personnelCode); - if (response.hasPersonelCode) { - inputCode.attr("disabled", "disabled"); - inputCode.attr("data-haspersonelcode", "true"); - } else { - inputCode.attr("data-haspersonelcode", "false"); - } - disableInput(); - disableSaveBtn(); - }, - failure: function (response) { - // console.log(5, response); - } - - }); - -} - -function getWorkshopInformation(workshopId) { - const employeeId = modelEmployeeId; - - - $.ajax({ - /* contentType: 'charset=utf-8',*/ - dataType: 'json', - type: 'POST', - url: GetWorkshopInformationurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": Number(workshopId) }, - success: function (response) { - console.log(response); - - const addBonusesPay = $('.tab-pane.active').find("input.addbonusespay"); - const addYearsPay = $('.tab-pane.active').find("input.addyearspay"); - const addLeavePay = $('.tab-pane.active').find("input.addleavepay"); - - if (response.addBonusesPay) { - addBonusesPay.prop("checked", true); - // addBonusesPay.trigger("click"); - } else { - addBonusesPay.prop("checked", false); - } - - if (response.addYearsPay) { - addYearsPay.prop("checked", true); - // addYearsPay.trigger("click"); - } else { - addYearsPay.prop("checked", false); - } - - if (response.addLeavePay) { - addLeavePay.prop("checked", true); - //addLeavePay.trigger("click"); - } else { - addLeavePay.prop("checked", false); - } - - }, - failure: function (response) { - // console.log(5, response); - } - - }); - -} - -lock = false; -lastValue = ''; - -function jobListByText() { - const this_ = $(".select2-search__field"); - var text = $(this_).val(); - var selectItem = $('.tab-pane.active').find('.select-city'); - const selectControls = $(this_).attr("aria-controls"); - if (text != "" && selectControls != "select2-input1-results") { - if (!lock) { - lock = true; - lastValue = text; - } else { - return; - } - $.ajax({ - /* contentType: 'charset=utf-8',*/ - dataType: 'json', - type: 'POST', - url: JobListByTexturl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "textSearch": text }, - success: function (response) { - lock = false; - $.each(response.jobList, - function (i, item) { - if (selectItem.find(`option[value='${item.id}']`).length == 0) { - const newOption = new Option((item.jobName + ' | ' + item.jobCode), item.id, true, true); - selectItem.append(newOption).trigger('change'); - } - }); - if (text != lastValue) { - jobListByText($(".select2-search__field")); - } - }, - failure: function (response) { - lock = false; - console.log(5, response); - } - }); - } else { - //console.log(10); - } -} - -function checkPremision() { - if (list.indexOf(10422) == -1) { - $(".permission-removeDate").addClass("d-none"); - } - if (list.indexOf(10423) == -1) { - $(".permission-editDate").addClass("d-none"); - } - if (list.indexOf(10424) == -1) { - $(".permission-options").addClass("d-none"); - } - if (list.indexOf(10421) == -1) { - $('.delworkshop').remove(); - } -} - -function deleteWorkshop(id) { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - return new Promise(function (resolve, reject) { - $.ajax({ - dataType: 'json', - type: 'POST', - url: DeleteLeftWorkWorkshopurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": id, "employeeId": modelEmployeeId }, - success: function (response) { - console.log(response); - if (response.isSuccedded == true) { - if (response.message != null) - swal({ - title: response.message, - text: "", - type: "success", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: "بستن", - //cancelButtonText: "خیر", - closeOnConfirm: true, - customClass: "successSwall" - }); - resolve(true); - } else { - swal({ - title: response.message, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - resolve(false); - } - }, - error: function (response) { - console.log(5, response); - reject(response); - } - }); - }); -} - -function afterDeleteWorkshop(element, workshopId, result, newItem) { - const navLink = $(element).closest('.nav-link'); - const navTitle = navLink.find('.nav-title'); - const activeTabPane = $('.tab-pane.active'); - if ((workshopId != 0 && result == true) || newItem == "true") { - if ($(element).closest('.nav-link').index() === 0 && $('.nav-tabs a').length === 1) { - navTitle.text('نام شرکت'); - navTitle.addClass("disactive"); - activeTabPane.find("input.position-code").val(""); - activeTabPane.find(".position-name").val(0); - const rows = activeTabPane.find(".workDate-table tbody").find("tr"); - const rowCount = rows.length; - if (rowCount === 6) { - $('.table-content').addClass('hide-scrollbar'); - } - rows.each(function () { - if (rowCount <= 5) { - $(this).find('td:eq(6)').text(""); - $(this).find('td:eq(4)').text(""); - $(this).find('td:eq(3)').text(""); - $(this).find('td:eq(1)').text(""); - } - if (rowCount > 5) { - $(this).remove(); - updateRowNumbers(); - } - }); - disappearIcon(); - checkPremision(); - } else { - const href_ = $(element).closest('.nav-link').attr("href"); - const tabId = href_.replace('#', ''); - $(element).closest('.nav-link').remove(); - handleCompanyScroll(); - $(`#${tabId}`).remove(); - if ($(element).closest('.nav-link').hasClass('active')) { - $('.nav-tabs a:first-child').trigger('click'); - } - } - swal({ - title: "عملیات با موفقیت حذف شد.", - text: "", - type: "success", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: "بستن", - //cancelButtonText: "خیر", - closeOnConfirm: true, - customClass: "successSwall" - }); - } -} - -$(function () { - $('#result-modal [data-parent-modal]').on('click', - function (e) { - e.preventDefault(); - e.stopPropagation(); - const parentModalId = $(this).data('parent-modal'); - $(parentModalId).modal('hide'); - }); -}); - -function deleteDate(element, date, workshopId, type) { - - $("#editIndex").val(''); - - const deletedRow = $(element).closest('tr'); - const endDate = deletedRow.find('td:eq(3)').text(); - $("#deleteIndex").val(deletedRow.find('td:eq(0)').text()); - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - if (type == "first" && endDate != "") { - swal({ - title: "لطفا برای حذف تاریخ شروع به کار، ابتدا تاریخ ترک کار را حذف کنید.", - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - } else if (workshopId != 0 && date != '') { - $.ajax({ - dataType: 'json', - type: 'POST', - url: CheckDeleteLeftWorkurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": date, "type": (type == "first" ? 1 : 2) }, - success: function (response) { - console.log(response); - if (response.isSuccedded == true) { - if (type == "first") - startDateEdit(element); - else - endDateEdit(element); - } else { - swal({ - title: "امکان حذف تاریخ وجود ندارد", - text: response.message, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - const tr = $(element).parent().parent(); - if (type == "first") { - tr.find('td:eq(1)').addClass("emptyStart"); - } else { - tr.find('td:eq(3)').addClass("emptyStart"); - tr.find('td:eq(4)').addClass("emptyStart"); - } - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - } - }, - error: function (response) { - console.log(5, response); - } - }); - } else if (workshopId == 0 || date == '') { - if (type == "first") - startDateEdit(element); - else - endDateEdit(element); - } -} - -function removeDisabledJob() { - const activeTabPane = $('.tab-pane.active'); - var workshopId = activeTabPane.attr("data-workshopid"); - - if (activeTabPane.find(".dadmehr-select-search").hasClass('disabled')) { - activeTabPane.find(".custom-select").removeClass('disabled'); - activeTabPane.find(".dadmehr-select-search").removeClass('disabled'); - var workshopId = activeTabPane.attr("data-workshopid"); - - activeTabPane.find(".custom-select").html( - `' + '' - ); - } -} - -function disabledJob() { - - const activeTabPane = $('.tab-pane.active'); - activeTabPane.find(".custom-select").addClass('disabled'); - activeTabPane.find(".dadmehr-select-search").addClass('disabled'); - const workshopId = activeTabPane.attr("data-workshopid"); - - activeTabPane.find(".custom-select").html( - `' + '' - ); - activeTabPane.find('.ul-search').html(''); -} \ No newline at end of file diff --git a/ServiceHost/wwwroot/AssetsAdmin/page/Employee/leftWorkInsurance.js b/ServiceHost/wwwroot/AssetsAdmin/page/Employee/leftWorkInsurance.js deleted file mode 100644 index 137c8f64..00000000 --- a/ServiceHost/wwwroot/AssetsAdmin/page/Employee/leftWorkInsurance.js +++ /dev/null @@ -1,2611 +0,0 @@ - -var list = []; -$(document).ready(function () { - handleScroll(); - handleCompanyScroll(); - employerDiagnose(); - disappearIcon(); -}); - // checkPremision(); - -if (leftWorkInsuranceGroups == null || (leftWorkInsuranceGroups != null && leftWorkInsuranceGroups.length == 0)) { - disabledJob(); -} - -permisiionIds.forEach(function (item) { - list.push(item); -}); - - -const navTitle = $('.nav-title'); -if (navTitle.text().trim() === 'نام شرکت') { - navTitle.addClass("disactive"); -} -//adding / between dates -$(".date").mask("0000/00/00"); -//this function is for disabling the first tab and adding a new row to the table of the first tab -checkcountRow(); -//this code adds a new tab(with the content in it)... -const addTab = (counter) => { - var workshopId = $('#input1').val(); - var workshopName = $('#input1 option:selected').text(); - //the data in each tab... - const newTab = $(`
مشمول مزایا
عدم شمول مزایا
#تاریخ شروع بکارتاریخ آخرین روز کاریتاریخ ترک کارروزهای کارکرد
1
2
3
4
5
`); - $(".tab-content").prepend(newTab); - const endDateInput = newTab.find('.end-date'); - const startDateInput = newTab.find('.start-date'); - getPersonelCode(workshopId); - - getJobByWorkshopId(workshopId); - - $(".edit-icon").unbind('click').on("click", - function (e) { - editDate(this); - e.preventDefault(); - }); - //this code checks the date in keyup function... - $(".date").keyup(function () { - const value = $(this).val(); - const lengthValue = value.length; - const id = $(this).attr('id'); - if (lengthValue == 10) { - if (!dateValidCheck(this)) { - $(this).addClass("errored"); - } else { - $(this).removeClass("errored"); - - if (id == 'last-day-' + counter) { - setDate(value, `last-day-${counter}`, `end-date-${counter}`, true); - } else if (id == 'end-date-' + counter) { - setDate(value, `end-date-${counter}`, `end-date-${counter}`, false); - } - } - } - }); - - //the save button in the new tab... - ////////newTab.find('.save').click(function (e) { - //////// console.log(3333);-------- - //////// e.preventDefault();------ - //////// let activeTabPane = $('.tab-pane.active');------- - - //////// let paneNumber = newTab.data('pane'); - //////// let startDate = $('#start-date-' + paneNumber).val(); - //////// let lastDay = $('#last-day-' + paneNumber).val(); - //////// let endDate = $('#end-date-' + paneNumber).val(); - - //////// if (startDate != '' && !checkLength($('#start-date-' + counter).val(), 10)) { - //////// if (!dateValidCheckByValue($('#start-date-' + counter))) { - //////// $('#start-date-' + counter).addClass("errored"); - //////// } else { - //////// $('#start-date-' + counter).removeClass("errored"); - //////// } - - //////// } - //////// if (lastDay != '' && !checkLength($('#last-day-' + counter).val(), 10)) { - //////// if (!dateValidCheckByValue($('#start-date-' + counter))) { - //////// $('#last-day-' + counter).addClass("errored"); - //////// } else { - //////// $('#last-day-' + counter).removeClass("errored"); - //////// } - - //////// } - //////// if (endDate != '' && !checkLength($('#end-date-' + counter).val(), 10)) { - //////// if (!dateValidCheckByValue($('#end-date-' + counter))) { - //////// $('#end-date-' + counter).addClass("errored"); - //////// } else { - //////// $('#end-date-' + counter).removeClass("errored"); - //////// } - - //////// } - //////// var editable = false; - //////// if (startDate != '' && !$('.date').hasClass('errored') && $("#editStartDate").val() != '') { - //////// var workshopId = activeTabPane.attr("data-workshopid"); - //////// $.ajax({ - //////// dataType: 'json', - //////// type: 'POST', - //////// url: '@Url.Page("/Company/Employees/Index", "CheckEditLeftWorkInsurance")', - //////// headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - //////// data: { "workshopId": workshopId, "employeeId": @Model.EmployeeId, "date": startDate, "type": 1 }, - //////// success: function (response) { - //////// // console.log(response); - //////// if (response.isSuccedded == true) { - //////// if (!$('#start-date-' + paneNumber).hasClass('errored') && !$('#last-day-' + paneNumber).hasClass('errored') && !$('#end-date-' + paneNumber).hasClass('errored')) { - //////// addRow2(counter, startDate, lastDay, endDate); - //////// console.log(2222); - //////// disableInput(); - //////// disableSaveBtn(); - //////// handleScroll(); - //////// $('#start-date-' + paneNumber).val(""); - //////// $('#last-day-' + paneNumber).val(""); - //////// $('#end-date-' + paneNumber).val(""); - //////// let editIcon = activeTabPane.find(".edit-icon"); - //////// let deleteIcon = activeTabPane.find(".edit-date"); - //////// deleteIcon.removeClass("disabled-edit"); - //////// editIcon.removeClass("disabled-edit"); - //////// activeTabPane.find(".date").removeClass("blinking"); - //////// } - //////// $('.workDate-table').find("tbody tr").each(function () { - //////// let row = $(this); - //////// let rowStartDate = row.find('td:eq(1)'); - //////// let rowEndDate = row.find('td:eq(4)'); - //////// let rowStartDateText = row.find('td:eq(1)').text(); - //////// let rowEndDateText = row.find('td:eq(4)').text(); - //////// if (rowStartDateText != '') { - //////// rowStartDate.removeClass("emptyStart"); - //////// } - //////// }); - //////// } - //////// else { - //////// swal({ - //////// title: "امکان ویرایش تاریخ وجود ندارد.", - //////// text: " به دلیل استفاده این تاریخ در ایجاد لیست بیمه، ویرایش تاریخ قبل از تاریخ " + $("#editStartDate").val() + "امکان پذیر می باشد. ", - //////// type: "warning", - //////// showCancelButton: true, - //////// confirmButtonColor: "#DD6B55", - //////// //confirmButtonText: "بستن", - //////// cancelButtonText: "بستن", - //////// closeOnConfirm: false, - //////// customClass: "errorSwall" - //////// }); - //////// // var tr = $(activeTabPane).find('.workDate-table tbody tr'); - //////// // tr.find('td:eq(1)').text($("#editStartDate").val()); - - //////// } - //////// }, - //////// error: function (response) { - //////// console.log(5, response); - //////// } - //////// }); - //////// } - //////// else { - //////// if (!activeTabPane.find('.date').hasClass('errored')) - //////// { - //////// if ($("#deleteStartDate").val() != '' && $("#deleteStartDate").val() < startDate) { - //////// swal({ - //////// title: "امکان حذف تاریخ وجود ندارد.", - //////// text: " به دلیل استفاده این تاریخ در ایجاد لیست بیمه، ثبت تاریخ جدید قبل از تاریخ " + $("#deleteStartDate").val() + "امکان پذیر می باشد. ", - //////// type: "warning", - //////// showCancelButton: true, - //////// confirmButtonColor: "#DD6B55", - //////// //confirmButtonText: "بستن", - //////// cancelButtonText: "بستن", - //////// closeOnConfirm: false, - //////// customClass: "errorSwall" - //////// }); - //////// } - //////// else - //////// { - //////// $("#deleteStartDate").val(''); - - //////// addRow2(counter, startDate, lastDay, endDate); - //////// disableInput(); - //////// disableSaveBtn(); - //////// handleScroll(); - - //////// $('#start-date-' + paneNumber).val(""); - //////// $('#last-day-' + paneNumber).val(""); - //////// $('#end-date-' + paneNumber).val(""); - //////// } - //////// } - //////// $('.workDate-table').find("tbody tr").each(function () { - //////// let row = $(this); - //////// let rowStartDate = row.find('td:eq(1)'); - //////// let rowEndDate = row.find('td:eq(4)'); - //////// let rowStartDateText = row.find('td:eq(1)').text(); - //////// let rowEndDateText = row.find('td:eq(4)').text(); - //////// if (rowStartDateText != '') { - //////// rowStartDate.removeClass("emptyStart"); - //////// } - //////// }); - //////// } - - - //////// $('.workDate-table').find("tbody tr").each(function () { - //////// let row = $(this); - //////// let rowStartDate = row.find('td:eq(1)'); - //////// let rowEndDate = row.find('td:eq(4)'); - //////// let rowStartDateText = row.find('td:eq(1)').text(); - //////// let rowEndDateText = row.find('td:eq(4)').text(); - //////// if (rowStartDateText != '') { - //////// rowStartDate.removeClass("emptyStart"); - //////// } - //////// }); - - - //////// }); - -}; -//this code handles the first button(for adding new tabs) -$(function () { - var counter = 1; // start counter from 2 since we already have one tab - $('#save1').on('click', - function (e) { - e.preventDefault(); - if ($('#input1').val() != '0') { - $("#IsDelete").val('false'); - var workshopId = $('#input1').val(); - var workshopname = $('#input1 option:selected').text(); - - let navLink = $('.nav-link'); - let navTitle = navLink.find('.nav-title'); - // Vafa - removeDisabledJob(); - $('.setContract').prop('disabled', false); - $('#startDate1').prop('disabled', false); - // Vafa - - //if there was only one tab... - if (navTitle.text().trim() === 'نام شرکت') { - $('#tab-1').attr("data-workshopId", workshopId); - $('#tab-1').attr("data-workshopname", workshopname); - navTitle.text($('#input1 option:selected').text()); - - navTitle.attr("data-workshopid", workshopId); - navLink.find('.trash-icon').attr("onclick", `deleteLeftwork(this,${workshopId})`); - - navTitle.removeClass("disactive"); - navTitle.addClass("active"); - $('#input1').val('0').trigger('change'); - //$('#startDate1').prop('disabled', false); - getPersonelCode(workshopId); - $('.position-name').prop('id', `select-${workshopId}`); - getJobByWorkshopId(workshopId); - } else { - counter++; - $("#nav-title1").removeClass("active"); - $('.position-name').prop('disabled', false); - - // $('.position-code').prop('disabled', false); - - $('.setContract').prop('disabled', false); - const newTitle = $('#input1 option:selected').text(); - const newworkshopId = $('#input1 option:selected').val(); - //const $existingTitle = $('.nav-title:contains("' + newTitle + '")'); - var $existingTitle = false; - $('.nav-title').each(function () { - if ($(this).attr("data-workshopid") == newworkshopId) { - $existingTitle = true; - } - }); - if ($existingTitle) { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - swal({ - title: 'شرکت انتخاب شده در لیست وجود دارد.', - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - return; - } else { - addTab(counter); - // var selectItem = $('.tab-pane.active').find('.select-city'); - // selectItem.select2(); - const newTabLink = $(`${newTitle}`); - $(".nav-tabs").prepend(newTabLink); - handleCompanyScroll(); - - // tooltip for when the title of the tabs are long - $(function () { - $('.nav-title').tooltip({ - container: 'body', - fontFamily: 'IranSans', - background: 'grey', - placement: 'top', - offset: { x: 300, y: 20 }, - trigger: 'hover', - html: true, - title: function () { - return `${$(this).text()}`; - } - }); - }); - - // Add the click event listener to the new tab link - newTabLink.on('click', - function (e) { - e.preventDefault(); - const $tab = $(this); - const target = $tab.attr('href'); - $('.nav-tabs .nav-link, .tab-pane').removeClass('active'); - $tab.addClass('active'); - $(target).addClass('active'); - disableSaveBtn(); - disableInput(); - }); - newTabLink.trigger('click'); - var selectItem = $('.tab-pane.active').find('.select-city'); - selectItem.select2(); - } - $('.table-content').addClass('hide-scrollbar'); - $('#input1').val('0').trigger('change'); - }; - - } - - handleScroll(); - disappearIcon(); - checkPremision(); - - }); -}); - - -//this code handles the second button(for adding data in the first tabs table) -$(function () { - $('#save').on('click', - function (e) { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - e.preventDefault(); - - let activeTabPane = $('.tab-pane.active'); - let date1 = $('#startDate1').val(); - let date2 = $('#lastDay1').val(); - let date3 = $('#endDate1').val(); - // let editIcon = activeTabPane.find(".edit-icon permission-editDate"); - // let deleteIcon = activeTabPane.find(".edit-date"); - // deleteIcon.removeClass("disabled-edit"); - // editIcon.removeClass("disabled-edit"); - let positionCode = $('.position-code').val(); - let positionName = $(".position-name").val(); - if (positionCode == "") { - activeTabPane.find('.position-code').addClass("errored"); - } else { - activeTabPane.find('.position-code').removeClass("errored"); - } - if (positionName == "") { - activeTabPane.find('.custom-select').addClass("errored"); - } else { - activeTabPane.find('.custom-select').removeClass("errored"); - } - if (positionName == 0) { - activeTabPane.find('.position-name').addClass("errored"); - } else { - activeTabPane.find('.position-name').addClass("errored"); - } - - if (date1 != '' && !checkLength($('#startDate1').val(), 10)) { - if (!dateValidCheckByValue($('#startDate1'))) { - $('#startDate1').addClass("errored"); - } else { - $('#startDate1').removeClass("errored"); - } - } - if (date2 != '' && !checkLength($('#lastDay1').val(), 10)) { - if (!dateValidCheckByValue($('#lastDay1'))) { - $('#lastDay1').addClass("errored"); - } else { - $('#lastDay1').removeClass("errored"); - } - - } - if (date3 != '' && !checkLength($('#endDate1').val(), 10)) { - if (!dateValidCheckByValue($('#endDate1'))) { - $('#endDate1').addClass("errored"); - } else { - $('#endDate1').removeClass("errored"); - } - } - - var editable = false; - - if ((!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) && $("#editStartDate").val() == '' && $("#editEndDate").val() == '' && $("#deleteStartDate").val() == '') { - var workshopId = activeTabPane.attr("data-workshopid"); - //check edit for startDate - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: CheckEditLeftWorkInsuranceurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { - "workshopId": workshopId, - "employeeId": modelEmployeeId, - "date": (date3 != '') ? date3 : date1, - "type": (date3 != '') ? 2 : 1 - }, - success: function (response) { - // console.log(response); - if (response.isSuccedded == true) { - if (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) { - addRow(date1, date2, date3); - handleScroll(); - disableInput(); - disableSaveBtn(); - } - activeTabPane.find('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } else { - swal({ - title: "امکان ثبت تاریخ وجود ندارد.", - text: response.message, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - - } - }, - error: function (response) { - console.log(5, response); - } - }); - } else if (date1 != '' && (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) && $("#editStartDate").val() != '') { - var workshopId = activeTabPane.attr("data-workshopid"); - //check edit for startDate - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: CheckEditLeftWorkInsuranceurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": date1, "type": 1 }, - success: function (response) { - // console.log(response); - if (response.isSuccedded == true) { - if (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) { - addRow(date1, date2, date3); - handleScroll(); - disableInput(); - disableSaveBtn(); - } - activeTabPane.find('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } else { - swal({ - title: "امکان ویرایش تاریخ وجود ندارد.", - text: response.message, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - // var tr = $(activeTabPane).find('.workDate-table tbody tr'); - // tr.find('td:eq(1)').text($("#editStartDate").val()); - - } - }, - error: function (response) { - console.log(5, response); - } - }); - } else { - if (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) { - var workshopId = activeTabPane.attr("data-workshopid"); - //check after Delete for startDate - if ($("#deleteStartDate").val() != '') { - - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: CheckEditLeftWorkInsuranceurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": $('#startDate1').val(), "type": 1 }, - success: function (response) { - if (response.isSuccedded == true) { - if (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) { - addRow(date1, date2, date3); - handleScroll(); - disableInput(); - disableSaveBtn(); - $("#deleteStartDate").val(''); - } - activeTabPane.find('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } else { - - swal({ - title: "امکان ثبت تاریخ وجود ندارد", - text: response.message, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - - } - }, - error: function (response) { - console.log(5, response); - } - }); - - - } else { - - if ($('#lastDay1').val() != '' && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) { - //check edit for endDate - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: CheckEditLeftWorkInsuranceurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": $('#endDate1').val(), "type": 2 }, - success: function (response) { - if (response.isSuccedded == true) { - if (!$('#startDate1').hasClass('errored') && !$('#lastDay1').hasClass('errored') && !$('#endDate1').hasClass('errored')) { - addRow(date1, date2, date3); - handleScroll(); - disableInput(); - disableSaveBtn(); - $("#deleteStartDate").val(''); - } - activeTabPane.find('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } else { - if ($("#editLeftDate").val() != '') { - swal({ - title: "امکان ویرایش تاریخ وجود ندارد", - text: `در صورت تمایل به ثبت تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید.`, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - } else { - swal({ - title: "امکان ثبت تاریخ وجود ندارد", - text: `در صورت تمایل به ثبت تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید.`, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - } - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - - } - }, - error: function (response) { - console.log(5, response); - } - }); - - } else if ($('#startDate1').val() != '' && !$('#startDate1').hasClass('errored')) { - addRow(date1, date2, date3); - handleScroll(); - disableInput(); - disableSaveBtn(); - - $('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } - // addRow(date1, date2, date3); - // handleScroll(); - // disableInput(); - // disableSaveBtn(); - // $("#deleteStartDate").val(''); - } - } - activeTabPane.find('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } - - }); -}); -// Add the click event listener to the new tab link -$('.nav-tabs .nav-link').on('click', function (e) { - e.preventDefault(); - updateRowNumbers(); - const $tab = $(this); - const target = $tab.attr('href'); - $('.nav-tabs .nav-link, .tab-pane').removeClass('active'); - $tab.addClass('active'); - $(target).addClass('active'); - const selectItem = $('.tab-pane.active').find('.select-city'); - selectItem.select2(); - handleScroll(); - disableInput(); - disableSaveBtn(); - //employerDiagnose(); -}); - -checkPremision(); - //}); - -$(document).on('keyup', function (event) { - if (event.key === 'Enter' || event.key === 'Tab') { - employerDiagnose(); - } - }); - -function vibratingAnimation(element) { - $(element).animate({ left: "-2px" }, 50) - .animate({ left: "2px" }, 50) - .animate({ left: "0px" }, 50); -} - -function startDateEdit(element) { - const deletedRow = $(element).closest('tr'); - deletedRow.find('td:eq(1)').text(""); - deletedRow.find('td:eq(6)').text(""); - disableInput(); - disableSaveBtn(); - disappearIcon(); - checkPremision(); -} - -function endDateEdit(element) { - const deletedRow = $(element).closest('tr'); - deletedRow.find('td:eq(3)').text(""); - deletedRow.find('td:eq(4)').text(""); - disableInput(); - disableSaveBtn(); - disappearIcon(); - checkPremision(); -} - -$(".edit-date , .edit-icon").on("mouseenter", function () { - vibratingAnimation(this); - }); - -function employerDiagnose() { - const positionTitle = $('.value').data('value'); - const setContract = $(".setContract"); - // if (positionTitle == '10' || positionTitle == '16' || positionTitle == '17' || positionTitle == '18') { - // setContract.prop("checked", false); - // } else { - // setContract.prop("checked", true); - // } -} - -function disappearIcon() { - const activeTabPane = $('.tab-pane.active'); - const table = activeTabPane.find('.workDate-table'); - table.find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)').text(); - const rowEndDate = row.find('td:eq(4)').text(); - if (rowStartDate == "") { - row.find('td:eq(2) a').addClass("d-none"); - } else { - row.find('td:eq(2) a').removeClass("d-none"); - } - if (rowEndDate == "") { - row.find('td:eq(5) a').addClass("d-none"); - } else { - row.find('td:eq(5) a').removeClass("d-none"); - } - }); -} - -function editDate(element) { - let activeTabPane = $('.tab-pane.active'); - var workshopId = activeTabPane.attr("data-workshopid"); - var row = $(element).closest('tr'); - var id = row.attr('data-id'); - var rowIndex = $(element).closest('tr').index(); - var colIndex = $(element).closest('td').index(); - $("#editIndex").val(row.find('td:eq(0)').text()); - if (colIndex == 2) { - let startDateText = row.find('td:eq(1)').text(); - $("#editStartDate").val(startDateText); - activeTabPane.find(".input2").val(startDateText).addClass("blinking"); - row.find('td:eq(1)').text(""); - disableInput(); - disableSaveBtn(); - //let activeTabPane = $('.tab-pane.active'); - let editIcon = activeTabPane.find(".edit-icon"); - let deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.addClass("disabled-edit"); - editIcon.addClass("disabled-edit"); - } else if (colIndex == 5) { - var workshopId = activeTabPane.attr("data-workshopid"); - let lastDateText = row.find('td:eq(3)').text(); - let endDateText = row.find('td:eq(4)').text(); - var id = row.attr('data-id'); - // console.log(id); - if (id != "0" && id != 'undefined') { - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: '/Admin/Company/Employees?handler=CheckEditLeftWorkInsurance', - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": endDateText, "type": 2 }, - success: function (response) { - // console.log(response); - if (response.isSuccedded == true) { - $("#editLeftDate").val(lastDateText); - $("#editEndDate").val(endDateText); - activeTabPane.find(".input3").val(lastDateText).addClass("blinking"); - activeTabPane.find(".input4").val(endDateText).addClass("blinking"); - row.find('td:eq(3)').text(""); - row.find('td:eq(4)').text(""); - disableInput(); - disableSaveBtn(); - //let activeTabPane = $('.tab-pane.active'); - const editIcon = activeTabPane.find(".edit-icon"); - const deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.addClass("disabled-edit"); - editIcon.addClass("disabled-edit"); - } else { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - swal({ - title: "امکان ویرایش ترک کار این پرسنل وجود ندارد. ", - text: `در صورت تمایل به ویرایش تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید. `, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - const tr = $(activeTabPane).find('.workDate-table tbody tr'); - } - }, - error: function (response) { - console.log(5, response); - } - }); - } else { - $("#editLeftDate").val(lastDateText); - $("#editEndDate").val(endDateText); - activeTabPane.find(".input3").val(lastDateText).addClass("blinking"); - activeTabPane.find(".input4").val(endDateText).addClass("blinking"); - row.find('td:eq(3)').text(""); - row.find('td:eq(4)').text(""); - disableInput(); - disableSaveBtn(); - // let activeTabPane = $('.tab-pane.active'); - let editIcon = activeTabPane.find(".edit-icon"); - let deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.addClass("disabled-edit"); - editIcon.addClass("disabled-edit"); - } - } - -} - - -$(".edit-icon").unbind('click').on("click", - function (e) { - editDate(this); - }); - -$(function () { - $('#result-modal [data-parent-modal]').on('click', - function (e) { - e.preventDefault(); - e.stopPropagation(); - const parentModalId = $(this).data('parent-modal'); - $(parentModalId).modal('hide'); - }); -}); -handleCompanyScroll(); -//this code checks the rows, if there are empty rows,they will be filled, and if there is none, a new row will be added -let addRow = (date1, date2, date3) => { - - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - $("#editStartDate").val(''); - $("#editLeftDate").val(''); - $("#editEndDate").val(''); - - let activeTabPane = $('.tab-pane.active'); - let table = activeTabPane.find('.workDate-table'); - let tableRow = table.find('tbody tr'); - let conflictFound = false; - tableRow.each(function (rowIndex) { - let row = $(this); - let iconShown = row.find('td:eq(2) a').hasClass("d-none"); - let rowStartDate = row.find('td:eq(1)').text(); // Get the start date of the row - let rowEndDate = row.find('td:eq(4)').text(); // Get the end date of the row - const $existingDate1 = row.find(`td:eq(1):contains("${date1}")`); - - var index = ''; - if ($("#deleteIndex").val() != '') { - index = $("#deleteIndex").val(); - } else if ($("#editIndex").val() != '') - index = $("#editIndex").val(); - else { - index = rowIndex + 1; - } - - // console.log(index); - - - let trNumber = table.find(`tr:eq(${index})`); - let firstTd = trNumber.find('td:eq(1)').text(); - let lastTd = trNumber.find('td:eq(4)').text(); - - if (date1 != '' && $existingDate1.length > 0) { - //$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' وارد شده است.'); - swal({ - title: `تاریخ شروع در ردیف ${row.find('td:eq(0)').text()} وارد شده است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return; - } - const $existingDate2 = row.find(`td:eq(4):contains("${date1}")`); - if (date1 != '' && $existingDate2.length > 0) { - //$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع با تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.'); - swal({ - title: `تاریخ شروع با تاریخ پایان در ردیف ${row.find('td:eq(0)').text()} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return; - } - const $existingDate3 = row.find(`td:eq(4):contains("${date3}")`); - if (date3 != '' && $existingDate3.length > 0) { - // $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' وارد شده است.'); - swal({ - title: `تاریخ پایان در ردیف ${row.find('td:eq(0)').text()} وارد شده است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return; - } - const $existingDate4 = row.find(`td:eq(1):contains("${date3}")`); - if (date3 != '' && $existingDate4.length > 0) { - //$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.'); - swal({ - title: `تاریخ پایان با تاریخ شروع در ردیف ${row.find('td:eq(0)').text()} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#endDate1').addClass("errored"); - conflictFound = true; - return; - } - const $existingDate5 = row.find(`td:eq(1):contains("${date2}")`); - if (date2 != '' && $existingDate5.length > 0) { - // $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ آخرین روز کاری با تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.'); - swal({ - title: `تاریخ پایان با تاریخ شروع در ردیف ${row.find('td:eq(0)').text()} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return; - } - - if (rowStartDate != '' && date3 != '' && date3 > rowStartDate && date3 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - console.log(11); - swal({ - title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return false; - } - - - if (rowStartDate != '' && date3 != '' && rowEndDate == '' && date3 < rowStartDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - console.log(22); - swal({ - title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return false; - } - - if (rowStartDate != '' && date1 != '' && date1 > rowStartDate && date1 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - console.log(33); - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return false; - } - if (rowStartDate != '' && rowEndDate != '' && date1 != '' && date1 < rowEndDate && date1 >= rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - console.log(44); - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date1 != '' && rowStartDate != '' && date1 > rowStartDate && date1 < rowEndDate) { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date3 != '' && rowStartDate != '' && date3 > rowStartDate && date3 < rowEndDate) { - swal({ - title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#startDate1').addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && lastTd != '' && date1 != '' && date1 > lastTd) { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && firstTd != '' && date3 != '' && date3 < firstTd) { - // $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.'); - swal({ - title: `تاریخ پایان با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $('#lastDay1').addClass("errored"); - conflictFound = true; - return false; - } - - }); - if (!conflictFound) { - //let emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - var index = ''; - if ($("#editIndex").val() != '') { - index = $("#editIndex").val(); - } else if ($("#deleteIndex").val() != '') { - index = $("#deleteIndex").val(); - } - - let emptyRow = null; - if (index == '') - emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - else - emptyRow = table.find(`tr:eq(${index})`); - - if (emptyRow.length > 0) { - if (date1 != '') { - emptyRow.children('td:eq(1)').text(date1); - } - if (date2 != '') { - emptyRow.children('td:eq(3)').text(date2); - } - if (date3 != '') { - emptyRow.children('td:eq(4)').text(date3); - } - emptyRow.children('td:eq(6)').text("_"); - // disappearIcon(); checkPremision(); - activeTabPane.find(".date").removeClass("blinking"); - } - if (emptyRow.length === 0 && !conflictFound) { - let rowCount = table.find("tbody tr").length; - let newRow = `${rowCount + 1}${date1 - }${date2}${date3 - }_`; - table.find("tbody").append(newRow); - disableInput(); - disableSaveBtn(); - $('#startDate1').val(""); - $('#lastDay1').val(""); - $('#endDate1').val(""); - } - disappearIcon(); - checkPremision(); - let editIcon = activeTabPane.find(".edit-icon"); - let deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - $("#editIndex").val(''); - $("#deleteIndex").val(''); - $(".edit-date , .edit-icon").on("mouseenter", - function () { - vibratingAnimation(this); - }); - sortDates(); - updateRowNumbers(); - - - } - -}; - -//this code is like addRow for the tabs except the first tab -let addRow2 = (counter, date1, date2, date3) => { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - - let activeTabPane = $('.tab-pane.active'); - let table = activeTabPane.find('.workDate-table'); - let tableRow = table.find('tbody tr'); - let emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - let startDate = activeTabPane.find('.input2'); - let lastDay = activeTabPane.find('.input3'); - let endDate = activeTabPane.find('.input4'); - let conflictFound = false; - tableRow.each(function (rowIndex) { - let row = $(this); - let iconShown = row.find('td:eq(2) a').hasClass("d-none"); - let rowStartDate = row.find('td:eq(1)').text(); - let rowEndDate = row.find('td:eq(4)').text(); - var index = ''; - if ($("#deleteIndex").val() != '') { - index = $("#deleteIndex").val(); - } else if ($("#editIndex").val() != '') - index = $("#editIndex").val(); - else { - index = rowIndex + 1; - } - - let trNumber = table.find(`tr:eq(${index})`); - let firstTd = trNumber.find('td:eq(1)').text(); - let lastTd = trNumber.find('td:eq(4)').text(); - - const $existingDate1 = row.find(`td:eq(1):contains("${date1}")`); - if (date1 != '' && $existingDate1.length > 0) { - //$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' وارد شده است.'); - swal({ - title: `تاریخ شروع در ردیف ${row.find('td:eq(0)').text()} وارد شده است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return; - } - - const $existingDate2 = row.find(`td:eq(4):contains("${date1}")`); - if (date1 != '' && $existingDate2.length > 0) { - // $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع با تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.'); - swal({ - title: `تاریخ شروع با تاریخ پایان در ردیف ${row.find('td:eq(0)').text()} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - - startDate.addClass("errored"); - conflictFound = true; - return; - } - - - const $existingDate3 = row.find(`td:eq(4):contains("${date2}")`); - if (date2 != '' && $existingDate3.length > 0) { - // $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان در ردیف ' + row.find('td:eq(0)').text() + ' وارد شده است.'); - swal({ - title: `تاریخ پایان در ردیف${row.find('td:eq(0)').text()} وارد شده است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - lastDay.addClass("errored"); - - conflictFound = true; - return; - } - - const $existingDate4 = row.find(`td:eq(1):contains("${date2}")`); - if (date2 != '' && $existingDate4.length > 0) { - swal({ - title: `تاریخ آخرین روز کاری با تاریخ شروع در ردیف${row.find('td:eq(0)').text()} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - //$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ آخرین روز کاری با تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.'); - lastDay.addClass("errored"); - - conflictFound = true; - return; - } - const $existingDate5 = row.find(`td:eq(1):contains("${date3}")`); - if (date3 != '' && $existingDate5.length > 0) { - // $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با تاریخ شروع در ردیف ' + row.find('td:eq(0)').text() + ' برابر است.'); - swal({ - title: `تاریخ پایان با تاریخ شروع در ردیف${row.find('td:eq(0)').text()} برابر است.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - endDate.addClass("errored"); - conflictFound = true; - return; - } - - if (rowStartDate != '' && date2 != '' && date2 > rowStartDate && date2 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - // $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.'); - swal({ - title: `تاریخ پایان با توجه به بازه وارد شده در ردیف ${row.find('td:eq(0)').text()} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - - lastDay.addClass("errored"); - conflictFound = true; - return false; - } - - if (rowStartDate != '' && date2 != '' && rowEndDate == '' && date2 < rowStartDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - // $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.'); - swal({ - title: `تاریخ پایان با توجه به بازه وارد شده در ردیف ${row.find('td:eq(0)').text()} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - - lastDay.addClass("errored"); - conflictFound = true; - return false; - } - - if (rowStartDate != '' && date1 != '' && date1 > rowStartDate && date1 < rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - // $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع با توجه به بازه وارد شده در ردیف ' + row.find('td:eq(0)').text() + ' نادرست می باشد.'); - swal({ - title: `تاریخ شروع با توجه به بازه وارد شده در ردیف ${row.find('td:eq(0)').text()} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - - startDate.addClass("errored"); - conflictFound = true; - return false; - } - if (rowStartDate != '' && rowEndDate != '' && date1 != '' && date1 < rowEndDate && date1 >= rowEndDate && $("#deleteIndex").val() == '' && $("#editIndex").val() == '') { - console.log(44); - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date1 != '' && rowStartDate != '' && date1 > rowStartDate && date1 < rowEndDate) { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && date3 != '' && rowStartDate != '' && date3 > rowStartDate && date3 < rowEndDate) { - swal({ - title: `تاریخ پایان وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - startDate.addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && lastTd != '' && date1 != '' && date1 > lastTd) { - swal({ - title: `تاریخ شروع وارد شده با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - lastDay.addClass("errored"); - conflictFound = true; - return false; - } - if (($("#deleteIndex").val() != '' || $("#editIndex").val() != '') && firstTd != '' && date3 != '' && date3 < firstTd) { - swal({ - title: `تاریخ پایان با توجه به بازه وارد شده در ردیف ${index} نادرست می باشد.`, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - lastDay.addClass("errored"); - conflictFound = true; - return false; - } - - }); - if (!conflictFound) { - var index = ''; - if ($("#editIndex").val() != '') - index = $("#editIndex").val(); - else if ($("#deleteIndex").val() != '') - index = $("#deleteIndex").val(); - - // let emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - let emptyRow = null; - if (index == '') - emptyRow = table.find("tbody tr td:empty:first").closest('tr'); - else - emptyRow = table.find(`tr:eq(${index})`); - - - if (emptyRow.length > 0) { - if (date1 != '') - emptyRow.children('td:eq(1)').text(date1); - if (date2 != '') - emptyRow.children('td:eq(3)').text(date2); - if (date3 != '') - emptyRow.children('td:eq(4)').text(date3); - emptyRow.children('td:eq(6)').text("_"); - // disappearIcon(); checkPremision(); - activeTabPane.find(".date").removeClass("blinking"); - - } - if (emptyRow.length === 0) { - let rowCount = table.find("tbody tr").length; - let newRow = `${rowCount + 1}${date1 - }${date2}${date3 - }_`; - table.find("tbody").append(newRow); - disableInput(); - disableSaveBtn(); - // disappearIcon(); checkPremision(); - - } - disappearIcon(); - checkPremision(); - let editIcon = activeTabPane.find(".edit-icon"); - let deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - $(".edit-date , .edit-icon").on("mouseenter", - function () { - vibratingAnimation(this); - }); - sortDates(); - updateRowNumbers(); - $("#editIndex").val(''); - $("#deleteIndex").val(''); - - } - -}; - -//this code checks the row number -let updateRowNumbers = () => { - - const activeTabPane = $('.tab-pane.active'); - const rows = activeTabPane.find(".workDate-table tbody").find("tr"); - rows.each(function (index) { - $(this).find("td:first-child").text(index + 1); - }); -}; - -//this code sorts the table based on the second date column in descending order -function sortDates() { - const activeTabPane = $('.tab-pane.active'); - const table = activeTabPane.find('.workDate-table'); - const rows = table.find('tr:gt(0)').toArray(); - rows.sort(function (a, b) { - const date1a = new Date($(a).find('td:eq(1)').text().replace(/\//g, '-')); - const date1b = new Date($(b).find('td:eq(1)').text().replace(/\//g, '-')); - return date1b - date1a; - }); - for (let i = 0; i < rows.length; i++) { - table.append(rows[i]); - } -} - -//date keyup for tab-1 -$(".date").keyup(function () { - const value = $(this).val(); - const lengthValue = value.length; - const id = $(this).attr('id'); - - - if (lengthValue == 10) { - if (!dateValidCheck(this)) { - $(this).addClass("errored"); - } else { - $(this).removeClass("errored"); - - if (id == 'lastDay1') { - setDate(value, 'lastDay1', 'endDate1', true); - } else if (id == 'endDate1') { - setDate(value, 'endDate1', 'lastDay1', false); - } - } - } -}); -//date keyup for tab-except1 -$(".date").keyup(function () { - const value = $(this).val(); - const lengthValue = value.length; - const activeTabPane = $('.tab-pane.active'); - const startDate = activeTabPane.find('.input2'); - const lastDay = activeTabPane.find('.input3'); - const endDate = activeTabPane.find('.input4'); - const endDateId = endDate.attr('id'); - const lastDateId = lastDay.attr('id'); - const id = $(this).attr('id'); - - - if (lengthValue == 10) { - if (!dateValidCheck(this)) { - $(this).addClass("errored"); - } else { - $(this).removeClass("errored"); - - if (id == lastDateId) { - setDate(value, lastDateId, endDateId, true); - } else if (id == endDateId) { - setDate(value, endDateId, lastDateId, false); - } - } - } -}); - -function setDate(value, fieldIdInput, fieldIdResult, islastDay) { - - let urlPost = ''; - - if (islastDay == true) { - urlPost = AfterDateurl; - } else { - urlPost = BeforeDatesurl; - } - $.ajax({ - /* contentType: 'charset=utf-8',*/ - async: false, - dataType: 'json', - type: 'POST', - url: urlPost, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "date": value }, - success: function (response) { - - - $(`#${fieldIdResult}`).val(response.resultDate); - }, - failure: function (response) { - //console.log(5, response); - } - - }); -} - - -$("#btnSaveData").click(function () { - $(".input-send-data").remove(); - - $(".tab-pane").each(function (i) { - var workshopid = $(this).attr("data-workshopid"); - var workshopName = $(this).attr("data-workshopName"); - var employeeId = modelEmployeeId; - const personnelCode = $(this).find('input.position-code'); - var jobId = $(this).find('.ul-search').find('span.value').attr('data-value'); - var includeStatus = $(this).find('input[type=checkbox]').is(":checked"); - //console.log(workshopid); - //console.log(jobId); - //console.log($("#select-"+workshopid).val()); - - const haspersonelcode = personnelCode.attr("data-haspersonelcode"); - - if (haspersonelcode.toLowerCase() != "true") { - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - } else { - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - } - var index2 = 0; - $(this).find('table tr').each(function (x) { - const leftWorkDate = $(this).find('td:eq(4)').text().trim(); - const startWorkDate = $(this).find('td:eq(1)').text().trim(); - const id = $(this).attr("data-id"); - - $("#divAppendData").append(``); - $("#divAppendData").append(``); - - if (startWorkDate != '') { - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - $("#divAppendData").append(``); - //$("#divAppendData").append(''); - index2 = index2 + 1; - } - }); - }); - let conflictFound = false; - $('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText == '' && rowEndDateText != '') { - rowStartDate.addClass("emptyStart"); - conflictFound = true; - } - }); - if (!conflictFound) { - $("#employee").submit(); - } - - //$('#sendData').click(); - //$("#employee").submit(); -}); - - -$('#employee').submit(function (e) { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - - e.preventDefault(); - e.stopImmediatePropagation(); - $.ajax({ - async: false, - type: "POST", - url: $(this).attr('action'), - data: $(this).serialize(), - success: function (response) { - console.log(response); - if (response.flag == 'list') { - let result = ''; - $("#resultdiv").html(result); - $("#result-modal").modal('show'); - } else { - if (response.endResult.isSuccedded == true) { - //$.Notification.autoHideNotify('success', 'top right', response.endResult.message); - swal({ - title: response.endResult.message, - text: "", - type: "success", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: "بستن", - //cancelButtonText: "خیر", - closeOnConfirm: true, - customClass: "successSwall" - }); - } else { - // $.Notification.autoHideNotify('error', 'top right', response.endResult.message); - swal({ - title: response.endResult.message, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - } - } - } - - }); - return false; -}); - - -function checkcountRow() { - - $(".tab-pane").each(function () { - const tab = $(this); - const table = $(this).find('table'); - table.find('tr').each(function (x) { - const leftWorkDate = $(this).find('td:eq(4)').text().trim(); - const startWorkDate = $(this).find('td:eq(1)').text().trim(); - disableInput(); - disableSaveBtn(); - - }); - - const trCount = $(this).find('table tr').length - 1; - const newRowNumber = 5 - trCount; - if (trCount < 5) { - for (let index = 0; index < newRowNumber; index++) { - const newRow = `${trCount + index + 1 - }`; - table.find("tbody").append(newRow); - disappearIcon(); - //checkPremision(); - } - } - }); - sortDates(); - handleScroll(); - checkPremision(); -} - -//this function handles the show or hide of the scrollbar -function handleScroll() { - const activeTabPane = $('.tab-pane.active'); - const rows = activeTabPane.find(".workDate-table tbody").find("tr"); - const rowCount = rows.length; - const content = activeTabPane.find('.table-content'); - if (rowCount > 5) { - content.removeClass('hide-scrollbar'); - } else { - content.addClass('hide-scrollbar'); - } -} - -//this function handles the show or hide of the scrollbar of the company titles -function handleCompanyScroll() { - if ($('.nav-tabs a').length <= 4) { - $('.nav-tabs').addClass('hide-scrollbar'); - } else { - $('.nav-tabs').removeClass('hide-scrollbar'); - } -} - -// this function disable/enable the input fields based on the data in the table -function disableSaveBtn() { - const activeTabPane = $('.tab-pane'); - const table = activeTabPane.find(".workDate-table tbody").get(0); - const navLink = $('.nav-link'); - const navTitle = navLink.find('.nav-title'); - const firstColumnData = Array.from(table.rows) - .map(row => row.cells[1].textContent.trim()) - .filter(cellValue => cellValue !== ""); - const secondColumnData = Array.from(table.rows) - .map(row => row.cells[3].textContent.trim()) - .filter(cellValue => cellValue !== ""); - const thirdColumnData = Array.from(table.rows) - .map(row => row.cells[4].textContent.trim()) - .filter(cellValue => cellValue !== ""); - if (navTitle.text().trim() === 'نام شرکت') { - $("#save1").removeClass("buttonDeactived"); - } else if (firstColumnData.length > secondColumnData.length) { - $("#save1").addClass("buttonDeactived"); - } else if (firstColumnData.length == 0 && secondColumnData.length == 0) { - $("#save1").addClass("buttonDeactived"); - } else { - $("#save1").removeClass("buttonDeactived"); - } -} - -function disableInput() { - let activeTabPane = $('.tab-pane.active'); - let table = activeTabPane.find(".workDate-table tbody").get(0); - let navLink = $('.nav-link'); - let navTitle = navLink.find('.nav-title'); - - - let firstColumnData = Array.from(table.rows) - .map(row => row.cells[1].textContent.trim()) - .filter(cellValue => cellValue !== ""); - - - let secondColumnData = Array.from(table.rows) - .map(row => row.cells[3].textContent.trim()) - .filter(cellValue => cellValue !== ""); - - - let thirdColumnData = Array.from(table.rows) - .map(row => row.cells[4].textContent.trim()) - .filter(cellValue => cellValue !== ""); - - - // console.log(firstColumnData.length); - // console.log(secondColumnData.length); - //console.log(thirdColumnData.length); - - if (navTitle.text().trim() === 'نام شرکت') { - disabledJob(); - activeTabPane.find('.input2').prop('disabled', true); - activeTabPane.find('.input3').prop('disabled', true); - activeTabPane.find('.input4').prop('disabled', true); - if (!activeTabPane.find('.input2').hasClass('blinking')) { - activeTabPane.find('.input2').val(''); - } else if (!activeTabPane.find('.input3').hasClass('blinking')) { - activeTabPane.find('.input3').val(''); - } else if (!activeTabPane.find('.input4').hasClass('blinking')) { - activeTabPane.find('.input4').val(''); - } - activeTabPane.find('.position-name').prop('disabled', true); - //$('.position-code').prop('disabled', true); - activeTabPane.find('.setContract').prop('disabled', true); - //$("#save1").removeClass("buttonDeactived"); - } else if (firstColumnData.length > secondColumnData.length) { - removeDisabledJob(); - activeTabPane.find('.input2').prop('disabled', true); - activeTabPane.find('.input2').val(''); - activeTabPane.find('.input3').prop('disabled', false); - activeTabPane.find('.input4').prop('disabled', false); - } else { - removeDisabledJob(); - activeTabPane.find('.input3').val(''); - activeTabPane.find('.input4').val(''); - activeTabPane.find('.input2').prop('disabled', false); - activeTabPane.find('.input3').prop('disabled', true); - activeTabPane.find('.input4').prop('disabled', true); - activeTabPane.find('.position-name').prop('disabled', false); - //$("#save1").removeClass("buttonDeactived"); - activeTabPane.find('.setContract').prop('disabled', false); - } - var haspersonelcode = activeTabPane.find('input.position-code').attr("data-haspersonelcode"); - if (haspersonelcode.toLowerCase() == "true" || haspersonelcode == '') { - activeTabPane.find('input.position-code').prop('disabled', true); - } else { - activeTabPane.find('input.position-code').prop('disabled', false); - } - - -} - -// tooltip for when the title of the tabs are long -$(function () { - $('.nav-title').tooltip({ - container: 'body', - fontFamily: 'IranSans', - background: 'grey', - placement: 'top', - offset: { x: 150, y: 20 }, - trigger: 'hover', - html: true, - title: function () { - return `${$(this).text()}`; - } - }); -}); - - -function deleteLeftwork(element, workshopId) { - swal({ - title: "توجه داشته باشید با تایید این پیام، اطلاعات لیست مورد نظر بطور کامل از بانک اطلاعاتی حذف خواهد شد.", - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: "بله", - cancelButtonText: "خیر", - closeOnConfirm: false, - closeOnCancel: true - }, - function (isConfirm) { - if (isConfirm) { - - const newItem = $(element).attr('newitem'); - var result = false; - if (newItem == null) { - $("#IsDelete").val('true'); - //result=deleteWorkshop(workshopId); - deleteWorkshop(workshopId).then(function (res) { - result = res; - afterDeleteWorkshop(element, workshopId, result, newItem); - }).catch(function (error) { - console.log(error); - }); - } else { - afterDeleteWorkshop(element, workshopId, result, newItem); - } - disableInput(); - disableSaveBtn(); - // disappearIcon(); checkPremision(); - } - }); -} - - -function getPersonelCode(workshopId) { - //console.log(workshopId); - const employeeId = modelEmployeeId; - // var workshopId=$("#input1").val(); - - $.ajax({ - /* contentType: 'charset=utf-8',*/ - async: false, - dataType: 'json', - type: 'POST', - url: GetPersonelCodeurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": Number(workshopId), "employeeId": Number(employeeId) }, - success: function (response) { - - const inputCode = $(`div[data-workshopid|='${workshopId}']`).find("input.position-code"); - // var inputCode = $('.tab-pane').find(`[data-workshopid='${workshopId}']`).find("input.position-code"); - //var inputClass=inputCode.attr("class"); - inputCode.val(response.personnelCode); - if (response.hasPersonelCode) { - disableInput(); - inputCode.prop("disabled", true); - inputCode.attr("data-haspersonelcode", "true"); - } else { - inputCode.prop("disabled", false); - inputCode.attr("data-haspersonelcode", "false"); - } - - disableSaveBtn(); - }, - failure: function (response) { - // console.log(5, response); - } - }); -} - -var timerLeftWorkInsurance = null; -$('body').on('keyup', - '.select2-search__field', - function () { - //clearTimeout(timerLeftWorkInsurance); - //timerLeftWorkInsurance = setTimeout(jobListByText, 1000); - jobListByText(); - }); - -lockLeftWorkInsurance = false; -lastValueLeftWorkInsurance = ''; - -function jobListByText() { - const this_ = $(".select2-search__field"); - var text = $(this_).val(); - var selectItem = $('.tab-pane.active').find('.select-city'); - const workshopid = $('.tab-pane.active').attr('data-workshopid'); - - const selectControls = $(this_).attr("aria-controls"); - if (text != "" && selectControls != "select2-input1-results") { - if (!lockLeftWorkInsurance) { - lockLeftWorkInsurance = true; - lastValueLeftWorkInsurance = text; - } else { - return; - } - $.ajax({ - async: false, - /* contentType: 'charset=utf-8',*/ - dataType: 'json', - type: 'POST', - url: JobListByTexturl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "textSearch": text, "workshopId": workshopid }, - success: function (response) { - lockLeftWorkInsurance = false; - $.each(response.jobList, - function (i, item) { - if (selectItem.find(`option[value='${item.id}']`).length == 0) { - const newOption = new Option((item.jobName + ' | ' + item.jobCode), item.id, true, true); - selectItem.append(newOption); - } - selectItem.val('0'); - }); - if (text != lastValueLeftWorkInsurance) { - //console.log(100); - jobListByText($(".select2-search__field")); - } - }, - failure: function (response) { - lockLeftWorkInsurance = false; - console.log(5, response); - } - }); - } else { - //console.log(10); - } -} - -function getJobByWorkshopId(workshopId) { - $.ajax({ - async: false, - /* contentType: 'charset=utf-8',*/ - dataType: 'json', - type: 'POST', - url: JobListByWorkshopIdurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId }, - success: function (response) { - // console.log(response); - $.each(response.jobList, - function (i, item) { - const newOption = new Option((item.jobName + ' | ' + item.jobCode), item.id, true, true); - $(`#select-${workshopId}`).append(newOption); - }); - $(`#select-${workshopId}`).val('0'); - }, - failure: function (response) { - - console.log(5, response); - } - }); -} - -function checkPremision() { - if (list.indexOf(10420) == -1) { - $(".permission-removeDate").addClass("d-none"); - } - if (list.indexOf(10425) == -1) { - $(".permission-editDate").addClass("d-none"); - } - if (list.indexOf(10419) == -1) { - $('.delworkshop').remove(); - } -} - -function deleteWorkshop(id) { - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - return new Promise(function (resolve, reject) { - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: DeleteLeftWorkInsuranceWorkshopurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": id, "employeeId": modelEmployeeId }, - success: function (response) { - console.log(response); - if (response.isSuccedded == true) { - if (response.message != null) { - swal({ - title: response.message, - text: "", - type: "success", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: "بستن", - //cancelButtonText: "خیر", - closeOnConfirm: true, - customClass: "successSwall" - }); - } - resolve(true); - } else { - //$.Notification.autoHideNotify('error', 'top right', response.message); - - swal({ - title: response.message, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - closeOnCancel: true, - customClass: "errorSwall" - }); - resolve(false); - } - }, - error: function (response) { - console.log(5, response); - reject(response); - } - }); - }); -} - -function afterDeleteWorkshop(element, workshopId, result, newItem) { - const navLink = $(element).closest('.nav-link'); - const navTitle = navLink.find('.nav-title'); - - if ((workshopId != 0 && result == true) || newItem == "true") { - - if ($(element).closest('.nav-link').index() === 0 && $('.nav-tabs a').length === 1) { - navTitle.text('نام شرکت'); - navTitle.addClass("disactive"); - const activeTabPane = $('.tab-pane.active'); - activeTabPane.find("input.position-code").val(""); - activeTabPane.find(".position-name").val(0); - const rows = activeTabPane.find(".workDate-table tbody").find("tr"); - const rowCount = rows.length; - if (rowCount === 6) { - $('.table-content').addClass('hide-scrollbar'); - } - rows.each(function () { - if (rowCount <= 5) { - $(this).find('td:eq(6)').text(""); - //$(this).find('td:eq(5)').text(""); - $(this).find('td:eq(4)').text(""); - $(this).find('td:eq(3)').text(""); - // $(this).find('td:eq(2)').text(""); - $(this).find('td:eq(1)').text(""); - disappearIcon(); - - } - if (rowCount > 5) { - $(this).remove(); - updateRowNumbers(); - } - }); - } else { - const href_ = $(element).closest('.nav-link').attr("href"); - - const tabId = href_.replace('#', ''); - - - $(element).closest('.nav-link').remove(); - handleCompanyScroll(); - $(`#${tabId}`).remove(); - - if ($(element).closest('.nav-link').hasClass('active')) { - $('.nav-tabs a:first-child').trigger('click'); - } - } - swal({ - title: "عملیات با موفقیت حذف شد.", - text: "", - type: "success", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: "بستن", - //cancelButtonText: "خیر", - closeOnConfirm: true, - customClass: "successSwall" - }); - } - checkPremision(); -} - -function deleteDate(element, date, workshopId, type) { - const deletedRow = $(element).closest('tr'); - const endDate = deletedRow.find('td:eq(3)').text(); - $("#deleteIndex").val(deletedRow.find('td:eq(0)').text()); - - $('.sweet-alert').removeClass("successSwall"); - $('.sweet-alert').removeClass("errorSwall"); - - if (type == "first" && endDate != "") { - swal({ - title: "لطفا برای حذف تاریخ شروع به کار، ابتدا تاریخ ترک کار را حذف کنید.", - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - } else if (workshopId != 0 && date != '') { - const hasInsuranceList = deletedRow.attr("data-hasInsuranceList"); - //console.log(hasInsuranceList); - if (type == "first" && hasInsuranceList.toLowerCase() == "true") - $("#deleteStartDate").val(date); - - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: DeleteLeftWorkInsuranceWorkshopurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": date, "type": (type == "first" ? 1 : 2) }, - success: function (response) { - //console.log(response); - if (response.isSuccedded == true) { - if (type == "first") - startDateEdit(element); - else - endDateEdit(element); - } else { - //$.Notification.autoHideNotify('error', 'top right', response.message); - swal({ - title: response.message, //response.endResult.message, - text: "", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - - const tr = $(element).parent().parent(); - if (type == "first") { - tr.find('td:eq(1)').addClass("emptyStart"); - } else { - tr.find('td:eq(3)').addClass("emptyStart"); - tr.find('td:eq(4)').addClass("emptyStart"); - } - - } - }, - error: function (response) { - console.log(5, response); - } - }); - } else if (workshopId == 0 || date == '') { - if (type == "first") - startDateEdit(element); - else - endDateEdit(element); - } - -} - - -function removeDisabledJob() { - const activeTabPane = $('.tab-pane.active'); - var workshopId = activeTabPane.attr("data-workshopid"); - - if (activeTabPane.find(".dadmehr-select-search").hasClass('disabled')) { - activeTabPane.find(".custom-select").removeClass('disabled'); - activeTabPane.find(".dadmehr-select-search").removeClass('disabled'); - var workshopId = activeTabPane.attr("data-workshopid"); - - activeTabPane.find(".custom-select").html( - `` - ); - } -} - -function disabledJob() { - - const activeTabPane = $('.tab-pane.active'); - activeTabPane.find(".custom-select").addClass('disabled'); - activeTabPane.find(".dadmehr-select-search").addClass('disabled'); - const workshopId = activeTabPane.attr("data-workshopid"); - - activeTabPane.find(".custom-select").html( - `` - ); - activeTabPane.find('.ul-search').html(''); -} - -function saveData() { - $("#editStartDate").val(''); - $("#editLeftDate").val(''); - $("#editEndDate").val(''); - let activeTabPane = $('.tab-pane.active'); - let editIcon = activeTabPane.find(".edit-icon"); - let deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - activeTabPane.find(".date").removeClass("blinking"); - let startDate = activeTabPane.find('.input2'); - let lastDay = activeTabPane.find('.input3'); - let endDate = activeTabPane.find('.input4'); - let startValue = startDate.val(); - let lastValue = lastDay.val(); - let endValue = endDate.val(); - let dateId = startDate.attr('id'); - let number = dateId.match(/\d+/)[0]; - - if (startValue != '' && !checkLength(startDate.val(), 10)) { - if (!dateValidCheckByValue(startDate)) { - startDate.addClass("errored"); - } else { - startDate.removeClass("errored"); - } - } - if (lastValue != '' && !checkLength(lastDay.val(), 10)) { - if (!dateValidCheckByValue(startDate)) { - lastDay.addClass("errored"); - } else { - lastDay.removeClass("errored"); - } - } - if (endValue != '' && !checkLength(endDate.val(), 10)) { - if (!dateValidCheckByValue(endDate)) { - endDate.addClass("errored"); - } else { - endDate.removeClass("errored"); - } - - } - - if (!activeTabPane.find('.date').hasClass('errored')) { - - - var editable = false; - if (startDate != '' && !activeTabPane.find('.date').hasClass('errored') && $("#editStartDate").val() != '') { - var workshopId = activeTabPane.attr("data-workshopid"); - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: CheckEditLeftWorkInsuranceurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": startValue, "type": 1 }, - success: function (response) { - // console.log(response); - if (response.isSuccedded == true) { - if (!startDate.hasClass('errored') && !endDate.hasClass('errored') && !lastDay.hasClass('errored')) { - addRow2(number, startValue, lastValue, endValue); - activeTabPane.find('.input2').val(''); - disableInput(); - disableSaveBtn(); - handleScroll(); - - const editIcon = activeTabPane.find(".edit-icon"); - const deleteIcon = activeTabPane.find(".edit-date"); - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - activeTabPane.find(".date").removeClass("blinking"); - } - $('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } else { - swal({ - title: "امکان ویرایش ثبت شروع به کار وجود ندارد.", - text: response.message, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - // var tr = $(activeTabPane).find('.workDate-table tbody tr'); - // tr.find('td:eq(1)').text($("#editStartDate").val()); - - } - }, - error: function (response) { - console.log(5, response); - } - }); - } else { - if (!activeTabPane.find('.date').hasClass('errored')) { - if ($("#deleteStartDate").val() != '') { - swal({ - title: "امکان حذف تاریخ وجود ندارد.", - text: ` به دلیل استفاده این تاریخ در ایجاد لیست بیمه، ثبت تاریخ جدید قبل از تاریخ ${$("#deleteStartDate").val()}امکان پذیر می باشد. `, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url: CheckEditLeftWorkInsuranceurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": date1, "type": 1 }, - success: function (response) { - if (response.isSuccedded == true) { - if (!startDate.hasClass('errored') && !lastDay.hasClass('errored') && !endDate.hasClass('errored')) { - $("#deleteStartDate").val(''); - - addRow2(number, startValue, lastValue, endValue); - disableInput(); - disableSaveBtn(); - handleScroll(); - activeTabPane.find('.input2').val(''); - } - activeTabPane.find('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } else { - if ($("#editLeftDate").val() != '') { - swal({ - title: "امکان ثبت تاریخ شروع به کار وجود ندارد", - text: response.message, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - } else { - swal({ - title: "امکان ثبت تاریخ ترک کار وجود ندارد", - text: `در صورت تمایل به ویرایش تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید. `, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - } - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - - } - }, - error: function (response) { - console.log(5, response); - } - }); - - - } else { - var workshopId = activeTabPane.attr("data-workshopid"); - if (lastValue != '' && !lastDay.hasClass('errored') && !endDate.hasClass('errored')) { - //check edit for endDate - $.ajax({ - async: false, - dataType: 'json', - type: 'POST', - url:CheckEditLeftWorkInsuranceurl, - headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }, - data: { "workshopId": workshopId, "employeeId": modelEmployeeId, "date": endValue, "type": 2 }, - success: function (response) { - if (response.isSuccedded == true) { - if (!startDate.hasClass('errored') && !lastDay.hasClass('errored') && !endDate.hasClass('errored')) { - $("#deleteStartDate").val(''); - - addRow2(number, startValue, lastValue, endValue); - disableInput(); - disableSaveBtn(); - handleScroll(); - activeTabPane.find('.input2').val(''); - } - activeTabPane.find('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } else { - if ($("#editLeftDate").val() != '') { - swal({ - title: "امکان ویرایش تاریخ ترک کار وجود ندارد", - text: `در صورت تمایل به ویرایش تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید. `, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - } else { - swal({ - title: "امکان ثبت تاریخ ترک کار وجود ندارد", - text: `در صورت تمایل به ویرایش تاریخ ترک کار این پرسنل می بایست لیست تنظیمی بیمه ${response.message} را حذف نمایید. `, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - //confirmButtonText: "بستن", - cancelButtonText: "بستن", - closeOnConfirm: false, - customClass: "errorSwall" - }); - } - deleteIcon.removeClass("disabled-edit"); - editIcon.removeClass("disabled-edit"); - - } - }, - error: function (response) { - console.log(5, response); - } - }); - - } else if (startDate.val() != '' && !startDate.hasClass('errored')) { - addRow2(number, startValue, lastValue, endValue); - activeTabPane.find('.input2').val(''); - disableInput(); - disableSaveBtn(); - handleScroll(); - } - } - } - $('.workDate-table').find("tbody tr").each(function () { - const row = $(this); - const rowStartDate = row.find('td:eq(1)'); - const rowEndDate = row.find('td:eq(4)'); - const rowStartDateText = row.find('td:eq(1)').text(); - const rowEndDateText = row.find('td:eq(4)').text(); - if (rowStartDateText != '') { - rowStartDate.removeClass("emptyStart"); - } - }); - } - - } - - // $('.workDate-table').find("tbody tr").each(function () { - // let row = $(this); - // let rowStartDate = row.find('td:eq(1)'); - // let rowEndDate = row.find('td:eq(4)'); - // let rowStartDateText = row.find('td:eq(1)').text(); - // let rowEndDateText = row.find('td:eq(4)').text(); - // if (rowStartDateText != '') { - // rowStartDate.removeClass("emptyStart"); - // } - // }); -} \ No newline at end of file