[UPDT] LEAVE: Leave assign records single view
This commit is contained in:
@@ -254,9 +254,9 @@
|
||||
<button
|
||||
class="oh-btn oh-btn--secondary oh-btn--shadow"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#editModal2"
|
||||
data-target="#assignLeaveModal"
|
||||
hx-get="{% url 'assign' %}"
|
||||
hx-target="#assignForm"
|
||||
hx-target="#assignLeaveFormModal"
|
||||
>
|
||||
{% trans "Assign" %}
|
||||
</button>
|
||||
@@ -336,50 +336,43 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<!-- update available leave -->
|
||||
|
||||
<!-- view single available leave -->
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="editModal1"
|
||||
role="dialog"
|
||||
aria-labelledby="editDialogModal"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="oh-modal__dialog oh-modal__dialog--timeoff">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<span class="oh-modal__dialog-title" id="editDialogDialog"
|
||||
>{% trans "Update Available Leave" %}</span
|
||||
>
|
||||
<button class="oh-modal__close" aria-label="Close">
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div id="leaveForm"></div>
|
||||
</div>
|
||||
class="oh-modal"
|
||||
id="leaveAssignModal"
|
||||
role="dialog"
|
||||
aria-hidden="true"
|
||||
aria-labelledby="leaveAssignModal"
|
||||
>
|
||||
<div class="oh-modal__dialog" id="leaveAssignModalTarget"></div>
|
||||
</div>
|
||||
|
||||
<!-- update available leave -->
|
||||
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="assignLeaveUpdateModal"
|
||||
role="dialog"
|
||||
aria-labelledby="assignLeaveUpdateModalLabel"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="oh-modal__dialog oh-modal__dialog--timeoff"
|
||||
id="assignLeaveUpdateFormModal">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Assign leave -->
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="editModal2"
|
||||
id="assignLeaveModal"
|
||||
role="dialog"
|
||||
aria-labelledby="bulkPayslipModal"
|
||||
aria-labelledby="assignLeaveModalLabel"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<h1 class="oh-modal__dialog-title" id="addEmployeeModalLabel">
|
||||
{% trans "Assign Leaves" %}
|
||||
<div class="oh-payslip__header mt-3 mb-0"></div>
|
||||
</h1>
|
||||
<button class="oh-modal__close" aria-label="Close">
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body" id="assignForm">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-modal__dialog" id="assignLeaveFormModal"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("#id_field").on("change", function () {
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
{% load i18n %} {% load static %} {% load basefilters %}
|
||||
<!-- Sticky Table -->
|
||||
{% include 'filter_tags.html' %}
|
||||
{% if messages %}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="oh-table_sticky--wrapper" id="ot-table">
|
||||
<div class="oh-sticky-dropdown--header">
|
||||
<div class="oh-dropdown" x-data="{open: false}">
|
||||
@@ -36,7 +47,10 @@
|
||||
</div>
|
||||
<div class="oh-sticky-table__tbody">
|
||||
{% for available_leave in available_leaves %}
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-sticky-table__tr" draggable="false"
|
||||
data-toggle="oh-modal-toggle" data-target="#leaveAssignModal"
|
||||
hx-target="#leaveAssignModalTarget"
|
||||
hx-get="{% url 'available-leave-single-view' available_leave.id %}?{{pd}}&instances_ids={{available_leave_ids}}">
|
||||
<div class="oh-sticky-table__sd">
|
||||
<div class="centered-div">
|
||||
<input type="checkbox" id="{{available_leave.id}}" onchange="highlightRow($(this))"
|
||||
@@ -59,16 +73,16 @@
|
||||
<div data-cell-index="6" class="oh-sticky-table__td dateformat_changer">{{available_leave.assigned_date}}</div>
|
||||
{% if perms.leave.change_availableleave or perms.leave.delete_availableleave or request.user|is_reportingmanager %}
|
||||
<div class="oh-sticky-table__td">
|
||||
<div class="oh-btn-group">
|
||||
<div class="oh-btn-group" onclick="event.stopPropagation();">
|
||||
{% if request.user|is_reportingmanager or perms.leave.change_availableleave %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#editModal1" hx-get="{% url 'available-leave-update' available_leave.id %}"
|
||||
hx-target="#leaveForm"><ion-icon name="create-outline"></ion-icon></button>
|
||||
data-target="#assignLeaveUpdateModal" hx-get="{% url 'available-leave-update' available_leave.id %}?{{pd}}"
|
||||
hx-target="#assignLeaveUpdateFormModal"><ion-icon name="create-outline"></ion-icon></button>
|
||||
{% endif %}
|
||||
{% if request.user|is_reportingmanager or perms.leave.delete_availableleave %}
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" onclick="return confirm('{% trans "Are you sure you want to delete ?" %}');" id="delete-link"
|
||||
href="{% url 'assign-delete' available_leave.id %}" title="{% trans 'Delete' %}"><ion-icon
|
||||
name="trash-outline"></ion-icon></a>
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" hx-confirm="{% trans 'Are you sure you want to delete ?' %}"
|
||||
id="delete-link" hx-post="{% url 'assign-delete' available_leave.id %}?{{pd}}" hx-target="#assignedLeaves" title="{% trans 'Delete' %}">
|
||||
<ion-icon name="trash-outline"></ion-icon></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,26 +1,57 @@
|
||||
{% load i18n %}
|
||||
{% if form.errors %}
|
||||
{% load i18n %} {% if messages %}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<script>
|
||||
setTimeout(function () {
|
||||
$(".oh-modal__close--custom").click();
|
||||
}, 1000);
|
||||
</script>
|
||||
</div>
|
||||
{% endif %} {% if form.errors %}
|
||||
<!-- form errors -->
|
||||
<div class="oh-wrapper">
|
||||
<div class="oh-alert-container">
|
||||
{% for error in form.non_field_errors %}
|
||||
<div class="oh-alert oh-alert--animated oh-alert--danger">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-wrapper">
|
||||
<div class="oh-alert-container">
|
||||
{% for error in form.non_field_errors %}
|
||||
<div class="oh-alert oh-alert--animated oh-alert--danger">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<form hx-post="{% url 'available-leave-update' id %}">
|
||||
<div class="oh-modal__dialog-body pb-2">
|
||||
<label class="oh-label d-block">{% trans "Available Days" %}</label>
|
||||
{{form.available_days}} {{form.available_days.errors}}
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body pb-2">
|
||||
<label class="oh-label d-block">{% trans "Carryforward Days" %}</label>
|
||||
{{form.carryforward_days}} {{form.carryforward_days.errors}}
|
||||
</div>
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<button type="submit" class="oh-btn oh-btn--secondary w-100">
|
||||
{% trans "Apply" %}
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-header">
|
||||
<span class="oh-modal__dialog-title" id="updateAssignLeaveModalLabel"
|
||||
>{% trans "Update Available Leave" %}</span
|
||||
>
|
||||
<button
|
||||
class="oh-modal__close--custom"
|
||||
onclick="$(this).closest('.oh-modal--show').removeClass('oh-modal--show');"
|
||||
aria-label="Close"
|
||||
hx-get="{% url 'assign-filter' %}?{{pd}}"
|
||||
hx-target="#assignedLeaves"
|
||||
>
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<form
|
||||
hx-post="{% url 'available-leave-update' id %}?{{pd}}"
|
||||
hx-target="#assignLeaveUpdateFormModal"
|
||||
>
|
||||
<div class="oh-modal__dialog-body pb-2">
|
||||
<label class="oh-label d-block">{% trans "Available Days" %}</label>
|
||||
{{form.available_days}} {{form.available_days.errors}}
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body pb-2">
|
||||
<label class="oh-label d-block">{% trans "Carryforward Days" %}</label>
|
||||
{{form.carryforward_days}} {{form.carryforward_days.errors}}
|
||||
</div>
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<button type="submit" class="oh-btn oh-btn--secondary w-100">
|
||||
{% trans "Apply" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
{% load attendancefilters %} {% load basefilters %} {% load static %}
|
||||
{% load i18n %} {% include 'filter_tags.html' %}
|
||||
|
||||
{% if messages %}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<script>
|
||||
function highlightRow(checkbox) {
|
||||
checkbox.closest(".oh-sticky-table__tr").removeClass("highlight-selected");
|
||||
@@ -57,7 +67,10 @@
|
||||
</div>
|
||||
<div class="oh-sticky-table__tbody">
|
||||
{% for available_leave in assigned_leaves.list %}
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-sticky-table__tr" draggable="false"
|
||||
data-toggle="oh-modal-toggle" data-target="#leaveAssignModal"
|
||||
hx-target="#leaveAssignModalTarget"
|
||||
hx-get="{% url 'available-leave-single-view' available_leave.id %}?{{pd}}&instances_ids={{available_leave_ids}}">
|
||||
<div class="oh-sticky-table__sd">
|
||||
<input type="checkbox" id="{{available_leave.id}}" onchange="highlightRow($(this))" class="oh-input assigned-leaves-checkbox oh-input__checkbox mt-2 mr-2 all-assigned-leaves-row" />
|
||||
</div>
|
||||
@@ -78,16 +91,16 @@
|
||||
<div class="oh-sticky-table__td dateformat_changer">{{available_leave.assigned_date}}</div>
|
||||
{% if perms.leave.change_availableleave or perms.leave.delete_availableleave or request.user|is_reportingmanager%}
|
||||
<div class="oh-sticky-table__td">
|
||||
<div class="oh-btn-group">
|
||||
<div class="oh-btn-group" onclick="event.stopPropagation();">
|
||||
{% if perms.leave.change_availableleave or request.user|is_reportingmanager %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#editModal1" hx-get="{% url 'available-leave-update' available_leave.id %}"
|
||||
hx-target="#leaveForm"><ion-icon name="create-outline"></ion-icon></button>
|
||||
data-target="#assignLeaveUpdateModal" hx-get="{% url 'available-leave-update' available_leave.id %}?{{pd}}"
|
||||
hx-target="#assignLeaveUpdateFormModal"><ion-icon name="create-outline"></ion-icon></button>
|
||||
{% endif %}
|
||||
{% if perms.leave.delete_availableleave or request.user|is_reportingmanager %}
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" onclick="return confirm('{% trans "Are you sure you want to delete ?" %}');" id="delete-link"
|
||||
href="{% url 'assign-delete' available_leave.id %}" title="{% trans 'Delete' %}"><ion-icon
|
||||
name="trash-outline"></ion-icon></a>
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" hx-confirm="{% trans 'Are you sure you want to delete ?' %}" id="delete-link"
|
||||
hx-post="{% url 'assign-delete' available_leave.id %}?{{pd}}" hx-target="#assignedLeaves" title="{% trans 'Delete' %}">
|
||||
<ion-icon name="trash-outline"></ion-icon></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
{% load i18n %}
|
||||
{% if form.errors %}
|
||||
{% load i18n %} {% if form.errors %}
|
||||
<!-- form errors -->
|
||||
<div class="oh-wrapper">
|
||||
<div class="oh-alert-container">
|
||||
{% for error in form.non_field_errors %}
|
||||
<div class="oh-alert oh-alert--animated oh-alert--danger">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-wrapper">
|
||||
<div class="oh-alert-container">
|
||||
{% for error in form.non_field_errors %}
|
||||
<div class="oh-alert oh-alert--animated oh-alert--danger">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<form hx-post="{% url 'assign' %}">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<span class="oh-modal__dialog-title" id="assignLeaveModalLabel">
|
||||
{% trans "Assign Leaves" %}
|
||||
<div class="oh-payslip__header mt-3 mb-0"></div>
|
||||
</span>
|
||||
<button
|
||||
class="oh-modal__close"
|
||||
aria-label="Close"
|
||||
hx-get="{% url 'assign-filter' %}"
|
||||
hx-target="#assignedLeaves"
|
||||
>
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body">
|
||||
<form hx-post="{% url 'assign' %}" hx-target="#assignLeaveFormModal">
|
||||
{{assign_form}}
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<button type="submit" class="oh-btn oh-btn--secondary w-100">
|
||||
{% trans "Apply" %}
|
||||
</button>
|
||||
<button type="submit" class="oh-btn oh-btn--secondary w-100">
|
||||
{% trans "Apply" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
159
leave/templates/leave/leave_assign/single_assign_view.html
Normal file
159
leave/templates/leave/leave_assign/single_assign_view.html
Normal file
@@ -0,0 +1,159 @@
|
||||
{% load static %} {% load i18n %} {% load basefilters %} {% load yes_no %}
|
||||
{% if messages %}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="oh-modal__dialog-header">
|
||||
<h2
|
||||
class="oh-modal__dialog-title"
|
||||
style="margin-left: 30px"
|
||||
id="attendanceModalLabel"
|
||||
>
|
||||
{% trans "Details" %}
|
||||
</h2>
|
||||
<button class="oh-modal__close" aria-label="Close">
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="oh-modal__dialog-body oh-modal__dialog-relative">
|
||||
<div class="oh-modal__dialog oh-modal__dialog--navigation m-0 p-0">
|
||||
<button
|
||||
hx-get="{% url 'available-leave-single-view' previous_instance %}?instances_ids={{instance_ids_json}}"
|
||||
hx-target="#leaveAssignModalTarget"
|
||||
class="oh-modal__diaglog-nav oh-modal__nav-prev"
|
||||
>
|
||||
<ion-icon
|
||||
name="chevron-back-outline"
|
||||
class="md hydrated"
|
||||
role="img"
|
||||
aria-label="chevron back outline"
|
||||
></ion-icon>
|
||||
</button>
|
||||
|
||||
<button
|
||||
hx-get="{% url 'available-leave-single-view' next_instance %}?instances_ids={{instance_ids_json}}"
|
||||
hx-target="#leaveAssignModalTarget"
|
||||
class="oh-modal__diaglog-nav oh-modal__nav-next"
|
||||
>
|
||||
<ion-icon
|
||||
name="chevron-forward-outline"
|
||||
class="md hydrated"
|
||||
role="img"
|
||||
aria-label="chevron forward outline"
|
||||
></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
{% if available_leave %}
|
||||
<div class="oh-modal__dialog-header">
|
||||
<a
|
||||
class="oh-timeoff-modal__profile-content"
|
||||
style="text-decoration: none"
|
||||
href="{% url 'employee-view-individual' available_leave.employee_id.id %}"
|
||||
>
|
||||
<div class="oh-profile mb-2">
|
||||
<div class="oh-profile__avatar">
|
||||
<img
|
||||
src="{{available_leave.employee_id.get_avatar}}"
|
||||
class="oh-profile__image me-2"
|
||||
alt="Mary Magdalene"
|
||||
/>
|
||||
</div>
|
||||
<div class="oh-timeoff-modal__profile-info">
|
||||
<span class="oh-timeoff-modal__user fw-bold"
|
||||
>{{available_leave.employee_id}}</span
|
||||
>
|
||||
<span
|
||||
class="oh-timeoff-modal__user m-0"
|
||||
style="font-size: 18px; color: #4d4a4a"
|
||||
>
|
||||
{{available_leave.employee_id.employee_work_info.department_id}} /
|
||||
{{available_leave.employee_id.employee_work_info.job_position_id}}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div class="oh-timeoff-modal__stats-container mt-3 mb-3">
|
||||
<div class="oh-timeoff-modal__stat">
|
||||
<span class="oh-timeoff-modal__stat-title"
|
||||
>{% trans "Leave Type" %}</span
|
||||
>
|
||||
<span class="oh-timeoff-modal__stat-count"
|
||||
>{{available_leave.leave_type_id}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="oh-timeoff-modal__stat" style="margin-left: 20px">
|
||||
<span class="oh-timeoff-modal__stat-title">{% trans "Available Days" %}</span>
|
||||
<span class="oh-timeoff-modal__stat-count">{{available_leave.available_days}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="oh-timeoff-modal__stats-container mt-3 mb-3">
|
||||
<div class="oh-timeoff-modal__stat">
|
||||
<span class="oh-timeoff-modal__stat-title">{% trans "Carryforward Days" %}</span>
|
||||
<span class="oh-timeoff-modal__stat-count"
|
||||
>{{available_leave.carryforward_days}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="oh-timeoff-modal__stat" style="margin-left: 20px">
|
||||
<span class="oh-timeoff-modal__stat-title"
|
||||
>{% trans "Total Leave Days" %}</span
|
||||
>
|
||||
<span class="oh-timeoff-modal__stat-count"
|
||||
>{{available_leave.total_leave_days}}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="oh-timeoff-modal__stats-container mt-3 mb-3">
|
||||
<div class="oh-timeoff-modal__stat">
|
||||
<span class="oh-timeoff-modal__stat-title"
|
||||
>{% trans "Assigned Date" %}</span
|
||||
>
|
||||
<span class="oh-timeoff-modal__stat-count dateformat_changer"
|
||||
>{{available_leave.assigned_date}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="oh-timeoff-modal__stat" style="margin-left: 20px">
|
||||
<span class="oh-timeoff-modal__stat-title"
|
||||
>{% trans "Leave Reset Date" %}</span
|
||||
>
|
||||
<span class="oh-timeoff-modal__stat-count dateformat_changer"
|
||||
>{{available_leave.reset_date}}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
{% if perms.leave.change_availableleave or perms.leave.delete_availableleave or request.user|is_reportingmanager %}
|
||||
<div class="oh-modal__button-container text-center">
|
||||
<div class="oh-btn-group">
|
||||
{% if request.user|is_reportingmanager or perms.leave.change_availableleave %}
|
||||
<a hx-get="{% url 'available-leave-update' available_leave.id %}?{{pd}}" hx-target='#assignLeaveUpdateFormModal'
|
||||
data-toggle="oh-modal-toggle" data-target='#assignLeaveUpdateModal' class="oh-btn oh-btn--info w-50" title="{% trans 'Edit' %}">
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
<form hx-confirm="{% trans 'Are you sure you want to delete this work type request?' %}"
|
||||
hx-post="{% url 'assign-delete' available_leave.id %}?instances_ids={{instance_ids_json}}" hx-target="#leaveAssignModalTarget" style="width: 50%">
|
||||
{% csrf_token %}
|
||||
<button type='submit' class="oh-btn oh-btn--secondary w-100" title="{% trans 'Remove' %}"><ion-icon name="trash-outline"></ion-icon></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
|
||||
<img style="display: block; width: 15%; margin: 20px auto; filter: opacity(0.5);" src="{% static 'images/ui/employee_shift.png' %}" class="" alt="Page not found. 404." />
|
||||
<h5 class="oh-404__subtitle">{% trans "Attendance not found." %}</h5>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -57,13 +57,14 @@ urlpatterns = [
|
||||
path("request-filter", views.leave_request_filter, name="request-filter"),
|
||||
path("assign", views.leave_assign, name="assign"),
|
||||
path("assign-one/<int:id>", views.leave_assign_one, name="assign-one"),
|
||||
path("assign-view", views.leave_assign_view, name="assign-view"),
|
||||
path("assign-view/", views.leave_assign_view, name="assign-view"),
|
||||
path("available-leave-single-view/<int:obj_id>/", views.available_leave_single_view, name="available-leave-single-view"),
|
||||
path(
|
||||
"available-leave-update/<int:id>",
|
||||
views.available_leave_update,
|
||||
name="available-leave-update",
|
||||
),
|
||||
path("assign-delete/<int:id>", views.leave_assign_delete, name="assign-delete"),
|
||||
path("assign-delete/<int:obj_id>", views.leave_assign_delete, name="assign-delete"),
|
||||
path(
|
||||
"assigned-leave-bulk-delete",
|
||||
views.leave_assign_bulk_delete,
|
||||
|
||||
110
leave/views.py
110
leave/views.py
@@ -424,12 +424,12 @@ def leave_request_filter(request):
|
||||
template = ("leave/leave_request/leave_requests.html",)
|
||||
if request.GET.get("sortby"):
|
||||
leave_request_filter = sortby(request, leave_request_filter, "sortby")
|
||||
|
||||
|
||||
if field != "" and field is not None:
|
||||
leave_request_filter = group_by_queryset(
|
||||
leave_request_filter, field, request.GET.get("page"), "page"
|
||||
)
|
||||
list_values = [entry['list'] for entry in leave_request_filter]
|
||||
list_values = [entry["list"] for entry in leave_request_filter]
|
||||
id_list = []
|
||||
for value in list_values:
|
||||
for instance in value.object_list:
|
||||
@@ -438,13 +438,12 @@ def leave_request_filter(request):
|
||||
requests_ids = json.dumps(list(id_list))
|
||||
template = "leave/leave_request/group_by.html"
|
||||
|
||||
else:
|
||||
leave_request_filter = paginator_qry(leave_request_filter, request.GET.get("page"))
|
||||
else:
|
||||
leave_request_filter = paginator_qry(
|
||||
leave_request_filter, request.GET.get("page")
|
||||
)
|
||||
requests_ids = json.dumps(
|
||||
[
|
||||
instance.id
|
||||
for instance in leave_request_filter.object_list
|
||||
]
|
||||
[instance.id for instance in leave_request_filter.object_list]
|
||||
)
|
||||
|
||||
data_dict = []
|
||||
@@ -933,6 +932,12 @@ def leave_assign_view(request):
|
||||
setattr(request.GET, "field", True)
|
||||
|
||||
page_obj = group_by_queryset(queryset.order_by("-id"), "leave_type_id", page_number)
|
||||
list_values = [entry["list"] for entry in page_obj]
|
||||
id_list = []
|
||||
for value in list_values:
|
||||
for instance in value.object_list:
|
||||
id_list.append(instance.id)
|
||||
available_leave_ids = json.dumps(list(id_list))
|
||||
|
||||
return render(
|
||||
request,
|
||||
@@ -946,10 +951,29 @@ def leave_assign_view(request):
|
||||
"filter_dict": data_dict,
|
||||
"gp_fields": LeaveAssignReGroup.fields,
|
||||
"assign_form": assign_form,
|
||||
"available_leave_ids": available_leave_ids,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def available_leave_single_view(request, obj_id):
|
||||
previous_data = request.GET.urlencode()
|
||||
available_leave = AvailableLeave.objects.filter(id=obj_id).first()
|
||||
instance_ids_json = request.GET["instances_ids"]
|
||||
instance_ids = json.loads(instance_ids_json) if instance_ids_json else []
|
||||
previous_instance, next_instance = closest_numbers(instance_ids, obj_id)
|
||||
content = {
|
||||
"available_leave": available_leave,
|
||||
"previous_instance": previous_instance,
|
||||
"next_instance": next_instance,
|
||||
"instance_ids_json": instance_ids_json,
|
||||
"pd": previous_data,
|
||||
}
|
||||
return render(
|
||||
request, "leave/leave_assign/single_assign_view.html", context=content
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@hx_request_required
|
||||
@manager_can_enter("leave.view_availableleave")
|
||||
@@ -974,10 +998,22 @@ def leave_assign_filter(request):
|
||||
available_leaves = assigned_leave_filter.order_by("-id")
|
||||
if request.GET.get("sortby"):
|
||||
available_leaves = sortby(request, available_leaves, "sortby")
|
||||
available_leave_ids = json.dumps(
|
||||
[instance.id for instance in paginator_qry(available_leaves, None)]
|
||||
)
|
||||
if field != "" and field is not None:
|
||||
page_obj = group_by_queryset(available_leaves, field, page_number)
|
||||
list_values = [entry["list"] for entry in page_obj]
|
||||
id_list = []
|
||||
for value in list_values:
|
||||
for instance in value.object_list:
|
||||
id_list.append(instance.id)
|
||||
available_leave_ids = json.dumps(list(id_list))
|
||||
template = "leave/leave_assign/group_by.html"
|
||||
else:
|
||||
available_leave_ids = json.dumps(
|
||||
[instance.id for instance in paginator_qry(available_leaves, None)]
|
||||
)
|
||||
page_obj = paginator_qry(available_leaves, page_number)
|
||||
|
||||
data_dict = parse_qs(previous_data)
|
||||
@@ -991,6 +1027,7 @@ def leave_assign_filter(request):
|
||||
"filter_dict": data_dict,
|
||||
"field": field,
|
||||
"assign_form": assign_form,
|
||||
"available_leave_ids": available_leave_ids,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1044,16 +1081,7 @@ def leave_assign(request):
|
||||
request,
|
||||
_("Leave type is already assigned to the employee.."),
|
||||
)
|
||||
|
||||
response = render(
|
||||
request,
|
||||
"leave/leave_assign/leave_assign_form.html",
|
||||
{"form": form, "id": id},
|
||||
)
|
||||
return HttpResponse(
|
||||
response.content.decode("utf-8") + "<script>location.reload();</script>"
|
||||
)
|
||||
|
||||
return HttpResponse("<script>window.location.reload()</script>")
|
||||
return render(
|
||||
request, "leave/leave_assign/leave_assign_form.html", {"assign_form": form}
|
||||
)
|
||||
@@ -1076,6 +1104,7 @@ def available_leave_update(request, id):
|
||||
"""
|
||||
leave_assign = AvailableLeave.objects.get(id=id)
|
||||
form = AvailableLeaveUpdateForm(instance=leave_assign)
|
||||
previous_data = request.GET.urlencode()
|
||||
if request.method == "POST":
|
||||
form = AvailableLeaveUpdateForm(request.POST, instance=leave_assign)
|
||||
if form.is_valid():
|
||||
@@ -1093,24 +1122,16 @@ def available_leave_update(request, id):
|
||||
icon="people-circle",
|
||||
redirect="/leave/user-request-view",
|
||||
)
|
||||
response = render(
|
||||
request,
|
||||
"leave/leave_assign/available_update_form.html",
|
||||
{"form": form, "id": id},
|
||||
)
|
||||
return HttpResponse(
|
||||
response.content.decode("utf-8") + "<script>location. reload();</script>"
|
||||
)
|
||||
return render(
|
||||
request,
|
||||
"leave/leave_assign/available_update_form.html",
|
||||
{"form": form, "id": id},
|
||||
{"form": form, "id": id, "pd": previous_data},
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@manager_can_enter("leave.delete_availableleave")
|
||||
def leave_assign_delete(request, id):
|
||||
def leave_assign_delete(request, obj_id):
|
||||
"""
|
||||
function used to delete assign leave type of an employee.
|
||||
|
||||
@@ -1121,14 +1142,27 @@ def leave_assign_delete(request, id):
|
||||
Returns:
|
||||
GET : return leave type assigned view template
|
||||
"""
|
||||
pd = request.GET.urlencode()
|
||||
try:
|
||||
AvailableLeave.objects.get(id=id).delete()
|
||||
AvailableLeave.objects.get(id=obj_id).delete()
|
||||
messages.success(request, _("Assigned leave is successfully deleted."))
|
||||
except AvailableLeave.DoesNotExist:
|
||||
messages.error(request, _("Assigned leave not found."))
|
||||
except ProtectedError:
|
||||
messages.error(request, _("Related entries exists"))
|
||||
return redirect(leave_assign_view)
|
||||
if not request.GET.get("instances_ids"):
|
||||
return redirect(f"/leave/assign-filter?{pd}")
|
||||
else:
|
||||
instances_ids = request.GET.get("instances_ids")
|
||||
instances_list = json.loads(instances_ids)
|
||||
if obj_id in instances_list:
|
||||
instances_list.remove(obj_id)
|
||||
previous_instance, next_instance = closest_numbers(
|
||||
json.loads(instances_ids), obj_id
|
||||
)
|
||||
return redirect(
|
||||
f"/leave/available-leave-single-view/{next_instance}/?instances_ids={instances_list}"
|
||||
)
|
||||
|
||||
|
||||
@require_http_methods(["POST"])
|
||||
@@ -1740,7 +1774,7 @@ def user_leave_request(request, id):
|
||||
|
||||
overlapping_requests = LeaveRequest.objects.filter(
|
||||
employee_id=employee, start_date__lte=end_date, end_date__gte=start_date
|
||||
).exclude(status__in=["cancelled","rejected"])
|
||||
).exclude(status__in=["cancelled", "rejected"])
|
||||
if overlapping_requests.exists():
|
||||
form.add_error(
|
||||
None, _("There is already a leave request for this date range..")
|
||||
@@ -2056,7 +2090,7 @@ def user_request_filter(request):
|
||||
user_request_filter = group_by_queryset(
|
||||
user_request_filter, field, request.GET.get("page"), "page"
|
||||
)
|
||||
list_values = [entry['list'] for entry in user_request_filter]
|
||||
list_values = [entry["list"] for entry in user_request_filter]
|
||||
id_list = []
|
||||
for value in list_values:
|
||||
for instance in value.object_list:
|
||||
@@ -2065,16 +2099,14 @@ def user_request_filter(request):
|
||||
requests_ids = json.dumps(list(id_list))
|
||||
template = "leave/user_leave/group_by.html"
|
||||
|
||||
else:
|
||||
user_request_filter = paginator_qry(user_request_filter, request.GET.get("page"))
|
||||
else:
|
||||
user_request_filter = paginator_qry(
|
||||
user_request_filter, request.GET.get("page")
|
||||
)
|
||||
requests_ids = json.dumps(
|
||||
[
|
||||
instance.id
|
||||
for instance in user_request_filter.object_list
|
||||
]
|
||||
[instance.id for instance in user_request_filter.object_list]
|
||||
)
|
||||
|
||||
|
||||
data_dict = parse_qs(previous_data)
|
||||
get_key_instances(LeaveRequest, data_dict)
|
||||
if "status" in data_dict:
|
||||
|
||||
@@ -73,9 +73,9 @@
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: flex">
|
||||
<div class="oh-navbar__notification-image" style="margin-left: 5px">
|
||||
{% comment %} <div class="oh-navbar__notification-image" style="margin-left: 5px">
|
||||
<ion-icon name="{{notification.data.icon}}"></ion-icon>
|
||||
</div>
|
||||
</div> {% endcomment %}
|
||||
<div
|
||||
class="oh-navbar__notification-image"
|
||||
style="margin-left: 5px"
|
||||
|
||||
Reference in New Issue
Block a user