feat: optionally sort pricetable by room name
This commit is contained in:
@@ -292,6 +292,7 @@ class AjaxTableController extends ActionController
|
||||
'filterSettings' => $this->filterService->getNormalizedFilterSettings(),
|
||||
'template' => $this->settings['bpnBookingUrlTemplateCode'],
|
||||
'paCode' => $paCode,
|
||||
'sortByRoom' => true,
|
||||
]);
|
||||
|
||||
$this->view->assign('pricetable', $pricetable);
|
||||
|
||||
@@ -187,7 +187,7 @@ class ProductRepository extends AbstractRepository
|
||||
;
|
||||
}
|
||||
|
||||
public function getPricetable(Product $product, Hotel $hotel, array $filterSettings, Date $date = null): array
|
||||
public function getPricetable(Product $product, Hotel $hotel, array $filterSettings, Date $date = null, bool $sortByRoom = false): array
|
||||
{
|
||||
$qb = $this->getDbConnection()->createQueryBuilder();
|
||||
|
||||
@@ -203,7 +203,14 @@ class ProductRepository extends AbstractRepository
|
||||
)
|
||||
->from('tx_epproducts_domain_model_date', 'date')
|
||||
->innerJoin('date', 'tx_epproducts_domain_model_room', 'room', 'date.uid = room.date')
|
||||
->orderBy('date.date_start', 'ASC')
|
||||
;
|
||||
|
||||
if (true === $sortByRoom) {
|
||||
$qb->addOrderBy('room.name', 'ASC');
|
||||
}
|
||||
|
||||
$qb
|
||||
->addOrderBy('date.date_start', 'ASC')
|
||||
->addOrderBy('room.pax', 'ASC')
|
||||
->addOrderBy('room.price', 'ASC')
|
||||
->where('date.date_start >= NOW()')
|
||||
@@ -350,7 +357,6 @@ class ProductRepository extends AbstractRepository
|
||||
'date.date_end as dateEnd', 'date.hotel as hotelUid', 'date.hotel_name as hotelName',
|
||||
'date.hotel_header_title as hotelTitle', 'date.hotel_category as hotelCategory',
|
||||
'room.pax as roomPax', 'room.price as roomPrice', 'room.available as available',
|
||||
'room.pax as roomPax', 'room.price as roomPrice', 'room.available as available',
|
||||
'hotel.detail_page as hotelDetailPageUid', 'hotel.short_name as hotelShortName',
|
||||
'hotel.show_as_teaser as hotelShowAsTeaser'
|
||||
)
|
||||
|
||||
@@ -109,6 +109,7 @@ class DateService implements SingletonInterface
|
||||
$date = $resolvedOptions['date'];
|
||||
$template = $resolvedOptions['template'];
|
||||
$paCode = $resolvedOptions['paCode'];
|
||||
$sortByRoom = $resolvedOptions['sortByRoom'];
|
||||
|
||||
if ($filterSettings === null) {
|
||||
$filterSettings = $this->filterService->getNormalizedFilterSettings();
|
||||
@@ -117,7 +118,7 @@ class DateService implements SingletonInterface
|
||||
$nonBookableDateUids = GeneralUtility::trimExplode(',', $product->getNonBookableDates(), true);
|
||||
|
||||
return $this->preprocessPriceTable([
|
||||
'priceTableData' => $this->productRepository->getPricetable($product, $hotel, $filterSettings, $date),
|
||||
'priceTableData' => $this->productRepository->getPricetable($product, $hotel, $filterSettings, $date, $sortByRoom),
|
||||
'template' => $template,
|
||||
'paCode' => $paCode,
|
||||
'isDayTrip' => $product->isDaytrip(),
|
||||
@@ -133,10 +134,12 @@ class DateService implements SingletonInterface
|
||||
$resolver->setDefaults([
|
||||
'template' => 'base',
|
||||
'date' => null,
|
||||
'sortByRoom' => false,
|
||||
]);
|
||||
$resolver->setAllowedTypes('product', Product::class);
|
||||
$resolver->setAllowedTypes('hotel', Hotel::class);
|
||||
$resolver->setAllowedTypes('date', [Date::class, 'null']);
|
||||
$resolver->setAllowedTypes('sortByRoom', 'bool');
|
||||
}
|
||||
|
||||
public function getDatesTable(array $options): array
|
||||
|
||||
Reference in New Issue
Block a user