Implement reseller domains
This commit is contained in:
+2924
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ use EP\EpProducts\Domain\Model\Hotel;
|
|||||||
use EP\EpProducts\Domain\Model\Product;
|
use EP\EpProducts\Domain\Model\Product;
|
||||||
use EP\EpProducts\Service\DateService;
|
use EP\EpProducts\Service\DateService;
|
||||||
use EP\EpProducts\Service\FilterService;
|
use EP\EpProducts\Service\FilterService;
|
||||||
|
use EP\EpProducts\Service\ResellerService;
|
||||||
use EP\EpProducts\Traits\RequestArgumentTypeConversionTrait;
|
use EP\EpProducts\Traits\RequestArgumentTypeConversionTrait;
|
||||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||||
|
|
||||||
@@ -50,15 +51,22 @@ class AjaxDateController extends ActionController
|
|||||||
*/
|
*/
|
||||||
protected $dateService;
|
protected $dateService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ResellerService
|
||||||
|
*/
|
||||||
|
protected $resellerService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FilterService $filterService
|
* @param FilterService $filterService
|
||||||
* @param DateService $dateService
|
* @param DateService $dateService
|
||||||
|
* @param ResellerService $resellerService
|
||||||
*/
|
*/
|
||||||
public function __construct(FilterService $filterService, DateService $dateService)
|
public function __construct(FilterService $filterService, DateService $dateService, ResellerService $resellerService)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->filterService = $filterService;
|
$this->filterService = $filterService;
|
||||||
$this->dateService = $dateService;
|
$this->dateService = $dateService;
|
||||||
|
$this->resellerService = $resellerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initializeAction()
|
public function initializeAction()
|
||||||
@@ -101,7 +109,11 @@ class AjaxDateController extends ActionController
|
|||||||
$altLabel = $product->getAltLabel();
|
$altLabel = $product->getAltLabel();
|
||||||
}
|
}
|
||||||
$template = $this->settings['bpnBookingUrlTemplateCode'];
|
$template = $this->settings['bpnBookingUrlTemplateCode'];
|
||||||
$datesTable = $this->dateService->getDatesTable($product, $hotel, $filterSettings, $template);
|
$paCode = null;
|
||||||
|
if ($reseller = $this->resellerService->getResellerForCurrentDomain()) {
|
||||||
|
$paCode = $reseller['paCode'];
|
||||||
|
}
|
||||||
|
$datesTable = $this->dateService->getDatesTable($product, $hotel, $filterSettings, $template, $paCode);
|
||||||
return json_encode([
|
return json_encode([
|
||||||
'dates' => $datesTable,
|
'dates' => $datesTable,
|
||||||
'bookable' => $product->getBookable(),
|
'bookable' => $product->getBookable(),
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ use EP\EpProducts\Domain\Model\Hotel;
|
|||||||
use EP\EpProducts\Domain\Model\Product;
|
use EP\EpProducts\Domain\Model\Product;
|
||||||
use EP\EpProducts\Service\DateService;
|
use EP\EpProducts\Service\DateService;
|
||||||
use EP\EpProducts\Service\FilterService;
|
use EP\EpProducts\Service\FilterService;
|
||||||
|
use EP\EpProducts\Service\ResellerService;
|
||||||
use EP\EpProducts\Traits\RequestArgumentTypeConversionTrait;
|
use EP\EpProducts\Traits\RequestArgumentTypeConversionTrait;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||||
@@ -52,15 +53,22 @@ class AjaxTableController extends ActionController
|
|||||||
*/
|
*/
|
||||||
protected $dateService;
|
protected $dateService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ResellerService
|
||||||
|
*/
|
||||||
|
protected $resellerService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DateService $dateService
|
* @param DateService $dateService
|
||||||
* @param FilterService $filterService
|
* @param FilterService $filterService
|
||||||
|
* @param ResellerService $resellerService
|
||||||
*/
|
*/
|
||||||
public function __construct(DateService $dateService, FilterService $filterService)
|
public function __construct(DateService $dateService, FilterService $filterService, ResellerService $resellerService)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->dateService = $dateService;
|
$this->dateService = $dateService;
|
||||||
$this->filterService = $filterService;
|
$this->filterService = $filterService;
|
||||||
|
$this->resellerService = $resellerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initializeAction()
|
public function initializeAction()
|
||||||
@@ -83,8 +91,12 @@ class AjaxTableController extends ActionController
|
|||||||
$forcedConceptUid = (int) $this->settings['forcedConceptUid'];
|
$forcedConceptUid = (int) $this->settings['forcedConceptUid'];
|
||||||
$filterSettings = $this->filterService->getDefaultFilterSettings($forcedConceptUid, false);
|
$filterSettings = $this->filterService->getDefaultFilterSettings($forcedConceptUid, false);
|
||||||
}
|
}
|
||||||
|
$paCode = null;
|
||||||
|
if ($reseller = $this->resellerService->getResellerForCurrentDomain()) {
|
||||||
|
$paCode = $reseller['paCode'];
|
||||||
|
}
|
||||||
$template = $this->settings['bpnBookingUrlTemplateCode'];
|
$template = $this->settings['bpnBookingUrlTemplateCode'];
|
||||||
$priceTable = $this->dateService->getPriceTable($product, $hotel, $filterSettings, $date, $template);
|
$priceTable = $this->dateService->getPriceTable($product, $hotel, $filterSettings, $date, $template, $paCode);
|
||||||
return json_encode([
|
return json_encode([
|
||||||
'dateStart' => $date ? $date->getDateStart()->format('Y-m-d') : '',
|
'dateStart' => $date ? $date->getDateStart()->format('Y-m-d') : '',
|
||||||
'dateEnd' => $date ? $date->getDateEnd()->format('Y-m-d') : '',
|
'dateEnd' => $date ? $date->getDateEnd()->format('Y-m-d') : '',
|
||||||
@@ -100,8 +112,12 @@ class AjaxTableController extends ActionController
|
|||||||
public function pricetableHtmlAction(Product $product, Hotel $hotel)
|
public function pricetableHtmlAction(Product $product, Hotel $hotel)
|
||||||
{
|
{
|
||||||
$filterSettings = $this->filterService->getDefaultFilterSettings();
|
$filterSettings = $this->filterService->getDefaultFilterSettings();
|
||||||
|
$paCode = null;
|
||||||
|
if ($reseller = $this->resellerService->getResellerForCurrentDomain()) {
|
||||||
|
$paCode = $reseller['paCode'];
|
||||||
|
}
|
||||||
$template = $this->settings['bpnBookingUrlTemplateCode'];
|
$template = $this->settings['bpnBookingUrlTemplateCode'];
|
||||||
$pricetable = $this->dateService->getPriceTable($product, $hotel, $filterSettings, null, $template);
|
$pricetable = $this->dateService->getPriceTable($product, $hotel, $filterSettings, null, $template, $paCode);
|
||||||
$this->view->assign('pricetable', $pricetable);
|
$this->view->assign('pricetable', $pricetable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace EP\EpProducts\Domain\Repository;
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
*
|
||||||
|
* Copyright notice
|
||||||
|
*
|
||||||
|
* (c) 2018 Björn Fromme <[email protected]>, 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 ResellerRepository extends AbstractRepository
|
||||||
|
{}
|
||||||
@@ -70,6 +70,7 @@ class DateService implements SingletonInterface
|
|||||||
* @param FilterSettings|null $filterSettings
|
* @param FilterSettings|null $filterSettings
|
||||||
* @param Date|null $date
|
* @param Date|null $date
|
||||||
* @param string $template
|
* @param string $template
|
||||||
|
* @param string $paCode
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -79,20 +80,23 @@ class DateService implements SingletonInterface
|
|||||||
Hotel $hotel,
|
Hotel $hotel,
|
||||||
FilterSettings $filterSettings = null,
|
FilterSettings $filterSettings = null,
|
||||||
Date $date = null,
|
Date $date = null,
|
||||||
$template = 'base'
|
$template = 'base',
|
||||||
|
$paCode = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ($filterSettings === null) {
|
if ($filterSettings === null) {
|
||||||
$filterSettings = $this->filterService->getDefaultFilterSettings();
|
$filterSettings = $this->filterService->getDefaultFilterSettings();
|
||||||
}
|
}
|
||||||
$priceTableData = $this->productRepository->getPricetable($product, $hotel, $filterSettings, $date);
|
$priceTableData = $this->productRepository->getPricetable($product, $hotel, $filterSettings, $date);
|
||||||
return $this->preprocessPriceTable($priceTableData, $template);
|
return $this->preprocessPriceTable($priceTableData, $template, $paCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Product $product
|
* @param Product $product
|
||||||
* @param Hotel $hotel
|
* @param Hotel $hotel
|
||||||
* @param FilterSettings|null $filterSettings
|
* @param FilterSettings|null $filterSettings
|
||||||
|
* @param string $template
|
||||||
|
* @param string $paCode
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -101,14 +105,15 @@ class DateService implements SingletonInterface
|
|||||||
Product $product,
|
Product $product,
|
||||||
Hotel $hotel,
|
Hotel $hotel,
|
||||||
FilterSettings $filterSettings = null,
|
FilterSettings $filterSettings = null,
|
||||||
$template = 'base'
|
$template = 'base',
|
||||||
|
$paCode = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ($filterSettings === null) {
|
if ($filterSettings === null) {
|
||||||
$filterSettings = $this->filterService->getDefaultFilterSettings();
|
$filterSettings = $this->filterService->getDefaultFilterSettings();
|
||||||
}
|
}
|
||||||
$dateTableData = $this->productRepository->getAvailableDates($product, $hotel, $filterSettings);
|
$dateTableData = $this->productRepository->getAvailableDates($product, $hotel, $filterSettings);
|
||||||
return $this->preprocessDateTable($dateTableData, $template);
|
return $this->preprocessDateTable($dateTableData, $template, $paCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -186,10 +191,11 @@ class DateService implements SingletonInterface
|
|||||||
/**
|
/**
|
||||||
* @param array $priceTableData
|
* @param array $priceTableData
|
||||||
* @param string $template
|
* @param string $template
|
||||||
|
* @param string $paCode
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function preprocessPriceTable(array $priceTableData, $template)
|
public function preprocessPriceTable(array $priceTableData, $template, $paCode = null)
|
||||||
{
|
{
|
||||||
$priceTable = [];
|
$priceTable = [];
|
||||||
|
|
||||||
@@ -201,7 +207,8 @@ class DateService implements SingletonInterface
|
|||||||
$row['dateBusProId'],
|
$row['dateBusProId'],
|
||||||
$row['hotelBusProId'],
|
$row['hotelBusProId'],
|
||||||
$row['dateEnd'],
|
$row['dateEnd'],
|
||||||
$template
|
$template,
|
||||||
|
$paCode
|
||||||
);
|
);
|
||||||
$priceTable[] = [
|
$priceTable[] = [
|
||||||
'dateStart' => $dateStart->format('d.m.Y'),
|
'dateStart' => $dateStart->format('d.m.Y'),
|
||||||
@@ -229,10 +236,11 @@ class DateService implements SingletonInterface
|
|||||||
/**
|
/**
|
||||||
* @param array $dateTableData
|
* @param array $dateTableData
|
||||||
* @param string $template
|
* @param string $template
|
||||||
|
* @param string $paCode
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function preprocessDateTable(array $dateTableData, $template)
|
public function preprocessDateTable(array $dateTableData, $template, $paCode = null)
|
||||||
{
|
{
|
||||||
$dateTable = [];
|
$dateTable = [];
|
||||||
foreach ($dateTableData as $row)
|
foreach ($dateTableData as $row)
|
||||||
@@ -243,7 +251,8 @@ class DateService implements SingletonInterface
|
|||||||
$row['dateBusProId'],
|
$row['dateBusProId'],
|
||||||
$row['hotelBusProId'],
|
$row['hotelBusProId'],
|
||||||
$row['dateEnd'],
|
$row['dateEnd'],
|
||||||
$template
|
$template,
|
||||||
|
$paCode
|
||||||
);
|
);
|
||||||
$dateTable[] = [
|
$dateTable[] = [
|
||||||
'dateUid' => $row['dateUid'],
|
'dateUid' => $row['dateUid'],
|
||||||
@@ -269,9 +278,11 @@ class DateService implements SingletonInterface
|
|||||||
* @param array $priceTableData
|
* @param array $priceTableData
|
||||||
* @param int $maxPax
|
* @param int $maxPax
|
||||||
* @param string $template
|
* @param string $template
|
||||||
|
* @param string $paCode
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function preprocessEventPriceTable(array $priceTableData, $maxPax = 99, $template = 'base')
|
public function preprocessEventPriceTable(array $priceTableData, $maxPax = 99, $template = 'base', $paCode = null)
|
||||||
{
|
{
|
||||||
$priceTable = [
|
$priceTable = [
|
||||||
Hotel::CATEGORY_STANDARD => [],
|
Hotel::CATEGORY_STANDARD => [],
|
||||||
@@ -293,7 +304,8 @@ class DateService implements SingletonInterface
|
|||||||
$row['dateBusProId'],
|
$row['dateBusProId'],
|
||||||
$row['hotelBusProId'],
|
$row['hotelBusProId'],
|
||||||
$row['dateEnd'],
|
$row['dateEnd'],
|
||||||
$template
|
$template,
|
||||||
|
$paCode
|
||||||
),
|
),
|
||||||
'rooms' => [],
|
'rooms' => [],
|
||||||
];
|
];
|
||||||
@@ -340,4 +352,4 @@ class DateService implements SingletonInterface
|
|||||||
return $priceTable;
|
return $priceTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ 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;
|
||||||
use EP\EpProducts\Utility\BookingUrlUtility;
|
use EP\EpProducts\Utility\BookingUrlUtility;
|
||||||
|
use EP\EpProducts\Utility\DbUtility;
|
||||||
use TYPO3\CMS\Core\SingletonInterface;
|
use TYPO3\CMS\Core\SingletonInterface;
|
||||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
|
|
||||||
class ResellerService implements SingletonInterface
|
class ResellerService implements SingletonInterface
|
||||||
{
|
{
|
||||||
@@ -122,4 +123,27 @@ class ResellerService implements SingletonInterface
|
|||||||
|
|
||||||
return array_values($data);
|
return array_values($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool|array
|
||||||
|
*/
|
||||||
|
public function getResellerForCurrentDomain()
|
||||||
|
{
|
||||||
|
$currentDomain = GeneralUtility::getIndpEnv('HTTP_HOST');
|
||||||
|
|
||||||
|
$qb = DbUtility::getDbConnection()->createQueryBuilder();
|
||||||
|
|
||||||
|
return $qb
|
||||||
|
->select('r.name name, r.pa_code paCode')
|
||||||
|
->from('tx_epproducts_domain_model_reseller', 'r')
|
||||||
|
->innerJoin('r', 'sys_domain', 'd', 'r.uid = d.tx_epproducts_reseller')
|
||||||
|
->where('d.domainName = :domain')
|
||||||
|
->andWhere('r.deleted = 0')
|
||||||
|
->andWhere('r.hidden = 0')
|
||||||
|
->andWhere('d.hidden = 0')
|
||||||
|
->setParameter('domain', $currentDomain)
|
||||||
|
->execute()
|
||||||
|
->fetch()
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class BookingUrlUtility
|
|||||||
* @param string $paCode
|
* @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 = static::buildQuery($bookingId, $hotelId, $dateEnd, $template);
|
$query = static::buildQuery($bookingId, $hotelId, $dateEnd, $template);
|
||||||
|
|
||||||
@@ -55,7 +55,9 @@ class BookingUrlUtility
|
|||||||
}
|
}
|
||||||
$bpnCookie = $_COOKIE[static::COOKIE_NAME_BPN];
|
$bpnCookie = $_COOKIE[static::COOKIE_NAME_BPN];
|
||||||
|
|
||||||
if (!empty($bpnCookie)) {
|
if ($paCode !== null) {
|
||||||
|
$query['agenturcode'] = $paCode;
|
||||||
|
} elseif (!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)) {
|
||||||
@@ -79,7 +81,7 @@ class BookingUrlUtility
|
|||||||
{
|
{
|
||||||
$query = static::buildQuery($bookingId, $hotelId, $dateEnd);
|
$query = static::buildQuery($bookingId, $hotelId, $dateEnd);
|
||||||
|
|
||||||
if (!empty($paCode)) {
|
if ($paCode !== null) {
|
||||||
$query['agenturcode'] = $paCode;
|
$query['agenturcode'] = $paCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
defined('TYPO3_MODE') or die();
|
||||||
|
|
||||||
|
call_user_func(function() {
|
||||||
|
|
||||||
|
$temporaryColumns = [
|
||||||
|
'tx_epproducts_reseller' => [
|
||||||
|
'label' => 'Vertragspartner',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'renderType' => 'selectSingle',
|
||||||
|
'foreign_table' => 'tx_epproducts_domain_model_reseller',
|
||||||
|
'foreign_table_where' => 'ORDER BY title',
|
||||||
|
'items' => [
|
||||||
|
['Keine Zuordnung', 0],
|
||||||
|
],
|
||||||
|
'minitems' => 0,
|
||||||
|
'maxitems' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
|
||||||
|
'sys_domain',
|
||||||
|
$temporaryColumns
|
||||||
|
);
|
||||||
|
|
||||||
|
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
|
||||||
|
'sys_domain',
|
||||||
|
'tx_epproducts_reseller',
|
||||||
|
'',
|
||||||
|
'before:redirectTo'
|
||||||
|
);
|
||||||
|
|
||||||
|
});
|
||||||
@@ -1109,6 +1109,13 @@ CREATE TABLE tx_epproducts_domain_model_reseller (
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#
|
||||||
|
# Table structure for table 'sys_domain'
|
||||||
|
#
|
||||||
|
CREATE TABLE sys_domain (
|
||||||
|
tx_epproducts_reseller int(11) unsigned DEFAULT '0',
|
||||||
|
);
|
||||||
|
|
||||||
#
|
#
|
||||||
# Table structure for table 'tx_epproducts_product_hotel_mm'
|
# Table structure for table 'tx_epproducts_product_hotel_mm'
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user