From 183422b0c8c2674adf9d30962ba4e9e2c77bdc59 Mon Sep 17 00:00:00 2001 From: torsten Date: Sun, 8 Nov 2026 17:34:01 +0100 Subject: [PATCH] Aktuelle Touren im Jahres-Pillen-Layout --- motorradig/src/Controllers/TourController.php | 34 ++++++++++- motorradig/views/tour/index.php | 57 ++++++++++++++----- 2 files changed, 75 insertions(+), 16 deletions(-) diff --git a/motorradig/src/Controllers/TourController.php b/motorradig/src/Controllers/TourController.php index 5fd6de0..0b23911 100644 --- a/motorradig/src/Controllers/TourController.php +++ b/motorradig/src/Controllers/TourController.php @@ -17,14 +17,46 @@ class TourController { $tours = Tour::upcoming(); $participantCount = []; + $toursByYear = []; foreach ($tours as $tour) { $participantCount[$tour->id] = Booking::countForTour((int) $tour->id); + + // Jahr vor der Formatierung aus dem DB-Datum (YYYY-MM-DD) lesen. + $year = (int) substr((string) $tour->start, 0, 4); + if ($year < 1900) { + $year = 0; + } + $tour->start = german_date($tour->start); $tour->deadline = german_date($tour->deadline); + + $toursByYear[$year][] = $tour; } - view('tour.index', ['tours' => $tours, 'participantCount' => $participantCount]); + krsort($toursByYear, SORT_NUMERIC); + $years = array_keys($toursByYear); + + // Ohne Auswahl werden alle Jahre gruppiert angezeigt. ?jahr=2026 filtert. + $requestedYear = input('jahr'); + $selectedYear = null; + + if (is_string($requestedYear) && ctype_digit($requestedYear)) { + $candidate = (int) $requestedYear; + if (isset($toursByYear[$candidate])) { + $selectedYear = $candidate; + } + } + + $visibleYears = $selectedYear === null ? $years : [$selectedYear]; + + view('tour.index', [ + 'toursByYear' => $toursByYear, + 'years' => $years, + 'visibleYears' => $visibleYears, + 'selectedYear' => $selectedYear, + 'participantCount' => $participantCount, + ]); } public function indexOld(): void diff --git a/motorradig/views/tour/index.php b/motorradig/views/tour/index.php index f23af95..188fc6c 100644 --- a/motorradig/views/tour/index.php +++ b/motorradig/views/tour/index.php @@ -2,6 +2,10 @@ use App\Models\Tour; $current = auth_check() ? user() : null; + $selectedYear = $selectedYear ?? null; + $years = $years ?? []; + $toursByYear = $toursByYear ?? []; + $visibleYears = $visibleYears ?? ($selectedYear === null ? $years : [$selectedYear]); ?>
@@ -12,23 +16,46 @@

Download

-
- . -
+ + + + +
+

+ + +
+ + role === 'ADMIN' || $current->role === 'MEMBER')): ?>