diff --git a/app.py b/app.py index 11c9a9c..38f1041 100644 --- a/app.py +++ b/app.py @@ -7164,6 +7164,7 @@ def export_time_attendance(): start_date = request.args.get('start_date') end_date = request.args.get('end_date') import_batch = request.args.get('import_batch') + project_filter = request.args.get('project_id') # Build query with same filters as the view from models.time_attendance import TimeAttendance @@ -7195,6 +7196,9 @@ def export_time_attendance(): if import_batch: query = query.filter(TimeAttendance.import_batch_id == import_batch) + if project_filter: + query = query.filter(TimeAttendance.project_id == project_filter) + # Order by date and time (most recent first) records = query.order_by( TimeAttendance.attendance_date.desc(), @@ -7410,6 +7414,7 @@ def time_attendance_records(): location_filter = request.args.get('location_name') start_date = request.args.get('start_date') end_date = request.args.get('end_date') + project_filter = request.args.get('project_id') page = request.args.get('page', 1, type=int) per_page = 50 # Records per page @@ -7422,6 +7427,9 @@ def time_attendance_records(): if location_filter: query = query.filter(TimeAttendance.location_name == location_filter) + + if project_filter: + query = query.filter(TimeAttendance.project_id == project_filter) if start_date: try: @@ -7477,12 +7485,14 @@ def time_attendance_records(): # Get unique employees and locations for filters unique_employees = TimeAttendance.get_unique_employees() unique_locations = TimeAttendance.get_unique_locations() + projects = Project.query.filter_by(active_status=True).order_by(Project.name).all() return render_template( 'time_attendance_records.html', records=records, unique_employees=unique_employees, - unique_locations=unique_locations + unique_locations=unique_locations, + projects=projects ) except Exception as e: diff --git a/static/css/time_attendance.css b/static/css/time_attendance.css index 92e8412..ab26277 100644 --- a/static/css/time_attendance.css +++ b/static/css/time_attendance.css @@ -371,7 +371,7 @@ body.has-sidebar .time-attendance-page { .filter-form { display: grid; - grid-template-columns: repeat(4, 1fr); /* 4 equal columns */ + grid-template-columns: repeat(5, 1fr); /* 5 equal columns */ gap: 1rem; align-items: end; } @@ -401,7 +401,7 @@ body.has-sidebar .time-attendance-page { /* Responsive */ @media (max-width: 1200px) { .filter-form { - grid-template-columns: repeat(2, 1fr); /* 2 columns on medium screens */ + grid-template-columns: repeat(3, 1fr); /* 2 columns on medium screens */ } } diff --git a/templates/time_attendance_records.html b/templates/time_attendance_records.html index b1d0629..2a415dd 100644 --- a/templates/time_attendance_records.html +++ b/templates/time_attendance_records.html @@ -79,6 +79,18 @@ {% endfor %} + +
+ + +
@@ -355,8 +367,9 @@ function exportRecords(format) { document.getElementById('exportMenu').style.display = 'none'; // Get current filter values - const employeeId = document.querySelector('input[name="employee_id"]')?.value || ''; - const locationName = document.querySelector('input[name="location_name"]')?.value || ''; + const employeeId = document.querySelector('select[name="employee_id"]')?.value || ''; + const locationName = document.querySelector('select[name="location_name"]')?.value || ''; + const projectId = document.querySelector('select[name="project_id"]')?.value || ''; // ADD THIS LINE const startDate = document.querySelector('input[name="start_date"]')?.value || ''; const endDate = document.querySelector('input[name="end_date"]')?.value || ''; @@ -364,6 +377,7 @@ function exportRecords(format) { const params = new URLSearchParams(); if (employeeId) params.append('employee_id', employeeId); if (locationName) params.append('location_name', locationName); + if (projectId) params.append('project_id', projectId); // ADD THIS LINE if (startDate) params.append('start_date', startDate); if (endDate) params.append('end_date', endDate); params.append('format', format);