diff --git a/web/typo3conf/ext/ep_products/Classes/Controller/ResellerController.php b/web/typo3conf/ext/ep_products/Classes/Controller/ResellerController.php
index bdb51857..7b3b9557 100644
--- a/web/typo3conf/ext/ep_products/Classes/Controller/ResellerController.php
+++ b/web/typo3conf/ext/ep_products/Classes/Controller/ResellerController.php
@@ -88,7 +88,7 @@ class ResellerController extends ActionController
$this->redirect('list', null, null, [ 'reseller' => $reseller ]);
}
- $data = $this->resellerService->preprocessSingle($product);
+ $data = $this->resellerService->preprocessSingle($product, $reseller);
var_dump($data);
return false;
@@ -102,7 +102,7 @@ class ResellerController extends ActionController
{
$products = $reseller->getProducts();
- $data = $this->resellerService->preprocessAll($products);
+ $data = $this->resellerService->preprocessAll($reseller);
$encoders = [new XmlEncoder('products')];
$normalizers = [new ObjectNormalizer()];
diff --git a/web/typo3conf/ext/ep_products/Classes/Domain/Model/Reseller.php b/web/typo3conf/ext/ep_products/Classes/Domain/Model/Reseller.php
index f163f11a..fdb9efbf 100644
--- a/web/typo3conf/ext/ep_products/Classes/Domain/Model/Reseller.php
+++ b/web/typo3conf/ext/ep_products/Classes/Domain/Model/Reseller.php
@@ -42,6 +42,11 @@ class Reseller extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $code;
+ /**
+ * @var string
+ */
+ protected $paCode;
+
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EP\EpProducts\Domain\Model\Product>
*/
@@ -84,6 +89,22 @@ class Reseller extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
$this->code = $code;
}
+ /**
+ * @return string
+ */
+ public function getPaCode()
+ {
+ return $this->paCode;
+ }
+
+ /**
+ * @param string $paCode
+ */
+ public function setPaCode($paCode)
+ {
+ $this->paCode = $paCode;
+ }
+
/**
* @return ObjectStorage
*/
diff --git a/web/typo3conf/ext/ep_products/Classes/Service/ResellerService.php b/web/typo3conf/ext/ep_products/Classes/Service/ResellerService.php
index b7427215..4eedc224 100644
--- a/web/typo3conf/ext/ep_products/Classes/Service/ResellerService.php
+++ b/web/typo3conf/ext/ep_products/Classes/Service/ResellerService.php
@@ -29,6 +29,7 @@ namespace EP\EpProducts\Service;
use EP\EpProducts\Domain\Model\Hotel;
use EP\EpProducts\Domain\Model\Product;
+use EP\EpProducts\Domain\Model\Reseller;
use EP\EpProducts\Domain\Repository\ProductRepository;
use EP\EpProducts\Domain\Serialization\Date;
use EP\EpProducts\Domain\Serialization\Room;
@@ -52,17 +53,18 @@ class ResellerService implements SingletonInterface
}
/**
- * @param ObjectStorage $products
+ * @param Reseller $reseller
* @return array
*/
- public function preprocessAll(ObjectStorage $products)
+ public function preprocessAll(Reseller $reseller)
{
$data = [];
+ $products = $reseller->getProducts();
foreach ($products as $product)
{
/** @var Product $product */
- $data['product'][] = $this->preprocessSingle($product);
+ $data['product'][] = $this->preprocessSingle($product, $reseller);
}
return $data;
@@ -70,20 +72,22 @@ class ResellerService implements SingletonInterface
/**
* @param Product $product
+ * @param Reseller $reseller
* @return \EP\EpProducts\Domain\Serialization\Product
*/
- public function preprocessSingle(Product $product)
+ public function preprocessSingle(Product $product, Reseller $reseller)
{
$data = \EP\EpProducts\Domain\Serialization\Product::fromEntity($product);
$hotels = $product->getHotels();
+ $paCode = $reseller->getPaCode();
foreach ($hotels as $hotel)
{
/** @var Hotel $hotel */
$hotelData = \EP\EpProducts\Domain\Serialization\Hotel::fromEntity($hotel);
$dates = $this->productRepository->getDatesForExport($product, $hotel);
- $hotelData->dates['date'] = $this->preprocessDates($dates);
+ $hotelData->dates['date'] = $this->preprocessDates($dates, $paCode);
$data->hotels['hotel'][] = $hotelData;
}
@@ -92,9 +96,10 @@ class ResellerService implements SingletonInterface
/**
* @param array $dates
+ * @param string $paCode
* @return array
*/
- public function preprocessDates(array $dates)
+ public function preprocessDates(array $dates, $paCode = null)
{
$data = [];
@@ -108,7 +113,9 @@ class ResellerService implements SingletonInterface
$date->bookingurl = BookingUrlUtility::generateUrl(
$row['dateBusProId'],
$row['hotelBusProId'],
- $row['dateEnd']
+ $row['dateEnd'],
+ 'base',
+ $paCode
);
$date->rooms['room'][] = Room::fromArray($row);
diff --git a/web/typo3conf/ext/ep_products/Classes/Utility/BookingUrlUtility.php b/web/typo3conf/ext/ep_products/Classes/Utility/BookingUrlUtility.php
index 0eb75eb8..d195262a 100644
--- a/web/typo3conf/ext/ep_products/Classes/Utility/BookingUrlUtility.php
+++ b/web/typo3conf/ext/ep_products/Classes/Utility/BookingUrlUtility.php
@@ -41,9 +41,10 @@ class BookingUrlUtility
* @param int $hotelId
* @param string $dateEnd
* @param string $template
+ * @param string $paCode
* @return string
*/
- public static function generateUrl($bookingId, $hotelId, $dateEnd, $template = 'base')
+ public static function generateUrl($bookingId, $hotelId, $dateEnd, $template = 'base', $paCode = null)
{
$query = [
'id' => $bookingId,
@@ -58,20 +59,24 @@ class BookingUrlUtility
$query['templatezusatz'] = '_' . $template;
}
- $cookie = $_COOKIE[static::COOKIE_NAME];
- if (strpos($cookie, '?') !== false) {
- $items = GeneralUtility::trimExplode('?', $cookie);
- $cookie = $items[0];
- }
- $bpnCookie = $_COOKIE[static::COOKIE_NAME_BPN];
+ if ($paCode !== null) {
+ $query['agenturcode'] = $paCode;
+ } else {
+ $cookie = $_COOKIE[static::COOKIE_NAME];
+ if (strpos($cookie, '?') !== false) {
+ $items = GeneralUtility::trimExplode('?', $cookie);
+ $cookie = $items[0];
+ }
+ $bpnCookie = $_COOKIE[static::COOKIE_NAME_BPN];
- if (!empty($bpnCookie)) {
- $query['agenturcode'] = $bpnCookie;
- } elseif (!empty($cookie)) {
- if (preg_match('/^P[a-zA-Z0-9]*/', $cookie)) {
- $query['agenturcode'] = $cookie;
- } else {
- $query['crminfo'] = $cookie;
+ if (!empty($bpnCookie)) {
+ $query['agenturcode'] = $bpnCookie;
+ } elseif (!empty($cookie)) {
+ if (preg_match('/^P[a-zA-Z0-9]*/', $cookie)) {
+ $query['agenturcode'] = $cookie;
+ } else {
+ $query['crminfo'] = $cookie;
+ }
}
}
diff --git a/web/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_reseller.php b/web/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_reseller.php
index bfc6c9f3..51b8e5df 100644
--- a/web/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_reseller.php
+++ b/web/typo3conf/ext/ep_products/Configuration/TCA/tx_epproducts_domain_model_reseller.php
@@ -23,10 +23,10 @@ return [
'iconfile' => 'EXT:ep_products/Resources/Public/Icons/tx_epproducts_domain_model_reseller.gif'
],
'interface' => [
- 'showRecordFieldList' => 'name,code,products',
+ 'showRecordFieldList' => 'name,code,pa_code,products',
],
'types' => [
- '1' => ['showitem' => 'name, code, products'],
+ '1' => ['showitem' => 'name, code, pa_code, products'],
],
'palettes' => [],
'columns' => [
@@ -132,6 +132,15 @@ return [
'eval' => 'trim,required'
],
],
+ 'pa_code' => [
+ 'exclude' => 0,
+ 'label' => 'LLL:EXT:ep_products/Resources/Private/Language/locallang.xlf:tx_epproducts_domain_model_reseller.pa_code',
+ 'config' => [
+ 'type' => 'input',
+ 'size' => 30,
+ 'eval' => 'trim,required'
+ ],
+ ],
'products' => [
'exclude' => 0,
'label' => 'LLL:EXT:ep_products/Resources/Private/Language/locallang.xlf:tx_epproducts_domain_model_reseller.products',
diff --git a/web/typo3conf/ext/ep_products/Resources/Private/Language/locallang.xlf b/web/typo3conf/ext/ep_products/Resources/Private/Language/locallang.xlf
index 10b22ea9..5667c390 100644
--- a/web/typo3conf/ext/ep_products/Resources/Private/Language/locallang.xlf
+++ b/web/typo3conf/ext/ep_products/Resources/Private/Language/locallang.xlf
@@ -598,6 +598,9 @@
Code
+
+ PA-Code
+
Produkte
diff --git a/web/typo3conf/ext/ep_products/ext_tables.sql b/web/typo3conf/ext/ep_products/ext_tables.sql
index 3238c01a..a362b959 100644
--- a/web/typo3conf/ext/ep_products/ext_tables.sql
+++ b/web/typo3conf/ext/ep_products/ext_tables.sql
@@ -1075,6 +1075,7 @@ CREATE TABLE tx_epproducts_domain_model_reseller (
name varchar(255) DEFAULT '' NOT NULL,
code varchar(255) DEFAULT '' NOT NULL,
+ pa_code varchar(255) DEFAULT '' NOT NULL,
products int(11) unsigned DEFAULT '0' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,