motorradig2027/motorradig/views/tour/create.php

132 lines
7.3 KiB
PHP

<?php
$flashError = flash_pull('error');
$validationErrors = errors();
unset($_SESSION['_errors']);
?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.2/dist/css/datepicker-bs4.min.css">
<script src="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.2/dist/js/datepicker.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.2/dist/js/locales/de.js"></script>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card mt-4">
<div class="card-header"><h4>Tour anlegen</h4></div>
<div class="card-body">
<?php if ($flashError !== null): ?>
<div class="alert alert-danger" role="alert"><?= e($flashError) ?></div>
<?php endif; ?>
<?php if ($validationErrors !== []): ?>
<div class="alert alert-danger" role="alert">
<strong>Bitte die Eingaben prüfen:</strong>
<ul class="mb-0 mt-1">
<?php foreach ($validationErrors as $messages): ?>
<?php foreach ($messages as $message): ?>
<li><?= e($message) ?></li>
<?php endforeach; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<form style="background-color: #fff;" class="text-dark" method="post" action="/tour/store" enctype="multipart/form-data">
<?= csrf_field() ?>
<input type="hidden" name="tour_guide_id" value="<?= e(user()->id) ?>">
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-3 col-form-label col-form-label-sm" style="width:180px; text-align:left;font-size:18px;" for="name">Name:</label>
<input class="mt-3 mr-2 form-control input-sm" type="text" id="name" name="name" value="<?= e(old('name') ?? $tour->name) ?>" required>
</div>
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-3" style="width:180px; text-align:left;font-size:18px;" for="start">Start:</label>
<input class="mt-3 mr-2 form-control input-sm" type="text" id="start" name="start" value="<?= e(old('start') ?? $tour->start) ?>" autocomplete="off" required>
</div>
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-3" style="width:180px; text-align:left;font-size:18px;" for="end_date">Ende:</label>
<input class="mt-3 mr-2 form-control input-sm" type="text" id="end_date" name="end_date"
value="<?= e(old('end_date') ?? $tour->end_date) ?>" autocomplete="off"
placeholder="optional, z. B. bei Mehrtages-Touren">
<?php if (error('end_date')): ?>
<div class="invalid-feedback d-block"><?= e(error('end_date')) ?></div>
<?php endif; ?>
</div>
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-4" style="width:180px; text-align:left;font-size:18px;" for="deadline">Anmeldeschluss:</label>
<input class="mt-3 mr-2 form-control" type="text" id="deadline" style="font-size:16px;" name="deadline" value="<?= e(old('deadline') ?? $tour->deadline) ?>" autocomplete="off" required>
</div>
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-4" style="width:180px; text-align:left;font-size:18px;" for="max_participants">Max Teilnehmer:</label>
<input class="mt-3 mr-2 form-control" type="text" id="max_participants" style="font-size:16px;" name="max_participants" value="<?= e(old('max_participants') ?? $tour->max_participants) ?>" required>
</div>
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="bild"><h4>Bild:</h4></label>
<img src="/img/placeholder/tour128x100.jpg" class="mt-3 ml-3">
<input type="file" class="mt-3 mr-2 form-control" id="bild" style="font-size:20px;" name="bild"
accept="image/jpeg,image/png,image/gif,image/webp" value="">
<small class="form-text text-muted ml-3 mt-2">
Optional. Weitere Bilder können nach dem Anlegen in der Tour hinzugefügt werden.
Bitte nur Bilder verwenden, an denen du die erforderlichen Rechte hast und
abgebildete Personen mit der Veröffentlichung einverstanden sind.
</small>
</div>
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-3" style="width:140px; text-align:left;font-size:18px;" for="is_cancelled">Storniert:</label>
<input class="mt-3 mr-2 form-control" type="checkbox" id="is_cancelled" style="font-size:10px;width:20px;" name="is_cancelled" <?= (old('is_cancelled') ?? input('is_cancelled')) ? 'checked' : '' ?>>
</div>
<div class="form-group">
<textarea class="col-12" name="beschreibung" rows="10" cols="50"><?= e(old('beschreibung') ?? $tour->beschreibung) ?></textarea>
</div>
<a href="/tour"><div type="submit" class="btn btn-success col-2 mb-2 float-right mr-2">Abbrechen</div></a>
<button type="submit" class="btn btn-danger col-2 mb-2 float-right mr-2">Speichern</button>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
const startInput = document.querySelector('input[name="start"]');
if (startInput && typeof Datepicker !== 'undefined') {
new Datepicker(startInput, {
'autohide': true,
'format': 'dd.mm.yyyy',
'language': 'de',
'orientation': 'bottom'
});
}
const endDateInput = document.querySelector('input[name="end_date"]');
if (endDateInput && typeof Datepicker !== 'undefined') {
new Datepicker(endDateInput, {
'autohide': true,
'format': 'dd.mm.yyyy',
'language': 'de',
'orientation': 'bottom'
});
}
const deadlineInput = document.querySelector('input[name="deadline"]');
if (deadlineInput && typeof Datepicker !== 'undefined') {
new Datepicker(deadlineInput, {
'autohide': true,
'format': 'dd.mm.yyyy',
'language': 'de',
'orientation': 'bottom'
});
}
</script>