[UPDT] ATTENDANCE: Added filter to work records

This commit is contained in:
Horilla
2024-06-12 15:46:03 +05:30
parent f1a8c939f8
commit 431ccb191d
3 changed files with 45 additions and 6 deletions

View File

@@ -295,7 +295,7 @@ def clock_out_attendance_and_activity(employee, date_today, now, out_datetime=No
"""
attendance_activities = AttendanceActivity.objects.filter(
employee_id=employee
employee_id=employee, clock_out__isnull=True
).order_by("attendance_date", "id")
if attendance_activities.exists():
attendance_activity = attendance_activities.last()

View File

@@ -73,6 +73,7 @@ from base.methods import (
get_pagination,
)
from base.models import EmployeeShiftSchedule
from employee.filters import EmployeeFilter
from employee.models import Employee, EmployeeWorkInformation
from horilla.decorators import (
hx_request_required,
@@ -2030,6 +2031,7 @@ def work_records(request):
@hx_request_required
def work_records_change_month(request):
previous_data = request.GET.urlencode()
employee_filter_form = EmployeeFilter()
if request.GET.get("month"):
date_obj = request.GET.get("month")
month = int(date_obj.split("-")[1])
@@ -2040,6 +2042,9 @@ def work_records_change_month(request):
schedules = list(EmployeeShiftSchedule.objects.all())
employees = list(Employee.objects.filter(is_active=True))
if request.method == "POST":
employee_filter_form = EmployeeFilter(request.POST)
employees = list(employee_filter_form.qs)
data = []
month_matrix = calendar.monthcalendar(year, month)
@@ -2093,6 +2098,7 @@ def work_records_change_month(request):
"data": data,
"pd": previous_data,
"current_date": date.today(),
"f": employee_filter_form,
}
return render(
request, "attendance/work_record/work_record_list.html", context=context