3.0 KiB
3.0 KiB
PLAN: Attendance Device Type (Biometrics vs Web)
1. Context & Objectives
- Objective 1: Track the "source" or "device type" for every clock-in and clock-out event to differentiate between a standard Web Dashboard punch and a physical Biometric device (e.g., ZKTeco) punch.
- Objective 2: Display this device type clearly in the Attendance Record Details UI (
view.tsx) so HR and managers know exactly how the employee logged their time.
2. Technical Approach
Phase 1: Database Schema Updates
- Migration: Create a new migration for the
attendance_recordstable to add two new string columns:clock_in_source(nullable, e.g., 'web', 'zkteco', 'manual')clock_out_source(nullable, e.g., 'web', 'zkteco', 'manual')
Phase 2: Backend Logic Integration
- Web Clock-in/out:
- Update
AttendanceRecordController@clockInto save'clock_in_source' => 'web'. - Update
AttendanceRecordController@clockOutto save'clock_out_source' => 'web'.
- Update
- Biometric / ZKTeco Sync:
- Locate the controller or service responsible for syncing biometrics (e.g.,
BiometricAttendanceControlleror a webhook handler). - Ensure that when it creates an attendance record from a device punch, it explicitly sets the source to
'zkteco'(or the specific device name if your system supports multiple devices).
- Locate the controller or service responsible for syncing biometrics (e.g.,
- Manual Overrides:
- If a manager manually creates or edits a record from the admin panel, set the source to
'manual'or'admin'.
- If a manager manually creates or edits a record from the admin panel, set the source to
Phase 3: UI Enhancements
- View Modal (
view.tsx):- Under the Clock In and Clock Out times where we recently added the Location pins, add a new visual indicator (like a small badge or icon) showing the source.
- Examples: a Laptop icon for "Web", a Fingerprint icon for "Biometric/ZKTeco", and a User-Cog icon for "Manual/HR Override".
- List View / Table (Optional but recommended):
- Expose the source in the main Attendance Records data grid if useful for filtering.
3. Execution Steps
- Generate and run database migration to add
clock_in_sourceandclock_out_source. - Update
AttendanceRecordControllerto inject the 'web' and 'manual' sources. - Update the Biometric sync logic to inject the 'zkteco' source.
- Update
resources/js/pages/hr/attendance-records/view.tsxto display the device/source type with appropriate icons.
4. Open Questions (Socratic Gate)
- Clock-In vs Clock-Out Sources: Does it happen often that an employee clocks in via the Web but clocks out via ZKTeco (or vice versa)? Should we track the source for both punches individually as proposed, or just a single
sourcefor the whole day? - Biometric Infrastructure: How are ZKTeco records currently being synced to your system? Do you have an existing cron job, API webhook, or a manual sync button that I will need to update?
- Specific Device Names: Do you just want it to say "Biometric/ZKTeco", or do you actually want to capture the specific device's IP/Name (e.g., "ZKTeco - Main Gate") if multiple devices exist?