- bookings um optionale start_time/end_time sowie rent_cents und delivery_cents erweitert; Gesamtbetrag ist Miete + Lieferkosten (Migration 003, Schema und Doku nachgezogen) - Formular, Detailansicht, Panel, Kalender und Kopiertext zeigen Uhrzeiten und die getrennten Beträge - Live-Stand nachgezogen: Impressum/Datenschutz, Privacy-Cleanup im Cron-Lauf, Löschsperre für Buchungen mit Rechnung - Cache-Buster auf Version 10 erhöht
170 lines
11 KiB
PHP
170 lines
11 KiB
PHP
<?php
|
||
/** @var string $view */
|
||
/** @var string $date */
|
||
/** @var string $from */
|
||
/** @var string $to */
|
||
/** @var array $days */
|
||
/** @var array $rows */
|
||
/** @var string $calTitle */
|
||
/** @var string $prevDate */
|
||
/** @var string $nextDate */
|
||
/** @var string $today */
|
||
/** @var int $employeeId */
|
||
/** @var bool $showCancelled */
|
||
/** @var array $employees */
|
||
/** @var int $bookingCount */
|
||
/** @var callable $urlFor */
|
||
$cols = count($days);
|
||
$laneWidth = 150;
|
||
$minWidth = match ($view) {
|
||
'week' => $laneWidth + 7 * 92,
|
||
'month' => $laneWidth + $cols * 40,
|
||
default => 0,
|
||
};
|
||
?>
|
||
<div class="page-head page-head--compact">
|
||
<div>
|
||
<p class="eyebrow">Kalender · <?= $bookingCount ?> Buchung<?= $bookingCount === 1 ? '' : 'en' ?> im Zeitraum</p>
|
||
<h1><?= e($calTitle) ?></h1>
|
||
</div>
|
||
<div class="page-head__actions">
|
||
<a class="btn primary" href="<?= e(url('/bookings/new?start=' . $date)) ?>">
|
||
<svg class="ico" aria-hidden="true"><use href="#i-plus"/></svg> Neue Buchung
|
||
</a>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="cal-toolbar">
|
||
<div class="cal-toolbar__left">
|
||
<div class="segmented" role="group" aria-label="Ansicht">
|
||
<?php foreach (['day' => 'Tag', 'week' => 'Woche', 'month' => 'Monat'] as $key => $label): ?>
|
||
<a href="<?= e(url(calendar_url($date, $key, $employeeId, $showCancelled))) ?>"<?= $view === $key ? ' class="is-active" aria-current="page"' : '' ?>><?= $label ?></a>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<div class="cal-nav">
|
||
<a class="icon-btn" href="<?= e(url($urlFor($prevDate))) ?>" aria-label="Vorheriger Zeitraum"><svg class="ico" aria-hidden="true"><use href="#i-left"/></svg></a>
|
||
<a class="btn small" href="<?= e(url($urlFor($today))) ?>">Heute</a>
|
||
<a class="icon-btn" href="<?= e(url($urlFor($nextDate))) ?>" aria-label="Nächster Zeitraum"><svg class="ico" aria-hidden="true"><use href="#i-right"/></svg></a>
|
||
<form class="date-jump" method="get" action="<?= e(url('/calendar')) ?>">
|
||
<input type="hidden" name="view" value="<?= e($view) ?>">
|
||
<?php if ($employeeId > 0): ?><input type="hidden" name="employee" value="<?= (int) $employeeId ?>"><?php endif; ?>
|
||
<?php if ($showCancelled): ?><input type="hidden" name="cancelled" value="1"><?php endif; ?>
|
||
<label class="sr-only" for="cal-date">Datum</label>
|
||
<input type="date" id="cal-date" name="date" value="<?= e($date) ?>" data-autosubmit>
|
||
<button class="btn small" type="submit">Springen</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<form class="cal-filters" method="get" action="<?= e(url('/calendar')) ?>">
|
||
<input type="hidden" name="view" value="<?= e($view) ?>">
|
||
<input type="hidden" name="date" value="<?= e($date) ?>">
|
||
<?php if (count($employees) > 1): ?>
|
||
<label class="inline-field">
|
||
<span>Mitarbeiter</span>
|
||
<select name="employee" data-autosubmit>
|
||
<option value="">Alle</option>
|
||
<?php foreach ($employees as $employee): ?>
|
||
<option value="<?= (int) $employee['id'] ?>"<?= $employeeId === (int) $employee['id'] ? ' selected' : '' ?>><?= e($employee['name']) ?></option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</label>
|
||
<?php endif; ?>
|
||
<label class="check check--small">
|
||
<input type="checkbox" name="cancelled" value="1" data-autosubmit<?= $showCancelled ? ' checked' : '' ?>>
|
||
<span>Stornierte</span>
|
||
</label>
|
||
<button class="btn small cal-filters__submit" type="submit">Anwenden</button>
|
||
</form>
|
||
</div>
|
||
|
||
<?php if ($view !== 'day'): ?>
|
||
<p class="cal-scroll-hint"><svg class="ico" aria-hidden="true"><use href="#i-left"/></svg> Seitlich scrollen, um alle Tage zu sehen <svg class="ico" aria-hidden="true"><use href="#i-right"/></svg></p>
|
||
<?php endif; ?>
|
||
|
||
<div class="cal-shell" data-calendar-view="<?= e($view) ?>" data-calendar-date="<?= e($date) ?>">
|
||
<div class="cal-scroll">
|
||
<div class="cal" style="--cols: <?= $cols ?>;<?= $minWidth > 0 ? ' min-width: ' . $minWidth . 'px;' : '' ?>">
|
||
<div class="cal-corner">
|
||
<span class="cal-corner__title">Anhänger</span>
|
||
<span class="cal-corner__hint">Farbe = Anhänger</span>
|
||
</div>
|
||
<div class="cal-head">
|
||
<?php foreach ($days as $day): ?>
|
||
<div class="cal-head__day<?= $day['is_today'] ? ' is-today' : '' ?><?= $day['is_weekend'] ? ' is-weekend' : '' ?>">
|
||
<span class="cal-head__weekday"><?= e($day['weekday']) ?></span>
|
||
<span class="cal-head__num"><?= (int) $day['day'] ?></span>
|
||
<?php if ($view === 'day' || ($view === 'month' && $day['is_first_of_month']) || ($view === 'week' && $day['is_first_of_month'])): ?>
|
||
<span class="cal-head__month"><?= e(fmt_month($day['iso'])) ?></span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
|
||
<?php foreach ($rows as $row): ?>
|
||
<?php $trailer = $row['trailer']; ?>
|
||
<div class="cal-label" style="--row-h: <?= (int) $row['height'] ?>px">
|
||
<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']) ?><?= (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>
|
||
<div class="cal-track" style="--row-h: <?= (int) $row['height'] ?>px; --lanes: <?= (int) $row['lanes'] ?>" data-trailer-id="<?= (int) $trailer['id'] ?>">
|
||
<div class="cal-cells">
|
||
<?php foreach ($days as $day): ?>
|
||
<a class="cal-cell<?= $day['is_today'] ? ' is-today' : '' ?><?= $day['is_weekend'] ? ' is-weekend' : '' ?>"
|
||
href="<?= e(url('/bookings/new?trailer=' . (int) $trailer['id'] . '&start=' . $day['iso'] . '&end=' . $day['iso'])) ?>"
|
||
data-cell="1"
|
||
data-date="<?= e($day['iso']) ?>"
|
||
aria-label="Neue Buchung <?= e($trailer['label']) ?> am <?= e(fmt_date($day['iso'])) ?>"></a>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php foreach ($row['bars'] as $bar): ?>
|
||
<?php
|
||
$booking = $bar['booking'];
|
||
$geo = $bar['geo'];
|
||
$cancelled = $booking['status'] === 'cancelled';
|
||
$showMeta = $view === 'day' || ($view === 'week' && $geo['span'] >= 2);
|
||
$label = $view === 'month' ? truncate((string) $booking['customer_name'], 18) : (string) $booking['customer_name'];
|
||
$aria = $booking['customer_name'] . ', ' . $booking['trailer_label'] . ', '
|
||
. fmt_date_with_time($booking['start_date'], $booking['start_time'] ?? null) . ' bis '
|
||
. fmt_date_with_time($booking['end_date'], $booking['end_time'] ?? null)
|
||
. ', ' . $booking['employee_name'] . ($cancelled ? ', storniert' : '');
|
||
?>
|
||
<a class="cal-bar<?= $cancelled ? ' is-cancelled' : '' ?><?= $geo['cut_start'] ? ' is-cut-start' : '' ?><?= $geo['cut_end'] ? ' is-cut-end' : '' ?><?= $geo['span'] <= 1 ? ' is-tiny' : '' ?>"
|
||
href="<?= e(url('/bookings/' . (int) $booking['id'])) ?>"
|
||
draggable="false"
|
||
data-panel="<?= (int) $booking['id'] ?>"
|
||
data-booking-id="<?= (int) $booking['id'] ?>"
|
||
data-trailer-id="<?= (int) $booking['trailer_id'] ?>"
|
||
data-start-date="<?= e($booking['start_date']) ?>"
|
||
data-days="<?= days_between($booking['start_date'], $booking['end_date']) + 1 ?>"
|
||
style="--left: <?= number_format($geo['left'], 5, '.', '') ?>%; --width: <?= number_format($geo['width'], 5, '.', '') ?>%; --top: <?= number_format($geo['top'], 5, '.', '') ?>%; --height: <?= number_format($geo['height'], 5, '.', '') ?>%; --bar: <?= e($booking['trailer_color']) ?>; --bar-text: <?= e(contrast_color($booking['trailer_color'])) ?>;"
|
||
aria-label="<?= e($aria) ?>"
|
||
title="<?= e($booking['customer_name'] . ' · ' . fmt_date_with_time($booking['start_date'], $booking['start_time'] ?? null) . ' – ' . fmt_date_with_time($booking['end_date'], $booking['end_time'] ?? null) . ' · ' . $booking['employee_name'] . ($cancelled ? ' · storniert' : '')) ?>">
|
||
<span class="cal-bar__name"><?= e($label) ?></span>
|
||
<?php if ($showMeta): ?>
|
||
<span class="cal-bar__meta"><?= e($view === 'day' ? fmt_date_with_time($booking['start_date'], $booking['start_time'] ?? null) . ' – ' . fmt_date_with_time($booking['end_date'], $booking['end_time'] ?? null) : $booking['employee_name']) ?><?= $view === 'day' ? ' · ' . e($booking['employee_name']) : '' ?></span>
|
||
<?php endif; ?>
|
||
<?php if ($view === 'day'): ?>
|
||
<span class="cal-bar__meta cal-bar__meta--soft"><?= e(booking_kind_label((string) $booking['kind'])) ?> · <?= e(fmt_money((int) $booking['total_cents'])) ?></span>
|
||
<?php endif; ?>
|
||
<?php if ($cancelled): ?><span class="cal-bar__flag">storniert</span><?php endif; ?>
|
||
</a>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="cal-foot">
|
||
<p>
|
||
<span class="legend-dot"></span>
|
||
Farbige Balken gehören zum jeweiligen Anhänger. Zwei Buchungen dürfen sich am Wechseltag (letzter Tag = erster Tag) überschneiden – beide Balken bleiben sichtbar.
|
||
</p>
|
||
<?php if ($view !== 'month'): ?>
|
||
<p class="cal-foot__hint">Tipp: Balken lassen sich mit der Maus verschieben – horizontal ändert das Datum, vertikal den Anhänger.</p>
|
||
<?php endif; ?>
|
||
</div>
|