From 4c7ddefb4398ad346e26d7ec2b6c6a8e03ad1045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 31 May 2024 15:00:23 +0200 Subject: [PATCH] feat: hide included services column in tables when not applicable --- .../Controller/AjaxTableController.php | 25 +++-- .../Classes/Service/DateService.php | 14 +++ .../Private/Partials/Pricetable.html | 48 ++++---- .../Templates/AjaxTable/Datestable.html | 104 +++++++++--------- .../Templates/AjaxTable/Pricetable.html | 96 ++++++++-------- 5 files changed, 161 insertions(+), 126 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Controller/AjaxTableController.php b/public/typo3conf/ext/ep_products/Classes/Controller/AjaxTableController.php index e7417e00..3558839d 100644 --- a/public/typo3conf/ext/ep_products/Classes/Controller/AjaxTableController.php +++ b/public/typo3conf/ext/ep_products/Classes/Controller/AjaxTableController.php @@ -194,6 +194,7 @@ class AjaxTableController extends ActionController } $hasSurchargeOrDiscount = $this->dateService->checkSurcharcheOrDiscount($allDates); + $hasIncludedServices = $this->dateService->hasIncludedServices($allDates); $noInfoConceptUids = GeneralUtility::trimExplode(',', $this->settings['noInfoConceptUids']); $isProductWithNoInfoConcept = ($product->getConcept() !== null) && \in_array($product->getConcept()->getUid(), $noInfoConceptUids, false); @@ -209,6 +210,7 @@ class AjaxTableController extends ActionController 'hotel' => $hotel, 'altProductLink' => $altProductLink, 'altLabel' => $altLabel, + 'hasIncludedServices' => $hasIncludedServices, 'hasSurcharge' => $hasSurchargeOrDiscount['surcharge'], 'hasDiscount' => $hasSurchargeOrDiscount['discount'], 'isProductWithNoInfoConcept' => $isProductWithNoInfoConcept, @@ -244,14 +246,14 @@ class AjaxTableController extends ActionController 'paCode' => GeneralUtility::_GET('pa'), ]); $hasSurchargeOrDiscount = $this->dateService->checkSurcharcheOrDiscount($priceTable); + $hasIncludedServices = $this->dateService->hasIncludedServices($priceTable); $dateStart = $date ? $date->getDateStart()->format('d.m.y') : ''; $dateEnd = $date ? $date->getDateEnd()->format('d.m.y') : ''; $dateRange = sprintf('%s - %s', $dateStart, $dateEnd); $noInfoConceptUids = GeneralUtility::trimExplode(',', $this->settings['noInfoConceptUids']); - $isProductWithNoInfoConcept = ($product->getConcept() !== null) && \in_array($product->getConcept()->getUid(), - $noInfoConceptUids, false); + $isProductWithNoInfoConcept = ($product->getConcept() !== null) && \in_array($product->getConcept()->getUid(), $noInfoConceptUids); $nonBookableInfo = $this->getNonBookableInfobox($product); @@ -262,6 +264,7 @@ class AjaxTableController extends ActionController 'servicesIncluded' => $date->getServicesIncluded(), 'prices' => $priceTable, 'unavailable' => count($priceTable) === 0, + 'hasIncludedServices' => $hasIncludedServices, 'hasSurcharge' => $hasSurchargeOrDiscount['surcharge'], 'hasDiscount' => $hasSurchargeOrDiscount['discount'], 'isProductWithNoInfoConcept' => $isProductWithNoInfoConcept, @@ -286,7 +289,7 @@ class AjaxTableController extends ActionController $nonBookableInfo = $this->getNonBookableInfobox($product); - $pricetable = $this->dateService->getPriceTable([ + $priceTable = $this->dateService->getPriceTable([ 'product' => $product, 'hotel' => $hotel, 'filterSettings' => $this->filterService->getNormalizedFilterSettings(), @@ -294,10 +297,14 @@ class AjaxTableController extends ActionController 'paCode' => $paCode, 'sortByRoom' => true, ]); + $hasIncludedServices = $this->dateService->hasIncludedServices($priceTable); - $this->view->assign('pricetable', $pricetable); - $this->view->assign('nonBookableInfo', $nonBookableInfo); - $this->view->assign('bpnBookingUrlTemplateCode', $bpnBookingUrlTemplateCode ?? $this->settings['bpnBookingUrlTemplateCode']); + $this->view->assignMultiple([ + 'pricetable' => $priceTable, + 'hasIncludedServices' => $hasIncludedServices, + 'nonBookableInfo' => $nonBookableInfo, + 'bpnBookingUrlTemplateCode' => $bpnBookingUrlTemplateCode ?? $this->settings['bpnBookingUrlTemplateCode'], + ]); } /** @@ -319,7 +326,8 @@ class AjaxTableController extends ActionController }, $roomTypes); $maxPax = max($roomTypesPax); $template = $this->settings['bpnBookingUrlTemplateCode']; - $pricetable = $this->dateService->getEventPriceTable($product, $maxPax, $template); + $priceTable = $this->dateService->getEventPriceTable($product, $maxPax, $template); + $hasIncludedServices = $this->dateService->hasIncludedServices($priceTable); $nonBookableInfo = $this->getNonBookableInfobox($product); $categories = [ Hotel::CATEGORY_STANDARD => 'Standard', @@ -330,7 +338,8 @@ class AjaxTableController extends ActionController $this->view->assignMultiple([ 'roomTypesPax' => $roomTypesPax, 'roomTypesLabels' => $roomTypesLabels, - 'pricetable' => $pricetable, + 'pricetable' => $priceTable, + 'hasIncludedServices' => $hasIncludedServices, 'categories' => $categories, 'themekey' => $this->settings['themekey'], 'nonBookableInfo' => $nonBookableInfo, diff --git a/public/typo3conf/ext/ep_products/Classes/Service/DateService.php b/public/typo3conf/ext/ep_products/Classes/Service/DateService.php index c3ad5889..4dc288d6 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/DateService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/DateService.php @@ -410,6 +410,20 @@ class DateService implements SingletonInterface return $priceTable; } + public function hasIncludedServices(array $tableData): bool + { + $included = false; + + foreach ($tableData as $row) { + if ($row['busIncluded'] || $row['skipassIncluded']) { + $included = true; + break; + } + } + + return $included; + } + public function checkSurcharcheOrDiscount(array $tableData): array { $data = [ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Pricetable.html b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Pricetable.html index 8076c1ed..67ca036a 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Pricetable.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Pricetable.html @@ -22,9 +22,11 @@ Preis/Pers. - - inkl. - + + + inkl. + + @@ -58,25 +60,27 @@ - - - - {ep:icon(icon: 'bus', class: 'w-4 h-4 md:w-5 md:h-5')} - - - - - {ep:icon(icon: 'tag', class: 'w-4 h-4 md:w-5 md:h-5')} - - - + + + + + {ep:icon(icon: 'bus', class: 'w-4 h-4 md:w-5 md:h-5')} + + + + + {ep:icon(icon: 'tag', class: 'w-4 h-4 md:w-5 md:h-5')} + + + + - - - + + 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 44bfa8c7..5ad353e2 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 @@ -28,14 +28,16 @@ Zimmertyp {dateRange} - - - inkl. - - - + + + + inkl. + + + + optional @@ -71,45 +73,47 @@ - -
-
- - - - - - - - - - - - - - - - - - - - - - - - + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
-
- + +