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
|
||||
->select('status as status', 'date as date', 'min_price as minPrice')
|
||||
->addSelectLiteral('SUM(pax) as pax')
|
||||
->addSelectLiteral('SUM(available) as available')
|
||||
->select('status as status', 'date as date', 'min_price as minPrice', 'pax', 'available')
|
||||
->from('tx_epproducts_domain_model_contingent')
|
||||
->groupBy('hotel')
|
||||
->addGroupBy('date')
|
||||
->orderBy('date')
|
||||
;
|
||||
|
||||
@@ -82,9 +78,30 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
||||
|
||||
$result = $qb->execute()->fetchAll();
|
||||
|
||||
$events = [];
|
||||
$dates = [];
|
||||
|
||||
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) {
|
||||
$row['hotel'] = $hotel;
|
||||
|
||||
Reference in New Issue
Block a user