[ADD]sweet alert

This commit is contained in:
Horilla
2023-08-31 16:53:07 +05:30
parent 45f9d4aaf0
commit 9d8fdc5cf7
15 changed files with 956 additions and 379 deletions

View File

@@ -20,10 +20,31 @@ $(document).ready(function () {
en: "Do you really want to delete all the selected attendances?",
fr: "Voulez-vous vraiment supprimer toutes les présences sélectionnées?",
};
var norowvalidateMessages = {
ar: "لم يتم تحديد أي صفوف من فحص الحضور.",
de: "Im Feld „Anwesenheit validieren“ sind keine Zeilen ausgewählt.",
es: "No se selecciona ninguna fila de Validar asistencia.",
en: "No rows are selected from Validate Attendances.",
fr: "Aucune ligne n'est sélectionnée dans Valider la présence.",
};
var norowotMessages = {
ar: "لم يتم تحديد أي صفوف من حضور العمل الإضافي.",
de: "In der OT-Anwesenheit sind keine Zeilen ausgewählt.",
es: "No se seleccionan filas de Asistencias de OT.",
en: "No rows are selected from OT Attendances.",
fr: "Aucune ligne n'est sélectionnée dans les présences OT.",
};
var norowdeleteMessages = {
ar: "لم يتم تحديد أي صفوف لحذف الحضور.",
de: "Es sind keine Zeilen zum Löschen von Anwesenheiten ausgewählt.",
es: "No se seleccionan filas para eliminar asistencias.",
en: "No rows are selected for deleting attendances.",
fr: "Aucune ligne n'est sélectionnée pour la suppression des présences.",
};
function getCurrentLanguageCode(callback) {
$.ajax({
type: "GET",
url: "/attendance/get-language-code/",
url: "/employee/get-language-code/",
success: function (response) {
var languageCode = response.language_code;
callback(languageCode); // Pass the language code to the callback function
@@ -72,33 +93,50 @@ $(document).ready(function () {
}
return cookieValue;
}
$("#validateAttendances").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
console.log(languageCode);
var confirmMessage = validateMessages[languageCode];
choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".validate-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowvalidateMessages[languageCode];
var checkedRows = $(".validate-row").filter(":checked");
if (checkedRows.length === 0) {
Swal.fire({
text: textMessage,
icon: "warning",
confirmButtonText: "Close",
});
$.ajax({
type: "POST",
url: "/attendance/validate-bulk-attendance",
data: {
csrfmiddlewaretoken: getCookie("csrftoken"),
ids: JSON.stringify(ids),
},
success: function (response, textStatus, jqXHR) {
if (jqXHR.status === 200) {
location.reload();
} else {
}
},
} else {
Swal.fire({
text: confirmMessage,
icon: "info",
showCancelButton: true,
confirmButtonColor: "#008000",
cancelButtonColor: "#d33",
confirmButtonText: "Confirm",
}).then(function (result) {
if (result.isConfirmed) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.ajax({
type: "POST",
url: "/attendance/validate-bulk-attendance",
data: {
csrfmiddlewaretoken: getCookie("csrftoken"),
ids: JSON.stringify(ids),
},
success: function (response, textStatus, jqXHR) {
if (jqXHR.status === 200) {
location.reload();
} else {
}
},
});
}
});
}
});
@@ -110,26 +148,43 @@ $(document).ready(function () {
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = overtimeMessages[languageCode];
choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".ot-attendance-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowotMessages[languageCode];
var checkedRows = $(".ot-attendance-row").filter(":checked");
if (checkedRows.length === 0) {
Swal.fire({
text: textMessage,
icon: "warning",
confirmButtonText: "Close",
});
$.ajax({
type: "POST",
url: "/attendance/approve-bulk-overtime",
data: {
csrfmiddlewaretoken: getCookie("csrftoken"),
ids: JSON.stringify(ids),
},
success: function (response, textStatus, jqXHR) {
if (jqXHR.status === 200) {
location.reload();
} else {
}
},
} else {
Swal.fire({
text: confirmMessage,
icon: "success",
showCancelButton: true,
confirmButtonColor: "#008000",
cancelButtonColor: "#d33",
confirmButtonText: "Confirm",
}).then(function (result) {
if (result.isConfirmed) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.ajax({
type: "POST",
url: "/attendance/approve-bulk-overtime",
data: {
csrfmiddlewaretoken: getCookie("csrftoken"),
ids: JSON.stringify(ids),
},
success: function (response, textStatus, jqXHR) {
if (jqXHR.status === 200) {
location.reload();
} else {
}
},
});
}
});
}
});
@@ -141,26 +196,43 @@ $(document).ready(function () {
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = deleteMessages[languageCode];
choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".attendance-checkbox").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowdeleteMessages[languageCode];
var checkedRows = $(".attendance-checkbox").filter(":checked");
if (checkedRows.length === 0) {
Swal.fire({
text: textMessage,
icon: "warning",
confirmButtonText: "Close",
});
$.ajax({
type: "POST",
url: "/attendance/attendance-bulk-delete",
data: {
csrfmiddlewaretoken: getCookie("csrftoken"),
ids: JSON.stringify(ids),
},
success: function (response, textStatus, jqXHR) {
if (jqXHR.status === 200) {
location.reload();
} else {
}
},
} else {
Swal.fire({
text: confirmMessage,
icon: "error",
showCancelButton: true,
confirmButtonColor: "#008000",
cancelButtonColor: "#d33",
confirmButtonText: "Confirm",
}).then(function (result) {
if (result.isConfirmed) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.ajax({
type: "POST",
url: "/attendance/attendance-bulk-delete",
data: {
csrfmiddlewaretoken: getCookie("csrftoken"),
ids: JSON.stringify(ids),
},
success: function (response, textStatus, jqXHR) {
if (jqXHR.status === 200) {
location.reload();
} else {
}
},
});
}
});
}
});

View File

@@ -125,10 +125,6 @@ def attendance_validate(attendance):
at_work = strtime_seconds(attendance.attendance_worked_hour)
return condition_for_at_work >= at_work
def get_language_code(request):
language_code = request.LANGUAGE_CODE
return JsonResponse({"language_code": language_code})
@login_required
@manager_can_enter("attendance.add_attendance")
def attendance_create(request):
@@ -780,6 +776,14 @@ def approve_bulk_overtime(request):
"""
ids = request.POST["ids"]
ids = json.loads(ids)
print('-----------------------------------------------------------------')
print('-----------------------------------------------------------------')
print('-----------------------------------------------------------------')
print('-----------------------------------------------------------------')
print(ids)
print('-----------------------------------------------------------------')
print('-----------------------------------------------------------------')
print('-----------------------------------------------------------------')
for attendance_id in ids:
attendance = Attendance.objects.get(id=attendance_id)
attendance.attendance_overtime_approve = True

View File

@@ -43,6 +43,13 @@ var requestDeleteMessages = {
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.",
};
function getCookie(name) {
let cookieValue = null;
@@ -63,7 +70,7 @@ function getCookie(name) {
function getCurrentLanguageCode(callback) {
$.ajax({
type: "GET",
url: "get-language-code/",
url: "/employee/get-language-code/",
success: function (response) {
var languageCode = response.language_code;
callback(languageCode); // Pass the language code to the callback
@@ -80,33 +87,52 @@ $(".all-rshift").change(function (e) {
}
});
$("#archiveRotatingShiftAssign").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = archiveMessages[languageCode];
choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".all-rshift-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-rshift-row").filter(":checked");
if (checkedRows.length === 0) {
Swal.fire({
text: textMessage,
icon: "warning",
confirmButtonText: "Close",
});
$.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);
}
},
} else {
Swal.fire({
text: confirmMessage,
icon: "info",
showCancelButton: true,
confirmButtonColor: "#008000",
cancelButtonColor: "#d33",
confirmButtonText: "Confirm",
}).then(function (result) {
if (result.isConfirmed) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
});
}
});
}
});
@@ -114,31 +140,49 @@ $("#archiveRotatingShiftAssign").click(function (e) {
$("#unArchiveRotatingShiftAssign").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = unarchiveMessages[languageCode];
choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".all-rshift-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-rshift-row").filter(":checked");
if (checkedRows.length === 0) {
Swal.fire({
text: textMessage,
icon: "warning",
confirmButtonText: "Close",
});
$.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);
}
},
} else {
Swal.fire({
text: confirmMessage,
icon: "info",
showCancelButton: true,
confirmButtonColor: "#008000",
cancelButtonColor: "#d33",
confirmButtonText: "Confirm",
}).then(function (result) {
if (result.isConfirmed) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
});
}
});
}
});
@@ -146,31 +190,49 @@ $("#unArchiveRotatingShiftAssign").click(function (e) {
$("#deleteRotatingShiftAssign").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = deleteMessages[languageCode];
var choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".all-rshift-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-rshift-row").filter(":checked");
if (checkedRows.length === 0) {
Swal.fire({
text: textMessage,
icon: "warning",
confirmButtonText: "Close",
});
$.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);
}
},
} else {
Swal.fire({
text: confirmMessage,
icon: "error",
showCancelButton: true,
confirmButtonColor: "#008000",
cancelButtonColor: "#d33",
confirmButtonText: "Confirm",
}).then(function (result) {
if (result.isConfirmed) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
});
}
});
}
});
@@ -185,33 +247,52 @@ $(".all-rwork-type").change(function (e) {
}
});
$("#archiveRotatingWorkTypeAssign").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = archiveMessages[languageCode];
var choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".all-rwork-type-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-rwork-type-row").filter(":checked");
if (checkedRows.length === 0) {
Swal.fire({
text: textMessage,
icon: "warning",
confirmButtonText: "Close",
});
$.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);
}
},
} else {
Swal.fire({
text: confirmMessage,
icon: "info",
showCancelButton: true,
confirmButtonColor: "#008000",
cancelButtonColor: "#d33",
confirmButtonText: "Confirm",
}).then(function (result) {
if (result.isConfirmed) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
});
}
});
}
});
@@ -219,32 +300,48 @@ $("#archiveRotatingWorkTypeAssign").click(function (e) {
$("#unArchiveRotatingWorkTypeAssign").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = unarchiveMessages[languageCode];
var choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".all-rwork-type-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-rwork-type-row").filter(":checked");
if (checkedRows.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) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
$.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);
}
},
});
}
});
}
});
@@ -252,32 +349,50 @@ $("#unArchiveRotatingWorkTypeAssign").click(function (e) {
$("#deleteRotatingWorkTypeAssign").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = deleteMessages[languageCode];
var choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".all-rwork-type-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-rwork-type-row").filter(":checked");
if (checkedRows.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 = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
$.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);
}
},
});
}
});
}
});
@@ -292,34 +407,54 @@ $(".all-shift-requests").change(function (e) {
}
});
$("#approveShiftRequest").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = approveMessages[languageCode];
var choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".all-shift-requests-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-shift-requests-row").filter(":checked");
if (checkedRows.length === 0) {
Swal.fire({
text: textMessage,
icon: "warning",
confirmButtonText: "Close",
});
} else {
// Use SweetAlert for the confirmation dialog
Swal.fire({
text: confirmMessage,
icon: "success",
showCancelButton: true,
confirmButtonColor: "#008000",
cancelButtonColor: "#d33",
confirmButtonText: "Confirm",
}).then(function (result) {
if (result.isConfirmed) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
$.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);
}
},
});
}
});
}
});
@@ -327,32 +462,50 @@ $("#approveShiftRequest").click(function (e) {
$("#cancelShiftRequest").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = cancelMessages[languageCode];
var choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".all-shift-requests-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-shift-requests-row").filter(":checked");
if (checkedRows.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) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
$.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);
}
},
});
}
});
}
});
@@ -360,32 +513,50 @@ $("#cancelShiftRequest").click(function (e) {
$("#deleteShiftRequest").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = requestDeleteMessages[languageCode];
var choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".all-shift-requests-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-shift-requests-row").filter(":checked");
if (checkedRows.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) {
var ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
$.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);
}
},
});
}
});
}
});
@@ -400,67 +571,54 @@ $(".all-work-type-requests").change(function (e) {
}
});
$("#approveWorkTypeRequest").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = approveMessages[languageCode];
var choice = originalConfirm(confirmMessage);
if (choice) {
e.preventDefault();
var checkedRows = $(".all-work-type-requests-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-work-type-requests-row").filter(":checked");
if (checkedRows.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) {
e.preventDefault();
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
});
}
});
});
$("#deleteWorkTypeRequest").click(function (e) {
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = requestDeleteMessages[languageCode];
var choice = originalConfirm(confirmMessage);
if (choice) {
e.preventDefault();
var checkedRows = $(".all-work-type-requests-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
$.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);
}
},
});
}
});
}
});
@@ -468,32 +626,102 @@ $("#deleteWorkTypeRequest").click(function (e) {
$("#cancelWorkTypeRequest").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = cancelMessages[languageCode];
var choice = originalConfirm(confirmMessage);
if (choice) {
var checkedRows = $(".all-work-type-requests-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-work-type-requests-row").filter(":checked");
if (checkedRows.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) {
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
$.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);
}
},
});
}
});
}
});
});
$("#deleteWorkTypeRequest").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = requestDeleteMessages[languageCode];
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-work-type-requests-row").filter(":checked");
if (checkedRows.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 = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
$.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);
}
},
});
}
});
}
});

View File

@@ -978,7 +978,11 @@ def rotating_work_type_assign_bulk_archive(request):
is_active=True, employee_id=rwork_type_assign.employee_id
)
flag = True
if len(employees_rwork_type_assign) < 1:
if is_active:
if len(employees_rwork_type_assign) < 1:
flag = False
rwork_type_assign.is_active = is_active
else:
flag = False
rwork_type_assign.is_active = is_active
rwork_type_assign.save()
@@ -1488,7 +1492,11 @@ def rotating_shift_assign_bulk_archive(request):
is_active=True, employee_id=rshift_assign.employee_id
)
flag = True
if len(employees_rshift_assign) < 1:
if is_active:
if len(employees_rshift_assign) < 1:
flag = False
rshift_assign.is_active = is_active
else:
flag = False
rshift_assign.is_active = is_active
rshift_assign.save()
@@ -1782,6 +1790,7 @@ def work_type_request_bulk_cancel(request):
"""
ids = request.POST["ids"]
ids = json.loads(ids)
result = False
for id in ids:
work_type_request = WorkTypeRequest.objects.get(id=id)
if (
@@ -1809,7 +1818,8 @@ def work_type_request_bulk_cancel(request):
redirect="/",
icon="close",
)
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
result = True
return JsonResponse({"result": result})
@login_required
@@ -1855,6 +1865,7 @@ def work_type_request_bulk_approve(request):
"""
ids = request.POST["ids"]
ids = json.loads(ids)
result = False
for id in ids:
work_type_request = WorkTypeRequest.objects.get(id=id)
if (
@@ -1884,7 +1895,8 @@ def work_type_request_bulk_approve(request):
redirect="/",
icon="checkmark",
)
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
result = True
return JsonResponse({"result": result})
@login_required
@@ -1992,13 +2004,8 @@ def work_type_request_bulk_delete(request):
date=work_type_request.requested_date,
),
)
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
@login_required
def get_language_code(request):
language_code = request.LANGUAGE_CODE
return JsonResponse({"language_code": language_code})
result = True
return JsonResponse({"result": result})
@login_required
@@ -2179,6 +2186,7 @@ def shift_request_bulk_cancel(request):
"""
ids = request.POST["ids"]
ids = json.loads(ids)
result = False
for id in ids:
shift_request = ShiftRequest.objects.get(id=id)
if (
@@ -2206,7 +2214,8 @@ def shift_request_bulk_cancel(request):
redirect="/",
icon="close",
)
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
result = True
return JsonResponse({"result": result})
@login_required
@@ -2257,7 +2266,7 @@ def shift_request_bulk_approve(request):
"""
ids = request.POST["ids"]
ids = json.loads(ids)
result = False
for id in ids:
shift_request = ShiftRequest.objects.get(id=id)
if (
@@ -2275,7 +2284,7 @@ def shift_request_bulk_approve(request):
employee_work_info.shift_id = shift_request.shift_id
employee_work_info.save()
shift_request.save()
messages.success(request, _("Shift has been approved."))
messages.success(request, _("Shifts have been approved."))
notify.send(
request.user.employee_get,
recipient=shift_request.employee_id.employee_user_id,
@@ -2287,7 +2296,8 @@ def shift_request_bulk_approve(request):
redirect="/",
icon="checkmark",
)
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
result = True
return JsonResponse({"result": result})
@login_required
@@ -2304,7 +2314,6 @@ def shift_request_delete(request, id):
shift_request = ShiftRequest.objects.get(id=id)
user = shift_request.employee_id.employee_user_id
shift_request.delete()
messages.success(request, _("Shift request deleted."))
notify.send(
request.user.employee_get,
recipient=user,
@@ -2335,7 +2344,7 @@ def shift_request_bulk_delete(request):
"""
ids = request.POST["ids"]
ids = json.loads(ids)
result = False
for id in ids:
try:
shift_request = ShiftRequest.objects.get(id=id)
@@ -2364,8 +2373,8 @@ def shift_request_bulk_delete(request):
date=shift_request.requested_date,
),
)
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
result = True
return JsonResponse({"result": result})
@login_required

View File

@@ -0,0 +1,100 @@
var deleteMessages = {
ar: "هل تريد حقًا حذف جميع كشوف الدفع المحددة؟",
de: "Sind Sie sicher, dass Sie alle ausgewählten Gehaltsabrechnungen löschen möchten?",
es: "¿Realmente quieres eliminar todas las nóminas seleccionadas?",
en: "Do you really want to delete all the selected payslips?",
fr: "Voulez-vous vraiment supprimer tous les bulletins de paie 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.",
};
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;
}
}
}
return cookieValue;
}
function getCurrentLanguageCode(callback) {
$.ajax({
type: "GET",
url: "/employee/get-language-code/",
success: function (response) {
var languageCode = response.language_code;
callback(languageCode); // Pass the language code to the callback
},
});
}
$(".all-payslip").change(function (e) {
var is_checked = $(this).is(":checked");
if (is_checked) {
$(".all-payslip-row").prop("checked", true);
} else {
$(".all-payslip-row").prop("checked", false);
}
});
$("#DeletePayslipBulk").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = deleteMessages[languageCode];
var textMessage = norowMessages[languageCode];
var checkedRows = $(".all-payslip-row").filter(":checked");
ids = [];
checkedRows.each(function () {
ids.push($(this).attr("id"));
});
if (checkedRows.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) {
$.ajax({
type: "POST",
url: "/payroll/payslip-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);
}
},
});
}
});
}
});
});

