771 lines
29 KiB
JavaScript
771 lines
29 KiB
JavaScript
var ajaxService = new AjaxService(antiForgeryToken);
|
||
var currentEmployeeId = 0;
|
||
var previousStartDate = "";
|
||
|
||
$(document).ready(function () {
|
||
|
||
$('.loading').hide();
|
||
|
||
$(".modal-xxl").css('max-width', '900px');
|
||
|
||
document.getElementById("MainModal").style.visibility = "visible";
|
||
|
||
$(".select2Option").select2({
|
||
language: "fa",
|
||
dir: "rtl",
|
||
dropdownParent: $('#MainModal'),
|
||
templateResult: function (data, container) {
|
||
if (data.element) {
|
||
$(container).addClass($(data.element).attr("class"));
|
||
}
|
||
return data.text;
|
||
}
|
||
});
|
||
|
||
$('#employeeSelect').on('change', function () {
|
||
$('#rotatingShiftSection').hide();
|
||
$('#HasRollCall').val(false);
|
||
previousStartDate = "";
|
||
$('#SelectedShift_StartTime').val('');
|
||
$('#SelectedShift_EndTime').val('');
|
||
$('#StartLeave').val('');
|
||
$('#EndLeave').val('');
|
||
$('#StartHoures').val('');
|
||
$('#EndHours').val('');
|
||
const selectedEmployeeId = $(this).val();
|
||
currentEmployeeId = selectedEmployeeId;
|
||
});
|
||
|
||
$('#StartLeave').on('keyup', function () {
|
||
const startDateValue = $(this).val();
|
||
|
||
if (startDateValue.length === 10) {
|
||
const dateRegex = /^\d{4}\/\d{2}\/\d{2}$/;
|
||
if (dateRegex.test(startDateValue) && startDateValue !== previousStartDate) {
|
||
previousStartDate = startDateValue;
|
||
rotatingShift(startDateValue);
|
||
}
|
||
}
|
||
});
|
||
|
||
$('#rotatingShift').on('change', function () {
|
||
const [startTime, endTime] = $(this).val().split('|');
|
||
|
||
$('#SelectedShift_StartTime').val(startTime || '');
|
||
$('#SelectedShift_EndTime').val(endTime || '');
|
||
});
|
||
|
||
//******************** شرط استحقاقی و استعلاجی ********************
|
||
$(document).on("change", ".LeaveType", function () {
|
||
if ($('#paid').is(':checked')) {
|
||
$('#dailyType').css('visibility', 'visible');
|
||
}
|
||
|
||
if ($('#sick').is(':checked')) {
|
||
$('#dailyType').css('visibility', 'hidden');
|
||
$('#daily').prop('checked', true);
|
||
if ($('#daily').is(':checked')) {
|
||
$('#end_date_estehghaghi').show();
|
||
$('.time_paid').hide();
|
||
}
|
||
}
|
||
});
|
||
|
||
// شرط ساعتی و روزانه
|
||
$(document).on("change", ".LeaveTime", function () {
|
||
if ($('#daily').is(':checked')) {
|
||
$('#end_date_estehghaghi').show();
|
||
$('.time_paid').hide();
|
||
}
|
||
|
||
if ($('#hourly').is(':checked')) {
|
||
$('#end_date_estehghaghi').hide();
|
||
$('.time_paid').show();
|
||
}
|
||
});
|
||
//******************** شرط استحقاقی و استعلاجی ********************
|
||
|
||
|
||
//******************** بلور کردن باکس ********************
|
||
$('#IsAccepted').on('change', function () {
|
||
if ($(this).is(':checked')) {
|
||
$('#blur-div').addClass('blur');
|
||
$('#descriptionAcceptedCheck').text('');
|
||
$('#descriptionAcceptedCheck').attr('disabled', true);
|
||
|
||
} else {
|
||
$('#blur-div').removeClass('blur');
|
||
$('#descriptionAcceptedCheck').attr('disabled', false);
|
||
}
|
||
});
|
||
|
||
|
||
if ($('#IsAccepted').is(':checked')) {
|
||
$('#blur-div').addClass('blur');
|
||
$('#descriptionAcceptedCheck').text('');
|
||
$('#descriptionAcceptedCheck').attr('disabled', true);
|
||
} else {
|
||
$('#blur-div').removeClass('blur');
|
||
$('#descriptionAcceptedCheck').attr('disabled', false);
|
||
}
|
||
//******************** بلور کردن باکس ********************
|
||
|
||
$(document).ready(function () {
|
||
$(document).on("change", "#IsAccepted", function () {
|
||
var IsAcceptedCheck = $('#IsAccepted').is(':checked');
|
||
if (IsAcceptedCheck) {
|
||
$('#descriptionAcceptedCheck').removeClass('errored');
|
||
$('#descriptionAcceptedCheck').addClass('disable-input');
|
||
$("#descriptionAcceptedCheck").prop('disabled', true);
|
||
} else {
|
||
$('#descriptionAcceptedCheck').removeClass('disable-input');
|
||
$("#descriptionAcceptedCheck").prop('disabled', false);
|
||
}
|
||
})
|
||
});
|
||
|
||
$('#save').on('click', function () {
|
||
var workshopSelect = $("#workshopSelect").val();
|
||
var employeeSelect = $("#employeeSelect").val();
|
||
var hasRollCallInput = $("#HasRollCall").val();
|
||
var rotatingShiftInput = $("#rotatingShift").val();
|
||
|
||
if (hasRollCallInput === 'true') {
|
||
if (rotatingShiftInput == null) {
|
||
$('.alert-msg').show();
|
||
$('.alert-msg p').text('لطفا شیفت را انتخاب کنید ...');
|
||
setTimeout(function () {
|
||
$('.alert-msg').hide();
|
||
$('.alert-msg p').text('');
|
||
}, 3500);
|
||
return false;
|
||
}
|
||
}
|
||
|
||
if(workshopSelect == '') {
|
||
$('.alert-msg').show();
|
||
$('.alert-msg p').text('لطفا کارگاه را انتخاب کنید ...');
|
||
setTimeout(function () {
|
||
$('.alert-msg').hide();
|
||
$('.alert-msg p').text('');
|
||
}, 3500);
|
||
return false;
|
||
}
|
||
|
||
if (employeeSelect == '') {
|
||
$('.alert-msg').show();
|
||
$('.alert-msg p').text('لطفا پرسنل را انتخاب کنید ...');
|
||
setTimeout(function () {
|
||
$('.alert-msg').hide();
|
||
$('.alert-msg p').text('');
|
||
}, 3500);
|
||
return false;
|
||
}
|
||
|
||
$("#descriptionAcceptedCheck").on("change", function () {
|
||
$('#descriptionAcceptedCheck').removeClass('errored');
|
||
});
|
||
|
||
var IsAcceptedCheck = $('#IsAccepted').is(':checked');
|
||
var descriptionAcceptedCheck = $('#descriptionAcceptedCheck').val();
|
||
|
||
if (!IsAcceptedCheck && descriptionAcceptedCheck.length === 0) {
|
||
$('#descriptionAcceptedCheck').addClass('errored');
|
||
$('.alert-msg').show();
|
||
$('.alert-msg p').text('لطفا توضیحات در صورت عدم موافقت را پر کنید.');
|
||
setTimeout(function () {
|
||
$('.alert-msg').hide();
|
||
$('.alert-msg p').text('');
|
||
}, 3500);
|
||
return false;
|
||
}
|
||
|
||
if ($('.errored').length < 1) {
|
||
// $('#saveFinaly').click();
|
||
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'POST',
|
||
url: leaveSaveAjax,
|
||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||
data: $('#create-leave-form').serialize(),
|
||
success: function (response) {
|
||
if (response.isSuccedded) {
|
||
$('.alert-success-msg').show();
|
||
$('.alert-success-msg p').text(response.message);
|
||
setTimeout(function () {
|
||
$('.alert-success-msg').hide();
|
||
$('.alert-success-msg p').text('');
|
||
}, 3500);
|
||
|
||
$('#printSingleID').val(response.printID);
|
||
$('#printSingle').show();
|
||
} else {
|
||
$('.alert-msg').show();
|
||
$('.alert-msg p').text(response.message);
|
||
setTimeout(function () {
|
||
$('.alert-msg').hide();
|
||
$('.alert-msg p').text('');
|
||
}, 3500);
|
||
}
|
||
},
|
||
error: function (err) {
|
||
console.log(err);
|
||
}
|
||
});
|
||
} else {
|
||
$('.alert-msg').show();
|
||
$('.alert-msg p').text('لطفا خطاها را برطرف کنید.');
|
||
setTimeout(function () {
|
||
$('.alert-msg').hide();
|
||
$('.alert-msg p').text('');
|
||
}, 3500);
|
||
}
|
||
});
|
||
|
||
$('#printSingle').on('click', function () {
|
||
var id = $('#printSingleID').val();
|
||
var url = `#showmodal=/Client/Company/Employees/Leave?id=${id}&handler=PrintOneMobile`;
|
||
window.location.href = url;
|
||
});
|
||
|
||
|
||
// $(".date").mask("0000/00/00");
|
||
$(".date").on('input', function () {
|
||
var value = $(this).val();
|
||
$(this).val(convertPersianNumbersToEnglish(value));
|
||
}).mask("0000/00/00");
|
||
|
||
$('.date').on('input', function () {
|
||
let startDate = this.value;
|
||
if (startDate.length == 10) {
|
||
let submitcheck = dateValidcheck(this);
|
||
if (submitcheck) {
|
||
|
||
$(this).removeClass('errored');
|
||
if ($('#StartLeave').val() != '' && $('#EndLeave').val() != '') {
|
||
computeDays();
|
||
}
|
||
|
||
} else {
|
||
$(this).addClass('errored');
|
||
}
|
||
|
||
} else {
|
||
$(this).addClass('errored');
|
||
}
|
||
});
|
||
|
||
function dateValidcheck(inputField1) {
|
||
|
||
let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g],
|
||
arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g],
|
||
fixNumbers = function (str) {
|
||
if (typeof str === 'string') {
|
||
for (var i = 0; i < 10; i++) {
|
||
str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i);
|
||
}
|
||
}
|
||
return str;
|
||
};
|
||
let getdate = inputField1.value;
|
||
|
||
let m1, m2;
|
||
let y1, y2, y3, y4;
|
||
let d1, d2;
|
||
let s1, s2;
|
||
for (var i = 0; i < getdate.length; i++) {
|
||
if (i === 0) {
|
||
y1 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 1) {
|
||
y2 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 2) {
|
||
y3 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 3) {
|
||
y4 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 4) {
|
||
s1 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 5) {
|
||
m1 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 6) {
|
||
m2 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 7) {
|
||
s2 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 8) {
|
||
d1 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 9) {
|
||
d2 = fixNumbers(getdate[i]);
|
||
}
|
||
|
||
}
|
||
let yRes = y1 + y2 + y3 + y4;
|
||
let year = parseInt(yRes);
|
||
let mRes = m1 + m2;
|
||
let month = parseInt(mRes);
|
||
let dRes = d1 + d2;
|
||
let day = parseInt(dRes);
|
||
let fixResult = yRes + s1 + mRes + s2 + dRes;
|
||
let test1 = checkEnValid(inputField1.value);
|
||
|
||
let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult);
|
||
|
||
|
||
if (isValid && test1) {
|
||
// inputField1.style.backgroundColor = '#a6e9a6';
|
||
start1valid = true;
|
||
} else {
|
||
if (inputField1.value != "") {
|
||
// inputField1.style.backgroundColor = '#f94c4c';
|
||
//$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید");
|
||
$('#StartLeave').addClass('errored');
|
||
$('.alert-msg').show();
|
||
$('.alert-msg p').text('لطفا تاریخ را بصورت صحیح وارد کنید');
|
||
setTimeout(function () {
|
||
$('.alert-msg').hide();
|
||
$('.alert-msg p').text("");
|
||
$('#StartLeave').removeClass("errored");
|
||
}, 3500);
|
||
start1valid = false;
|
||
}
|
||
}
|
||
return start1valid;
|
||
|
||
}
|
||
|
||
function checkEnValid(fixDate1) {
|
||
|
||
let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g],
|
||
arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g],
|
||
fixNumbers = function (str) {
|
||
if (typeof str === 'string') {
|
||
for (var i = 0; i < 10; i++) {
|
||
str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i);
|
||
}
|
||
}
|
||
return str;
|
||
};
|
||
let getdate = fixDate1;
|
||
|
||
let m1, m2;
|
||
let y1, y2, y3, y4;
|
||
let d1, d2;
|
||
for (let i = 0; i < getdate.length; i++) {
|
||
if (i === 0) {
|
||
y1 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 1) {
|
||
y2 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 2) {
|
||
y3 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 3) {
|
||
y4 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 5) {
|
||
m1 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 6) {
|
||
m2 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 8) {
|
||
d1 = fixNumbers(getdate[i]);
|
||
}
|
||
if (i === 9) {
|
||
d2 = fixNumbers(getdate[i]);
|
||
}
|
||
}
|
||
let yRes = y1 + y2 + y3 + y4;
|
||
let year = parseInt(yRes);
|
||
let mRes = m1 + m2;
|
||
let month = parseInt(mRes);
|
||
let dRes = d1 + d2;
|
||
let day = parseInt(dRes);
|
||
let kabiseh = false;
|
||
if (month <= 6 && day > 31) {
|
||
return false;
|
||
} else if (month > 6 && month < 12 && day > 30) {
|
||
return false;
|
||
} else if (month === 12) {
|
||
|
||
switch (year) {
|
||
case 1346:
|
||
kabiseh = true;
|
||
break;
|
||
case 1350:
|
||
kabiseh = true;
|
||
break;
|
||
case 1354:
|
||
kabiseh = true;
|
||
break;
|
||
case 1358:
|
||
kabiseh = true;
|
||
break;
|
||
case 1362:
|
||
kabiseh = true;
|
||
break;
|
||
case 1366:
|
||
kabiseh = true;
|
||
break;
|
||
case 1370:
|
||
kabiseh = true;
|
||
break;
|
||
case 1375:
|
||
kabiseh = true;
|
||
break;
|
||
case 1379:
|
||
kabiseh = true;
|
||
break;
|
||
case 1383:
|
||
kabiseh = true;
|
||
break;
|
||
case 1387:
|
||
kabiseh = true;
|
||
break;
|
||
case 1391:
|
||
kabiseh = true;
|
||
break;
|
||
case 1395:
|
||
kabiseh = true;
|
||
break;
|
||
case 1399:
|
||
kabiseh = true;
|
||
break;
|
||
case 1403:
|
||
kabiseh = true;
|
||
break;
|
||
case 1408:
|
||
kabiseh = true;
|
||
break;
|
||
case 1412:
|
||
kabiseh = true;
|
||
break;
|
||
case 1416:
|
||
kabiseh = true;
|
||
break;
|
||
case 1420:
|
||
kabiseh = true;
|
||
break;
|
||
case 1424:
|
||
kabiseh = true;
|
||
break;
|
||
case 1428:
|
||
kabiseh = true;
|
||
break;
|
||
case 1432:
|
||
kabiseh = true;
|
||
break;
|
||
case 1436:
|
||
kabiseh = true;
|
||
break;
|
||
case 1441:
|
||
kabiseh = true;
|
||
break;
|
||
case 1445:
|
||
kabiseh = true;
|
||
break;
|
||
default:
|
||
kabiseh = false;
|
||
|
||
}
|
||
if (kabiseh == true && day > 30) {
|
||
return false;
|
||
} else if (kabiseh == false && day > 29) {
|
||
return false;
|
||
} else {
|
||
return true;
|
||
}
|
||
} else {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
$('input:radio[name="PaidLeaveType"]').change(function () {
|
||
if ($(this).is(':checked') && $(this).val() === 'روزانه') {
|
||
$("#hours").val('');
|
||
$("#hours").attr("disabled", "disabled");
|
||
$("#endLeave").removeAttr("disabled");
|
||
$('.endLeaveLabal').show();
|
||
$('#StartHoures').removeClass("invalidTime");
|
||
$('#StartHoures').val('');
|
||
$('#EndHours').removeClass("invalidTime");
|
||
$('#EndHours').val('');
|
||
$("#endLeave").show();
|
||
$('.res').remove();
|
||
$('.validTime').removeClass("validTime");
|
||
$('.sumHourseDiv').hide();
|
||
$('.sumDaysDiv').show();
|
||
} else if ($(this).is(':checked') && $(this).val() === 'ساعتی') {
|
||
$("#endLeave").val('');
|
||
$("#endLeave").attr("disabled", "disabled");
|
||
$("#endLeave").hide();
|
||
$('.endLeaveLabal').hide();
|
||
$("#hours").removeAttr("disabled");
|
||
$('.sumHourseDiv').show();
|
||
$('.sumDaysDiv').hide();
|
||
}
|
||
});
|
||
/////////////////Time Input Validatet/////////////////
|
||
|
||
$(".dateTime").each(function () {
|
||
let element = $(this);
|
||
element.on('input', function () {
|
||
let value = convertPersianNumbersToEnglish(element.val());
|
||
element.val(value);
|
||
});
|
||
|
||
new Cleave(this, {
|
||
time: true,
|
||
timePattern: ['h', 'm']
|
||
});
|
||
});
|
||
|
||
$("#StartHoures, #EndHours").on("keyup", validateTimeOrder);
|
||
function parseTimeToMinutes(time) {
|
||
const [hours, minutes] = time.split(':').map(Number);
|
||
return hours * 60 + minutes;
|
||
}
|
||
|
||
function validateTimeOrder() {
|
||
const startTime = $("#StartHoures").val();
|
||
const endTime = $("#EndHours").val();
|
||
|
||
if (startTime && endTime) {
|
||
const startMinutes = parseTimeToMinutes(startTime);
|
||
const endMinutes = parseTimeToMinutes(endTime);
|
||
|
||
if (startMinutes >= endMinutes) {
|
||
$('.alert-msg').show();
|
||
$('.alert-msg p').text('ساعت شروع و پایان نامعتبر است');
|
||
|
||
$("#StartHoures, #EndHours").addClass("invalidTime").removeClass("validTime");
|
||
|
||
return false;
|
||
} else {
|
||
$('.alert-msg').hide();
|
||
$('.alert-msg p').text('');
|
||
|
||
$("#StartHoures, #EndHours").addClass("validTime").removeClass("invalidTime");
|
||
|
||
}
|
||
|
||
if ($("#StartHoures").val().length === 5 && $("#EndHours").val().length === 5) {
|
||
computeHourse();
|
||
}
|
||
} else {
|
||
$('.alert-msg').hide();
|
||
$('.alert-msg p').text('');
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
//$('#StartHoures').on("keyup",
|
||
// function () {
|
||
// var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val());
|
||
// if (isValid) {
|
||
// $(this).addClass("validTime");
|
||
// $(this).removeClass("invalidTime");
|
||
// if ($('#EndHours').hasClass('validTime') && $('#EndHours').val() != null) {
|
||
// computeHourse();
|
||
// }
|
||
// } else {
|
||
// $(this).removeClass("validTime");
|
||
// $(this).addClass("invalidTime");
|
||
// }
|
||
// });
|
||
//$('#EndHours').on("keyup",
|
||
// function () {
|
||
// var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test($(this).val());
|
||
// if (isValid) {
|
||
// $(this).addClass("validTime");
|
||
// $(this).removeClass("invalidTime");
|
||
// if ($('#StartHoures').hasClass('validTime') && $('#StartHoures').val() != null) {
|
||
// computeHourse();
|
||
// }
|
||
// } else {
|
||
// $(this).removeClass("validTime");
|
||
// $(this).addClass("invalidTime");
|
||
// }
|
||
// });
|
||
|
||
function computeHourse() {
|
||
$('.res').remove();
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'GET',
|
||
url: computeLeaveHourlyAjax,
|
||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||
data: { "startHours": $('#StartHoures').val(), "endHours": $('#EndHours').val() },
|
||
success: function (response) {
|
||
let res = `<span class="res">${response.res}</span>`;
|
||
$('.sumHours').append(res);
|
||
},
|
||
failure: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
}
|
||
|
||
function computeDays() {
|
||
$('.resultDays').remove();
|
||
$.ajax({
|
||
async: false,
|
||
dataType: 'json',
|
||
type: 'GET',
|
||
url: computeLeaveDailyAjax,
|
||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||
data: { "startDay": $('#StartLeave').val(), "endDay": $('#EndLeave').val() },
|
||
success: function (response) {
|
||
if (response.status == false) {
|
||
$('.sumDays').addClass("note");
|
||
} else {
|
||
$('.sumDays').removeClass("note");
|
||
}
|
||
let res = `<span class="resultDays">${response.res}</span>`;
|
||
$('.sumDays').append(res);
|
||
},
|
||
failure: function (response) {
|
||
console.log(5, response);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
$(document).ready(function () {
|
||
$("#cardSectionLeave div *").prop('disabled', true);
|
||
|
||
ajaxPersonals();
|
||
// Fetch workshops on page load
|
||
// $.ajax({
|
||
// url: '@Url.Page("/Index", "WorkshopList")',
|
||
// type: 'GET',
|
||
// success: function (response) {
|
||
// var workshops = response.workshops;
|
||
// var workshopOptionsHtml = '';
|
||
// if (workshops.length != 1) {
|
||
// workshopOptionsHtml += '<option value="">انتخاب کارگاه ...</option>';
|
||
// }
|
||
// workshops.forEach(function (workshop) {
|
||
// workshopOptionsHtml += '<option value="' + workshop.id + '">' + workshop.workshopFullName + '</option>';
|
||
// });
|
||
// $('#workshopSelect').html(workshopOptionsHtml);
|
||
// if (workshops.length == 1) {
|
||
// ajaxPersonals(workshops[0].id);
|
||
// }
|
||
// },
|
||
// error: function (xhr, status, error) {
|
||
// console.error(xhr.responseText);
|
||
// }
|
||
// });
|
||
|
||
// Handle workshop selection
|
||
// $('#workshopSelect').change(function () {
|
||
// var workshopId = $(this).val();
|
||
// if (workshopId) {
|
||
// ajaxPersonals(workshopId);
|
||
// }
|
||
// });
|
||
|
||
var selectEmployeeValue = $('#employeeSelect').val();
|
||
if (selectEmployeeValue == '') {
|
||
$('#cardSectionLeave').addClass('blur');
|
||
$("#cardSectionLeave div *").prop('disabled', true);
|
||
}
|
||
|
||
var selectWorkshopValue = $('#workshopSelect').val();
|
||
if (selectWorkshopValue == '') {
|
||
$('#cardSectionLeave').addClass('blur');
|
||
$("#cardSectionLeave div *").prop('disabled', true);
|
||
}
|
||
|
||
$('#employeeSelect').change(function () {
|
||
var selectValue = $('#employeeSelect').val();
|
||
|
||
if (selectValue == '') {
|
||
$('#cardSectionLeave').addClass('blur');
|
||
$("#cardSectionLeave div *").prop('disabled', true);
|
||
} else {
|
||
$('#cardSectionLeave').removeClass('blur');
|
||
$("#cardSectionLeave div *").prop('disabled', false);
|
||
$('#descriptionAcceptedCheck').attr('disabled', true);
|
||
}
|
||
});
|
||
|
||
// $('#workshopSelect').change(function () {
|
||
// var selectValue = $('#workshopSelect').val();
|
||
|
||
// if (selectValue == '') {
|
||
// var employeeOptionsHtmlEmpty = `<option value="" > ابتدا کارگاه را انتخاب کنید ...</option>`;
|
||
// $('#employeeSelect').html(employeeOptionsHtmlEmpty);
|
||
// $('#cardSectionLeave').addClass('blur');
|
||
// $("#cardSectionLeave div *").prop('disabled', true);
|
||
// }
|
||
// });
|
||
});
|
||
|
||
function ajaxPersonals() {
|
||
$.ajax({
|
||
url: employeeListAjax,
|
||
type: 'GET',
|
||
success: function (response) {
|
||
$('#cardSectionLeave').addClass('blur');
|
||
$("#cardSectionLeave div *").prop('disabled', true);
|
||
var employees = response.employees.connectedPersonnelViewModels;
|
||
var employeeOptionsHtml = '<option value="">انتخاب پرسنل ...</option>';
|
||
employees.forEach(function (employee) {
|
||
var black = employee.black ? "blackSelect" : "";
|
||
employeeOptionsHtml += `<option class="${black}" value="${employee.id}">${employee.employeeFullName}</option>`;
|
||
});
|
||
$('#employeeSelect').html(employeeOptionsHtml);
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
}
|
||
});
|
||
}
|
||
|
||
function rotatingShift(startDateValue) {
|
||
|
||
ajaxService.get(hasRotatingShiftAjax, { employeeId: currentEmployeeId, startDateTime: startDateValue })
|
||
.then(response => {
|
||
$('#HasRollCall').val(response.hasRollCall);
|
||
|
||
if (response.hasRollCall) {
|
||
$('#rotatingShiftSection').show();
|
||
|
||
var shiftsList = response.shifts;
|
||
var shiftsOptionsHtml = '<option selected disabled>انتخاب شیفت ...</option>';
|
||
|
||
shiftsList.forEach(function (item) {
|
||
shiftsOptionsHtml += `<option value="${item.startTime}|${item.endTime}">${item.startTime} الی ${item.endTime}</option>`;
|
||
});
|
||
$('#rotatingShift').html(shiftsOptionsHtml);
|
||
} else {
|
||
$('#rotatingShiftSection').hide();
|
||
|
||
if (response.message) {
|
||
$('#StartLeave').addClass('errored');
|
||
$('.alert-msg').show();
|
||
$('.alert-msg p').text(response.message);
|
||
setTimeout(function () {
|
||
$('.alert-msg').hide();
|
||
$('.alert-msg p').text("");
|
||
$('#StartLeave').removeClass("errored");
|
||
}, 3500);
|
||
}
|
||
}
|
||
});
|
||
|
||
} |