2.2 KiB
2.2 KiB
PLAN: Multi-Branch Attendance
Target Files:
branch-agent/sync.jsapp/Http/Controllers/Api/AttendanceSyncController.phpapp/Http/Controllers/BiometricAttendanceController.phpapp/Http/Controllers/AttendanceRecordController.phpdatabase/migrations/xxxx_add_branch_id_to_attendance_records.php(if needed)
Phase 0: Context & Socratic Alignment
- Problem: Employees travel and clock in at multiple branches. Currently, the dashboard filters attendance based on the Employee's "Home Branch", which hides their records from the branch they actually visited.
- Goal: The dashboard must show attendance records based on where they physically punched in.
- Agent Change: The local agent shouldn't restrict punches. We will keep
BRANCH_IDin the.envsolely to tell the cloud where the machine is located, but we will remove any restrictions that block employees from other branches.
Phase 1: Database & Sync Engine Updates
- AttendanceRecord Migration:
- Check if
attendance_recordstable has abranch_idcolumn. If not, create a migration to add it. - This column will store the physical location where the punch happened.
- Check if
- Sync Logic (
BiometricAttendanceController@syncAll):- When converting a
biometric_attendancerecord into a finalattendance_record, map thebranch_idfrom the physical ZKTeco punch directly into theattendance_record, bypassing the employee's default home branch.
- When converting a
Phase 2: Web Dashboard & Filtering Updates
- Dashboard Query (
AttendanceRecordController@index):- Update the branch filter. Instead of searching
employee.branch_id, it must search theattendance_records.branch_id(the actual location of the punch). - This ensures Branch Managers can see anyone who clocked in at their building, even if the employee officially belongs to another branch.
- Update the branch filter. Instead of searching
Phase 3: Verification Checklist
- Ensure the sync engine correctly assigns the punch location's
branch_idto the final attendance record. - Verify that a Branch Manager can see a visiting employee's punch on their dashboard.
- Verify that the local agent still sends its location identity to the API without blocking unassigned employees.