From d6df7ba552cfdb065fa2c11bc2cc98c305ffe41d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 22 Apr 2025 14:34:00 +0200 Subject: [PATCH] feat: render price table rows separately in regard of availability closes #8698te15z --- .../Domain/Repository/ProductRepository.php | 15 +- .../Classes/Service/DateService.php | 14 +- .../Templates/AjaxTable/Pricetable.html | 256 +++++++++--------- 3 files changed, 147 insertions(+), 138 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php index 3753dfa4..9cfd8df9 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php @@ -191,7 +191,7 @@ class ProductRepository extends AbstractRepository ; } - public function getPricetable(Product $product, Hotel $hotel, array $filterSettings, Date $date = null, bool $sortByRoom = true): array + public function getPricetable(Product $product, Hotel $hotel, array $filterSettings, Date $date = null): array { $qb = $this->getDbConnection()->createQueryBuilder(); @@ -207,18 +207,11 @@ class ProductRepository extends AbstractRepository ) ->from('tx_epproducts_domain_model_date', 'date') ->innerJoin('date', 'tx_epproducts_domain_model_room', 'room', 'date.uid = room.date') - ->orderBy('room.available', 'DESC') + ->orderBy('room.pax', 'ASC') + ->addOrderBy('room.price', 'ASC') + ->addOrderBy('room.available', 'DESC') ; - if (true === $sortByRoom) { - $qb->addOrderBy('room.name', 'ASC'); - } else { - $qb - ->addOrderBy('room.pax', 'ASC') - ->addOrderBy('room.price', 'ASC') - ; - } - $qb ->where('date.date_start >= NOW()') ->andWhere($qb->expr()->eq( diff --git a/public/typo3conf/ext/ep_products/Classes/Service/DateService.php b/public/typo3conf/ext/ep_products/Classes/Service/DateService.php index 03661b1a..c8d90af7 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/DateService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/DateService.php @@ -109,7 +109,6 @@ class DateService implements SingletonInterface $date = $resolvedOptions['date']; $template = $resolvedOptions['template']; $paCode = $resolvedOptions['paCode']; - $sortByRoom = $resolvedOptions['sortByRoom']; if ($filterSettings === null) { $filterSettings = $this->filterService->getNormalizedFilterSettings(); @@ -118,7 +117,7 @@ class DateService implements SingletonInterface $nonBookableDateUids = GeneralUtility::trimExplode(',', $product->getNonBookableDates(), true); return $this->preprocessPriceTable([ - 'priceTableData' => $this->productRepository->getPricetable($product, $hotel, $filterSettings, $date, $sortByRoom), + 'priceTableData' => $this->productRepository->getPricetable($product, $hotel, $filterSettings, $date), 'template' => $template, 'paCode' => $paCode, 'isDayTrip' => $product->isDaytrip(), @@ -188,7 +187,11 @@ class DateService implements SingletonInterface $resolver->setDefault('isDayTrip', false); $resolver->setDefault('showBookingButton', true); $resolvedOptions = $resolver->resolve($options); - $priceTable = []; + + $priceTable = [ + 'available' => [], + 'unavailable' => [], + ]; $priceTableData = $resolvedOptions['priceTableData']; $template = $resolvedOptions['template']; @@ -210,7 +213,10 @@ class DateService implements SingletonInterface 'isDayTrip' => $isDayTrip, ]); $optionalServices = $this->preprocessOptionalServices(unserialize($row['roomOptionalServices'], ['allowed_classes' => false])); - $priceTable[] = [ + + $key = $row['roomAvailable'] && $row['roomPrice'] ? 'available' : 'unavailable'; + + $priceTable[$key][] = [ 'dateStart' => $dateStart->format('d.m.Y'), 'dateEnd' => $dateEnd->format('d.m.Y'), 'season' => $row['season'], diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/AjaxTable/Pricetable.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/AjaxTable/Pricetable.html index f9ffae3e..f6b1b9a5 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/AjaxTable/Pricetable.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/AjaxTable/Pricetable.html @@ -47,129 +47,17 @@ - - - - - - - {row.roomName} - - - - - {row.roomName} - - - - ausgebucht - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - - - - - - - - - - {row.minPrice} - - - - - - {row.minPrice} € - - - - - - - Reisen-Alert - - - - - + + + + + + @@ -307,4 +195,126 @@ + + + + + + + {row.roomName} + + + + {row.roomName} + + + ausgebucht + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + + + + + + + + + + + {row.minPrice} + + + + + + {row.minPrice} € + + + + + + + Reisen-Alert + + + + + +