From 33c7a7ef4fc9f273cbf3a04a8b8a31a9d3bb80b0 Mon Sep 17 00:00:00 2001 From: Horilla Date: Tue, 6 Feb 2024 12:50:53 +0530 Subject: [PATCH] [UPDT] ATTENDANCE: Attendance getCurrentLanguageCode function to check and retrieve language code from HTML attribute --- attendance/static/attendance/actions.js | 64 +++++++++++-------- .../late_come_early_out/export_filter.html | 50 +++++++-------- .../late_come_early_out_filters.html | 52 +++++++-------- .../attendance/late_come_early_out/nav.html | 4 +- .../late_come_early_out/report_list.html | 2 +- 5 files changed, 91 insertions(+), 81 deletions(-) diff --git a/attendance/static/attendance/actions.js b/attendance/static/attendance/actions.js index cd67d91fc..b58c2a520 100644 --- a/attendance/static/attendance/actions.js +++ b/attendance/static/attendance/actions.js @@ -77,15 +77,30 @@ function makelatecomeListUnique(list) { } 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 - }, - }); + 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"); + }, + }); + } } + $(".validate").change(function (e) { var is_checked = $(this).is(":checked"); if (is_checked) { @@ -245,8 +260,6 @@ function selectAllHourAcconts() { type: "GET", dataType: "json", success: function (response) { - console.log(response); - var employeeIds = response.employee_ids; if (Array.isArray(employeeIds)) { @@ -497,8 +510,6 @@ function selectAllActivity() { type: "GET", dataType: "json", success: function (response) { - console.log(response); - var employeeIds = response.employee_ids; if (Array.isArray(employeeIds)) { @@ -749,13 +760,15 @@ $(".all-latecome").change(function () { }); $(".all-attendance-activity").change(function () { - $(".all-attendance-activity-row").prop("checked",false) + $(".all-attendance-activity-row") + .prop("checked", false) .closest(".oh-sticky-table__tr") .removeClass("highlight-selected"); if ($(this).is(":checked")) { - $(".all-attendance-activity-row").prop("checked",true) - .closest(".oh-sticky-table__tr") - .addClass("highlight-selected"); + $(".all-attendance-activity-row") + .prop("checked", true) + .closest(".oh-sticky-table__tr") + .addClass("highlight-selected"); } }); @@ -1252,41 +1265,38 @@ $("#lateComeBulkDelete").click(function (e) { // Iterate through all elements with the 'dateformat_changer' class and format their content -$('.dateformat_changer').each(function(index, element) { +$(".dateformat_changer").each(function (index, element) { var currentDate = $(element).text(); // Checking currentDate value is a date or None value. if (/[\.,\-\/]/.test(currentDate)) { var formattedDate = dateFormatter.getFormattedDate(currentDate); - } - else { - var formattedDate = 'None'; + } else { + var formattedDate = "None"; } $(element).text(formattedDate); }); // Display the formatted date wherever needed -var currentDate = $('.dateformat_changer').first().text(); +var currentDate = $(".dateformat_changer").first().text(); var formattedDate = dateFormatter.getFormattedDate(currentDate); - // ****************************************************************** // * THIS IS FOR SWITCHING THE TIME FORMAT IN THE ALL VIEWS * // ****************************************************************** // Iterate through all elements with the 'timeformat_changer' class and format their content -$('.timeformat_changer').each(function(index, element) { +$(".timeformat_changer").each(function (index, element) { var currentTime = $(element).text(); // Checking currentTime value is a valid time. if (/[\.:]/.test(currentTime)) { - var formattedTime = timeFormatter.getFormattedTime(currentTime); + var formattedTime = timeFormatter.getFormattedTime(currentTime); } else { - var formattedTime = 'None'; + var formattedTime = "None"; } $(element).text(formattedTime); - }); // Display the formatted time wherever needed -var currentTime = $('.timeformat_changer').first().text(); +var currentTime = $(".timeformat_changer").first().text(); var formattedTime = timeFormatter.getFormattedTime(currentTime); diff --git a/attendance/templates/attendance/late_come_early_out/export_filter.html b/attendance/templates/attendance/late_come_early_out/export_filter.html index 522beba8a..b880a390d 100644 --- a/attendance/templates/attendance/late_come_early_out/export_filter.html +++ b/attendance/templates/attendance/late_come_early_out/export_filter.html @@ -29,37 +29,37 @@
- + {{export.form.employee_id}}
- + {{export.form.employee_id__employee_work_info__department_id}}
- + {{export.form.attendance_id__shift_id}}
- + {{export.form.employee_id__employee_work_info__reporting_manager_id}}
- + {{export.form.employee_id__employee_work_info__company_id}}
- + {{export.form.employee_id__employee_work_info__job_position_id}}
- + {{export.form.attendance_id__work_type_id}}
- + {{export.form.employee_id__employee_work_info__location}}
@@ -72,33 +72,33 @@
- + {{export.form.type}}
- + {{export.form.attendance_date}}
- + {{export.form.attendance_clock_out}}
- + {{export.form.attendance_id__attendance_validated}}
- + {{export.form.attendance_id__minimum_hour}}
- + {{export.form.attendance_clock_in}}
- + {{export.form.attendance_id__attendance_overtime_approve}}
@@ -111,49 +111,49 @@
- + {{export.form.attendance_date__gte}}
- + {{export.form.attendance_clock_in__gte}}
- + {{export.form.attendance_clock_out__gte}}
- {{export.form.at_work_second__gte}}
- + {{export.form.overtime_second__gte}}
- + {{export.form.attendance_date__lte}}
- + {{export.form.attendance_clock_in__lte}}
- + {{export.form.attendance_clock_out__lte}}
- {{export.form.at_work_second__lte}}
- + {{export.form.overtime_second__lte}}
diff --git a/attendance/templates/attendance/late_come_early_out/late_come_early_out_filters.html b/attendance/templates/attendance/late_come_early_out/late_come_early_out_filters.html index e2d229def..a21175ca2 100644 --- a/attendance/templates/attendance/late_come_early_out/late_come_early_out_filters.html +++ b/attendance/templates/attendance/late_come_early_out/late_come_early_out_filters.html @@ -7,19 +7,19 @@
- + {{f.form.employee_id}}
- + {{f.form.employee_id__employee_work_info__department_id}}
- + {{f.form.attendance_id__shift_id}}
- + {{f.form.employee_id__employee_work_info__reporting_manager_id}}
@@ -27,19 +27,19 @@
- + {{f.form.employee_id__employee_work_info__company_id}}
- + {{f.form.employee_id__employee_work_info__job_position_id}}
- + {{f.form.attendance_id__work_type_id}}
- + {{f.form.employee_id__employee_work_info__location}}
@@ -53,33 +53,33 @@
- + {{f.form.type}}
- + {{f.form.attendance_date}}
- + {{f.form.attendance_clock_out}}
- + {{f.form.attendance_id__attendance_validated}}
- + {{f.form.attendance_id__minimum_hour}}
- + {{f.form.attendance_clock_in}}
- + {{f.form.attendance_id__attendance_overtime_approve}}
@@ -92,46 +92,46 @@
- + {{f.form.attendance_date__gte}}
- + {{f.form.attendance_clock_in__gte}}
- + {{f.form.attendance_clock_out__gte}}
- + {{f.form.at_work_second__gte}}
- + {{f.form.overtime_second__gte}}
- + {{f.form.attendance_date__lte}}
- + {{f.form.attendance_clock_in__lte}}
- + {{f.form.attendance_clock_out__lte}}
- + {{f.form.at_work_second__lte}}
- - {{f.form.overtime_second__gte}} + + {{f.form.overtime_second__lte}}
diff --git a/attendance/templates/attendance/late_come_early_out/nav.html b/attendance/templates/attendance/late_come_early_out/nav.html index 1bc8891e3..ada4b14f1 100644 --- a/attendance/templates/attendance/late_come_early_out/nav.html +++ b/attendance/templates/attendance/late_come_early_out/nav.html @@ -97,11 +97,11 @@ style="display: none" >
- +
- +
diff --git a/attendance/templates/attendance/late_come_early_out/report_list.html b/attendance/templates/attendance/late_come_early_out/report_list.html index e93b0cf2a..31b8d5478 100644 --- a/attendance/templates/attendance/late_come_early_out/report_list.html +++ b/attendance/templates/attendance/late_come_early_out/report_list.html @@ -19,7 +19,7 @@
- +
{% trans "Employee" %}