Add partnercode, fix booking urls in xml export
This commit is contained in:
@@ -88,7 +88,7 @@ class ResellerController extends ActionController
|
|||||||
$this->redirect('list', null, null, [ 'reseller' => $reseller ]);
|
$this->redirect('list', null, null, [ 'reseller' => $reseller ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->resellerService->preprocessSingle($product);
|
$data = $this->resellerService->preprocessSingle($product, $reseller);
|
||||||
var_dump($data);
|
var_dump($data);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -102,7 +102,7 @@ class ResellerController extends ActionController
|
|||||||
{
|
{
|
||||||
$products = $reseller->getProducts();
|
$products = $reseller->getProducts();
|
||||||
|
|
||||||
$data = $this->resellerService->preprocessAll($products);
|
$data = $this->resellerService->preprocessAll($reseller);
|
||||||
|
|
||||||
$encoders = [new XmlEncoder('products')];
|
$encoders = [new XmlEncoder('products')];
|
||||||
$normalizers = [new ObjectNormalizer()];
|
$normalizers = [new ObjectNormalizer()];
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ class Reseller extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
|||||||
*/
|
*/
|
||||||
protected $code;
|
protected $code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $paCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EP\EpProducts\Domain\Model\Product>
|
* @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;
|
$this->code = $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPaCode()
|
||||||
|
{
|
||||||
|
return $this->paCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $paCode
|
||||||
|
*/
|
||||||
|
public function setPaCode($paCode)
|
||||||
|
{
|
||||||
|
$this->paCode = $paCode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ObjectStorage
|
* @return ObjectStorage
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ namespace EP\EpProducts\Service;
|
|||||||
|
|
||||||
use EP\EpProducts\Domain\Model\Hotel;
|
use EP\EpProducts\Domain\Model\Hotel;
|
||||||
use EP\EpProducts\Domain\Model\Product;
|
use EP\EpProducts\Domain\Model\Product;
|
||||||
|
use EP\EpProducts\Domain\Model\Reseller;
|
||||||
use EP\EpProducts\Domain\Repository\ProductRepository;
|
use EP\EpProducts\Domain\Repository\ProductRepository;
|
||||||
use EP\EpProducts\Domain\Serialization\Date;
|
use EP\EpProducts\Domain\Serialization\Date;
|
||||||
use EP\EpProducts\Domain\Serialization\Room;
|
use EP\EpProducts\Domain\Serialization\Room;
|
||||||
@@ -52,17 +53,18 @@ class ResellerService implements SingletonInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ObjectStorage $products
|
* @param Reseller $reseller
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function preprocessAll(ObjectStorage $products)
|
public function preprocessAll(Reseller $reseller)
|
||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
|
$products = $reseller->getProducts();
|
||||||
|
|
||||||
foreach ($products as $product)
|
foreach ($products as $product)
|
||||||
{
|
{
|
||||||
/** @var Product $product */
|
/** @var Product $product */
|
||||||
$data['product'][] = $this->preprocessSingle($product);
|
$data['product'][] = $this->preprocessSingle($product, $reseller);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@@ -70,20 +72,22 @@ class ResellerService implements SingletonInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Product $product
|
* @param Product $product
|
||||||
|
* @param Reseller $reseller
|
||||||
* @return \EP\EpProducts\Domain\Serialization\Product
|
* @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);
|
$data = \EP\EpProducts\Domain\Serialization\Product::fromEntity($product);
|
||||||
|
|
||||||
$hotels = $product->getHotels();
|
$hotels = $product->getHotels();
|
||||||
|
$paCode = $reseller->getPaCode();
|
||||||
|
|
||||||
foreach ($hotels as $hotel)
|
foreach ($hotels as $hotel)
|
||||||
{
|
{
|
||||||
/** @var Hotel $hotel */
|
/** @var Hotel $hotel */
|
||||||
$hotelData = \EP\EpProducts\Domain\Serialization\Hotel::fromEntity($hotel);
|
$hotelData = \EP\EpProducts\Domain\Serialization\Hotel::fromEntity($hotel);
|
||||||
$dates = $this->productRepository->getDatesForExport($product, $hotel);
|
$dates = $this->productRepository->getDatesForExport($product, $hotel);
|
||||||
$hotelData->dates['date'] = $this->preprocessDates($dates);
|
$hotelData->dates['date'] = $this->preprocessDates($dates, $paCode);
|
||||||
$data->hotels['hotel'][] = $hotelData;
|
$data->hotels['hotel'][] = $hotelData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,9 +96,10 @@ class ResellerService implements SingletonInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $dates
|
* @param array $dates
|
||||||
|
* @param string $paCode
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function preprocessDates(array $dates)
|
public function preprocessDates(array $dates, $paCode = null)
|
||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
@@ -108,7 +113,9 @@ class ResellerService implements SingletonInterface
|
|||||||
$date->bookingurl = BookingUrlUtility::generateUrl(
|
$date->bookingurl = BookingUrlUtility::generateUrl(
|
||||||
$row['dateBusProId'],
|
$row['dateBusProId'],
|
||||||
$row['hotelBusProId'],
|
$row['hotelBusProId'],
|
||||||
$row['dateEnd']
|
$row['dateEnd'],
|
||||||
|
'base',
|
||||||
|
$paCode
|
||||||
);
|
);
|
||||||
|
|
||||||
$date->rooms['room'][] = Room::fromArray($row);
|
$date->rooms['room'][] = Room::fromArray($row);
|
||||||
|
|||||||
@@ -41,9 +41,10 @@ class BookingUrlUtility
|
|||||||
* @param int $hotelId
|
* @param int $hotelId
|
||||||
* @param string $dateEnd
|
* @param string $dateEnd
|
||||||
* @param string $template
|
* @param string $template
|
||||||
|
* @param string $paCode
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function generateUrl($bookingId, $hotelId, $dateEnd, $template = 'base')
|
public static function generateUrl($bookingId, $hotelId, $dateEnd, $template = 'base', $paCode = null)
|
||||||
{
|
{
|
||||||
$query = [
|
$query = [
|
||||||
'id' => $bookingId,
|
'id' => $bookingId,
|
||||||
@@ -58,20 +59,24 @@ class BookingUrlUtility
|
|||||||
$query['templatezusatz'] = '_' . $template;
|
$query['templatezusatz'] = '_' . $template;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cookie = $_COOKIE[static::COOKIE_NAME];
|
if ($paCode !== null) {
|
||||||
if (strpos($cookie, '?') !== false) {
|
$query['agenturcode'] = $paCode;
|
||||||
$items = GeneralUtility::trimExplode('?', $cookie);
|
} else {
|
||||||
$cookie = $items[0];
|
$cookie = $_COOKIE[static::COOKIE_NAME];
|
||||||
}
|
if (strpos($cookie, '?') !== false) {
|
||||||
$bpnCookie = $_COOKIE[static::COOKIE_NAME_BPN];
|
$items = GeneralUtility::trimExplode('?', $cookie);
|
||||||
|
$cookie = $items[0];
|
||||||
|
}
|
||||||
|
$bpnCookie = $_COOKIE[static::COOKIE_NAME_BPN];
|
||||||
|
|
||||||
if (!empty($bpnCookie)) {
|
if (!empty($bpnCookie)) {
|
||||||
$query['agenturcode'] = $bpnCookie;
|
$query['agenturcode'] = $bpnCookie;
|
||||||
} elseif (!empty($cookie)) {
|
} elseif (!empty($cookie)) {
|
||||||
if (preg_match('/^P[a-zA-Z0-9]*/', $cookie)) {
|
if (preg_match('/^P[a-zA-Z0-9]*/', $cookie)) {
|
||||||
$query['agenturcode'] = $cookie;
|
$query['agenturcode'] = $cookie;
|
||||||
} else {
|
} else {
|
||||||
$query['crminfo'] = $cookie;
|
$query['crminfo'] = $cookie;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-2
@@ -23,10 +23,10 @@ return [
|
|||||||
'iconfile' => 'EXT:ep_products/Resources/Public/Icons/tx_epproducts_domain_model_reseller.gif'
|
'iconfile' => 'EXT:ep_products/Resources/Public/Icons/tx_epproducts_domain_model_reseller.gif'
|
||||||
],
|
],
|
||||||
'interface' => [
|
'interface' => [
|
||||||
'showRecordFieldList' => 'name,code,products',
|
'showRecordFieldList' => 'name,code,pa_code,products',
|
||||||
],
|
],
|
||||||
'types' => [
|
'types' => [
|
||||||
'1' => ['showitem' => 'name, code, products'],
|
'1' => ['showitem' => 'name, code, pa_code, products'],
|
||||||
],
|
],
|
||||||
'palettes' => [],
|
'palettes' => [],
|
||||||
'columns' => [
|
'columns' => [
|
||||||
@@ -132,6 +132,15 @@ return [
|
|||||||
'eval' => 'trim,required'
|
'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' => [
|
'products' => [
|
||||||
'exclude' => 0,
|
'exclude' => 0,
|
||||||
'label' => 'LLL:EXT:ep_products/Resources/Private/Language/locallang.xlf:tx_epproducts_domain_model_reseller.products',
|
'label' => 'LLL:EXT:ep_products/Resources/Private/Language/locallang.xlf:tx_epproducts_domain_model_reseller.products',
|
||||||
|
|||||||
@@ -598,6 +598,9 @@
|
|||||||
<trans-unit id="tx_epproducts_domain_model_reseller.code">
|
<trans-unit id="tx_epproducts_domain_model_reseller.code">
|
||||||
<source>Code</source>
|
<source>Code</source>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="tx_epproducts_domain_model_reseller.pa_code">
|
||||||
|
<source>PA-Code</source>
|
||||||
|
</trans-unit>
|
||||||
<trans-unit id="tx_epproducts_domain_model_reseller.products">
|
<trans-unit id="tx_epproducts_domain_model_reseller.products">
|
||||||
<source>Produkte</source>
|
<source>Produkte</source>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
|||||||
@@ -1075,6 +1075,7 @@ CREATE TABLE tx_epproducts_domain_model_reseller (
|
|||||||
|
|
||||||
name varchar(255) DEFAULT '' NOT NULL,
|
name varchar(255) DEFAULT '' NOT NULL,
|
||||||
code 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,
|
products int(11) unsigned DEFAULT '0' NOT NULL,
|
||||||
|
|
||||||
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
|
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user