Introduce location filtering to operational planning, site management, and resource availability queries. This includes backend route modifications to handle location parameters and frontend updates for location selection and display. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e5565357-90e1-419f-b9a8-6ee8394636df Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/e5565357-90e1-419f-b9a8-6ee8394636df/5GnGQQ0
7.8 KiB
VigilanzaTurni - Sistema Gestione Turni per Istituti di Vigilanza
Overview
VigilanzaTurni is a professional 24/7 shift management system designed for security companies. It offers multi-role authentication (Admin, Coordinator, Guard, Client), comprehensive guard and site management, 24/7 shift planning, a live operational dashboard with KPIs, reporting for worked hours, and a notification system. The system supports multi-location operations (Roccapiemonte, Milano, Roma) managing 250+ security personnel across different branches. The project aims to streamline operations and enhance efficiency for security institutes.
User Preferences
- Interfaccia in italiano
- Dark mode di default
- Design operativo e funzionale (non decorativo)
- Focus su efficienza e densità informativa
- Testing: Tutti i test vengono eseguiti ESCLUSIVAMENTE sul server esterno (vt.alfacom.it) con autenticazione locale (non Replit Auth)
System Architecture
Stack Tecnologico
- Frontend: React + TypeScript + Tailwind CSS + Shadcn UI
- Backend: Express.js + TypeScript
- Database: PostgreSQL (Neon) with Drizzle ORM
- Autenticazione: Replit Auth (OIDC)
- State Management: TanStack Query v5
- Routing: Wouter
Design System
- Font Principale: Inter (sans-serif)
- Font Monospace: JetBrains Mono
- Colori: Primary Blue, Status Green, Orange, Red, Gray for various operational states.
- Tema: Dark mode by default, with light mode support.
- Componenti: Shadcn UI with an operational design.
Database Schema
The database includes core tables for users, guards, certifications, sites, shifts, shift_assignments, and notifications. Advanced scheduling and constraints are managed via guard_constraints, site_preferences, contract_parameters, training_courses, holidays, holiday_assignments, absences, and absence_affected_shifts. All tables include appropriate foreign keys and unique constraints to maintain data integrity.
Recent Schema Updates (October 2025):
- Service types now include specialized parameters:
fixedPostHours(ore presidio fisso),patrolPassages(numero passaggi pattuglia),inspectionFrequency(frequenza ispezioni),responseTimeMinutes(tempo risposta pronto intervento) - Sites include service schedule fields:
serviceStartTimeandserviceEndTime(formato HH:MM) - Contract Management: Sites now include contract fields:
contractReference(codice contratto),contractStartDate,contractEndDate(date validità contratto in formato YYYY-MM-DD) - Sites now reference service types via
serviceTypeIdforeign key;shiftTypeis optional and can be derived from service type - Multi-Location Support: Added
locationfield (enum: roccapiemonte, milano, roma) tosites,guards, andvehiclestables for complete multi-sede resource isolation
Recent Features (October 17, 2025):
- Multi-Sede Operational Planning: Redesigned operational planning workflow with location-first approach:
- Select sede (Roccapiemonte/Milano/Roma) - first step with default value
- Select date
- View uncovered sites filtered by selected sede
- Select site → view available resources (guards and vehicles) filtered by sede
- Assign resources and create shift
- Location-Based Filtering: Backend endpoints use INNER JOIN with sites table to ensure complete resource isolation between locations - guards/vehicles in one sede remain available even when assigned to shifts in other sedi
- Site Management: Added sede selection in site creation/editing forms with visual badges showing location in site listings
Recent Bug Fixes (October 17, 2025):
- Operational Planning Date Handling: Fixed date sanitization in
/api/operational-planning/uncovered-sitesand/api/operational-planning/availabilityendpoints to handle malformed date inputs (e.g., "2025-10-17/2025-10-17"). Both endpoints now validate dates usingparseISO/isValidand return 400 for invalid formats. - Checkbox Event Propagation: Fixed double-toggle bug in operational planning resource selection by wrapping vehicle and guard checkboxes in
<div onClick={e => e.stopPropagation()}>to prevent Card onClick from firing when clicking checkboxes. - Multi-Sede Resource Isolation: Fixed critical bug where resources from different sedi were incorrectly marked as unavailable due to global shift queries. Now both availability and uncovered-sites endpoints filter shifts by location using JOIN with sites table.
- QueryKey Cache Invalidation: Fixed queryKey structure from single-string to hierarchical array with custom queryFn to enable targeted cache invalidation by location and date while preventing URL concatenation errors.
API Endpoints
Comprehensive RESTful API endpoints are provided for Authentication, Users, Guards, Sites, Shifts, and Notifications, supporting full CRUD operations with role-based access control.
Frontend Routes
Key frontend routes include /, /guards, /sites, /shifts, /reports, /notifications, and /users, with access controlled by user roles.
User Roles
- Admin: Full access to all functionalities, managing guards, sites, shifts, and reports.
- Coordinator: Shift planning, guard assignment, operational site management, and reporting.
- Guard: View assigned shifts, future time-punching, notifications, and personal profile.
- Client: View assigned sites, service reporting, and KPIs.
Key Features
- Dashboard Operativa: Live KPIs (active shifts, total guards, active sites, expiring certifications) and real-time shift status.
- Gestione Guardie: Complete profiles with skill matrix (armed, fire safety, first aid, driver's license), certification management with automatic expiry, and unique badge numbers.
- Gestione Siti/Commesse: Service types with specialized parameters (fixed post hours, patrol passages, inspection frequency, response time) and minimum requirements (guard count, armed, driver's license). Sites include service schedule (start/end time), contract management (reference code, validity period with start/end dates), and location/sede assignment. Contract status is visualized with badges (active/expiring/expired) and enforces shift creation only within active contract periods.
- Pianificazione Operativa Multi-Sede: Location-aware workflow for shift assignment:
- Select sede (Roccapiemonte/Milano/Roma) → filters all subsequent data by location
- Select date → view uncovered sites with coverage status (sede-filtered)
- Select site → view available resources (guards and vehicles matching sede and requirements)
- Assign resources → create shift with atomic guard assignments and vehicle allocation
- Pianificazione Turni: 24/7 calendar, manual guard assignment, basic constraints, and shift statuses (planned, active, completed, cancelled).
- Reportistica: Total hours worked, monthly hours per guard, shift statistics, and data export capabilities.
- Advanced Planning: Management of guard constraints (preferences, max hours, rest days), site preferences (preferred/blacklisted guards), contract parameters, training courses, holidays, and absences with substitution system.
External Dependencies
- Replit Auth: For OpenID Connect (OIDC) based authentication.
- Neon: Managed PostgreSQL database service.
- Tailwind CSS: For utility-first CSS styling.
- Shadcn UI: For UI components.
- Zod: For schema validation.
- TanStack Query: For data fetching and state management.
- Wouter: For client-side routing.
- date-fns: For date manipulation and formatting.
- PM2: Production process manager for Node.js applications.
- Nginx: As a reverse proxy for the production environment.
- Let's Encrypt: For SSL/TLS certificates.
- GitLab CI/CD: For continuous integration and deployment.