feat: add subtypes PAR and LVS as bookable additional services
This commit is contained in:
@@ -29,6 +29,8 @@ class BookingDataProcessor
|
||||
...$participant->skiPass,
|
||||
...$participant->board,
|
||||
...$participant->rentals,
|
||||
...$participant->parking,
|
||||
...$participant->rentalInsurance,
|
||||
];
|
||||
foreach ($servicesToMap as $service) {
|
||||
if (false === isset($this->additionalServices[$service->id])) {
|
||||
|
||||
@@ -19,6 +19,8 @@ class Service
|
||||
public const TOKEN_ADDITIONAL = 'SON';
|
||||
public const TOKEN_BOARD = 'VPF';
|
||||
public const TOKEN_RENTALS = ['VER', 'VE2', 'VE3', 'VE4', 'VE5', 'VE6', 'VE7', 'VE8'];
|
||||
public const TOKEN_PARKING = 'PAR';
|
||||
public const TOKEN_RENTAL_INSURANCE = 'LVS';
|
||||
|
||||
public const STATUS_AVAILABLE = 'Frei';
|
||||
public const STATUS_BLOCKED = 'Buchungsstop';
|
||||
|
||||
@@ -29,6 +29,8 @@ final class BookingType extends AbstractType
|
||||
'selectable_services' => $this->mergeSelectableServices($data, Service::TOKEN_ADDITIONAL),
|
||||
'selectable_board' => $this->mergeSelectableServices($data, Service::TOKEN_BOARD),
|
||||
'selectable_rentals' => $this->mergeSelectableServices($data, Service::TOKEN_RENTALS),
|
||||
'selectable_parking' => $this->mergeSelectableServices($data, Service::TOKEN_PARKING),
|
||||
'selectable_rental_insurance' => $this->mergeSelectableServices($data, Service::TOKEN_RENTAL_INSURANCE),
|
||||
'selectable_transportation_services_to' => $travelData
|
||||
->getTransportationServicesByDirection('HIN', false),
|
||||
'selectable_transportation_services_fro' => $travelData
|
||||
|
||||
@@ -38,6 +38,11 @@ class BookingData
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_BOARD);
|
||||
$participantData->rentals = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_RENTALS);
|
||||
$participantData->parking = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_PARKING);
|
||||
$participantData->rentalInsurance = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_RENTAL_INSURANCE);
|
||||
|
||||
// Different keys for direction used in booking data (H <=> HIN, R <=> RUECK)!
|
||||
$participantData->transportationServiceTo = $booking
|
||||
->getTransportationServiceForParticipantAndDirection($index, 'H');
|
||||
|
||||
@@ -42,6 +42,8 @@ class ParticipantData
|
||||
public array $skiPass = [];
|
||||
public array $board = [];
|
||||
public array $rentals = [];
|
||||
public array $parking = [];
|
||||
public array $rentalInsurance = [];
|
||||
public ?Service $transportationServiceTo = null;
|
||||
public ?Service $transportationServiceFro = null;
|
||||
public ?Pickup $pickup = null;
|
||||
|
||||
@@ -233,13 +233,36 @@ class ParticipantType extends AbstractType
|
||||
]);
|
||||
}
|
||||
if (0 < count($options['selectable_rentals'])) {
|
||||
// Extend common options for rentals to add checkbox-toggle action
|
||||
$rentalChoiceAttr = $commonChoiceFieldOptions['choice_attr'];
|
||||
$form->add('rentals', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Verleih',
|
||||
'choices' => $options['selectable_rentals'],
|
||||
'choice_attr' => function (?Service $service) use ($rentalChoiceAttr) {
|
||||
$attributes = $rentalChoiceAttr($service);
|
||||
// Add checkbox-toggle action to existing actions
|
||||
$attributes['data-action'] = 'booking#toggle checkbox-toggle#check';
|
||||
|
||||
return $attributes;
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
// Parking - single checkbox (always add, JS will show/hide for PKW travelers)
|
||||
$form->add('parking', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Parkplatz',
|
||||
'choices' => $options['selectable_parking'],
|
||||
]);
|
||||
|
||||
// Rental Insurance - single checkbox (always add, JS will show/hide when rentals selected)
|
||||
$form->add('rentalInsurance', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
'label' => 'Leihausrüstungsversicherung',
|
||||
'choices' => $options['selectable_rental_insurance'],
|
||||
]);
|
||||
|
||||
// Transportation
|
||||
$transportationChoiceAttributes = function (?Service $service) use ($options) {
|
||||
$attributes = [
|
||||
@@ -330,12 +353,39 @@ class ParticipantType extends AbstractType
|
||||
return;
|
||||
}
|
||||
|
||||
// Get selected transportation service
|
||||
$transportationId = $data['transportationServiceTo'] ?? null;
|
||||
$transportation = $options['travel']->pickups[$transportationId] ?? null;
|
||||
$transportation = null;
|
||||
foreach ($options['selectable_transportation_services_to'] as $service) {
|
||||
if ($service->id == $transportationId) {
|
||||
$transportation = $service;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove pickup field for PKW (existing logic, corrected)
|
||||
if (null !== $transportation && 'PKW' === $transportation->subType) {
|
||||
$form->remove('pickup');
|
||||
unset($data['pickup']);
|
||||
if ($form->has('pickup')) {
|
||||
$form->remove('pickup');
|
||||
unset($data['pickup']);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove parking field for BUS travelers (only show for PKW)
|
||||
if (null !== $transportation && 'BUS' === $transportation->subType) {
|
||||
if ($form->has('parking')) {
|
||||
$form->remove('parking');
|
||||
unset($data['parking']);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove rental insurance if no rentals selected
|
||||
$hasRentals = isset($data['rentals']) && is_array($data['rentals']) && 0 < count($data['rentals']);
|
||||
if (false === $hasRentals) {
|
||||
if ($form->has('rentalInsurance')) {
|
||||
$form->remove('rentalInsurance');
|
||||
unset($data['rentalInsurance']);
|
||||
}
|
||||
}
|
||||
|
||||
// filter selectable services by participant's age
|
||||
@@ -389,6 +439,7 @@ class ParticipantType extends AbstractType
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@@ -402,6 +453,8 @@ class ParticipantType extends AbstractType
|
||||
'selectable_services' => [],
|
||||
'selectable_board' => [],
|
||||
'selectable_rentals' => [],
|
||||
'selectable_parking' => [],
|
||||
'selectable_rental_insurance' => [],
|
||||
'selectable_transportation_services_to' => [],
|
||||
'selectable_transportation_services_fro' => [],
|
||||
'selectable_pickups' => [],
|
||||
|
||||
Reference in New Issue
Block a user