Compare commits
No commits in common. "fecfe44542fdb64491289de06b08479e1f62e1c1" and "278419c4ff59da12cb032ab14ba03b6c7bd7ca9e" have entirely different histories.
fecfe44542
...
278419c4ff
@ -22,7 +22,6 @@ import Vehicles from "@/pages/vehicles";
|
|||||||
import Parameters from "@/pages/parameters";
|
import Parameters from "@/pages/parameters";
|
||||||
import Services from "@/pages/services";
|
import Services from "@/pages/services";
|
||||||
import Planning from "@/pages/planning";
|
import Planning from "@/pages/planning";
|
||||||
import OperationalPlanning from "@/pages/operational-planning";
|
|
||||||
|
|
||||||
function Router() {
|
function Router() {
|
||||||
const { isAuthenticated, isLoading } = useAuth();
|
const { isAuthenticated, isLoading } = useAuth();
|
||||||
@ -41,7 +40,6 @@ function Router() {
|
|||||||
<Route path="/vehicles" component={Vehicles} />
|
<Route path="/vehicles" component={Vehicles} />
|
||||||
<Route path="/shifts" component={Shifts} />
|
<Route path="/shifts" component={Shifts} />
|
||||||
<Route path="/planning" component={Planning} />
|
<Route path="/planning" component={Planning} />
|
||||||
<Route path="/operational-planning" component={OperationalPlanning} />
|
|
||||||
<Route path="/advanced-planning" component={AdvancedPlanning} />
|
<Route path="/advanced-planning" component={AdvancedPlanning} />
|
||||||
<Route path="/reports" component={Reports} />
|
<Route path="/reports" component={Reports} />
|
||||||
<Route path="/notifications" component={Notifications} />
|
<Route path="/notifications" component={Notifications} />
|
||||||
|
|||||||
@ -49,12 +49,6 @@ const menuItems = [
|
|||||||
icon: ClipboardList,
|
icon: ClipboardList,
|
||||||
roles: ["admin", "coordinator"],
|
roles: ["admin", "coordinator"],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: "Pianificazione Operativa",
|
|
||||||
url: "/operational-planning",
|
|
||||||
icon: Calendar,
|
|
||||||
roles: ["admin", "coordinator"],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: "Gestione Pianificazioni",
|
title: "Gestione Pianificazioni",
|
||||||
url: "/advanced-planning",
|
url: "/advanced-planning",
|
||||||
|
|||||||
@ -1,336 +0,0 @@
|
|||||||
import { useState } from "react";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { Label } from "@/components/ui/label";
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
|
||||||
import { Calendar, Car, Users, Clock, AlertCircle, CheckCircle2, ArrowRight } from "lucide-react";
|
|
||||||
import { format } from "date-fns";
|
|
||||||
import { it } from "date-fns/locale";
|
|
||||||
|
|
||||||
interface AssignedShift {
|
|
||||||
id: string;
|
|
||||||
startTime: string;
|
|
||||||
endTime: string;
|
|
||||||
siteId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface VehicleAvailability {
|
|
||||||
id: string;
|
|
||||||
licensePlate: string;
|
|
||||||
brand: string;
|
|
||||||
model: string;
|
|
||||||
vehicleType: string;
|
|
||||||
location: string;
|
|
||||||
status: string;
|
|
||||||
isAvailable: boolean;
|
|
||||||
assignedShift: AssignedShift | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GuardAvailability {
|
|
||||||
id: string;
|
|
||||||
badgeNumber: string;
|
|
||||||
firstName: string;
|
|
||||||
lastName: string;
|
|
||||||
location: string;
|
|
||||||
isAvailable: boolean;
|
|
||||||
assignedShift: AssignedShift | null;
|
|
||||||
availability: {
|
|
||||||
weeklyHours: number;
|
|
||||||
remainingWeeklyHours: number;
|
|
||||||
remainingMonthlyHours: number;
|
|
||||||
consecutiveDaysWorked: number;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AvailabilityData {
|
|
||||||
date: string;
|
|
||||||
vehicles: VehicleAvailability[];
|
|
||||||
guards: GuardAvailability[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function OperationalPlanning() {
|
|
||||||
const [selectedDate, setSelectedDate] = useState<string>(
|
|
||||||
format(new Date(), "yyyy-MM-dd")
|
|
||||||
);
|
|
||||||
|
|
||||||
const { data, isLoading, refetch } = useQuery<AvailabilityData>({
|
|
||||||
queryKey: [`/api/operational-planning/availability?date=${selectedDate}`, selectedDate],
|
|
||||||
enabled: !!selectedDate,
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleDateChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
setSelectedDate(e.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const availableVehicles = data?.vehicles.filter((v) => v.isAvailable) || [];
|
|
||||||
const unavailableVehicles = data?.vehicles.filter((v) => !v.isAvailable) || [];
|
|
||||||
const availableGuards = data?.guards.filter((g) => g.isAvailable) || [];
|
|
||||||
const unavailableGuards = data?.guards.filter((g) => !g.isAvailable) || [];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="container mx-auto p-6 space-y-6">
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<div>
|
|
||||||
<h1 className="text-3xl font-bold flex items-center gap-2">
|
|
||||||
<Calendar className="h-8 w-8" />
|
|
||||||
Pianificazione Operativa
|
|
||||||
</h1>
|
|
||||||
<p className="text-muted-foreground mt-1">
|
|
||||||
Visualizza disponibilità automezzi e agenti per data
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Card>
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="flex items-center gap-2">
|
|
||||||
<Calendar className="h-5 w-5" />
|
|
||||||
Seleziona Data
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<div className="flex gap-4 items-end">
|
|
||||||
<div className="flex-1 max-w-xs">
|
|
||||||
<Label htmlFor="planning-date">Data</Label>
|
|
||||||
<Input
|
|
||||||
id="planning-date"
|
|
||||||
data-testid="input-planning-date"
|
|
||||||
type="date"
|
|
||||||
value={selectedDate}
|
|
||||||
onChange={handleDateChange}
|
|
||||||
className="mt-1"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
onClick={() => refetch()}
|
|
||||||
data-testid="button-refresh-availability"
|
|
||||||
>
|
|
||||||
Aggiorna Disponibilità
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
{data && (
|
|
||||||
<p className="text-sm text-muted-foreground mt-4">
|
|
||||||
Visualizzando disponibilità per: {format(new Date(selectedDate), "dd MMMM yyyy", { locale: it })}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
|
||||||
{/* Veicoli */}
|
|
||||||
<Card>
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="flex items-center gap-2">
|
|
||||||
<Car className="h-5 w-5" />
|
|
||||||
Automezzi Disponibili
|
|
||||||
<Badge variant="secondary" className="ml-auto">
|
|
||||||
{availableVehicles.length}/{data?.vehicles.length || 0}
|
|
||||||
</Badge>
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="space-y-3">
|
|
||||||
{isLoading ? (
|
|
||||||
<>
|
|
||||||
<Skeleton className="h-20 w-full" />
|
|
||||||
<Skeleton className="h-20 w-full" />
|
|
||||||
<Skeleton className="h-20 w-full" />
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{/* Veicoli disponibili */}
|
|
||||||
{availableVehicles.length > 0 ? (
|
|
||||||
availableVehicles.map((vehicle) => (
|
|
||||||
<Card key={vehicle.id} className="bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-800">
|
|
||||||
<CardContent className="p-4">
|
|
||||||
<div className="flex items-start justify-between">
|
|
||||||
<div className="flex-1">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<CheckCircle2 className="h-4 w-4 text-green-600" />
|
|
||||||
<h4 className="font-semibold">{vehicle.licensePlate}</h4>
|
|
||||||
<Badge variant="outline" className="text-xs">
|
|
||||||
{vehicle.location}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
<p className="text-sm text-muted-foreground mt-1">
|
|
||||||
{vehicle.brand} {vehicle.model} - {vehicle.vehicleType}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
data-testid={`button-assign-vehicle-${vehicle.id}`}
|
|
||||||
className="ml-2"
|
|
||||||
>
|
|
||||||
<ArrowRight className="h-4 w-4 mr-1" />
|
|
||||||
Assegna
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<p className="text-sm text-muted-foreground text-center py-4">
|
|
||||||
Nessun veicolo disponibile
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Veicoli non disponibili */}
|
|
||||||
{unavailableVehicles.length > 0 && (
|
|
||||||
<>
|
|
||||||
<div className="pt-3 border-t">
|
|
||||||
<h4 className="text-sm font-medium text-muted-foreground mb-3">Non Disponibili</h4>
|
|
||||||
</div>
|
|
||||||
{unavailableVehicles.map((vehicle) => (
|
|
||||||
<Card key={vehicle.id} className="bg-gray-50 dark:bg-gray-900/20">
|
|
||||||
<CardContent className="p-4">
|
|
||||||
<div className="flex items-start justify-between">
|
|
||||||
<div className="flex-1">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<AlertCircle className="h-4 w-4 text-orange-600" />
|
|
||||||
<h4 className="font-semibold">{vehicle.licensePlate}</h4>
|
|
||||||
<Badge variant="outline" className="text-xs">
|
|
||||||
{vehicle.location}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
<p className="text-sm text-muted-foreground mt-1">
|
|
||||||
{vehicle.brand} {vehicle.model}
|
|
||||||
</p>
|
|
||||||
{vehicle.assignedShift && (
|
|
||||||
<div className="flex items-center gap-1 mt-2 text-xs text-orange-600">
|
|
||||||
<Clock className="h-3 w-3" />
|
|
||||||
<span>
|
|
||||||
Assegnato: {format(new Date(vehicle.assignedShift.startTime), "HH:mm")} -
|
|
||||||
{format(new Date(vehicle.assignedShift.endTime), "HH:mm")}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
{/* Agenti */}
|
|
||||||
<Card>
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="flex items-center gap-2">
|
|
||||||
<Users className="h-5 w-5" />
|
|
||||||
Agenti Disponibili
|
|
||||||
<Badge variant="secondary" className="ml-auto">
|
|
||||||
{availableGuards.length}/{data?.guards.length || 0}
|
|
||||||
</Badge>
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="space-y-3">
|
|
||||||
{isLoading ? (
|
|
||||||
<>
|
|
||||||
<Skeleton className="h-20 w-full" />
|
|
||||||
<Skeleton className="h-20 w-full" />
|
|
||||||
<Skeleton className="h-20 w-full" />
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{/* Agenti disponibili */}
|
|
||||||
{availableGuards.length > 0 ? (
|
|
||||||
availableGuards.map((guard) => (
|
|
||||||
<Card key={guard.id} className="bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-800">
|
|
||||||
<CardContent className="p-4">
|
|
||||||
<div className="flex items-start justify-between">
|
|
||||||
<div className="flex-1">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<CheckCircle2 className="h-4 w-4 text-green-600" />
|
|
||||||
<h4 className="font-semibold">
|
|
||||||
{guard.firstName} {guard.lastName}
|
|
||||||
</h4>
|
|
||||||
<Badge variant="outline" className="text-xs">
|
|
||||||
{guard.badgeNumber}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-3 mt-2 text-xs text-muted-foreground">
|
|
||||||
<span className="flex items-center gap-1">
|
|
||||||
<Clock className="h-3 w-3" />
|
|
||||||
{guard.availability.weeklyHours.toFixed(1)}h questa settimana
|
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
Residuo: {guard.availability.remainingWeeklyHours.toFixed(1)}h
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
{guard.availability.consecutiveDaysWorked > 0 && (
|
|
||||||
<p className="text-xs text-orange-600 mt-1">
|
|
||||||
{guard.availability.consecutiveDaysWorked} giorni consecutivi
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
data-testid={`button-assign-guard-${guard.id}`}
|
|
||||||
className="ml-2"
|
|
||||||
>
|
|
||||||
<ArrowRight className="h-4 w-4 mr-1" />
|
|
||||||
Assegna
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<p className="text-sm text-muted-foreground text-center py-4">
|
|
||||||
Nessun agente disponibile
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Agenti non disponibili */}
|
|
||||||
{unavailableGuards.length > 0 && (
|
|
||||||
<>
|
|
||||||
<div className="pt-3 border-t">
|
|
||||||
<h4 className="text-sm font-medium text-muted-foreground mb-3">Non Disponibili</h4>
|
|
||||||
</div>
|
|
||||||
{unavailableGuards.map((guard) => (
|
|
||||||
<Card key={guard.id} className="bg-gray-50 dark:bg-gray-900/20">
|
|
||||||
<CardContent className="p-4">
|
|
||||||
<div className="flex items-start justify-between">
|
|
||||||
<div className="flex-1">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<AlertCircle className="h-4 w-4 text-orange-600" />
|
|
||||||
<h4 className="font-semibold">
|
|
||||||
{guard.firstName} {guard.lastName}
|
|
||||||
</h4>
|
|
||||||
<Badge variant="outline" className="text-xs">
|
|
||||||
{guard.badgeNumber}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
{guard.assignedShift && (
|
|
||||||
<div className="flex items-center gap-1 mt-2 text-xs text-orange-600">
|
|
||||||
<Clock className="h-3 w-3" />
|
|
||||||
<span>
|
|
||||||
Assegnato: {format(new Date(guard.assignedShift.startTime), "HH:mm")} -
|
|
||||||
{format(new Date(guard.assignedShift.endTime), "HH:mm")}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="flex items-center gap-3 mt-1 text-xs text-muted-foreground">
|
|
||||||
<span>{guard.availability.weeklyHours.toFixed(1)}h settimana</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Binary file not shown.
BIN
database-backups/vigilanzaturni_v1.0.4_20251017_065308.sql.gz
Normal file
BIN
database-backups/vigilanzaturni_v1.0.4_20251017_065308.sql.gz
Normal file
Binary file not shown.
122
server/routes.ts
122
server/routes.ts
@ -6,7 +6,7 @@ import { setupLocalAuth, isAuthenticated as isAuthenticatedLocal } from "./local
|
|||||||
import { db } from "./db";
|
import { db } from "./db";
|
||||||
import { guards, certifications, sites, shifts, shiftAssignments, users, insertShiftSchema, contractParameters } from "@shared/schema";
|
import { guards, certifications, sites, shifts, shiftAssignments, users, insertShiftSchema, contractParameters } from "@shared/schema";
|
||||||
import { eq, and, gte, lte, desc, asc } from "drizzle-orm";
|
import { eq, and, gte, lte, desc, asc } from "drizzle-orm";
|
||||||
import { differenceInDays, differenceInHours, differenceInMinutes, startOfWeek, endOfWeek, startOfMonth, endOfMonth, isWithinInterval, startOfDay, isSameDay, parseISO, format } from "date-fns";
|
import { differenceInDays, differenceInHours, differenceInMinutes, startOfWeek, endOfWeek, startOfMonth, endOfMonth, isWithinInterval, startOfDay, isSameDay, parseISO } from "date-fns";
|
||||||
|
|
||||||
// Determina quale sistema auth usare basandosi sull'ambiente
|
// Determina quale sistema auth usare basandosi sull'ambiente
|
||||||
const USE_LOCAL_AUTH = process.env.DOMAIN === "vt.alfacom.it" || !process.env.REPLIT_DOMAINS;
|
const USE_LOCAL_AUTH = process.env.DOMAIN === "vt.alfacom.it" || !process.env.REPLIT_DOMAINS;
|
||||||
@ -534,126 +534,6 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ============= OPERATIONAL PLANNING ROUTES =============
|
|
||||||
app.get("/api/operational-planning/availability", isAuthenticated, async (req, res) => {
|
|
||||||
try {
|
|
||||||
const { getGuardAvailabilityReport } = await import("./ccnlRules");
|
|
||||||
const dateStr = req.query.date as string || format(new Date(), "yyyy-MM-dd");
|
|
||||||
const date = new Date(dateStr + "T00:00:00.000Z");
|
|
||||||
|
|
||||||
// Imposta inizio e fine giornata in UTC
|
|
||||||
const startOfDay = new Date(dateStr + "T00:00:00.000Z");
|
|
||||||
const endOfDay = new Date(dateStr + "T23:59:59.999Z");
|
|
||||||
|
|
||||||
// Ottieni tutti i veicoli
|
|
||||||
const allVehicles = await storage.getAllVehicles();
|
|
||||||
|
|
||||||
// Ottieni turni del giorno per trovare veicoli assegnati
|
|
||||||
const dayShifts = await db
|
|
||||||
.select()
|
|
||||||
.from(shifts)
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
gte(shifts.startTime, startOfDay),
|
|
||||||
lte(shifts.startTime, endOfDay)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Mappa veicoli con disponibilità
|
|
||||||
const vehiclesWithAvailability = await Promise.all(
|
|
||||||
allVehicles.map(async (vehicle) => {
|
|
||||||
const assignedShift = dayShifts.find((shift: any) => shift.vehicleId === vehicle.id);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...vehicle,
|
|
||||||
isAvailable: !assignedShift,
|
|
||||||
assignedShift: assignedShift ? {
|
|
||||||
id: assignedShift.id,
|
|
||||||
startTime: assignedShift.startTime,
|
|
||||||
endTime: assignedShift.endTime,
|
|
||||||
siteId: assignedShift.siteId
|
|
||||||
} : null
|
|
||||||
};
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
// Ottieni tutte le guardie
|
|
||||||
const allGuards = await storage.getAllGuards();
|
|
||||||
|
|
||||||
// Ottieni assegnazioni turni del giorno
|
|
||||||
const dayShiftAssignments = await db
|
|
||||||
.select()
|
|
||||||
.from(shiftAssignments)
|
|
||||||
.innerJoin(shifts, eq(shiftAssignments.shiftId, shifts.id))
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
gte(shifts.startTime, startOfDay),
|
|
||||||
lte(shifts.startTime, endOfDay)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Calcola disponibilità agenti con report CCNL
|
|
||||||
const guardsWithAvailability = await Promise.all(
|
|
||||||
allGuards.map(async (guard) => {
|
|
||||||
const assignedShift = dayShiftAssignments.find(
|
|
||||||
(assignment: any) => assignment.shift_assignments.guardId === guard.id
|
|
||||||
);
|
|
||||||
|
|
||||||
// Calcola report disponibilità CCNL
|
|
||||||
const availabilityReport = await getGuardAvailabilityReport(
|
|
||||||
guard.id,
|
|
||||||
startOfDay,
|
|
||||||
endOfDay
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...guard,
|
|
||||||
isAvailable: !assignedShift,
|
|
||||||
assignedShift: assignedShift ? {
|
|
||||||
id: assignedShift.shifts.id,
|
|
||||||
startTime: assignedShift.shifts.startTime,
|
|
||||||
endTime: assignedShift.shifts.endTime,
|
|
||||||
siteId: assignedShift.shifts.siteId
|
|
||||||
} : null,
|
|
||||||
availability: {
|
|
||||||
weeklyHours: availabilityReport.weeklyHours.current,
|
|
||||||
remainingWeeklyHours: availabilityReport.remainingWeeklyHours,
|
|
||||||
remainingMonthlyHours: availabilityReport.remainingMonthlyHours,
|
|
||||||
consecutiveDaysWorked: availabilityReport.consecutiveDaysWorked
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
// Ordina veicoli: disponibili prima, poi per targa
|
|
||||||
const sortedVehicles = vehiclesWithAvailability.sort((a, b) => {
|
|
||||||
if (a.isAvailable && !b.isAvailable) return -1;
|
|
||||||
if (!a.isAvailable && b.isAvailable) return 1;
|
|
||||||
return a.licensePlate.localeCompare(b.licensePlate);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Ordina agenti: disponibili prima, poi per ore settimanali (meno ore = più disponibili)
|
|
||||||
const sortedGuards = guardsWithAvailability.sort((a, b) => {
|
|
||||||
if (a.isAvailable && !b.isAvailable) return -1;
|
|
||||||
if (!a.isAvailable && b.isAvailable) return 1;
|
|
||||||
// Se entrambi disponibili, ordina per ore settimanali (meno ore = prima)
|
|
||||||
if (a.isAvailable && b.isAvailable) {
|
|
||||||
return a.availability.weeklyHours - b.availability.weeklyHours;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
res.json({
|
|
||||||
date: dateStr,
|
|
||||||
vehicles: sortedVehicles,
|
|
||||||
guards: sortedGuards
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error fetching operational planning availability:", error);
|
|
||||||
res.status(500).json({ message: "Failed to fetch availability", error: String(error) });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// ============= CERTIFICATION ROUTES =============
|
// ============= CERTIFICATION ROUTES =============
|
||||||
app.post("/api/certifications", isAuthenticated, async (req, res) => {
|
app.post("/api/certifications", isAuthenticated, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
10
version.json
10
version.json
@ -1,13 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.14",
|
"version": "1.0.13",
|
||||||
"lastUpdate": "2025-10-17T13:25:44.910Z",
|
"lastUpdate": "2025-10-17T10:17:48.446Z",
|
||||||
"changelog": [
|
"changelog": [
|
||||||
{
|
|
||||||
"version": "1.0.14",
|
|
||||||
"date": "2025-10-17",
|
|
||||||
"type": "patch",
|
|
||||||
"description": "Deployment automatico v1.0.14"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"version": "1.0.13",
|
"version": "1.0.13",
|
||||||
"date": "2025-10-17",
|
"date": "2025-10-17",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user