Verfügbarkeit: nur tatsächlich freie Anhänger und Truhen auflisten

Belegte Fahrzeuge erscheinen nicht mehr in der Auswahl; die Kopfzeile
nennt weiterhin "x von y frei". Ist für eine Gruppe nichts frei, steht
dort ein kurzer Hinweis.
This commit is contained in:
torsten 2026-11-18 21:47:11 +01:00
parent 771954ba3d
commit f27dea310c
2 changed files with 26 additions and 30 deletions

View file

@ -474,17 +474,18 @@ function page_availability(array $user): void
}
$groups = ['trailer' => [], 'chest' => []];
$totals = ['trailer' => 0, 'chest' => 0];
$freeCount = 0;
if ($checked && !$errors) {
foreach (trailers_all() as $trailer) {
$conflicts = booking_conflicts((int) $trailer['id'], $from, $to);
$free = !$conflicts;
$freeCount += $free ? 1 : 0;
$groups[trailer_is_chest($trailer) ? 'chest' : 'trailer'][] = [
'trailer' => $trailer,
'free' => $free,
'conflicts' => $conflicts,
];
$key = trailer_is_chest($trailer) ? 'chest' : 'trailer';
$totals[$key]++;
// Nur tatsächlich freie Fahrzeuge ausweisen; belegte entfallen.
if (booking_conflicts((int) $trailer['id'], $from, $to)) {
continue;
}
$freeCount++;
$groups[$key][] = ['trailer' => $trailer];
}
}
@ -494,8 +495,9 @@ function page_availability(array $user): void
'checked' => $checked,
'errors' => $errors,
'groups' => $groups,
'totals' => $totals,
'freeCount' => $freeCount,
'total' => count($groups['trailer']) + count($groups['chest']),
'total' => $totals['trailer'] + $totals['chest'],
'user' => $user,
], 'Verfügbarkeit');
}