[UPDT] ATTENDANCE: Attendance getCurrentLanguageCode function to check and retrieve language code from HTML attribute

This commit is contained in:
Horilla
2024-02-06 12:50:53 +05:30
parent 58e4783dbf
commit 33c7a7ef4f
5 changed files with 91 additions and 81 deletions

View File

@@ -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);

View File

@@ -29,37 +29,37 @@
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Employee" %}</label>
<label class="oh-label" for="{{export.form.employee_id.id_for_label}}">{% trans "Employee" %}</label>
{{export.form.employee_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Department" %}</label>
<label class="oh-label" for="{{export.form.employee_id__employee_work_info__department_id.id_for_label}}">{% trans "Department" %}</label>
{{export.form.employee_id__employee_work_info__department_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Shift" %}</label>
<label class="oh-label" for="{{export.form.attendance_id__shift_id.id_for_label}}">{% trans "Shift" %}</label>
{{export.form.attendance_id__shift_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Reporting Manager" %}</label>
<label class="oh-label" for="{{export.form.employee_id__employee_work_info__reporting_manager_id.id_for_label}}">{% trans "Reporting Manager" %}</label>
{{export.form.employee_id__employee_work_info__reporting_manager_id}}
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Company" %}</label>
<label class="oh-label" for="{{export.form.employee_id__employee_work_info__company_id.id_for_label}}">{% trans "Company" %}</label>
{{export.form.employee_id__employee_work_info__company_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Job Position" %}</label>
<label class="oh-label" for="{{export.form.employee_id__employee_work_info__job_position_id.id_for_label}}">{% trans "Job Position" %}</label>
{{export.form.employee_id__employee_work_info__job_position_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Work Type" %}</label>
<label class="oh-label" for="{{export.form.attendance_id__work_type_id.id_for_label}}">{% trans "Work Type" %}</label>
{{export.form.attendance_id__work_type_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Work Location" %}</label>
<label class="oh-label" for="{{export.form.employee_id__employee_work_info__location.id_for_label}}">{% trans "Work Location" %}</label>
{{export.form.employee_id__employee_work_info__location}}
</div>
</div>
@@ -72,33 +72,33 @@
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Type" %}</label>
<label class="oh-label" for="{{export.form.type.id_for_label}}">{% trans "Type" %}</label>
{{export.form.type}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Attendance Date" %}</label>
<label class="oh-label" for="{{export.form.attendance_date.id_for_label}}">{% trans "Attendance Date" %}</label>
{{export.form.attendance_date}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Out Time" %}</label>
<label class="oh-label" for="{{export.form.attendance_clock_out.id_for_label}}">{% trans "Out Time" %}</label>
{{export.form.attendance_clock_out}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Validated?" %}</label>
<label class="oh-label" for="{{export.form.attendance_id__attendance_validated.id_for_label}}">{% trans "Validated?" %}</label>
{{export.form.attendance_id__attendance_validated}}
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Min Hour" %}</label>
<label class="oh-label" for="{{export.form.attendance_id__minimum_hour.id_for_label}}">{% trans "Min Hour" %}</label>
{{export.form.attendance_id__minimum_hour}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "In Time" %}</label>
<label class="oh-label" for="{{export.form.attendance_clock_in.id_for_label}}">{% trans "In Time" %}</label>
{{export.form.attendance_clock_in}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "OT Approved?" %}</label>
<label class="oh-label" for="{{export.form.attendance_id__attendance_overtime_approve.id_for_label}}">{% trans "OT Approved?" %}</label>
{{export.form.attendance_id__attendance_overtime_approve}}
</div>
</div>
@@ -111,49 +111,49 @@
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Attendance From" %}</label>
<label class="oh-label" for="{{export.form.attendance_date__gte.id_for_label}}">{% trans "Attendance From" %}</label>
{{export.form.attendance_date__gte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "In From" %}</label>
<label class="oh-label" for="{{export.form.attendance_clock_in__gte.id_for_label}}">{% trans "In From" %}</label>
{{export.form.attendance_clock_in__gte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Out From" %}</label>
<label class="oh-label" for="{{export.form.attendance_clock_out__gte.id_for_label}}">{% trans "Out From" %}</label>
{{export.form.attendance_clock_out__gte}}
</div>
<div class="oh-input-group">
<label class="oh-label"
<label class="oh-label" for="{{export.form.at_work_second__gte.id_for_label}}"
>{% trans "At Work Greater or Equal" %}</label
>
{{export.form.at_work_second__gte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "OT Greater or Equal" %}</label>
<label class="oh-label" for="{{export.form.overtime_second__gte.id_for_label}}">{% trans "OT Greater or Equal" %}</label>
{{export.form.overtime_second__gte}}
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Attendance Till" %}</label>
<label class="oh-label" for="{{export.form.attendance_date__lte.id_for_label}}">{% trans "Attendance Till" %}</label>
{{export.form.attendance_date__lte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "In Till" %}</label>
<label class="oh-label" for="{{export.form.attendance_clock_in__lte.id_for_label}}">{% trans "In Till" %}</label>
{{export.form.attendance_clock_in__lte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Out Till" %}</label>
<label class="oh-label" for="{{export.form.attendance_clock_out__lte.id_for_label}}">{% trans "Out Till" %}</label>
{{export.form.attendance_clock_out__lte}}
</div>
<div class="oh-input-group">
<label class="oh-label"
<label class="oh-label" for="{{export.form.at_work_second__lte.id_for_label}}"
>{% trans "At Work Less Than or Equal" %}</label
>
{{export.form.at_work_second__lte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "OT Less Than or Equal" %}</label>
<label class="oh-label" for="{{export.form.overtime_second__lte.id_for_label}}">{% trans "OT Less Than or Equal" %}</label>
{{export.form.overtime_second__lte}}
</div>
</div>

View File

@@ -7,19 +7,19 @@
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Employee" %}</label>
<label class="oh-label" for="{{f.form.employee_id.id_for_label}}">{% trans "Employee" %}</label>
{{f.form.employee_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Department" %}</label>
<label class="oh-label" for="{{f.form.employee_id__employee_work_info__department_id.id_for_label}}">{% trans "Department" %}</label>
{{f.form.employee_id__employee_work_info__department_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Shift" %}</label>
<label class="oh-label" for="{{f.form.attendance_id__shift_id.id_for_label}}">{% trans "Shift" %}</label>
{{f.form.attendance_id__shift_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Reporting Manager" %}</label>
<label class="oh-label" for="{{f.form.employee_id__employee_work_info__reporting_manager_id.id_for_label}}">{% trans "Reporting Manager" %}</label>
{{f.form.employee_id__employee_work_info__reporting_manager_id}}
</div>
@@ -27,19 +27,19 @@
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Company" %}</label>
<label class="oh-label" for="{{f.form.employee_id__employee_work_info__company_id.id_for_label}}">{% trans "Company" %}</label>
{{f.form.employee_id__employee_work_info__company_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Job Position" %}</label>
<label class="oh-label" for="{{f.form.employee_id__employee_work_info__job_position_id.id_for_label}}">{% trans "Job Position" %}</label>
{{f.form.employee_id__employee_work_info__job_position_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Work Type" %}</label>
<label class="oh-label" for="{{f.form.attendance_id__work_type_id.id_for_label}}">{% trans "Work Type" %}</label>
{{f.form.attendance_id__work_type_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Work Location" %}</label>
<label class="oh-label" for="{{f.form.employee_id__employee_work_info__location.id_for_label}}">{% trans "Work Location" %}</label>
{{f.form.employee_id__employee_work_info__location}}
</div>
</div>
@@ -53,33 +53,33 @@
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Type" %}</label>
<label class="oh-label" for="{{f.form.type.id_for_label}}">{% trans "Type" %}</label>
{{f.form.type}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Attendance Date" %}</label>
<label class="oh-label" for="{{f.form.attendance_date.id_for_label}}">{% trans "Attendance Date" %}</label>
{{f.form.attendance_date}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Out Time" %}</label>
<label class="oh-label" for="{{f.form.attendance_clock_out.id_for_label}}">{% trans "Out Time" %}</label>
{{f.form.attendance_clock_out}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Validated?" %}</label>
<label class="oh-label" for="{{f.form.attendance_id__attendance_validated.id_for_label}}">{% trans "Validated?" %}</label>
{{f.form.attendance_id__attendance_validated}}
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Min Hour" %}</label>
<label class="oh-label" for="{{f.form.attendance_id__minimum_hour.id_for_label}}">{% trans "Min Hour" %}</label>
{{f.form.attendance_id__minimum_hour}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "In Time" %}</label>
<label class="oh-label" for="{{f.form.attendance_clock_in.id_for_label}}">{% trans "In Time" %}</label>
{{f.form.attendance_clock_in}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "OT Approved?" %}</label>
<label class="oh-label" for="{{f.form.attendance_id__attendance_overtime_approve.id_for_label}}">{% trans "OT Approved?" %}</label>
{{f.form.attendance_id__attendance_overtime_approve}}
</div>
</div>
@@ -92,46 +92,46 @@
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Attendance From" %}</label>
<label class="oh-label" for="{{f.form.attendance_date__gte.id_for_label}}">{% trans "Attendance From" %}</label>
{{f.form.attendance_date__gte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "In From" %}</label>
<label class="oh-label" for="{{f.form.attendance_clock_in__gte.id_for_label}}">{% trans "In From" %}</label>
{{f.form.attendance_clock_in__gte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Out From" %}</label>
<label class="oh-label" for="{{f.form.attendance_clock_out__gte.id_for_label}}">{% trans "Out From" %}</label>
{{f.form.attendance_clock_out__gte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "At Work Greater or Equal" %}</label>
<label class="oh-label" for="{{f.form.at_work_second__gte.id_for_label}}">{% trans "At Work Greater or Equal" %}</label>
{{f.form.at_work_second__gte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "OT Greater or Equal" %}</label>
<label class="oh-label" for="{{f.form.overtime_second__gte.id_for_label}}">{% trans "OT Greater or Equal" %}</label>
{{f.form.overtime_second__gte}}
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Attendance Till" %}</label>
<label class="oh-label" for="{{f.form.attendance_date__lte.id_for_label}}">{% trans "Attendance Till" %}</label>
{{f.form.attendance_date__lte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "In Till" %}</label>
<label class="oh-label" for="{{f.form.attendance_clock_in__lte.id_for_label}}">{% trans "In Till" %}</label>
{{f.form.attendance_clock_in__lte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Out Till" %}</label>
<label class="oh-label" for="{{f.form.attendance_clock_out__lte.id_for_label}}">{% trans "Out Till" %}</label>
{{f.form.attendance_clock_out__lte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "At Work Less Than or Equal" %}</label>
<label class="oh-label" for="{{f.form.at_work_second__lte.id_for_label}}">{% trans "At Work Less Than or Equal" %}</label>
{{f.form.at_work_second__lte}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "OT Less Than or Equal" %}</label>
{{f.form.overtime_second__gte}}
<label class="oh-label" for="{{f.form.overtime_second__lte.id_for_label}}">{% trans "OT Less Than or Equal" %}</label>
{{f.form.overtime_second__lte}}
</div>
</div>
</div>

View File

@@ -97,11 +97,11 @@
style="display: none"
>
<div class="oh-accordion">
<label>{% trans "Group By" %}</label>
<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">{% 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">

View File

@@ -19,7 +19,7 @@
<div class="oh-sticky-table__tr">
<div class="oh-sticky-table__th" style="width: 20px;">
<div class="centered-div">
<input type="checkbox" title="{% trans 'Select All' %}" class="oh-input oh-input__checkbox all-latecome"/>
<input type="checkbox" name="selectAllInstance" title="{% trans 'Select All' %}" class="oh-input oh-input__checkbox all-latecome"/>
</div>
</div>
<div class="oh-sticky-table__th {% if request.sort_option.order == '-employee_id__employee_first_name' %}arrow-up {% elif request.sort_option.order == 'employee_id__employee_first_name' %}arrow-down {% else %} arrow-up-down {% endif %}" scope="col" hx-target='#report-container' hx-get="{% url 'late-come-early-out-search' %}?{{pd}}&sortby=employee_id__employee_first_name">{% trans "Employee" %}</div>