diff --git a/README.md b/README.md index eed7c26..2188e82 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,9 @@ Die Anforderungen stammen aus Rechnung JA/NEIN samt Rechnungsnummer, Abholung/Lieferung und vollständigen Kundendaten. Das Formular folgt der Reihenfolge der Excel-Vorlage „Neuanlage"; eine kopierte Spalte wird beim Einfügen auf die Felder verteilt. +- **Verfügbarkeit prüfen**: Zeitraum wählen, freie und belegte Anhänger/Truhen + sehen und mit einem Klick in die neue Buchung springen (Knopf links neben + „Kalender" auf der Übersicht). - **Buchungstext kopieren** mit einem Klick – exakt in der geforderten Reihenfolge und mit erhaltenen Zeilenumbrüchen. - **Doppelbelegungsschutz**: Ein Anhänger kann im gleichen Zeitraum nicht diff --git a/app/pages.php b/app/pages.php index a3d84bc..16ba468 100644 --- a/app/pages.php +++ b/app/pages.php @@ -83,6 +83,10 @@ function page_handle(string $method, string $path): void page_calendar($user); return; } + if ($path === '/availability') { + page_availability($user); + return; + } if ($path === '/bookings/new') { page_booking_new($user, $method); return; @@ -438,6 +442,64 @@ function page_calendar(array $user): void ], 'Kalender'); } +/* ----------------------------------------------------------- Verfügbarkeit */ + +function page_availability(array $user): void +{ + $from = query_string('from'); + $to = query_string('to'); + $checked = $from !== '' || $to !== ''; + $errors = []; + + if (!$checked) { + $from = today_iso(); + $to = add_days($from, 3); + } else { + if (!valid_date($from)) { + $errors['from'] = 'Bitte ein gültiges Startdatum angeben.'; + } + if ($to === '') { + $to = $from; + } + if (!valid_date($to)) { + $errors['to'] = 'Bitte ein gültiges Enddatum angeben.'; + } + if (!$errors) { + if ($to < $from) { + $errors['to'] = 'Das Ende darf nicht vor dem Beginn liegen.'; + } elseif (days_between($from, $to) > 365) { + $errors['to'] = 'Der Zeitraum darf höchstens 365 Tage betragen.'; + } + } + } + + $groups = ['trailer' => [], 'chest' => []]; + $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, + ]; + } + } + + render_page('availability', [ + 'from' => $from, + 'to' => $to, + 'checked' => $checked, + 'errors' => $errors, + 'groups' => $groups, + 'freeCount' => $freeCount, + 'total' => count($groups['trailer']) + count($groups['chest']), + 'user' => $user, + ], 'Verfügbarkeit'); +} + /* --------------------------------------------------------------- Buchungen */ function booking_form_context(array $user, ?array $booking = null, array $values = [], array $errors = []): array diff --git a/app/util.php b/app/util.php index b2f2847..448a811 100644 --- a/app/util.php +++ b/app/util.php @@ -89,7 +89,7 @@ function url(string $path = '/'): string } /** Cache-Buster: bei Änderungen an app.css/app.js erhöhen. */ -const DIC_ASSET_VERSION = '13'; +const DIC_ASSET_VERSION = '14'; function asset(string $path): string { diff --git a/views/availability.php b/views/availability.php new file mode 100644 index 0000000..11839a1 --- /dev/null +++ b/views/availability.php @@ -0,0 +1,127 @@ + (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.'], +]; +?> +
+
+

Übersicht

+

Verfügbarkeit

+

Zeitraum wählen – die App zeigt, welche Anhänger und Truhen in dieser Zeit frei sind.

+
+
+ + Im Kalender + + + Zur Übersicht + +
+
+ +
+
+

Zeitraum

+

Ein Wechseltag ist erlaubt: Endet eine Buchung am Tag des neuen Beginns, gilt das Fahrzeug als frei.

+
+
+ + +
+ +
+
+
+ + +
+
+
+

Ergebnis

+

· von frei

+
+ + Neue Buchung + +
+ +
+ $meta): ?> + $row['free'])); + ?> +
+

+ + von frei +

+ +

+ +
    + + +
  • + + + + · + + + + frei + Buchen + + + belegt + + + · + 1): ?> + (+) + + + Ansehen + +
  • + +
+ +
+ +
+
+ + + +
+

Zeitraum wählen und „Verfügbarkeit prüfen" – danach kannst du direkt buchen.

+
+ diff --git a/views/dashboard.php b/views/dashboard.php index 49e481b..a905eb2 100644 --- a/views/dashboard.php +++ b/views/dashboard.php @@ -41,6 +41,9 @@ $isEmployeeView = $employeeScope > 0;

Was heute ansteht – und wer sich um welche Übergabe kümmert.

+ + Verfügbarkeit + Kalender diff --git a/web/assets/app.css b/web/assets/app.css index 17d0cbe..68282ef 100644 --- a/web/assets/app.css +++ b/web/assets/app.css @@ -342,8 +342,26 @@ a .ico, button .ico { pointer-events: none; } .kpi strong { display: block; font-family: var(--font-display); font-size: 1.3rem; color: var(--ink); line-height: 1.1; } .kpi span { font-size: .78rem; color: var(--muted); } -.dash-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, .85fr); gap: 18px; align-items: start; } -.dash-main, .dash-side { display: grid; gap: 18px; min-width: 0; } +/* ---------------------------------------------------------- Verfügbarkeit */ +.availability-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; } +.availability-group h3 { + display: flex; align-items: baseline; justify-content: space-between; gap: 10px; + margin: 0 0 8px; font-size: .95rem; +} +.availability-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; } +.availability-row { + display: flex; align-items: center; gap: 10px; flex-wrap: wrap; + padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; +} +.availability-row.is-free { border-color: #bfe3bf; background: #f8fdf8; } +.availability-row.is-busy { background: #fbfcfd; } +.availability-row__name { flex: 1 1 auto; min-width: 0; } +.availability-row__hint { flex: 1 1 100%; } +@media (max-width: 760px) { + .availability-grid { grid-template-columns: 1fr; } +} + +.dash-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, .85fr); gap: 18px; align-items: start; }.dash-main, .dash-side { display: grid; gap: 18px; min-width: 0; } .trailer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .trailer-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 13px;