From 9007c5e2b89034cac68cd0e08e62f74ff8f8d1b7 Mon Sep 17 00:00:00 2001 From: Horilla Date: Fri, 13 Sep 2024 18:02:59 +0530 Subject: [PATCH] [UPDT] PAYROLL: Add data-action attribute for next and previous button in individual view --- horilla/decorators.py | 10 +- horilla/methods.py | 7 + .../payroll/allowance/card_allowance.html | 4 +- .../allowance/view_single_allowance.html | 86 +- .../payroll/contract/contract_list.html | 2 +- .../contract/contract_single_view.html | 344 +++--- .../templates/payroll/contract/group_by.html | 2 +- .../payroll/deduction/card_deduction.html | 2 +- .../payroll/deduction/list_deduction.html | 2 +- .../deduction/view_single_deduction.html | 231 ++-- .../templates/payroll/loan/installments.html | 4 +- .../reimbursenent_individual.html | 4 +- payroll/views/component_views.py | 96 +- payroll/views/views.py | 55 +- static/index/index.js | 314 ++++- templates/index.html | 1009 ++++++----------- 16 files changed, 1103 insertions(+), 1069 deletions(-) diff --git a/horilla/decorators.py b/horilla/decorators.py index 2145330c9..c3b9970a2 100755 --- a/horilla/decorators.py +++ b/horilla/decorators.py @@ -274,10 +274,14 @@ def owner_can_enter(function, perm: str, model: object, manager_access=False): def _function(request, *args, **kwargs): instance_id = kwargs[list(kwargs.keys())[0]] if model == Employee: - employee = Employee.objects.get(id=instance_id) + employee = Employee.objects.filter(id=instance_id).first() else: try: - employee = model.objects.get(id=instance_id).employee_id + employee = ( + model.objects.filter(id=instance_id).first().employee_id + if model.objects.filter(id=instance_id).first() + else None + ) except: messages.error(request, ("Sorry, something went wrong!")) return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/")) @@ -293,7 +297,7 @@ def owner_can_enter(function, perm: str, model: object, manager_access=False): else False ) ) - if can_enter: + if can_enter or not employee: return function(request, *args, **kwargs) return render(request, "no_perm.html") diff --git a/horilla/methods.py b/horilla/methods.py index 5c61e0c5e..ea291e292 100644 --- a/horilla/methods.py +++ b/horilla/methods.py @@ -71,3 +71,10 @@ def horilla_users_with_perms(permissions): ) return users_with_permissions.distinct() + + +def get_urlencode(request): + get_data = request.GET.copy() + get_data.pop("instances_ids", None) + previous_data = get_data.urlencode() + return previous_data diff --git a/payroll/templates/payroll/allowance/card_allowance.html b/payroll/templates/payroll/allowance/card_allowance.html index 6e56e3cbb..f4e1e8100 100644 --- a/payroll/templates/payroll/allowance/card_allowance.html +++ b/payroll/templates/payroll/allowance/card_allowance.html @@ -15,7 +15,7 @@
{% for allowance in allowances %}
+ data-toggle="oh-modal-toggle" data-target = "#objectDetailsModal" hx-get="{% url 'single-allowance-view' allowance.id %}?{{pd}}&view=card&instances_ids={{allowance_ids}}" hx-target = "#objectDetailsModalTarget">
diff --git a/payroll/templates/payroll/allowance/view_single_allowance.html b/payroll/templates/payroll/allowance/view_single_allowance.html index 5b13e938c..9fcf59e7e 100644 --- a/payroll/templates/payroll/allowance/view_single_allowance.html +++ b/payroll/templates/payroll/allowance/view_single_allowance.html @@ -1,17 +1,37 @@ -{% load i18n %} {% load yes_no %} -{% if request.GET.instances_ids %} -
- - - -
+{% load i18n %} {% load yes_no %} {% load static %} +{% if messages %} +
+ {% for message in messages %} +
+
+ {{ message }} +
+
+ {% endfor %} +
+ {% endif %} +{% if request.GET.instances_ids %} +
+ + + +
+{% endif %} +{% if allowance %}
{{allowance.title}}
@@ -86,25 +106,35 @@
{% if perms.payroll.change_allowance or perms.payroll.delete_allowance %} -
-
- - {% trans "Edit" %} - - +
+
+ {% trans "Delete" %} - + >{% trans "Edit" %} + + +
-
{% endif %}
+{% else %} +
+ + Page not found. 404. +
+ {% trans "There are currently no allowances to consider." %} +
+
+{% endif %} diff --git a/payroll/templates/payroll/contract/contract_list.html b/payroll/templates/payroll/contract/contract_list.html index 3909531b1..7fc1f8270 100644 --- a/payroll/templates/payroll/contract/contract_list.html +++ b/payroll/templates/payroll/contract/contract_list.html @@ -68,7 +68,7 @@
{% for contract in contracts %} -
+
- - - -
+{% load i18n %} {% load yes_no %} {% load static %} +{% if messages %} +
+ {% for message in messages %} +
+
+ {{ message }} +
+
+ {% endfor %} +
+ {% endif %} -
- -
{{contract.contract_name}}
-
- -
-
- -
-
- Mary Magdalene -
-
- {{contract.employee_id}} - - {{contract.employee_id.employee_work_info.department_id}} / - {{contract.employee_id.employee_work_info.job_position_id}} -
-
-
-
-
-
- {% trans "Start Date" %} - {{contract.contract_start_date}} + +{% if contract_ids %} +
+ + + +
+{% endif %} +{% if contract %} +
+ +
{{contract.contract_name}}
+
+ +
+
+ +
+
+ Mary Magdalene
-
- {% trans "End Date" %} - {{contract.contract_end_date}} +
+ {{contract.employee_id}} + + {{contract.employee_id.employee_work_info.department_id}} / + {{contract.employee_id.employee_work_info.job_position_id}}
-
-
-
- {% trans "Wage Type" %} - {{contract.get_wage_type_display}}
-
- {% trans "Wage" %} - {{contract.wage}} + +
+
+
+ {% trans "Start Date" %} + {{contract.contract_start_date}} +
+
+ {% trans "End Date" %} + {{contract.contract_end_date}} +
-
-
-
- {% if contract.calculate_daily_leave_amount %} - {% trans "Calculate Leave Amount" %} - {{contract.calculate_daily_leave_amount|yesno|capfirst}} - {% else %} - {% trans "Deduction Amount For One Leave" %} - {{contract.deduction_for_one_leave_amount}} - {% endif %} +
+
+ {% trans "Wage Type" %} + {{contract.get_wage_type_display}} +
+
+ {% trans "Wage" %} + {{contract.wage}} +
-
- {% trans "Deduct From Basic Pay" %} - {{contract.deduct_leave_from_basic_pay|yesno|capfirst}} +
+
+ {% if contract.calculate_daily_leave_amount %} + {% trans "Calculate Leave Amount" %} + {{contract.calculate_daily_leave_amount|yesno|capfirst}} + {% else %} + {% trans "Deduction Amount For One Leave" %} + {{contract.deduction_for_one_leave_amount}} + {% endif %} +
+
+ {% trans "Deduct From Basic Pay" %} + {{contract.deduct_leave_from_basic_pay|yesno|capfirst}} +
-
-
-
- {% trans "Department" %} - {{contract.department}} +
+
+ {% trans "Department" %} + {{contract.department}} +
+
+ {% trans "Job Position" %} + {{contract.job_position}} +
-
- {% trans "Job Position" %} - {{contract.job_position}} +
+
+ {% trans "Job Role" %} + {{contract.job_role}} +
+
+ {% trans "Shift" %} + {{contract.shift}} +
-
-
-
- {% trans "Job Role" %} - {{contract.job_role}} +
+
+ {% trans "Work Type" %} + {{contract.work_type}} +
+
+ {% trans "Filing Status" %} + {{contract.filing_status}} +
-
- {% trans "Shift" %} - {{contract.shift}} +
+
+ {% trans "Pay Frequency" %} + {{contract.get_pay_frequency_display}} +
+
+ {% trans "Document" %} + {% if contract.contract_document %} + {{ contract.contract_document.name }} + {% endif %} +
-
-
-
- {% trans "Work Type" %} - {{contract.work_type}} -
-
- {% trans "Filing Status" %} - {{contract.filing_status}} -
-
-
-
- {% trans "Pay Frequency" %} - {{contract.get_pay_frequency_display}} -
-
- {% trans "Document" %} - {% if contract.contract_document %} - {{ contract.contract_document.name }} - {% endif %} -
-
- {% if contract.note %} + {% if contract.note %} +
+
+ {% trans "Note" %} + {{contract.note}} +
+
+ {% endif %}
- {% trans "Note" %} - {{contract.note}} + {% trans "Status" %} + {{contract.get_contract_status_display}}
- {% endif %} -
-
- {% trans "Status" %} - {{contract.get_contract_status_display}} -
+ {% if dashboard != "dashboard" and perms.payroll.delete_contract or perms.payroll.change_contract %} +
+
+ {% if perms.payroll.change_contract %} + + {% trans "Edit" %} + + {% endif %} + {% if perms.payroll.delete_contract %} + + {% endif %} +
+
+ {% endif %}
- {% if dashboard != "dashboard" and perms.payroll.delete_contract or perms.payroll.change_contract %} -
-
- {% if perms.payroll.change_contract %} - - {% trans "Edit" %} - - {% endif %} - {% if perms.payroll.delete_contract %} - - {% trans "Delete" %} - - {% endif %} -
-
- {% endif %}
-
+{% else %} +
+ + Page not found. 404. +
{% trans "There have been no contracts signed." %}
+
+{% endif %} diff --git a/payroll/templates/payroll/contract/group_by.html b/payroll/templates/payroll/contract/group_by.html index 972ae835b..cbe5609e6 100644 --- a/payroll/templates/payroll/contract/group_by.html +++ b/payroll/templates/payroll/contract/group_by.html @@ -58,7 +58,7 @@
{% for contract in contract_list.list %} -
+
{% for deduction in deductions %}
+ data-toggle="oh-modal-toggle" data-target="#objectDetailsModal" hx-get="{% url 'single-deduction-view' deduction.id %}?{{pd}}&instances_ids={{deduction_ids}}" hx-target = "#objectDetailsModalTarget" >
{% for deduction in deductions %} -
+
{{deduction.title}}
diff --git a/payroll/templates/payroll/deduction/view_single_deduction.html b/payroll/templates/payroll/deduction/view_single_deduction.html index 320da2962..2963f2d13 100644 --- a/payroll/templates/payroll/deduction/view_single_deduction.html +++ b/payroll/templates/payroll/deduction/view_single_deduction.html @@ -1,81 +1,80 @@ {% load i18n %} {% load yes_no %} {% load static %} {% if messages %} -
- {% for message in messages %} -
-
- {{ message }} +
+ {% for message in messages %} +
+
+ {{ message }} +
+ {% endfor %}
- {% endfor %} -
+ {% endif %} {% if deduction %} -{% if request.GET.instances_ids %} -
- + {% if request.GET.instances_ids %} +
+ - -
-{% endif %} -
- -
{{deduction.title}}
-
- -
- {% if deduction.is_tax %} -
- {% trans "Tax" %} - {{deduction.is_tax|yesno|capfirst}} +
- {% else %} -
- {% trans "Pretax" %} - {{deduction.is_pretax|yesno|capfirst}} -
- {% endif %} -
- {% trans "One Time deduction" %} - {% if deduction.one_time_date %} - {% trans "On" %} {{deduction.one_time_date}} - {% else %} - {% trans "No" %} - {% endif %} -
-
-
-
- {% trans "Condition Based" %} - {% if deduction.is_condition_based %} - {{deduction.get_field_display}} {{deduction.get_condition_display}} {{deduction.value}} + {% endif %} +
+ +
{{deduction.title}}
+
+ +
+ {% if deduction.is_tax %} +
+ {% trans "Tax" %} + {{deduction.is_tax|yesno|capfirst}} +
{% else %} - {% trans "No" %} +
+ {% trans "Pretax" %} + {{deduction.is_pretax|yesno|capfirst}} +
{% endif %} +
+ {% trans "One Time deduction" %} + {% if deduction.one_time_date %} + {% trans "On" %} {{deduction.one_time_date}} + {% else %} + {% trans "No" %} + {% endif %} +
-
+
+
+ {% trans "Condition Based" %} + {% if deduction.is_condition_based %} + {{deduction.get_field_display}} + {{deduction.get_condition_display}} {{deduction.value}} + {% else %} + {% trans "No" %} + {% endif %} +
+
{% trans "Amount" %} {% if deduction.update_compensation %} {% if deduction.is_fixed %} - {{deduction.amount}}{{currency}} Deduct From {{deduction.get_update_compensation_display}} + {{deduction.amount}}{{currency}} Deduct From + {{deduction.get_update_compensation_display}} {% else %} - {{deduction.rate}}% {% trans "of" %} {{deduction.get_update_compensation_display}} + {{deduction.rate}}% {% trans "of" %} + {{deduction.get_update_compensation_display}} {% endif %} {% else %} {% if deduction.is_fixed %} @@ -85,64 +84,56 @@ {% trans "Employee Rate :" %} {{deduction.rate}}% {% trans "of" %} {{deduction.get_based_on_display}} {% endif %} {% endif %} +
+
+
+ {% trans "Has Maximum Limit" %} + {% if deduction.has_max_limit %} + {{deduction.maximum_amount}} {{currency}} {% trans "For working days on a month" %} + {% else %} + {% trans "No" %} + {% endif %} +
+
+ {% trans "Deduction Eligibility" %} + If {{deduction.get_if_choice_display}} + {{deduction.get_if_condition_display}} {{deduction.if_amount}} +
+
+ {% if perms.payroll.change_deduction or perms.payroll.delete_deduction %} + + {% endif %}
-
-
- {% trans "Has Maximum Limit" %} - {% if deduction.has_max_limit %} - {{deduction.maximum_amount}} {{currency}} {% trans "For working days on a month" %} - {% else %} - {% trans "No" %} - {% endif %} -
-
- {% trans "Deduction Eligibility" %} - If {{deduction.get_if_choice_display}} {{deduction.get_if_condition_display}} {{deduction.if_amount}} -
-
- {% if perms.payroll.change_deduction or perms.payroll.delete_deduction %} - - {% endif %} -
{% else %} -
- - -

