[UPDT] BASE: Add data-action attribute from drop down option in delete in nav bar
This commit is contained in:
@@ -55,7 +55,7 @@ var norowMessages = {
|
||||
ar: "لم يتم تحديد أي صفوف.",
|
||||
de: "Es wurden keine Zeilen ausgewählt.",
|
||||
es: "No se han seleccionado filas.",
|
||||
en: "No rows have been selected.",
|
||||
en: "No rows have been selected for deleting",
|
||||
fr: "Aucune ligne n'a été sélectionnée.",
|
||||
};
|
||||
var rowMessages = {
|
||||
|
||||
@@ -149,6 +149,7 @@
|
||||
<a
|
||||
href="#"
|
||||
class="oh-dropdown__link oh-dropdown__link--danger"
|
||||
data-action="delete"
|
||||
id="deleteRotatingShiftAssign"
|
||||
>{% trans "Delete" %}</a
|
||||
>
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
<a
|
||||
href="#"
|
||||
class="oh-dropdown__link oh-dropdown__link--danger"
|
||||
data-action="delete"
|
||||
id="deleteRotatingWorkTypeAssign"
|
||||
>{% trans "Delete" %}</a
|
||||
>
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
href="#"
|
||||
id="bulkHolidaysDelete"
|
||||
class="oh-dropdown__link oh-dropdown__link--danger"
|
||||
data-action="delete"
|
||||
>{% trans "Delete" %}</a
|
||||
>
|
||||
</li>
|
||||
|
||||
@@ -314,6 +314,7 @@
|
||||
<a
|
||||
href="#"
|
||||
class="oh-dropdown__link oh-dropdown__link--danger"
|
||||
data-action="delete"
|
||||
id="deleteShiftRequest"
|
||||
>{% trans "Delete" %}</a
|
||||
>
|
||||
|
||||
@@ -245,6 +245,7 @@ x-data="{searchShow: false}"
|
||||
<a
|
||||
href="#"
|
||||
class="oh-dropdown__link oh-dropdown__link--danger"
|
||||
data-action="delete"
|
||||
id="deleteWorkTypeRequest"
|
||||
>{% trans "Delete" %}</a
|
||||
>
|
||||
|
||||
@@ -1,523 +1,523 @@
|
||||
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?",
|
||||
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 Mitarbeiter archivieren?",
|
||||
es: "¿Realmente quieres archivar a todos los empleados seleccionados?",
|
||||
en: "Do you really want to archive all the selected employees?",
|
||||
fr: "Voulez-vous vraiment archiver tous les employés sélectionnés ?",
|
||||
ar: "هل ترغب حقًا في أرشفة جميع الموظفين المحددين؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Mitarbeiter archivieren?",
|
||||
es: "¿Realmente quieres archivar a todos los empleados seleccionados?",
|
||||
en: "Do you really want to archive all the selected employees?",
|
||||
fr: "Voulez-vous vraiment archiver tous les employés sélectionnés ?",
|
||||
};
|
||||
|
||||
var unarchiveMessages = {
|
||||
ar: "هل ترغب حقًا في إلغاء أرشفة جميع الموظفين المحددين؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Mitarbeiter aus der Archivierung zurückholen?",
|
||||
es: "¿Realmente quieres desarchivar a todos los empleados seleccionados?",
|
||||
en: "Do you really want to unarchive all the selected employees?",
|
||||
fr: "Voulez-vous vraiment désarchiver tous les employés sélectionnés?",
|
||||
ar: "هل ترغب حقًا في إلغاء أرشفة جميع الموظفين المحددين؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Mitarbeiter aus der Archivierung zurückholen?",
|
||||
es: "¿Realmente quieres desarchivar a todos los empleados seleccionados?",
|
||||
en: "Do you really want to unarchive all the selected employees?",
|
||||
fr: "Voulez-vous vraiment désarchiver tous les employés sélectionnés?",
|
||||
};
|
||||
|
||||
var deleteMessages = {
|
||||
ar: "هل ترغب حقًا في حذف جميع الموظفين المحددين؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Mitarbeiter löschen?",
|
||||
es: "¿Realmente quieres eliminar a todos los empleados seleccionados?",
|
||||
en: "Do you really want to delete all the selected employees?",
|
||||
fr: "Voulez-vous vraiment supprimer tous les employés sélectionnés?",
|
||||
ar: "هل ترغب حقًا في حذف جميع الموظفين المحددين؟",
|
||||
de: "Möchten Sie wirklich alle ausgewählten Mitarbeiter löschen?",
|
||||
es: "¿Realmente quieres eliminar a todos los empleados seleccionados?",
|
||||
en: "Do you really want to delete all the selected employees?",
|
||||
fr: "Voulez-vous vraiment supprimer tous les employés sélectionnés?",
|
||||
};
|
||||
|
||||
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.",
|
||||
ar: "لم يتم تحديد أي صفوف لحذف الموظفين.",
|
||||
de: "Es wurden keine Zeilen ausgewählt, um Mitarbeiter zu löschen.",
|
||||
es: "No se han seleccionado filas para eliminar empleados.",
|
||||
en: "No rows have been selected to delete employees.",
|
||||
fr: "Aucune ligne n'a été sélectionnée pour supprimer des employés.",
|
||||
};
|
||||
|
||||
var rowMessages = {
|
||||
ar: " تم الاختيار",
|
||||
de: " Ausgewählt",
|
||||
es: " Seleccionado",
|
||||
en: " Selected",
|
||||
fr: " Sélectionné",
|
||||
ar: " تم الاختيار",
|
||||
de: " Ausgewählt",
|
||||
es: " Seleccionado",
|
||||
en: " Selected",
|
||||
fr: " Sélectionné",
|
||||
};
|
||||
|
||||
tickCheckboxes();
|
||||
|
||||
function makeListUnique(list) {
|
||||
return Array.from(new Set(list));
|
||||
return Array.from(new Set(list));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
return cookieValue;
|
||||
}
|
||||
|
||||
$(".all-employee").change(function (e) {
|
||||
var is_checked = $(this).is(":checked");
|
||||
var closest = $(this)
|
||||
.closest(".oh-sticky-table__thead")
|
||||
.siblings(".oh-sticky-table__tbody");
|
||||
if (is_checked) {
|
||||
$(closest)
|
||||
.children()
|
||||
.find(".all-employee-row")
|
||||
.prop("checked", true)
|
||||
.closest(".oh-sticky-table__tr")
|
||||
.addClass("highlight-selected");
|
||||
} else {
|
||||
$(closest)
|
||||
.children()
|
||||
.find(".all-employee-row")
|
||||
.prop("checked", false)
|
||||
.closest(".oh-sticky-table__tr")
|
||||
.removeClass("highlight-selected");
|
||||
}
|
||||
addingIds();
|
||||
var is_checked = $(this).is(":checked");
|
||||
var closest = $(this)
|
||||
.closest(".oh-sticky-table__thead")
|
||||
.siblings(".oh-sticky-table__tbody");
|
||||
if (is_checked) {
|
||||
$(closest)
|
||||
.children()
|
||||
.find(".all-employee-row")
|
||||
.prop("checked", true)
|
||||
.closest(".oh-sticky-table__tr")
|
||||
.addClass("highlight-selected");
|
||||
} else {
|
||||
$(closest)
|
||||
.children()
|
||||
.find(".all-employee-row")
|
||||
.prop("checked", false)
|
||||
.closest(".oh-sticky-table__tr")
|
||||
.removeClass("highlight-selected");
|
||||
}
|
||||
addingIds();
|
||||
});
|
||||
|
||||
$(".all-employee-row").change(function () {
|
||||
var parentTable = $(this).closest(".oh-sticky-table");
|
||||
var body = parentTable.find(".oh-sticky-table__tbody");
|
||||
var parentCheckbox = parentTable.find(".all-employee");
|
||||
parentCheckbox.prop(
|
||||
"checked",
|
||||
body.find(".all-employee-row:checked").length ===
|
||||
body.find(".all-employee-row").length
|
||||
);
|
||||
addingIds();
|
||||
var parentTable = $(this).closest(".oh-sticky-table");
|
||||
var body = parentTable.find(".oh-sticky-table__tbody");
|
||||
var parentCheckbox = parentTable.find(".all-employee");
|
||||
parentCheckbox.prop(
|
||||
"checked",
|
||||
body.find(".all-employee-row:checked").length ===
|
||||
body.find(".all-employee-row").length
|
||||
);
|
||||
addingIds();
|
||||
});
|
||||
|
||||
function addingIds() {
|
||||
var ids = JSON.parse($("#selectedInstances").attr("data-ids") || "[]");
|
||||
var selectedCount = 0;
|
||||
var ids = JSON.parse($("#selectedInstances").attr("data-ids") || "[]");
|
||||
var selectedCount = 0;
|
||||
|
||||
$(".all-employee-row").each(function () {
|
||||
if ($(this).is(":checked")) {
|
||||
ids.push(this.id);
|
||||
$(".all-employee-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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ids = makeListUnique(ids);
|
||||
selectedCount = ids.length;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var message =
|
||||
rowMessages[languageCode] ||
|
||||
((languageCode = "en"), rowMessages[languageCode]);
|
||||
$("#selectedInstances").attr("data-ids", JSON.stringify(ids));
|
||||
if (selectedCount === 0) {
|
||||
$("#unselectAllEmployees").css("display", "none");
|
||||
$("#exportEmployees").css("display", "none");
|
||||
$("#selectedShow").css("display", "none");
|
||||
} else {
|
||||
var index = ids.indexOf(this.id);
|
||||
if (index > -1) {
|
||||
ids.splice(index, 1);
|
||||
}
|
||||
$("#unselectAllEmployees").css("display", "inline-flex");
|
||||
$("#exportEmployees").css("display", "inline-flex");
|
||||
$("#selectedShow").css("display", "inline-flex");
|
||||
$("#selectedShow").text(selectedCount + " - " + message);
|
||||
}
|
||||
});
|
||||
|
||||
ids = makeListUnique(ids);
|
||||
selectedCount = ids.length;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var message =
|
||||
rowMessages[languageCode] ||
|
||||
((languageCode = "en"), rowMessages[languageCode]);
|
||||
$("#selectedInstances").attr("data-ids", JSON.stringify(ids));
|
||||
if (selectedCount === 0) {
|
||||
$("#unselectAllEmployees").css("display", "none");
|
||||
$("#exportEmployees").css("display", "none");
|
||||
$("#selectedShow").css("display", "none");
|
||||
} else {
|
||||
$("#unselectAllEmployees").css("display", "inline-flex");
|
||||
$("#exportEmployees").css("display", "inline-flex");
|
||||
$("#selectedShow").css("display", "inline-flex");
|
||||
$("#selectedShow").text(selectedCount + " - " + message);
|
||||
}
|
||||
}
|
||||
|
||||
function tickCheckboxes() {
|
||||
var ids = JSON.parse($("#selectedInstances").attr("data-ids") || "[]");
|
||||
var uniqueIds = makeListUnique(ids);
|
||||
toggleHighlight(uniqueIds);
|
||||
click = $("#selectedInstances").attr("data-clicked");
|
||||
if (click === "1") {
|
||||
$(".all-employee").prop("checked", true);
|
||||
}
|
||||
var ids = JSON.parse($("#selectedInstances").attr("data-ids") || "[]");
|
||||
var uniqueIds = makeListUnique(ids);
|
||||
toggleHighlight(uniqueIds);
|
||||
click = $("#selectedInstances").attr("data-clicked");
|
||||
if (click === "1") {
|
||||
$(".all-employee").prop("checked", true);
|
||||
}
|
||||
|
||||
uniqueIds.forEach(function (id) {
|
||||
$("#" + id).prop("checked", true);
|
||||
});
|
||||
var selectedCount = uniqueIds.length;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var message =
|
||||
rowMessages[languageCode] ||
|
||||
((languageCode = "en"), rowMessages[languageCode]);
|
||||
if (selectedCount > 0) {
|
||||
$("#unselectAllEmployees").css("display", "inline-flex");
|
||||
$("#exportEmployees").css("display", "inline-flex");
|
||||
$("#selectedShow").css("display", "inline-flex");
|
||||
$("#selectedShow").text(selectedCount + " -" + message);
|
||||
} else {
|
||||
$("#unselectAllEmployees").css("display", "none");
|
||||
$("#exportEmployees").css("display", "none");
|
||||
$("#selectedShow").css("display", "none");
|
||||
}
|
||||
uniqueIds.forEach(function (id) {
|
||||
$("#" + id).prop("checked", true);
|
||||
});
|
||||
var selectedCount = uniqueIds.length;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var message =
|
||||
rowMessages[languageCode] ||
|
||||
((languageCode = "en"), rowMessages[languageCode]);
|
||||
if (selectedCount > 0) {
|
||||
$("#unselectAllEmployees").css("display", "inline-flex");
|
||||
$("#exportEmployees").css("display", "inline-flex");
|
||||
$("#selectedShow").css("display", "inline-flex");
|
||||
$("#selectedShow").text(selectedCount + " -" + message);
|
||||
} else {
|
||||
$("#unselectAllEmployees").css("display", "none");
|
||||
$("#exportEmployees").css("display", "none");
|
||||
$("#selectedShow").css("display", "none");
|
||||
}
|
||||
}
|
||||
|
||||
function selectAllEmployees() {
|
||||
var allEmployeeCount = 0;
|
||||
$("#selectedInstances").attr("data-clicked", 1);
|
||||
$("#selectedShow").removeAttr("style");
|
||||
var savedFilters = JSON.parse(localStorage.getItem("savedFilters"));
|
||||
var filterQuery = $("#selectAllEmployees").data("pd");
|
||||
if (savedFilters && savedFilters["filterData"] !== null) {
|
||||
$.ajax({
|
||||
url: "/employee/employee-select-filter?" + filterQuery,
|
||||
data: { page: "all" },
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
var employeeIds = response.employee_ids;
|
||||
var allEmployeeCount = 0;
|
||||
$("#selectedInstances").attr("data-clicked", 1);
|
||||
$("#selectedShow").removeAttr("style");
|
||||
var savedFilters = JSON.parse(localStorage.getItem("savedFilters"));
|
||||
var filterQuery = $("#selectAllEmployees").data("pd");
|
||||
if (savedFilters && savedFilters["filterData"] !== null) {
|
||||
$.ajax({
|
||||
url: "/employee/employee-select-filter?" + filterQuery,
|
||||
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);
|
||||
}
|
||||
if (Array.isArray(employeeIds)) {
|
||||
// Continue
|
||||
} else {
|
||||
console.error("employee_ids is not an array:", employeeIds);
|
||||
}
|
||||
|
||||
allEmployeeCount = employeeIds.length;
|
||||
allEmployeeCount = employeeIds.length;
|
||||
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", true);
|
||||
}
|
||||
$("#selectedInstances").attr("data-ids", JSON.stringify(employeeIds));
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", true);
|
||||
}
|
||||
$("#selectedInstances").attr("data-ids", JSON.stringify(employeeIds));
|
||||
|
||||
count = makeListUnique(employeeIds);
|
||||
$("#unselectAllEmployees").css("display", "inline-flex");
|
||||
$("#exportEmployees").css("display", "inline-flex");
|
||||
tickCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "/employee/employee-select",
|
||||
data: { page: "all" },
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
var employeeIds = response.employee_ids;
|
||||
count = makeListUnique(employeeIds);
|
||||
$("#unselectAllEmployees").css("display", "inline-flex");
|
||||
$("#exportEmployees").css("display", "inline-flex");
|
||||
tickCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "/employee/employee-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);
|
||||
}
|
||||
if (Array.isArray(employeeIds)) {
|
||||
// Continue
|
||||
} else {
|
||||
console.error("employee_ids is not an array:", employeeIds);
|
||||
}
|
||||
|
||||
allEmployeeCount = employeeIds.length;
|
||||
allEmployeeCount = employeeIds.length;
|
||||
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", true);
|
||||
}
|
||||
var previousIds = $("#selectedInstances").attr("data-ids");
|
||||
$("#selectedInstances").attr(
|
||||
"data-ids",
|
||||
JSON.stringify(
|
||||
Array.from(new Set([...employeeIds, ...JSON.parse(previousIds)]))
|
||||
)
|
||||
);
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", true);
|
||||
}
|
||||
var previousIds = $("#selectedInstances").attr("data-ids");
|
||||
$("#selectedInstances").attr(
|
||||
"data-ids",
|
||||
JSON.stringify(
|
||||
Array.from(new Set([...employeeIds, ...JSON.parse(previousIds)]))
|
||||
)
|
||||
);
|
||||
|
||||
count = makeListUnique(employeeIds);
|
||||
$("#unselectAllEmployees").css("display", "inline-flex");
|
||||
$("#exportEmployees").css("display", "inline-flex");
|
||||
tickCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
count = makeListUnique(employeeIds);
|
||||
$("#unselectAllEmployees").css("display", "inline-flex");
|
||||
$("#exportEmployees").css("display", "inline-flex");
|
||||
tickCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function unselectAllEmployees() {
|
||||
$("#selectedInstances").attr("data-clicked", 0);
|
||||
$("#selectedInstances").attr("data-clicked", 0);
|
||||
|
||||
$.ajax({
|
||||
url: "/employee/employee-select",
|
||||
data: { page: "unselect", filter: "{}" },
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
var employeeIds = response.employee_ids;
|
||||
$.ajax({
|
||||
url: "/employee/employee-select",
|
||||
data: { page: "unselect", 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);
|
||||
$("#tick").prop("checked", false);
|
||||
}
|
||||
var ids = JSON.parse($("#selectedInstances").attr("data-ids") || "[]");
|
||||
var uniqueIds = makeListUnique(ids);
|
||||
toggleHighlight(uniqueIds);
|
||||
for (var i = 0; i < employeeIds.length; i++) {
|
||||
var empId = employeeIds[i];
|
||||
$("#" + empId).prop("checked", false);
|
||||
$("#tick").prop("checked", false);
|
||||
}
|
||||
var ids = JSON.parse($("#selectedInstances").attr("data-ids") || "[]");
|
||||
var uniqueIds = makeListUnique(ids);
|
||||
toggleHighlight(uniqueIds);
|
||||
|
||||
$("#selectedInstances").attr("data-ids", JSON.stringify([]));
|
||||
$("#selectedInstances").attr("data-ids", JSON.stringify([]));
|
||||
|
||||
count = [];
|
||||
$("#unselectAllEmployees").css("display", "none");
|
||||
$("#exportEmployees").css("display", "none");
|
||||
tickCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
count = [];
|
||||
$("#unselectAllEmployees").css("display", "none");
|
||||
$("#exportEmployees").css("display", "none");
|
||||
tickCheckboxes(count);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
$("#exportEmployees").click(function (e) {
|
||||
var currentDate = new Date().toISOString().slice(0, 10);
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var confirmMessage =
|
||||
excelMessages[languageCode] ||
|
||||
((languageCode = "en"), excelMessages[languageCode]);
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/employee/work-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 = "employee_export_" + currentDate + ".xlsx";
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
console.error("Error downloading file:", errorThrown);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
var currentDate = new Date().toISOString().slice(0, 10);
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var confirmMessage =
|
||||
excelMessages[languageCode] ||
|
||||
((languageCode = "en"), excelMessages[languageCode]);
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/employee/work-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 = "employee_export_" + currentDate + ".xlsx";
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
console.error("Error downloading file:", errorThrown);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#employeeBulkUpdateId").click(function (e) {
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var textMessage =
|
||||
noRowMessages[languageCode] ||
|
||||
((languageCode = "en"), noRowMessages[languageCode]);
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
$("#bulkUpdateModal").removeClass("oh-modal--show");
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
});
|
||||
} else {
|
||||
$("#id_bulk_employee_ids").val(JSON.stringify(ids));
|
||||
$("#bulkUpdateModal").addClass("oh-modal--show");
|
||||
}
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var textMessage =
|
||||
noRowMessages[languageCode] ||
|
||||
((languageCode = "en"), noRowMessages[languageCode]);
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
if (ids.length === 0) {
|
||||
$("#bulkUpdateModal").removeClass("oh-modal--show");
|
||||
Swal.fire({
|
||||
text: textMessage,
|
||||
icon: "warning",
|
||||
confirmButtonText: "Close",
|
||||
});
|
||||
} else {
|
||||
$("#id_bulk_employee_ids").val(JSON.stringify(ids));
|
||||
$("#bulkUpdateModal").addClass("oh-modal--show");
|
||||
}
|
||||
});
|
||||
|
||||
$("#archiveEmployees").click(function (e) {
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var confirmMessage =
|
||||
archiveMessages[languageCode] ||
|
||||
((languageCode = "en"), archiveMessages[languageCode]);
|
||||
var textMessage =
|
||||
noRowMessages[languageCode] ||
|
||||
((languageCode = "en"), 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: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
e.preventDefault();
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/employee/employee-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);
|
||||
}
|
||||
},
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var confirmMessage =
|
||||
archiveMessages[languageCode] ||
|
||||
((languageCode = "en"), archiveMessages[languageCode]);
|
||||
var textMessage =
|
||||
noRowMessages[languageCode] ||
|
||||
((languageCode = "en"), 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: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
e.preventDefault();
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/employee/employee-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);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#unArchiveEmployees").click(function (e) {
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var confirmMessage =
|
||||
unarchiveMessages[languageCode] ||
|
||||
((languageCode = "en"), unarchiveMessages[languageCode]);
|
||||
var textMessage =
|
||||
noRowMessages[languageCode] ||
|
||||
((languageCode = "en"), 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: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
e.preventDefault();
|
||||
|
||||
ids = [];
|
||||
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/employee/employee-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);
|
||||
}
|
||||
},
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var confirmMessage =
|
||||
unarchiveMessages[languageCode] ||
|
||||
((languageCode = "en"), unarchiveMessages[languageCode]);
|
||||
var textMessage =
|
||||
noRowMessages[languageCode] ||
|
||||
((languageCode = "en"), 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: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
e.preventDefault();
|
||||
|
||||
ids = [];
|
||||
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/employee/employee-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);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#deleteEmployees").click(function (e) {
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var confirmMessage =
|
||||
deleteMessages[languageCode] ||
|
||||
((languageCode = "en"), deleteMessages[languageCode]);
|
||||
var textMessage =
|
||||
noRowMessages[languageCode] ||
|
||||
((languageCode = "en"), 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: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
e.preventDefault();
|
||||
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/employee/employee-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);
|
||||
}
|
||||
},
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var confirmMessage =
|
||||
deleteMessages[languageCode] ||
|
||||
((languageCode = "en"), deleteMessages[languageCode]);
|
||||
var textMessage =
|
||||
noRowMessages[languageCode] ||
|
||||
((languageCode = "en"), 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: "error",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
e.preventDefault();
|
||||
|
||||
ids = [];
|
||||
ids.push($("#selectedInstances").attr("data-ids"));
|
||||
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/employee/employee-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);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#select-all-fields").change(function () {
|
||||
const isChecked = $(this).prop("checked");
|
||||
$('[name="selected_fields"]').prop("checked", isChecked);
|
||||
const isChecked = $(this).prop("checked");
|
||||
$('[name="selected_fields"]').prop("checked", isChecked);
|
||||
});
|
||||
|
||||
@@ -446,6 +446,7 @@
|
||||
<a
|
||||
href="#"
|
||||
class="oh-dropdown__link oh-dropdown__link--danger"
|
||||
data-action="delete"
|
||||
id="deleteEmployees"
|
||||
>
|
||||
{% trans "Delete" %}
|
||||
|
||||
@@ -1,422 +0,0 @@
|
||||
var rowMessages = {
|
||||
ar: " تم الاختيار",
|
||||
de: " Ausgewählt",
|
||||
es: " Seleccionado",
|
||||
en: " Selected",
|
||||
fr: " Sélectionné",
|
||||
};
|
||||
|
||||
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 createHolidayHxValue() {
|
||||
var pd = $(".oh-pagination").attr("data-pd");
|
||||
var hxValue = JSON.stringify(pd);
|
||||
$("#holidayCreateButton").attr("hx-vals", `{"pd":${hxValue}}`);
|
||||
}
|
||||
|
||||
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");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addingHolidayIds() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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");
|
||||
} else {
|
||||
$("#unselectAllHolidays").css("display", "inline-flex");
|
||||
$("#exportHolidays").css("display", "inline-flex");
|
||||
$("#selectedShowHolidays").css("display", "inline-flex");
|
||||
$("#selectedShowHolidays").text(selectedCount + " - " + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function selectAllHolidays() {
|
||||
$("#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: "/leave/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);
|
||||
}
|
||||
|
||||
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: "/leave/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);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function unselectAllHolidays() {
|
||||
$("#selectedHolidays").attr("data-clicked", 0);
|
||||
$.ajax({
|
||||
url: "/leave/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);
|
||||
}
|
||||
|
||||
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);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
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];
|
||||
ids = [];
|
||||
ids = JSON.parse($("#selectedHolidays").attr("data-ids"));
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/leave/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);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$("#bulkHolidaysDelete").click(function (e) {
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = deleteHolidayMessages[languageCode];
|
||||
var textMessage = no_rows_deleteMessages[languageCode];
|
||||
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",
|
||||
});
|
||||
} 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"));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/leave/holidays-bulk-delete",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (response, textStatus, jqXHR) {
|
||||
if (jqXHR.status === 200) {
|
||||
location.reload();
|
||||
} else {
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#holidaysInfoImport").click(function (e) {
|
||||
e.preventDefault();
|
||||
var languageCode = null;
|
||||
getCurrentLanguageCode(function (code) {
|
||||
languageCode = code;
|
||||
var confirmMessage = downloadMessages[languageCode];
|
||||
Swal.fire({
|
||||
text: confirmMessage,
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Confirm",
|
||||
}).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",
|
||||
});
|
||||
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);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$("#holidaysImportForm").submit(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Create a FormData object to send the file
|
||||
$("#uploadContainer").css("display", "none");
|
||||
$("#uploading").css("display", "block");
|
||||
var formData = new FormData(this);
|
||||
|
||||
fetch("/leave/holidays-info-import", {
|
||||
method: "POST",
|
||||
dataType: "binary",
|
||||
body: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
headers: {
|
||||
// Include the CSRF token in the headers
|
||||
"X-CSRFToken": "{{ csrf_token }}",
|
||||
},
|
||||
xhrFields: {
|
||||
responseType: "blob",
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.blob(); // Use response.blob() to get the binary data
|
||||
} else {
|
||||
// Handle errors, e.g., show an error message
|
||||
}
|
||||
})
|
||||
.then((blob) => {
|
||||
if (blob) {
|
||||
// Create a Blob from the binary data
|
||||
const file = new Blob([blob], {
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
});
|
||||
const url = URL.createObjectURL(file);
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = "HolidayImportError.xlsx";
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
window.location.href = "/leave/holiday-view";
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
.catch((error) => {});
|
||||
});
|
||||
@@ -2,10 +2,9 @@ var activityButton = $("#attendance-activity-container").find("button");
|
||||
outUrl = "/attendance/clock-out";
|
||||
bttnUrl = activityButton.attr("hx-get");
|
||||
if (outUrl == bttnUrl) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
console.log(outUrl);
|
||||
console.log(bttnUrl);
|
||||
console.log(activityButton);
|
||||
|
||||
|
||||
@@ -1,127 +1,134 @@
|
||||
var confirmModal = {
|
||||
ar: "تأكيد",
|
||||
de: "Bestätigen",
|
||||
es: "Confirmar",
|
||||
en: "Confirm",
|
||||
fr: "Confirmer",
|
||||
ar: "تأكيد",
|
||||
de: "Bestätigen",
|
||||
es: "Confirmar",
|
||||
en: "Confirm",
|
||||
fr: "Confirmer",
|
||||
};
|
||||
|
||||
var cancelModal = {
|
||||
ar: "إلغاء",
|
||||
de: "Abbrechen",
|
||||
es: "Cancelar",
|
||||
en: "Cancel",
|
||||
fr: "Annuler",
|
||||
ar: "إلغاء",
|
||||
de: "Abbrechen",
|
||||
es: "Cancelar",
|
||||
en: "Cancel",
|
||||
fr: "Annuler",
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
return cookieValue;
|
||||
}
|
||||
|
||||
var originalConfirm = window.confirm;
|
||||
// Override the default confirm function with SweetAlert
|
||||
window.confirm = function (message) {
|
||||
var event = window.event || {};
|
||||
event.preventDefault();
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var confirm =
|
||||
confirmModal[languageCode] ||
|
||||
((languageCode = "en"), confirmModal[languageCode]);
|
||||
var cancel =
|
||||
cancelModal[languageCode] ||
|
||||
((languageCode = "en"), cancelModal[languageCode]);
|
||||
// Add event listener to "Confirm" button
|
||||
$("#confirmModalBody").html(message);
|
||||
var submit = false;
|
||||
Swal.fire({
|
||||
text: message,
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: confirm,
|
||||
cancelButtonText: cancel,
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
if (event.target.tagName.toLowerCase() === "form") {
|
||||
if (event.target["htmx-internal-data"]) {
|
||||
var path = event.target["htmx-internal-data"].path;
|
||||
var verb = event.target["htmx-internal-data"].verb;
|
||||
var hxTarget = $(event.target).attr("hx-target");
|
||||
if (verb === "post") {
|
||||
htmx.ajax("POST", path, hxTarget);
|
||||
} else {
|
||||
htmx.ajax("GET", path, hxTarget);
|
||||
}
|
||||
var event = window.event || {};
|
||||
event.preventDefault();
|
||||
var languageCode = null;
|
||||
languageCode = $("#main-section-data").attr("data-lang");
|
||||
var confirm =
|
||||
confirmModal[languageCode] ||
|
||||
((languageCode = "en"), confirmModal[languageCode]);
|
||||
var cancel =
|
||||
cancelModal[languageCode] ||
|
||||
((languageCode = "en"), cancelModal[languageCode]);
|
||||
// Add event listener to "Confirm" button
|
||||
$("#confirmModalBody").html(message);
|
||||
var submit = false;
|
||||
Swal.fire({
|
||||
text: message,
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#008000",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: confirm,
|
||||
cancelButtonText: cancel,
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
if (event.target.tagName.toLowerCase() === "form") {
|
||||
if (event.target["htmx-internal-data"]) {
|
||||
var path = event.target["htmx-internal-data"].path;
|
||||
var verb = event.target["htmx-internal-data"].verb;
|
||||
var hxTarget = $(event.target).attr("hx-target");
|
||||
if (verb === "post") {
|
||||
htmx.ajax("POST", path, hxTarget);
|
||||
} else {
|
||||
htmx.ajax("GET", path, hxTarget);
|
||||
}
|
||||
} else {
|
||||
event.target.submit();
|
||||
}
|
||||
} else if (event.target.tagName.toLowerCase() === "a") {
|
||||
if (event.target.href) {
|
||||
window.location.href = event.target.href;
|
||||
} else {
|
||||
var path = event.target["htmx-internal-data"].path;
|
||||
var verb = event.target["htmx-internal-data"].verb;
|
||||
var hxTarget = $(event.target).attr("hx-target");
|
||||
if (verb === "post") {
|
||||
// hx.post(path)
|
||||
htmx.ajax("POST", path, hxTarget);
|
||||
} else {
|
||||
htmx.ajax("GET", path, hxTarget);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var path = event.target["htmx-internal-data"].path;
|
||||
var verb = event.target["htmx-internal-data"].verb;
|
||||
var hxTarget = $(event.target).attr("hx-target");
|
||||
if (verb === "post") {
|
||||
htmx.ajax("POST", path, hxTarget);
|
||||
} else {
|
||||
htmx.ajax("GET", path, hxTarget);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
event.target.submit();
|
||||
}
|
||||
} else if (event.target.tagName.toLowerCase() === "a") {
|
||||
if (event.target.href) {
|
||||
window.location.href = event.target.href;
|
||||
} else {
|
||||
var path = event.target["htmx-internal-data"].path;
|
||||
var verb = event.target["htmx-internal-data"].verb;
|
||||
var hxTarget = $(event.target).attr("hx-target");
|
||||
if (verb === "post") {
|
||||
// hx.post(path)
|
||||
htmx.ajax("POST", path, hxTarget);
|
||||
} else {
|
||||
htmx.ajax("GET", path, hxTarget);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var path = event.target["htmx-internal-data"].path;
|
||||
var verb = event.target["htmx-internal-data"].verb;
|
||||
var hxTarget = $(event.target).attr("hx-target");
|
||||
if (verb === "post") {
|
||||
htmx.ajax("POST", path, hxTarget);
|
||||
} else {
|
||||
htmx.ajax("GET", path, hxTarget);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
var nav = $("section.oh-wrapper.oh-main__topbar");
|
||||
nav.after(
|
||||
$(
|
||||
`
|
||||
$(
|
||||
`
|
||||
<div id="filterTagContainerSectionNav" class="oh-titlebar-container__filters mb-2 mt-0 oh-wrapper"></div>
|
||||
`
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
function attendanceDateChange(selectElement) {
|
||||
var selectedDate =selectElement.val()
|
||||
let parentForm = selectElement.parents().closest("form")
|
||||
var shiftId = parentForm.find("[name=shift_id]").val()
|
||||
var selectedDate = selectElement.val()
|
||||
let parentForm = selectElement.parents().closest("form")
|
||||
var shiftId = parentForm.find("[name=shift_id]").val()
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/attendance/update-date-details",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
"attendance_date":selectedDate,
|
||||
"shift_id":shiftId
|
||||
},
|
||||
success: function (response) {
|
||||
parentForm.find("[name=minimum_hour]").val(response.minimum_hour)
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/attendance/update-date-details",
|
||||
data: {
|
||||
csrfmiddlewaretoken: getCookie("csrftoken"),
|
||||
"attendance_date": selectedDate,
|
||||
"shift_id": shiftId
|
||||
},
|
||||
success: function (response) {
|
||||
parentForm.find("[name=minimum_hour]").val(response.minimum_hour)
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('keydown', function (event) {
|
||||
if (event.keyCode === 46) {
|
||||
// Click the delete option from navbar of current page
|
||||
$('[data-action="delete"]').click();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user