diff --git a/README.md b/README.md index 55712ac..6b286de 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Die Anforderungen stammen aus ## Was die App kann -- **Kalender** mit Tages-, Wochen- und Monatsansicht (Monat ist Standard). Alle Anhänger haben +- **Kalender** mit Tages-, 4-Wochen- und Monatsansicht (4 Kalenderwochen sind Standard und starten mit der aktuellen KW). Alle Anhänger haben eine eigene Zeile und sind immer gleichzeitig sichtbar. Jeder Termin ist ein durchgehender, farbiger Balken in der Farbe des Anhängers. - **Buchungen** mit Anfangs- und Endtermin (Datum, Uhrzeit optional), Miete, diff --git a/app/pages.php b/app/pages.php index 8a3d619..711e9cb 100644 --- a/app/pages.php +++ b/app/pages.php @@ -407,9 +407,9 @@ function calendar_url(string $date, string $view, int $employeeId, bool $showCan function page_calendar(array $user): void { - $view = query_string('view', 'month'); - if (!in_array($view, ['day', 'week', 'month'], true)) { - $view = 'month'; + $view = query_string('view', 'weeks'); + if (!in_array($view, ['day', 'weeks', 'month'], true)) { + $view = 'weeks'; } $date = query_string('date'); if (!valid_date($date)) { @@ -424,8 +424,9 @@ function page_calendar(array $user): void $from = month_start($date); $to = month_end($date); } else { + // Vier Kalenderwochen ab dem Montag der Woche, in der $date liegt. $from = week_start($date); - $to = add_days($from, 6); + $to = add_days($from, CALENDAR_WEEKS * 7 - 1); } $bookings = booking_list($from, $to, $showCancelled, $employeeId); @@ -449,13 +450,14 @@ function page_calendar(array $user): void 'weekday' => fmt_weekday_short($cursor), 'is_today' => $cursor === today_iso(), 'is_weekend' => (int) date_obj($cursor)->format('N') >= 6, + 'is_week_start' => date_obj($cursor)->format('N') === '1', 'is_first_of_month' => date_obj($cursor)->format('j') === '1', ]; $cursor = add_days($cursor, 1); } - $barBase = ['day' => 76, 'week' => 48, 'month' => 34][$view]; - $rowMin = ['day' => 104, 'week' => 64, 'month' => 44][$view]; + $barBase = ['day' => 76, 'weeks' => 34, 'month' => 34][$view]; + $rowMin = ['day' => 104, 'weeks' => 44, 'month' => 44][$view]; $rows = []; foreach ($trailers as $trailer) { @@ -480,9 +482,9 @@ function page_calendar(array $user): void if ($view === 'day') { $prevDate = add_days($date, -1); $nextDate = add_days($date, 1); - } elseif ($view === 'week') { - $prevDate = add_days($date, -7); - $nextDate = add_days($date, 7); + } elseif ($view === 'weeks') { + $prevDate = add_days($date, -CALENDAR_WEEKS * 7); + $nextDate = add_days($date, CALENDAR_WEEKS * 7); } else { $prevDate = date_obj(month_start($date))->modify('first day of previous month')->format('Y-m-d'); $nextDate = date_obj(month_start($date))->modify('first day of next month')->format('Y-m-d'); @@ -490,8 +492,9 @@ function page_calendar(array $user): void if ($view === 'day') { $title = fmt_date_long($date); - } elseif ($view === 'week') { - $title = 'KW ' . date_obj($from)->format('W') . ' · ' . fmt_date_range($from, $to); + } elseif ($view === 'weeks') { + $title = 'KW ' . date_obj($from)->format('W') . '–' . date_obj($to)->format('W') + . ' · ' . fmt_date_range($from, $to); } else { $title = fmt_month($date); } @@ -850,7 +853,7 @@ function page_booking_delete(array $user, int $id): void } booking_delete($id); flash('success', 'Buchung von ' . $booking['customer_name'] . ' wurde endgültig gelöscht.'); - redirect('/calendar?view=month&date=' . $booking['start_date']); + redirect('/calendar?date=' . $booking['start_date']); } function page_booking_move(array $user, int $id): void diff --git a/app/util.php b/app/util.php index fbbe81c..179e5ea 100644 --- a/app/util.php +++ b/app/util.php @@ -92,7 +92,7 @@ function url(string $path = '/'): string } /** Cache-Buster: bei Änderungen an app.css/app.js erhöhen. */ -const DIC_ASSET_VERSION = '20'; +const DIC_ASSET_VERSION = '21'; function asset(string $path): string { @@ -329,6 +329,9 @@ function week_start(string $iso): string return $date->modify('-' . ($weekday - 1) . ' days')->format('Y-m-d'); } +/** Anzahl der Kalenderwochen, die die Kalenderansicht standardmäßig zeigt. */ +const CALENDAR_WEEKS = 4; + function month_start(string $iso): string { return date_obj($iso)->modify('first day of this month')->format('Y-m-d'); diff --git a/docs/architecture.md b/docs/architecture.md index 37f6d95..d5a2a21 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -62,7 +62,7 @@ entstehen. Zwei Buchungen mit Wechseltag liegen in zwei Lanes und bleiben beide sichtbar. Lanes und Balkenpositionen werden serverseitig in Prozent berechnet; das funktioniert ohne JavaScript und ohne externe Kalender-Library. -- Tages-, Wochen- und Monatsansicht nutzen dieselbe Zeilenstruktur +- Tages-, 4-Wochen- und Monatsansicht nutzen dieselbe Zeilenstruktur (Anhänger × Zeitraum). Die Monatsansicht ist bewusst als horizontale Zeitachse umgesetzt, damit auch dort jeder Anhänger eine eigene Zeile behält und kein Termin in „weitere Termine“ wandert. @@ -173,7 +173,7 @@ sind die primäre Anzeige und funktionieren ohne Mailversand. | Anforderung | Umsetzung | |---|---| | 2. Kalender, ein Anhänger je Zeile | `trailers` (Start-Anhänger aus der Anforderung, weitere anlegbar), Kalenderzeilen mit fester Lane-Spalte, alle aktiven Anhänger immer sichtbar | -| Tag/Woche/Monat, Google-ähnlich | `?view=day|week|month`, Navigation, Heute, Datumssprung | +| Tag/4 Wochen/Monat, Google-ähnlich | `?view=day|weeks|month` (Default `weeks`, 4 Kalenderwochen ab Montag), Navigation, Heute, Datumssprung | | Durchgehende farbige Balken | absolute Balken pro Zeile, Farbe aus `trailers.color_hex` | | Keine ausgeblendeten Termine | alle Buchungen im Zeitraum werden gerendert; Lanes statt „weitere Termine“ | | 3. Mietzeiträume | `DATE`-Zeitraum inklusive Endtag; Uhrzeiten (`start_time`, `end_time`) optional, ohne Angabe ganztägig | diff --git a/views/availability.php b/views/availability.php index f4457d7..9cad2ab 100644 --- a/views/availability.php +++ b/views/availability.php @@ -31,7 +31,7 @@ $groupMeta = [
Zeitraum wählen – die App zeigt, welche Anhänger und Truhen in dieser Zeit frei sind.