wip: check eligibility based on ski pass availability

This commit is contained in:
Björn Fromme
2025-10-01 18:52:50 +02:00
parent fef4997132
commit 8a495346d6
9 changed files with 471 additions and 184 deletions
@@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
namespace App\Form\Service\Condition;
use App\Form\Model\BookingDtoInterface;
use App\Form\Service\Contract\FieldConditionInterface;
use App\Service\ParticipantEligibilityService;
/**
* Condition that evaluates whether a participant is eligible for booking.
*
* A participant is considered ineligible when no skipass is available for their age.
* When this condition is met (participant is ineligible), all service fields should
* be hidden and replaced with an ineligibility message.
*
* This prevents underaged participants from booking when the travel has no appropriate
* skipasses for their age group. Since skipasses are mandatory for booking, having no
* available skipasses means the participant cannot complete the booking process.
*
* The condition is satisfied when:
* 1. Participant has provided date of birth
* 2. No skipasses are available for the participant's age at travel date
*/
class BookingEligibilityCondition implements FieldConditionInterface
{
public function __construct(
private readonly ParticipantEligibilityService $participantEligibilityService
) {
}
/**
* Evaluates if a participant is ineligible for booking.
*
* Returns true when the participant is INELIGIBLE (should hide service fields).
* Returns false when the participant is eligible (show normal form fields).
*
* @param BookingDtoInterface $bookingDto The current booking data
* @param int $participantIndex The index of the participant being evaluated
* @param array<string, mixed> $formData Current form data for condition evaluation
*
* @return bool True if participant is ineligible (no skipasses available for their age)
*/
public function evaluate(BookingDtoInterface $bookingDto, int $participantIndex, array $formData): bool
{
// Invert the eligibility check since conditions typically evaluate to TRUE for "hide"
// isParticipantEligible() returns TRUE when eligible, we need TRUE when INELIGIBLE
return !$this->participantEligibilityService->isParticipantEligible($bookingDto, $participantIndex);
}
/**
* Returns field names that this condition depends on.
*
* This condition depends on the dateOfBirth field since eligibility
* is determined by age-based skipass availability.
*
* @return string[] Array containing field names this condition depends on
*/
public function getDependentFields(): array
{
return ['dateOfBirth'];
}
/**
* Returns a human-readable description of this condition.
*
* @return string Description of the booking eligibility condition
*/
public function getDescription(): string
{
return 'Participant has no available skipasses for their age';
}
}
+55 -8
View File
@@ -6,6 +6,7 @@ namespace App\Form\Service;
use App\BusProNet\Utility\DirectionMapper;
use App\Form\Service\Abstract\AbstractFieldStateProvider;
use App\Form\Service\Condition\BookingEligibilityCondition;
use App\Form\Service\Condition\BulkInsuranceBookingCondition;
use App\Form\Service\Condition\CompositeCondition;
use App\Form\Service\Condition\DateOfBirthProvidedCondition;
@@ -14,6 +15,7 @@ use App\Form\Service\Condition\RentalSelectionCondition;
use App\Form\Service\Condition\RoomSelectionCondition;
use App\Form\Service\Condition\ServiceSubTypeCondition;
use App\Form\Service\Condition\SkiPassSelectionCondition;
use App\Service\ParticipantEligibilityService;
/**
* Field state provider for the booking create workflow.
@@ -27,9 +29,15 @@ use App\Form\Service\Condition\SkiPassSelectionCondition;
* - Age-dependent service fields are hidden until birth date is provided
* - Transportation pickup fields are hidden by default, shown only when transportation type is BUS
* - Parking field is hidden by default, shown only when outbound transportation is PKW
* - All service fields are hidden for ineligible participants (no skipasses available for their age)
*/
class CreateFieldStateProvider extends AbstractFieldStateProvider
{
public function __construct(
private readonly ParticipantEligibilityService $participantEligibilityService
) {
parent::__construct();
}
/**
* Registers field state conditions for the create workflow.
*
@@ -56,6 +64,9 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
*/
protected function registerFieldStateConditions(): void
{
// Booking eligibility condition - hide all service fields when no skipasses available for participant's age
$bookingEligibilityCondition = new BookingEligibilityCondition($this->participantEligibilityService);
$rentalCondition = new RentalSelectionCondition();
$skiPassCondition = new SkiPassSelectionCondition();
@@ -67,25 +78,43 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
// Hide age-dependent fields when no date of birth is provided
$dateOfBirthProvidedCondition = new DateOfBirthProvidedCondition();
// Age-dependent service fields are hidden until birth date is provided
// Age-dependent service fields are hidden until birth date is provided OR when participant is ineligible
$this->fieldStateConditions['courses'] = [
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
'hidden' => CompositeCondition::or(
CompositeCondition::not($dateOfBirthProvidedCondition),
$bookingEligibilityCondition
),
];
$this->fieldStateConditions['additionalServices'] = [
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
'hidden' => CompositeCondition::or(
CompositeCondition::not($dateOfBirthProvidedCondition),
$bookingEligibilityCondition
),
];
// Show rentals only when both date of birth is provided AND skipass is selected
// Skipass field - hidden when participant is ineligible OR when no date of birth
$this->fieldStateConditions['skiPass'] = [
'hidden' => CompositeCondition::or(
CompositeCondition::not($dateOfBirthProvidedCondition),
$bookingEligibilityCondition
),
];
// Show rentals only when both date of birth is provided AND skipass is selected AND participant is eligible
$this->fieldStateConditions['rentals'] = [
'hidden' => CompositeCondition::or(
CompositeCondition::not($dateOfBirthProvidedCondition),
CompositeCondition::not($skiPassCondition)
CompositeCondition::not($skiPassCondition),
$bookingEligibilityCondition
),
];
$this->fieldStateConditions['board'] = [
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
'hidden' => CompositeCondition::or(
CompositeCondition::not($dateOfBirthProvidedCondition),
$bookingEligibilityCondition
),
];
// Bulk insurance booking conditions
@@ -114,11 +143,12 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
),
];
// Hide insurance field until date of birth is provided OR when bulk insurance booking is active for dependent participants
// Hide insurance field until date of birth is provided OR when bulk insurance booking is active OR when participant is ineligible
$this->fieldStateConditions['insurance'] = [
'hidden' => CompositeCondition::or(
CompositeCondition::not($dateOfBirthProvidedCondition),
$bulkInsuranceBookingCondition
$bulkInsuranceBookingCondition,
$bookingEligibilityCondition
),
];
@@ -131,6 +161,23 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
];
// Transportation-related field conditions
// All transportation fields require date of birth and participant eligibility
// Outbound transportation - hidden until date of birth provided AND participant is eligible
$this->fieldStateConditions['transportationOutbound'] = [
'hidden' => CompositeCondition::or(
CompositeCondition::not($dateOfBirthProvidedCondition),
$bookingEligibilityCondition
),
];
// Inbound transportation - hidden until date of birth provided AND participant is eligible
$this->fieldStateConditions['transportationInbound'] = [
'hidden' => CompositeCondition::or(
CompositeCondition::not($dateOfBirthProvidedCondition),
$bookingEligibilityCondition
),
];
// Show outbound pickup only when transportation is BUS (hidden by default)
$this->fieldStateConditions['pickupOutbound'] = [
@@ -685,6 +685,7 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
});
}
/**
* Generates label for rental insurance checkbox including pricing information.
*/
+21 -3
View File
@@ -21,6 +21,10 @@ use App\Form\Model\ParticipantDto;
*/
class BookingPriceCalculatorService
{
public function __construct(
private readonly ParticipantEligibilityService $participantEligibilityService
) {
}
/**
* Calculates comprehensive pricing breakdown for a booking.
*
@@ -89,6 +93,8 @@ class BookingPriceCalculatorService
/**
* Calculates pricing for all selected services across all participants, grouped by subtype.
*
* Only includes services from eligible participants (those with available skipasses for their age).
*
* @param BookingDtoInterface $bookingDto The booking data containing participants and their service selections
*
* @return array Array of service groups with each group containing services of the same subtype
@@ -101,10 +107,15 @@ class BookingPriceCalculatorService
return [];
}
// Aggregate service selections across all participants
// Aggregate service selections across all eligible participants
$serviceAggregation = [];
foreach ($participants as $participant) {
foreach ($participants as $participantIndex => $participant) {
// Skip ineligible participants (no skipasses available for their age)
if (false === $this->participantEligibilityService->isParticipantEligible($bookingDto, $participantIndex)) {
continue;
}
$this->aggregateParticipantServices($participant, $serviceAggregation);
}
@@ -285,6 +296,8 @@ class BookingPriceCalculatorService
* - Zustieg: Sum of all pickup prices and base transportation costs (positive and negative)
* - Parkplatz: Sum of all parking service prices
*
* Only includes transportation costs from eligible participants.
*
* Note: Transportation discounts will be handled generically by groupServicesBySubtype as "Beförderung - Rabatt"
*
* @param BookingDtoInterface $bookingDto The booking data containing participants
@@ -301,7 +314,12 @@ class BookingPriceCalculatorService
$pickupParticipants = 0;
$parkingParticipants = 0;
foreach ($participants as $participant) {
foreach ($participants as $participantIndex => $participant) {
// Skip ineligible participants (no skipasses available for their age)
if (false === $this->participantEligibilityService->isParticipantEligible($bookingDto, $participantIndex)) {
continue;
}
$participantPickupCost = 0.0;
$participantParkingCost = 0.0;
+12 -2
View File
@@ -19,6 +19,7 @@ class BookingService
public function __construct(
private readonly TravelDataService $travelDataService,
private readonly BookingPriceCalculatorService $priceCalculator,
private readonly ParticipantEligibilityService $participantEligibilityService,
) {
}
@@ -149,7 +150,7 @@ class BookingService
* Converts a Room model into a RoomSelectionDto with the specified quantity
* selection. Used during booking initialization to create selectable room options.
*
* @param Room $room The room model to convert
* @param Room $room The room model to convert
* @param array $roomsIdsAndQuantities Array of room ID to quantity mappings
*
* @return RoomSelectionDto The room selection DTO
@@ -329,6 +330,10 @@ class BookingService
* and pricing calculations, resolving timing issues where mandatory services
* were only selected during form rendering via choice_attr callbacks.
*
* Mandatory services are only preselected for eligible participants - those who
* have at least one skipass available for their age. Ineligible participants are
* skipped to prevent their mandatory services from being included in pricing.
*
* @param BookingCreateDto $bookingDto The booking DTO to update with mandatory services
*/
public function preselectMandatoryServices(BookingCreateDto $bookingDto): void
@@ -337,11 +342,16 @@ class BookingService
$mandatoryServices = array_filter($additionalServices, fn ($service) => true === $service->mandatory);
// Pre-select mandatory services for each participant
foreach ($bookingDto->participants as $participant) {
foreach ($bookingDto->participants as $participantIndex => $participant) {
if (null === $participant->dateOfBirth) {
continue; // Skip participants without age information
}
// Skip ineligible participants (no skipasses available for their age)
if (false === $this->participantEligibilityService->isParticipantEligible($bookingDto, $participantIndex)) {
continue;
}
// Get age-appropriate mandatory services for this participant
$ageAppropriateServices = array_filter($mandatoryServices, function ($service) use ($bookingDto, $participant) {
if (null === $service->ageFrom && null === $service->ageTo) {
@@ -0,0 +1,117 @@
<?php
declare(strict_types=1);
namespace App\Service;
use App\BusProNet\Constants;
use App\BusProNet\Model\Service;
use App\Form\Model\BookingDtoInterface;
use Carbon\CarbonImmutable;
use Spatie\Blink\Blink;
/**
* Service for evaluating participant eligibility for booking.
*
* A participant is considered eligible when at least one skipass is available
* for their age at the travel date. This service provides the business logic
* for eligibility checks used by both the conditional field state system and
* the view layer via Twig extension.
*
* Results are cached per request using Blink to avoid redundant calculations
* when checking the same participant multiple times.
*/
class ParticipantEligibilityService
{
/**
* Checks if a participant is eligible for booking.
*
* Returns true when the participant can book services (at least one skipass available).
* Returns false when the participant cannot book (no skipasses available for their age).
*
* Results are cached per request to avoid redundant calculations.
*
* @param BookingDtoInterface $bookingDto The current booking data
* @param int $participantIndex The index of the participant being evaluated
*
* @return bool True if participant is eligible (has available skipasses)
*/
public function isParticipantEligible(BookingDtoInterface $bookingDto, int $participantIndex): bool
{
$participant = $bookingDto->getParticipant($participantIndex);
if (null === $participant || null === $participant->dateOfBirth) {
return false;
}
// Create cache key based on participant's birth date, travel date, and index
$cacheKey = sprintf(
'participant_eligibility_%s_%s_%d',
$participant->dateOfBirth->format('Y-m-d'),
$bookingDto->travel->dateFrom->format('Y-m-d'),
$participantIndex
);
return Blink::global()->once($cacheKey, function () use ($bookingDto, $participantIndex) {
$allSkiPasses = $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_SKI_PASS, true, true);
$availableSkiPasses = array_filter(
$allSkiPasses,
fn (Service $service) => $this->isSkiPassAvailableForParticipant($service, $bookingDto, $participantIndex)
);
return !empty($availableSkiPasses);
});
}
/**
* Checks if a skipass service is available for the given participant based on age constraints.
*/
private function isSkiPassAvailableForParticipant(Service $service, BookingDtoInterface $bookingDto, int $participantIndex): bool
{
$participant = $bookingDto->getParticipant($participantIndex);
if (null === $participant || null === $participant->dateOfBirth) {
return false;
}
// No age constraints = available to all
if (null === $service->ageConstraintType) {
return true;
}
$travelStartDate = CarbonImmutable::instance($bookingDto->travel->dateFrom);
$birthDate = CarbonImmutable::instance($participant->dateOfBirth);
$ageAtTravelStart = $travelStartDate->diffInYears($birthDate);
$birthYear = (int) $birthDate->format('Y');
$constraintType = $service->ageConstraintType ?? 'absolute_age';
if ('absolute_age' === $constraintType || 'mixed' === $constraintType) {
$minAge = $service->ageFrom;
$maxAge = $service->ageTo;
if (null !== $minAge && $ageAtTravelStart < $minAge) {
return false;
}
if (null !== $maxAge && $ageAtTravelStart > $maxAge) {
return false;
}
}
if ('birth_year' === $constraintType || 'mixed' === $constraintType) {
$minBirthYear = $service->birthYearFrom;
$maxBirthYear = $service->birthYearTo;
if (null !== $minBirthYear && $birthYear < $minBirthYear) {
return false;
}
if (null !== $maxBirthYear && $birthYear > $maxBirthYear) {
return false;
}
}
return true;
}
}
+1
View File
@@ -25,6 +25,7 @@ class AppExtension extends AbstractExtension
{
return [
new TwigFunction('icon', [AppRuntime::class, 'renderIcon'], ['needs_environment' => true, 'is_safe' => ['html']]),
new TwigFunction('is_participant_eligible', [AppRuntime::class, 'isParticipantEligible']),
];
}
}
+8
View File
@@ -3,6 +3,8 @@
namespace App\Twig;
use App\BusProNet\DataProvider\CountryDataProvider;
use App\Form\Model\BookingDtoInterface;
use App\Service\ParticipantEligibilityService;
use Twig\Environment;
use Twig\Extension\RuntimeExtensionInterface;
use Twig\Extra\Intl\IntlExtension;
@@ -12,6 +14,7 @@ class AppRuntime implements RuntimeExtensionInterface
public function __construct(
private readonly IntlExtension $intlExtension,
private readonly CountryDataProvider $countryDataProvider,
private readonly ParticipantEligibilityService $participantEligibilityService,
) {
}
@@ -93,4 +96,9 @@ class AppRuntime implements RuntimeExtensionInterface
return $this->countryDataProvider->get($nationality)?->nationality;
}
public function isParticipantEligible(BookingDtoInterface $bookingDto, int $participantIndex): bool
{
return $this->participantEligibilityService->isParticipantEligible($bookingDto, $participantIndex);
}
}
+182 -171
View File
@@ -63,12 +63,15 @@
<div id="participants-form" class="space-y-8 pb-8"{% if htmx_oob_swap is defined and htmx_oob_swap %} hx-swap-oob="true"{% endif %}>
{% for participant in form.participants %}
{% set participantDataValid = participant.vars.valid %}
{% set participantData = participant.vars.data %}
{% set hasDateOfBirth = participantData and participantData.dateOfBirth %}
{% set isEligible = hasDateOfBirth and is_participant_eligible(bookingCreateDto, loop.index0) %}
<div class="{{ html_classes('border rounded px-4 py-2', { 'border-gray-300': participantDataValid, 'border-red-700': not participantDataValid }) }}" {{ stimulus_controller('toggle', {'storageKey': 'participant_' ~ loop.index0, 'open': participant.vars.valid == false}, { 'closed': 'hidden' }) }}>
<fieldset>
<legend class="w-full flex items-center justify-between">
<div class="flex items-center gap-3">
<span class="font-bold text-xl">Teilnehmer:in {{ loop.index }}</span>
{% if participantPrices is defined and participantPrices[loop.index0] is defined and participantPrices[loop.index0] > 0.0 %}
{% if isEligible and participantPrices is defined and participantPrices[loop.index0] is defined and participantPrices[loop.index0] > 0.0 %}
<span class="text-sm font-medium text-gray-600 bg-gray-100 px-2 py-1 rounded">
{{ participantPrices[loop.index0]|number_format(2, ',', '.') }}
</span>
@@ -118,10 +121,6 @@
{% endif %}
</div>
{# Services hint - shown when date of birth is missing #}
{% set participantData = participant.vars.data %}
{% set hasDateOfBirth = participantData and participantData.dateOfBirth %}
{% if not hasDateOfBirth %}
<div class="my-4 p-4 bg-blue-50 border border-blue-200 rounded-lg">
<div class="flex items-center">
@@ -133,175 +132,187 @@
</p>
</div>
</div>
{% endif %}
<div class="grid grid-cols-2 gap-4">
{{ _self.service_field(participant, 'skiPass', 'Skipass', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{{ _self.service_field(participant, 'courses', 'Kurse', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{{ _self.service_field(participant, 'additionalServices', 'Zusatzleistungen', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{{ _self.service_field(participant, 'rentals', 'Leihmaterial', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{{ _self.checkbox_field(participant, 'rentalInsurance', 'Leihmaterial-Versicherung', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{{ _self.service_field(participant, 'board', 'Verpflegung', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{# Insurance field OR assigned insurance display for dependent participants #}
{% set participantData = participant.vars.data %}
{% set showBulkInsurance = loop.index > 1 and form.vars.data.participants[0].bulkInsuranceBooking %}
{% if showBulkInsurance %}
<fieldset class="mb-1">
<legend class="font-semibold mb-1">Reiseversicherung</legend>
<div class="text-sm text-gray-600">
{% if participantData.insurance %}
{{ participantData.insurance.label }}
{% if participantData.insurance.price and participantData.insurance.price > 0 %}
<span class="text-gray-500">(€{{ participantData.insurance.price|number_format(2, ',', '.') }})</span>
{% endif %}
<span class="italic text-gray-500 ml-2"> wie Anmelder</span>
{% else %}
<span class="italic">wie Anmelder</span>
{% endif %}
</div>
</fieldset>
{% else %}
<fieldset class="mb-1">
<legend class="font-semibold mb-1">Reiseversicherung</legend>
{# Bulk insurance booking checkbox (applicant only) #}
{% if participant.bulkInsuranceBooking is defined %}
{{ form_row(participant.bulkInsuranceBooking) }}
{% endif %}
{% if participant.insurance is defined %}
{{ form_row(participant.insurance, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
},
'label': false
}) }}
{% else %}
<div class="text-sm text-gray-500">Nicht wählbar</div>
{% endif %}
</fieldset>
{% endif %}
</div>
{# Transportation Services Section #}
<div class="mt-6 border-t pt-4">
<h3 class="font-semibold text-lg mb-4">Anreise</h3>
<div class="grid grid-cols-2 gap-4">
<div>
{% if participant.transportationOutbound is defined %}
{{ form_row(participant.transportationOutbound, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{% endif %}
{% if participant.pickupOutbound is defined %}
<div class="mt-4">
{{ form_row(participant.pickupOutbound, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
</div>
{% endif %}
{% if participant.parking is defined %}
<div class="mt-4">
{{ form_row(participant.parking, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
</div>
{% endif %}
{% if participant.licensePlate is defined %}
<div class="mt-4">
{{ form_row(participant.licensePlate, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
</div>
{% endif %}
</div>
<div>
{% if participant.transportationInbound is defined %}
{{ form_row(participant.transportationInbound, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{% endif %}
{% if participant.pickupInbound is defined %}
<div class="mt-4">
{{ form_row(participant.pickupInbound, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
</div>
{% endif %}
{% elseif not isEligible %}
<div class="my-4 p-4 bg-red-50 border border-red-200 rounded-lg">
<div class="flex items-center">
<svg class="w-5 h-5 text-red-600 mr-2" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"></path>
</svg>
<p class="text-sm text-red-800">
Buchung wegen des Alters von Teilnehmer:in {{ loop.index }} nicht möglich
</p>
</div>
</div>
{% endif %}
</div>
{% if isEligible %}
<div class="grid grid-cols-2 gap-4">
{{ _self.service_field(participant, 'skiPass', 'Skipass', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{{ _self.service_field(participant, 'courses', 'Kurse', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{{ _self.service_field(participant, 'additionalServices', 'Zusatzleistungen', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{{ _self.service_field(participant, 'rentals', 'Leihmaterial', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{{ _self.checkbox_field(participant, 'rentalInsurance', 'Leihmaterial-Versicherung', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{{ _self.service_field(participant, 'board', 'Verpflegung', {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{# Insurance field OR assigned insurance display for dependent participants #}
{% set participantData = participant.vars.data %}
{% set showBulkInsurance = loop.index > 1 and form.vars.data.participants[0].bulkInsuranceBooking %}
{% if showBulkInsurance %}
<fieldset class="mb-1">
<legend class="font-semibold mb-1">Reiseversicherung</legend>
<div class="text-sm text-gray-600">
{% if participantData.insurance %}
{{ participantData.insurance.label }}
{% if participantData.insurance.price and participantData.insurance.price > 0 %}
<span class="text-gray-500">(€{{ participantData.insurance.price|number_format(2, ',', '.') }})</span>
{% endif %}
<span class="italic text-gray-500 ml-2"> wie Anmelder</span>
{% else %}
<span class="italic">wie Anmelder</span>
{% endif %}
</div>
</fieldset>
{% else %}
<fieldset class="mb-1">
<legend class="font-semibold mb-1">Reiseversicherung</legend>
{# Bulk insurance booking checkbox (applicant only) #}
{% if participant.bulkInsuranceBooking is defined %}
{{ form_row(participant.bulkInsuranceBooking) }}
{% endif %}
{% if participant.insurance is defined %}
{{ form_row(participant.insurance, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
},
'label': false
}) }}
{% else %}
<div class="text-sm text-gray-500">Nicht wählbar</div>
{% endif %}
</fieldset>
{% endif %}
</div>
{# Transportation Services Section #}
<div class="mt-6 border-t pt-4">
<h3 class="font-semibold text-lg mb-4">Anreise</h3>
<div class="grid grid-cols-2 gap-4">
<div>
{% if participant.transportationOutbound is defined %}
{{ form_row(participant.transportationOutbound, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{% endif %}
{% if participant.pickupOutbound is defined %}
<div class="mt-4">
{{ form_row(participant.pickupOutbound, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
</div>
{% endif %}
{% if participant.parking is defined %}
<div class="mt-4">
{{ form_row(participant.parking, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
</div>
{% endif %}
{% if participant.licensePlate is defined %}
<div class="mt-4">
{{ form_row(participant.licensePlate, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
</div>
{% endif %}
</div>
<div>
{% if participant.transportationInbound is defined %}
{{ form_row(participant.transportationInbound, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
{% endif %}
{% if participant.pickupInbound is defined %}
<div class="mt-4">
{{ form_row(participant.pickupInbound, {
'attr': {
'hx-trigger': 'change',
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}
</div>
</fieldset>
</div>