wip: refactor admin controllers

This commit is contained in:
Björn Fromme committed 2026-07-16 09:03:42 +02:00
1 parent a294d1cc5e
commit bb7ae1adcc
24 files changed
+124 -45

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260630085856 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_2D38541277153098 ON accommodation');
$this->addSql('ALTER TABLE accommodation ADD cms_code VARCHAR(16) DEFAULT NULL, CHANGE code calendar_code VARCHAR(16) NOT NULL');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2D3854122583B3CC ON accommodation (calendar_code)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_2D3854122583B3CC ON accommodation');
$this->addSql('ALTER TABLE accommodation DROP cms_code, CHANGE calendar_code code VARCHAR(16) NOT NULL');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2D38541277153098 ON accommodation (code)');
}
}
@@ -8,4 +8,10 @@ enum ContingentStatus: string
{ {
case Ok = 'OK'; case Ok = 'OK';
case Blocked = 'BLOCKED'; case Blocked = 'BLOCKED';
case OnRequest = 'ON_REQUEST';
public function label(): string
{
return 'enum.contingent_status.'.strtolower($this->value);
}
} }
@@ -38,7 +38,7 @@ class CreateController extends AbstractController
$this->logger->info('Created accommodation', [ $this->logger->info('Created accommodation', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
]); ]);
return new HxRedirectResponse($this->generateUrl('app_admin_accommodation')); return new HxRedirectResponse($this->generateUrl('app_admin_accommodation'));
@@ -32,7 +32,7 @@ class DeleteController extends AbstractController
$this->logger->info('Deleted accommodation', [ $this->logger->info('Deleted accommodation', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
]); ]);
return new HxRedirectResponse($this->generateUrl('app_admin_accommodation')); return new HxRedirectResponse($this->generateUrl('app_admin_accommodation'));
@@ -29,8 +29,8 @@ class EditController extends AbstractController
// fetch additional data from cms if available // fetch additional data from cms if available
$cmsData = []; $cmsData = [];
if (null !== $accommodation->getCode()) { if (null !== $accommodation->getCalendarCode()) {
$cmsData = $this->cmsDataProvider->getHotelDetails($accommodation->getCode()); $cmsData = $this->cmsDataProvider->getHotelDetails($accommodation->getEffectiveCmsCode());
} }
$form = $this->createForm(AccommodationType::class, $accommodation); $form = $this->createForm(AccommodationType::class, $accommodation);
@@ -44,7 +44,7 @@ class EditController extends AbstractController
$this->logger->info('Updated accommodation', [ $this->logger->info('Updated accommodation', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
]); ]);
return $this->redirectToRoute('app_admin_accommodation_edit', ['id' => $accommodation->getId()]); return $this->redirectToRoute('app_admin_accommodation_edit', ['id' => $accommodation->getId()]);
@@ -19,7 +19,7 @@ class IndexController extends AbstractController
#[Route('/admin/accommodation', name: 'app_admin_accommodation')] #[Route('/admin/accommodation', name: 'app_admin_accommodation')]
public function index(): Response public function index(): Response
{ {
$accommodations = $this->accommodationRepository->findBy([], ['code' => 'ASC']); $accommodations = $this->accommodationRepository->findBy([], ['calendarCode' => 'ASC']);
return $this->render('admin/accommodation/index.html.twig', [ return $this->render('admin/accommodation/index.html.twig', [
'accommodations' => $accommodations, 'accommodations' => $accommodations,
@@ -40,7 +40,7 @@ class CreateController extends AbstractController
$this->logger->info('Created accommodation price', [ $this->logger->info('Created accommodation price', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
'date_range' => [ 'date_range' => [
'from' => $accommodationPrice->getDateFrom()->format('Y-m-d'), 'from' => $accommodationPrice->getDateFrom()->format('Y-m-d'),
'to' => $accommodationPrice->getDateTo()->format('Y-m-d'), 'to' => $accommodationPrice->getDateTo()->format('Y-m-d'),
@@ -33,7 +33,7 @@ class DeleteController extends AbstractController
$this->logger->info('Deleted accommodation price', [ $this->logger->info('Deleted accommodation price', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
'date_range' => [ 'date_range' => [
'from' => $accommodationPrice->getDateFrom()->format('Y-m-d'), 'from' => $accommodationPrice->getDateFrom()->format('Y-m-d'),
'to' => $accommodationPrice->getDateTo()->format('Y-m-d'), 'to' => $accommodationPrice->getDateTo()->format('Y-m-d'),
@@ -46,7 +46,7 @@ class EditController extends AbstractController
$this->logger->info('Edited accommodation price', [ $this->logger->info('Edited accommodation price', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
'date_range' => [ 'date_range' => [
'from' => $accommodationPrice->getDateFrom()->format('Y-m-d'), 'from' => $accommodationPrice->getDateFrom()->format('Y-m-d'),
'to' => $accommodationPrice->getDateTo()->format('Y-m-d'), 'to' => $accommodationPrice->getDateTo()->format('Y-m-d'),
@@ -43,7 +43,7 @@ class CreateController extends AbstractController
$this->logger->info('Created additional service', [ $this->logger->info('Created additional service', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
'label' => $additionalService->getLabel(), 'label' => $additionalService->getLabel(),
]); ]);
@@ -37,7 +37,7 @@ class DeleteController extends AbstractController
$this->logger->info('Deleted additional service', [ $this->logger->info('Deleted additional service', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
'label' => $additionalService->getLabel(), 'label' => $additionalService->getLabel(),
]); ]);
@@ -52,7 +52,7 @@ class EditController extends AbstractController
$this->logger->info('Edited additional service', [ $this->logger->info('Edited additional service', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
'label' => $additionalService->getLabel(), 'label' => $additionalService->getLabel(),
]); ]);
@@ -42,7 +42,7 @@ class CreateController extends AbstractController
$this->logger->info('Created board service', [ $this->logger->info('Created board service', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
'label' => $boardService->getLabel(), 'label' => $boardService->getLabel(),
]); ]);
@@ -36,7 +36,7 @@ class DeleteController extends AbstractController
$this->logger->info('Deleted board service', [ $this->logger->info('Deleted board service', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
'label' => $boardService->getLabel(), 'label' => $boardService->getLabel(),
]); ]);
@@ -48,7 +48,7 @@ class EditController extends AbstractController
$this->logger->info('Edited board service', [ $this->logger->info('Edited board service', [
'name' => $accommodation->getName(), 'name' => $accommodation->getName(),
'code' => $accommodation->getCode(), 'code' => $accommodation->getCalendarCode(),
'label' => $boardService->getLabel(), 'label' => $boardService->getLabel(),
]); ]);
@@ -95,6 +95,7 @@ class ContingentController extends AbstractController
'priceAdditionalPerson' => null !== $price ? round($price->getPriceAdditionalPerson() / 100, 2) : null, 'priceAdditionalPerson' => null !== $price ? round($price->getPriceAdditionalPerson() / 100, 2) : null,
'priceAdditionalPersonOverride' => null !== $price?->getPriceAdditionalPersonOverride() ? round($price->getPriceAdditionalPersonOverride() / 100, 2) : null, 'priceAdditionalPersonOverride' => null !== $price?->getPriceAdditionalPersonOverride() ? round($price->getPriceAdditionalPersonOverride() / 100, 2) : null,
'includedPax' => $price?->getIncludedPax(), 'includedPax' => $price?->getIncludedPax(),
'minPax' => $price?->getAccommodation()->getMinPaxSummer(),
'minNights' => $price?->getMinNights(), 'minNights' => $price?->getMinNights(),
]; ];
} }
+25 -5
View File
@@ -29,7 +29,10 @@ class Accommodation implements BlameableEntityInterface, TimestampableEntityInte
#[ORM\Column(length: 16, unique: true)] #[ORM\Column(length: 16, unique: true)]
#[Assert\NotBlank(message: 'required')] #[Assert\NotBlank(message: 'required')]
private ?string $code = null; private ?string $calendarCode = null;
#[ORM\Column(length: 16, nullable: true)]
private ?string $cmsCode = null;
#[ORM\Column] #[ORM\Column]
#[Assert\NotNull(message: 'required')] #[Assert\NotNull(message: 'required')]
@@ -89,18 +92,35 @@ class Accommodation implements BlameableEntityInterface, TimestampableEntityInte
return $this; return $this;
} }
public function getCode(): ?string public function getCalendarCode(): ?string
{ {
return $this->code; return $this->calendarCode;
} }
public function setCode(string $code): self public function setCalendarCode(string $calendarCode): self
{ {
$this->code = $code; $this->calendarCode = $calendarCode;
return $this; return $this;
} }
public function getCmsCode(): ?string
{
return $this->cmsCode;
}
public function setCmsCode(?string $cmsCode): self
{
$this->cmsCode = $cmsCode;
return $this;
}
public function getEffectiveCmsCode(): string
{
return $this->cmsCode ?? $this->calendarCode;
}
public function getMinPaxSummer(): ?int public function getMinPaxSummer(): ?int
{ {
return $this->minPaxSummer; return $this->minPaxSummer;
+7 -3
View File
@@ -20,14 +20,18 @@ class AccommodationType extends AbstractType
->add('name', TextType::class, [ ->add('name', TextType::class, [
'label' => 'Name', 'label' => 'Name',
]) ])
->add('code', TextType::class, [ ->add('calendarCode', TextType::class, [
'label' => 'Code', 'label' => 'Code für Kalender',
])
->add('cmsCode', TextType::class, [
'label' => 'Code für CMS-Daten',
'required' => false,
]) ])
->add('minPaxSummer', IntegerType::class, [ ->add('minPaxSummer', IntegerType::class, [
'label' => 'Mindestbelegung Sommer', 'label' => 'Mindestbelegung Sommer',
]) ])
->add('maxAdolescentAge', IntegerType::class, [ ->add('maxAdolescentAge', IntegerType::class, [
'label' => 'Altersgrenze Jugendliche R', 'label' => 'Altersgrenze Jugendliche',
]) ])
->add('currency', ChoiceType::class, [ ->add('currency', ChoiceType::class, [
'label' => 'Währung', 'label' => 'Währung',
@@ -31,7 +31,7 @@ class AccommodationPriceRepository extends ServiceEntityRepository
): array { ): array {
return $this->createQueryBuilder('ap') return $this->createQueryBuilder('ap')
->join('ap.accommodation', 'a') ->join('ap.accommodation', 'a')
->where('a.code = :hotelCode') ->where('a.calendarCode = :hotelCode')
->andWhere('ap.dateFrom <= :dateTo') ->andWhere('ap.dateFrom <= :dateTo')
->andWhere('ap.dateTo >= :dateFrom') ->andWhere('ap.dateTo >= :dateFrom')
->setParameter('hotelCode', $hotelCode) ->setParameter('hotelCode', $hotelCode)
+1 -1
View File
@@ -61,7 +61,7 @@ class Calendar
$map = $this->buildCoverageMap(); $map = $this->buildCoverageMap();
$blockedDates = $this->fetchBlockedDates( $blockedDates = $this->fetchBlockedDates(
$accommodation->getCode() ?? '', $accommodation->getCalendarCode() ?? '',
$start->format('Y-m-d'), $start->format('Y-m-d'),
$start->addMonths(3)->subDay()->format('Y-m-d'), $start->addMonths(3)->subDay()->format('Y-m-d'),
); );
+11 -1
View File
@@ -6,7 +6,8 @@
<div class="lg:col-span-2"> <div class="lg:col-span-2">
{{ form_row(form.name) }} {{ form_row(form.name) }}
</div> </div>
{{ form_row(form.code) }} {{ form_row(form.calendarCode) }}
{{ form_row(form.cmsCode) }}
{{ form_row(form.minPaxSummer) }} {{ form_row(form.minPaxSummer) }}
{{ form_row(form.maxAdolescentAge) }} {{ form_row(form.maxAdolescentAge) }}
{{ form_row(form.currency) }} {{ form_row(form.currency) }}
@@ -25,6 +26,15 @@
{{ cmsData.address | default('-') | nl2br }} {{ cmsData.address | default('-') | nl2br }}
</div> </div>
</div> </div>
{% else %}
<div class="space-y-4">
<div class="max-w-64">
<svg class="w-full h-auto" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M4 5V19H20V7H11.5858L9.58579 5H4ZM12.4142 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5ZM10 10.5C10 11.3284 9.32843 12 8.5 12C7.67157 12 7 11.3284 7 10.5C7 9.67157 7.67157 9 8.5 9C9.32843 9 10 9.67157 10 10.5ZM18 17L14 11L7 17H18Z"></path></svg>
</div>
<div>
<strong>CMS-Code falsch oder Haus in TYPO3 nicht angelegt</strong>
</div>
</div>
{% endif %} {% endif %}
</div> </div>
<div class="flex justify-between pt-8"> <div class="flex justify-between pt-8">
@@ -29,7 +29,7 @@
{{ accommodation.name }} {{ accommodation.name }}
</td> </td>
<td> <td>
{{ accommodation.code }} {{ accommodation.calendarCode }}
</td> </td>
<td> <td>
{{ accommodation.createdAt | date('d.m.Y, H:i') }} {{ accommodation.createdAt | date('d.m.Y, H:i') }}
@@ -2,8 +2,11 @@
{{ form_start(form) }} {{ form_start(form) }}
<div class="grid lg:grid-cols-2 gap-y-4 lg:gap-x-8"> <div class="grid lg:grid-cols-2 gap-y-4 lg:gap-x-8">
{{ form_row(form.dateFrom) }} <div class="lg:col-span-2 grid lg:grid-cols-3 gap-y-4 lg:gap-x-8">
{{ form_row(form.dateTo) }} {{ form_row(form.dateFrom) }}
{{ form_row(form.dateTo) }}
{{ form_row(form.season) }}
</div>
{{ form_row(form.pricePerNight) }} {{ form_row(form.pricePerNight) }}
{{ form_row(form.pricePerNightOverride) }} {{ form_row(form.pricePerNightOverride) }}
{{ form_row(form.priceAdditionalPerson) }} {{ form_row(form.priceAdditionalPerson) }}
+16 -16
View File
@@ -1,19 +1,4 @@
<div class="flex justify-around items-center gap-6 mb-4 text-sm text-gray-600"> <div class="grid grid-cols-3 gap-8 mb-4">
<div class="flex items-center gap-1.5">
<span class="inline-block w-3 h-3 rounded-full bg-blue-500"></span> Preiskonfigurationen
</div>
<div class="flex items-center gap-1.5">
<span class="inline-block w-3 h-3 rounded-full bg-green-500"></span> Verpflegungsleistungen
</div>
<div class="flex items-center gap-1.5">
<span class="inline-block w-3 h-3 rounded-full bg-amber-500"></span> optionale Zusatzleistungen
</div>
<div class="flex items-center gap-1.5">
<span class="inline-block w-3 h-3 rounded-full bg-red-500"></span> Buchungsstopp
</div>
</div>
<div class="grid grid-cols-3 gap-8">
{% for month in months %} {% for month in months %}
<div> <div>
<div class="text-sm font-semibold text-center mb-2">{{ month.label }}</div> <div class="text-sm font-semibold text-center mb-2">{{ month.label }}</div>
@@ -54,3 +39,18 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="flex justify-around items-center gap-6 mb-4 text-sm text-gray-600">
<div class="flex items-center gap-1.5">
<span class="inline-block w-3 h-3 rounded-full bg-blue-500"></span> Preiskonfigurationen
</div>
<div class="flex items-center gap-1.5">
<span class="inline-block w-3 h-3 rounded-full bg-green-500"></span> Verpflegungsleistungen
</div>
<div class="flex items-center gap-1.5">
<span class="inline-block w-3 h-3 rounded-full bg-amber-500"></span> optionale Zusatzleistungen
</div>
<div class="flex items-center gap-1.5">
<span class="inline-block w-3 h-3 rounded-full bg-red-500"></span> nicht verfügbar
</div>
</div>