View File

@@ -1,8 +1,23 @@
{% load i18n %}
{% load static i18n %}
<div class="oh-sticky-table">
<div class="oh-sticky-table__table oh-table--sortable">
<div class="oh-sticky-table__thead">
<div class="oh-sticky-table__tr">
<div class="oh-sticky-table__th" >
<div class="d-flex">
<div>
<input
type="checkbox"
class="all-payslip oh-input oh-input__checkbox mt-1 mr-2 "
id = "Allpayslip"
/>
</div>
<div>
{% trans "Employee" %}
</div>
</div>
</div>
<div class="oh-sticky-table__th">{% trans "Employee" %}</div>
<div class="oh-sticky-table__th">{% trans "Period" %}</div>
<div class="oh-sticky-table__th">{% trans "Status" %}</div>
@@ -16,6 +31,14 @@
{% for payslip in payslips %}
<div class="oh-sticky-table__tr" draggable="true">
<div class="oh-sticky-table__td">
<div class="d-flex">
<div>
<input
type="checkbox"
id="{{payslip.id}}"
class="oh-input payslip-checkbox oh-input__checkbox mt-2 mr-2 all-payslip-row"
/>
</div>
<div class="oh-profile oh-profile--md">
<div class="oh-profile__avatar mr-1">
<img
@@ -26,6 +49,7 @@
</div>
<span class="oh-profile__name oh-text--dark">{{payslip.employee_id}}</span>
</div>
</div>
</div>
<div class="oh-sticky-table__td">
@@ -103,5 +127,14 @@
</nav>
</div>
<script src="{% static 'payroll/action.js' %}"></script>
<script>
$("#Allpayslip").click(function (e) {
var is_checked = $(this).is(":checked");
if (is_checked) {
$(".all-payslip-row").prop("checked", true);
} else {
$(".all-payslip-row").prop("checked", false);
}
});
</script>

