motorradig2027/motorradig/views/tour/show.php

228 lines
12 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use App\Models\Tour;
$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;
}
?>
<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="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>
<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; ?>
<div class="card mt-4">
<div class="card-header"><h5>Teilnehmer</h5></div>
<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 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;">
<?= csrf_field() ?>
<button type="submit" class="text-primary" style="border:none;background:none;padding:0;cursor:pointer;" title="Entfernen">(X)</button>
</form>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
<div style="height:2px;"></div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
<script>
var modal = document.getElementById("myModal");
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0];
if (btn) {
btn.onclick = function (e) {
e.preventDefault();
modal.style.display = "block";
}
}
if (span) {
span.onclick = function (e) {
e.preventDefault();
modal.style.display = "none";
}
}
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>