2.9 KiB
2.9 KiB
PLAN - Out of Radius Clock-In Warning
1. Context & Objective
The user wants to remove the explicit "Location Exempt" toggle from the employee profile. Instead, the new behavior should apply to all employees: they can clock in/out from anywhere, but if they attempt to clock in/out outside of the designated branch radius (or without location data), they should be presented with a confirmation modal warning them that they are out of bounds.
The objective is to:
- Remove
is_location_exemptfields from the Employee forms. - Modify
AttendanceRecordControllerto remove the strict geofence block and instead return a warning trigger to the frontend. - Update
employee-dashboard.tsxto catch this warning, display a confirmation modal, and allow the user to force the clock-in/out.
2. Target Files
resources/js/pages/hr/employees/create.tsxresources/js/pages/hr/employees/edit.tsxapp/Http/Controllers/EmployeeController.phpapp/Http/Controllers/AttendanceRecordController.phpresources/js/pages/employee-dashboard.tsx
3. Task Breakdown
Phase 1: Clean up Employee Forms and Controller
- Remove the
is_location_exemptSwitch, Label, and Tooltip fromcreate.tsxandedit.tsx. - (Optional but recommended) Remove
is_location_exempthandling inEmployeeController.phpto clean up the backend.
Phase 2: Modify Attendance Logic (Backend)
- In
AttendanceRecordController.php(clockInandclockOut), remove theif (!$user->is_location_exempt)condition. - Add a check for
$request->input('force_location', false). - If the employee is out of radius or location is missing, and
force_locationis false, returnredirect()->back()->with('location_warning', __('You are outside the required branch radius. Do you want to proceed?'));instead of an error. - If
force_locationis true, bypass the radius check and allow the clock in/out.
Phase 3: Implement Confirmation Modal (Frontend)
- In
employee-dashboard.tsx, add state variables:showLocationWarningModal(boolean),pendingAction('in' | 'out' | null), andpendingCoords(latitude/longitude). - Update
sendClockInRequestandsendClockOutRequestto accept aforceboolean parameter (defaults to false). - Pass
force_location: forcein the request payload. - In the Inertia
onSuccesscallback, check ifpage.props.flash?.location_warningexists. If so, open the modal and save the action and coords to state. - Create a
<Dialog>component (Confirmation Modal) that asks the user if they want to proceed. - On Confirm, call
sendClockInRequestorsendClockOutRequestwith the saved coords andforce = true.
4. Verification Checklist
- Verify
is_location_exemptis removed from Add/Edit Employee pages. - Clock in while outside the radius and verify the modal appears.
- Confirm the modal and verify the clock in is successful.
- Repeat the test for clocking out.