View File

@@ -114,7 +114,8 @@
</div>
</div>
{% endif %}
{% if perms.payroll.add_payslip %}
{% comment %} {% if perms.payroll.add_payslip %}
<div class="oh-main__titlebar-button-container">
<div class="oh-btn-group ml-2">
<div>
@@ -154,6 +155,70 @@
</div>
</div>
{% endif %}
{% if perms.payroll.add_payslip %}
<div class="oh-main__titlebar-button-container">
<div class="oh-btn-group ml-2">
<div>
<a
class="oh-btn oh-btn--secondary oh-btn--shadow"
id="DeletePayslipBulk"
>
<ion-icon
class="me-2 md hydrated" role="img"
aria-label="add outline" name="trash-outline"
></ion-icon
>{% trans "Delete" %}</a>
</div>
</div>
</div>
{% endif %} {% endcomment %}
{% if perms.payroll.add_payslip %}
<div class="oh-btn-group ml-2">
<div class="oh-dropdown" x-data="{open: false}">
<button
class="oh-btn oh-btn--dropdown "
@click="open = !open"
@click.outside="open = false"
>
{% trans "Actions" %}
</button>
<div class="oh-dropdown__menu oh-dropdown__menu--right" x-show="open" style="display: none; cursor:pointer;">
<ul class="oh-dropdown__items">
{% if perms.payroll.add_payslip %}
<li class="oh-dropdown__item">
<a
class="oh-dropdown__link"
data-toggle="oh-modal-toggle"
data-target="#individualPayslipModal"
>{% trans "Create" %}</a
>
</li>
{% endif %}
{% if perms.payroll.add_payslip %}
<li class="oh-dropdown__item">
<a
class="oh-dropdown__link"
data-toggle="oh-modal-toggle"
data-target="#bulkPayslipModal"
>{% trans "Generate" %}</a>
</li>
{% endif %}
{% if perms.payroll.add_payslip %}
<li class="oh-dropdown__item">
<a
class="oh-dropdown__link "
id="DeletePayslipBulk"
>{% trans "Delete" %}</a>
{% endif %}
</ul>
</div>
</div>
</div>
{% endif %}
</div>
</section>
<div id="payroll-payslip-container" class="oh-wrapper">

