Overview
Managers of mobile and field workforces have no easy way to see where on-duty staff are during the day. This module extends the AlshayebCo HR Attendance mobile app with consent-based live location tracking: employees opt in, their phone sends periodic GPS pings, and managers fetch a live team view scoped strictly to their own direct reports. It stores each point in a dedicated log model, enforces opt-in on the server, and automatically purges location data older than 30 days to keep tracking privacy-respecting and storage lean.
Key Features
- Records timestamped GPS pings (latitude, longitude, accuracy, battery level, source) per employee in a dedicated hr.location.ping log.
- Per-employee opt-in toggle and configurable ping interval (60–3600 seconds), so tracking only happens with explicit consent.
- Server-side opt-in enforcement rejects any ping submitted by an employee who has not opted in.
- Validates and sanitises incoming coordinates and clamps stale client timestamps to prevent bad or backdated data.
- Manager team-map endpoint returns the latest position per teammate in a single efficient grouped query, with avatar and check-in/check-out status.
- Per-employee location-trail history endpoint scoped to a chosen time window (default 8 hours) for reviewing a worker's route.
- Manager access is restricted to their own reporting line via record rules — team leads see only direct reports, HR managers see all.
- Daily auto-vacuum cron permanently deletes location pings older than 30 days for data minimisation.
- Tags each ping by source (attendance event, periodic, or manual) and links it to the originating attendance record when available.