79 lines
3.9 KiB
PHP
79 lines
3.9 KiB
PHP
<?php
|
|
use App\Models\Tour;
|
|
|
|
$current = auth_check() ? user() : null;
|
|
$selectedYear = $selectedYear ?? null;
|
|
$years = $years ?? [];
|
|
$toursByYear = $toursByYear ?? [];
|
|
$visibleYears = $visibleYears ?? ($selectedYear === null ? $years : [$selectedYear]);
|
|
$flashStatus = flash_pull('status');
|
|
$flashError = flash_pull('error');
|
|
?>
|
|
|
|
<div class="container text-center text-light mt-5">
|
|
<h1 class="text-center">Tourenplan: aktuelle Touren</h1>
|
|
|
|
<?php if ($flashStatus !== null): ?>
|
|
<div class="alert alert-success" role="alert"><?= e($flashStatus) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($flashError !== null): ?>
|
|
<div class="alert alert-danger" role="alert"><?= e($flashError) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="container text-primary mb-3">
|
|
<span class="offset-1 col-4 float-left mb-3"><a class="btn btn-success" href="/tour/index_old" class="text-center text-light"><h3>Abgeschlossene Touren</h3></a></span>
|
|
<span class="offset-1"><a href="/img_storage/pdf/Tourenplan.pdf" class="btn btn-success"><h3>Download</h3></a></span>
|
|
</div>
|
|
|
|
<?php if ($years === []): ?>
|
|
<p class="tour-years-empty">Es sind aktuell keine Touren geplant.</p>
|
|
<?php else: ?>
|
|
<nav class="tour-years" aria-label="Aktuelle Touren nach Jahr">
|
|
<a class="tour-year-pill<?= $selectedYear === null ? ' is-active' : '' ?>"
|
|
href="/tour"<?= $selectedYear === null ? ' aria-current="page"' : '' ?>>Alle</a>
|
|
|
|
<?php foreach ($years as $year): ?>
|
|
<?php $yearLabel = ((int) $year === 0) ? 'Ohne Datum' : (string) $year; ?>
|
|
<a class="tour-year-pill<?= $selectedYear === $year ? ' is-active' : '' ?>"
|
|
href="/tour?jahr=<?= e($year) ?>"<?= $selectedYear === $year ? ' aria-current="page"' : '' ?>><?= e($yearLabel) ?></a>
|
|
<?php endforeach; ?>
|
|
</nav>
|
|
|
|
<?php foreach ($visibleYears as $year): ?>
|
|
<?php $yearLabel = ((int) $year === 0) ? 'Ohne Datum' : (string) $year; ?>
|
|
<section class="tour-year-group" aria-labelledby="tour-year-<?= e($year) ?>">
|
|
<h2 class="tour-year-heading" id="tour-year-<?= e($year) ?>"><?= e($yearLabel) ?></h2>
|
|
|
|
<ul class="list-group tour-list">
|
|
<?php foreach ($toursByYear[$year] ?? [] as $tour): ?>
|
|
<li class="list-group-item tour-list-item">
|
|
<a class="tour-list-link" href="/tour/<?= e($tour->id) ?>">
|
|
<span class="tour-list-title"><?= e($tour->periodLabel()) ?> - <?= e($tour->name) ?></span>
|
|
<span class="tour-list-meta">[<?= e($participantCount[$tour->id] ?? 0) ?>/<?= e($tour->max_participants) ?>]</span>
|
|
</a>
|
|
|
|
<span class="tour-list-actions">
|
|
<?php if ($current && Tour::hasParticipant((int) $tour->id, (int) $current->id)): ?>
|
|
<i class="fas fa-biking" title="Du hast teilgenommen" aria-label="Du hast teilgenommen"></i>
|
|
<?php endif; ?>
|
|
|
|
<span class="badge <?= $tour->is_cancelled ? 'badge-danger' : 'badge-success' ?> badge-pill"><?= $tour->is_cancelled ? 'STORNIERT' : 'FINDET STATT' ?></span>
|
|
</span>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</section>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
|
|
<div class="container text-primary">
|
|
<a href="/tour/kalender" class="btn btn-success col-3 mt-2"><h3>Jahreskalender</h3></a>
|
|
</div>
|
|
|
|
<?php if ($current && $current->canCreateTours()): ?>
|
|
<div class="container text-primary">
|
|
<a href="/tour/create" class="btn btn-danger col-3 mt-2 "><h3>Neue Tour anlegen</h3></a>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|