[UPDT] ATTENDANCE: Ordering indication on attendance tables

This commit is contained in:
Horilla
2024-02-02 19:37:57 +05:30
parent de45631fd7
commit 515dce8bf0
2 changed files with 25 additions and 21 deletions

View File

@@ -27,18 +27,18 @@
<div class="oh-sticky-table__table oh-table--sortable">
<div class="oh-sticky-table__thead">
<div class="oh-sticky-table__tr">
<div class="oh-sticky-table__sd oh-sticky-table__top">{% trans "Employee" %}</div>
<div class="oh-sticky-table__th">{% trans "Date" %}</div>
<div class="oh-sticky-table__sd oh-sticky-table__top {% 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 %}" hx-target='#view-container' hx-get="{% url 'search-attendance-requests' %}?{{pd}}&sortby=employee_id__employee_first_name">{% trans "Employee" %}</div>
<div class="oh-sticky-table__th {% if request.sort_option.order == '-attendance_date' %}arrow-up {% elif request.sort_option.order == 'attendance_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-target='#view-container' hx-get="{% url 'search-attendance-requests' %}?{{pd}}&sortby=attendance_date">{% trans "Date" %}</div>
<div class="oh-sticky-table__th">{% trans "Day" %}</div>
<div class="oh-sticky-table__th">{% trans "Check-In" %}</div>
<div class="oh-sticky-table__th">{% trans "In Date" %}</div>
<div class="oh-sticky-table__th {% if request.sort_option.order == '-attendance_clock_in_date' %}arrow-up {% elif request.sort_option.order == 'attendance_clock_in_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-target='#view-container' hx-get="{% url 'search-attendance-requests' %}?{{pd}}&sortby=attendance_clock_in_date">{% trans "In Date" %}</div>
<div class="oh-sticky-table__th">{% trans "Check-Out" %}</div>
<div class="oh-sticky-table__th">{% trans "Out Date" %}</div>
<div class="oh-sticky-table__th {% if request.sort_option.order == '-attendance_clock_out_date' %}arrow-up {% elif request.sort_option.order == 'attendance_clock_out_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-target='#view-container' hx-get="{% url 'search-attendance-requests' %}?{{pd}}&sortby=attendance_clock_out_date">{% trans "Out Date" %}</div>
<div class="oh-sticky-table__th">{% trans "Shift" %}</div>
<div class="oh-sticky-table__th">{% trans "Work Type" %}</div>
<div class="oh-sticky-table__th">{% trans "Min Hour" %}</div>
<div class="oh-sticky-table__th">{% trans "At Work" %}</div>
<div class="oh-sticky-table__th">{% trans "Overtime" %}</div>
<div class="oh-sticky-table__th {% if request.sort_option.order == '-attendance_overtime' %}arrow-up {% elif request.sort_option.order == 'attendance_overtime' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-target='#view-container' hx-get="{% url 'search-attendance-requests' %}?{{pd}}&sortby=attendance_overtime">{% trans "Overtime" %}</div>
<div class="oh-sticky-table__th oh-sticky-table__right">{% trans "Comment" %}</div>
<div class="oh-sticky-table__th oh-sticky-table__right">{% trans "Actions" %}</div>
</div>
@@ -194,18 +194,18 @@
<div class="oh-sticky-table__table oh-table--sortable">
<div class="oh-sticky-table__thead">
<div class="oh-sticky-table__tr">
<div class="oh-sticky-table__sd oh-sticky-table__top">{% trans "Employee" %}</div>
<div class="oh-sticky-table__th">{% trans "Date" %}</div>
<div class="oh-sticky-table__sd oh-sticky-table__top {% 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 %}" hx-target='#view-container' hx-get="{% url 'search-attendance-requests' %}?{{pd}}&sortby=employee_id__employee_first_name">{% trans "Employee" %}</div>
<div class="oh-sticky-table__th {% if request.sort_option.order == '-attendance_date' %}arrow-up {% elif request.sort_option.order == 'attendance_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-target='#view-container' hx-get="{% url 'search-attendance-requests' %}?{{pd}}&sortby=attendance_date">{% trans "Date" %}</div>
<div class="oh-sticky-table__th">{% trans "Day" %}</div>
<div class="oh-sticky-table__th">{% trans "Check-In" %}</div>
<div class="oh-sticky-table__th">{% trans "In Date" %}</div>
<div class="oh-sticky-table__th {% if request.sort_option.order == '-attendance_clock_in_date' %}arrow-up {% elif request.sort_option.order == 'attendance_clock_in_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-target='#view-container' hx-get="{% url 'search-attendance-requests' %}?{{pd}}&sortby=attendance_clock_in_date">{% trans "In Date" %}</div>
<div class="oh-sticky-table__th">{% trans "Check-Out" %}</div>
<div class="oh-sticky-table__th">{% trans "Out Date" %}</div>
<div class="oh-sticky-table__th {% if request.sort_option.order == '-attendance_clock_out_date' %}arrow-up {% elif request.sort_option.order == 'attendance_clock_out_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-target='#view-container' hx-get="{% url 'search-attendance-requests' %}?{{pd}}&sortby=attendance_clock_out_date">{% trans "Out Date" %}</div>
<div class="oh-sticky-table__th">{% trans "Shift" %}</div>
<div class="oh-sticky-table__th">{% trans "Work Type" %}</div>
<div class="oh-sticky-table__th">{% trans "Min Hour" %}</div>
<div class="oh-sticky-table__th">{% trans "At Work" %}</div>
<div class="oh-sticky-table__th">{% trans "Overtime" %}</div>
<div class="oh-sticky-table__th {% if request.sort_option.order == '-attendance_overtime' %}arrow-up {% elif request.sort_option.order == 'attendance_overtime' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-target='#view-container' hx-get="{% url 'search-attendance-requests' %}?{{pd}}&sortby=attendance_overtime">{% trans "Overtime" %}</div>
<div class="oh-sticky-table__th oh-sticky-table__right">{% trans "Request" %}</div>
</div>
</div>

