fix: ensure correct sorting of rooms in pricetables

This commit is contained in:
Björn Fromme
2024-05-29 11:05:29 +02:00
parent 51a1dba6df
commit 0c910c4713
2 changed files with 7 additions and 5 deletions
@@ -187,7 +187,7 @@ class ProductRepository extends AbstractRepository
;
}
public function getPricetable(Product $product, Hotel $hotel, array $filterSettings, Date $date = null, bool $sortByRoom = false): array
public function getPricetable(Product $product, Hotel $hotel, array $filterSettings, Date $date = null, bool $sortByRoom = true): array
{
$qb = $this->getDbConnection()->createQueryBuilder();
@@ -207,12 +207,14 @@ class ProductRepository extends AbstractRepository
if (true === $sortByRoom) {
$qb->addOrderBy('room.name', 'ASC');
} else {
$qb
->addOrderBy('room.pax', 'ASC')
->addOrderBy('room.price', 'ASC')
;
}
$qb
->addOrderBy('date.date_start', 'ASC')
->addOrderBy('room.pax', 'ASC')
->addOrderBy('room.price', 'ASC')
->where('date.date_start >= NOW()')
->andWhere($qb->expr()->eq(
'date.product',
@@ -134,7 +134,7 @@ class DateService implements SingletonInterface
$resolver->setDefaults([
'template' => 'base',
'date' => null,
'sortByRoom' => false,
'sortByRoom' => true,
]);
$resolver->setAllowedTypes('product', Product::class);
$resolver->setAllowedTypes('hotel', Hotel::class);