Enhance planning features with multi-location support and weekly overview

Add location-based resource isolation, a general weekly planning overview with missing guard calculation, and improve operational planning page integration.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: e5565357-90e1-419f-b9a8-6ee8394636df
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/e5565357-90e1-419f-b9a8-6ee8394636df/uZXH8P1
This commit is contained in:
marco370 2025-10-18 07:27:10 +00:00
parent cafaa76608
commit edbd1f1aae
2 changed files with 10 additions and 5 deletions

View File

@ -31,10 +31,6 @@ externalPort = 3002
localPort = 43267
externalPort = 3003
[[ports]]
localPort = 44791
externalPort = 4200
[env]
PORT = "5000"

View File

@ -37,7 +37,7 @@ The database includes core tables for `users`, `guards`, `certifications`, `site
- Sites now reference service types via `serviceTypeId` foreign key; `shiftType` is optional and can be derived from service type
- **Multi-Location Support**: Added `location` field (enum: roccapiemonte, milano, roma) to `sites`, `guards`, and `vehicles` tables for complete multi-sede resource isolation
**Recent Features (October 17, 2025)**:
**Recent Features (October 17-18, 2025)**:
- **Multi-Sede Operational Planning**: Redesigned operational planning workflow with location-first approach:
1. Select sede (Roccapiemonte/Milano/Roma) - first step with default value
2. Select date
@ -46,6 +46,15 @@ The database includes core tables for `users`, `guards`, `certifications`, `site
5. 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
- **Planning Generale (October 18, 2025)**: New weekly planning overview feature showing all sites × 7 days in table format:
- Backend endpoint `/api/general-planning?weekStart=YYYY-MM-DD&location=sede` with complex joins and location filtering
- Automatic missing guards calculation: `ceil(totalShiftHours / maxHoursPerGuard) × minGuards - assignedGuards` (e.g., 24h shift, 2 guards min, 9h max = 6 total needed)
- Table cells display: assigned guards with hours, vehicles, missing guards badge (if any), shift count, total hours
- Interactive cells with click handler opening detail dialog
- Dialog shows: shift count, total hours, guard list with hours and badge numbers, vehicle list, missing guards warning with explanation
- "Modifica in Pianificazione Operativa" button in dialog navigates to operational planning page with pre-filled date/location parameters
- Week navigation (previous/next week) with location selector
- Operational planning page now supports query parameters (`?date=YYYY-MM-DD&location=sede`) for seamless integration
**Recent Bug Fixes (October 17, 2025)**:
- **Operational Planning Date Handling**: Fixed date sanitization in `/api/operational-planning/uncovered-sites` and `/api/operational-planning/availability` endpoints to handle malformed date inputs (e.g., "2025-10-17/2025-10-17"). Both endpoints now validate dates using `parseISO`/`isValid` and return 400 for invalid formats.