Anhänger-anlegen-Button kompakt in den Kopfbereich integrieren

This commit is contained in:
OpenCode 2026-11-13 01:28:34 +01:00
parent b05bda7c96
commit e3d328f55a
4 changed files with 170 additions and 150 deletions

View file

@ -25,129 +25,135 @@ $createError = static fn (string $key): string => (string) ($createErrors[$key]
</div>
<?php endif; ?>
<details class="card create-trailer"<?= $createErrors ? ' open' : '' ?>>
<summary class="create-trailer__summary">
<span class="create-trailer__title">
<svg class="ico" aria-hidden="true"><use href="#i-plus"/></svg>
Anhänger anlegen
</span>
<span class="create-trailer__hint">Nur bei Bedarf – z. B. für einen zusätzlichen Mietanhänger.</span>
<svg class="ico create-trailer__chevron" aria-hidden="true"><use href="#i-right"/></svg>
</summary>
<div class="create-trailer__body">
<p class="muted small">Neue Anhänger stehen sofort im Kalender und in der Buchungsmaske zur Auswahl. Die Sortierung bestimmt die Reihenfolge der Zeilen.</p>
<?php if ($createErrors): ?>
<div class="alert alert--error" role="alert" style="margin-top: 14px">
<svg class="ico" aria-hidden="true"><use href="#i-alert"/></svg>
<div><strong>Bitte die markierten Felder prüfen.</strong>
<?php foreach ($createErrors as $message): ?><p><?= e($message) ?></p><?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<form method="post" action="<?= e(url('/admin/trailers')) ?>" class="form-grid" data-color-row>
<?= csrf_field() ?>
<input type="hidden" name="action" value="create">
<label class="field<?= $createError('label') !== '' ? ' has-error' : '' ?>">
<span>Bezeichnung</span>
<input type="text" name="label" value="<?= e($createValues['label']) ?>" maxlength="40" required placeholder="z. B. Nr. 9">
<?php if ($createError('label')): ?><em class="field-error"><?= e($createError('label')) ?></em><?php endif; ?>
</label>
<label class="field<?= $createError('color_name') !== '' ? ' has-error' : '' ?>">
<span>Farbname</span>
<input type="text" name="color_name" value="<?= e($createValues['color_name']) ?>" maxlength="40" required placeholder="z. B. Türkis">
<?php if ($createError('color_name')): ?><em class="field-error"><?= e($createError('color_name')) ?></em><?php endif; ?>
</label>
<div class="field<?= $createError('color_hex') !== '' ? ' has-error' : '' ?>">
<span>Farbe</span>
<span class="trailer-admin__color">
<input type="color" value="<?= e($createValues['color_hex']) ?>" data-color-sync aria-label="Farbe für den neuen Anhänger">
<input type="text" name="color_hex" value="<?= e($createValues['color_hex']) ?>" maxlength="7" pattern="#[0-9a-fA-F]{6}" class="color-hex" data-color-text aria-label="Farbe als Hex-Wert">
</span>
<span class="trailer-admin__preview" data-color-preview style="--trailer: <?= e($createValues['color_hex']) ?>; --trailer-text: <?= e(contrast_color($createValues['color_hex'])) ?>">
<span class="trailer-dot" style="--trailer: <?= e($createValues['color_hex']) ?>"></span>
<span data-color-preview-label><?= e($createValues['label'] ?: 'Neuer Anhänger') ?></span>
</span>
<?php if ($createError('color_hex')): ?><em class="field-error"><?= e($createError('color_hex')) ?></em><?php endif; ?>
</div>
<label class="field">
<span>Sortierung</span>
<input type="number" name="sort_order" value="<?= (int) $createValues['sort_order'] ?>" step="10">
</label>
<div class="field">
<span>Status</span>
<label class="check check--boxed">
<input type="hidden" name="active" value="0">
<input type="checkbox" name="active" value="1"<?= (int) $createValues['active'] === 1 ? ' checked' : '' ?>>
<span>Anhänger ist aktiv</span>
</label>
</div>
<div class="field field--wide">
<button class="btn primary" type="submit"><svg class="ico" aria-hidden="true"><use href="#i-plus"/></svg> Anhänger anlegen</button>
</div>
</form>
</div>
</details>
<form method="post" action="<?= e(url('/admin/trailers')) ?>" class="panel" style="margin-top: 16px">
<?= csrf_field() ?>
<input type="hidden" name="action" value="update">
<section class="panel">
<div class="panel__head">
<div>
<h2>Anhänger &amp; Farben</h2>
<p>Inaktive Anhänger erscheinen nicht in der Buchungsmaske; historische Buchungen bleiben erhalten.</p>
</div>
<button class="btn primary" type="submit"><svg class="ico" aria-hidden="true"><use href="#i-check"/></svg> Speichern</button>
<div class="panel__actions">
<details class="create-trailer" <?= $createErrors ? 'open' : '' ?>>
<summary class="btn small create-trailer__summary">
<svg class="ico" aria-hidden="true"><use href="#i-plus"/></svg> Anhänger anlegen
</summary>
<div class="create-trailer__body">
<div class="create-trailer__body-head">
<div>
<strong>Neuer Anhänger</strong>
<span>Er steht sofort im Kalender und in der Buchungsmaske zur Auswahl.</span>
</div>
<span class="muted small">Sortierung bestimmt die Zeilenreihenfolge</span>
</div>
<?php if ($createErrors): ?>
<div class="alert alert--error" role="alert">
<svg class="ico" aria-hidden="true"><use href="#i-alert"/></svg>
<div><strong>Bitte die markierten Felder prüfen.</strong>
<?php foreach ($createErrors as $message): ?><p><?= e($message) ?></p><?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<form method="post" action="<?= e(url('/admin/trailers')) ?>" class="form-grid" data-color-row>
<?= csrf_field() ?>
<input type="hidden" name="action" value="create">
<label class="field<?= $createError('label') !== '' ? ' has-error' : '' ?>">
<span>Bezeichnung</span>
<input type="text" name="label" value="<?= e($createValues['label']) ?>" maxlength="40" required placeholder="z. B. Nr. 9">
<?php if ($createError('label')): ?><em class="field-error"><?= e($createError('label')) ?></em><?php endif; ?>
</label>
<label class="field<?= $createError('color_name') !== '' ? ' has-error' : '' ?>">
<span>Farbname</span>
<input type="text" name="color_name" value="<?= e($createValues['color_name']) ?>" maxlength="40" required placeholder="z. B. Türkis">
<?php if ($createError('color_name')): ?><em class="field-error"><?= e($createError('color_name')) ?></em><?php endif; ?>
</label>
<div class="field<?= $createError('color_hex') !== '' ? ' has-error' : '' ?>">
<span>Farbe</span>
<span class="trailer-admin__color">
<input type="color" value="<?= e($createValues['color_hex']) ?>" data-color-sync aria-label="Farbe für den neuen Anhänger">
<input type="text" name="color_hex" value="<?= e($createValues['color_hex']) ?>" maxlength="7" pattern="#[0-9a-fA-F]{6}" class="color-hex" data-color-text aria-label="Farbe als Hex-Wert">
</span>
<span class="trailer-admin__preview" data-color-preview style="--trailer: <?= e($createValues['color_hex']) ?>; --trailer-text: <?= e(contrast_color($createValues['color_hex'])) ?>">
<span class="trailer-dot" style="--trailer: <?= e($createValues['color_hex']) ?>"></span>
<span data-color-preview-label><?= e($createValues['label'] ?: 'Neuer Anhänger') ?></span>
</span>
<?php if ($createError('color_hex')): ?><em class="field-error"><?= e($createError('color_hex')) ?></em><?php endif; ?>
</div>
<label class="field">
<span>Sortierung</span>
<input type="number" name="sort_order" value="<?= (int) $createValues['sort_order'] ?>" step="10">
</label>
<div class="field">
<span>Status</span>
<label class="check check--boxed">
<input type="hidden" name="active" value="0">
<input type="checkbox" name="active" value="1"<?= (int) $createValues['active'] === 1 ? ' checked' : '' ?>>
<span>Anhänger ist aktiv</span>
</label>
</div>
<div class="field field--wide">
<button class="btn primary" type="submit"><svg class="ico" aria-hidden="true"><use href="#i-plus"/></svg> Anhänger anlegen</button>
</div>
</form>
</div>
</details>
<button class="btn primary" type="submit" form="trailer-bulk-form">
<svg class="ico" aria-hidden="true"><use href="#i-check"/></svg> Speichern
</button>
</div>
</div>
<div class="trailer-admin">
<div class="trailer-admin__head" aria-hidden="true">
<span>Farbe</span>
<span>Bezeichnung</span>
<span>Farbname</span>
<span>Sortierung</span>
<span>Aktiv</span>
<span>Vorschau</span>
<span>Aktion</span>
</div>
<?php foreach ($rows as $row): ?>
<?php $id = (int) $row['id']; ?>
<div class="trailer-admin__row<?= $fieldError($id) !== '' ? ' has-error' : '' ?>" data-color-row>
<span class="trailer-admin__color">
<input type="color" value="<?= e($row['color_hex']) ?>" data-color-sync aria-label="Farbe für <?= e($row['label']) ?>">
<input type="text" name="color_hex[<?= $id ?>]" value="<?= e($row['color_hex']) ?>" maxlength="7" pattern="#[0-9a-fA-F]{6}" class="color-hex" data-color-text aria-label="Farbe als Hex-Wert">
</span>
<input type="text" name="label[<?= $id ?>]" value="<?= e($row['label']) ?>" maxlength="40" required aria-label="Bezeichnung">
<input type="text" name="color_name[<?= $id ?>]" value="<?= e($row['color_name']) ?>" maxlength="40" required aria-label="Farbname">
<input type="number" name="sort_order[<?= $id ?>]" value="<?= (int) $row['sort_order'] ?>" step="10" aria-label="Sortierung">
<label class="check trailer-admin__active">
<input type="hidden" name="active[<?= $id ?>]" value="0">
<input type="checkbox" name="active[<?= $id ?>]" value="1"<?= (int) $row['active'] === 1 ? ' checked' : '' ?>>
<span class="sr-only"><?= e($row['label']) ?> ist aktiv</span>
</label>
<span class="trailer-admin__preview" data-color-preview style="--trailer: <?= e($row['color_hex']) ?>; --trailer-text: <?= e(contrast_color($row['color_hex'])) ?>">
<span class="trailer-dot" style="--trailer: <?= e($row['color_hex']) ?>"></span>
<?= e($row['label']) ?>
</span>
<?php if ((int) $row['booking_count'] === 0): ?>
<button class="link-button small" type="submit" form="delete-trailer-<?= $id ?>"><svg class="ico" aria-hidden="true"><use href="#i-trash"/></svg> Löschen</button>
<?php else: ?>
<span class="muted small" title="<?= (int) $row['booking_count'] ?> Buchung(en) verweisen auf diesen Anhänger"><?= (int) $row['booking_count'] ?> Buchung<?= (int) $row['booking_count'] === 1 ? '' : 'en' ?></span>
<?php endif; ?>
<?php if ($fieldError($id)): ?><em class="field-error"><?= e($fieldError($id)) ?></em><?php endif; ?>
<form id="trailer-bulk-form" method="post" action="<?= e(url('/admin/trailers')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="action" value="update">
<div class="trailer-admin">
<div class="trailer-admin__head" aria-hidden="true">
<span>Farbe</span>
<span>Bezeichnung</span>
<span>Farbname</span>
<span>Sortierung</span>
<span>Aktiv</span>
<span>Vorschau</span>
<span>Aktion</span>
</div>
<?php endforeach; ?>
</div>
<p class="muted small">Hinweis: Die Farbe wird bei allen Buchungen dieses Anhängers sofort übernommen. Der Buchungstext selbst bleibt unverändert.</p>
</form>
<?php foreach ($rows as $row): ?>
<?php $id = (int) $row['id']; ?>
<div class="trailer-admin__row<?= $fieldError($id) !== '' ? ' has-error' : '' ?>" data-color-row>
<span class="trailer-admin__color">
<input type="color" value="<?= e($row['color_hex']) ?>" data-color-sync aria-label="Farbe für <?= e($row['label']) ?>">
<input type="text" name="color_hex[<?= $id ?>]" value="<?= e($row['color_hex']) ?>" maxlength="7" pattern="#[0-9a-fA-F]{6}" class="color-hex" data-color-text aria-label="Farbe als Hex-Wert">
</span>
<input type="text" name="label[<?= $id ?>]" value="<?= e($row['label']) ?>" maxlength="40" required aria-label="Bezeichnung">
<input type="text" name="color_name[<?= $id ?>]" value="<?= e($row['color_name']) ?>" maxlength="40" required aria-label="Farbname">
<input type="number" name="sort_order[<?= $id ?>]" value="<?= (int) $row['sort_order'] ?>" step="10" aria-label="Sortierung">
<label class="check trailer-admin__active">
<input type="hidden" name="active[<?= $id ?>]" value="0">
<input type="checkbox" name="active[<?= $id ?>]" value="1"<?= (int) $row['active'] === 1 ? ' checked' : '' ?>>
<span class="sr-only"><?= e($row['label']) ?> ist aktiv</span>
</label>
<span class="trailer-admin__preview" data-color-preview style="--trailer: <?= e($row['color_hex']) ?>; --trailer-text: <?= e(contrast_color($row['color_hex'])) ?>">
<span class="trailer-dot" style="--trailer: <?= e($row['color_hex']) ?>"></span>
<?= e($row['label']) ?>
</span>
<?php if ((int) $row['booking_count'] === 0): ?>
<button class="link-button small" type="submit" form="delete-trailer-<?= $id ?>"><svg class="ico" aria-hidden="true"><use href="#i-trash"/></svg> Löschen</button>
<?php else: ?>
<span class="muted small" title="<?= (int) $row['booking_count'] ?> Buchung(en) verweisen auf diesen Anhänger"><?= (int) $row['booking_count'] ?> Buchung<?= (int) $row['booking_count'] === 1 ? '' : 'en' ?></span>
<?php endif; ?>
<?php if ($fieldError($id)): ?><em class="field-error"><?= e($fieldError($id)) ?></em><?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<p class="muted small">Hinweis: Die Farbe wird bei allen Buchungen dieses Anhängers sofort übernommen. Der Buchungstext selbst bleibt unverändert.</p>
</form>
</section>
<?php foreach ($rows as $row): ?>
<?php if ((int) $row['booking_count'] === 0): ?>