CRM: Calendar and scheduling
Technical specification for the calendar and scheduling module in the PestControlOS CRM (PWA).
Data model
- Firestore: Calendar events stored in collections named
*_workview(e.g. per technician or per user). Document fields: event type (contract, job, follow-up), start time, end time, status (Scheduled, In Progress, Completed, Cancelled), assigned technician, linked job/contract IDs. Date normalization applied for cross-platform compatibility with Android Work View. - Google Calendar API: Optional sync or integration; primary source of truth is Firestore for CRM–Android consistency.
Behaviour
- Monthly calendar view: Display month grid; events shown per day. Create event (contract, job, follow-up); edit event; update status.
- Status lifecycle: Scheduled → In Progress → Completed or Cancelled. UI and rules enforce valid transitions.
- Multi-technician: Admin and super_admin can view and manage all technicians’ calendars (read/write all
*_workviewcollections). Technicians can only read/write their own workview collection. Firestore rules enforce: allow read, write only whererequest.auth.token.contractKey == collectionUserIdorrequest.auth.token.role in ['admin','super_admin']. - Visual identification: Each technician’s events are color-coded in admin views (client-side or stored colour per technician in
staffor config).
Rules
- Calendar isolation: technician A cannot read/write technician B’s workview. Admin/super_admin can read/write any. Indexes required for queries by date range and technician.
Event–job linking
- Event can "Create New Job": prefill from event, assign technician (admin), save; creates JobWork document and updates event with
linkedJobId/linkedJobCollection. Event can "Link Existing Job": select from job list (admin: all jobs, tech: own); event document updated with job reference. Used for single source of truth between schedule and job lifecycle.