feat: auto-booking services

addresses #869cfcptv
This commit is contained in:
Björn Fromme
2026-03-16 20:24:58 +01:00
parent 6d9265de0f
commit c510cbf590
19 changed files with 1829 additions and 72 deletions
@@ -85,7 +85,7 @@ class Step2Controller extends AbstractController
$this->roomAssignmentService->assignRoomsIfNeeded($bookingCreateDto);
// Preselect mandatory services
$this->bookingService->preselectMandatoryServices($bookingCreateDto);
$this->bookingService->preselectDefaultServices($bookingCreateDto);
// Save BookingDto to session
$this->bookingService->saveBookingDto($request, $bookingCreateDto, BookingDto::MODE_CREATE);
@@ -149,18 +149,19 @@ class Step2Controller extends AbstractController
$form = $this->createParticipantForm($bookingDto, $index);
$form->handleRequest($request);
$isSubmitted = $form->isSubmitted();
// Detect dummy data fill token — render pre-filled form immediately, skipping validation
$isDummyDataFill = $this
->dummyDataFillService
->isTokenMatch($bookingDto->participants[$index], $bookingDto->getMode())
;
if (true === $form->isSubmitted() && true === $isDummyDataFill) {
if (true === $isSubmitted && true === $isDummyDataFill) {
$this->dummyDataFillService->fill($bookingDto->participants[$index], $index);
// Keep behavior consistent with cards view: newly filled participant data
// (especially dateOfBirth) must immediately trigger mandatory service preselection.
$this->bookingService->preselectMandatoryServices($bookingDto);
$this->bookingService->preselectDefaultServices($bookingDto);
$bookingDto->bookingStatus = Constants::BOOKING_STATUS_OPEN;
$this->bookingService->saveBookingDto($request, $bookingDto, BookingDto::MODE_CREATE);
@@ -171,10 +172,16 @@ class Step2Controller extends AbstractController
return $this->renderParticipantForm($form, $index, $bookingDto);
}
if (true === $isSubmitted) {
// Re-run default preselection after participant form input changes (e.g. DOB).
// This ensures auto-book defaults are applied as soon as eligibility becomes known.
$this->bookingService->preselectDefaultServices($bookingDto);
}
// Collect notifications from field handlers (run during PRE_SUBMIT)
$notifications = $this->collectAndClearNotifications($bookingDto);
if (true === $form->isSubmitted() && true === $form->isValid()) {
if (true === $isSubmitted && true === $form->isValid()) {
// Save BookingDto to session
$this->bookingService->saveBookingDto($request, $bookingDto, BookingDto::MODE_CREATE);
@@ -122,13 +122,19 @@ trait ParticipantCardFlowTrait
int $index,
string $refreshRouteName,
): Response {
$refreshFormOptions = ['validation_groups' => false];
// Create form with validation disabled
$form = $this->createParticipantForm($bookingDto, $index, [
'validation_groups' => false,
]);
$form = $this->createParticipantForm($bookingDto, $index, $refreshFormOptions);
$form->handleRequest($request);
// Refresh endpoint is POST-only and always processes submitted participant data.
$this->bookingService->preselectDefaultServices($bookingDto);
// Recreate form so the rendered state reflects any new auto-preselections.
$form = $this->createParticipantForm($bookingDto, $index, $refreshFormOptions);
// Collect notifications from field handlers
$notifications = $this->collectAndClearNotifications($bookingDto);