Anhänger anlegen, aktivieren und löschen
This commit is contained in:
parent
b50267e4f0
commit
5ecbd29d21
15 changed files with 265 additions and 55 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Drink it cold – Terminplanung
|
||||
|
||||
Interne Web-App zur Verwaltung von acht Kühlanhängern: Buchungen, Mietzeiträume,
|
||||
Interne Web-App zur Verwaltung der Kühlanhänger: Buchungen, Mietzeiträume,
|
||||
Mitarbeiterzuordnung und automatische Erinnerungen. Farbschema und Logo der
|
||||
bestehenden Website (Weiß/Blau, `#196abc`) wurden übernommen.
|
||||
|
||||
|
|
@ -9,7 +9,7 @@ Die Anforderungen stammen aus
|
|||
|
||||
## Was die App kann
|
||||
|
||||
- **Kalender** mit Tages-, Wochen- und Monatsansicht. Alle acht Anhänger haben
|
||||
- **Kalender** mit Tages-, Wochen- und Monatsansicht. Alle Anhänger haben
|
||||
eine eigene Zeile und sind immer gleichzeitig sichtbar. Jeder Termin ist ein
|
||||
durchgehender, farbiger Balken in der Farbe des Anhängers.
|
||||
- **Buchungen** mit Anfangs- und Endtermin (ganztägig), Anzahlung,
|
||||
|
|
@ -29,6 +29,7 @@ Die Anforderungen stammen aus
|
|||
- **Web Push (VAPID):** In der installierten PWA kann jedes Gerät
|
||||
Benachrichtigungen autorisieren. Der Admin sieht in der Benutzerverwaltung,
|
||||
wer Push aktiviert hat und mit wie vielen Geräten.
|
||||
- **Anhänger verwalten**: neue Anhänger anlegen, Bezeichnung/Farbe/Sortierung ändern, aktivieren, deaktivieren und löschen, solange keine Buchung darauf verweist.
|
||||
- **Buchungen verwalten**: anlegen, bearbeiten, per Drag & Drop verschieben,
|
||||
anderen Anhänger oder Mitarbeiter zuordnen, stornieren, wiederherstellen und
|
||||
nach Kundenname suchen.
|
||||
|
|
@ -81,7 +82,7 @@ php -S 127.0.0.1:8099 -t web tools/router.php
|
|||
```
|
||||
|
||||
Dann `http://127.0.0.1:8099/install.php?token=<install_token>` öffnen und den
|
||||
ersten Administrator anlegen. Der Installer legt Schema, acht Anhänger und die
|
||||
ersten Administrator anlegen. Der Installer legt Schema, die in der Anforderung genannten Start-Anhänger und die
|
||||
Mitarbeiter M. Krücken, N. Jorns und M. Schmitz an. Danach `install.php`
|
||||
löschen.
|
||||
|
||||
|
|
|
|||
155
app/admin.php
155
app/admin.php
|
|
@ -332,55 +332,144 @@ function admin_employees(): void
|
|||
function admin_trailers(): void
|
||||
{
|
||||
$errors = [];
|
||||
$createErrors = [];
|
||||
$nextSort = (int) db()->query('SELECT COALESCE(MAX(sort_order), 0) + 10 FROM trailers')->fetchColumn();
|
||||
$createValues = [
|
||||
'label' => '',
|
||||
'color_name' => '',
|
||||
'color_hex' => '#196abc',
|
||||
'sort_order' => $nextSort,
|
||||
'active' => 1,
|
||||
];
|
||||
|
||||
if (is_post()) {
|
||||
require_post();
|
||||
$labels = post_array('label');
|
||||
$colorNames = post_array('color_name');
|
||||
$colors = post_array('color_hex');
|
||||
$sorts = post_array('sort_order');
|
||||
$action = post_string('action', 'update');
|
||||
|
||||
$existing = trailers_map();
|
||||
$seen = [];
|
||||
foreach ($existing as $id => $trailer) {
|
||||
$label = trim((string) ($labels[$id] ?? ''));
|
||||
$colorName = trim((string) ($colorNames[$id] ?? ''));
|
||||
$color = strtolower(trim((string) ($colors[$id] ?? '')));
|
||||
$sort = (int) ($sorts[$id] ?? $trailer['sort_order']);
|
||||
|
||||
if ($label === '' || mb_strlen($label) > 40) {
|
||||
$errors['trailer_' . $id] = 'Bitte eine Bezeichnung angeben (max. 40 Zeichen).';
|
||||
continue;
|
||||
if ($action === 'create') {
|
||||
$createValues = [
|
||||
'label' => post_string('label'),
|
||||
'color_name' => post_string('color_name'),
|
||||
'color_hex' => strtolower(post_string('color_hex')),
|
||||
'sort_order' => (int) post_string('sort_order'),
|
||||
'active' => post_string('active') === '1' ? 1 : 0,
|
||||
];
|
||||
if ($createValues['label'] === '' || mb_strlen($createValues['label']) > 40) {
|
||||
$createErrors['label'] = 'Bitte eine Bezeichnung angeben (max. 40 Zeichen).';
|
||||
}
|
||||
if (isset($seen[mb_strtolower($label)])) {
|
||||
$errors['trailer_' . $id] = 'Die Bezeichnung muss eindeutig sein.';
|
||||
continue;
|
||||
if ($createValues['color_name'] === '' || mb_strlen($createValues['color_name']) > 40) {
|
||||
$createErrors['color_name'] = 'Bitte einen Farbnamen angeben.';
|
||||
}
|
||||
$seen[mb_strtolower($label)] = true;
|
||||
if ($colorName === '' || mb_strlen($colorName) > 40) {
|
||||
$errors['trailer_' . $id] = 'Bitte einen Farbnamen angeben.';
|
||||
continue;
|
||||
if (!preg_match('/^#[0-9a-f]{6}$/', $createValues['color_hex'])) {
|
||||
$createErrors['color_hex'] = 'Bitte eine gültige Farbe (#rrggbb) wählen.';
|
||||
}
|
||||
if (!preg_match('/^#[0-9a-f]{6}$/', $color)) {
|
||||
$errors['trailer_' . $id] = 'Bitte eine gültige Farbe (#rrggbb) wählen.';
|
||||
continue;
|
||||
if ($createValues['label'] !== '') {
|
||||
$stmt = db()->prepare('SELECT id FROM trailers WHERE label = ? LIMIT 1');
|
||||
$stmt->execute([$createValues['label']]);
|
||||
if ($stmt->fetchColumn()) {
|
||||
$createErrors['label'] = 'Diese Bezeichnung ist bereits vergeben.';
|
||||
}
|
||||
}
|
||||
db()->prepare('UPDATE trailers SET label = ?, color_name = ?, color_hex = ?, sort_order = ? WHERE id = ?')
|
||||
->execute([$label, $colorName, $color, $sort, $id]);
|
||||
}
|
||||
if (!$errors) {
|
||||
flash('success', 'Anhänger wurden gespeichert.');
|
||||
if (!$createErrors) {
|
||||
db()->prepare('INSERT INTO trailers (label, color_name, color_hex, sort_order, active) VALUES (?, ?, ?, ?, ?)')
|
||||
->execute([
|
||||
$createValues['label'], $createValues['color_name'], $createValues['color_hex'],
|
||||
$createValues['sort_order'], $createValues['active'],
|
||||
]);
|
||||
flash('success', 'Anhänger ' . $createValues['label'] . ' wurde angelegt.');
|
||||
redirect('/admin/trailers');
|
||||
}
|
||||
http_response_code(422);
|
||||
} elseif ($action === 'delete') {
|
||||
$id = (int) post_string('id');
|
||||
$trailer = trailer_find($id);
|
||||
if (!$trailer) {
|
||||
abort_page(404, 'Anhänger nicht gefunden.');
|
||||
}
|
||||
$stmt = db()->prepare('SELECT COUNT(*) FROM bookings WHERE trailer_id = ?');
|
||||
$stmt->execute([$id]);
|
||||
if ((int) $stmt->fetchColumn() > 0) {
|
||||
flash('error', 'Anhänger ' . $trailer['label'] . ' kann nicht gelöscht werden, weil Buchungen darauf verweisen. Der Anhänger kann stattdessen deaktiviert werden.');
|
||||
redirect('/admin/trailers');
|
||||
}
|
||||
if ((int) $trailer['active'] === 1
|
||||
&& (int) db()->query('SELECT COUNT(*) FROM trailers WHERE active = 1')->fetchColumn() <= 1
|
||||
) {
|
||||
flash('error', 'Mindestens ein Anhänger muss aktiv bleiben, damit neue Buchungen möglich sind.');
|
||||
redirect('/admin/trailers');
|
||||
}
|
||||
db()->prepare('DELETE FROM trailers WHERE id = ?')->execute([$id]);
|
||||
flash('success', 'Anhänger ' . $trailer['label'] . ' wurde gelöscht.');
|
||||
redirect('/admin/trailers');
|
||||
} else {
|
||||
$labels = post_array('label');
|
||||
$colorNames = post_array('color_name');
|
||||
$colors = post_array('color_hex');
|
||||
$sorts = post_array('sort_order');
|
||||
$actives = post_array('active');
|
||||
|
||||
$existing = trailers_all(false);
|
||||
$seen = [];
|
||||
$updates = [];
|
||||
foreach ($existing as $trailer) {
|
||||
$id = (int) $trailer['id'];
|
||||
$label = trim((string) ($labels[$id] ?? $trailer['label']));
|
||||
$colorName = trim((string) ($colorNames[$id] ?? $trailer['color_name']));
|
||||
$color = strtolower(trim((string) ($colors[$id] ?? $trailer['color_hex'])));
|
||||
$sort = (int) ($sorts[$id] ?? $trailer['sort_order']);
|
||||
$active = ((string) ($actives[$id] ?? '0')) === '1' ? 1 : 0;
|
||||
|
||||
if ($label === '' || mb_strlen($label) > 40) {
|
||||
$errors['trailer_' . $id] = 'Bitte eine Bezeichnung angeben (max. 40 Zeichen).';
|
||||
} elseif (isset($seen[mb_strtolower($label)])) {
|
||||
$errors['trailer_' . $id] = 'Die Bezeichnung muss eindeutig sein.';
|
||||
}
|
||||
$seen[mb_strtolower($label)] = true;
|
||||
if ($colorName === '' || mb_strlen($colorName) > 40) {
|
||||
$errors['trailer_' . $id] = $errors['trailer_' . $id] ?? 'Bitte einen Farbnamen angeben.';
|
||||
}
|
||||
if (!preg_match('/^#[0-9a-f]{6}$/', $color)) {
|
||||
$errors['trailer_' . $id] = $errors['trailer_' . $id] ?? 'Bitte eine gültige Farbe (#rrggbb) wählen.';
|
||||
}
|
||||
if ((int) $trailer['active'] === 1 && $active === 0) {
|
||||
$stmt = db()->prepare("SELECT COUNT(*) FROM bookings WHERE trailer_id = ? AND status = 'active' AND end_date >= ?");
|
||||
$stmt->execute([$id, today_iso()]);
|
||||
if ((int) $stmt->fetchColumn() > 0) {
|
||||
$errors['trailer_' . $id] = 'Der Anhänger hat noch aktuelle oder zukünftige Buchungen und kann nicht deaktiviert werden.';
|
||||
}
|
||||
}
|
||||
$updates[$id] = [$label, $colorName, $color, $sort, $active];
|
||||
}
|
||||
if (!array_filter($updates, static fn (array $row): bool => (int) $row[4] === 1)) {
|
||||
$errors['general'] = 'Mindestens ein Anhänger muss aktiv bleiben, damit neue Buchungen möglich sind.';
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
foreach ($updates as $id => [$label, $colorName, $color, $sort, $active]) {
|
||||
db()->prepare('UPDATE trailers SET label = ?, color_name = ?, color_hex = ?, sort_order = ?, active = ? WHERE id = ?')
|
||||
->execute([$label, $colorName, $color, $sort, $active, $id]);
|
||||
}
|
||||
flash('success', 'Anhänger wurden gespeichert.');
|
||||
redirect('/admin/trailers');
|
||||
}
|
||||
http_response_code(422);
|
||||
}
|
||||
http_response_code(422);
|
||||
}
|
||||
|
||||
$rows = trailers_all(false);
|
||||
// Zeilen mit Anzahl Buchungen für die Lösch-/Deaktivierungsprüfung.
|
||||
$rows = db()->query(
|
||||
'SELECT t.*, (SELECT COUNT(*) FROM bookings b WHERE b.trailer_id = t.id) AS booking_count
|
||||
FROM trailers t ORDER BY t.sort_order, t.id'
|
||||
)->fetchAll();
|
||||
|
||||
render_page('admin_trailers', [
|
||||
'rows' => $rows,
|
||||
'errors' => $errors,
|
||||
'createErrors' => $createErrors,
|
||||
'createValues' => $createValues,
|
||||
'nextSort' => $nextSort,
|
||||
], 'Anhänger');
|
||||
}
|
||||
|
||||
function admin_reminders_send(): void
|
||||
{
|
||||
require_post();
|
||||
|
|
|
|||
|
|
@ -338,12 +338,17 @@ function page_calendar(array $user): void
|
|||
$to = add_days($from, 6);
|
||||
}
|
||||
|
||||
$trailers = trailers_all();
|
||||
$bookings = booking_list($from, $to, $showCancelled, $employeeId);
|
||||
$byTrailer = [];
|
||||
foreach ($bookings as $booking) {
|
||||
$byTrailer[(int) $booking['trailer_id']][] = $booking;
|
||||
}
|
||||
// Aktive Anhänger immer zeigen; inaktive nur, wenn im Zeitraum noch
|
||||
// historische Buchungen sichtbar sind.
|
||||
$trailers = array_values(array_filter(
|
||||
trailers_all(false),
|
||||
static fn (array $t): bool => (int) $t['active'] === 1 || !empty($byTrailer[(int) $t['id']])
|
||||
));
|
||||
|
||||
$days = [];
|
||||
$cursor = $from;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ function url(string $path = '/'): string
|
|||
}
|
||||
|
||||
/** Cache-Buster: bei Änderungen an app.css/app.js erhöhen. */
|
||||
const DIC_ASSET_VERSION = '3';
|
||||
const DIC_ASSET_VERSION = '4';
|
||||
|
||||
function asset(string $path): string
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ Browser
|
|||
|
||||
| Tabelle | Zweck |
|
||||
|---|---|
|
||||
| `trailers` | Acht Anhänger mit Bezeichnung, Farbname, Hex-Farbe, Sortierung |
|
||||
| `trailers` | Anhänger mit Bezeichnung, Farbname, Hex-Farbe, Sortierung und Aktiv-Status (Start-Anhänger aus der Anforderung vorinstalliert, weitere im Admin anlegbar) |
|
||||
| `employees` | Mitarbeiter (M. Krücken, N. Jorns, M. Schmitz), aktiv/inaktiv |
|
||||
| `users` | Login-Konten (Vorname, Nachname, Passwort-Hash, Rolle, optional E-Mail, optional Mitarbeiter-Link) |
|
||||
| `bookings` | Buchung inkl. Zeitraum, Beträge, Rechnungsflag, Art, Kundendaten, Status |
|
||||
|
|
@ -57,7 +57,7 @@ entstehen.
|
|||
sichtbar. Lanes und Balkenpositionen werden serverseitig in Prozent
|
||||
berechnet; das funktioniert ohne JavaScript und ohne externe Kalender-Library.
|
||||
- Tages-, Wochen- und Monatsansicht nutzen dieselbe Zeilenstruktur
|
||||
(8 Anhänger × Zeitraum). Die Monatsansicht ist bewusst als horizontale
|
||||
(Anhänger × Zeitraum). Die Monatsansicht ist bewusst als horizontale
|
||||
Zeitachse umgesetzt, damit auch dort jeder Anhänger eine eigene Zeile behält
|
||||
und kein Termin in „weitere Termine“ wandert.
|
||||
|
||||
|
|
@ -65,6 +65,21 @@ Drag & Drop verschiebt den Mietbeginn horizontal um ganze Tage (Mietdauer
|
|||
bleibt erhalten) und den Anhänger vertikal. Die Server-API validiert erneut,
|
||||
inklusive Überschneidungsprüfung; bei Konflikt bleibt die Buchung unverändert.
|
||||
|
||||
## Anhänger verwalten
|
||||
|
||||
Die Startausstattung aus der Anforderung wird vom Installer angelegt. Unter
|
||||
**Verwaltung → Anhänger** können weitere Anhänger angelegt werden:
|
||||
|
||||
- Bezeichnung, Farbname, Hex-Farbe und Sortierung sind frei wählbar.
|
||||
- Aktive Anhänger erscheinen sofort im Kalender und in der Buchungsmaske.
|
||||
- Inaktive Anhänger werden nicht mehr neu vergebbar; historische Buchungen
|
||||
bleiben erhalten und werden in ihrem Zeitraum weiterhin im Kalender
|
||||
angezeigt.
|
||||
- Deaktivieren ist gesperrt, solange aktive oder zukünftige Buchungen auf dem
|
||||
Anhänger liegen.
|
||||
- Löschen ist nur ohne jede Buchung möglich; sonst bleibt der Anhänger
|
||||
stattdessen deaktivierbar. Mindestens ein Anhänger muss aktiv bleiben.
|
||||
|
||||
## Erinnerungen
|
||||
|
||||
Die drei Erinnerungen werden **nicht** als Datensätze angelegt, sondern bei
|
||||
|
|
@ -109,7 +124,7 @@ sind die primäre Anzeige und funktionieren ohne Mailversand.
|
|||
|
||||
| Anforderung | Umsetzung |
|
||||
|---|---|
|
||||
| 2. Kalender, 8 Anhänger, je eine Zeile | `trailers` (8 Seeds), Kalenderzeilen mit fester Lane-Spalte, alle aktiven Anhänger immer sichtbar |
|
||||
| 2. Kalender, ein Anhänger je Zeile | `trailers` (Start-Anhänger aus der Anforderung, weitere anlegbar), Kalenderzeilen mit fester Lane-Spalte, alle aktiven Anhänger immer sichtbar |
|
||||
| Tag/Woche/Monat, Google-ähnlich | `?view=day|week|month`, Navigation, Heute, Datumssprung |
|
||||
| Durchgehende farbige Balken | absolute Balken pro Zeile, Farbe aus `trailers.color_hex` |
|
||||
| Keine ausgeblendeten Termine | alle Buchungen im Zeitraum werden gerendert; Lanes statt „weitere Termine“ |
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ $css = ($base !== '' ? $base : '') . '/assets/app.css';
|
|||
<div class="auth-visual__claim">
|
||||
<p class="eyebrow">Einrichtung</p>
|
||||
<h2>Einmal einrichten.<br>Dann läuft es.</h2>
|
||||
<p>Der Installer legt die acht Anhänger, das Mitarbeiter-Team und den ersten Administrator an.</p>
|
||||
<p>Der Installer legt die in der Anforderung genannten Start-Anhänger, das Mitarbeiter-Team und den ersten Administrator an.</p>
|
||||
</div>
|
||||
<p class="auth-visual__foot">Drink it cold · Neuss</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -142,7 +142,8 @@ CREATE TABLE IF NOT EXISTS login_attempts (
|
|||
KEY idx_login_name (name_key, attempted_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Grundausstattung: 8 Kühlanhänger (Farben laut Anforderung) und das
|
||||
-- Startausstattung: die in der Anforderung genannten Kühlanhänger
|
||||
-- (weitere können im Admin angelegt werden) und das
|
||||
-- bestehende Mitarbeiter-Team. Bestehende Zeilen bleiben bei erneutem
|
||||
-- Installationslauf unverändert.
|
||||
INSERT IGNORE INTO trailers (label, color_name, color_hex, sort_order) VALUES
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
<?php
|
||||
/** @var array $rows */
|
||||
/** @var array $errors */
|
||||
/** @var array $createErrors */
|
||||
/** @var array $createValues */
|
||||
$fieldError = static fn (int $id): string => (string) ($errors['trailer_' . $id] ?? '');
|
||||
$createError = static fn (string $key): string => (string) ($createErrors[$key] ?? '');
|
||||
?>
|
||||
<div class="page-head page-head--compact">
|
||||
<div>
|
||||
<p class="eyebrow">Verwaltung</p>
|
||||
<h1>Kühlanhänger</h1>
|
||||
<p class="page-head__lede">Acht Anhänger, acht Farben. Bezeichnung und Farbe lassen sich anpassen – die Farbe steuert die Balken im Kalender.</p>
|
||||
<p class="page-head__lede">Anhänger anlegen und pflegen. Jeder Anhänger hat seine eigene Farbe im Kalender; weitere Anhänger erscheinen automatisch als zusätzliche Zeile.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -22,12 +25,77 @@ $fieldError = static fn (int $id): string => (string) ($errors['trailer_' . $id]
|
|||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="<?= e(url('/admin/trailers')) ?>" class="panel">
|
||||
<section class="card">
|
||||
<div class="card__head">
|
||||
<h2>Anhänger anlegen</h2>
|
||||
<p>Neue Anhänger stehen sofort im Kalender und in der Buchungsmaske zur Auswahl. Die Sortierung bestimmt die Reihenfolge der Zeilen.</p>
|
||||
</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>
|
||||
</section>
|
||||
|
||||
<form method="post" action="<?= e(url('/admin/trailers')) ?>" class="panel" style="margin-top: 16px">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="update">
|
||||
<div class="panel__head">
|
||||
<div>
|
||||
<h2>Anhänger & Farben</h2>
|
||||
<p>Alle acht Anhänger bleiben gleichzeitig im Kalender sichtbar.</p>
|
||||
<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>
|
||||
|
|
@ -38,11 +106,13 @@ $fieldError = static fn (int $id): string => (string) ($errors['trailer_' . $id]
|
|||
<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' : '' ?>">
|
||||
<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">
|
||||
|
|
@ -50,13 +120,33 @@ $fieldError = static fn (int $id): string => (string) ($errors['trailer_' . $id]
|
|||
<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>
|
||||
|
||||
<?php foreach ($rows as $row): ?>
|
||||
<?php if ((int) $row['booking_count'] === 0): ?>
|
||||
<form id="delete-trailer-<?= (int) $row['id'] ?>" method="post" action="<?= e(url('/admin/trailers')) ?>" data-confirm="Anhänger <?= e($row['label']) ?> endgültig löschen?">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="id" value="<?= (int) $row['id'] ?>">
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ $minWidth = match ($view) {
|
|||
<span class="trailer-dot" style="--trailer: <?= e($trailer['color_hex']) ?>"></span>
|
||||
<span class="cal-label__text">
|
||||
<strong><?= e($trailer['label']) ?></strong>
|
||||
<small><?= e($trailer['color_name']) ?></small>
|
||||
<small><?= e($trailer['color_name']) ?><?= (int) $trailer['active'] === 1 ? '' : ' · inaktiv' ?></small>
|
||||
</span>
|
||||
<a class="cal-label__add" href="<?= e(url('/bookings/new?trailer=' . (int) $trailer['id'] . '&start=' . $date)) ?>" aria-label="Neue Buchung für <?= e($trailer['label']) ?>">+</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ $isEmployeeView = $employeeScope > 0;
|
|||
<div class="panel__head">
|
||||
<div>
|
||||
<h2>Heute im Einsatz</h2>
|
||||
<p>Alle acht Anhänger auf einen Blick<?= $isEmployeeView ? ' – mit Ihren Buchungen hervorgehoben' : '' ?>.</p>
|
||||
<p>Alle Anhänger auf einen Blick<?= $isEmployeeView ? ' – mit Ihren Buchungen hervorgehoben' : '' ?>.</p>
|
||||
</div>
|
||||
<a class="link-arrow" href="<?= e(url('/calendar?view=day')) ?>">Tagesansicht <svg class="ico" aria-hidden="true"><use href="#i-right"/></svg></a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
</div>
|
||||
<div class="auth-visual__claim">
|
||||
<p class="eyebrow">Terminplanung</p>
|
||||
<h2>Alle acht Anhänger.<br>Ein Blick.</h2>
|
||||
<h2>Alle Anhänger.<br>Ein Blick.</h2>
|
||||
<p>Buchungen, Übergaben und Erinnerungen zentral – damit niemand mehr im Kalender blättern muss.</p>
|
||||
<ul class="auth-points">
|
||||
<li><svg class="ico" aria-hidden="true"><use href="#i-check"/></svg> Kalender für Tag, Woche und Monat</li>
|
||||
|
|
|
|||
|
|
@ -706,7 +706,7 @@ a .ico, button .ico { pointer-events: none; }
|
|||
.admin-split { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 16px; align-items: start; }
|
||||
.trailer-admin { display: grid; gap: 0; border-top: 1px solid var(--line-soft); }
|
||||
.trailer-admin__head, .trailer-admin__row {
|
||||
display: grid; grid-template-columns: 150px minmax(110px, 1fr) minmax(100px, .8fr) 90px 170px;
|
||||
display: grid; grid-template-columns: 140px minmax(110px, 1fr) minmax(100px, .8fr) 78px 54px 150px 92px;
|
||||
gap: 10px; align-items: center;
|
||||
}
|
||||
.trailer-admin__head { padding: 8px 2px; font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
|
||||
|
|
@ -719,8 +719,10 @@ a .ico, button .ico { pointer-events: none; }
|
|||
.trailer-admin__color { display: flex; align-items: center; gap: 7px; }
|
||||
.trailer-admin__color input[type="color"] { width: 38px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
|
||||
.trailer-admin__color .color-hex { width: 82px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; }
|
||||
.trailer-admin__preview { display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; border-radius: 8px; background: var(--trailer); color: var(--trailer-text); font-size: .76rem; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
||||
.trailer-admin__preview { display: inline-flex; width: fit-content; max-width: 100%; align-items: center; gap: 7px; padding: 7px 9px; border-radius: 8px; background: var(--trailer); color: var(--trailer-text); font-size: .76rem; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
||||
.trailer-admin__row .field-error { grid-column: 1 / -1; }
|
||||
.trailer-admin__active { justify-content: center; }
|
||||
.trailer-admin__active input { margin-top: 0; }
|
||||
|
||||
/* --------------------------------------------------------------- Account */
|
||||
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
|
||||
|
|
@ -875,6 +877,8 @@ a .ico, button .ico { pointer-events: none; }
|
|||
.trailer-admin__row { grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px 0; }
|
||||
.trailer-admin__row .trailer-admin__color { grid-column: 1 / -1; }
|
||||
.trailer-admin__row .trailer-admin__preview { grid-column: 1 / -1; }
|
||||
.trailer-admin__row .trailer-admin__active { grid-column: 1 / -1; justify-content: flex-start; }
|
||||
.trailer-admin__row > .link-button, .trailer-admin__row > .muted { grid-column: 1 / -1; }
|
||||
.trailer-admin__row input[type="number"] { width: 100%; }
|
||||
.admin-nav { overflow-x: auto; flex-wrap: nowrap; }
|
||||
.admin-nav a { flex: 0 0 auto; }
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@
|
|||
|
||||
/* --------------------------------------------------- Anhängerfarben (Admin) */
|
||||
document.querySelectorAll('[data-color-sync]').forEach((colorInput) => {
|
||||
const row = colorInput.closest('.trailer-admin__row');
|
||||
const row = colorInput.closest('[data-color-row]');
|
||||
const textInput = row?.querySelector('[data-color-text]');
|
||||
const preview = row?.querySelector('[data-color-preview]');
|
||||
const dot = preview?.querySelector('.trailer-dot');
|
||||
|
|
@ -519,6 +519,11 @@
|
|||
});
|
||||
labelInput?.addEventListener('input', () => {
|
||||
if (!preview) return;
|
||||
const labelTarget = preview.querySelector('[data-color-preview-label]');
|
||||
if (labelTarget) {
|
||||
labelTarget.textContent = labelInput.value || 'Neuer Anhänger';
|
||||
return;
|
||||
}
|
||||
const textNode = [...preview.childNodes].find((node) => node.nodeType === Node.TEXT_NODE && node.textContent.trim());
|
||||
if (textNode) textNode.textContent = ` ${labelInput.value}`;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
{
|
||||
"name": "Kalender",
|
||||
"short_name": "Kalender",
|
||||
"description": "Wochenkalender aller acht Anhänger öffnen",
|
||||
"description": "Wochenkalender aller Anhänger öffnen",
|
||||
"url": "/calendar?view=week",
|
||||
"icons": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* zwischengespeichert, damit niemand veraltete Buchungen sieht.
|
||||
*/
|
||||
|
||||
const VERSION = 'dic-v3';
|
||||
const VERSION = 'dic-v4';
|
||||
const CACHE = VERSION;
|
||||
const BASE = new URL(self.registration.scope).pathname.replace(/\/$/, '');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue