diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 164d695d9..d4e986b49 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1583,6 +1583,9 @@ class HotelBookingDetail extends ObjectModel if ($occupancy) { $urlData['occupancy'] = $occupancy; } + if ($location = Tools::getValue('location')) { + $urlData['location'] = $location; + } if (Configuration::get('PS_REWRITING_SETTINGS')) { $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product).'?'.http_build_query($urlData); diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index 101cc7245..4482606ae 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -518,7 +518,7 @@ class HotelBranchInformation extends ObjectModel ON (hbl.`id` = hbi.`id` AND hbl.`id_lang` = '.(int)$idLang.') WHERE hbi.`id_category` = '.(int)$cat_id.' AND `active` = 1'; - return Db::getInstance()->executeS($sql); + return Db::getInstance()->getRow($sql); } /** @@ -537,7 +537,7 @@ class HotelBranchInformation extends ObjectModel FROM `'._DB_PREFIX_.'category_lang` AS cl INNER JOIN `'._DB_PREFIX_.'category` AS c ON (cl.`id_category` = c.`id_category`) WHERE cl.`name` LIKE \'%'.pSQL($searchData).'%\' - AND c.`level_depth` NOT IN (0, 1, 5) and cl.`id_lang`='.(int)$context->language->id.' + AND c.`level_depth` NOT IN (0, 1, 6) and cl.`id_lang`='.(int)$context->language->id.' AND c.`nleft` > '.(int)$locationCategory->nleft.' AND c.`nright` < '.(int)$locationCategory->nright.' GROUP BY cl.`name`' ); diff --git a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php index e0543f189..ea14b1bca 100644 --- a/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php +++ b/modules/wkroomsearchblock/classes/WkRoomSearchHelper.php @@ -98,6 +98,7 @@ class WkRoomSearchHelper public function assignSearchPanelVariables() { $smartyVars = array(); + $context = Context::getContext(); // send if page is landing or not $smartyVars['is_index_page'] = 0; if (Tools::getValue('controller') == 'index') { @@ -127,6 +128,7 @@ class WkRoomSearchHelper // if category page $idHotelCategory = Tools::getValue('id_category'); } + $locationCategoryId = Tools::getValue('location'); if ($idHotelCategory) { if (Validate::isLoadedObject($objCategory = new Category((int) $idHotelCategory))) { if ($objCategory->hasParent(Configuration::get('PS_LOCATIONS_CATEGORY'))) { @@ -152,11 +154,18 @@ class WkRoomSearchHelper $searchedData['date_to'] = $dateTo; $searchedData['htl_dtl'] = $objHotelInfo->hotelBranchesInfo(0, 1, 1, $idHotel); - $searchedData['location'] = $searchedData['htl_dtl']['city']; - if (isset($searchedData['htl_dtl']['state_name'])) { - $searchedData['location'] .= ', '.$searchedData['htl_dtl']['state_name']; + if ($locationCategoryId) { + $objLocationCategory = new Category($locationCategoryId, $context->language->id); + $searchedData['location'] = $objLocationCategory->name; + } else { + $locationCategoryId = $objCategory->id_parent; + $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']; } - $searchedData['location'] .= ', '.$searchedData['htl_dtl']['country_name']; + $searchedData['location_category_id'] = $locationCategoryId; $searchedData['order_date_restrict'] = false; $max_order_date = HotelOrderRestrictDate::getMaxOrderDate($idHotel); @@ -191,16 +200,22 @@ class WkRoomSearchHelper // if location is enabled the send hotels of the selected location only if ($locationEnabled) { - $hotelsInfo = $objHotelInfo->hotelBranchInfoByCategoryId($idHotelCategory); + $hotelsInfo = Category::getAllCategoriesName($locationCategoryId); } } $totalActiveHotels = count($hotelsInfo); // set hotels order restrict date on all hotels - foreach ($hotelsInfo as &$hotel) { - $maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel['id']); - $hotel['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate)); - $hotel['preparation_time'] = (int) HotelOrderRestrictDate::getPreparationTime($hotel['id']); + foreach ($hotelsInfo as $key => $hotel) { + if ($hotel_info = $objHotelInfo->hotelBranchInfoByCategoryId($hotel['id_category'])) { + $maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel_info['id']); + $hotelsInfo[$key]['id'] = $hotel_info['id']; + $hotelsInfo[$key]['hotel_name'] = $hotel_info['hotel_name']; + $hotelsInfo[$key]['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate)); + $hotelsInfo[$key]['preparation_time'] = (int) HotelOrderRestrictDate::getPreparationTime($hotel_info['id']); + } else { + unset($hotelsInfo[$key]); + } } $smartyVars['location_enabled'] = $locationEnabled; $smartyVars['total_active_hotels'] = $totalActiveHotels; diff --git a/modules/wkroomsearchblock/controllers/front/autocompletesearch.php b/modules/wkroomsearchblock/controllers/front/autocompletesearch.php index d8aa6ad59..4a051c103 100644 --- a/modules/wkroomsearchblock/controllers/front/autocompletesearch.php +++ b/modules/wkroomsearchblock/controllers/front/autocompletesearch.php @@ -26,7 +26,7 @@ class WkRoomSearchBlockAutoCompleteSearchModuleFrontController extends ModuleFro $this->display_column_left = false; $this->display_column_right = false; $search_data = Tools::getValue('to_search_data'); - $city_cat_id = Tools::getValue('hotel_city_cat_id'); + $location_category_id = Tools::getValue('location_category_id'); $obj_htl_info = new HotelBranchInformation(); if (isset($search_data) && $search_data) { $return_data = $obj_htl_info->getHotelCategoryTree($search_data); @@ -39,17 +39,17 @@ class WkRoomSearchBlockAutoCompleteSearchModuleFrontController extends ModuleFro $result['status'] = 'success'; $result['data'] = $html; } - } elseif (isset($city_cat_id) && $city_cat_id) { - $cat_ids = Category::getAllCategoriesName($city_cat_id); + } elseif (isset($location_category_id) && $location_category_id) { + $cat_ids = Category::getAllCategoriesName($location_category_id); if ($cat_ids) { $html = ''; foreach ($cat_ids as $value) { if ($hotel_info = $obj_htl_info->hotelBranchInfoByCategoryId($value['id_category'])) { - $maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel_info[0]['id']); + $maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel_info['id']); $maxOrderDate = date('Y-m-d', strtotime($maxOrderDate)); - $html .= '