Determine correct occupancy level considering room status
This commit is contained in:
@@ -53,12 +53,8 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
$qb = $this->getDbConnection()->createQueryBuilder();
|
$qb = $this->getDbConnection()->createQueryBuilder();
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
->select('status as status', 'date as date', 'min_price as minPrice')
|
->select('status as status', 'date as date', 'min_price as minPrice', 'pax', 'available')
|
||||||
->addSelectLiteral('SUM(pax) as pax')
|
|
||||||
->addSelectLiteral('SUM(available) as available')
|
|
||||||
->from('tx_epproducts_domain_model_contingent')
|
->from('tx_epproducts_domain_model_contingent')
|
||||||
->groupBy('hotel')
|
|
||||||
->addGroupBy('date')
|
|
||||||
->orderBy('date')
|
->orderBy('date')
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -82,9 +78,30 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
|
|
||||||
$result = $qb->execute()->fetchAll();
|
$result = $qb->execute()->fetchAll();
|
||||||
|
|
||||||
$events = [];
|
$dates = [];
|
||||||
|
|
||||||
foreach ($result as $row)
|
foreach ($result as $row)
|
||||||
|
{
|
||||||
|
if (!\array_key_exists($row['date'], $dates)) {
|
||||||
|
$dates[$row['date']] = [
|
||||||
|
'status' => Contingent::STATUS_OK,
|
||||||
|
'date' => $row['date'],
|
||||||
|
'minPrice' => $row['minPrice'],
|
||||||
|
'pax' => $row['pax'],
|
||||||
|
'available' => $row['available'],
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
if ($row['status'] !== Contingent::STATUS_OK) {
|
||||||
|
$dates[$row['date']]['status'] = $row['status'];
|
||||||
|
}
|
||||||
|
$dates[$row['date']]['pax'] += $row['pax'];
|
||||||
|
$dates[$row['date']]['available'] += $row['available'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$events = [];
|
||||||
|
|
||||||
|
foreach ($dates as $row)
|
||||||
{
|
{
|
||||||
if ($hotel) {
|
if ($hotel) {
|
||||||
$row['hotel'] = $hotel;
|
$row['hotel'] = $hotel;
|
||||||
|
|||||||
Reference in New Issue
Block a user