feat: show room pricing details

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 0bd9d79bbe
commit 3c1192298b
5 changed files with 17 additions and 9 deletions
+2
View File
@@ -11,6 +11,8 @@ class RoomSelectionDto
public ?string $roomLabel = null;
public ?float $roomPrice = null;
public ?int $quantity = null;
public int $maxQuantity = 100;
+4 -5
View File
@@ -17,15 +17,15 @@ class RoomSelectType extends AbstractType
{
$builder
->add('roomId', HiddenType::class)
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) {
$data = $event->getData();
$form = $event->getForm();
// Build label with pricing
$label = 'Anzahl '.$data->roomLabel;
if (null !== $options['room_price']) {
$formattedPrice = number_format((float) $options['room_price'], 2, ',', '.');
$label .= sprintf(' (€%s pro Nacht)', $formattedPrice);
if (null !== $data->roomPrice) {
$formattedPrice = number_format((float) $data->roomPrice, 2, ',', '.');
$label .= sprintf(' (€%s pro Person)', $formattedPrice);
}
$form->add('quantity', ChoiceType::class, [
@@ -40,7 +40,6 @@ class RoomSelectType extends AbstractType
{
$resolver->setDefaults([
'data_class' => RoomSelectionDto::class,
'room_price' => null,
]);
}
}
+1
View File
@@ -159,6 +159,7 @@ class BookingService
$selection = new RoomSelectionDto();
$selection->roomId = $room->id;
$selection->roomLabel = $room->label;
$selection->roomPrice = $room->price;
$selection->maxQuantity = $room->available;
$selection->capacity = $room->minPax;
$selection->quantity = $roomsIdsAndQuantities[$room->id] ?? 0;
+9 -4
View File
@@ -18,16 +18,21 @@
<h4 class="font-semibold text-lg mb-3 text-gray-800">Unterkunft</h4>
<div class="space-y-2">
{% for roomPricing in pricingData.rooms %}
<div class="flex justify-between items-center">
<div class="flex justify-between items-start">
<div class="text-sm text-gray-600">
<span class="font-medium">{{ roomPricing.quantity }}x {{ roomPricing.label }}</span>
{% if assignmentCounts is defined and assignmentCounts[roomPricing.roomId] is defined %}
<span class="block text-xs text-gray-500">{{ assignmentCounts[roomPricing.roomId] }} belegt</span>
{% endif %}
</div>
<span class="text-gray-900">
{{ roomPricing.totalPrice|number_format(2, ',', '.') }}
</span>
<div class="text-right">
<div class="text-gray-900">
{{ roomPricing.totalPrice|number_format(2, ',', '.') }}
</div>
<div class="text-xs text-gray-500">
{{ roomPricing.unitPrice|number_format(2, ',', '.') }} pro Person
</div>
</div>
</div>
{% endfor %}
</div>
@@ -50,6 +50,7 @@
{% include 'booking/_summary.html.twig' with {
'bookingCreateDto': bookingCreateDto,
'participantCount': participantCount,
'pricingData': pricingData,
'groupedSelectedRooms': groupedSelectedRooms,
'assignmentCounts': []
} %}