-
-
- Page not found. 404. -
- {% trans "There are currently no deductions to consider." %} -
-
+
+ + +

+
+
+ Page not found. 404. +
+ {% trans "There are currently no deductions to consider." %} +
+
{% endif %} diff --git a/payroll/templates/payroll/loan/installments.html b/payroll/templates/payroll/loan/installments.html index a1e86b457..9e4685c57 100644 --- a/payroll/templates/payroll/loan/installments.html +++ b/payroll/templates/payroll/loan/installments.html @@ -18,7 +18,7 @@
- + @load.window=" + width = (window.innerWidth > 0) ? window.innerWidth : screen.width; + if (width < 575.98) { + sidebarOpen = false + }" @resize.window=" + width = (window.innerWidth > 0) ? window.innerWidth : screen.width; + if (width < 575.98) { + sidebarOpen = false + }" + > - -
- - - - + + + + + + + + + + + + + + -
- - - - - - + + + + {% if "attendance"|app_installed %} + {% endif %} - function removeHighlight() { - setTimeout(function() { - $(".toggle-highlight").removeClass("toggle-highlight") - }, 200); - } - - $(document).on("htmx:beforeRequest", function (event, data) { - var response = event.detail.xhr.response; - var target = $(event.detail.elt.getAttribute("hx-target")); - var avoid_target = ["BiometricDeviceTestFormTarget","reloadMessages", "infinite"]; - if (!target.closest("form").length && avoid_target.indexOf(target.attr("id")) === -1) { - target.html(`
`); - } - }); - - - - - - - - - - - - - - - - - - - - {% if "attendance"|app_installed %} - - {% endif %} - - - - - - {% if enabled_timerunner %} - - {% endif %} - - - + + + + + {% if enabled_timerunner %} + - + // accessing initial worked hours from the user + $(".time-runner").not("title").html(secondsToDuration(at_work_seconds)); + $("title.time-runner").html("{{white_label_company_name}} | " + secondsToDuration(at_work_seconds)); + setInterval(() => { + if (run) { + at_work_seconds = at_work_seconds + 1 + $("div.time-runner").html(secondsToDuration(at_work_seconds)); + $("title").html("{{white_label_company_name}} | " + secondsToDuration(at_work_seconds)); + } + }, 1000); + + {% endif %}