From e8821db3547b9d12789e9e60b319918e34ce58e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Sat, 29 Sep 2018 17:47:22 +0200 Subject: [PATCH] Import included services for daytrips --- .../Controller/AjaxContingentController.php | 2 + .../Repository/ContingentRepository.php | 3 +- .../Classes/Service/ContingentDataService.php | 1 + .../Classes/Service/DateImportService.php | 42 ++++++++++++++----- web/typo3conf/ext/ep_products/ext_tables.sql | 1 + 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/web/typo3conf/ext/ep_products/Classes/Controller/AjaxContingentController.php b/web/typo3conf/ext/ep_products/Classes/Controller/AjaxContingentController.php index 466b2117..0df8bd88 100644 --- a/web/typo3conf/ext/ep_products/Classes/Controller/AjaxContingentController.php +++ b/web/typo3conf/ext/ep_products/Classes/Controller/AjaxContingentController.php @@ -75,6 +75,7 @@ class AjaxContingentController extends ActionController * @param Hotel $hotel * @param Product $product * @return string + * @throws \Doctrine\DBAL\DBALException */ public function listAction(Hotel $hotel, Product $product) { @@ -89,6 +90,7 @@ class AjaxContingentController extends ActionController * @param \DateTime $dateFrom * @param \DateTime $dateTo * @return string + * @throws \Doctrine\DBAL\DBALException */ public function roomsAction(Hotel $hotel, Product $product, \DateTime $dateFrom, \DateTime $dateTo) { diff --git a/web/typo3conf/ext/ep_products/Classes/Domain/Repository/ContingentRepository.php b/web/typo3conf/ext/ep_products/Classes/Domain/Repository/ContingentRepository.php index 30ba8c8b..5c8947f7 100644 --- a/web/typo3conf/ext/ep_products/Classes/Domain/Repository/ContingentRepository.php +++ b/web/typo3conf/ext/ep_products/Classes/Domain/Repository/ContingentRepository.php @@ -138,7 +138,8 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa $qb ->select('c.room_code as code', 'c.room_label as label', 'c.available as available', 'c.min_price as price', - 'c.hotel_bus_pro_id as hotelBusProId', 'd.bus_pro_id as busProId') + 'c.hotel_bus_pro_id as hotelBusProId', + 'd.bus_pro_id as busProId', 'd.services_included as servicesIncluded') ->from('tx_epproducts_domain_model_contingent', 'c') ->innerJoin('c', 'tx_epproducts_domain_model_daytrip', 'd', 'c.date = d.date AND c.hotel_code = d.hotel_code') ->where('c.hotel = :hotelUid') diff --git a/web/typo3conf/ext/ep_products/Classes/Service/ContingentDataService.php b/web/typo3conf/ext/ep_products/Classes/Service/ContingentDataService.php index 87812a7c..6686ffdd 100644 --- a/web/typo3conf/ext/ep_products/Classes/Service/ContingentDataService.php +++ b/web/typo3conf/ext/ep_products/Classes/Service/ContingentDataService.php @@ -53,6 +53,7 @@ class ContingentDataService * @param Hotel $hotel * @param Product $product * @return array + * @throws \Doctrine\DBAL\DBALException */ public function getAvailableRooms(\DateTime $dateFrom, \DateTime $dateTo, Hotel $hotel, Product $product) { diff --git a/web/typo3conf/ext/ep_products/Classes/Service/DateImportService.php b/web/typo3conf/ext/ep_products/Classes/Service/DateImportService.php index e4585509..71d7a704 100644 --- a/web/typo3conf/ext/ep_products/Classes/Service/DateImportService.php +++ b/web/typo3conf/ext/ep_products/Classes/Service/DateImportService.php @@ -315,6 +315,12 @@ class DateImportService implements SingletonInterface { static $datesAdded = []; + $skiPass = $this->parseSelectionGroup($xmlDate, 'Leistungen Skipass'); + $servicesBoard = $this->parseSelectionGroup($xmlDate, 'Leistungen Verpflegung'); + $servicesIncluded = $this->parseSelectionGroup($xmlDate, 'Leistungen Sonstige'); + + $servicesCombined = serialize($this->combineServices($skiPass, $servicesBoard, $servicesIncluded)); + foreach ($xmlDate->hotel as $xmlHotel) { $hotelCode = (string) $xmlHotel->attributes()['code']; @@ -335,6 +341,7 @@ class DateImportService implements SingletonInterface 'hotel' => $hotel['uid'], 'hotel_bus_pro_id' => (int) $xmlHotel->attributes()['idbuspro'], 'hotel_code' => $hotelCode, + 'services_included' => $servicesCombined, ] ); } @@ -391,17 +398,8 @@ class DateImportService implements SingletonInterface $skiPass = $this->parseSelectionGroup($xmlDate, 'Leistungen Skipass'); $servicesBoard = $this->parseSelectionGroup($xmlDate, 'Leistungen Verpflegung'); $servicesIncluded = $this->parseSelectionGroup($xmlDate, 'Leistungen Sonstige'); - $combinedServices = []; - if ($skiPass) { - array_push($combinedServices, ...$skiPass); - } - if ($servicesBoard) { - array_push($combinedServices, ...$servicesBoard); - } - if ($servicesIncluded) { - array_push($combinedServices, ...$servicesIncluded); - } - $date['services_included'] = serialize($combinedServices); + + $date['services_included'] = serialize($this->combineServices($skiPass, $servicesBoard, $servicesIncluded)); if ($servicesBoard) { $date['board'] = reset($servicesBoard); @@ -478,6 +476,28 @@ class DateImportService implements SingletonInterface return $date; } + /** + * @param array $skiPass + * @param array $servicesBoard + * @param array $servicesIncluded + * @return array + */ + protected function combineServices(array $skiPass, array $servicesBoard, array $servicesIncluded) + { + $combinedServices = []; + if ($skiPass) { + array_push($combinedServices, ...$skiPass); + } + if ($servicesBoard) { + array_push($combinedServices, ...$servicesBoard); + } + if ($servicesIncluded) { + array_push($combinedServices, ...$servicesIncluded); + } + + return $combinedServices; + } + /** * @param \SimpleXMLElement $xmlHotel * @param array $date diff --git a/web/typo3conf/ext/ep_products/ext_tables.sql b/web/typo3conf/ext/ep_products/ext_tables.sql index cecb4b2a..e0b6a272 100644 --- a/web/typo3conf/ext/ep_products/ext_tables.sql +++ b/web/typo3conf/ext/ep_products/ext_tables.sql @@ -1000,6 +1000,7 @@ CREATE TABLE tx_epproducts_domain_model_daytrip ( hotel int(11) unsigned DEFAULT '0', hotel_bus_pro_id varchar(64) DEFAULT '' NOT NULL, hotel_code varchar(64) DEFAULT '' NOT NULL, + services_included TEXT NOT NULL, tstamp int(11) unsigned DEFAULT '0' NOT NULL, crdate int(11) unsigned DEFAULT '0' NOT NULL,