View File

@@ -52,12 +52,16 @@ def attendance_search(request):
field = request.GET.get("field")
minot = strtime_seconds("00:00")
condition = AttendanceValidationCondition.objects.first()
all_attendances = Attendance.objects.all()
if request.GET.get("sortby"):
all_attendances = sortby(request, all_attendances, "sortby")
if condition is not None and condition.minimum_overtime_to_approve is not None:
minot = strtime_seconds(condition.minimum_overtime_to_approve)
validate_attendances = Attendance.objects.filter(attendance_validated=False)
attendances = Attendance.objects.filter(attendance_validated=True)
ot_attendances = Attendance.objects.filter(
validate_attendances = all_attendances.filter(attendance_validated=False)
attendances = all_attendances.filter(attendance_validated=True)
ot_attendances = all_attendances.filter(
overtime_second__gte=minot,
attendance_validated=True,
)
@@ -76,10 +80,6 @@ def attendance_search(request):
ot_attendances = filtersubordinates(
request, ot_attendances, "attendance.view_attendance"
)
if request.GET.get("sortby"):
attendances = sortby(request, attendances, "sortby")
validate_attendances = sortby(request, validate_attendances, "sortby")
ot_attendances = sortby(request, ot_attendances, "sortby")
data_dict = parse_qs(previous_data)
get_key_instances(Attendance, data_dict)
keys_to_remove = [
@@ -329,7 +329,11 @@ def own_attendance_sort(request):
@login_required
def search_attendance_requests(request):
field = request.GET.get("field")
requests = Attendance.objects.filter(
all_attendance = Attendance.objects.all()
if request.GET.get("sortby"):
all_attendance = sortby(request, all_attendance, "sortby")
requests = all_attendance.filter(
is_validate_request=True, employee_id__is_active=True
)
requests = filtersubordinates(
@@ -337,7 +341,7 @@ def search_attendance_requests(request):
perm="attendance.view_attendance",
queryset=requests,
)
requests = requests | Attendance.objects.filter(
requests = requests | all_attendance.filter(
employee_id__employee_user_id=request.user,
is_validate_request=True,
)
@@ -345,9 +349,9 @@ def search_attendance_requests(request):
attendances = filtersubordinates(
request=request,
perm="attendance.view_attendance",
queryset=Attendance.objects.all(),
queryset=all_attendance.all(),
)
attendances = attendances | Attendance.objects.filter(
attendances = attendances | all_attendance.filter(
employee_id__employee_user_id=request.user
)
attendances = AttendanceFilters(request.GET, attendances).qs