feat: create new bookings or inquiries on behalf of customer
This commit is contained in:
1 parent
5f2252af71
commit
dc86e715cb
8 files changed
+149
-83
No files matched your search
@@ -5,7 +5,8 @@ declare(strict_types=1);
|
||||
namespace App\Controller\Admin\AccommodationBooking;
|
||||
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Form\Admin\Groups\AccommodationBookingType;
|
||||
use App\Form\Admin\Groups\AccommodationBookingCreateType;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -30,8 +31,8 @@ class CreateController extends AbstractController
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
|
||||
$form = $this->createForm(AccommodationBookingType::class, $booking, [
|
||||
'with_accommodation' => true,
|
||||
$form = $this->createForm(AccommodationBookingCreateType::class, $booking, [
|
||||
'hx_post' => $request->getRequestUri(),
|
||||
]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
@@ -40,20 +41,18 @@ class CreateController extends AbstractController
|
||||
$this->entityManager->persist($booking);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->bookingService->issueAccessLinkForDirectBooking($booking);
|
||||
$this->bookingService->sendCustomerConfirmationEmail($booking);
|
||||
|
||||
$this->addFlash('success', 'Die Buchung wurde erstellt');
|
||||
|
||||
$this->logger->info('Created accommodation booking', [
|
||||
'id' => $booking->getId(),
|
||||
'groupName' => $booking->getGroupName(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_accommodationbooking_edit', ['id' => $booking->getId()]);
|
||||
return new HxRedirectResponse(
|
||||
$this->generateUrl('app_admin_accommodationbooking_edit', ['id' => $booking->getId()])
|
||||
);
|
||||
}
|
||||
|
||||
return $this->render('admin/accommodation_booking/create.html.twig', [
|
||||
return $this->render('admin/accommodation_booking/modal_create.html.twig', [
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -84,19 +84,24 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $acceptedAt = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Assert\NotBlank(groups: ['edit'])]
|
||||
private ?string $groupName = null;
|
||||
|
||||
#[ORM\Column(length: 10, nullable: true)]
|
||||
private ?string $salutation = null;
|
||||
|
||||
#[ORM\Column(length: 100)]
|
||||
#[ORM\Column(length: 100, nullable: true)]
|
||||
#[Assert\NotBlank(groups: ['edit'])]
|
||||
private ?string $firstName = null;
|
||||
|
||||
#[ORM\Column(length: 100)]
|
||||
#[ORM\Column(length: 100, nullable: true)]
|
||||
#[Assert\NotBlank(groups: ['edit'])]
|
||||
private ?string $lastName = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Assert\NotBlank(groups: ['edit'])]
|
||||
#[Assert\Email(groups: ['edit'])]
|
||||
private ?string $email = null;
|
||||
|
||||
#[ORM\Column(length: 50, nullable: true)]
|
||||
@@ -371,7 +376,7 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
return $this->groupName;
|
||||
}
|
||||
|
||||
public function setGroupName(string $groupName): self
|
||||
public function setGroupName(?string $groupName): self
|
||||
{
|
||||
$this->groupName = $groupName;
|
||||
|
||||
@@ -395,7 +400,7 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
return $this->firstName;
|
||||
}
|
||||
|
||||
public function setFirstName(string $firstName): self
|
||||
public function setFirstName(?string $firstName): self
|
||||
{
|
||||
$this->firstName = $firstName;
|
||||
|
||||
@@ -407,7 +412,7 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
return $this->lastName;
|
||||
}
|
||||
|
||||
public function setLastName(string $lastName): self
|
||||
public function setLastName(?string $lastName): self
|
||||
{
|
||||
$this->lastName = $lastName;
|
||||
|
||||
@@ -419,7 +424,7 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): self
|
||||
public function setEmail(?string $email): self
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Admin\Groups;
|
||||
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* Lean form for creating a booking. The available board and additional services can only be
|
||||
* resolved once accommodation and date range are known, so they are offered on the edit page.
|
||||
*
|
||||
* @extends AbstractType<AccommodationBooking>
|
||||
*/
|
||||
class AccommodationBookingCreateType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('accommodation', EntityType::class, [
|
||||
'class' => Accommodation::class,
|
||||
'choice_label' => 'name',
|
||||
'label' => 'Gruppenhaus',
|
||||
])
|
||||
->add('dateFrom', DateType::class, [
|
||||
'label' => 'Anreise',
|
||||
'widget' => 'single_text',
|
||||
])
|
||||
->add('dateTo', DateType::class, [
|
||||
'label' => 'Abreise',
|
||||
'widget' => 'single_text',
|
||||
])
|
||||
->add('paxCount', IntegerType::class, [
|
||||
'label' => 'Anzahl Personen',
|
||||
])
|
||||
->add('minorsCount', IntegerType::class, [
|
||||
'label' => 'davon Kinder (0–3 Jahre)',
|
||||
])
|
||||
->add('childrenCount', IntegerType::class, [
|
||||
'label' => 'davon Kinder',
|
||||
])
|
||||
->add('isInquiry', CheckboxType::class, [
|
||||
'label' => 'Anfrage (nicht bindend)',
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => AccommodationBooking::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Admin\Groups;
|
||||
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use App\Entity\Groups\BoardService;
|
||||
@@ -26,14 +25,6 @@ class AccommodationBookingType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
if ($options['with_accommodation']) {
|
||||
$builder->add('accommodation', EntityType::class, [
|
||||
'class' => Accommodation::class,
|
||||
'choice_label' => 'name',
|
||||
'label' => 'Gruppenhaus',
|
||||
]);
|
||||
}
|
||||
|
||||
$builder
|
||||
->add('groupName', TextType::class, [
|
||||
'label' => 'Gruppenname',
|
||||
@@ -158,14 +149,13 @@ class AccommodationBookingType extends AbstractType
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => AccommodationBooking::class,
|
||||
'with_accommodation' => false,
|
||||
'validation_groups' => ['Default', 'edit'],
|
||||
'max_adolescent_age' => 0,
|
||||
'board_services' => [],
|
||||
'additional_services' => [],
|
||||
'current_board_service' => null,
|
||||
'current_additional_services' => [],
|
||||
]);
|
||||
$resolver->setAllowedTypes('with_accommodation', 'bool');
|
||||
$resolver->setAllowedTypes('max_adolescent_age', 'int');
|
||||
$resolver->setAllowedTypes('board_services', 'array');
|
||||
$resolver->setAllowedTypes('additional_services', 'array');
|
||||
|
||||
Reference in new issue
Block a user