3.4 KiB
3.4 KiB
PLAN: Fix Attendance Calendar Validation & Display
Overview
The user reported an issue where updating an attendance record "won't allow" them to save. This occurs when an attendance record has a present status in the database but lacks clock_in and clock_out times (e.g., from imported legacy data).
The root causes are:
- Misleading UI Display: The calendar grid forcibly overrides the display status to
A(Absent) ifclock_inandclock_outare empty, even if the actual database record hasstatus = 'present'. This prompts the user to mistakenly think they need to "fix" it. - Strict Validation Block: When the user opens the modal and clicks "Save" to ensure it's marked as Present, the frontend and backend both strictly require
clock_inandclock_outtimes. Because the user leaves them blank (as they only want to confirm the "Present" status), the form silently fails validation in the UI and blocks submission.
Project Type
WEB
Success Criteria
- The calendar accurately displays
P(Present) if the database status ispresent, even if the time logs are empty (displaying "Present (No Times)"). - The UI and backend validation allow HR/Admins to save an attendance record as
Presentwithout forcing them to manually input arbitrary clock-in and clock-out times. - The user can successfully update Mark Edward's attendance records without being blocked by the strict time validation.
Tech Stack
- Laravel (Backend Controller)
- React/Inertia (Frontend Calendar & Modal Components)
File Structure
app/Http/Controllers/AttendanceRecordController.phpapp/Http/Requests/...(if applicable)resources/js/pages/hr/attendance-records/calendar.tsx
Task Breakdown
Task 1: Fix Calendar Status Display Logic
- Agent:
backend-specialist - Description: Update
AttendanceRecordController@calendarto respect thepresentstatus even when times are empty. - INPUT:
AttendanceRecordController.phplines handling status overrides (approx line 1056). - OUTPUT: Modified logic where
else if (!empty($record->clock_in) ...)is followed by a fallback that checks if$record->status === 'present', and returns'P'and'Present (No Times)'. - VERIFY: Load calendar, verify Mark Edward's 04/02 record shows as
P.
Task 2: Relax Backend Validation for Clock Times
- Agent:
backend-specialist - Description: Remove the strict
required_if:status,present,half_dayvalidation rules forclock_inandclock_outinAttendanceRecordController@storeandupdate. - INPUT:
AttendanceRecordController.phpvalidation arrays. - OUTPUT: Changed to
nullable|date_format:H:ior similar, removing the strict requirement. - VERIFY: API accepts PUT requests with empty times for present status.
Task 3: Relax Frontend Validation for Clock Times
- Agent:
frontend-specialist - Description: Update
calendar.tsxto remove the strictrequiredflag forclock_inandclock_outfields in theCrudFormModalconfiguration. - INPUT:
resources/js/pages/hr/attendance-records/calendar.tsx - OUTPUT:
required: falsefor both time fields. - VERIFY: User can click "Save" with empty time fields and the modal submits successfully.
✅ PHASE X: Verification
- No purple/violet hex codes
- No standard template layouts
- Socratic Gate was respected
- Run
python .agent/scripts/checklist.py .