2225 lines
104 KiB
JavaScript
2225 lines
104 KiB
JavaScript
|
|
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 = $(`<div class="tab-pane" data-workshopId="${workshopId}" data-workshopName="${workshopName}" id="tab${counter}" data-pane="${counter
|
|
}"><div class="pane-content"><div class="top-content first-row"><div class="first-col-content"><div class="select-container"><label> سمت </label><div class="dadmehr-select-search" onclick="inputFocus(this)" ><div class="custom-select text-right"><ul class="ul-search single text-right" data-url="${JobByTextSearchurl}" ><li><input onkeyup=searchText(event,this,"${JobByTextSearchurl}",true) class= "text-right input-text" /> </li></ul><ul class="result options text-right"></ul></div><span class="span-input"></span></div></div></div><div class="second-col-content"><label> شماره پرسنلی </label><input type="text" data-haspersonelcode="" class="position-code"></div></div><div class="top-content"><div class="first-col-content"><input type="text" tabindex="1" class="persianDateInput date-input date input2 start-date" id="start-date-${counter
|
|
}" placeholder="تاریخ شروع بکار"></div><div class="second-col-content"><input type="text" tabindex="2" class="persianDateInput date-input date input3 last-day" id="last-day-${counter
|
|
}" placeholder="تاریخ آخرین روز کاری"></div><div class="third-col-content"><input type="text" tabindex="3" class="persianDateInput date-input date input4 end-date" id="end-date-${counter
|
|
}" placeholder="تاریخ ترک کار"><button class="btn save" onclick="saveData()">ثبت</button></div></div><div class="table-content"><table class="table table-bordered table-striped workDate-table"><colgroup><col style="width: 20px;"><col style="width: 140px;"><col class="col-edit" style="width: 5px;"><col style="width: 140px;"><col style="width: 140px;"><col class="col-remove" style="width: 5px;"><col style="width: 30px;"></colgroup><thead><tr><th>#</th><th style="text-align: end;">تاریخ شروع بکار</th><th style="border-right-width: 0;"></th><th>تاریخ آخرین روز کاری</th><th style="text-align: end;">تاریخ ترک کار</th><th style="border-right-width: 0;" class="permision" ></th><th class="text-small">روزهای کارکرد</th></tr></thead><tbody><tr data-id="0"><td>1</td><td></td><td class="permision"><a onclick=deleteDate(this,"",0,"first") href="#" class="edit-date permission-removeDate first-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td><td></td><td class="permision" ><a onclick=deleteDate(this,"",0,"last") href="#" class="edit-date permission-removeDate second-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td></tr><tr data-id="0"><td>2</td><td></td><td class="permision"><a onclick=deleteDate(this,"",0,"first") href="#" class="edit-date permission-removeDate first-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td><td></td><td class="permision" ><a onclick=deleteDate(this,"",0,"last") href="#" class="edit-date permission-removeDate second-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td></tr><tr data-id="0"><td>3</td><td></td><td class="permision"><a onclick=deleteDate(this,"",0,"first") href="#" class="edit-date permission-removeDate first-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td><td></td><td class="permision" ><a onclick=deleteDate(this,"",0,"last") href="#" class="edit-date permission-removeDate second-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td></tr><tr data-id="0"><td>4</td><td></td><td class="permision"><a onclick=deleteDate(this,"",0,"first") href="#" class="edit-date permission-removeDate first-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td><td></td><td class="permision" ><a onclick=deleteDate(this,"",0,"last") href="#" class="edit-date permission-removeDate second-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td></tr><tr data-id="0"><td>5</td><td></td><td class="permision"><a onclick=deleteDate(this,"",0,"first") href="#" class="edit-date permission-removeDate first-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td><td></td><td class="permision" ><a onclick=deleteDate(this,"",0,"last") href="#" class="edit-date permission-removeDate second-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td></tr></tbody></table></div > <div class="permision-info permission-options options-box"><div class="options-info">در صورت تمایل به محاسبه ی عناوین ذیل در فیش حقوقی، گزینه های موردنظر را فعال نمایید</div><div class="optional-wages d-flex"><div class="d-flex options-check col-lg-4 col-md-4 col-sm-3 col-xs-4"><div class="checkbox-wrapper-2"><label class="toggleButton"><input type="checkbox" class="activated addyearspay"><div><svg viewBox="0 0 44 44"><path d="M14,24 L21,31 L39.7428882,11.5937758 C35.2809627,6.53125861 30.0333333,4 24,4 C12.95,4 4,12.95 4,24 C4,35.05 12.95,44 24,44 C35.05,44 44,35.05 44,24 C44,19.3 42.5809627,15.1645919 39.7428882,11.5937758" transform="translate(-2.000000, -2.000000)"></path></svg></div></label></div><span class="options-type">سنوات </span></div><div class="d-flex options-check col-lg-4 col-md-4 col-sm-3 col-xs-4"><div class="checkbox-wrapper-2"><label class="toggleButton"><input type="checkbox" class="activated addbonusespay"><div><svg viewBox="0 0 44 44"><path d="M14,24 L21,31 L39.7428882,11.5937758 C35.2809627,6.53125861 30.0333333,4 24,4 C12.95,4 4,12.95 4,24 C4,35.05 12.95,44 24,44 C35.05,44 44,35.05 44,24 C44,19.3 42.5809627,15.1645919 39.7428882,11.5937758" transform="translate(-2.000000, -2.000000)"></path></svg></div></label></div><span class="options-type"> عیدی و پاداش </span></div><div class="d-flex options-check col-lg-4 col-md-4 col-sm-3 col-xs-4"><div class="checkbox-wrapper-2"><label class="toggleButton"><input type="checkbox" class="activated addleavepay"><div><svg viewBox="0 0 44 44"><path d="M14,24 L21,31 L39.7428882,11.5937758 C35.2809627,6.53125861 30.0333333,4 24,4 C12.95,4 4,12.95 4,24 C4,35.05 12.95,44 24,44 C35.05,44 44,35.05 44,24 C44,19.3 42.5809627,15.1645919 39.7428882,11.5937758" transform="translate(-2.000000, -2.000000)"></path></svg></div></label></div><span class="options-type">مزد و مرخصی </span></div></div></div></div ></div > `);
|
|
$(".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" ><span class="del-com"><i newItem="true" onclick="deleteLeftwork(this,${newworkshopId
|
|
})" class="fa fa-trash trash-icon delworkshop" style = "color: white;" permission="10421"></i></span><span data-workshopid="${newworkshopId}" class="nav-title">${newTitle}</span></a > `);
|
|
$(".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()}</span > `;
|
|
}
|
|
});
|
|
});
|
|
|
|
// 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" ><td>${rowCount + 1}</td><td>${date1
|
|
}</td><td class="permision"><a href="#" onclick=deleteDate(this,"",0,"first") class="edit-date permission-removeDate first-edit"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate"><i class="fa fa-edit"></i></a></td ><td>${date2}</td><td>${date3
|
|
}</td><td class="permision"><a href="#" onclick=deleteDate(this,"",0,"last") class="edit-date permission-removeDate second-edit"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate"><i class="fa fa-edit"></i></a></td > <td>_</td></tr > `;
|
|
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" ><td>${rowCount + 1}</td><td>${date1
|
|
}</td><td class="permision"><a href="#" onclick=deleteDate(this,"",0,"first") class="edit-date permission-removeDate first-edit"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate"><i class="fa fa-edit"></i></a></td ><td>${date2}</td><td>${date3
|
|
}</td><td class="permision"><a href="#" onclick=deleteDate(this,"",0,"last") class="edit-date permission-removeDate second-edit"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate"><i class="fa fa-edit"></i></a></td > <td>_</td></tr > `;
|
|
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(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].WorkshopId" id="PersonnelCode_${i
|
|
}__WorkshopId" value="${workshopid}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].EmployeeId" id="PersonnelCode_${i
|
|
}__EmployeeId" value="${employeeId}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].PersonnelCode" id="PersonnelCode_${i
|
|
}__PersonnelCode" value="${personnelCode.val()}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].WorkShopName" id="PersonnelCode_${i
|
|
}__WorkShopName" value="${workshopName}" />`);
|
|
} else {
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].HasPersonelCode" id="PersonnelCode_${i
|
|
}__HasPersonelCode" value="true" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].WorkshopId" id="PersonnelCode_${i
|
|
}__WorkshopId" value="0" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].EmployeeId" id="PersonnelCode_${i
|
|
}__EmployeeId" value="0" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].PersonnelCode" id="PersonnelCode_${i
|
|
}__PersonnelCode" value="0" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="PersonnelCode[${i}].WorkShopName" id="PersonnelCode_${i
|
|
}__WorkShopName" value="" />`);
|
|
}
|
|
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(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].WorkshopId" id="LeftWorkGroups_${i
|
|
}__WorkshopId" value="${workshopid}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].WorkshopName" id="LeftWorkGroups_${i
|
|
}__WorkshopName" value="${workshopName}" />`);
|
|
if (startWorkDate != '') {
|
|
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].Id" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__Id" value="${id}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].WorkshopId" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__WorkshopId" value="${workshopid}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].EmployeeId" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__EmployeeId" value="${employeeId}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].WorkshopName" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__WorkshopName" value="${workshopName}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].StartWorkDate" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__StartWorkDate" value="${startWorkDate}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].LeftWorkDate" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__LeftWorkDate" value="${leftWorkDate}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].JobId" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__JobId" value="${jobId}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].IncludeStatus" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__IncludeStatus" value="${includeStatus}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].AddBonusesPay" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__AddBonusesPay" value="${addBonusesPay}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].AddYearsPay" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__AddYearsPay" value="${addYearsPay}" />`);
|
|
$("#divAppendData").append(`<input class="input-send-data" type="hidden" name="LeftWorkGroups[${i}].LeftworkViewModels[${index2
|
|
}].AddLeavePay" id="LeftWorkGroups_${i}__LeftworkViewModels_${index2}__AddLeavePay" value="${addLeavePay}" />`);
|
|
|
|
//$("#divAppendData").append('<input type="hidden" name="LeftWorkGroups['+i+'].LeftworkViewModels['+x+'].EmployeeFullName" id="LeftWorkGroups_'+i+'__LeftworkViewModels_'+x+'__EmployeeFullName" value="'+leftWorkDate+'" />');
|
|
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 = '<ul>';
|
|
for (let i = 0; i < response.endResult.length; i++) {
|
|
if (response.endResult[i].isSuccedded == true) {
|
|
result = result + '<li ><div class="alert alert-success">' + response.endResult[i].message + '</div></li>';
|
|
} else {
|
|
result = result + '<li><div class="alert alert-danger">' + response.endResult[i].message + '</div></li>';
|
|
}
|
|
}
|
|
result = result + '</ul>';
|
|
$("#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 = `<tr><td>${trCount + index + 1
|
|
}</td><td></td><td class="permision"><a href="#" onclick=deleteDate(this,"",0,"first") class="edit-date permission-removeDate first-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td><td></td><td class="permision"><a href="#" onclick=deleteDate(this,"",0,"last") class="edit-date permission-removeDate second-edit d-none"><i style="color: red;" class="ion-close-circled"></i></a><a href="#" class="edit-icon permission-editDate d-none"><i class="fa fa-edit"></i></a></td><td></td></tr>`;
|
|
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 `<span style="font-family: IranSans, sans-serif;">${$(this).text()}</span>`;
|
|
}
|
|
});
|
|
});
|
|
|
|
//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(
|
|
`<ul class="ul-search single text-right" data-url="${JobListByTexturl}">` + `<li> <input onkeyup=searchText(event,this,"${JobByTextSearchurl}",true) class= "text-right input-text" /> </li>` + '</ul>' + '<ul class= "result options text-right" >' + '</ul>'
|
|
);
|
|
}
|
|
}
|
|
|
|
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(
|
|
`<ul class="ul-search single text-right" data-url="${JobListByTexturl}">` + `<li> <input onkeyup=searchText(event,this,"${JobByTextSearchurl}",true) class= "text-right input-text" /> </li>` + '</ul>' + '<ul class= "result options text-right" >' + '</ul>'
|
|
);
|
|
activeTabPane.find('.ul-search').html('');
|
|
} |