fix: process canceled participants correctly
This commit is contained in:
@@ -33,14 +33,12 @@ final class BookingType extends AbstractType
|
||||
->getTransportationServicesByDirection('HIN'),
|
||||
'selectable_transportation_services_fro' => $travelData
|
||||
->getTransportationServicesByDirection('RUECK'),
|
||||
'selectable_pickups_to' => $travelData->pickupsTo,
|
||||
'selectable_pickups_fro' => $travelData->pickupsFro,
|
||||
'selectable_pickups' => $travelData->pickupsTo,
|
||||
'personal_data_mutable' => $travelData->participantDataMutable,
|
||||
'additional_services_mutable' => $travelData->additionalServicesMutable,
|
||||
'transportation_services_mutable' => $travelData->transportationServicesMutable,
|
||||
'pickups_mutable' => $travelData->pickupsMutable,
|
||||
'applicant_id' => $data->booking->applicant->personId,
|
||||
|
||||
],
|
||||
'allow_add' => false,
|
||||
'allow_delete' => false,
|
||||
|
||||
@@ -27,23 +27,26 @@ class BookingData
|
||||
/** @var PersonalData $participant */
|
||||
$participantData = ParticipantData::fromPersonalData($participant);
|
||||
$participantData->index = $index;
|
||||
$participantData->courses = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_COURSES);
|
||||
$participantData->skiPass = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_SKI_PASS);
|
||||
$participantData->additionalServices = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_ADDITIONAL);
|
||||
$participantData->board = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_BOARD);
|
||||
$participantData->rentals = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_RENTALS);
|
||||
// Different keys for direction used in booking data (H <=> HIN, R <=> RUECK)!
|
||||
$participantData->transportationServiceTo = $booking
|
||||
->getTransportationServiceForParticipantAndDirection($index, 'H');
|
||||
$participantData->transportationServiceFro = $booking
|
||||
->getTransportationServiceForParticipantAndDirection($index, 'R');
|
||||
$participantData->pickupTo = $booking->getPickupToForParticipant($index);
|
||||
$participantData->pickupFro = $booking->getPickupFroForParticipant($index);
|
||||
|
||||
// update services only for active participants
|
||||
if ('F' === $participantData->status) {
|
||||
$participantData->courses = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_COURSES);
|
||||
$participantData->skiPass = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_SKI_PASS);
|
||||
$participantData->additionalServices = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_ADDITIONAL);
|
||||
$participantData->board = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_BOARD);
|
||||
$participantData->rentals = $booking
|
||||
->getAdditionalServicesForParticipantByGroup($index, Service::TOKEN_RENTALS);
|
||||
// Different keys for direction used in booking data (H <=> HIN, R <=> RUECK)!
|
||||
$participantData->transportationServiceTo = $booking
|
||||
->getTransportationServiceForParticipantAndDirection($index, 'H');
|
||||
$participantData->transportationServiceFro = $booking
|
||||
->getTransportationServiceForParticipantAndDirection($index, 'R');
|
||||
$participantData->pickupTo = $booking->getPickupForParticipant($index);
|
||||
}
|
||||
|
||||
$instance->participants[$index] = $participantData;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ class ParticipantData
|
||||
#[Assert\Email(message: 'Bitte eine gültige E-Mail Adresse angeben', mode: 'strict')]
|
||||
public ?string $email = null;
|
||||
|
||||
#[Assert\NotBlank(message: 'Bitte angeben')]
|
||||
public ?string $mobile = null;
|
||||
public array $courses = [];
|
||||
public array $additionalServices = [];
|
||||
@@ -43,8 +42,7 @@ class ParticipantData
|
||||
public array $rentals = [];
|
||||
public ?Service $transportationServiceTo = null;
|
||||
public ?Service $transportationServiceFro = null;
|
||||
public ?Pickup $pickupTo = null;
|
||||
public ?Pickup $pickupFro = null;
|
||||
public ?Pickup $pickup = null;
|
||||
|
||||
#[Assert\Callback]
|
||||
public function assertBodyMeasurementsValid(ExecutionContextInterface $context): void
|
||||
@@ -78,15 +76,9 @@ class ParticipantData
|
||||
#[Assert\Callback]
|
||||
public function assertPickupSelected(ExecutionContextInterface $context): void
|
||||
{
|
||||
if (null !== $this->transportationServiceTo && null === $this->pickupTo) {
|
||||
if (null !== $this->transportationServiceTo && null === $this->pickup) {
|
||||
$context->buildViolation('Bitte auswählen')
|
||||
->atPath('pickupTo')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
if (null !== $this->transportationServiceFro && null === $this->pickupFro) {
|
||||
$context->buildViolation('Bitte auswählen')
|
||||
->atPath('pickupFro')
|
||||
->atPath('pickup')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
@@ -96,6 +88,7 @@ class ParticipantData
|
||||
{
|
||||
$instance = new static();
|
||||
|
||||
$instance->status = $personalData->status;
|
||||
$instance->addressId = $personalData->addressId;
|
||||
$instance->personId = $personalData->personId;
|
||||
$instance->mutable = $personalData->mutable;
|
||||
|
||||
@@ -25,6 +25,11 @@ class ParticipantType extends AbstractType
|
||||
$participantData = $event->getData();
|
||||
$participantIndex = $participantData->index;
|
||||
|
||||
// don't add any fields for canceled participants
|
||||
if ('F' !== $participantData->status) {
|
||||
return;
|
||||
}
|
||||
|
||||
$form = $event->getForm();
|
||||
|
||||
$personalDataMutable = $options['personal_data_mutable'] && $participantData->mutable;
|
||||
@@ -83,6 +88,7 @@ class ParticipantType extends AbstractType
|
||||
])
|
||||
->add('mobile', TextType::class, [
|
||||
'label' => 'Telefon (mobil)',
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
'readonly' => false === $personalDataMutable,
|
||||
]
|
||||
@@ -259,11 +265,11 @@ class ParticipantType extends AbstractType
|
||||
;
|
||||
|
||||
// Pickup
|
||||
$form->add('pickupTo', ChoiceType::class, [
|
||||
$form->add('pickup', ChoiceType::class, [
|
||||
'label' => 'Zustieg',
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'choices' => $options['selectable_pickups_to'],
|
||||
'choices' => $options['selectable_pickups'],
|
||||
'choice_value' => 'id',
|
||||
'choice_label' => function (?Pickup $pickup) {
|
||||
if (null === $pickup) {
|
||||
@@ -282,24 +288,16 @@ class ParticipantType extends AbstractType
|
||||
);
|
||||
},
|
||||
]);
|
||||
|
||||
if (0 < count($options['selectable_pickups_fro'])) {
|
||||
$form->add('pickupFro', ChoiceType::class, [
|
||||
'label' => 'Ausstieg',
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'choices' => $options['selectable_pickups_fro'],
|
||||
'choice_value' => 'id',
|
||||
'choice_label' => function (?Pickup $pickup) {
|
||||
return $pickup?->city;
|
||||
},
|
||||
]);
|
||||
}
|
||||
})
|
||||
->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($options) {
|
||||
$data = $event->getData();
|
||||
$form = $event->getForm();
|
||||
|
||||
// skip processing for canceled participants
|
||||
if ('F' !== $form->getData()->status) {
|
||||
return;
|
||||
}
|
||||
|
||||
$transportationId = $data['transportationServiceTo'];
|
||||
$transportation = $options['travel']->pickups[$transportationId] ?? null;
|
||||
|
||||
@@ -342,8 +340,7 @@ class ParticipantType extends AbstractType
|
||||
'selectable_rentals' => [],
|
||||
'selectable_transportation_services_to' => [],
|
||||
'selectable_transportation_services_fro' => [],
|
||||
'selectable_pickups_to' => [],
|
||||
'selectable_pickups_fro' => [],
|
||||
'selectable_pickups' => [],
|
||||
'personal_data_mutable' => true,
|
||||
'additional_services_mutable' => true,
|
||||
'transportation_services_mutable' => true,
|
||||
|
||||
Reference in New Issue
Block a user