Improve planning overview to show sites with active contracts
Update the general planning overview to filter sites by active contract dates and display a weekly summary of total guards needed, assigned, and missing. 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/uZXH8P1
This commit is contained in:
parent
63ce62ee24
commit
4d6fb9dff8
@ -47,8 +47,10 @@ The database includes core tables for `users`, `guards`, `certifications`, `site
|
|||||||
- **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
|
- **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
|
- **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:
|
- **Planning Generale (October 18, 2025)**: New weekly planning overview feature showing all sites × 7 days in table format:
|
||||||
|
- **Contract filtering**: Shows only sites with active contracts in the week dates (`contractStartDate <= weekEnd AND contractEndDate >= weekStart`)
|
||||||
- Backend endpoint `/api/general-planning?weekStart=YYYY-MM-DD&location=sede` with complex joins and location filtering
|
- 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)
|
- Automatic missing guards calculation: `ceil(totalShiftHours / maxHoursPerGuard) × minGuards - assignedGuards` (e.g., 24h shift, 2 guards min, 9h max = 6 total needed)
|
||||||
|
- **Weekly summary**: Shows total guards needed, guards assigned (counting slots, not unique people), and guards missing for the entire week
|
||||||
- Table cells display: assigned guards with hours, vehicles, missing guards badge (if any), shift count, total hours
|
- 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
|
- 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
|
- Dialog shows: shift count, total hours, guard list with hours and badge numbers, vehicle list, missing guards warning with explanation
|
||||||
|
|||||||
@ -1004,22 +1004,18 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
let totalGuardsNeededForWeek = 0;
|
let totalGuardsNeededForWeek = 0;
|
||||||
let totalGuardsAssignedForWeek = 0;
|
let totalGuardsAssignedForWeek = 0;
|
||||||
|
|
||||||
// Set per tracciare guardie uniche assegnate nella settimana
|
|
||||||
const uniqueGuardsInWeek = new Set<string>();
|
|
||||||
|
|
||||||
for (const day of weekData) {
|
for (const day of weekData) {
|
||||||
for (const siteData of day.sites) {
|
for (const siteData of day.sites) {
|
||||||
// Somma guardie necessarie (già calcolate per sito/giorno)
|
// Somma guardie necessarie (già calcolate per sito/giorno)
|
||||||
|
// totalGuardsNeeded per sito = guardsAssigned + missingGuards
|
||||||
totalGuardsNeededForWeek += (siteData.guardsAssigned + siteData.missingGuards);
|
totalGuardsNeededForWeek += (siteData.guardsAssigned + siteData.missingGuards);
|
||||||
|
|
||||||
// Traccia guardie uniche
|
// Somma slot guardia assegnati (non guardie uniche)
|
||||||
for (const guard of siteData.guards) {
|
// Questo conta ogni assegnazione, anche se la stessa guardia lavora più turni
|
||||||
uniqueGuardsInWeek.add(guard.guardId);
|
totalGuardsAssignedForWeek += siteData.guardsAssigned;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
totalGuardsAssignedForWeek = uniqueGuardsInWeek.size;
|
|
||||||
const totalGuardsMissingForWeek = Math.max(0, totalGuardsNeededForWeek - totalGuardsAssignedForWeek);
|
const totalGuardsMissingForWeek = Math.max(0, totalGuardsNeededForWeek - totalGuardsAssignedForWeek);
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user