feat: apply pax filter to min pax attribute of a room

This commit is contained in:
Björn Fromme
2025-01-07 10:34:49 +01:00
parent 9f857c0257
commit 403c53d1e0
5 changed files with 38 additions and 2 deletions
@@ -164,6 +164,11 @@ class Date extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/ */
protected $available = 0; protected $available = 0;
/**
* @var int
*/
protected $minPax = 0;
/** /**
* @var bool * @var bool
*/ */
@@ -589,6 +594,18 @@ class Date extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
$this->available = $available; $this->available = $available;
} }
public function getMinPax()
{
return $this->minPax;
}
public function setMinPax($minPax)
{
$this->minPax = $minPax;
return $this;
}
public function isNew() public function isNew()
{ {
return $this->new; return $this->new;
@@ -139,7 +139,7 @@ abstract class AbstractRepository extends Repository
// Pax // Pax
if ($filterSettings['pax'] > 0) { if ($filterSettings['pax'] > 0) {
$qb->andWhere($qb->expr()->gte( $qb->andWhere($qb->expr()->gte(
'date.available', 'date.min_pax',
$qb->createNamedParameter($filterSettings['pax'], Connection::PARAM_INT) $qb->createNamedParameter($filterSettings['pax'], Connection::PARAM_INT)
)); ));
} }
@@ -578,6 +578,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
{ {
$minPriceOverall = 0; $minPriceOverall = 0;
$minPriceAvailable = 0; $minPriceAvailable = 0;
$minPax = 0;
$availableTotal = 0; $availableTotal = 0;
$boardCode = ''; $boardCode = '';
$count = 0; $count = 0;
@@ -607,6 +608,11 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
continue; continue;
} }
$pax = (int) $roomXml->attributes()['MinPax'];
if (0 === $minPax || $pax < $minPax) {
$minPax = $pax;
}
$pax = (int) $roomXml->attributes()['MaxPax']; $pax = (int) $roomXml->attributes()['MaxPax'];
$availableTotal += $available * $pax; $availableTotal += $available * $pax;
@@ -658,6 +664,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
$date['min_price'] = $minPriceAvailable ?: $minPriceOverall; $date['min_price'] = $minPriceAvailable ?: $minPriceOverall;
$date['available'] = $availableTotal; $date['available'] = $availableTotal;
$date['rooms'] = $count; $date['rooms'] = $count;
$date['min_pax'] = $minPax;
} }
/** /**
@@ -25,7 +25,9 @@ return [
'types' => [ 'types' => [
'1' => ['showitem' => 'hidden, bus_pro_id, hotel_bus_pro_id, code, daytrip, date_start, date_end, nights, board, '1' => ['showitem' => 'hidden, bus_pro_id, hotel_bus_pro_id, code, daytrip, date_start, date_end, nights, board,
board_code, board_bus_pro_id, bus_included, bus_available, skipass_included, services_included, board_code, board_bus_pro_id, bus_included, bus_available, skipass_included, services_included,
services_general, courses_included, guide, pickups, discount, min_price, pseudo_price, available, new'], services_general, courses_included, guide, pickups, discount, min_price, pseudo_price, available, min_pax,
new'
],
], ],
'palettes' => [ 'palettes' => [
'1' => ['showitem' => ''], '1' => ['showitem' => ''],
@@ -362,6 +364,15 @@ return [
'eval' => 'trim', 'eval' => 'trim',
], ],
], ],
'min_pax' => [
'exclude' => false,
'label' => 'Min. Pax',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
],
],
'new' => [ 'new' => [
'exclude' => false, 'exclude' => false,
'label' => 'neu', 'label' => 'neu',
@@ -126,6 +126,7 @@ CREATE TABLE tx_epproducts_domain_model_date
min_price int(11) DEFAULT '0' NOT NULL, min_price int(11) DEFAULT '0' NOT NULL,
pseudo_price int(11) DEFAULT '0' NOT NULL, pseudo_price int(11) DEFAULT '0' NOT NULL,
available int(11) DEFAULT '0' NOT NULL, available int(11) DEFAULT '0' NOT NULL,
min_pax int(11) DEFAULT '0' NOT NULL,
product int(11) unsigned DEFAULT '0', product int(11) unsigned DEFAULT '0',
product_pid int(11) unsigned DEFAULT '0', product_pid int(11) unsigned DEFAULT '0',
daytrip tinyint(1) unsigned DEFAULT '0' NOT NULL, daytrip tinyint(1) unsigned DEFAULT '0' NOT NULL,