feat: panel layout for the accommodation booking edit and detail pages

This commit is contained in:
fromme committed 2026-09-30 18:06:45 +02:00
1 parent 5fdee68ccd
commit eb45693257
9 files changed
+366 -233

No files matched your search

@@ -12,6 +12,7 @@ use App\Form\Admin\Groups\AccommodationBookingType;
use App\Repository\Groups\AdditionalServiceRepository; use App\Repository\Groups\AdditionalServiceRepository;
use App\Repository\Groups\BoardServiceRepository; use App\Repository\Groups\BoardServiceRepository;
use App\Repository\UserRepository; use App\Repository\UserRepository;
use App\Service\AccommodationBookingBreakdownCalculator;
use App\Service\AccommodationBookingService; use App\Service\AccommodationBookingService;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@@ -33,6 +34,7 @@ class EditController extends AbstractController
private readonly AdditionalServiceRepository $additionalServiceRepo, private readonly AdditionalServiceRepository $additionalServiceRepo,
private readonly UserRepository $userRepo, private readonly UserRepository $userRepo,
private readonly AccommodationBookingService $bookingService, private readonly AccommodationBookingService $bookingService,
private readonly AccommodationBookingBreakdownCalculator $breakdownCalculator,
) { ) {
} }
@@ -128,10 +130,7 @@ class EditController extends AbstractController
// The submitted changes stay on the entity but are never flushed, so the form // The submitted changes stay on the entity but are never flushed, so the form
// comes back filled in with the error on it. Logging is safe here: the database // comes back filled in with the error on it. Logging is safe here: the database
// handler writes through DBAL, not the EntityManager. // handler writes through DBAL, not the EntityManager.
return $this->render('admin/accommodation_booking/edit.html.twig', [ return $this->renderForm($booking, $form);
'booking' => $booking,
'form' => $form,
]);
} }
// Editing never moves the booking on and never mails the customer: every status // Editing never moves the booking on and never mails the customer: every status
@@ -160,9 +159,22 @@ class EditController extends AbstractController
return $this->redirectToRoute('app_admin_accommodationbooking_show', $parameters); return $this->redirectToRoute('app_admin_accommodationbooking_show', $parameters);
} }
return $this->renderForm($booking, $form);
}
/**
* The sidebar shows the stored price, not one computed from the submitted values: after a
* refused save the entity carries the unsaved changes, and the price there is labelled as the
* state of the last save.
*
* @param FormInterface<AccommodationBooking> $form
*/
private function renderForm(AccommodationBooking $booking, FormInterface $form): Response
{
return $this->render('admin/accommodation_booking/edit.html.twig', [ return $this->render('admin/accommodation_booking/edit.html.twig', [
'booking' => $booking, 'booking' => $booking,
'form' => $form, 'form' => $form,
'priceBreakdown' => $this->breakdownCalculator->compute($booking),
]); ]);
} }
@@ -18,10 +18,11 @@ class AccommodationBookingPeriodType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder $builder
// "Überschrift" rather than "Bezeichnung", which the lines below use for their own field.
->add('label', TextType::class, [ ->add('label', TextType::class, [
'label' => 'Bezeichnung', 'label' => 'Überschrift (optional)',
'required' => false, 'required' => false,
'help' => 'Überschrift in der Preisaufstellung, z. B. „Vorausteam“. Ohne Bezeichnung steht dort nur der Zeitraum.', 'attr' => ['placeholder' => 'z. B. Vorausteam'],
]) ])
->add('nights', IntegerType::class, [ ->add('nights', IntegerType::class, [
'label' => 'Nächte', 'label' => 'Nächte',
@@ -0,0 +1,32 @@
{#- One split-off period on the edit page, with its actions. Context: booking, period. -#}
{% set period_params = { id: period.id } %}
{% if app.request.query.get('r') %}
{% set period_params = period_params | merge({ r: app.request.query.get('r') }) %}
{% endif %}
<tr class="border-t border-gray-200 align-top">
<td class="py-1 whitespace-nowrap">{{ period.dateFrom | date('d.m.Y') }} – {{ period.dateTo | date('d.m.Y') }}</td>
<td class="py-1 whitespace-nowrap">{{ period.nights }} {{ period.nights != 1 ? 'Nächte' : 'Nacht' }}</td>
<td class="py-1">
{% if period.label %}
<div class="font-medium">{{ period.label }}</div>
{% endif %}
{% for line in period.lines %}
<div>{{ line.label }}</div>
{% else %}
<div class="text-gray-500">keine Positionen</div>
{% endfor %}
</td>
<td class="py-1 text-right whitespace-nowrap">
{{ (period.total / 100) | format_currency(booking.pricingCurrency ?? booking.accommodation.currency) }}
</td>
<td class="py-1 text-right">
<twig:dropdown>
<twig:dropdown:hxbutton url="{{ path('app_admin_accommodationbooking_period_edit', period_params) }}">
bearbeiten
</twig:dropdown:hxbutton>
<twig:dropdown:hxbutton url="{{ path('app_admin_accommodationbooking_period_remove', period_params) }}" warning>
entfernen
</twig:dropdown:hxbutton>
</twig:dropdown>
</td>
</tr>
@@ -0,0 +1,14 @@
{#- One split-off period of the price table on the detail page. Context: period, currency. -#}
<tr class="border-t border-gray-200 font-medium">
<td class="pt-2 pb-1" colspan="2">
{% if period.label ?? null %}{{ period.label }} · {% endif %}
{{ period.dateFrom | date('d.m.Y') }} – {{ period.dateTo | date('d.m.Y') }},
{{ period.nights }} {{ period.nights != 1 ? 'Nächte' : 'Nacht' }}
</td>
</tr>
{% for line in period.lines %}
<tr>
<td class="py-1">{{ line.label }}</td>
<td class="py-1 text-right whitespace-nowrap">{{ (line.amount / 100) | format_currency(currency) }}</td>
</tr>
{% endfor %}
@@ -22,37 +22,33 @@
{% form_theme form 'forms_admin.html.twig' %} {% form_theme form 'forms_admin.html.twig' %}
{{ form_start(form) }} {{ form_start(form) }}
<div class="grid lg:grid-cols-2 gap-y-4 lg:gap-x-8"> {{ form_errors(form) }}
<h2 class="lg:col-span-2 text-base font-bold">Kontaktdaten</h2> {# Ordered by what gets negotiated: the stay first, the contact data last. The sidebar keeps
{{ form_row(form.groupName) }} status, price and the save button in view on wide screens. #}
{{ form_row(form.salutation) }} <div class="xl:grid xl:grid-cols-3 xl:gap-6 xl:items-start space-y-6 xl:space-y-0">
{{ form_row(form.firstName) }} <div class="xl:col-span-2 space-y-6">
{{ form_row(form.lastName) }} <twig:form:section title="Aufenthalt">
{{ form_row(form.email) }} <div class="grid sm:grid-cols-2 gap-4">
{{ form_row(form.phone) }}
{{ form_row(form.street) }}
{{ form_row(form.zip) }}
{{ form_row(form.city) }}
<h2 class="lg:col-span-2 text-base font-bold pt-2">Reisedaten</h2>
{{ form_row(form.dateFrom) }} {{ form_row(form.dateFrom) }}
{{ form_row(form.dateTo) }} {{ form_row(form.dateTo) }}
</div>
<div class="grid sm:grid-cols-3 gap-4 pt-4">
{{ form_row(form.paxCount) }} {{ form_row(form.paxCount) }}
{{ form_row(form.minorsCount) }} {{ form_row(form.minorsCount) }}
{{ form_row(form.childrenCount) }} {{ form_row(form.childrenCount) }}
</div>
{# Saved by their own modals, which reprice the booking on the spot — see SplitPeriodController. #} {# Saved by their own modals, which reprice the booking on the spot — see SplitPeriodController. #}
<div class="lg:col-span-2"> <div class="mt-6 border-t border-gray-200 pt-4">
<h3 class="font-bold pb-1">Zeiträume</h3> <div class="font-bold pb-1">Zeiträume</div>
<p class="text-xs text-gray-500 pb-2"> <p class="text-xs text-gray-500 pb-2">
Anreise und Abreise umfassen den ganzen Aufenthalt. Abgeteilte Zeiträume, etwa für ein Anreise und Abreise umfassen den ganzen Aufenthalt. Abgeteilte Zeiträume, etwa für ein
Vorausteam, werden mit eigenen Positionen berechnet; Personen und Leistungen oben gelten Vorausteam, werden mit eigenen Positionen berechnet; Personen und Leistungen gelten
nur für den Zeitraum der Gruppe. nur für den Zeitraum der Gruppe.
</p> </p>
<table class="w-full text-sm"> <table class="w-full text-sm">
{% if booking.leadingPeriod %} {% if booking.leadingPeriod %}
{% set p = booking.leadingPeriod %} {% include 'admin/accommodation_booking/_period_row.html.twig' with { period: booking.leadingPeriod } %}
{{ block('period_row') }}
{% endif %} {% endif %}
<tr class="border-t border-gray-200"> <tr class="border-t border-gray-200">
<td class="py-1 whitespace-nowrap">{{ booking.mainDateFrom | date('d.m.Y') }} – {{ booking.mainDateTo | date('d.m.Y') }}</td> <td class="py-1 whitespace-nowrap">{{ booking.mainDateFrom | date('d.m.Y') }} – {{ booking.mainDateTo | date('d.m.Y') }}</td>
@@ -77,100 +73,149 @@
</td> </td>
</tr> </tr>
{% if booking.trailingPeriod %} {% if booking.trailingPeriod %}
{% set p = booking.trailingPeriod %} {% include 'admin/accommodation_booking/_period_row.html.twig' with { period: booking.trailingPeriod } %}
{{ block('period_row') }}
{% endif %} {% endif %}
</table> </table>
</div> </div>
</twig:form:section>
{% if form.boardService is defined or form.selectedAdditionalServices is defined %} {% if form.boardService is defined or form.selectedAdditionalServices is defined %}
<h2 class="lg:col-span-2 text-base font-bold pt-2">Leistungen</h2> <twig:form:section title="Leistungen">
<div class="space-y-4">
{% if form.boardService is defined %} {% if form.boardService is defined %}
{{ form_row(form.boardService) }} {{ form_row(form.boardService) }}
{% endif %} {% endif %}
{% if form.selectedAdditionalServices is defined %} {% if form.selectedAdditionalServices is defined %}
{{ form_row(form.selectedAdditionalServices) }} <div>
{% endif %} {{ form_label(form.selectedAdditionalServices) }}
{% endif %} {# Rows written out here rather than through the theme's choice_widget_expanded,
whose first:pt-0 would shift only the first cell of the two columns. #}
<h2 class="lg:col-span-2 text-base font-bold pt-2">Status & Rabatt</h2> <div class="grid sm:grid-cols-2 gap-x-8">
{# Read-only: the status only ever moves through a named action on the detail page, {% for child in form.selectedAdditionalServices %}
so that it cannot be set without the email and timestamp that belong to it. #} <div class="relative flex items-start py-1">
<p class="lg:col-span-2 text-sm"> <div class="min-w-0 flex-1 text-sm leading-4">
<span class="font-medium">Status:</span> <label for="{{ child.vars.id }}" class="select-none font-medium text-gray-900">
{% include 'admin/accommodation_booking/_status_label.html.twig' %} {{ child.vars.label }}
<span class="text-gray-500">· Herkunft: {{ booking.origin.label }}</span> </label>
</p> </div>
{% if booking.acceptedAt is not null %} <div class="ml-3 flex h-4 items-center">
<p class="lg:col-span-2 text-xs text-gray-500"> {{ form_widget(child) }}
Angenommen am {{ booking.acceptedAt | date('d.m.Y, H:i') }} </div>
</p> </div>
{% endif %} {% endfor %}
{% if booking.confirmedAt is not null %} </div>
<p class="lg:col-span-2 text-xs text-gray-500"> {{ form_errors(form.selectedAdditionalServices) }}
Bestätigt am {{ booking.confirmedAt | date('d.m.Y, H:i') }}
</p>
{% endif %}
{% if form.managedBy is defined %}
<div class="lg:col-span-2">
{{ form_row(form.managedBy) }}
</div> </div>
{% endif %} {% endif %}
<div class="lg:col-span-2 grid lg:grid-cols-3 gap-y-4 lg:gap-x-8"> </div>
</twig:form:section>
{% endif %}
<twig:form:section title="Rabatte">
<div class="grid sm:grid-cols-3 gap-4">
{{ form_row(form.accommodationDiscount) }} {{ form_row(form.accommodationDiscount) }}
{{ form_row(form.boardServiceDiscount) }} {{ form_row(form.boardServiceDiscount) }}
{{ form_row(form.additionalServicesDiscount) }} {{ form_row(form.additionalServicesDiscount) }}
</div> </div>
<div class="lg:col-span-2 grid lg:grid-cols-2 gap-y-4 lg:gap-x-8"> <div class="grid sm:grid-cols-3 gap-4 pt-4">
{{ form_row(form.totalDiscountLabel) }} {{ form_row(form.totalDiscountLabel, { row_attr: { class: 'sm:col-span-2' } }) }}
{{ form_row(form.totalDiscountAmount) }} {{ form_row(form.totalDiscountAmount) }}
</div> </div>
<div class="lg:col-span-2"> </twig:form:section>
{{ form_row(form.remarks) }}
<twig:form:section title="Kontakt">
<div class="grid sm:grid-cols-2 gap-4">
{{ form_row(form.groupName, { row_attr: { class: 'sm:col-span-2' } }) }}
{{ form_row(form.salutation) }}
<div class="hidden sm:block"></div>
{{ form_row(form.firstName) }}
{{ form_row(form.lastName) }}
{{ form_row(form.email) }}
{{ form_row(form.phone) }}
{{ form_row(form.street, { row_attr: { class: 'sm:col-span-2' } }) }}
{{ form_row(form.zip) }}
{{ form_row(form.city) }}
</div> </div>
</twig:form:section>
<twig:form:section title="Bemerkungen">
{{ form_widget(form.remarks) }}
{{ form_errors(form.remarks) }}
</twig:form:section>
</div> </div>
<div class="flex justify-between pt-8">
<a href="{{ path('app_admin_accommodationbooking_show', back_params) }}" class="button button--secondary button--small"> <aside class="space-y-6 xl:sticky xl:top-8">
zurück <twig:form:section title="Status">
</a> {# Read-only: the status only ever moves through a named action on the detail page,
<button type="submit" class="button button--primary button--small"> so that it cannot be set without the email and timestamp that belong to it. #}
<dl class="grid grid-cols-2 gap-y-1 text-sm">
<dt class="text-gray-500">Status</dt>
<dd>{% include 'admin/accommodation_booking/_status_label.html.twig' %}</dd>
<dt class="text-gray-500">Herkunft</dt>
<dd>{{ booking.origin.label }}</dd>
{% if booking.acceptedAt is not null %}
<dt class="text-gray-500">Angenommen</dt>
<dd>{{ booking.acceptedAt | date('d.m.Y, H:i') }}</dd>
{% endif %}
{% if booking.confirmedAt is not null %}
<dt class="text-gray-500">Bestätigt</dt>
<dd>{{ booking.confirmedAt | date('d.m.Y, H:i') }}</dd>
{% endif %}
</dl>
{% if form.managedBy is defined %}
<div class="pt-4">
{{ form_row(form.managedBy) }}
</div>
{% endif %}
</twig:form:section>
{% if priceBreakdown is not null %}
{% set currency = booking.pricingCurrency ?? priceBreakdown.currency %}
<twig:form:section title="Preis">
<table class="w-full text-sm">
{% if priceBreakdown.periods is not empty %}
<tr>
<td class="py-1">Gruppe</td>
<td class="py-1 text-right whitespace-nowrap">{{ ((priceBreakdown.total - priceBreakdown.periodsTotal) / 100) | format_currency(currency) }}</td>
</tr>
<tr>
<td class="py-1">Zeiträume</td>
<td class="py-1 text-right whitespace-nowrap">{{ (priceBreakdown.periodsTotal / 100) | format_currency(currency) }}</td>
</tr>
{% endif %}
{% if priceBreakdown.discountedTotal != priceBreakdown.total %}
{% if priceBreakdown.periods is empty %}
<tr>
<td class="py-1">Preis</td>
<td class="py-1 text-right whitespace-nowrap">{{ (priceBreakdown.total / 100) | format_currency(currency) }}</td>
</tr>
{% endif %}
<tr class="text-green-700">
<td class="py-1">Rabatte</td>
<td class="py-1 text-right whitespace-nowrap">– {{ ((priceBreakdown.total - priceBreakdown.discountedTotal) / 100) | format_currency(currency) }}</td>
</tr>
{% endif %}
<tr class="border-t border-gray-200 font-bold">
<td class="pt-2">Gesamtpreis</td>
<td class="pt-2 text-right whitespace-nowrap">{{ (priceBreakdown.discountedTotal / 100) | format_currency(currency) }}</td>
</tr>
</table>
<p class="text-xs text-gray-500 pt-2">
Stand der letzten Speicherung. Änderungen oben werden erst beim Speichern neu berechnet.
</p>
</twig:form:section>
{% endif %}
<div class="flex flex-col gap-3">
<button type="submit" class="button button--primary button--small w-full">
speichern speichern
</button> </button>
<a href="{{ path('app_admin_accommodationbooking_show', back_params) }}" class="text-sm text-gray-500 hover:text-gray-900 hover:underline">
← zurück ohne speichern
</a>
</div>
</aside>
</div> </div>
{{ form_rest(form) }} {{ form_rest(form) }}
{{ form_end(form) }} {{ form_end(form) }}
{% endblock %} {% endblock %}
{% block period_row %}
{% set period_params = { id: p.id } %}
{% if app.request.query.get('r') %}
{% set period_params = period_params | merge({ r: app.request.query.get('r') }) %}
{% endif %}
<tr class="border-t border-gray-200 align-top">
<td class="py-1 whitespace-nowrap">{{ p.dateFrom | date('d.m.Y') }} – {{ p.dateTo | date('d.m.Y') }}</td>
<td class="py-1 whitespace-nowrap">{{ p.nights }} {{ p.nights != 1 ? 'Nächte' : 'Nacht' }}</td>
<td class="py-1">
{% if p.label %}
<div class="font-medium">{{ p.label }}</div>
{% endif %}
{% for line in p.lines %}
<div>{{ line.label }}</div>
{% else %}
<div class="text-gray-500">keine Positionen</div>
{% endfor %}
</td>
<td class="py-1 text-right whitespace-nowrap">
{{ (p.total / 100) | format_currency(booking.pricingCurrency ?? booking.accommodation.currency) }}
</td>
<td class="py-1 text-right">
<twig:dropdown>
<twig:dropdown:hxbutton url="{{ path('app_admin_accommodationbooking_period_edit', period_params) }}">
bearbeiten
</twig:dropdown:hxbutton>
<twig:dropdown:hxbutton url="{{ path('app_admin_accommodationbooking_period_remove', period_params) }}" warning>
entfernen
</twig:dropdown:hxbutton>
</twig:dropdown>
</td>
</tr>
{% endblock %}
@@ -1,12 +1,21 @@
{% extends 'htmx_modal_admin.html.twig' %} {% extends 'htmx_modal_admin.html.twig' %}
{% form_theme form 'forms_admin.html.twig' %} {% form_theme form 'forms_admin.html.twig' %}
{# One line as a row of bare widgets; the column headings above name them once for all rows.
Plain flex rather than an arbitrary grid template: the modal is loaded into a page whose
stylesheet may predate any class used only here. #}
{% macro line_row(line) %} {% macro line_row(line) %}
<div class="flex items-start gap-2" data-form-collection-target="field"> <div class="flex gap-2 items-start" data-form-collection-target="field">
<div class="flex-1">{{ form_row(line.label) }}</div> <div class="flex-1 min-w-0">
<div class="w-40">{{ form_row(line.amount) }}</div> {{ form_widget(line.label, { attr: { placeholder: 'z. B. Übernachtung' } }) }}
{{ form_errors(line.label) }}
</div>
<div class="w-32 shrink-0">
{{ form_widget(line.amount) }}
{{ form_errors(line.amount) }}
</div>
<button type="button" <button type="button"
class="mt-9 text-gray-500 hover:text-red-500" class="shrink-0 mt-2 text-gray-400 hover:text-red-500"
data-action="form-collection#removeItem" data-action="form-collection#removeItem"
title="Position entfernen"> title="Position entfernen">
{{ icon('close', 'w-5 h-5') }} {{ icon('close', 'w-5 h-5') }}
@@ -16,24 +25,29 @@
{% block content %} {% block content %}
{% import _self as period %} {% import _self as period %}
<div class="text-xl font-bold pb-4"> <div class="text-xl font-bold pb-1">
{{ title }} {{ title }}
</div> </div>
<p class="text-sm text-gray-500 pb-4"> <p class="text-sm text-gray-500 pb-6">
Die Nächte werden vom Zeitraum der Gruppe abgezogen, der neu berechnet wird. Die Positionen Die Nächte werden vom Zeitraum der Gruppe abgezogen, der neu berechnet wird. Die Positionen
kommen zum Gesamtpreis hinzu und fallen nur unter den Rabatt auf den Gesamtpreis. kommen zum Gesamtpreis hinzu und fallen nur unter den Rabatt auf den Gesamtpreis.
</p> </p>
{{ form_start(form) }} {{ form_start(form) }}
{{ form_errors(form) }} {{ form_errors(form) }}
<div class="pb-4"> <div class="flex gap-4 items-start">
{{ form_row(form.label) }} {{ form_row(form.label, { row_attr: { class: 'flex-1 min-w-0' } }) }}
</div> {{ form_row(form.nights, { row_attr: { class: 'w-32 shrink-0' } }) }}
<div class="w-40 pb-4">
{{ form_row(form.nights) }}
</div> </div>
{% set prototype %}{{ period.line_row(form.lines.vars.prototype) }}{% endset %} {% set prototype %}{{ period.line_row(form.lines.vars.prototype) }}{% endset %}
<div {{ stimulus_controller('form-collection', { prototype: prototype|json_encode }) }}> <div class="mt-6 border border-gray-200 rounded-md" {{ stimulus_controller('form-collection', { prototype: prototype|json_encode }) }}>
<div class="font-bold pb-2">Positionen</div> <div class="flex gap-2 px-4 py-2 bg-gray-100 border-b border-gray-200 rounded-t-md text-sm font-bold">
<div class="flex-1">Position</div>
{# w-5 matches the remove button's icon, so the heading sits over the amounts. #}
<div class="w-32 shrink-0">Betrag</div>
<div class="w-5 shrink-0"></div>
</div>
<div class="p-4">
{{ form_errors(form.lines) }} {{ form_errors(form.lines) }}
<div class="space-y-2" data-form-collection-target="fields"> <div class="space-y-2" data-form-collection-target="fields">
{% for line in form.lines %} {% for line in form.lines %}
@@ -41,13 +55,15 @@
{% endfor %} {% endfor %}
</div> </div>
<button type="button" <button type="button"
class="button button--secondary button--small mt-2" class="mt-3 text-sm font-medium text-primary hover:underline"
data-action="form-collection#addItem"> data-action="form-collection#addItem">
Position hinzufügen + Position hinzufügen
</button> </button>
</div> </div>
</div>
{% do form.lines.setRendered %} {% do form.lines.setRendered %}
<div class="flex justify-end pt-8">
<div class="flex justify-end pt-6">
<button type="submit" class="button button--primary button--small"> <button type="submit" class="button button--primary button--small">
speichern speichern
</button> </button>
@@ -1,39 +1,22 @@
{% extends 'layout_admin.html.twig' %} {% extends 'layout_admin.html.twig' %}
{% block content %} {% block content %}
{% set edit_params = { 'id': booking.id } %}
{% if app.request.query.get('r') %}
{% set edit_params = edit_params | merge({ 'r': app.request.query.get('r') }) %}
{% endif %}
<twig:page:heading> <twig:page:heading>
{{ booking.recordLabel }} · {% include 'admin/accommodation_booking/_status_label.html.twig' %} {{ booking.recordLabel }} · {% include 'admin/accommodation_booking/_status_label.html.twig' %}
{{ booking.groupName }} {{ booking.groupName }}
</twig:page:heading> </twig:page:heading>
<p class="text-sm text-gray-500 mb-6">{{ booking.accommodation.name }}</p>
<div class="grid lg:grid-cols-2 gap-8"> {# Same arrangement as the edit form: what was booked in the main column, status, the next
<div> step and the actions in a sidebar that stays in view on wide screens. #}
<h2 class="text-lg font-bold mb-4">Kontakt</h2> <div class="xl:grid xl:grid-cols-3 xl:gap-6 xl:items-start space-y-6 xl:space-y-0">
<dl class="grid grid-cols-2 gap-y-2 text-sm"> <div class="xl:col-span-2 space-y-6">
<dt class="font-medium">Gruppenname</dt> <twig:form:section title="Aufenthalt">
<dd>{{ booking.groupName }}</dd>
<dt class="font-medium">Anrede</dt>
<dd>{{ booking.salutation | default('–') }}</dd>
<dt class="font-medium">Name</dt>
<dd>{{ booking.firstName }} {{ booking.lastName }}</dd>
<dt class="font-medium">E-Mail</dt>
<dd>{{ booking.email }}</dd>
<dt class="font-medium">Telefon</dt>
<dd>{{ booking.phone | default('–') }}</dd>
<dt class="font-medium">Adresse</dt>
<dd>
{% if booking.street %}
{{ booking.street }}<br>
{{ booking.zip }} {{ booking.city }}
{% else %}
–
{% endif %}
</dd>
</dl>
</div>
<div>
<h2 class="text-lg font-bold mb-4">Reisedaten</h2>
<dl class="grid grid-cols-2 gap-y-2 text-sm"> <dl class="grid grid-cols-2 gap-y-2 text-sm">
<dt class="font-medium">Gruppenhaus</dt> <dt class="font-medium">Gruppenhaus</dt>
<dd>{{ booking.accommodation.name }}</dd> <dd>{{ booking.accommodation.name }}</dd>
@@ -60,24 +43,11 @@
<dt class="font-medium">davon Kinder (4–{{ booking.accommodation.maxAdolescentAge }} Jahre)</dt> <dt class="font-medium">davon Kinder (4–{{ booking.accommodation.maxAdolescentAge }} Jahre)</dt>
<dd>{{ booking.childrenCount }}</dd> <dd>{{ booking.childrenCount }}</dd>
{% endif %} {% endif %}
<dt class="font-medium">Herkunft</dt>
<dd>{{ booking.origin.label }}</dd>
<dt class="font-medium">Status</dt>
<dd>{% include 'admin/accommodation_booking/_status_label.html.twig' %}</dd>
{% if booking.acceptedAt is not null %}
<dt class="font-medium">Angenommen am</dt>
<dd>{{ booking.acceptedAt | date('d.m.Y, H:i') }}</dd>
{% endif %}
{% if booking.confirmedAt is not null %}
<dt class="font-medium">Bestätigt am</dt>
<dd>{{ booking.confirmedAt | date('d.m.Y, H:i') }}</dd>
{% endif %}
</dl> </dl>
</div> </twig:form:section>
{% if booking.boardServiceLabel or booking.additionalServices | length > 0 %} {% if booking.boardServiceLabel or booking.additionalServices | length > 0 %}
<div> <twig:form:section title="Leistungen">
<h2 class="text-lg font-bold mb-4">Gebuchte Leistungen</h2>
<dl class="grid grid-cols-2 gap-y-2 text-sm"> <dl class="grid grid-cols-2 gap-y-2 text-sm">
{% if booking.boardServiceLabel %} {% if booking.boardServiceLabel %}
<dt class="font-medium">Verpflegung</dt> <dt class="font-medium">Verpflegung</dt>
@@ -88,16 +58,15 @@
<dd>{{ service.label }}</dd> <dd>{{ service.label }}</dd>
{% endfor %} {% endfor %}
</dl> </dl>
</div> </twig:form:section>
{% endif %} {% endif %}
{% if priceBreakdown is not null %} {% if priceBreakdown is not null %}
<div>
<h2 class="text-lg font-bold mb-4">Preise</h2>
{% set currency = booking.pricingCurrency ?? priceBreakdown.currency %} {% set currency = booking.pricingCurrency ?? priceBreakdown.currency %}
<twig:form:section title="Preise">
<table class="w-full text-sm"> <table class="w-full text-sm">
{% for period in priceBreakdown.periods | filter(p => p.position == 'leading') %} {% for period in priceBreakdown.periods | filter(p => p.position == 'leading') %}
{{ block('period_rows') }} {% include 'admin/accommodation_booking/_price_period.html.twig' %}
{% endfor %} {% endfor %}
{% if priceBreakdown.periods is not empty %} {% if priceBreakdown.periods is not empty %}
<tr class="border-t border-gray-200 font-medium"> <tr class="border-t border-gray-200 font-medium">
@@ -158,7 +127,7 @@
</tr> </tr>
{% endif %} {% endif %}
{% for period in priceBreakdown.periods | filter(p => p.position == 'trailing') %} {% for period in priceBreakdown.periods | filter(p => p.position == 'trailing') %}
{{ block('period_rows') }} {% include 'admin/accommodation_booking/_price_period.html.twig' %}
{% endfor %} {% endfor %}
<tr class="border-t border-gray-200 font-semibold"> <tr class="border-t border-gray-200 font-semibold">
<td class="pt-2"> <td class="pt-2">
@@ -192,76 +161,118 @@
</tr> </tr>
{% endif %} {% endif %}
</table> </table>
</div> </twig:form:section>
{% endif %} {% endif %}
<twig:form:section title="Kontakt">
<dl class="grid grid-cols-2 gap-y-2 text-sm">
<dt class="font-medium">Gruppenname</dt>
<dd>{{ booking.groupName }}</dd>
<dt class="font-medium">Anrede</dt>
<dd>{{ booking.salutation | default('–') }}</dd>
<dt class="font-medium">Name</dt>
<dd>{{ booking.firstName }} {{ booking.lastName }}</dd>
<dt class="font-medium">E-Mail</dt>
<dd>{{ booking.email }}</dd>
<dt class="font-medium">Telefon</dt>
<dd>{{ booking.phone | default('–') }}</dd>
<dt class="font-medium">Adresse</dt>
<dd>
{% if booking.street %}
{{ booking.street }}<br>
{{ booking.zip }} {{ booking.city }}
{% else %}
–
{% endif %}
</dd>
</dl>
</twig:form:section>
{% if booking.remarks %} {% if booking.remarks %}
<div class="lg:col-span-2"> <twig:form:section title="Bemerkungen">
<h2 class="text-lg font-bold mb-4">Bemerkungen</h2>
<p class="text-sm">{{ booking.remarks | nl2br }}</p> <p class="text-sm">{{ booking.remarks | nl2br }}</p>
</div> </twig:form:section>
{% endif %} {% endif %}
</div> </div>
<div class="text-xs text-gray-400 mt-6"> <aside class="space-y-6 xl:sticky xl:top-8">
Eingegangen: {{ booking.createdAt | date('d.m.Y, H:i') }} <twig:form:section title="Status">
<dl class="grid grid-cols-2 gap-y-1 text-sm">
<dt class="text-gray-500">Status</dt>
<dd>{% include 'admin/accommodation_booking/_status_label.html.twig' %}</dd>
<dt class="text-gray-500">Herkunft</dt>
<dd>{{ booking.origin.label }}</dd>
{% if booking.managedBy is not null %}
<dt class="text-gray-500">Bearbeiter:in</dt>
<dd>{{ booking.managedBy.displayName }}</dd>
{% endif %}
{% if booking.acceptedAt is not null %}
<dt class="text-gray-500">Angenommen</dt>
<dd>{{ booking.acceptedAt | date('d.m.Y, H:i') }}</dd>
{% endif %}
{% if booking.confirmedAt is not null %}
<dt class="text-gray-500">Bestätigt</dt>
<dd>{{ booking.confirmedAt | date('d.m.Y, H:i') }}</dd>
{% endif %}
<dt class="text-gray-500">Eingegangen</dt>
<dd>{{ booking.createdAt | date('d.m.Y, H:i') }}</dd>
{% if booking.updatedAt is not null and booking.updatedAt != booking.createdAt %} {% if booking.updatedAt is not null and booking.updatedAt != booking.createdAt %}
· Aktualisiert: {{ booking.updatedAt | date('d.m.Y, H:i') }} <dt class="text-gray-500">Aktualisiert</dt>
<dd>{{ booking.updatedAt | date('d.m.Y, H:i') }}</dd>
{% endif %} {% endif %}
</div> </dl>
</twig:form:section>
{# One pink button per page, for the next step; everything else is grey, and the one
destructive action is set apart below the others. #}
{% set has_next_step = booking.draft or booking.requested or booking.received %}
{% if booking.draft or booking.requested %} {% if booking.draft or booking.requested %}
<div class="mt-6 border-t border-gray-200 pt-6"> <twig:form:section title="Nächster Schritt: Angebot">
<h2 class="text-lg font-bold mb-2">Angebot</h2> <p class="text-sm text-gray-500 mb-3">
<p class="text-sm text-gray-500 mb-2">
Das Angebot wurde dem Kunden noch nicht zugestellt. Beim Versand wird der Zugangslink Das Angebot wurde dem Kunden noch nicht zugestellt. Beim Versand wird der Zugangslink
erzeugt und die Buchung wartet anschließend auf die Annahme durch den Kunden. erzeugt und die Buchung wartet anschließend auf die Annahme durch den Kunden.
</p> </p>
<div class="flex items-center gap-2"> <div class="flex flex-col gap-2">
<button type="button" <button type="button"
class="button button--primary button--small" class="button button--primary button--small w-full"
hx-get="{{ path('app_admin_accommodationbooking_send_offer', { id: booking.id }) }}" hx-get="{{ path('app_admin_accommodationbooking_send_offer', { id: booking.id }) }}"
hx-target="body" hx-target="body"
hx-swap="beforeend"> hx-swap="beforeend">
Angebot per E-Mail senden Angebot per E-Mail senden
</button> </button>
<button type="button" <button type="button"
class="button button--secondary button--small" class="button button--neutral button--small w-full"
hx-get="{{ path('app_admin_accommodationbooking_generate_access_link', { id: booking.id }) }}" hx-get="{{ path('app_admin_accommodationbooking_generate_access_link', { id: booking.id }) }}"
hx-target="body" hx-target="body"
hx-swap="beforeend"> hx-swap="beforeend">
Link erzeugen nur Link erzeugen
</button> </button>
</div> </div>
</div> </twig:form:section>
{% endif %} {% elseif booking.received %}
<twig:form:section title="Nächster Schritt: Bestätigung">
{% if booking.received %} <p class="text-sm text-gray-500 mb-3">
<div class="mt-6 border-t border-gray-200 pt-6">
<h2 class="text-lg font-bold mb-2">Bestätigung</h2>
<p class="text-sm text-gray-500 mb-2">
Die Buchung des Kunden ist eingegangen, aber es wurde noch keine Bestätigung verschickt. Die Buchung des Kunden ist eingegangen, aber es wurde noch keine Bestätigung verschickt.
</p> </p>
<button type="button" <button type="button"
class="button button--primary button--small" class="button button--primary button--small w-full"
hx-get="{{ path('app_admin_accommodationbooking_confirm', { id: booking.id }) }}" hx-get="{{ path('app_admin_accommodationbooking_confirm', { id: booking.id }) }}"
hx-target="body" hx-target="body"
hx-swap="beforeend"> hx-swap="beforeend">
Buchung per E-Mail bestätigen Buchung per E-Mail bestätigen
</button> </button>
</div> </twig:form:section>
{% endif %} {% endif %}
<div class="mt-6 border-t border-gray-200 pt-6"> <twig:form:section title="Zugangslink">
<h2 class="text-lg font-bold mb-2">Zugangslink</h2>
{% if not booking.customerAccessible %} {% if not booking.customerAccessible %}
<p class="text-sm text-gray-500"> <p class="text-sm text-gray-500">
Ein Zugangslink wird beim Versand des Angebots erzeugt. Ein Zugangslink wird beim Versand des Angebots erzeugt.
</p> </p>
{% elseif accessLink %} {% elseif accessLink %}
<div class="flex items-center gap-2"> <div class="grid grid-cols-2 gap-2">
<button type="button" <button type="button"
class="button button--secondary button--small" class="button button--neutral button--small sm:text-xs w-full"
data-controller="clipboard" data-controller="clipboard"
data-clipboard-content-value="{{ accessLink }}" data-clipboard-content-value="{{ accessLink }}"
data-clipboard-label-value="Kopiert!" data-clipboard-label-value="Kopiert!"
@@ -269,14 +280,14 @@
{{ icon('copy', 'w-4 h-4') }} Link kopieren {{ icon('copy', 'w-4 h-4') }} Link kopieren
</button> </button>
<button type="button" <button type="button"
class="button button--secondary button--small" class="button button--neutral button--small sm:text-xs w-full"
hx-get="{{ path('app_admin_accommodationbooking_send_access_link', { id: booking.id }) }}" hx-get="{{ path('app_admin_accommodationbooking_send_access_link', { id: booking.id }) }}"
hx-target="body" hx-target="body"
hx-swap="beforeend"> hx-swap="beforeend">
Link senden Link senden
</button> </button>
</div> </div>
<p class="text-xs text-gray-500 mt-1"> <p class="text-xs text-gray-500 mt-2">
Gültig bis {{ accessLinkExpiresAt | date('d.m.Y') }} Gültig bis {{ accessLinkExpiresAt | date('d.m.Y') }}
{% if accessLinkExpiresAt < date() %} {% if accessLinkExpiresAt < date() %}
<span class="text-red-600 font-medium">(abgelaufen)</span> <span class="text-red-600 font-medium">(abgelaufen)</span>
@@ -287,58 +298,44 @@
Der Zugangslink wird beim Versand des Angebots erzeugt. Der Zugangslink wird beim Versand des Angebots erzeugt.
</p> </p>
{% endif %} {% endif %}
</div> </twig:form:section>
<div class="flex justify-between pt-8"> <twig:form:section title="Aktionen">
<a href="{{ returnUrl }}" class="button button--secondary button--small"> <div class="flex flex-col gap-2">
zurück <a href="{{ path('app_admin_accommodationbooking_edit', edit_params) }}"
class="button {{ has_next_step ? 'button--neutral' : 'button--primary' }} button--small w-full">
bearbeiten
</a> </a>
<div class="flex items-center gap-2">
{% if not booking.confirmed and not booking.discarded %}
<button type="button" <button type="button"
class="button button--warning button--small" class="button button--neutral button--small w-full"
hx-get="{{ path('app_admin_accommodationbooking_discard', { id: booking.id }) }}"
hx-target="body"
hx-swap="beforeend">
Absagen
</button>
{% endif %}
{% if booking.confirmed %}
<a href="{{ path('app_admin_accommodationbooking_pdf', { 'id': booking.id }) }}" class="button button--secondary button--small">
PDF herunterladen
</a>
{% endif %}
{% set edit_params = { 'id': booking.id } %}
{% if app.request.query.get('r') %}
{% set edit_params = edit_params | merge({ 'r': app.request.query.get('r') }) %}
{% endif %}
<button type="button"
class="button button--secondary button--small"
hx-get="{{ path('app_admin_accommodationbooking_duplicate', edit_params) }}" hx-get="{{ path('app_admin_accommodationbooking_duplicate', edit_params) }}"
hx-target="body" hx-target="body"
hx-swap="beforeend"> hx-swap="beforeend">
duplizieren duplizieren
</button> </button>
<a href="{{ path('app_admin_accommodationbooking_edit', edit_params) }}" class="button button--primary button--small"> {% if booking.confirmed %}
bearbeiten <a href="{{ path('app_admin_accommodationbooking_pdf', { 'id': booking.id }) }}"
class="button button--neutral button--small w-full">
PDF herunterladen
</a> </a>
{% endif %}
</div> </div>
{% if not booking.confirmed and not booking.discarded %}
<div class="mt-4 pt-3 border-t border-gray-200 text-center">
<button type="button"
class="text-sm font-medium text-red-600 hover:underline"
hx-get="{{ path('app_admin_accommodationbooking_discard', { id: booking.id }) }}"
hx-target="body"
hx-swap="beforeend">
{{ booking.recordLabel }} absagen
</button>
</div> </div>
{% endblock %} {% endif %}
</twig:form:section>
{# One split-off period of the breakdown: its range as a heading, then its lines. #} <a href="{{ returnUrl }}" class="inline-block text-sm text-gray-500 hover:text-gray-900 hover:underline">
{% block period_rows %} ← zurück
<tr class="border-t border-gray-200 font-medium"> </a>
<td class="pt-2 pb-1" colspan="2"> </aside>
{% if period.label ?? null %}{{ period.label }} · {% endif %} </div>
{{ period.dateFrom | date('d.m.Y') }} – {{ period.dateTo | date('d.m.Y') }},
{{ period.nights }} {{ period.nights != 1 ? 'Nächte' : 'Nacht' }}
</td>
</tr>
{% for line in period.lines %}
<tr>
<td class="py-1">{{ line.label }}</td>
<td class="py-1 text-right whitespace-nowrap">{{ (line.amount / 100) | format_currency(currency) }}</td>
</tr>
{% endfor %}
{% endblock %} {% endblock %}
@@ -0,0 +1,11 @@
{#- A titled panel grouping the fields of a long admin form. No overflow-hidden: the dots
dropdowns inside must be able to open past its edge. -#}
<div {{ attributes.defaults({class: 'bg-white border border-gray-200 rounded-md'}).without('title') }}>
<div class="flex items-center justify-between gap-4 px-4 py-2 bg-gray-100 border-b border-gray-200 rounded-t-md font-bold">
{{ title }}
{% block actions %}{% endblock %}
</div>
<div class="p-4">
{% block content %}{% endblock %}
</div>
</div>
@@ -12,6 +12,7 @@ use App\Exception\ImplausibleBookingPriceException;
use App\Repository\Groups\AdditionalServiceRepository; use App\Repository\Groups\AdditionalServiceRepository;
use App\Repository\Groups\BoardServiceRepository; use App\Repository\Groups\BoardServiceRepository;
use App\Repository\UserRepository; use App\Repository\UserRepository;
use App\Service\AccommodationBookingBreakdownCalculator;
use App\Service\AccommodationBookingService; use App\Service\AccommodationBookingService;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
@@ -72,6 +73,7 @@ class EditControllerTest extends TestCase
$this->createStub(AdditionalServiceRepository::class), $this->createStub(AdditionalServiceRepository::class),
$this->createStub(UserRepository::class), $this->createStub(UserRepository::class),
$bookingService, $bookingService,
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$form, $form,
); );
@@ -108,6 +110,7 @@ class EditControllerTest extends TestCase
$this->createStub(AdditionalServiceRepository::class), $this->createStub(AdditionalServiceRepository::class),
$this->createStub(UserRepository::class), $this->createStub(UserRepository::class),
$bookingService, $bookingService,
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$form, $form,
); );
@@ -171,6 +174,7 @@ class EditControllerTest extends TestCase
$this->createStub(AdditionalServiceRepository::class), $this->createStub(AdditionalServiceRepository::class),
$userRepo, $userRepo,
$this->createStub(AccommodationBookingService::class), $this->createStub(AccommodationBookingService::class),
$this->createStub(AccommodationBookingBreakdownCalculator::class),
$form, $form,
$granted, $granted,
); );
@@ -189,10 +193,11 @@ final class TestableEditController extends EditController
AdditionalServiceRepository $additionalServiceRepo, AdditionalServiceRepository $additionalServiceRepo,
UserRepository $userRepo, UserRepository $userRepo,
AccommodationBookingService $bookingService, AccommodationBookingService $bookingService,
AccommodationBookingBreakdownCalculator $breakdownCalculator,
private readonly FormInterface $form, private readonly FormInterface $form,
private readonly bool $granted = false, private readonly bool $granted = false,
) { ) {
parent::__construct($entityManager, $logger, $boardServiceRepo, $additionalServiceRepo, $userRepo, $bookingService); parent::__construct($entityManager, $logger, $boardServiceRepo, $additionalServiceRepo, $userRepo, $bookingService, $breakdownCalculator);
} }
protected function createForm(string $type, mixed $data = null, array $options = []): FormInterface protected function createForm(string $type, mixed $data = null, array $options = []): FormInterface