Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated: The search flow of search result page in the front office. #1366

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions controllers/front/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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'));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']);
Expand Down
5 changes: 5 additions & 0 deletions modules/blockcart/blockcart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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']);
Expand Down
25 changes: 13 additions & 12 deletions modules/wkhotelfilterblock/wkhotelfilterblock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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();
Expand All @@ -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),
Expand Down
17 changes: 6 additions & 11 deletions modules/wkroomsearchblock/classes/WkRoomSearchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 2 additions & 0 deletions modules/wkroomsearchblock/views/js/wk-room-search-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ const BookingSearchManager = {
}
}
});
} else {
$('#location_category_id').val('');
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions modules/wkroomsearchblock/views/templates/hook/searchForm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
{if isset($location_enabled) && $location_enabled}
<div class="form-group grid-item area-4">
<div class="dropdown">
<input type="text" class="form-control header-rmsearch-input input-location" id="hotel_location" name="hotel_location" autocomplete="off" placeholder="{l s='Hotel Location' mod='wkroomsearchblock'}" {if isset($search_data)}value="{$search_data['location']|escape:'htmlall':'UTF-8'}"{/if}>
<input hidden="hidden" name="location_category_id" id="location_category_id" {if isset($search_data)}value="{$search_data['location_category_id']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="text" class="form-control header-rmsearch-input input-location" id="hotel_location" name="hotel_location" autocomplete="off" placeholder="{l s='Hotel Location' mod='wkroomsearchblock'}" {if isset($search_data['location'])}value="{$search_data['location']|escape:'htmlall':'UTF-8'}"{/if}>
<input hidden="hidden" name="location_category_id" id="location_category_id" {if isset($search_data['location_category_id'])}value="{$search_data['location_category_id']|escape:'htmlall':'UTF-8'}"{/if}>
<ul class="location_search_results_ul dropdown-menu"></ul>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
{block name='occupancy_field_actions'}
<div class="occupancy_block_actions">
<span class="add_occupancy_block">
<a class="add_new_occupancy_btn{if isset($occupancies) && $occupancies && isset($total_available_rooms) && $total_available_rooms <= count($occupancies)} disabled{/if}" data-title-available="{l s='Click to add more rooms.'}" data-title-unavailable="{l s='No more rooms available.'}" href="#">
<a class="add_new_occupancy_btn {if isset($occupancies) && $occupancies && isset($total_available_rooms) && $total_available_rooms <= count($occupancies) || isset($display_all_rooms) && $display_all_rooms} disabled{/if}" data-title-available="{l s='Click to add more rooms.'}" data-title-unavailable="{l s='No more rooms available.'}" href="#">
<i class="icon-plus"></i>
<span>{l s='Add Room'}</span>
</a>
Expand Down
8 changes: 4 additions & 4 deletions themes/hotel-reservation-theme/_partials/room_type_list.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
{block name='displayRoomTypeListBefore'}
{hook h='displayRoomTypeListBefore'}
{/block}
{if isset($booking_data['stats']) && $booking_data['stats']['num_avail']}
{if isset($booking_data['stats']) && $booking_data['stats']['num_avail'] || isset($display_all_rooms) && $display_all_rooms}
{foreach from=$booking_data['rm_data'] key=room_k item=room_v}
{if $room_v['data']['available']|count}
{if $room_v['data']['available']|count || isset($display_all_rooms) && $display_all_rooms }
<div class="col-sm-12 room_cont" data-id-product="{$room_v['id_product']|escape:'htmlall':'UTF-8'}">
<div class="row">
{block name='room_type_list_room_image'}
Expand All @@ -41,7 +41,7 @@
<div class="row">
<p class="rm_heading col-sm-12 col-md-7">{$room_v['name']|escape:'htmlall':'UTF-8'}</p>
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
<p class="rm_left col-sm-12 col-md-5" {if $room_v['room_left'] > $warning_num} style="display:none"{/if}>
<p class="rm_left col-sm-12 col-md-5" {if isset($display_all_rooms) && $display_all_rooms || $room_v['room_left'] > $warning_num} style="display:none"{/if}>
{l s='Hurry!'} <span class="remain_rm_qty">{$room_v['room_left']|escape:'htmlall':'UTF-8'}</span> {l s='rooms left'}
</p>
{/if}
Expand Down Expand Up @@ -115,7 +115,7 @@
{/if}
{block name='room_type_list_room_book_now_button'}
<div>
<a cat_rm_check_in="{$booking_date_from|escape:'htmlall':'UTF-8'}" cat_rm_check_out="{$booking_date_to|escape:'htmlall':'UTF-8'}" href="" rm_product_id="{$room_v['id_product']}" cat_rm_book_nm_days="{$num_days|escape:'htmlall':'UTF-8'}" data-id-product-attribute="0" data-id-product="{$room_v['id_product']|intval}" class="btn btn-default button button-medium ajax_add_to_cart_button"><span>{l s='Book Now'}</span></a>
<a cat_rm_check_in="{$booking_date_from|escape:'htmlall':'UTF-8'}" cat_rm_check_out="{$booking_date_to|escape:'htmlall':'UTF-8'}" href="" rm_product_id="{$room_v['id_product']}" cat_rm_book_nm_days="{$num_days|escape:'htmlall':'UTF-8'}" data-id-product-attribute="0" data-id-product="{$room_v['id_product']|intval}" class="btn btn-default button button-medium ajax_add_to_cart_button {if isset($display_all_rooms) && $display_all_rooms} display_type_room_list {/if}"><span>{l s='Book Now'}</span></a>
</div>
{/block}
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1366,4 +1369,4 @@ function getBookingOccupancyDetails(bookingform)
}

return occupancy;
}
}
3 changes: 3 additions & 0 deletions themes/hotel-reservation-theme/js/occupancy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down