Show only guards with driver's licenses and update site filtering

Modify the query to include guards with driver's licenses and use a left join for service types.

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/AXEqh9q
This commit is contained in:
marco370 2025-10-23 10:38:40 +00:00
parent 392079d2a1
commit bf5cfdcd50

View File

@ -3199,7 +3199,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
longitude: sites.longitude,
})
.from(sites)
.innerJoin(serviceTypes, eq(sites.serviceTypeId, serviceTypes.id))
.leftJoin(serviceTypes, eq(sites.serviceTypeId, serviceTypes.id))
.where(
and(
eq(sites.location, location as "roccapiemonte" | "milano" | "roma"),
@ -3235,17 +3235,18 @@ export async function registerRoutes(app: Express): Promise<Server> {
return res.status(400).json({ message: "Invalid date format (use YYYY-MM-DD)" });
}
// Ottieni tutte le guardie per location
// Ottieni tutte le guardie per location CHE HANNO LA PATENTE
const allGuards = await db
.select()
.from(guards)
.where(
and(
eq(guards.location, location as "roccapiemonte" | "milano" | "roma"),
eq(guards.isActive, true)
eq(guards.isActive, true),
eq(guards.hasDriverLicense, true)
)
)
.orderBy(guards.lastName, guards.firstName);
.orderBy(guards.lastName);
// Calcola settimana corrente per calcolare ore settimanali
const [year, month, day] = date.split("-").map(Number);