View File

@@ -65,13 +65,16 @@
>
</li>
<li class="oh-dropdown__item">
<a
onclick="event.stopPropagation()"
hx-post="{% url 'filing-status-delete' filing_status_id=filing_status.id %}"
hx-target="#FilingStatusList"
class="oh-dropdown__link oh-dropdown__link--danger"
>{% trans "Delete" %}</a
>
<form
action="{% url 'filing-status-delete' filing_status_id=filing_status.id %}"
onsubmit="return confirm('{% trans "Are you sure to delete this status ?" %}')"
method="post"
style="display: contents">
{% csrf_token %}
<button class="oh-dropdown__link oh-dropdown__link--danger">
{% trans 'Delete' %}
</button>
</form>
</li>
</ul>
</div>

View File

@@ -42,20 +42,16 @@
</div>
<div class="oh-sticky-table__td">
<div class="oh-btn-group">
<a
hx-post="{% url 'tax-bracket-delete' tax_bracket_id=tax_bracket.id%}"
data-toggle="oh-modal-toggle"
hx-target="#taxbracketList{{tax_bracket.filing_status_id.id}}"
class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
onclick="event.stopPropagation()"
>
<ion-icon
name="trash-outline"
role="img"
class="md hydrated"
aria-label="trash outline"
></ion-icon>
</a>
<form
action="{% url 'tax-bracket-delete' tax_bracket_id=tax_bracket.id%}"
onsubmit="return confirm('{% trans "Are you sure to delete this tax bracket ?" %}')"
method="post"
style="display: contents">
{% csrf_token %}
<button class="oh-btn oh-btn--danger-outline w-100" title="{% trans 'Delete' %}">
<ion-icon name="trash-outline" role="img" class="md hydrated" aria-label="trash outline"></ion-icon>
</button>
</form>
</div>
</div>
</div>

