diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index 10d9a0ae0a..ed48cce845 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -140,12 +140,15 @@ public function initContent() $id_category = Tools::getValue('id_category'); + $displayAllRooms = false; if (!($date_from = Tools::getValue('date_from'))) { $date_from = date('Y-m-d'); $date_to = date('Y-m-d', strtotime($date_from) + 86400); + $displayAllRooms = true; } if (!($date_to = Tools::getValue('date_to'))) { $date_to = date('Y-m-d', strtotime($date_from) + 86400); + $displayAllRooms = true; } // get occupancy of the search @@ -180,6 +183,10 @@ public function initContent() 'id_guest' => $id_guest, ); + if ($displayAllRooms) { + $bookingParams['room_info_detailed'] = 1; + } + $booking_data = $objBookingDetail->dataForFrontSearch($bookingParams); $num_days = $objBookingDetail->getNumberOfDays($date_from, $date_to); @@ -206,7 +213,8 @@ public function initContent() 'booking_date_to' => $date_to, 'booking_data' => $booking_data, 'max_order_date' => $max_order_date, - 'order_date_restrict' => $order_date_restrict + 'order_date_restrict' => $order_date_restrict, + 'display_all_rooms' => $displayAllRooms )); } else { Tools::redirect($this->context->link->getPageLink('pagenotfound')); @@ -261,8 +269,18 @@ public function displayAjaxFilterResults() $this->display_header = false; $this->display_footer = false; - $date_from = Tools::getValue('date_from'); - $date_to = Tools::getValue('date_to'); + $displayAllRooms = false; + if (!($date_from = Tools::getValue('date_from'))) { + $date_from = date('Y-m-d H:i:s'); + $date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400); + $displayAllRooms = true; + } + + if (!($date_to = Tools::getValue('date_to'))) { + $date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400); + $displayAllRooms = true; + } + $htl_id_category = Tools::getValue('id_category'); // occupancy of the search @@ -317,6 +335,10 @@ public function displayAjaxFilterResults() 'id_guest' => $this->context->cookie->id_guest, ); + if ($displayAllRooms) { + $bookingParams['room_info_detailed'] = 1; + } + $booking_data = $objBookingDetail->dataForFrontSearch($bookingParams); // reset array keys from 0 $booking_data['rm_data'] = array_values($booking_data['rm_data']); diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 32033875cb..2be499905e 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -395,6 +395,11 @@ public function hookHeader() $this->context->controller->addCSS(($this->_path).'blockcart.css', 'all'); if ((int) (Configuration::get('PS_BLOCK_CART_AJAX'))) { + Media::addJsDef( + array( + 'room_selection_error_message' => $this->l('You must check room availability before adding them to the cart.', null, true) + ) + ); $this->context->controller->addJS(($this->_path).'ajax-cart.js'); $this->context->controller->addJqueryPlugin(array('scrollTo', 'serialScroll', 'bxslider')); } diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 97f037fcda..2c409298f8 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -240,6 +240,10 @@ public function getBookingDataParams(&$params) $params['full_detail'] = 0; } + if (!isset($params['room_info_detailed'])) { + $params['room_info_detailed'] = 0; + } + Hook::exec('actionBookingDataParamsModifier', array('params' => &$params)); return $params; @@ -1704,7 +1708,7 @@ public function dataForFrontSearch($bookingParams) unset($bookingData['rm_data'][$key]); continue; } - if (count($value['data']['available'])) { + if (count($value['data']['available']) || $room_info_detailed) { $prod_price = Product::getPriceStatic($value['id_product'], self::useTax()); $productPriceWithoutReduction = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 1, 0); $cover_image_arr = Product::getCover($value['id_product']); diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index 3e628b65c9..81c2bb24f4 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -167,7 +167,6 @@ public function hookHeader() public function hookDisplayLeftColumn() { if ($this->context->controller->php_self == 'category') { - $htl_id_category = Tools::getValue('id_category'); if (Validate::isLoadedObject($objCategory = new Category((int) $htl_id_category)) && ($id_hotel = HotelBranchInformation::getHotelIdByIdCategory($htl_id_category)) @@ -184,13 +183,22 @@ public function hookDisplayLeftColumn() $max_child = HotelRoomType::getMaxChild($id_hotel); $category = new Category($htl_id_category); - + $urlData = array (); if (!($date_from = Tools::getValue('date_from'))) { - $date_from = date('Y-m-d'); - $date_to = date('Y-m-d', strtotime($date_from) + 86400); + $date_from = date('Y-m-d H:i:s'); + $date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400); + } else { + $urlData['date_from'] = $date_from; } + if (!($date_to = Tools::getValue('date_to'))) { - $date_to = date('Y-m-d', strtotime($date_from) + 86400); + $date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400); + } else { + $urlData['date_from'] = $date_to; + } + + if ($occupancy = Tools::getValue('occupancy')) { + $urlData['occupancy'] = $occupancy; } $obj_rm_type = new HotelRoomType(); @@ -204,13 +212,6 @@ public function hookDisplayLeftColumn() } // Create URL of category - $occupancy = Tools::getValue('occupancy'); - $urlData = array ( - 'date_from' => $date_from, - 'date_to' => $date_to, - 'occupancy' => $occupancy, - ); - if (Configuration::get('PS_REWRITING_SETTINGS')) { $categoryUrl = $this->context->link->getCategoryLink( new Category($htl_id_category, $this->context->language->id), diff --git a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php index 9f90bf6235..4a93393381 100644 --- a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php +++ b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php @@ -175,18 +175,13 @@ public function assignSearchPanelVariables() if ($locationCategoryId) { $objLocationCategory = new Category($locationCategoryId, $context->language->id); - $searchedData['location'] = $objLocationCategory->name; - } else { - $locationCategoryId = $objCategory->id_parent; - if ($searchedData['htl_dtl']) { - $searchedData['location'] = $searchedData['htl_dtl']['city']; - if (isset($searchedData['htl_dtl']['state_name'])) { - $searchedData['location'] .= ', '.$searchedData['htl_dtl']['state_name']; - } - $searchedData['location'] .= ', '.$searchedData['htl_dtl']['country_name']; + if ($objLocationCategory->hasParent(Configuration::get('PS_LOCATIONS_CATEGORY'))) { + $searchedData['location'] = $objLocationCategory->name; + $searchedData['location_category_id'] = $locationCategoryId; + } else { + $locationCategoryId = false; } } - $searchedData['location_category_id'] = $locationCategoryId; $searchedData['order_date_restrict'] = false; $max_order_date = HotelOrderRestrictDate::getMaxOrderDate($idHotel); @@ -224,7 +219,7 @@ public function assignSearchPanelVariables() } // if location is enabled the send hotels of the selected location only - if ($locationEnabled) { + if ($locationEnabled && $locationCategoryId) { $hotelsInfo = Category::getAllCategoriesName($locationCategoryId); } } diff --git a/modules/wkroomsearchblock/views/js/wk-room-search-block.js b/modules/wkroomsearchblock/views/js/wk-room-search-block.js index 36d0a4205f..8a1bec9e5b 100644 --- a/modules/wkroomsearchblock/views/js/wk-room-search-block.js +++ b/modules/wkroomsearchblock/views/js/wk-room-search-block.js @@ -115,6 +115,8 @@ const BookingSearchManager = { } } }); + } else { + $('#location_category_id').val(''); } } }, diff --git a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl index d7f89bc11a..a67e929b56 100644 --- a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl +++ b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl @@ -25,8 +25,8 @@ {if isset($location_enabled) && $location_enabled}
{$room_v['name']|escape:'htmlall':'UTF-8'}
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict} -$warning_num} style="display:none"{/if}> +
$warning_num} style="display:none"{/if}> {l s='Hurry!'} {$room_v['room_left']|escape:'htmlall':'UTF-8'} {l s='rooms left'}
{/if} @@ -115,7 +115,7 @@ {/if} {block name='room_type_list_room_book_now_button'} {/block} {/if} diff --git a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js index 5a9b17ee55..15b33b7736 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -146,8 +146,11 @@ var ajaxCart = { // var minimalQuantity = $("#quantity_wanted_" + idProduct).val(); // if (!minimalQuantity) // minimalQuantity = 1; - if ($(this).prop('disabled') != 'disabled' && occupancy) + if ($(this).prop('disabled') != 'disabled' && occupancy && !$(this).hasClass('display_type_room_list')) { ajaxCart.add(idProduct, idProductAttribute, false, this, occupancy, null, dateFrom, dateTo); + } else if ($(this).hasClass('display_type_room_list') && occupancy) { + showErrorMessage(room_selection_error_message); + } }); //for product page 'add' button... if ($('.cart_block').length) { @@ -1366,4 +1369,4 @@ function getBookingOccupancyDetails(bookingform) } return occupancy; -} \ No newline at end of file +} diff --git a/themes/hotel-reservation-theme/js/occupancy.js b/themes/hotel-reservation-theme/js/occupancy.js index b292e430ce..c13e4e13cb 100644 --- a/themes/hotel-reservation-theme/js/occupancy.js +++ b/themes/hotel-reservation-theme/js/occupancy.js @@ -235,6 +235,9 @@ $(document).ready(function(){ $(document).on('click', '.booking_occupancy_wrapper .add_new_occupancy_btn', function(e) { e.preventDefault(); + if ($(this).hasClass('disabled')) { + return; + } var booking_occupancy_wrapper = $(this).closest('.booking_occupancy_wrapper'); var occupancy_block = '';