[UPDT] HORILLA: Refactor html files to use Django i18n gettext in js
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -11,37 +11,6 @@ class DateFormattingUtility {
|
||||
}
|
||||
|
||||
getFormattedDate(date) {
|
||||
|
||||
// getCurrentLanguageCode(function (code) {
|
||||
// languageCode = code;
|
||||
// });
|
||||
|
||||
// // console.log("CODE>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
|
||||
// // console.log(languageCode)
|
||||
|
||||
// if (languageCode == 'en'){
|
||||
// // Set locale to English
|
||||
// moment.locale('en');
|
||||
// }
|
||||
// else if(languageCode == 'de'){
|
||||
// // Set locale to German
|
||||
// moment.locale('de');
|
||||
// }
|
||||
// else if(languageCode == 'es'){
|
||||
// // Set locale to Spanish
|
||||
// moment.locale('es');
|
||||
// }
|
||||
// else if(languageCode == 'fr'){
|
||||
// // Set locale to French
|
||||
// moment.locale('fr');
|
||||
// }
|
||||
// else if(languageCode == 'ar'){
|
||||
// // Set locale to Arabic
|
||||
// moment.locale('ar');
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// var specificDate = date; // Your specific date in YYYY-MM-DD format
|
||||
// var now = moment(specificDate);
|
||||
// // console.log('LANGUAGAE DATE')
|
||||
|
||||
@@ -1,454 +1,325 @@
|
||||
|
||||
|
||||
var excelMessages = {
|
||||
ar: "هل ترغب في تنزيل ملف Excel؟",
|
||||
de: "Möchten Sie die Excel-Datei herunterladen?",
|
||||
es: "¿Desea descargar el archivo de Excel?",
|
||||
en: "Do you want to download the excel file?",
|
||||
fr: "Voulez-vous télécharger le fichier Excel?",
|
||||
};
|
||||
|
||||
var archiveMessages = {
|
||||
ar: "هل ترغب حقًا في أرشفة كل الحضور المحدد؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Anwesenheiten archivieren?",
|
||||
es: "Realmente quieres archivar todas las asistencias seleccionadas?",
|
||||
en: "Do you really want to archive all the selected requests?",
|
||||
fr: "Voulez-vous vraiment archiver toutes les présences sélectionnées?",
|
||||
};
|
||||
|
||||
var unarchiveMessages = {
|
||||
ar: "هل ترغب حقًا في إلغاء أرشفة كل الحضور المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten archivierten Zuweisungen wiederherstellen?",
|
||||
es: "Realmente quieres desarchivar todas las asignaciones seleccionadas?",
|
||||
en: "Do you really want to un-archive all the selected requests?",
|
||||
fr: "Voulez-vous vraiment désarchiver toutes les allocations sélectionnées?",
|
||||
};
|
||||
|
||||
var shiftDeleteRequestMessages = {
|
||||
ar: "هل ترغب حقًا في حذف كل الحجوزات المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Zuweisungen löschen?",
|
||||
es: "Realmente quieres eliminar todas las asignaciones seleccionadas?",
|
||||
en: "Do you really want to delete all the selected requests?",
|
||||
fr: "Voulez-vous vraiment supprimer toutes les allocations sélectionnées?",
|
||||
};
|
||||
|
||||
var approveMessages = {
|
||||
ar: "هل ترغب حقًا في الموافقة على جميع الطلبات المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Anfragen genehmigen?",
|
||||
es: "Realmente quieres aprobar todas las solicitudes seleccionadas?",
|
||||
en: "Do you really want to approve all the selected requests?",
|
||||
fr: "Voulez-vous vraiment approuver toutes les demandes sélectionnées?",
|
||||
};
|
||||
var rejectMessages = {
|
||||
ar: "هل تريد حقًا رفض جميع الطلبات المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Anfragen ablehnen?",
|
||||
es: "¿Realmente deseas rechazar todas las solicitudes seleccionadas?",
|
||||
en: "Do you really want to reject all the selected requests?",
|
||||
fr: "Voulez-vous vraiment rejeter toutes les demandes sélectionnées?",
|
||||
};
|
||||
var requestDeleteMessages = {
|
||||
ar: "هل ترغب حقًا في حذف جميع الطلبات المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Anfragen löschen?",
|
||||
es: "Realmente quieres eliminar todas las solicitudes seleccionadas?",
|
||||
en: "Do you really want to delete all the selected requests?",
|
||||
fr: "Voulez-vous vraiment supprimer toutes les demandes sélectionnées?",
|
||||
};
|
||||
var norowMessagesShift = {
|
||||
ar: "لم يتم تحديد أي صفوف.",
|
||||
de: "Es wurden keine Zeilen ausgewählt.",
|
||||
es: "No se han seleccionado filas.",
|
||||
en: "No rows have been selected.",
|
||||
fr: "Aucune ligne n'a été sélectionnée.",
|
||||
};
|
||||
var rowMessages = {
|
||||
ar: " تم الاختيار",
|
||||
de: " Ausgewählt",
|
||||
es: " Seleccionado",
|
||||
en: " Selected",
|
||||
fr: " Sélectionné",
|
||||
};
|
||||
|
||||
tickShiftCheckboxes();
|
||||
function makeShiftListUnique(list) {
|
||||
tickShiftCheckboxes();
|
||||
function makeShiftListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
}
|
||||
|
||||
tickWorktypeCheckboxes();
|
||||
function makeWorktypeListUnique(list) {
|
||||
tickWorktypeCheckboxes();
|
||||
function makeWorktypeListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
}
|
||||
|
||||
tickRShiftCheckboxes();
|
||||
function makeRShiftListUnique(list) {
|
||||
tickRShiftCheckboxes();
|
||||
function makeRShiftListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
}
|
||||
|
||||
tickRWorktypeCheckboxes();
|
||||
function makeRWorktypeListUnique(list) {
|
||||
tickRWorktypeCheckboxes();
|
||||
function makeRWorktypeListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
function getCookie(name) {
|
||||
let cookieValue = null;
|
||||
if (document.cookie && document.cookie !== "") {
|
||||
const cookies = document.cookie.split(";");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
const cookie = cookies[i].trim();
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) === name + "=") {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
const cookies = document.cookie.split(";");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
const cookie = cookies[i].trim();
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) === name + "=") {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
|
||||
function getCurrentLanguageCode(callback) {
|
||||
var languageCode = $("#main-section-data").attr("data-lang");
|
||||
var allowedLanguageCodes = ["ar", "de", "es", "en", "fr"];
|
||||
if (allowedLanguageCodes.includes(languageCode)) {
|
||||
callback(languageCode);
|
||||
} else {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/employee/get-language-code/",
|
||||
success: function (response) {
|
||||
var ajaxLanguageCode = response.language_code;
|
||||
$("#main-section-data").attr("data-lang", ajaxLanguageCode);
|
||||
callback(
|
||||
allowedLanguageCodes.includes(ajaxLanguageCode)
|
||||
? ajaxLanguageCode
|
||||
: "en"
|
||||
);
|
||||
},
|
||||
error: function () {
|
||||
callback("en");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function shiftRequestApprove() {
|
||||
}
|
||||
|
||||
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = approveMessages[languageCode];
|
||||
var textMessage = norowMessagesShift[languageCode];
|
||||
ids = [];
|
||||
// function addIdsTab(tabId){
|
||||
// var dataIds = $("#"+tabId).attr("data-ids");
|
||||
// if (dataIds){
|
||||
// ids = ids.concat(JSON.parse(dataIds));
|
||||
// }
|
||||
// }
|
||||
// addIdsTab("shiftselectedInstances");
|
||||
// addIdsTab("allocatedselectedInstances");
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
function shiftRequestApprove() {
|
||||
|
||||
|
||||
|
||||
ids = [];
|
||||
// function addIdsTab(tabId){
|
||||
// var dataIds = $("#"+tabId).attr("data-ids");
|
||||
// if (dataIds){
|
||||
// ids = ids.concat(JSON.parse(dataIds));
|
||||
// }
|
||||
// }
|
||||
// addIdsTab("shiftselectedInstances");
|
||||
// addIdsTab("allocatedselectedInstances");
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
// Use SweetAlert for the confirmation dialog
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "success",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.confirmBulkApprove,
|
||||
icon: "success",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
// ids = [];
|
||||
// ids.push($("#selectedInstances").attr("data-ids"));
|
||||
// ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/shift-request-bulk-approve",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if (result.isConfirmed) {
|
||||
// ids = [];
|
||||
// ids.push($("#selectedInstances").attr("data-ids"));
|
||||
// ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/shift-request-bulk-approve",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function shiftRequestReject() {
|
||||
|
||||
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = rejectMessages[languageCode];
|
||||
var textMessage = norowMessagesShift[languageCode];
|
||||
ids = [];
|
||||
// function addIdsTab(tabId){
|
||||
// var dataIds = $("#"+tabId).attr("data-ids");
|
||||
// if (dataIds){
|
||||
// ids = ids.concat(JSON.parse(dataIds));
|
||||
// }
|
||||
// }
|
||||
// addIdsTab("shiftselectedInstances");
|
||||
// addIdsTab("allocatedselectedInstances");
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
function shiftRequestReject() {
|
||||
ids = [];
|
||||
// function addIdsTab(tabId){
|
||||
// var dataIds = $("#"+tabId).attr("data-ids");
|
||||
// if (dataIds){
|
||||
// ids = ids.concat(JSON.parse(dataIds));
|
||||
// }
|
||||
// }
|
||||
// addIdsTab("shiftselectedInstances");
|
||||
// addIdsTab("allocatedselectedInstances");
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.confirmBulkReject,
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/shift-request-bulk-cancel",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/shift-request-bulk-cancel",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function shiftRequestDelete() {
|
||||
|
||||
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = shiftDeleteRequestMessages[languageCode];
|
||||
var textMessage = norowMessagesShift[languageCode];
|
||||
ids = [];
|
||||
// function addIdsTab(tabId){
|
||||
// var dataIds = $("#"+tabId).attr("data-ids");
|
||||
// if (dataIds){
|
||||
// ids = ids.concat(JSON.parse(dataIds));
|
||||
// }
|
||||
// }
|
||||
// addIdsTab("shiftselectedInstances");
|
||||
// addIdsTab("allocatedselectedInstances");
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
function shiftRequestDelete() {
|
||||
ids = [];
|
||||
// function addIdsTab(tabId){
|
||||
// var dataIds = $("#"+tabId).attr("data-ids");
|
||||
// if (dataIds){
|
||||
// ids = ids.concat(JSON.parse(dataIds));
|
||||
// }
|
||||
// }
|
||||
// addIdsTab("shiftselectedInstances");
|
||||
// addIdsTab("allocatedselectedInstances");
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
console.log(ids)
|
||||
console.log('__________________________________________________________________________')
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.confirmBulkDelete,
|
||||
icon: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/shift-request-bulk-delete",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/shift-request-bulk-delete",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function archiveRotateShift() {
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = archiveMessages[languageCode];
|
||||
var textMessage = norowMessages[languageCode];
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
function archiveRotateShift() {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.confirmBulkArchive,
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-shift-assign-bulk-archive?is_active=False",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-shift-assign-bulk-archive?is_active=False",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
function un_archiveRotateShift() {
|
||||
|
||||
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = unarchiveMessages[languageCode];
|
||||
var textMessage = norowMessages[languageCode];
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
function un_archiveRotateShift() {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.confirmBulkUnArchive,
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-shift-assign-bulk-archive?is_active=True",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-shift-assign-bulk-archive?is_active=True",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
function deleteRotatingShift() {
|
||||
|
||||
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = shiftDeleteRequestMessages[languageCode];
|
||||
var textMessage = norowMessages[languageCode];
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
function deleteRotatingShift() {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.confirmBulkDelete,
|
||||
icon: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-shift-assign-bulk-delete",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-shift-assign-bulk-delete",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,432 +1,306 @@
|
||||
var excelMessages = {
|
||||
ar: "هل ترغب في تنزيل ملف Excel؟",
|
||||
de: "Möchten Sie die Excel-Datei herunterladen?",
|
||||
es: "¿Desea descargar el archivo de Excel?",
|
||||
en: "Do you want to download the excel file?",
|
||||
fr: "Voulez-vous télécharger le fichier Excel?",
|
||||
};
|
||||
|
||||
var archiveMessages = {
|
||||
ar: "هل ترغب حقًا في أرشفة كل الحضور المحدد؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Anwesenheiten archivieren?",
|
||||
es: "Realmente quieres archivar todas las asistencias seleccionadas?",
|
||||
en: "Do you really want to archive all the selected allocations?",
|
||||
fr: "Voulez-vous vraiment archiver toutes les présences sélectionnées?",
|
||||
};
|
||||
|
||||
var unarchiveMessages = {
|
||||
ar: "هل ترغب حقًا في إلغاء أرشفة كل الحضور المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten archivierten Zuweisungen wiederherstellen?",
|
||||
es: "Realmente quieres desarchivar todas las asignaciones seleccionadas?",
|
||||
en: "Do you really want to un-archive all the selected allocations?",
|
||||
fr: "Voulez-vous vraiment désarchiver toutes les allocations sélectionnées?",
|
||||
};
|
||||
|
||||
var rotatedeleteRequestMessages = {
|
||||
ar: "هل ترغب حقًا في حذف كل الحجوزات المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Zuweisungen löschen?",
|
||||
es: "Realmente quieres eliminar todas las asignaciones seleccionadas?",
|
||||
en: "Do you really want to delete all the selected Requests?",
|
||||
fr: "Voulez-vous vraiment supprimer toutes les allocations sélectionnées?",
|
||||
};
|
||||
|
||||
var approveMessages = {
|
||||
ar: "هل ترغب حقًا في الموافقة على جميع الطلبات المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Anfragen genehmigen?",
|
||||
es: "Realmente quieres aprobar todas las solicitudes seleccionadas?",
|
||||
en: "Do you really want to approve all the selected requests?",
|
||||
fr: "Voulez-vous vraiment approuver toutes les demandes sélectionnées?",
|
||||
};
|
||||
var rejectMessages = {
|
||||
ar: "هل تريد حقًا رفض جميع الطلبات المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Anfragen ablehnen?",
|
||||
es: "¿Realmente deseas rechazar todas las solicitudes seleccionadas?",
|
||||
en: "Do you really want to reject all the selected requests?",
|
||||
fr: "Voulez-vous vraiment rejeter toutes les demandes sélectionnées?",
|
||||
};
|
||||
var requestDeleteMessages = {
|
||||
ar: "هل ترغب حقًا في حذف جميع الطلبات المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Anfragen löschen?",
|
||||
es: "Realmente quieres eliminar todas las solicitudes seleccionadas?",
|
||||
en: "Do you really want to delete all the selected requests?",
|
||||
fr: "Voulez-vous vraiment supprimer toutes les demandes sélectionnées?",
|
||||
};
|
||||
var norowMessages = {
|
||||
ar: "لم يتم تحديد أي صفوف.",
|
||||
de: "Es wurden keine Zeilen ausgewählt.",
|
||||
es: "No se han seleccionado filas.",
|
||||
en: "No rows have been selected.",
|
||||
fr: "Aucune ligne n'a été sélectionnée.",
|
||||
};
|
||||
var rowMessages = {
|
||||
ar: " تم الاختيار",
|
||||
de: " Ausgewählt",
|
||||
es: " Seleccionado",
|
||||
en: " Selected",
|
||||
fr: " Sélectionné",
|
||||
};
|
||||
|
||||
tickShiftCheckboxes();
|
||||
function makeShiftListUnique(list) {
|
||||
tickShiftCheckboxes();
|
||||
function makeShiftListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
}
|
||||
|
||||
tickWorktypeCheckboxes();
|
||||
function makeWorktypeListUnique(list) {
|
||||
tickWorktypeCheckboxes();
|
||||
function makeWorktypeListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
}
|
||||
|
||||
tickRShiftCheckboxes();
|
||||
function makeRShiftListUnique(list) {
|
||||
tickRShiftCheckboxes();
|
||||
function makeRShiftListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
}
|
||||
|
||||
tickRWorktypeCheckboxes();
|
||||
function makeRWorktypeListUnique(list) {
|
||||
tickRWorktypeCheckboxes();
|
||||
function makeRWorktypeListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
function getCookie(name) {
|
||||
let cookieValue = null;
|
||||
if (document.cookie && document.cookie !== "") {
|
||||
const cookies = document.cookie.split(";");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
const cookie = cookies[i].trim();
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) === name + "=") {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
const cookies = document.cookie.split(";");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
const cookie = cookies[i].trim();
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) === name + "=") {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
|
||||
function getCurrentLanguageCode(callback) {
|
||||
var languageCode = $("#main-section-data").attr("data-lang");
|
||||
var allowedLanguageCodes = ["ar", "de", "es", "en", "fr"];
|
||||
if (allowedLanguageCodes.includes(languageCode)) {
|
||||
callback(languageCode);
|
||||
} else {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/employee/get-language-code/",
|
||||
success: function (response) {
|
||||
var ajaxLanguageCode = response.language_code;
|
||||
$("#main-section-data").attr("data-lang", ajaxLanguageCode);
|
||||
callback(
|
||||
allowedLanguageCodes.includes(ajaxLanguageCode)
|
||||
? ajaxLanguageCode
|
||||
: "en"
|
||||
);
|
||||
},
|
||||
error: function () {
|
||||
callback("en");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function handleApproveRequestsClick() {
|
||||
// e.preventDefault();
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = approveMessages[languageCode];
|
||||
var textMessage = norowMessages[languageCode];
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "success",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/work-type-request-bulk-approve",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function handleRejectRequestsClick() {
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = rejectMessages[languageCode];
|
||||
var textMessage = norowMessages[languageCode];
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
console.log("hello")
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/work-type-request-bulk-cancel",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function handleDeleteRequestsClick() {
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = rotatedeleteRequestMessages[languageCode];
|
||||
var textMessage = norowMessages[languageCode];
|
||||
function handleApproveRequestsClick() {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
});
|
||||
Swal.fire({
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/work-type-request-bulk-delete",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
Swal.fire({
|
||||
text: i18nMessages.confirmBulkApprove,
|
||||
icon: "success",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/work-type-request-bulk-approve",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//scripts for rotating work type page
|
||||
//bulk archive in rotate work type
|
||||
$(document).on('click', '#archiveWorkRotateNav', function(e) {
|
||||
|
||||
function handleRejectRequestsClick() {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: i18nMessages.confirmBulkReject,
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
console.log("hello")
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/work-type-request-bulk-cancel",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function handleDeleteRequestsClick() {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: i18nMessages.confirmBulkDelete,
|
||||
icon: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/work-type-request-bulk-delete",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//scripts for rotating work type page
|
||||
//bulk archive in rotate work type
|
||||
$(document).on('click', '#archiveWorkRotateNav', function (e) {
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = archiveMessages[languageCode];
|
||||
var textMessage = norowMessages[languageCode];
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.confirmBulkArchive,
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-work-type-assign-bulk-archive?is_active=False",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-work-type-assign-bulk-archive?is_active=False",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function UnarchiveWorkRotateNav() {
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = unarchiveMessages[languageCode];
|
||||
var textMessage = norowMessages[languageCode];
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
function UnarchiveWorkRotateNav() {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.confirmBulkUnArchive,
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-work-type-assign-bulk-archive?is_active=True",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-work-type-assign-bulk-archive?is_active=True",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deleteWorkRotateNav() {
|
||||
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = rotatedeleteRequestMessages[languageCode];
|
||||
var textMessage = norowMessages[languageCode];
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
function deleteWorkRotateNav() {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.confirmBulkDelete,
|
||||
icon: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-work-type-assign-bulk-delete",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/rotating-work-type-assign-bulk-delete",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload(); // Reload the current page
|
||||
} else {
|
||||
// console.log("Unexpected HTTP status:", jqXHR.status);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,368 +1,289 @@
|
||||
var rowMessages = {
|
||||
ar: " تم الاختيار",
|
||||
de: " Ausgewählt",
|
||||
es: " Seleccionado",
|
||||
en: " Selected",
|
||||
fr: " Sélectionné",
|
||||
};
|
||||
|
||||
var excelMessages = {
|
||||
ar: "هل ترغب في تنزيل ملف Excel؟",
|
||||
de: "Möchten Sie die Excel-Datei herunterladen?",
|
||||
es: "¿Desea descargar el archivo de Excel?",
|
||||
en: "Do you want to download the excel file?",
|
||||
fr: "Voulez-vous télécharger le fichier Excel?",
|
||||
};
|
||||
|
||||
var deleteHolidayMessages = {
|
||||
ar: "هل تريد حقًا حذف جميع العطل المحددة؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Feiertage löschen?",
|
||||
es: "¿Realmente quieres eliminar todas las vacaciones seleccionadas?",
|
||||
en: "Do you really want to delete all the selected holidays?",
|
||||
fr: "Voulez-vous vraiment supprimer toutes les vacances sélectionnées?",
|
||||
};
|
||||
|
||||
var no_rows_deleteMessages = {
|
||||
ar: "لم تتم تحديد صفوف لحذف العطلات.",
|
||||
de: "Es wurden keine Zeilen zum Löschen von Feiertagen ausgewählt.",
|
||||
es: "No se han seleccionado filas para eliminar las vacaciones.",
|
||||
en: "No rows are selected for deleting holidays.",
|
||||
fr: "Aucune ligne n'a été sélectionnée pour supprimer les vacances.",
|
||||
};
|
||||
var downloadMessages = {
|
||||
ar: "هل ترغب في تنزيل القالب؟",
|
||||
de: "Möchten Sie die Vorlage herunterladen?",
|
||||
es: "¿Quieres descargar la plantilla?",
|
||||
en: "Do you want to download the template?",
|
||||
fr: "Voulez-vous télécharger le modèle ?",
|
||||
};
|
||||
function makeListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
|
||||
tickHolidayCheckboxes();
|
||||
function makeHolidayListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
|
||||
function getCurrentLanguageCode(callback) {
|
||||
var languageCode = $("#main-section-data").attr("data-lang");
|
||||
var allowedLanguageCodes = ["ar", "de", "es", "en", "fr"];
|
||||
if (allowedLanguageCodes.includes(languageCode)) {
|
||||
callback(languageCode);
|
||||
} else {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/employee/get-language-code/",
|
||||
success: function (response) {
|
||||
var ajaxLanguageCode = response.language_code;
|
||||
$("#main-section-data").attr("data-lang", ajaxLanguageCode);
|
||||
callback(
|
||||
allowedLanguageCodes.includes(ajaxLanguageCode)
|
||||
? ajaxLanguageCode
|
||||
: "en"
|
||||
);
|
||||
},
|
||||
error: function () {
|
||||
callback("en");
|
||||
},
|
||||
});
|
||||
}
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
|
||||
function tickHolidayCheckboxes() {
|
||||
var ids = JSON.parse($("#selectedHolidays").attr("data-ids") || "[]");
|
||||
uniqueIds = makeHolidayListUnique(ids);
|
||||
toggleHighlight(uniqueIds);
|
||||
click = $("#selectedHolidays").attr("data-clicked");
|
||||
if (click === "1") {
|
||||
$(".all-holidays").prop("checked", true);
|
||||
}
|
||||
uniqueIds.forEach(function (id) {
|
||||
$("#" + id).prop("checked", true);
|
||||
});
|
||||
var selectedCount = uniqueIds.length;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var message = rowMessages[languageCode];
|
||||
if (selectedCount > 0) {
|
||||
$("#unselectAllHolidays").css("display", "inline-flex");
|
||||
$("#exportHolidays").css("display", "inline-flex");
|
||||
$("#selectedShowHolidays").css("display", "inline-flex");
|
||||
$("#selectedShowHolidays").text(selectedCount + " -" + message);
|
||||
} else {
|
||||
$("#unselectAllHolidays").css("display", "none");
|
||||
$("#selectedShowHolidays").css("display", "none");
|
||||
$("#exportHolidays").css("display", "none");
|
||||
var ids = JSON.parse($("#selectedHolidays").attr("data-ids") || "[]");
|
||||
uniqueIds = makeHolidayListUnique(ids);
|
||||
toggleHighlight(uniqueIds);
|
||||
click = $("#selectedHolidays").attr("data-clicked");
|
||||
if (click === "1") {
|
||||
$(".all-holidays").prop("checked", true);
|
||||
}
|
||||
uniqueIds.forEach(function (id) {
|
||||
$("#" + id).prop("checked", true);
|
||||
});
|
||||
|
||||
var selectedCount = uniqueIds.length;
|
||||
if (selectedCount > 0) {
|
||||
$("#unselectAllHolidays").css("display", "inline-flex");
|
||||
$("#exportHolidays").css("display", "inline-flex");
|
||||
$("#selectedShowHolidays").css("display", "inline-flex");
|
||||
$("#selectedShowHolidays").text(selectedCount + " -" + i18nMessages.selected);
|
||||
} else {
|
||||
$("#unselectAllHolidays").css("display", "none");
|
||||
$("#selectedShowHolidays").css("display", "none");
|
||||
$("#exportHolidays").css("display", "none");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addingHolidayIds() {
|
||||
var ids = JSON.parse($("#selectedHolidays").attr("data-ids") || "[]");
|
||||
var selectedCount = 0;
|
||||
var ids = JSON.parse($("#selectedHolidays").attr("data-ids") || "[]");
|
||||
var selectedCount = 0;
|
||||
|
||||
$(".all-holidays-row").each(function () {
|
||||
if ($(this).is(":checked")) {
|
||||
ids.push(this.id);
|
||||
} else {
|
||||
var index = ids.indexOf(this.id);
|
||||
if (index > -1) {
|
||||
ids.splice(index, 1);
|
||||
$(".all-holidays").prop("checked", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
$(".all-holidays-row").each(function () {
|
||||
if ($(this).is(":checked")) {
|
||||
ids.push(this.id);
|
||||
} else {
|
||||
var index = ids.indexOf(this.id);
|
||||
if (index > -1) {
|
||||
ids.splice(index, 1);
|
||||
$(".all-holidays").prop("checked", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ids = makeHolidayListUnique(ids);
|
||||
toggleHighlight(ids);
|
||||
selectedCount = ids.length;
|
||||
ids = makeHolidayListUnique(ids);
|
||||
toggleHighlight(ids);
|
||||
selectedCount = ids.length;
|
||||
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var message = rowMessages[languageCode];
|
||||
$("#selectedHolidays").attr("data-ids", JSON.stringify(ids));
|
||||
if (selectedCount === 0) {
|
||||
$("#selectedShowHolidays").css("display", "none");
|
||||
$("#exportHolidays").css("display", "none");
|
||||
$('#unselectAllHolidays').css("display", "none");
|
||||
$("#selectedShowHolidays").css("display", "none");
|
||||
$("#exportHolidays").css("display", "none");
|
||||
$('#unselectAllHolidays').css("display", "none");
|
||||
} else {
|
||||
$("#unselectAllHolidays").css("display", "inline-flex");
|
||||
$("#exportHolidays").css("display", "inline-flex");
|
||||
$("#selectedShowHolidays").css("display", "inline-flex");
|
||||
$("#selectedShowHolidays").text(selectedCount + " - " + message);
|
||||
$("#unselectAllHolidays").css("display", "inline-flex");
|
||||
$("#exportHolidays").css("display", "inline-flex");
|
||||
$("#selectedShowHolidays").css("display", "inline-flex");
|
||||
$("#selectedShowHolidays").text(selectedCount + " - " + i18nMessages.selected);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function selectAllHolidays() {
|
||||
$("#selectedHolidays").attr("data-clicked", 1);
|
||||
$("#selectedShowHolidays").removeAttr("style");
|
||||
var savedFilters = JSON.parse(localStorage.getItem("savedFilters"));
|
||||
$("#selectedHolidays").attr("data-clicked", 1);
|
||||
$("#selectedShowHolidays").removeAttr("style");
|
||||
var savedFilters = JSON.parse(localStorage.getItem("savedFilters"));
|
||||
|
||||
if (savedFilters && savedFilters["filterData"] !== null) {
|
||||
var filter = savedFilters["filterData"];
|
||||
$.ajax({
|
||||
url: "/holiday-select-filter",
|
||||
data: { page: "all", filter: JSON.stringify(filter) },
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
var employeeIds = response.employee_ids;
|
||||
if (savedFilters && savedFilters["filterData"] !== null) {
|
||||
var filter = savedFilters["filterData"];
|
||||
$.ajax({
|
||||
url: "/holiday-select-filter",
|
||||
data: { page: "all", filter: JSON.stringify(filter) },
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
var employeeIds = response.employee_ids;
|
||||
|
||||
if (Array.isArray(employeeIds)) {
|
||||
// Continue
|
||||
} else {
|
||||
console.error("employee_ids is not an array:", employeeIds);
|
||||
}
|
||||
if (Array.isArray(employeeIds)) {
|
||||
// Continue
|
||||
} else {
|
||||
console.error("employee_ids is not an array:", employeeIds);
|
||||
}
|
||||
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", true);
|
||||
}
|
||||
$("#selectedHolidays").attr("data-ids", JSON.stringify(employeeIds));
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", true);
|
||||
}
|
||||
$("#selectedHolidays").attr("data-ids", JSON.stringify(employeeIds));
|
||||
|
||||
count = makeHolidayListUnique(employeeIds);
|
||||
tickHolidayCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "/holiday-select",
|
||||
data: { page: "all" },
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
var employeeIds = response.employee_ids;
|
||||
if (Array.isArray(employeeIds)) {
|
||||
// Continue
|
||||
} else {
|
||||
console.error("employee_ids is not an array:", employeeIds);
|
||||
}
|
||||
count = makeHolidayListUnique(employeeIds);
|
||||
tickHolidayCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "/holiday-select",
|
||||
data: { page: "all" },
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
var employeeIds = response.employee_ids;
|
||||
if (Array.isArray(employeeIds)) {
|
||||
// Continue
|
||||
} else {
|
||||
console.error("employee_ids is not an array:", employeeIds);
|
||||
}
|
||||
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", true);
|
||||
}
|
||||
var previousIds = $("#selectedHolidays").attr("data-ids");
|
||||
$("#selectedHolidays").attr(
|
||||
"data-ids",
|
||||
JSON.stringify(
|
||||
Array.from(new Set([...employeeIds, ...JSON.parse(previousIds)]))
|
||||
)
|
||||
);
|
||||
count = makeHolidayListUnique(employeeIds);
|
||||
tickHolidayCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", true);
|
||||
}
|
||||
var previousIds = $("#selectedHolidays").attr("data-ids");
|
||||
$("#selectedHolidays").attr(
|
||||
"data-ids",
|
||||
JSON.stringify(
|
||||
Array.from(new Set([...employeeIds, ...JSON.parse(previousIds)]))
|
||||
)
|
||||
);
|
||||
count = makeHolidayListUnique(employeeIds);
|
||||
tickHolidayCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function unselectAllHolidays() {
|
||||
$("#selectedHolidays").attr("data-clicked", 0);
|
||||
$.ajax({
|
||||
url: "/holiday-select",
|
||||
data: { page: "all", filter: "{}" },
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
var employeeIds = response.employee_ids;
|
||||
$("#selectedHolidays").attr("data-clicked", 0);
|
||||
$.ajax({
|
||||
url: "/holiday-select",
|
||||
data: { page: "all", filter: "{}" },
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
var employeeIds = response.employee_ids;
|
||||
|
||||
if (Array.isArray(employeeIds)) {
|
||||
// Continue
|
||||
} else {
|
||||
console.error("employee_ids is not an array:", employeeIds);
|
||||
}
|
||||
if (Array.isArray(employeeIds)) {
|
||||
// Continue
|
||||
} else {
|
||||
console.error("employee_ids is not an array:", employeeIds);
|
||||
}
|
||||
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", false);
|
||||
$(".all-holidays").prop("checked", false);
|
||||
}
|
||||
var ids = JSON.parse($("#selectedHolidays").attr("data-ids") || "[]");
|
||||
var uniqueIds = makeListUnique(ids);
|
||||
toggleHighlight(uniqueIds);
|
||||
$("#selectedHolidays").attr("data-ids", JSON.stringify([]));
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", false);
|
||||
$(".all-holidays").prop("checked", false);
|
||||
}
|
||||
var ids = JSON.parse($("#selectedHolidays").attr("data-ids") || "[]");
|
||||
var uniqueIds = makeListUnique(ids);
|
||||
toggleHighlight(uniqueIds);
|
||||
$("#selectedHolidays").attr("data-ids", JSON.stringify([]));
|
||||
|
||||
count = [];
|
||||
tickHolidayCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
count = [];
|
||||
tickHolidayCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function exportHolidays() {
|
||||
var currentDate = new Date().toISOString().slice(0, 10);
|
||||
var language_code = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
language_code = code;
|
||||
var confirmMessage = excelMessages[language_code];
|
||||
var currentDate = new Date().toISOString().slice(0, 10);
|
||||
ids = [];
|
||||
ids = JSON.parse($("#selectedHolidays").attr("data-ids"));
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.downloadExcel,
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/holiday-info-export",
|
||||
data: {
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
dataType: "binary",
|
||||
xhrFields: {
|
||||
responseType: "blob",
|
||||
},
|
||||
success: function (response) {
|
||||
const file = new Blob([response], {
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/holiday-info-export",
|
||||
data: {
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
dataType: "binary",
|
||||
xhrFields: {
|
||||
responseType: "blob",
|
||||
},
|
||||
success: function (response) {
|
||||
const file = new Blob([response], {
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
});
|
||||
const url = URL.createObjectURL(file);
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = "holiday_leaves" + currentDate + ".xlsx";
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
console.error("Error downloading file:", errorThrown);
|
||||
},
|
||||
});
|
||||
const url = URL.createObjectURL(file);
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = "holiday_leaves" + currentDate + ".xlsx";
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
console.error("Error downloading file:", errorThrown);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$("#bulkHolidaysDelete").click(function (e) {
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = deleteHolidayMessages[languageCode];
|
||||
var textMessage = no_rows_deleteMessages[languageCode];
|
||||
e.preventDefault();
|
||||
|
||||
ids = [];
|
||||
ids.push($("#selectedHolidays").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedHolidays").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
});
|
||||
Swal.fire({
|
||||
text: i18nMessages.noRowsSelected,
|
||||
icon: "warning",
|
||||
confirmButtonText: i18nMessages.close,
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedHolidays").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedHolidays").attr("data-ids"));
|
||||
var hxValue = JSON.stringify(ids);
|
||||
$("#bulkHolidaysDeleteSpan").attr("hx-vals", `{"ids":${hxValue}}`);
|
||||
$('#unselectAllHolidays').click();
|
||||
$("#bulkHolidaysDeleteSpan").click();
|
||||
}
|
||||
});
|
||||
Swal.fire({
|
||||
text: i18nMessages.confirmBulkDelete,
|
||||
icon: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
ids = [];
|
||||
ids.push($("#selectedHolidays").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedHolidays").attr("data-ids"));
|
||||
var hxValue = JSON.stringify(ids);
|
||||
$("#bulkHolidaysDeleteSpan").attr("hx-vals", `{"ids":${hxValue}}`);
|
||||
$('#unselectAllHolidays').click();
|
||||
$("#bulkHolidaysDeleteSpan").click();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#holidaysInfoImport", function (e) {
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = downloadMessages[languageCode];
|
||||
e.preventDefault();
|
||||
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
text: i18nMessages.downloadTemplate,
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: i18nMessages.confirm,
|
||||
cancelButtonText: i18nMessages.cancel,
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "holidays-excel-template",
|
||||
dataType: "binary",
|
||||
xhrFields: {
|
||||
responseType: "blob",
|
||||
},
|
||||
success: function (response) {
|
||||
const file = new Blob([response], {
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "holidays-excel-template",
|
||||
dataType: "binary",
|
||||
xhrFields: {
|
||||
responseType: "blob",
|
||||
},
|
||||
success: function (response) {
|
||||
const file = new Blob([response], {
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
});
|
||||
const url = URL.createObjectURL(file);
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = "holiday_excel.xlsx";
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
console.error("Error downloading file:", errorThrown);
|
||||
},
|
||||
});
|
||||
const url = URL.createObjectURL(file);
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = "holiday_excel.xlsx";
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
console.error("Error downloading file:", errorThrown);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user