View File

@@ -89,4 +89,9 @@ urlpatterns = [
views.payslip_export,
name="dashboard-export",
),
path(
"payslip-bulk-delete",
views.payslip_bulk_delete,
name="payslip-bulk-delete",
),
]

View File

@@ -267,7 +267,7 @@ def delete_allowance(request, allowance_id):
"""
try:
payroll.models.models.Allowance.objects.get(id=allowance_id).delete()
messages.success(request, "Allowance deleted")
messages.success(request, "Allowance deleted successfully")
except ObjectDoesNotExist(Exception):
messages.error(request, "Allowance not found")
except ValidationError as validation_error:
@@ -361,13 +361,14 @@ def update_deduction(request, deduction_id):
@login_required
@permission_required("payroll.delete_deduction")
def delete_deduction(_request, deduction_id):
def delete_deduction(request, deduction_id):
"""
This method is used to delete the deduction instance
Args:
id : deduction instance id
"""
payroll.models.models.Deduction.objects.get(id=deduction_id).delete()
messages.success(request, "Deduction deleted successfully")
return redirect(view_deduction)

View File

@@ -10,7 +10,7 @@ django.shortcuts module.
"""
import math
from django.http import HttpResponse
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render, redirect
from django.contrib import messages
from horilla.decorators import permission_required, login_required
@@ -108,13 +108,10 @@ def filing_status_delete(request, filing_status_id):
filing_status = FilingStatus.objects.get(id=filing_status_id)
filing_status.delete()
messages.info(request, "Filing status successfully deleted.")
return HttpResponse("<script>window.location.reload()</script>")
except:
messages.error(request, "This filing status assigned to employees")
status = FilingStatus.objects.all()
context = {"status": status}
return render(request, "payroll/tax/filing_status_list.html", context)
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
@login_required
@@ -206,7 +203,7 @@ def update_tax_bracket(request, tax_bracket_id):
@login_required
@permission_required("payroll.delete_taxbracket")
def delete_tax_bracket(_request, tax_bracket_id):
def delete_tax_bracket(request, tax_bracket_id):
"""
Delete an existing tax bracket record.
@@ -217,9 +214,8 @@ def delete_tax_bracket(_request, tax_bracket_id):
"""
tax_bracket = TaxBracket.objects.get(id=tax_bracket_id)
tax_bracket.delete()
return redirect(
"tax-bracket-list", filing_status_id=tax_bracket.filing_status_id.id
)
messages.info(request, "Tax bracket successfully deleted.")
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
@login_required

