wip: refactor admin controllers
This commit is contained in:
1 parent
a294d1cc5e
commit
bb7ae1adcc
24 files changed
+124
-45
No files matched your search
@@ -8,4 +8,10 @@ enum ContingentStatus: string
|
||||
{
|
||||
case Ok = 'OK';
|
||||
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', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
]);
|
||||
|
||||
return new HxRedirectResponse($this->generateUrl('app_admin_accommodation'));
|
||||
|
||||
@@ -32,7 +32,7 @@ class DeleteController extends AbstractController
|
||||
|
||||
$this->logger->info('Deleted accommodation', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
]);
|
||||
|
||||
return new HxRedirectResponse($this->generateUrl('app_admin_accommodation'));
|
||||
|
||||
@@ -29,8 +29,8 @@ class EditController extends AbstractController
|
||||
// fetch additional data from cms if available
|
||||
$cmsData = [];
|
||||
|
||||
if (null !== $accommodation->getCode()) {
|
||||
$cmsData = $this->cmsDataProvider->getHotelDetails($accommodation->getCode());
|
||||
if (null !== $accommodation->getCalendarCode()) {
|
||||
$cmsData = $this->cmsDataProvider->getHotelDetails($accommodation->getEffectiveCmsCode());
|
||||
}
|
||||
|
||||
$form = $this->createForm(AccommodationType::class, $accommodation);
|
||||
@@ -44,7 +44,7 @@ class EditController extends AbstractController
|
||||
|
||||
$this->logger->info('Updated accommodation', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
]);
|
||||
|
||||
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')]
|
||||
public function index(): Response
|
||||
{
|
||||
$accommodations = $this->accommodationRepository->findBy([], ['code' => 'ASC']);
|
||||
$accommodations = $this->accommodationRepository->findBy([], ['calendarCode' => 'ASC']);
|
||||
|
||||
return $this->render('admin/accommodation/index.html.twig', [
|
||||
'accommodations' => $accommodations,
|
||||
|
||||
@@ -40,7 +40,7 @@ class CreateController extends AbstractController
|
||||
|
||||
$this->logger->info('Created accommodation price', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
'date_range' => [
|
||||
'from' => $accommodationPrice->getDateFrom()->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', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
'date_range' => [
|
||||
'from' => $accommodationPrice->getDateFrom()->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', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
'date_range' => [
|
||||
'from' => $accommodationPrice->getDateFrom()->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', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
'label' => $additionalService->getLabel(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class DeleteController extends AbstractController
|
||||
|
||||
$this->logger->info('Deleted additional service', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
'label' => $additionalService->getLabel(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class EditController extends AbstractController
|
||||
|
||||
$this->logger->info('Edited additional service', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
'label' => $additionalService->getLabel(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class CreateController extends AbstractController
|
||||
|
||||
$this->logger->info('Created board service', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
'label' => $boardService->getLabel(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class DeleteController extends AbstractController
|
||||
|
||||
$this->logger->info('Deleted board service', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
'label' => $boardService->getLabel(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class EditController extends AbstractController
|
||||
|
||||
$this->logger->info('Edited board service', [
|
||||
'name' => $accommodation->getName(),
|
||||
'code' => $accommodation->getCode(),
|
||||
'code' => $accommodation->getCalendarCode(),
|
||||
'label' => $boardService->getLabel(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ class ContingentController extends AbstractController
|
||||
'priceAdditionalPerson' => null !== $price ? round($price->getPriceAdditionalPerson() / 100, 2) : null,
|
||||
'priceAdditionalPersonOverride' => null !== $price?->getPriceAdditionalPersonOverride() ? round($price->getPriceAdditionalPersonOverride() / 100, 2) : null,
|
||||
'includedPax' => $price?->getIncludedPax(),
|
||||
'minPax' => $price?->getAccommodation()->getMinPaxSummer(),
|
||||
'minNights' => $price?->getMinNights(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -29,7 +29,10 @@ class Accommodation implements BlameableEntityInterface, TimestampableEntityInte
|
||||
|
||||
#[ORM\Column(length: 16, unique: true)]
|
||||
#[Assert\NotBlank(message: 'required')]
|
||||
private ?string $code = null;
|
||||
private ?string $calendarCode = null;
|
||||
|
||||
#[ORM\Column(length: 16, nullable: true)]
|
||||
private ?string $cmsCode = null;
|
||||
|
||||
#[ORM\Column]
|
||||
#[Assert\NotNull(message: 'required')]
|
||||
@@ -89,18 +92,35 @@ class Accommodation implements BlameableEntityInterface, TimestampableEntityInte
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return $this->minPaxSummer;
|
||||
|
||||
@@ -20,14 +20,18 @@ class AccommodationType extends AbstractType
|
||||
->add('name', TextType::class, [
|
||||
'label' => 'Name',
|
||||
])
|
||||
->add('code', TextType::class, [
|
||||
'label' => 'Code',
|
||||
->add('calendarCode', TextType::class, [
|
||||
'label' => 'Code für Kalender',
|
||||
])
|
||||
->add('cmsCode', TextType::class, [
|
||||
'label' => 'Code für CMS-Daten',
|
||||
'required' => false,
|
||||
])
|
||||
->add('minPaxSummer', IntegerType::class, [
|
||||
'label' => 'Mindestbelegung Sommer',
|
||||
])
|
||||
->add('maxAdolescentAge', IntegerType::class, [
|
||||
'label' => 'Altersgrenze Jugendliche R',
|
||||
'label' => 'Altersgrenze Jugendliche',
|
||||
])
|
||||
->add('currency', ChoiceType::class, [
|
||||
'label' => 'Währung',
|
||||
|
||||
@@ -31,7 +31,7 @@ class AccommodationPriceRepository extends ServiceEntityRepository
|
||||
): array {
|
||||
return $this->createQueryBuilder('ap')
|
||||
->join('ap.accommodation', 'a')
|
||||
->where('a.code = :hotelCode')
|
||||
->where('a.calendarCode = :hotelCode')
|
||||
->andWhere('ap.dateFrom <= :dateTo')
|
||||
->andWhere('ap.dateTo >= :dateFrom')
|
||||
->setParameter('hotelCode', $hotelCode)
|
||||
|
||||
@@ -61,7 +61,7 @@ class Calendar
|
||||
|
||||
$map = $this->buildCoverageMap();
|
||||
$blockedDates = $this->fetchBlockedDates(
|
||||
$accommodation->getCode() ?? '',
|
||||
$accommodation->getCalendarCode() ?? '',
|
||||
$start->format('Y-m-d'),
|
||||
$start->addMonths(3)->subDay()->format('Y-m-d'),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user