Uhrzeiten, Miete und Lieferkosten ergänzen; Server-Stand übernehmen
- 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
This commit is contained in:
parent
672df3d0a7
commit
d47a72820d
24 changed files with 1157 additions and 92 deletions
53
app/util.php
53
app/util.php
|
|
@ -89,7 +89,7 @@ function url(string $path = '/'): string
|
|||
}
|
||||
|
||||
/** Cache-Buster: bei Änderungen an app.css/app.js erhöhen. */
|
||||
const DIC_ASSET_VERSION = '8';
|
||||
const DIC_ASSET_VERSION = '10';
|
||||
|
||||
function asset(string $path): string
|
||||
{
|
||||
|
|
@ -233,6 +233,8 @@ function abort_page(int $code, string $message): never
|
|||
. '<p class="eyebrow">Drink it cold · Terminplanung</p>'
|
||||
. '<h1>' . e($title) . '</h1><p>' . e($message) . '</p>'
|
||||
. '<p><a class="btn primary" href="' . e(url('/')) . '">Zur Übersicht</a></p>'
|
||||
. '<p class="muted small"><a href="' . e(url('/impressum')) . '">Impressum</a>'
|
||||
. ' · <a href="' . e(url('/datenschutz')) . '">Datenschutz</a></p>'
|
||||
. '</div></body></html>';
|
||||
exit;
|
||||
}
|
||||
|
|
@ -258,6 +260,55 @@ function date_obj(string $iso): DateTimeImmutable
|
|||
return new DateTimeImmutable($iso . ' 12:00:00', new DateTimeZone('Europe/Berlin'));
|
||||
}
|
||||
|
||||
/** Uhrzeit als "HH:MM" normalisieren; leer bleibt leer (optional). */
|
||||
function normalize_time(mixed $value): string
|
||||
{
|
||||
$text = trim((string) $value);
|
||||
if ($text === '') {
|
||||
return '';
|
||||
}
|
||||
if (preg_match('/^(\d{1,2}):(\d{2})(?::\d{2})?$/', $text, $match) === 1) {
|
||||
return sprintf('%02d:%02d', (int) $match[1], (int) $match[2]);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
/** Leere Uhrzeit wird in der Datenbank als NULL gespeichert. */
|
||||
function null_if_empty(string $value): ?string
|
||||
{
|
||||
return $value === '' ? null : $value;
|
||||
}
|
||||
|
||||
/** Leere Uhrzeit ist erlaubt – sie ist ein optionales Zusatzfeld. */
|
||||
function valid_time(?string $time): bool
|
||||
{
|
||||
if ($time === null || $time === '') {
|
||||
return true;
|
||||
}
|
||||
return preg_match('/^([01]\d|2[0-3]):[0-5]\d$/', $time) === 1;
|
||||
}
|
||||
|
||||
function fmt_time(?string $time): string
|
||||
{
|
||||
$value = normalize_time($time);
|
||||
return $value !== '' && valid_time($value) ? $value : '';
|
||||
}
|
||||
|
||||
/** Datum mit optionaler Uhrzeit, z. B. "30.11.2026 14:00". */
|
||||
function fmt_date_with_time(string $iso, ?string $time): string
|
||||
{
|
||||
$clock = fmt_time($time);
|
||||
return $clock === '' ? fmt_date($iso) : fmt_date($iso) . ' ' . $clock;
|
||||
}
|
||||
|
||||
/** Kurzform für Listen/Kopiertext: "30.11.26 14:00". */
|
||||
function fmt_date_short_with_time(string $iso, ?string $time): string
|
||||
{
|
||||
$clock = fmt_time($time);
|
||||
return $clock === '' ? fmt_date_short($iso) : fmt_date_short($iso) . ' ' . $clock;
|
||||
}
|
||||
|
||||
|
||||
function add_days(string $iso, int $days): string
|
||||
{
|
||||
return date_obj($iso)->modify(($days >= 0 ? '+' : '') . $days . ' days')->format('Y-m-d');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue