diff --git a/migrations/Version20260804152215.php b/migrations/Version20260804152215.php
new file mode 100644
index 0000000..49bb1b1
--- /dev/null
+++ b/migrations/Version20260804152215.php
@@ -0,0 +1,29 @@
+addSql('ALTER TABLE accommodation_booking CHANGE first_name first_name VARCHAR(100) DEFAULT NULL, CHANGE last_name last_name VARCHAR(100) DEFAULT NULL, CHANGE email email VARCHAR(255) DEFAULT NULL, CHANGE group_name group_name VARCHAR(255) DEFAULT NULL');
+ }
+
+ public function down(Schema $schema): void
+ {
+ $this->addSql('ALTER TABLE accommodation_booking CHANGE group_name group_name VARCHAR(255) NOT NULL, CHANGE first_name first_name VARCHAR(100) NOT NULL, CHANGE last_name last_name VARCHAR(100) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL');
+ }
+}
diff --git a/src/Controller/Admin/AccommodationBooking/CreateController.php b/src/Controller/Admin/AccommodationBooking/CreateController.php
index 2c74b71..e8f1baf 100644
--- a/src/Controller/Admin/AccommodationBooking/CreateController.php
+++ b/src/Controller/Admin/AccommodationBooking/CreateController.php
@@ -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,
]);
}
diff --git a/src/Entity/Groups/AccommodationBooking.php b/src/Entity/Groups/AccommodationBooking.php
index a854cd9..47e513b 100644
--- a/src/Entity/Groups/AccommodationBooking.php
+++ b/src/Entity/Groups/AccommodationBooking.php
@@ -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;
diff --git a/src/Form/Admin/Groups/AccommodationBookingCreateType.php b/src/Form/Admin/Groups/AccommodationBookingCreateType.php
new file mode 100644
index 0000000..8192faa
--- /dev/null
+++ b/src/Form/Admin/Groups/AccommodationBookingCreateType.php
@@ -0,0 +1,63 @@
+
+ */
+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,
+ ]);
+ }
+}
diff --git a/src/Form/Admin/Groups/AccommodationBookingType.php b/src/Form/Admin/Groups/AccommodationBookingType.php
index 70faafc..6fe984e 100644
--- a/src/Form/Admin/Groups/AccommodationBookingType.php
+++ b/src/Form/Admin/Groups/AccommodationBookingType.php
@@ -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');
diff --git a/templates/admin/accommodation_booking/create.html.twig b/templates/admin/accommodation_booking/create.html.twig
deleted file mode 100644
index f9d11de..0000000
--- a/templates/admin/accommodation_booking/create.html.twig
+++ /dev/null
@@ -1,53 +0,0 @@
-{% extends 'layout_admin.html.twig' %}
-
-{% block content %}
-