From 9aaf5708dc028aaba6a0d6726c0d1c7c3eeb71d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Fri, 20 Aug 2021 14:42:57 +0200 Subject: [PATCH 1/5] Translate button --- .../ep_theme/Resources/Private/Language/de.locallang.xlf | 3 +++ .../ext/ep_theme/Resources/Private/Language/locallang.xlf | 3 +++ .../ep_theme/Resources/Private/Templates/City/Detail.html | 6 ++++-- .../Resources/Private/Templates/Concept/Detail.html | 4 ++-- .../Resources/Private/Templates/Country/Detail.html | 4 ++-- .../ep_theme/Resources/Private/Templates/Hotel/Detail.html | 4 ++-- .../ep_theme/Resources/Private/Templates/Region/Detail.html | 4 ++-- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf b/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf index 90e9f732..06b0ce3f 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf @@ -44,6 +44,9 @@ Details + + Direkt zu den Angeboten + Lineup diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf b/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf index 7e8dbfb2..65b09ac5 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf @@ -43,6 +43,9 @@ Details + + Inquiry Form + Lineup diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/City/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/City/Detail.html index 0ba426b4..93041f76 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/City/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/City/Detail.html @@ -13,7 +13,9 @@ @@ -28,7 +30,7 @@
- + diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Concept/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Concept/Detail.html index fdd30673..4f470b65 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Concept/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Concept/Detail.html @@ -14,7 +14,7 @@ @@ -55,7 +55,7 @@ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Country/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Country/Detail.html index 6562a42a..9a2677ea 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Country/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Country/Detail.html @@ -14,7 +14,7 @@ @@ -56,7 +56,7 @@
- +
diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Hotel/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Hotel/Detail.html index 8304545c..8e1c0ed4 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Hotel/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Hotel/Detail.html @@ -13,7 +13,7 @@ @@ -29,7 +29,7 @@
- + diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Region/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Region/Detail.html index aeb551b0..61f99f07 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Region/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Region/Detail.html @@ -14,7 +14,7 @@ @@ -32,7 +32,7 @@ From e1fda8981c78c34956eebf320968c49d6381e806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Fri, 20 Aug 2021 14:50:59 +0200 Subject: [PATCH 2/5] Revoke translation of buttons This reverts commit 14a114ebd744fc56ae0d9f5c4be1c099017d813d, reversing changes made to c40b25c812c1765aaefc2f6e910ea75e34c74e8a. --- .../ep_theme/Resources/Private/Language/de.locallang.xlf | 3 --- .../ext/ep_theme/Resources/Private/Language/locallang.xlf | 3 --- .../ep_theme/Resources/Private/Templates/City/Detail.html | 6 ++---- .../Resources/Private/Templates/Concept/Detail.html | 4 ++-- .../Resources/Private/Templates/Country/Detail.html | 4 ++-- .../ep_theme/Resources/Private/Templates/Hotel/Detail.html | 4 ++-- .../ep_theme/Resources/Private/Templates/Region/Detail.html | 4 ++-- 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf b/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf index 06b0ce3f..90e9f732 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf @@ -44,9 +44,6 @@ Details - - Direkt zu den Angeboten - Lineup diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf b/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf index 65b09ac5..7e8dbfb2 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf @@ -43,9 +43,6 @@ Details - - Inquiry Form - Lineup diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/City/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/City/Detail.html index 93041f76..0ba426b4 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/City/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/City/Detail.html @@ -13,9 +13,7 @@ @@ -30,7 +28,7 @@
- + diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Concept/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Concept/Detail.html index 4f470b65..fdd30673 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Concept/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Concept/Detail.html @@ -14,7 +14,7 @@ @@ -55,7 +55,7 @@ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Country/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Country/Detail.html index 9a2677ea..6562a42a 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Country/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Country/Detail.html @@ -14,7 +14,7 @@ @@ -56,7 +56,7 @@
- +
diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Hotel/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Hotel/Detail.html index 8e1c0ed4..8304545c 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Hotel/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Hotel/Detail.html @@ -13,7 +13,7 @@ @@ -29,7 +29,7 @@
- + diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Region/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Region/Detail.html index 61f99f07..aeb551b0 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Region/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Region/Detail.html @@ -14,7 +14,7 @@ @@ -32,7 +32,7 @@ From 18394fa2980f7e60a7de848f74414314815776f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Fri, 20 Aug 2021 14:53:24 +0200 Subject: [PATCH 3/5] Translate button --- .../ext/ep_theme/Resources/Private/Language/de.locallang.xlf | 3 +++ .../ext/ep_theme/Resources/Private/Language/locallang.xlf | 3 +++ .../ep_theme/Resources/Private/Templates/Product/Detail.html | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf b/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf index 90e9f732..958fee3d 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf @@ -44,6 +44,9 @@ Details + + Direkt zum Anfrageformular + Lineup diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf b/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf index 7e8dbfb2..65b09ac5 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf @@ -43,6 +43,9 @@ Details + + Inquiry Form + Lineup diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Product/Detail.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Product/Detail.html index 313af297..07da9f44 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Product/Detail.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Product/Detail.html @@ -282,7 +282,7 @@ - Direkt zum Anfrageformular + From 6a3c4d92ea88ff6dde6936878c158e573d83d3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Mon, 23 Aug 2021 15:58:30 +0200 Subject: [PATCH 4/5] Respect contingents of linked products --- .../Classes/Command/ContingentCommand.php | 3 +- .../Service/ContingentImportService.php | 55 +++++++++++++------ .../Classes/Task/ImportContingentsTask.php | 3 +- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Command/ContingentCommand.php b/public/typo3conf/ext/ep_products/Classes/Command/ContingentCommand.php index dd14d2ca..e84329e2 100644 --- a/public/typo3conf/ext/ep_products/Classes/Command/ContingentCommand.php +++ b/public/typo3conf/ext/ep_products/Classes/Command/ContingentCommand.php @@ -66,8 +66,7 @@ class ContingentCommand extends Command */ public function execute(InputInterface $input, OutputInterface $output) { - $path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexportzimmer'); - $count = $this->contingentImportService->import($path); + $count = $this->contingentImportService->import(); $output->writeln(sprintf('%d rows imported.', $count )); return 0; diff --git a/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php b/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php index 6dc2b363..ba784a21 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php @@ -41,7 +41,8 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac use LoggerAwareTrait; use DbConnectionTrait; - const ROOMCODE_STATUS = 'BelKal'; + public const XML_PATH = 'fileadmin/xmlexportzimmer'; + public const ROOMCODE_STATUS = 'BelKal'; /** * @var string[] @@ -83,15 +84,14 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac } /** - * @param string $path * @return int * @throws \Doctrine\DBAL\DBALException */ - public function import($path) + public function import() { $this->createTempTable(); $this->logger->info('starting product import'); - $contingentCount = $this->parseXmlFilesInFolder($path); + $contingentCount = $this->parseXmlFilesInFolder(); $this->clearTable(); $this->copyTable(); $this->clearTempTable(); @@ -109,35 +109,47 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac } /** - * @param string $path * @return int */ - public function parseXmlFilesInFolder($path) + public function parseXmlFilesInFolder() { $dateCount = 0; + $path = GeneralUtility::getFileAbsFileName(self::XML_PATH); $folder = opendir($path); while (($fileName = readdir($folder)) !== false) { if (strpos($fileName, 'HotelZimmer') === 0) { - $filePath = $path . '/' . $fileName; - $dateCount += $this->parseContingentXmlFile($filePath); + $dateCount += $this->parseContingentXmlFile($path, $fileName); } } + return $dateCount; } /** - * @param string $file + * @param string $fileName * @return int */ - public function parseContingentXmlFile($file) + public function parseContingentXmlFile($path, $fileName) + { + $filePath = sprintf('%s/%s', $path , $fileName); + + if (null === $xmlData = $this->loadXmlFile($filePath)) { + return 0; + } + + return $this->parseContingent($xmlData); + } + + public function loadXmlFile($file): ?\SimpleXMLElement { libxml_use_internal_errors (true); /** @var \SimpleXMLElement $xmlData */ if (!$xmlData = simplexml_load_string(file_get_contents($file))) { libxml_clear_errors(); - return 0; + return null; } - return $this->parseContingent($xmlData); + + return $xmlData; } /** @@ -179,9 +191,9 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac protected function parseContingent(\SimpleXMLElement $xmlContingent) { $hotelCode = (string) $xmlContingent['code']; - $sql = 'SELECT h.uid uid - FROM tx_epproducts_domain_model_hotel h - LEFT JOIN tx_epproducts_domain_model_matchcode m ON (h.uid = m.entity AND m.entity_type = "hotel" AND m.deleted = 0) + $sql = 'SELECT h.uid uid + FROM tx_epproducts_domain_model_hotel h + LEFT JOIN tx_epproducts_domain_model_matchcode m ON (h.uid = m.entity AND m.entity_type = "hotel" AND m.deleted = 0) WHERE h.deleted = 0 AND h.hidden = 0 AND h.code = :code OR m.code = :code LIMIT 0,1'; $hotelData = $this->db->fetchAssoc($sql, ['code' => $hotelCode]); @@ -192,14 +204,21 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac return 0; } + $hotelData['busProId'] = (string) $xmlContingent['idbuspro']; + $hotelData['code'] = (string) $xmlContingent['code']; + $roomTypes = $this->parseRoomTypes($xmlContingent->unterbringungen); + + if ($xmlContingent->idbuspro_kontingent_aus) { + $linkedProductId = (int)$xmlContingent->idbuspro_kontingent_aus; + $path = GeneralUtility::getFileAbsFileName(self::XML_PATH); + $xmlContingent = $this->loadXmlFile(sprintf('%s/HotelZimmer_%d.xml', $path, $linkedProductId)); + } + if (empty($xmlContingent->kapazitaeten)) { $this->logger->warning('hotel has no contingents', ['code' => $hotelCode]); return 0; } - $hotelData['busProId'] = (string) $xmlContingent['idbuspro']; - $hotelData['code'] = $hotelCode; - $roomTypes = $this->parseRoomTypes($xmlContingent->unterbringungen); return $this->parseRooms($xmlContingent->kapazitaeten, $hotelData, $roomTypes); } diff --git a/public/typo3conf/ext/ep_products/Classes/Task/ImportContingentsTask.php b/public/typo3conf/ext/ep_products/Classes/Task/ImportContingentsTask.php index 6d5c062a..b9aeaa28 100644 --- a/public/typo3conf/ext/ep_products/Classes/Task/ImportContingentsTask.php +++ b/public/typo3conf/ext/ep_products/Classes/Task/ImportContingentsTask.php @@ -41,8 +41,7 @@ class ImportContingentsTask extends AbstractTask /** @var \EP\EpProducts\Service\ContingentImportService $importService */ $importService = $objectManager->get(ContingentImportService::class); if ($importService->isImportRequired()) { - $path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexportzimmer'); - $importService->import($path); + $importService->import(); } return true; From 54c683702c761b81f1b445c6f29d37f07a30f4dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Mon, 23 Aug 2021 16:13:01 +0200 Subject: [PATCH 5/5] Use room config of linked product on contingent import --- .../ep_products/Classes/Service/ContingentImportService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php b/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php index ba784a21..be19c903 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php @@ -206,7 +206,6 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac $hotelData['busProId'] = (string) $xmlContingent['idbuspro']; $hotelData['code'] = (string) $xmlContingent['code']; - $roomTypes = $this->parseRoomTypes($xmlContingent->unterbringungen); if ($xmlContingent->idbuspro_kontingent_aus) { $linkedProductId = (int)$xmlContingent->idbuspro_kontingent_aus; @@ -219,6 +218,8 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac return 0; } + $roomTypes = $this->parseRoomTypes($xmlContingent->unterbringungen); + return $this->parseRooms($xmlContingent->kapazitaeten, $hotelData, $roomTypes); }