From f27dea310c41b9870d99d7a45045c62cbbfaf3c7 Mon Sep 17 00:00:00 2001 From: torsten Date: Wed, 18 Nov 2026 21:47:11 +0100 Subject: [PATCH] =?UTF-8?q?Verf=C3=BCgbarkeit:=20nur=20tats=C3=A4chlich=20?= =?UTF-8?q?freie=20Anh=C3=A4nger=20und=20Truhen=20auflisten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/pages.php | 20 +++++++++++--------- views/availability.php | 36 +++++++++++++++--------------------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/app/pages.php b/app/pages.php index 16ba468..be9de9d 100644 --- a/app/pages.php +++ b/app/pages.php @@ -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'); } diff --git a/views/availability.php b/views/availability.php index 11839a1..ae38826 100644 --- a/views/availability.php +++ b/views/availability.php @@ -10,8 +10,16 @@ $fieldError = static fn (string $key): string => (string) ($errors[$key] ?? ''); $bookingUrl = static fn (array $trailer): string => '/bookings/new?trailer=' . (int) $trailer['id'] . '&start=' . rawurlencode($from) . '&end=' . rawurlencode($to); $groupMeta = [ - 'trailer' => ['title' => 'Anhänger', 'empty' => 'Keine Anhänger hinterlegt.'], - 'chest' => ['title' => 'Truhen', 'empty' => 'Keine Truhen hinterlegt.'], + 'trailer' => [ + 'title' => 'Anhänger', + 'empty' => 'Keine Anhänger hinterlegt.', + 'none_free' => 'Im Zeitraum ist kein Anhänger frei.', + ], + 'chest' => [ + 'title' => 'Truhen', + 'empty' => 'Keine Truhen hinterlegt.', + 'none_free' => 'Im Zeitraum ist keine Truhe frei.', + ], ]; ?>
@@ -70,41 +78,27 @@ $groupMeta = [ $meta): ?> $row['free'])); + $groupTotal = (int) ($totals[$key] ?? 0); ?>

- von frei + von frei

-

+