Merge branch 'release/2020.03-06'

This commit is contained in:
Björn Fromme
2020-03-13 13:30:50 +01:00
6 changed files with 69 additions and 48 deletions
@@ -260,6 +260,11 @@ class Product extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements
*/ */
protected $badge; protected $badge;
/**
* @var string
*/
protected $nonBookableDates;
public function __construct() public function __construct()
{ {
$this->initStorageObjects(); $this->initStorageObjects();
@@ -1052,4 +1057,12 @@ class Product extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements
$this->badge = $badge; $this->badge = $badge;
} }
/**
* @return string
*/
public function getNonBookableDates()
{
return $this->nonBookableDates;
}
} }
@@ -248,31 +248,6 @@ class ProductRepository extends AbstractRepository
return $query->execute()->fetchAll(); return $query->execute()->fetchAll();
} }
/**
* Returns uids of date records that are selected to be non bookable
* via backend
*
* @param Product $product
* @return array
*/
public function getNonBookableDateUids(Product $product)
{
$qb = $this->getDbConnection()->createQueryBuilder();
$result = $qb
->select('uid_foreign as uid')
->from('tx_epproducts_product_date_mm')
->where('uid_local = :product')
->setParameter('product', $product->getUid())
->execute()
->fetchAll()
;
return array_map(function ($row) {
return $row['uid'];
}, $result);
}
/** /**
* @param Product $product * @param Product $product
* @param Hotel $hotel * @param Hotel $hotel
@@ -35,6 +35,7 @@ use EP\EpProducts\Domain\Repository\ProductRepository;
use EP\EpProducts\Utility\BookingUrlUtility; use EP\EpProducts\Utility\BookingUrlUtility;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
class DateService implements SingletonInterface class DateService implements SingletonInterface
@@ -102,7 +103,7 @@ class DateService implements SingletonInterface
$filterSettings = $this->filterService->getDefaultFilterSettings(); $filterSettings = $this->filterService->getDefaultFilterSettings();
} }
$nonBookableDateUids = $this->productRepository->getNonBookableDateUids($product); $nonBookableDateUids = GeneralUtility::trimExplode(',', $product->getNonBookableDates(), true);
return $this->preprocessPriceTable([ return $this->preprocessPriceTable([
'priceTableData' => $this->productRepository->getPricetable($product, $hotel, $filterSettings, $date), 'priceTableData' => $this->productRepository->getPricetable($product, $hotel, $filterSettings, $date),
@@ -148,7 +149,7 @@ class DateService implements SingletonInterface
$filterSettings = $this->filterService->getDefaultFilterSettings(); $filterSettings = $this->filterService->getDefaultFilterSettings();
} }
$nonBookableDateUids = $this->productRepository->getNonBookableDateUids($product); $nonBookableDateUids = GeneralUtility::trimExplode(',', $product->getNonBookableDates(), true);
$dateTableData = $this->productRepository->getAvailableDates( $dateTableData = $this->productRepository->getAvailableDates(
$product, $product,
@@ -289,7 +290,7 @@ class DateService implements SingletonInterface
foreach ($priceTableData as $row) foreach ($priceTableData as $row)
{ {
$isHideBookingButton = $resolvedOptions['isHideBookingButton'] || in_array($row['dateUid'], $nonBookableDateUids, false); $isHideBookingButton = $resolvedOptions['isHideBookingButton'] || in_array($row['dateBusProId'], $nonBookableDateUids, false);
$dateStart = new \DateTime($row['dateStart']); $dateStart = new \DateTime($row['dateStart']);
$dateEnd = new \DateTime($row['dateEnd']); $dateEnd = new \DateTime($row['dateEnd']);
@@ -349,7 +350,7 @@ class DateService implements SingletonInterface
foreach ($dateTableData as $row) foreach ($dateTableData as $row)
{ {
$isHideBookingButton = $resolvedOptions['isHideBookingButton'] || in_array($row['dateUid'], $nonBookableDateUids, false); $isHideBookingButton = $resolvedOptions['isHideBookingButton'] || in_array($row['dateBusProId'], $nonBookableDateUids, false);
$dateStart = new \DateTime($row['dateStart']); $dateStart = new \DateTime($row['dateStart']);
$dateEnd = new \DateTime($row['dateEnd']); $dateEnd = new \DateTime($row['dateEnd']);
@@ -0,0 +1,48 @@
<?php
namespace EP\EpProducts\UserFunc;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class TcaProcFunc
{
public function getDateItemsForProduct($config)
{
$productUid = $config['row']['uid'];
if (!is_numeric($productUid)) {
return $config;
}
$items = [];
/** @var ConnectionPool $connectionPool */
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$qb = $connectionPool->getQueryBuilderForTable('tx_epproducts_domain_model_date');
$result = $qb
->select('date_start', 'date_end', 'bus_pro_id')
->from('tx_epproducts_domain_model_date')
->where($qb->expr()->eq('product', $productUid))
->orderBy('date_start')
->execute()
->fetchAll()
;
foreach ($result as $row) {
$dateStart = new \DateTime($row['date_start']);
$dateEnd = new \DateTime($row['date_end']);
$items[] = [
sprintf('%s - %s', $dateStart->format('d.m.Y'), $dateEnd->format('d.m.Y')),
$row['bus_pro_id'],
];
}
$config['items'] = $items;
return $config;
}
}
@@ -838,10 +838,8 @@ return [
'config' => [ 'config' => [
'type' => 'select', 'type' => 'select',
'renderType' => 'selectMultipleSideBySide', 'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_epproducts_domain_model_date', 'itemsProcFunc' => \EP\EpProducts\UserFunc\TcaProcFunc::class.'->getDateItemsForProduct',
'foreign_table_where' => 'AND tx_epproducts_domain_model_date.product=###THIS_UID### ORDER BY tx_epproducts_domain_model_date.date_start',
'MM' => 'tx_epproducts_product_date_mm',
] ]
] ],
], ],
]; ];
@@ -59,7 +59,7 @@ CREATE TABLE tx_epproducts_domain_model_product
video varchar(255) DEFAULT '' NOT NULL, video varchar(255) DEFAULT '' NOT NULL,
banner int(11) unsigned NOT NULL default '0', banner int(11) unsigned NOT NULL default '0',
badge int(11) unsigned NOT NULL default '0', badge int(11) unsigned NOT NULL default '0',
non_bookable_dates int(11) unsigned NOT NULL default '0', non_bookable_dates varchar(255) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL, tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL, crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL, cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
@@ -1329,20 +1329,6 @@ CREATE TABLE tx_epproducts_product_region_mm
KEY uid_foreign (uid_foreign) KEY uid_foreign (uid_foreign)
); );
#
# Table structure for table 'tx_epproducts_product_date_mm'
#
CREATE TABLE tx_epproducts_product_date_mm
(
uid_local int(11) unsigned DEFAULT '0' NOT NULL,
uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,
sorting int(11) unsigned DEFAULT '0' NOT NULL,
sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL,
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);
# #
# Table structure for table 'tx_epproducts_hotel_teammember_mm' # Table structure for table 'tx_epproducts_hotel_teammember_mm'
# #