drink-it-cold/views/booking_panel.php

91 lines
4.5 KiB
PHP

<?php
/** @var array $booking */
/** @var array $reminders */
/** @var array $doneMap */
/** @var string $copyText */
/** @var bool $canDelete */
$cancelled = $booking['status'] === 'cancelled';
$lines = explode("\n", $copyText);
$due = due_cents((int) $booking['total_cents'], (int) $booking['deposit_cents']);
$bookingUrl = '/bookings/' . (int) $booking['id'];
$openReminder = null;
foreach ($reminders as $reminder) {
$key = reminder_done_key($booking, $reminder['kind'], $reminder['due_date']);
if (!isset($doneMap[$key]) && !$cancelled) {
$openReminder = $reminder;
break;
}
}
?>
<div class="panel-head">
<div class="panel-head__main">
<div class="panel-head__trailer">
<span class="trailer-dot" style="--trailer: <?= e($booking['trailer_color']) ?>"></span>
<?= e($booking['trailer_label']) ?> · <?= e($booking['trailer_color_name']) ?>
</div>
<h2><?= e($booking['customer_name']) ?></h2>
<p>
<?= e(fmt_date_range($booking['start_date'], $booking['end_date'])) ?>
· <?= e($booking['employee_name']) ?>
<span class="pill <?= $cancelled ? 'pill--grey' : 'pill--green' ?>"><?= $cancelled ? 'storniert' : 'aktiv' ?></span>
</p>
</div>
<button class="icon-btn" type="button" data-close-dialog aria-label="Dialog schließen"><svg class="ico" aria-hidden="true"><use href="#i-close"/></svg></button>
</div>
<div class="panel-body">
<section class="panel-copy" data-copy-wrap>
<div class="panel-copy__head">
<h3>Buchungsinformation</h3>
<button class="btn small primary" type="button" data-copy>
<svg class="ico" aria-hidden="true"><use href="#i-copy"/></svg> Kopieren
</button>
</div>
<textarea class="copy-source" readonly aria-hidden="true" tabindex="-1"><?= e($copyText) ?></textarea>
<dl class="copy-list copy-list--compact">
<?php foreach ($lines as $line): ?>
<?php $parts = explode(': ', $line, 2); ?>
<div class="copy-list__row<?= ($parts[0] ?? '') === 'Noch zu zahlen' ? ' is-strong' : '' ?>">
<dt><?= e($parts[0] ?? $line) ?></dt>
<dd><?= e($parts[1] ?? '') ?></dd>
</div>
<?php endforeach; ?>
</dl>
</section>
<section class="panel-meta">
<dl class="meta-list meta-list--compact">
<div><dt>Anhänger</dt><dd><?= e($booking['trailer_label'] . ' · ' . $booking['trailer_color_name']) ?></dd></div>
<div><dt>Mitarbeiter</dt><dd><?= e($booking['employee_name']) ?></dd></div>
<div><dt>Art</dt><dd><?= e(booking_kind_label((string) $booking['kind'])) ?></dd></div>
<div><dt>Rechnung</dt><dd><?= e(booking_invoice_label($booking['invoice'])) ?></dd></div>
<div><dt>Anzahlung</dt><dd><?= e(fmt_money((int) $booking['deposit_cents'])) ?></dd></div>
<div><dt>Gesamt</dt><dd><?= e(fmt_money((int) $booking['total_cents'])) ?></dd></div>
<div class="is-strong"><dt>Noch zu zahlen</dt><dd><?= e(fmt_money($due)) ?></dd></div>
</dl>
<?php if ($openReminder): ?>
<div class="next-reminder<?= $openReminder['due_date'] < today_iso() ? ' is-overdue' : '' ?>">
<span>Nächste Erinnerung</span>
<strong><?= e(fmt_date($openReminder['due_date'])) ?> · <?= e(relative_day($openReminder['due_date'])) ?></strong>
<p><?= e($openReminder['label']) ?></p>
</div>
<?php endif; ?>
</section>
</div>
<div class="panel-actions">
<a class="btn primary" href="<?= e(url($bookingUrl . '/edit')) ?>"><svg class="ico" aria-hidden="true"><use href="#i-edit"/></svg> Bearbeiten</a>
<a class="btn" href="<?= e(url($bookingUrl)) ?>">Vollständige Buchung</a>
<?php if (!$cancelled): ?>
<form method="post" action="<?= e(url($bookingUrl . '/cancel')) ?>" data-confirm="Buchung von <?= e($booking['customer_name']) ?> wirklich stornieren?">
<?= csrf_field() ?>
<input type="hidden" name="return_to" value="<?= e($bookingUrl) ?>">
<button class="btn danger-ghost" type="submit">Stornieren</button>
</form>
<?php else: ?>
<form method="post" action="<?= e(url($bookingUrl . '/restore')) ?>" data-confirm="Buchung wieder aktivieren?">
<?= csrf_field() ?>
<button class="btn" type="submit">Wiederherstellen</button>
</form>
<?php endif; ?>
</div>