View File

@@ -38,7 +38,6 @@ def get_language_code(request):
scale_x_text = _("Name of Employees")
scale_y_text = _("Amount")
response = {"scale_x_text": scale_x_text, "scale_y_text": scale_y_text}
print(response)
return JsonResponse(response)
@@ -853,3 +852,31 @@ def payslip_export(request):
writer.close()
return response
@login_required
@permission_required("payroll.delete_payslip")
def payslip_bulk_delete(request):
"""
This method is used to bulk delete for Payslip
"""
ids = request.POST["ids"]
ids = json.loads(ids)
for id in ids:
payslip = Payslip.objects.get(id=id)
period = f"{payslip.start_date} to {payslip.end_date}"
try:
payslip.delete()
messages.success(
request,
_("{employee} {period} payslip deleted.").format(
employee=payslip.employee_id, period=period
),
)
except Exception as e:
messages.error(
request,
_("You cannot delete {payslip}").format(payslip=payslip),
)
messages.error(request, e)
return JsonResponse({"message": "Success"})

View File

@@ -38,9 +38,38 @@
$temp.val(link).select();
document.execCommand("copy");
$temp.remove();
alert("Linke copied")
Swal.fire({
text: "Link copied",
icon: "success",
showConfirmButton: false,
timer: 3000, // Set the timer to 3000 milliseconds (3 seconds)
timerProgressBar: true, // Show a progress bar as the timer counts down
});
}
</script>
<!-- filter items showing here -->
<div class="oh-filter-tag-container "
style="position: fixed;top: 150px;z-index: 9999;">
{%for field,value in filter_dict.items %}
{%if value %}
<span class="oh-filter-tag filter-field" data-x-field="{{field}}" >{{field}}<button class="oh-filter-tag__close">
<ion-icon name="close-outline" role="img" class="md hydrated" aria-label="close outline"></ion-icon></button>
</span>
{%endif%}
{% endfor %}
</div>
<script>
var form_submit_id = 'recruitment-filter-form-submit'
$(document).ready(function () {
$('.filter-field').on('click',function(){
const field_id = $(this).attr("data-x-field")
$('#id_'+field_id).val('')
$('.'+form_submit_id).click()
})
});
</script>
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12">
<div class="oh-card p-4">
@@ -143,9 +172,15 @@
<a hx-get="{% url 'recruitment-update' rec.id %}" hx-target='#updateFormContainer' hx-swap='innerHTML' data-toggle='oh-modal-toggle' data-target='#updateRecruitmentModal' class="oh-btn oh-btn--light-bkg w-100" title="Edit"><ion-icon name="create-outline"></ion-icon></a>
{% endif %}
{% if perms.recruitment.delete_recruitment %}
<form action="{% url 'recruitment-delete' rec.id %}" onsubmit="return confirm(`{% trans 'Are you sure to delete this recruitment?' %})" method='post'>
<form
action="{% url 'recruitment-delete' rec.id %}"
onsubmit="return confirm('{% trans "Are you sure to delete this recruitment?" %}')"
method="post"
style="display: contents">
{% csrf_token %}
<button type='submit' class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" title="Remove"><ion-icon name="trash-outline"></ion-icon></button>
<button class="oh-btn oh-btn--danger-outline w-100" title="{% trans 'Delete' %}">
<ion-icon name="trash-outline" role="img" class="md hydrated" aria-label="trash outline"></ion-icon>
</button>
</form>
{% endif %}
</div>

View File

@@ -14,6 +14,7 @@
<link rel="apple-touch-icon" sizes="180x180" href="{% static 'favicons/apple-touch-icon.png' %}">
<link rel="icon" type="image/png" sizes="32x32" href="{% static 'favicons/favicon-32x32.png' %}">
<link rel="icon" type="image/png" sizes="16x16" href="{% static 'favicons/favicon-16x16.png' %}">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.20/dist/sweetalert2.min.css">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
@@ -89,12 +90,12 @@
<div class="oh-modal__dialog-body" id="confirmModalBody">
</div>
<div class="oh-modal__dialog-footer">
{% comment %} <div class="oh-modal__dialog-footer">
<button class="oh-btn oh-btn--success" id="ok">{% trans "Confirm" %}</button>
<button class="oh-btn oh-btn--danger oh-modal__cancel" id="cancel">
{% trans "Cancel" %}
</button>
</div>
</div> {% endcomment %}
</div>
</div>
<!-- End of Confirm Modal -->
@@ -235,6 +236,8 @@
<script src="{% static 'attendance/actions.js' %}"></script>
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
<script src="{% static '/build/js/sweetAlert.js' %}"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>