Пример #1
0
 /**
  * @param RateCategory $rateCategory
  * @param $brand
  * @return Paginator
  */
 public function findAllValidForCategory(RateCategory $rateCategory, $brand, $hotel = null)
 {
     $queryBuilder = $this->createQueryBuilder('r')->join('r.categories', 'rc')->join('r.brands', 'b')->andWhere('rc.id = :rateCategoryId')->andWhere('r.active = :active')->andWhere('r.bookingPeriodType = :unlimited OR ((r.bookingPeriodStart IS NULL OR r.bookingPeriodStart <= :now) AND (r.bookingPeriodEnd IS NULL OR r.bookingPeriodEnd >= :now))')->andWhere('b.artsysID = :brand')->setParameter(':active', true)->setParameter(':rateCategoryId', $rateCategory->getId())->setParameter(':unlimited', Rate::BOOKING_PERIOD_TYPE_UNLIMITED)->setParameter(':now', date('Y-m-d'))->setParameter(':brand', strtoupper($brand));
     if ($hotel) {
         $queryBuilder->join('r.hotels', 'h')->andWhere('h.id = :hotel')->setParameter(':hotel', $hotel->getId());
     }
     if ($rateCategory->getChainRate()) {
         $queryBuilder->setMaxResults(1);
         $queryBuilder->setFirstResult(0);
     }
     return new Paginator($queryBuilder, true);
 }
Пример #2
0
 /**
  * @param $brand
  *
  * @return mixed
  */
 public function findAllForRateCategory(RateCategory $rateCategory, $brand = null)
 {
     $queryBuilder = $this->getValidQueryBuilder()->select('h.id as hotel_id')->addSelect('c.id as country_id, r.id as region_id, ci.id as city_id')->join('h.rates', 'hr', Expr\Join::WITH, 'hr.bookingPeriodType = :unlimited OR (hr.bookingPeriodStart <= :now AND hr.bookingPeriodEnd >= :now)')->join('hr.categories', 'rc', Expr\Join::WITH, 'rc.id = :rateCategoryId')->join('hr.brands', 'rb', Expr\Join::WITH, 'rb.artsysID = :brand')->setParameter(':rateCategoryId', $rateCategory->getId())->setParameter(':unlimited', Rate::BOOKING_PERIOD_TYPE_UNLIMITED)->setParameter(':brand', strtoupper($brand))->setParameter(':now', date('Y-m-d'))->addGroupBy('hotel_id');
     if ($brand && $brand != 'seh') {
         $queryBuilder->andWhere('b.artsysID = :brand');
     }
     return $queryBuilder->getQuery()->getResult();
 }