diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index 0fc5f8efb..7b6b31489 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -165,6 +165,16 @@ class CategoryControllerCore extends FrontController $currency = new Currency($this->context->currency->id); if ($id_hotel = HotelBranchInformation::getHotelIdByIdCategory($id_category)) { + $preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($id_hotel); + if ($preparationTime + && strtotime('+ '.$preparationTime.' day') >= strtotime($date_from) + ) { + $date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day')); + if (strtotime($date_from) >= strtotime($date_to)) { + $date_to = date('Y-m-d', strtotime($date_from) + 86400); + } + } + $id_cart = $this->context->cart->id; $id_guest = $this->context->cookie->id_guest; diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index bd25afa81..fc503b2aa 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -344,10 +344,6 @@ class ProductControllerCore extends FrontController $preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_id); if (!($date_from = Tools::getValue('date_from'))) { $date_from = date('Y-m-d'); - if ($preparationTime) { - $date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day')); - } - // set date to according to los $objHotelRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange(); $los = $objHotelRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($this->product->id, $date_from); @@ -360,6 +356,17 @@ class ProductControllerCore extends FrontController $date_to = date('Y-m-d', strtotime('+'.$los['min_los'].' day', strtotime($date_from))); } + if ($preparationTime + && strtotime('+ '.$preparationTime.' day') >= strtotime($date_from) + ) { + $date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day')); + if (strtotime($date_from) >= strtotime($date_to)) { + $objHotelRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange(); + $los = $objHotelRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($this->product->id, $date_from); + $date_to = date('Y-m-d', strtotime('+'.$los['min_los'].' day', strtotime($date_from))); + } + } + $hotel_branch_obj = new HotelBranchInformation($hotel_id); /*Max date of ordering for order restrict*/ $order_date_restrict = false; diff --git a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php index effe0f15f..51fef3746 100644 --- a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php +++ b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php @@ -140,11 +140,31 @@ class WkRoomSearchHelper if (!$dateTo = Tools::getValue('date_to')) { $dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))); } - $smartyVars['date_from'] = $dateFrom; - $smartyVars['date_to'] = $dateTo; $idHotel = HotelBranchInformation::getHotelIdByIdCategory($idHotelCategory); $htlCategoryInfo = $objHotelInfo->getCategoryDataByIdCategory((int) $objCategory->id_parent); + $searchedData['htl_dtl'] = $objHotelInfo->hotelBranchesInfo(0, 1, 1, $idHotel); + $preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($idHotel); + if ($preparationTime + && strtotime('+ '.$preparationTime.' day') >= strtotime($dateFrom) + ) { + $dateFrom = date('Y-m-d', strtotime('+ '.$preparationTime.' day')); + if (strtotime($dateFrom) >= strtotime($dateTo)) { + $controller = Tools::getValue('controller'); + if ($controller == 'product' + && ($idProduct = Tools::getValue('id_product')) + ) { + $objHotelRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange(); + $los = $objHotelRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($idProduct, $dateFrom); + $dateTo = date('Y-m-d', strtotime('+'.$los['min_los'].' day', strtotime($dateFrom))); + } else { + $dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))); + } + } + } + + $smartyVars['date_from'] = $dateFrom; + $smartyVars['date_to'] = $dateTo; $objBookingDetail = new HotelBookingDetail(); $searchedData['num_days'] = $objBookingDetail->getNumberOfDays($dateFrom, $dateTo); @@ -152,7 +172,6 @@ class WkRoomSearchHelper $searchedData['parent_data'] = $htlCategoryInfo; $searchedData['date_from'] = $dateFrom; $searchedData['date_to'] = $dateTo; - $searchedData['htl_dtl'] = $objHotelInfo->hotelBranchesInfo(0, 1, 1, $idHotel); if ($locationCategoryId) { $objLocationCategory = new Category($locationCategoryId, $context->language->id);