diff --git a/web/typo3conf/ext/ep_products/Classes/Domain/Model/Date.php b/web/typo3conf/ext/ep_products/Classes/Domain/Model/Date.php index b80ea8d4..0d485b99 100644 --- a/web/typo3conf/ext/ep_products/Classes/Domain/Model/Date.php +++ b/web/typo3conf/ext/ep_products/Classes/Domain/Model/Date.php @@ -108,6 +108,11 @@ class Date extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity */ protected $servicesGeneral = ''; + /** + * @var string + */ + protected $pickups = ''; + /** * @var int */ @@ -368,6 +373,22 @@ class Date extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity $this->servicesGeneral = serialize($servicesGeneral); } + /** + * @return string + */ + public function getPickups() + { + return unserialize($this->pickups); + } + + /** + * @param array $pickups + */ + public function setPickups(array $pickups) + { + $this->pickups = serialize($pickups); + } + /** * @return int */ diff --git a/web/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php b/web/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php index d79c4fd6..25dbbef6 100644 --- a/web/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php +++ b/web/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php @@ -257,7 +257,7 @@ class ProductRepository extends AbstractRepository 'date.min_price dateMinPrice', 'date.discount dateDiscount', 'date.bus_price busPrice', 'date.nights dateNights', 'date.bus_included dateBusIncluded', 'date.services_included dateServicesIncluded', 'date.services_general dateServicesGeneral', 'date.skipass_included dateSkipassIncluded', - 'date.bus_pro_id dateBusProId', 'date.hotel_bus_pro_id hotelBusProId', + 'date.bus_pro_id dateBusProId', 'date.hotel_bus_pro_id hotelBusProId', 'date.pickups pickups', 'room.uid as roomUid', 'room.bus_pro_id roomBusProId', 'room.name roomName', 'room.price roomPrice', 'date.discount roomDiscount', 'date.bus_price busPrice', 'room.services roomOptionalServices', 'room.nights roomNights', 'room.available roomAvailable' diff --git a/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Date.php b/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Date.php index d95e52a2..3845e4d1 100644 --- a/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Date.php +++ b/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Date.php @@ -74,6 +74,11 @@ class Date */ public $rooms = []; + /** + * @var array + */ + public $pickups = []; + /** * @var string */ @@ -100,6 +105,11 @@ class Date $date->services['service'][] = Service::fromArray($row); } + foreach (unserialize($array['pickups']) as $row) + { + $date->pickups['pickup'][] = Pickup::fromArray($row); + } + return $date; } diff --git a/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Pickup.php b/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Pickup.php new file mode 100644 index 00000000..cd4c0413 --- /dev/null +++ b/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Pickup.php @@ -0,0 +1,67 @@ +, dreipunktnull + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +class Pickup +{ + + /** + * @var string + */ + public $city; + + /** + * @var string + */ + public $street; + + /** + * @var string + */ + public $time; + + /** + * @var float + */ + public $price; + + /** + * @param array $array + * @return Pickup + */ + public static function fromArray(array $array) + { + $pickup = new self; + + $pickup->city = $array['city']; + $pickup->street = $array['street']; + $pickup->time = $array['time']; + $pickup->price = $array['price']; + + return $pickup; + } +} diff --git a/web/typo3conf/ext/ep_products/Classes/Service/ImportService.php b/web/typo3conf/ext/ep_products/Classes/Service/ImportService.php index 3089a338..18edb358 100644 --- a/web/typo3conf/ext/ep_products/Classes/Service/ImportService.php +++ b/web/typo3conf/ext/ep_products/Classes/Service/ImportService.php @@ -66,6 +66,11 @@ class ImportService implements SingletonInterface */ protected $hotelMappings = []; + /** + * @var array + */ + protected $pickups = []; + /** * @var Connection */ @@ -111,6 +116,7 @@ class ImportService implements SingletonInterface $this->logger = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class)->getLogger(__CLASS__); $this->getRoomMappings(); $this->getHotelMappings(); + $this->importPickups(); $this->createTempTables(); $this->logger->info('starting product import'); $dateCount = $this->parseXmlFilesInFolder($path); @@ -394,6 +400,23 @@ class ImportService implements SingletonInterface } $date['services_general'] = serialize($combinedServices); + $pickups = []; + foreach ($xmlDate->xpath('zustiege/zustieg') as $pickup) + { + $attributes = $pickup->attributes(); + $busProId = (int) $attributes['idbuspro']; + if ($busProId === 0) { + continue; + } + $pickups[] = [ + 'city' => $this->pickups[$busProId]['city'], + 'street' => $this->pickups[$busProId]['street'], + 'price' => (float) str_replace(',', '.', (string) $attributes['preis']), + 'time' => (string) $attributes['zeit'], + ]; + } + $date['pickups'] = serialize($pickups); + return $date; } @@ -736,4 +759,20 @@ class ImportService implements SingletonInterface $list[$key] = array_merge($list[$key], $section); } } + + protected function importPickups() + { + $path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexport/zustiege.xml'); + $xmlData = simplexml_load_file($path); + + foreach ($xmlData->zustieg as $entry) + { + $attributes = $entry->attributes(); + $idBusPro = (int) $attributes['idbuspro']; + $this->pickups[$idBusPro] = [ + 'city' => (string) $entry->ort, + 'street' => (string) $entry->strasse, + ]; + } + } } diff --git a/web/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_date.php b/web/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_date.php index 7c320257..bb52baf9 100644 --- a/web/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_date.php +++ b/web/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_date.php @@ -27,12 +27,13 @@ return [ 'interface' => [ 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, bus_pro_id, hotel_bus_pro_id, code, date_start, date_end, nights, board, board_code, board_bus_pro_id, bus_included, bus_available, - skipass_included, services_included, services_general, discount, min_price, pseudo_price, available', + skipass_included, services_included, services_general, pickups, discount, min_price, pseudo_price, + available', ], 'types' => [ '1' => ['showitem' => 'hidden, bus_pro_id, hotel_bus_pro_id, code, date_start, date_end, nights, board, board_code, board_bus_pro_id, bus_included, bus_available, skipass_included, services_included, - services_general, discount, min_price, pseudo_price, available'], + services_general, pickups, discount, min_price, pseudo_price, available'], ], 'palettes' => [ '1' => ['showitem' => ''], @@ -255,6 +256,16 @@ return [ 'eval' => 'trim' ] ], + 'pickups' => [ + 'exclude' => 0, + 'label' => 'Zustiege', + 'config' => [ + 'type' => 'text', + 'cols' => 40, + 'rows' => 15, + 'eval' => 'trim' + ] + ], 'discount' => [ 'exclude' => 0, 'label' => 'Rabatt', diff --git a/web/typo3conf/ext/ep_products/ext_tables.sql b/web/typo3conf/ext/ep_products/ext_tables.sql index c220c1a8..36ee245a 100644 --- a/web/typo3conf/ext/ep_products/ext_tables.sql +++ b/web/typo3conf/ext/ep_products/ext_tables.sql @@ -104,6 +104,7 @@ CREATE TABLE tx_epproducts_domain_model_date ( bus_price int(11) DEFAULT '0' NOT NULL, services_included text NOT NULL, services_general text NOT NULL, + pickups text NOT NULL, discount int(11) DEFAULT '0' NOT NULL, min_price int(11) DEFAULT '0' NOT NULL, pseudo_price int(11) DEFAULT '0' NOT NULL,