Buchungen anlegen nur für Administratoren

This commit is contained in:
torsten 2026-11-19 10:48:32 +01:00
parent c8ec53ebdd
commit 6a2a9ea342
8 changed files with 67 additions and 32 deletions

View file

@ -6,7 +6,9 @@
/** @var array $groups */
/** @var int $freeCount */
/** @var int $total */
/** @var array $user */
$fieldError = static fn (string $key): string => (string) ($errors[$key] ?? '');
$canCreate = ($user['role'] ?? '') === 'admin';
$bookingUrl = static fn (array $trailer): string => '/bookings/new?trailer=' . (int) $trailer['id']
. '&start=' . rawurlencode($from) . '&end=' . rawurlencode($to);
$groupMeta = [
@ -69,9 +71,11 @@ $groupMeta = [
<h2>Ergebnis</h2>
<p><?= e(fmt_date_range($from, $to)) ?> · <?= (int) $freeCount ?> von <?= (int) $total ?> frei</p>
</div>
<a class="btn small" href="<?= e(url('/bookings/new?start=' . rawurlencode($from) . '&end=' . rawurlencode($to))) ?>">
<svg class="ico" aria-hidden="true"><use href="#i-plus"/></svg> Neue Buchung
</a>
<?php if ($canCreate): ?>
<a class="btn small" href="<?= e(url('/bookings/new?start=' . rawurlencode($from) . '&end=' . rawurlencode($to))) ?>">
<svg class="ico" aria-hidden="true"><use href="#i-plus"/></svg> Neue Buchung
</a>
<?php endif; ?>
</div>
<div class="availability-grid">
@ -98,7 +102,9 @@ $groupMeta = [
<?= e($trailer['label']) ?>
</span>
</span>
<a class="btn small primary" href="<?= e(url($bookingUrl($trailer))) ?>">Buchen</a>
<?php if ($canCreate): ?>
<a class="btn small primary" href="<?= e(url($bookingUrl($trailer))) ?>">Buchen</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>