Touren-Detailansicht: einheitliches Karten-Layout, bündige Fakten, mobil optimiert

This commit is contained in:
torsten 2026-11-21 13:37:06 +01:00
parent 3ea18501b8
commit b13b21f30f
6 changed files with 776 additions and 349 deletions

View file

@ -783,6 +783,434 @@ p {
}
}
/* Einzel-Tourenansicht: einheitliche Karten, bündige Faktenzeilen */
.tour-detail {
max-width: 1180px;
margin-top: 1.5rem;
margin-bottom: 3rem;
}
.tour-detail-card {
background: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 16px;
box-shadow: 0 18px 40px rgba(15, 23, 42, .16);
padding: 1.5rem 1.6rem;
}
.tour-detail-head {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: space-between;
gap: .75rem;
padding-bottom: 1rem;
margin-bottom: 1.25rem;
border-bottom: 1px solid #e2e8f0;
}
.tour-detail-heading {
min-width: 0;
}
.tour-detail-title {
margin: 0;
color: #0f172a;
font-size: 1.55rem;
font-weight: 700;
line-height: 1.25;
overflow-wrap: anywhere;
}
.tour-detail-sub {
margin: .3rem 0 0;
color: #64748b;
font-size: .92rem;
}
.tour-status {
display: inline-flex;
align-items: center;
padding: .3rem .75rem;
border-radius: 999px;
font-size: .75rem;
font-weight: 700;
letter-spacing: .04em;
text-transform: uppercase;
white-space: nowrap;
}
.tour-status.is-scheduled {
background: rgba(21, 128, 61, .14);
color: #15803d;
}
.tour-status.is-past {
background: rgba(100, 116, 139, .18);
color: #475569;
}
.tour-status.is-cancelled {
background: rgba(229, 72, 77, .16);
color: #c13034;
}
.tour-facts {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
gap: .9rem 2rem;
margin: 0 0 1.5rem;
}
.tour-fact {
display: grid;
grid-template-columns: 9.75rem minmax(0, 1fr);
align-items: baseline;
gap: .35rem;
padding-bottom: .5rem;
border-bottom: 1px dashed #e2e8f0;
}
.tour-fact dt {
margin: 0;
color: #64748b;
font-size: .74rem;
font-weight: 700;
letter-spacing: .06em;
text-transform: uppercase;
}
.tour-fact dd {
margin: 0;
color: #0f172a;
font-size: .95rem;
overflow-wrap: anywhere;
}
.tour-fact-muted {
color: #94a3b8;
}
.tour-fact-ok {
color: #15803d;
font-weight: 600;
}
.tour-section {
margin-bottom: 1.5rem;
}
.tour-section-title {
margin: 0 0 .5rem;
color: #0f172a;
font-size: 1.05rem;
font-weight: 700;
}
.tour-description {
margin: 0;
color: #1e293b;
font-size: .97rem;
line-height: 1.6;
overflow-wrap: anywhere;
}
.tour-actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: .6rem;
margin-top: 1.5rem;
padding-top: 1.25rem;
border-top: 1px solid #e2e8f0;
}
.tour-actions .btn {
min-width: 12rem;
}
.tour-action-form {
margin: 0;
}
/* Seitenspalte */
.tour-side-card {
background: rgba(8, 13, 20, .62);
border: 1px solid rgba(255, 255, 255, .14);
border-radius: 14px;
padding: 1.1rem 1.15rem;
margin-bottom: 1rem;
color: #e6edf6;
}
.tour-side-card .btn-block + .btn-block {
margin-top: .5rem;
}
.tour-side-title {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: .5rem;
margin: 0 0 .75rem;
color: #fff;
font-size: 1rem;
font-weight: 700;
}
.tour-side-count {
color: rgba(255, 255, 255, .7);
font-size: .8rem;
font-weight: 600;
}
.tour-side-empty {
margin: 0;
color: rgba(255, 255, 255, .7);
font-size: .88rem;
}
.tour-side-actions .btn {
font-size: .9rem;
}
.tour-side-card .btn-primary {
background: #4ea1ff;
border-color: #4ea1ff;
color: #071a30;
font-weight: 600;
}
.tour-side-card .btn-primary:hover,
.tour-side-card .btn-primary:focus {
background: #6cb4ff;
border-color: #6cb4ff;
color: #071a30;
}
.tour-side-card .btn-outline-light {
border-color: rgba(255, 255, 255, .45);
color: #e6edf6;
}
.tour-side-card .btn-outline-light:hover,
.tour-side-card .btn-outline-light:focus {
background: rgba(255, 255, 255, .14);
border-color: rgba(255, 255, 255, .65);
color: #fff;
}
.tour-person-list,
.tour-room-list {
list-style: none;
margin: 0;
padding: 0;
}
.tour-person {
display: flex;
align-items: center;
justify-content: space-between;
gap: .5rem;
padding: .35rem 0;
border-bottom: 1px solid rgba(255, 255, 255, .08);
font-size: .9rem;
}
.tour-person:last-child {
border-bottom: 0;
}
.tour-person-name i {
margin-right: .35rem;
color: #4ea1ff;
}
.tour-person-remove {
border: 0;
background: transparent;
color: rgba(255, 255, 255, .55);
cursor: pointer;
padding: 0 .25rem;
line-height: 1;
}
.tour-person-remove:hover,
.tour-person-remove:focus {
color: #e5484d;
}
.tour-room-group {
margin-top: .75rem;
padding-top: .6rem;
border-top: 1px solid rgba(255, 255, 255, .1);
}
.tour-room-group:first-of-type {
margin-top: 0;
padding-top: 0;
border-top: 0;
}
.tour-room-title {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: .5rem;
margin: 0 0 .25rem;
color: #fff;
font-size: .88rem;
font-weight: 600;
}
.tour-room-meta {
color: rgba(255, 255, 255, .65);
font-size: .78rem;
font-weight: 500;
}
/* Bildergalerie der Detailansicht */
.tour-detail-gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
gap: .6rem;
}
.tour-detail-gallery a {
display: block;
border-radius: 10px;
overflow: hidden;
background: #e2e8f0;
}
.tour-detail-gallery img {
display: block;
width: 100%;
height: 100%;
aspect-ratio: 4 / 3;
object-fit: cover;
}
/* Zimmerwahl-Modal */
.tour-modal-content {
max-width: 26rem;
border-radius: 14px;
padding: 1.5rem;
}
.tour-modal-title {
margin: 0 0 .35rem;
font-size: 1.2rem;
font-weight: 700;
color: #0f172a;
}
.tour-modal-hint {
margin: 0 0 1rem;
color: #64748b;
font-size: .9rem;
}
.tour-modal-rooms {
display: grid;
gap: .6rem;
}
.tour-modal-room {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
align-items: center;
gap: .15rem .75rem;
padding: .65rem .8rem;
border: 1px solid #e2e8f0;
border-radius: 10px;
background: #fff;
}
.tour-modal-room-name {
color: #0f172a;
font-weight: 600;
font-size: .95rem;
}
.tour-modal-room-meta {
grid-column: 1;
color: #64748b;
font-size: .78rem;
}
.tour-modal-room .btn {
grid-column: 2;
grid-row: 1 / span 2;
}
@media (max-width: 991.98px) {
.tour-detail {
margin-top: 1rem;
}
.tour-detail aside {
margin-top: 1rem;
}
.tour-side-card {
margin-top: .25rem;
}
}
@media (max-width: 767.98px) {
.tour-detail-card {
padding: 1.1rem 1rem;
border-radius: 12px;
}
.tour-detail-title {
font-size: 1.25rem;
}
.tour-facts {
grid-template-columns: 1fr;
gap: .5rem;
}
.tour-fact {
grid-template-columns: 1fr;
gap: .1rem;
padding-bottom: .45rem;
}
.tour-fact dt {
font-size: .7rem;
}
.tour-actions {
flex-direction: column;
align-items: stretch;
}
.tour-actions .btn,
.tour-actions .tour-action-form,
.tour-actions .tour-action-form .btn {
width: 100%;
min-width: 0;
}
}
@media (max-width: 575.98px) {
.tour-detail {
margin-top: .5rem;
margin-bottom: 2rem;
}
.tour-detail-gallery {
grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}
.tour-modal-content {
padding: 1.15rem;
}
}
/* Jahreskalender: Touren farblich markiert */
.tour-calendar-head {
display: flex;

View file

@ -431,6 +431,7 @@ class TourController
$tourDays = $tour->durationDays();
$tourEnd = $tour->endDate();
$tourPeriod = $tour->periodLabel();
// Vergangene Tour
if ($tourEnd !== null && $tourEnd < today()) {
@ -441,12 +442,15 @@ class TourController
view('tour.show_old', [
'tour' => $tour,
'days' => $tourDays,
'users' => $users,
'guide' => $guide,
'tourImages' => $tourImages,
'canManage' => $canManage,
'canChat' => $canChat,
'chatUnread' => $chatUnread,
'period' => $tourPeriod,
'users' => $users,
'current' => $current,
'guide' => $guide,
'tourImages' => $tourImages,
'canManage' => $canManage,
'canChat' => $canChat,
'chatUnread' => $chatUnread,
'roomOptions' => TourRoom::forTour((int) $tour->id),
]);
return;
@ -461,13 +465,16 @@ class TourController
view('tour.show', [
'tour' => $tour,
'days' => $tourDays,
'users' => $users,
'guide' => $guide,
'tourImages' => $tourImages,
'rooms' => $rooms,
'canManage' => $canManage,
'canChat' => $canChat,
'chatUnread' => $chatUnread,
'period' => $tourPeriod,
'users' => $users,
'current' => $current,
'guide' => $guide,
'tourImages' => $tourImages,
'rooms' => $rooms,
'roomOptions' => TourRoom::forTour((int) $tour->id),
'canManage' => $canManage,
'canChat' => $canChat,
'chatUnread' => $chatUnread,
]);
}

View file

@ -28,6 +28,23 @@ class TourRoom extends Model
return $row !== null && (int) $row['booked'] < (int) $row['capacity'];
}
/** Alle Zimmer einer Tour (auch ohne Buchungen), inkl. freier Plätze. */
public static function forTour(int $tourId): array
{
if ($tourId <= 0) {
return [];
}
return db()->fetchAll(
'SELECT tr.id, tr.name, tr.capacity,
(SELECT COUNT(*) FROM `bookings` b WHERE b.tour_id = tr.tour_id AND b.room_id = tr.id) AS booked
FROM `tour_rooms` tr
WHERE tr.tour_id = ?
ORDER BY tr.id',
[$tourId]
);
}
public static function findForTour(int $roomId, int $tourId): ?array
{
if ($roomId <= 0 || $tourId <= 0) {

View file

@ -0,0 +1,124 @@
<?php
/**
* Gemeinsame Detailansicht einer Tour (aktive und vergangene Touren).
*
* Erwartete Variablen: $tour, $guide, $days, $period, $current, $tourImages
* Optional: $isPast, $bericht, $showGallery
*/
$tourDays = (int) ($days ?? 1);
$tourPeriod = (string) ($period ?? $tour->start);
$isPastTour = !empty($isPast);
$isCancelledTour = (bool) $tour->is_cancelled;
$statusClass = $isCancelledTour ? 'is-cancelled' : ($isPastTour ? 'is-past' : 'is-scheduled');
$statusLabel = $isCancelledTour ? 'Abgesagt' : ($isPastTour ? 'Vorbei' : 'Findet statt');
$takesPart = $current !== null && \App\Models\Tour::hasParticipant((int) $tour->id, (int) $current->id);
?>
<article class="tour-detail-card">
<header class="tour-detail-head">
<div class="tour-detail-heading">
<h1 class="tour-detail-title"><?= e($tour->name) ?></h1>
<p class="tour-detail-sub">
<?= e($tourPeriod) ?>
&middot;
<?= $tourDays ?> Tag<?= $tourDays === 1 ? '' : 'e' ?>
</p>
</div>
<span class="tour-status <?= $statusClass ?>"><?= e($statusLabel) ?></span>
</header>
<dl class="tour-facts">
<div class="tour-fact">
<dt>Start</dt>
<dd><?= e($tour->start) ?></dd>
</div>
<div class="tour-fact">
<dt>Ende</dt>
<dd>
<?php if (!empty($tour->end_date)): ?>
<?= e($tour->end_date) ?>
<?php else: ?>
<span class="tour-fact-muted">eintägig</span>
<?php endif; ?>
</dd>
</div>
<div class="tour-fact">
<dt>Tour Guide</dt>
<dd><?= e($guide ? $guide->name : 'unbekannt') ?></dd>
</div>
<div class="tour-fact">
<dt>Anmeldeschluss</dt>
<dd><?= e($tour->deadline) ?></dd>
</div>
<div class="tour-fact">
<dt>Max. Teilnehmer</dt>
<dd><?= (int) $tour->max_participants ?></dd>
</div>
<div class="tour-fact">
<dt>Deine Teilnahme</dt>
<dd>
<?php if ($current === null): ?>
<span class="tour-fact-muted">&ndash;</span>
<?php elseif ($takesPart): ?>
<span class="tour-fact-ok"><i class="fas fa-check" aria-hidden="true"></i> Du fährst mit</span>
<?php else: ?>
<span class="tour-fact-muted">noch nicht angemeldet</span>
<?php endif; ?>
</dd>
</div>
</dl>
<section class="tour-section">
<h2 class="tour-section-title">Beschreibung</h2>
<p class="tour-description"><?= nl2br(e($tour->beschreibung), false) ?></p>
</section>
<?php if (!empty($bericht)): ?>
<section class="tour-section">
<h2 class="tour-section-title">Bericht</h2>
<p class="tour-description"><?= nl2br(e($bericht), false) ?></p>
</section>
<?php endif; ?>
<?php if (!empty($showGallery) && !empty($tourImages)): ?>
<section class="tour-section">
<h2 class="tour-section-title">Bilder</h2>
<div class="tour-detail-gallery">
<?php foreach ($tourImages as $i => $image): ?>
<a href="<?= e($image['large']) ?>?v=<?= e($image['version']) ?>"
target="_blank" rel="noopener">
<img src="<?= e($image['thumb']) ?>?v=<?= e($image['version']) ?>"
alt="<?= e($tour->name) ?> – Bild <?= $i + 1 ?>"
loading="lazy" decoding="async">
</a>
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
<div class="tour-actions">
<?php if (!empty($showJoinButton)): ?>
<button type="button" class="btn btn-success" id="myBtn">
<i class="fas fa-biking" aria-hidden="true"></i> Teilnehmen
</button>
<?php endif; ?>
<?php if ($takesPart && !$isPastTour): ?>
<form action="/tour/<?= e($tour->id) ?>/cancelBooking" method="POST" class="tour-action-form">
<?= csrf_field() ?>
<button type="submit" class="btn btn-outline-danger">
<i class="fas fa-user-minus" aria-hidden="true"></i> Anmeldung zurückziehen
</button>
</form>
<?php endif; ?>
<a class="btn btn-outline-secondary" href="/tour">
<i class="fas fa-list" aria-hidden="true"></i> Zur Tourübersicht
</a>
</div>
</article>

View file

@ -1,238 +1,161 @@
<?php
use App\Models\Tour;
/** @var \App\Models\Tour $tour */
$canJoin = $current !== null
&& !$tour->is_cancelled
&& !\App\Models\Tour::hasParticipant((int) $tour->id, (int) $current->id)
&& \App\Models\Tour::hasSpace((int) $tour->id);
$current = auth_check() ? user() : null;
$groups = [];
foreach ($rooms as $room) {
$roomId = (int) ($room->room_id ?? 0);
$key = $roomId > 0 ? (string) $roomId : 'ungebucht';
if (!isset($groups[$key])) {
$groups[$key] = [
'name' => $room->room_name,
'id' => $room->room_id,
'free_slots' => $room->free_slots,
'users' => [],
];
}
$groups[$key]['users'][] = $room;
}
$showJoinButton = $canJoin;
$showGallery = true;
$isPast = false;
?>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 mt-2">
<div class="card mt-4">
<div class="card-header"><h5><?= e($tour->name) ?></h5></div>
<div class="card-body">
<form style="background-color: #fff;" class="text-dark" method="post" action="" enctype="multipart/form-data">
<?= csrf_field() ?>
<div class="" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="name">Name:</label>
<input class="mr-1 form-control" type="text" id="name" name="name"
value="<?= e(old('name') ?? $tour->name) ?>" readonly>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="start">Start:</label>
<input class="mr-1 form-control" type="text" id="start" name="start"
value="<?= e(old('start') ?? $tour->start) ?>" readonly>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="end_date">Ende:</label>
<input class="mr-1 form-control" type="text" id="end_date" name="end_date"
value="<?= e($tour->end_date) ?>" readonly
placeholder="eintägig">
<span class="ml-2 align-self-center" style="font-size:15px;">
<?= (int) ($days ?? 1) ?> Tag<?= (int) ($days ?? 1) === 1 ? '' : 'e' ?>
</span>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="tour_guide">Tour Guide:</label>
<input class="mr-1 form-control" type="text" id="tour_guide" name="tour_guide"
value="<?= e($guide ? $guide->name : '') ?>" readonly>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="anmeldeschluss">Anmeldeschluss:</label>
<input class="mr-1 form-control" type="text" id="anmeldeschluss" style="font-size:16px;"
name="deadline" value="<?= e(old('anmeldeschluss') ?? $tour->deadline) ?>" readonly>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="max_participants">Max Teilnehmer:</label>
<input class="mr-1 form-control" type="text" id="max_participants"
style="font-size:16px;" name="max_participants"
value="<?= e(old('max_participants') ?? $tour->max_participants) ?>" readonly>
</div>
<?php if ($current && Tour::hasParticipant((int) $tour->id, (int) $current->id)): ?>
<label>Du nimmst teil.</label>
<?php else: ?>
<label>Du nimmst nicht teil.</label>
<?php endif; ?>
<?php if ($tourImages !== []): ?>
<div class="tour-media-grid gallery-grid">
<?php foreach ($tourImages as $i => $image): ?>
<figure class="gallery-item" style="--i:<?= $i % 20 ?>">
<a class="gallery-item-link"
href="<?= e($image['large']) ?>?v=<?= e($image['version']) ?>"
data-lightbox="tour-bilder-<?= e($tour->id) ?>"
data-title="<?= e($tour->name) ?> – Bild <?= $i + 1 ?>">
<img src="<?= e($image['large']) ?>?v=<?= e($image['version']) ?>"
alt="<?= e($tour->name) ?> – Bild <?= $i + 1 ?>"
loading="lazy" decoding="async">
<span class="gallery-overlay" aria-hidden="true">
<span class="gallery-zoom">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round">
<circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/>
<path d="M11 8v6"/><path d="M8 11h6"/>
</svg>
</span>
</span>
</a>
</figure>
<?php endforeach; ?>
</div>
<?php else: ?>
<img src="/img/placeholder/tour128x100.jpg" class="mt-3 ml-3">
<?php endif; ?>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:140px; text-align:left;font-size:18px;" for="is_cancelled">Storniert:</label>
<input class="mr-1 form-control" type="checkbox" id="is_cancelled"
style="font-size:10px;width:20px;" name="is_cancelled"
<?= $tour->is_cancelled ? 'checked' : '' ?> onclick="return false;">
</div>
<div class="mt-1">
<textarea class="col-12" name="beschreibung" rows="10" cols="50" readonly><?= e($tour->beschreibung) ?></textarea>
</div>
<?php if ($current && $canManage): ?>
<a href="/tour/<?= e($tour->id) ?>/edit">
<div type="submit" class="btn btn-danger col-3 mb-2 float-left mr-2">Bearbeiten</div>
</a>
<?php endif; ?>
<a href="/tour" type="submit" class="btn btn-success col-3 mb-2 float-right mr-2">Ok</a>
<?php if ($current && !Tour::hasParticipant((int) $tour->id, (int) $current->id) && Tour::hasSpace((int) $tour->id)): ?>
<button id="myBtn" class="btn btn-danger float-left">Teilnehmen</button>
<?php endif; ?>
</form>
<!-- Modal: Zimmer auswählen -->
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2>Bitte Zimmer auswählen</h2>
<div class="card-body">
<ul>
<?php $first = true; ?>
<?php foreach ($groups as $key => $group): ?>
<?php if ($key !== 'ungebucht' && $group['free_slots'] > 0): ?>
<?php if (!$first): ?><hr/><?php endif; ?>
<p style="list-style-type: none;">[<?= e($group['id']) ?>]
<span><?= e($group['name']) ?></span>
<b>
<form action="/tour/<?= e($tour->id) ?>/join/<?= e($group['id']) ?>" method="POST" style="display:inline;">
<?= csrf_field() ?>
<button type="submit" style="border:none;background:none;padding:0;cursor:pointer;font-weight:bold;">==> Buchen</button>
</form>
</b>
</p>
<?php $first = false; ?>
<?php foreach ($group['users'] as $room): ?>
<?php if ($room->user_name): ?>
<li> <?= e($room->user_name) ?></li>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="container tour-detail">
<div class="row">
<div class="col-12 col-lg-8">
<?php require __DIR__ . '/partials/detail_card.php'; ?>
</div>
<div class="col-md-3 mt-2">
<?php if (!empty($canChat)): ?>
<div class="card mt-4">
<div class="card-body text-center">
<a href="/tour/<?= e($tour->id) ?>/chat" class="btn btn-primary btn-block">
Tour-Chat
<?php if (($chatUnread ?? 0) > 0): ?>
<span class="badge badge-light ml-1"><?= e(($chatUnread ?? 0) > 99 ? '99+' : (string) $chatUnread) ?></span>
<?php endif; ?>
</a>
<small class="text-muted d-block mt-2">Geschlossener Chat für Teilnehmer</small>
</div>
</div>
<?php endif; ?>
<aside class="col-12 col-lg-4">
<section class="tour-side-card">
<h2 class="tour-side-title">Tour-Chat</h2>
<a href="/tour/<?= e($tour->id) ?>/chat" class="btn btn-primary btn-block">
<i class="fas fa-comments" aria-hidden="true"></i>
Chat öffnen
<?php if (($chatUnread ?? 0) > 0): ?>
<span class="badge badge-light ml-1"><?= e(($chatUnread ?? 0) > 99 ? '99+' : (string) $chatUnread) ?></span>
<?php endif; ?>
</a>
</section>
<div class="card mt-4">
<div class="card-header"><h5>Teilnehmer</h5></div>
<section class="tour-side-card">
<h2 class="tour-side-title">
Teilnehmer
<span class="tour-side-count"><?= count($users) ?>/<?= (int) $tour->max_participants ?></span>
</h2>
<div class="card-body">
<?php foreach ($groups as $key => $group): ?>
<div style="border:solid;border-width:1px;">
<div style="text-align:center;"><b><?= e($group['name']) ?>
<?php if ($key !== 'ungebucht'): ?>_<?= e($group['id']) ?><?php endif; ?></b>
</div>
<?php
// Buchungen nach Zimmer gruppieren (Quelle: TourRoom::fetchRooms)
$roomsByName = [];
<?php foreach ($group['users'] as $room): ?>
<?php if ($room->user_name): ?>
<div style="list-style:none"> &nbsp; <?= e($room->user_name) ?>
<?php if ($canManage): ?>
<form action="/tour/<?= e($tour->id) ?>/cancelBookingAdmin/<?= e($room->user_id) ?>" method="POST" style="display:inline;">
foreach (($rooms ?? []) as $row) {
$name = (string) $row->room_name;
if (!isset($roomsByName[$name])) {
$roomsByName[$name] = ['capacity' => (int) $row->capacity, 'people' => []];
}
if (!empty($row->user_name)) {
$roomsByName[$name]['people'][] = $row;
}
}
?>
<?php if (empty($users)): ?>
<p class="tour-side-empty">Noch keine Anmeldungen.</p>
<?php else: ?>
<?php foreach ($roomsByName as $roomName => $roomGroup): ?>
<div class="tour-room-group">
<p class="tour-room-title">
<?= e($roomName) ?>
<span class="tour-room-meta"><?= count($roomGroup['people']) ?>/<?= $roomGroup['capacity'] ?></span>
</p>
<ul class="tour-person-list">
<?php foreach ($roomGroup['people'] as $participant): ?>
<li class="tour-person">
<span class="tour-person-name">
<i class="fas fa-biking" aria-hidden="true"></i>
<?= e($participant->user_name) ?>
</span>
<?php if ($canManage && !empty($participant->user_id)): ?>
<form action="/tour/<?= e($tour->id) ?>/cancelBookingAdmin/<?= e($participant->user_id) ?>" method="POST">
<?= csrf_field() ?>
<button type="submit" class="text-primary" style="border:none;background:none;padding:0;cursor:pointer;" title="Entfernen">(X)</button>
<button type="submit" class="tour-person-remove" title="Anmeldung entfernen"
aria-label="Anmeldung von <?= e($participant->user_name) ?> entfernen">
<i class="fas fa-times" aria-hidden="true"></i>
</button>
</form>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<div style="height:2px;"></div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
</section>
<?php if ($canManage): ?>
<section class="tour-side-card">
<h2 class="tour-side-title">Organisation</h2>
<div class="tour-side-actions">
<a class="btn btn-outline-light btn-block" href="/tour/<?= e($tour->id) ?>/edit">
<i class="fas fa-pen" aria-hidden="true"></i> Tour bearbeiten
</a>
<a class="btn btn-outline-light btn-block" href="/tour">
<i class="fas fa-list" aria-hidden="true"></i> Zur Tourenliste
</a>
</div>
</section>
<?php endif; ?>
</aside>
</div>
</div>
<?php if ($canJoin): ?>
<div id="myModal" class="modal tour-modal">
<div class="modal-content tour-modal-content">
<span class="close" aria-label="Schließen">&times;</span>
<h2 class="tour-modal-title">Zimmer wählen</h2>
<p class="tour-modal-hint">Wähle das Zimmer, das du buchen möchtest.</p>
<div class="tour-modal-rooms">
<?php foreach (($roomOptions ?? []) as $room): ?>
<?php $free = (int) $room['capacity'] - (int) $room['booked']; ?>
<form class="booking_form tour-modal-room" action="/tour/<?= e($tour->id) ?>/join/<?= e($room['id']) ?>" method="POST">
<?= csrf_field() ?>
<input type="hidden" name="user_id" value="<?= e($current->id ?? '') ?>">
<span class="tour-modal-room-name"><?= e($room['name']) ?></span>
<span class="tour-modal-room-meta">
<?= (int) $room['capacity'] ?> Bett<?= (int) $room['capacity'] === 1 ? '' : 'en' ?>
&middot; <?= max(0, $free) ?> frei
</span>
<button type="submit" class="btn btn-success btn-sm" <?= $free <= 0 ? 'disabled' : '' ?>>
<?= $free <= 0 ? 'voll' : 'Buchen' ?>
</button>
</form>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
<script>
var modal = document.getElementById("myModal");
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0];
(function () {
var modal = document.getElementById('myModal');
var btn = document.getElementById('myBtn');
if (btn) {
btn.onclick = function (e) {
e.preventDefault();
modal.style.display = "block";
if (!modal || !btn) {
return;
}
}
if (span) {
span.onclick = function (e) {
e.preventDefault();
modal.style.display = "none";
}
}
var closeBtn = modal.querySelector('.close');
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
btn.addEventListener('click', function (event) {
event.preventDefault();
modal.style.display = 'block';
});
if (closeBtn) {
closeBtn.addEventListener('click', function (event) {
event.preventDefault();
modal.style.display = 'none';
});
}
}
modal.addEventListener('click', function (event) {
if (event.target === modal) {
modal.style.display = 'none';
}
});
})();
</script>

View file

@ -1,131 +1,59 @@
<?php
use App\Models\Tour;
$current = auth_check() ? user() : null;
/** @var \App\Models\Tour $tour */
$showJoinButton = false;
$showGallery = true;
$isPast = true;
$bericht = (string) ($tour->bericht ?? '');
?>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 mt-2">
<div class="card mt-4">
<div class="card-header"><h5><?= e($tour->name) ?></h5></div>
<div class="card-body">
<form style="background-color: #fff;" class="text-dark" method="post" action="" enctype="multipart/form-data">
<?= csrf_field() ?>
<div class="" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="name">Name:</label>
<input class="mr-1 form-control" type="text" id="name" name="name" value="<?= e(old('name') ?? $tour->name) ?>" readonly>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="start">Start:</label>
<input class="mr-1 form-control" type="text" id="start" name="start" value="<?= e(old('start') ?? $tour->start) ?>" readonly>
<?php if (!empty($tour->end_date)): ?>
<span class="ml-2 align-self-center" style="font-size:15px;">
bis <?= e($tour->end_date) ?> (<?= (int) ($days ?? 1) ?> Tage)
</span>
<?php endif; ?>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="tour_guide">Tour Guide:</label>
<input class="mr-1 form-control" type="text" id="tour_guide" name="tour_guide" value="<?= e($guide ? $guide->name : '') ?>" readonly>
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="anmeldeschluss">Anmeldeschluss:</label>
<input class="mr-1 form-control" type="text" id="anmeldeschluss" style="font-size:16px;" name="start" value="<?= e(old('anmeldeschluss') ?? $tour->deadline) ?>" readonly>
</div>
<?php if ($current && Tour::hasParticipant((int) $tour->id, (int) $current->id)): ?>
<label>Du nimmst teil.</label>
<?php else: ?>
<label>Du nimmst nicht teil.</label>
<?php endif; ?>
<?php if ($tourImages !== []): ?>
<div class="tour-media-grid gallery-grid">
<?php foreach ($tourImages as $i => $image): ?>
<figure class="gallery-item" style="--i:<?= $i % 20 ?>">
<a class="gallery-item-link"
href="<?= e($image['large']) ?>?v=<?= e($image['version']) ?>"
data-lightbox="tour-bilder-<?= e($tour->id) ?>"
data-title="<?= e($tour->name) ?> – Bild <?= $i + 1 ?>">
<img src="<?= e($image['large']) ?>?v=<?= e($image['version']) ?>"
alt="<?= e($tour->name) ?> – Bild <?= $i + 1 ?>"
loading="lazy" decoding="async">
<span class="gallery-overlay" aria-hidden="true">
<span class="gallery-zoom">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round">
<circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/>
<path d="M11 8v6"/><path d="M8 11h6"/>
</svg>
</span>
</span>
</a>
</figure>
<?php endforeach; ?>
</div>
<?php else: ?>
<img src="/img/placeholder/tour128x100.jpg" class="mt-3 ml-3">
<?php endif; ?>
<div class="mt-1">
<label class="ml-2" style="width:140px; text-align:left;font-size:18px;" for="beschreibung">Beschreibung:</label>
<textarea class="col-12" name="beschreibung" rows="10" cols="50" readonly><?= e($tour->beschreibung) ?></textarea>
</div>
<div class="mt-1">
<label class="ml-2" style="width:140px; text-align:left;font-size:18px;" for="bericht">Bericht:</label>
<textarea class="col-12" name="bericht" rows="10" cols="50" readonly><?= e($tour->bericht) ?></textarea>
</div>
<?php if ($current && $canManage): ?>
<a href="/tour/<?= e($tour->id) ?>/edit"><div type="submit" class="btn btn-danger col-3 mb-2 float-left mr-2">Bearbeiten</div></a>
<?php endif; ?>
<a href="/tour" type="submit" class="btn btn-success col-3 mb-2 float-right mr-2">Ok</a>
</form>
</div>
</div>
<div class="container tour-detail">
<div class="row">
<div class="col-12 col-lg-8">
<?php require __DIR__ . '/partials/detail_card.php'; ?>
</div>
<div class="col-md-3 mt-2">
<?php if (!empty($canChat)): ?>
<div class="card mt-4">
<div class="card-body text-center">
<a href="/tour/<?= e($tour->id) ?>/chat" class="btn btn-primary btn-block">
Tour-Chat
<?php if (($chatUnread ?? 0) > 0): ?>
<span class="badge badge-light ml-1"><?= e(($chatUnread ?? 0) > 99 ? '99+' : (string) $chatUnread) ?></span>
<?php endif; ?>
</a>
<small class="text-muted d-block mt-2">Geschlossener Chat für Teilnehmer</small>
</div>
</div>
<?php endif; ?>
<aside class="col-12 col-lg-4">
<section class="tour-side-card">
<h2 class="tour-side-title">
Teilnehmer
<span class="tour-side-count"><?= count($users) ?>/<?= (int) $tour->max_participants ?></span>
</h2>
<div class="card mt-4">
<div class="card-header"><h5>Teilnehmer</h5></div>
<div class="card-body">
<ul>
<?php foreach ($users as $u): ?>
<li><?= e($u->name) ?> &nbsp;
<?php if ($canManage): ?>
<form action="/tour/<?= e($tour->id) ?>/cancelBookingAdmin/<?= e($u->id) ?>" method="POST" style="display:inline;">
<?= csrf_field() ?>
<button type="submit" class="text-primary" style="border:none;background:none;padding:0;cursor:pointer;">(X)</button>
</form>
<?php endif; ?>
<?php if (empty($users)): ?>
<p class="tour-side-empty">Niemand hat teilgenommen.</p>
<?php else: ?>
<ul class="tour-person-list">
<?php foreach ($users as $participant): ?>
<li class="tour-person">
<span class="tour-person-name">
<i class="fas fa-biking" aria-hidden="true"></i>
<?= e($participant->name) ?>
</span>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<?php endif; ?>
</section>
<section class="tour-side-card">
<h2 class="tour-side-title">Tour-Chat</h2>
<a href="/tour/<?= e($tour->id) ?>/chat" class="btn btn-primary btn-block">
<i class="fas fa-comments" aria-hidden="true"></i> Chat-Archiv ansehen
</a>
</section>
<?php if ($canManage): ?>
<section class="tour-side-card">
<h2 class="tour-side-title">Organisation</h2>
<div class="tour-side-actions">
<a class="btn btn-outline-light btn-block" href="/tour/<?= e($tour->id) ?>/edit">
<i class="fas fa-pen" aria-hidden="true"></i> Tour bearbeiten
</a>
<a class="btn btn-outline-light btn-block" href="/tour">
<i class="fas fa-list" aria-hidden="true"></i> Zur Tourenliste
</a>
</div>
</section>
<?php endif; ?>
</aside>
</div>
</div>