[UPDT] EMPLOYEE: Language code updations

This commit is contained in:
Horilla
2024-02-02 19:44:48 +05:30
parent fa3c2126e5
commit 1902e0b142
5 changed files with 456 additions and 422 deletions

View File

@@ -67,16 +67,20 @@ function getCookie(name) {
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
},
});
}
// function getCurrentLanguageCode(callback) {
// var language_code = $("#main-section-data").attr("data-lang");
// console.log("[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]");
// console.log(language_code);
// console.log("[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]");
// $.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-employee").change(function (e) {
var is_checked = $(this).is(":checked");
@@ -122,22 +126,19 @@ function addingIds() {
ids = makeListUnique(ids);
selectedCount = ids.length;
getCurrentLanguageCode(function (code) {
languageCode = code;
var message = rowMessages[languageCode];
$("#selectedInstances").attr("data-ids", JSON.stringify(ids));
if (selectedCount === 0) {
$("#selectedShow").css("display", "none");
$("#exportInstances").css("display", "none");
} else {
$("#exportInstances").css("display", "inline-flex");
$("#selectedShow").css("display", "inline-flex");
$("#selectedShow").text(selectedCount + " - " + message);
}
});
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) {
$("#selectedShow").css("display", "none");
$("#exportInstances").css("display", "none");
} else {
$("#exportInstances").css("display", "inline-flex");
$("#selectedShow").css("display", "inline-flex");
$("#selectedShow").text(selectedCount + " - " + message);
}
}
function tickCheckboxes() {
@@ -153,18 +154,18 @@ function tickCheckboxes() {
$("#" + id).prop("checked", true);
});
var selectedCount = uniqueIds.length;
getCurrentLanguageCode(function (code) {
languageCode = code;
var message = rowMessages[languageCode];
if (selectedCount > 0) {
$("#exportInstances").css("display", "inline-flex");
$("#selectedShow").css("display", "inline-flex");
$("#selectedShow").text(selectedCount + " -" + message);
} else {
$("#selectedShow").css("display", "none");
$("#exportInstances").css("display", "none");
}
});
languageCode = $("#main-section-data").attr("data-lang");
var message =
rowMessages[languageCode] ||
((languageCode = "en"), rowMessages[languageCode]);
if (selectedCount > 0) {
$("#exportInstances").css("display", "inline-flex");
$("#selectedShow").css("display", "inline-flex");
$("#selectedShow").text(selectedCount + " -" + message);
} else {
$("#selectedShow").css("display", "none");
$("#exportInstances").css("display", "none");
}
}
function selectAllInstances() {
@@ -284,229 +285,234 @@ function unselectAllInstances() {
$("#exportInstances").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"));
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = excelMessages[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: "/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));
}
});
$("#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: "question",
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: "GET",
url: "/employee/work-info-export",
type: "POST",
url: "/employee/employee-bulk-archive?is_active=False",
data: {
csrfmiddlewaretoken: getCookie("csrftoken"),
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);
success: function (response, textStatus, jqXHR) {
if (jqXHR.status === 200) {
location.reload(); // Reload the current page
} else {
// console.log("Unexpected HTTP status:", jqXHR.status);
}
},
});
}
});
});
});
$("#employeeBulkUpdateId").click(function (e) {
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var textMessage = 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));
}
});
});
$("#archiveEmployees").click(function (e) {
e.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = archiveMessages[languageCode];
var textMessage = noRowMessages[languageCode];
ids = [];
ids.push($("#selectedInstances").attr("data-ids"));
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
if (ids.length === 0) {
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;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = unarchiveMessages[languageCode];
var textMessage = noRowMessages[languageCode];
ids = [];
ids.push($("#selectedInstances").attr("data-ids"));
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
if (ids.length === 0) {
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();
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 = [];
ids.push($("#selectedInstances").attr("data-ids"));
ids = JSON.parse($("#selectedInstances").attr("data-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);
}
},
});
}
});
}
});
$.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;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirmMessage = deleteMessages[languageCode];
var textMessage = noRowMessages[languageCode];
ids = [];
ids.push($("#selectedInstances").attr("data-ids"));
ids = JSON.parse($("#selectedInstances").attr("data-ids"));
if (ids.length === 0) {
Swal.fire({
text: textMessage,
icon: "warning",
confirmButtonText: "Close",
});
} else {
Swal.fire({
text: confirmMessage,
icon: "error",
showCancelButton: true,
confirmButtonColor: "#008000",
cancelButtonColor: "#d33",
confirmButtonText: "Confirm",
}).then(function (result) {
if (result.isConfirmed) {
e.preventDefault();
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"));
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);
}
},
});
}
});
}
});
$.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 () {

View File

@@ -6,23 +6,23 @@ var downloadMessages = {
fr: "Voulez-vous télécharger le modèle ?",
};
var importsuccess = {
ar: "نجح الاستيراد", // Arabic
de: "Import erfolgreich", // German
es: "Importado con éxito", // Spanish
en: "Imported Successfully!", // English
fr: "Importation réussie" // French
var importSuccess = {
ar: "نجح الاستيراد",
de: "Import erfolgreich",
es: "Importado con éxito",
en: "Imported Successfully!",
fr: "Importation réussie",
};
var uploadsuccess = {
ar: "تحميل كامل", // Arabic
de: "Upload abgeschlossen", // German
es: "Carga completa", // Spanish
en: "Upload Complete!", // English
fr: "Téléchargement terminé" // French
var uploadSuccess = {
ar: "تحميل كامل",
de: "Upload abgeschlossen",
es: "Carga completa",
en: "Upload Complete!",
fr: "Téléchargement terminé",
};
var uploadingmessage = {
var uploadingMessage = {
ar: "جارٍ الرفع",
de: "Hochladen...",
es: "Subiendo...",
@@ -30,7 +30,7 @@ var uploadingmessage = {
fr: "Téléchargement en cours...",
};
var validationmessage = {
var validationMessage = {
ar: "يرجى تحميل ملف بامتداد .xlsx فقط.",
de: "Bitte laden Sie nur eine Datei mit der Erweiterung .xlsx hoch.",
es: "Por favor, suba un archivo con la extensión .xlsx solamente.",
@@ -40,16 +40,16 @@ var validationmessage = {
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;
}
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;
}
@@ -65,7 +65,6 @@ function getCurrentLanguageCode(callback) {
});
}
// Get the form element
var form = document.getElementById("workInfoImportForm");
@@ -88,7 +87,7 @@ form.addEventListener("submit", function (event) {
processData: false,
contentType: false,
headers: {
"X-CSRFToken": getCookie('csrftoken'), // Replace with your csrf token value
"X-CSRFToken": getCookie("csrftoken"), // Replace with your csrf token value
},
xhrFields: {
responseType: "blob",
@@ -110,58 +109,58 @@ form.addEventListener("submit", function (event) {
});
});
$("#work-info-import").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) {
languageCode = $("#main-section-data").attr("data-lang");
var confirmMessage =
downloadMessages[languageCode] ||
((languageCode = "en"), downloadMessages[languageCode]);
Swal.fire({
text: confirmMessage,
icon: "question",
showCancelButton: true,
confirmButtonColor: "#008000",
cancelButtonColor: "#d33",
confirmButtonText: "Confirm",
}).then(function (result) {
if (result.isConfirmed) {
$("#loading").show();
$("#loading").show();
var xhr = new XMLHttpRequest();
xhr.open("GET", "/employee/work-info-import", true);
xhr.responseType = "arraybuffer";
var xhr = new XMLHttpRequest();
xhr.open('GET', '/employee/work-info-import', true);
xhr.responseType = 'arraybuffer';
xhr.upload.onprogress = function (e) {
if (e.lengthComputable) {
var percent = (e.loaded / e.total) * 100;
$(".progress-bar")
.width(percent + "%")
.attr("aria-valuenow", percent);
$("#progress-text").text("Uploading... " + percent.toFixed(2) + "%");
}
};
xhr.upload.onprogress = function (e) {
if (e.lengthComputable) {
var percent = (e.loaded / e.total) * 100;
$(".progress-bar").width(percent + "%").attr("aria-valuenow", percent);
$("#progress-text").text("Uploading... " + percent.toFixed(2) + "%");
}
};
xhr.onload = function (e) {
if (this.status == 200) {
const file = new Blob([this.response], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
const url = URL.createObjectURL(file);
const link = document.createElement("a");
link.href = url;
link.download = "work_info_template.xlsx";
document.body.appendChild(link);
link.click();
}
};
xhr.onload = function (e) {
if (this.status == 200) {
const file = new Blob([this.response], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
const url = URL.createObjectURL(file);
const link = document.createElement("a");
link.href = url;
link.download = "work_info_template.xlsx";
document.body.appendChild(link);
link.click();
}
};
xhr.onerror = function (e) {
console.error("Error downloading file:", e);
};
xhr.onerror = function (e) {
console.error("Error downloading file:", e);
};
xhr.send();
}
});
xhr.send();
}
});
});
@@ -175,21 +174,26 @@ $(document).ajaxStop(function () {
function simulateProgress() {
var languageCode = null;
getCurrentLanguageCode(function(code){
languageCode = code;
var importMessage = importsuccess[languageCode];
var uploadMessage = uploadsuccess[languageCode];
var uploadingMessage = uploadingmessage[languageCode];
let progressBar = document.querySelector('.progress-bar');
let progressText = document.getElementById('progress-text');
languageCode = $("#main-section-data").attr("data-lang");
var importMessage =
importSuccess[languageCode] ||
((languageCode = "en"), importSuccess[languageCode]);
var uploadMessage =
uploadSuccess[languageCode] ||
((languageCode = "en"), uploadSuccess[languageCode]);
var uploadingMessage =
uploadingMessage[languageCode] ||
((languageCode = "en"), uploadingMessage[languageCode]);
let progressBar = document.querySelector(".progress-bar");
let progressText = document.getElementById("progress-text");
let width = 0;
let interval = setInterval(function() {
let interval = setInterval(function () {
if (width >= 100) {
clearInterval(interval);
progressText.innerText = uploadMessage;
setTimeout(function() {
document.getElementById('loading').style.display = 'none';
setTimeout(function () {
document.getElementById("loading").style.display = "none";
}, 3000);
Swal.fire({
text: importMessage,
@@ -198,54 +202,49 @@ function simulateProgress() {
timer: 2000,
timerProgressBar: true,
});
setTimeout(function() {
$('#workInfoImport').removeClass('oh-modal--show');
setTimeout(function () {
$("#workInfoImport").removeClass("oh-modal--show");
location.reload(true);
}, 2000);
} else {
width++;
progressBar.style.width = width + '%';
progressBar.setAttribute('aria-valuenow', width);
progressText.innerText = uploadingMessage + width + '%';
progressBar.style.width = width + "%";
progressBar.setAttribute("aria-valuenow", width);
progressText.innerText = uploadingMessage + width + "%";
}
}, 20);
}
)}
document.getElementById('workInfoImportForm').addEventListener('submit', function(event) {
event.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function(code){
languageCode = code;
var erroMessage = validationmessage[languageCode];
document
.getElementById("workInfoImportForm")
.addEventListener("submit", function (event) {
event.preventDefault();
var languageCode = null;
languageCode = $("#main-section-data").attr("data-lang");
var errorMessage =
validationMessage[languageCode] ||
((languageCode = "en"), validationMessage[languageCode]);
var fileInput = $("#workInfoImportFile").val();
var allowedExtensions = /(\.xlsx)$/i;
var fileInput = $('#workInfoImportFile').val();
var allowedExtensions = /(\.xlsx)$/i;
if (!allowedExtensions.exec(fileInput)) {
var errorMessage = document.createElement("div");
errorMessage.classList.add("error-message");
if (!allowedExtensions.exec(fileInput)) {
errorMessage.textContent = errorMessage;
var errorMessage = document.createElement('div');
errorMessage.classList.add('error-message');
errorMessage.textContent = erroMessage;
document.getElementById("error-container").appendChild(errorMessage);
document.getElementById('error-container').appendChild(errorMessage);
fileInput.value = "";
fileInput.value = '';
setTimeout(function() {
errorMessage.remove();
}, 2000);
setTimeout(function () {
errorMessage.remove();
}, 2000);
return false;
}
else{
return false;
} else {
document.getElementById("loading").style.display = "block";
document.getElementById('loading').style.display = 'block';
simulateProgress();
}
});
})
simulateProgress();
}
});

View File

@@ -104,7 +104,7 @@
role="dialog"
aria-labelledby="employeeExport"
aria-hidden="true"
>
>
<div class="oh-modal__dialog" style="max-width: 750px">
<div class="oh-modal__dialog-header">
<h2 class="oh-modal__dialog-title" id="employeeExportLavel">
@@ -153,8 +153,7 @@
onsubmit="event.stopPropagation();$(this).parents().find('.oh-modal--show').last().toggleClass('oh-modal--show');"
id="bulkUpdateModalForm"
>
{% csrf_token %}
{{update_fields_form.update_fields.label}}
{% csrf_token %} {{update_fields_form.update_fields.label}}
{{update_fields_form.update_fields}}
{{update_fields_form.bulk_employee_ids}}
<div class="oh-dropdown__filter-footer">
@@ -196,12 +195,12 @@
id="filterForm"
hx-target="#view-container"
class="d-flex"
>
>
{% if emp %}
<div
class="oh-input-group oh-input__search-group"
:class="searchShow ? 'oh-input__search-group--show' : ''"
>
>
<ion-icon
name="search-outline"
class="oh-input-group__icon oh-input-group__icon--left"
@@ -215,15 +214,41 @@
class="oh-input oh-input__icon"
aria-label="Search Input"
/>
<div id="searchFieldDiv" style="display:none;">
<select name="search_field" class='oh-input__icon' style="border: none; display: flex; position: absolute; z-index: 999; margin-left:8%;" size="3" onclick="$('.filterButton')[0].click();">
<option style="margin-left: -10px;" value="reporting_manager">{% trans "Search in : Reporting Manager" %}</option>
<option style="margin-left: -10px;" value="department">{% trans "Search in : Department" %}</option>
<option style="margin-left: -10px;" value="job_position">{% trans "Search in : Job Position" %}</option>
<option style="margin-left: -10px;" value="job_role">{% trans "Search in : Job Role" %}</option>
<option style="margin-left: -10px;" value="shift">{% trans "Search in : Shift" %}</option>
<option style="margin-left: -10px;" value="work_type">{% trans "Search in : Work Type" %}</option>
<option style="margin-left: -10px;" value="company">{% trans "Search in : Company" %}</option>
<div id="searchFieldDiv" style="display: none">
<select
name="search_field"
class="oh-input__icon"
style="
border: none;
display: flex;
position: absolute;
z-index: 999;
margin-left: 8%;
"
size="3"
onclick="$('.filterButton')[0].click();"
>
<option style="margin-left: -10px" value="reporting_manager">
{% trans "Search in : Reporting Manager" %}
</option>
<option style="margin-left: -10px" value="department">
{% trans "Search in : Department" %}
</option>
<option style="margin-left: -10px" value="job_position">
{% trans "Search in : Job Position" %}
</option>
<option style="margin-left: -10px" value="job_role">
{% trans "Search in : Job Role" %}
</option>
<option style="margin-left: -10px" value="shift">
{% trans "Search in : Shift" %}
</option>
<option style="margin-left: -10px" value="work_type">
{% trans "Search in : Work Type" %}
</option>
<option style="margin-left: -10px" value="company">
{% trans "Search in : Company" %}
</option>
</select>
</div>
</div>
@@ -231,7 +256,12 @@
<div class="oh-main__titlebar-button-container">
{% if emp %}
<input type="hidden" name="view" value="{{request.GET.view}}" id="employeeViewType">
<input
type="hidden"
name="view"
value="{{request.GET.view}}"
id="employeeViewType"
/>
<ul class="oh-view-types ml-2" style="margin-bottom: 0">
<li class="oh-view-type employee-view-type" data-view="list">
<a
@@ -262,7 +292,7 @@
class="oh-btn ml-2"
@click="open = !open"
onclick="event.preventDefault()"
>
>
<ion-icon name="filter" class="mr-1"></ion-icon>{% trans "Filter" %}
<div id="filterCount"></div>
</button>
@@ -271,14 +301,14 @@
x-show="open"
@click.outside="open = false"
style="display: none"
>
>
{% include 'employee_filters.html' %}
<div class="oh-dropdown__filter-footer">
<button
class="oh-btn oh-btn--secondary oh-btn--small w-100 filterButton"
id="#employeeFilter"
onclick="employeeFilter(this)"
>
>
{% trans "Filter" %}
</button>
</div>
@@ -289,9 +319,9 @@
class="oh-btn ml-2"
@click="open = !open"
onclick="event.preventDefault()"
>
>
<ion-icon name="library-outline" class="mr-1"></ion-icon>
{% trans "Group By" %}
{% trans "Group By" %}
<div id="filterCount"></div>
</button>
<div
@@ -299,13 +329,15 @@
x-show="open"
@click.outside="open = false"
style="display: none"
>
>
<div class="oh-accordion">
<label for="id_field">{% trans "Group By" %}</label>
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label" for="id_field">{% trans "Field" %}</label>
<label class="oh-label" for="id_field"
>{% trans "Field" %}</label
>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
@@ -315,7 +347,7 @@
id="id_field"
name="field"
class="select2-selection select2-selection--single"
>
>
{% for field in gp_fields %}
<option value="{{ field.0 }}">{% trans field.1 %}</option>
{% endfor %}
@@ -327,20 +359,20 @@
</div>
</div>
{% endif %}
<div class="oh-btn-group ml-2">
<div class="oh-btn-group ml-2" onclick="event.preventDefault();">
<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"
>
>
<ul class="oh-dropdown__items">
<li class="oh-dropdown__item">
<a
@@ -349,7 +381,7 @@
id="work-info-import"
data-toggle="oh-modal-toggle"
data-target="#workInfoImport"
>
>
{% trans "Import" %}
</a>
</li>
@@ -361,7 +393,7 @@
id="employee-info-export"
data-toggle="oh-modal-toggle"
data-target="#employeeExport"
>
>
{% trans "Export" %}
</a>
</li>
@@ -382,7 +414,7 @@
id="employeeBulkUpdateId"
data-toggle="oh-modal-toggle"
data-target="#bulkUpdateModal"
>
>
{% trans "Bulk Update" %}
</a>
</li>
@@ -419,7 +451,7 @@
</div>
</section>
<script>
function clearFilterFromTag(element) {
function clearFilterFromTag(element) {
let field_id = element.attr("data-x-field");
$(`[name=${field_id}]`).val("");
$(`[name=${field_id}]`).change();
@@ -463,16 +495,16 @@
return value;
}
$(document).ready(function () {
$('#employee-search').on('keyup', function () {
var searchFieldDiv = $('#searchFieldDiv');
var selectedField = searchFieldDiv.find(':selected');
if ($(this).val().trim() !== '') {
searchFieldDiv.show();
$("#employee-search").on("keyup", function () {
var searchFieldDiv = $("#searchFieldDiv");
var selectedField = searchFieldDiv.find(":selected");
if ($(this).val().trim() !== "") {
searchFieldDiv.show();
} else {
searchFieldDiv.hide();
selectedField.prop('selected', false);
searchFieldDiv.hide();
selectedField.prop("selected", false);
}
$('.filterButton').eq(0).click();
$(".filterButton").eq(0).click();
});
$("#id_field").on("change", function () {
$(".filterButton")[0].click();
@@ -483,7 +515,12 @@
formData.split("&").forEach(function (field) {
var parts = field.split("=");
var value = parts[1];
if (value && value !== "unknown" && parts[0] != 'field' && parts[0] != 'view') {
if (
value &&
value !== "unknown" &&
parts[0] != "field" &&
parts[0] != "view"
) {
count++;
}
});
@@ -492,7 +529,7 @@
$("#filterCount").text(`(${count})`);
}
}
$("#filterForm").submit(function (e) {
filterFormSubmit("filterForm");
});

View File

@@ -30,55 +30,47 @@ function getCookie(name) {
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
},
});
}
var originalConfirm = window.confirm;
// Override the default confirm function with SweetAlert
window.confirm = function(message) {
window.confirm = function (message) {
var event = window.event || {};
event.preventDefault();
var languageCode = null;
getCurrentLanguageCode(function (code) {
languageCode = code;
var confirm = confirmModal[languageCode];
var cancel = cancelModal[languageCode];
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') {
event.target.submit();
}
else if (event.target.tagName.toLowerCase() === 'a') {
window.location.href = event.target.href;
}
}
else {
$("#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") {
event.target.submit();
} else if (event.target.tagName.toLowerCase() === "a") {
window.location.href = event.target.href;
}
})
} else {
}
});
};
var nav = $("section.oh-wrapper.oh-main__topbar");
nav.after($(
`
nav.after(
$(
`
<div id="filterTagContainerSectionNav" class="oh-titlebar-container__filters mb-2 mt-0 oh-wrapper"></div>
`
))
)
);

View File

@@ -590,7 +590,7 @@
<div id='main-section' >
<div id="tripple-loader-contaner" class="d-flex justify-content-center align-items-center tripple-loader-contaner--visible" style="height:90vh;"><div class="triple-spinner"></div></div>
<div id="main-section-data" style="display: none;">
<div id="main-section-data" style="display: none;" data-lang="{{LANGUAGE_CODE}}">
{% block content %}
{% include 'dashboard.html' %}
{% endblock content %}