Improve search flow

This commit is contained in:
Abhishek Kumar
2023-10-17 17:47:07 +05:30
parent fcbcc13c07
commit 87ac2f128e
13 changed files with 707 additions and 78 deletions

View File

@@ -199,6 +199,7 @@ class HotelHelper
Configuration::updateValue('WK_HOTEL_LOCATION_ENABLE', 1);
Configuration::updateValue('WK_HOTEL_NAME_ENABLE', 1);
Configuration::updateValue('WK_HOTEL_NAME_SEARCH_THRESHOLD', 5);
Configuration::updateValue('WK_ROOM_LEFT_WARNING_NUMBER', 10);
Configuration::updateValue('WK_HTL_ESTABLISHMENT_YEAR', 2010);

View File

@@ -81,6 +81,15 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
'hint' => $this->l('This option can be disabled if only one active hotel in the website.
In case of more than one active hotel, Hotel Name will always be shown in the search panel.'),
),
'WK_HOTEL_NAME_SEARCH_THRESHOLD' => array(
'title' => $this->l('Hotel name search threshold'),
'type' => 'text',
'required' => true,
'validation' => 'isUnsignedInt',
'hint' => $this->l('Enter the number of hotels after which user can search hotel by name.'),
'desc' => $this->l('Set to 0 to always show the search box.'),
'class' => 'fixed-width-xxl',
),
),
'submit' => array(
'title' => $this->l('Save'),
@@ -290,6 +299,8 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
public function postProcess()
{
if (Tools::isSubmit('submitOptions'.$this->table)) {
$hotelNameSearchThreshold = Tools::getValue('WK_HOTEL_NAME_SEARCH_THRESHOLD');
// check if field is atleast in default language. Not available in default prestashop
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
$objDefaultLanguage = Language::getLanguage((int) $defaultLangId);
@@ -302,6 +313,12 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
// End occupancy fields validation
if (!$hotelNameSearchThreshold && $hotelNameSearchThreshold !== '0') {
$this->errors[] = $this->l('Hotel name search threshold field is required.');
} elseif (!Validate::isUnsignedInt(Tools::getValue('WK_HOTEL_NAME_SEARCH_THRESHOLD'))) {
$this->errors[] = $this->l('Hotel name search threshold field is invalid.');
}
if (!trim(Tools::getValue('WK_HTL_CHAIN_NAME_'.$defaultLangId))) {
$this->errors[] = $this->l('Hotel chain name is required at least in ').$objDefaultLanguage['name'];
} else {

View File

@@ -226,6 +226,7 @@ class WkRoomSearchHelper
$smartyVars['hotels_info'] = $hotelsInfo;
$smartyVars['show_hotel_name'] = Configuration::get('WK_HOTEL_NAME_ENABLE');
$smartyVars['max_child_age'] = Configuration::get('WK_GLOBAL_CHILD_MAX_AGE');
$smartyVars['hotel_name_search_threshold'] = (int) Configuration::get('WK_HOTEL_NAME_SEARCH_THRESHOLD');
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($idHotel);
$smartyVars['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate));

View File

@@ -29,29 +29,39 @@ class WkRoomSearchBlockAutoCompleteSearchModuleFrontController extends ModuleFro
$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);
if ($return_data) {
$html = '';
foreach ($return_data as $value) {
$html .= '<li value="'.$value['id_category'].'" tabindex="-1" class="search_result_li">'.
$value['name'].'</li>';
}
$locationCategories = $obj_htl_info->getHotelCategoryTree($search_data);
if ($locationCategories) {
$this->context->smarty->assign(array('location_categories' => $locationCategories));
$html = $this->context->smarty->fetch(
$this->module->getTemplatePath('location-options.tpl')
);
$result['status'] = 'success';
$result['data'] = $html;
}
} 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['id']);
$locationCategories = Category::getAllCategoriesName($location_category_id);
if ($locationCategories) {
$hotelsInfo = array();
foreach ($locationCategories as $category) {
if ($hotelInfo = $obj_htl_info->hotelBranchInfoByCategoryId($category['id_category'])) {
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotelInfo['id']);
$maxOrderDate = date('Y-m-d', strtotime($maxOrderDate));
$html .= '<li tabindex="-1" class="search_result_li" data-id-hotel="'.$hotel_info['id'].'" data-hotel-cat-id="'.
$hotel_info['id_category'].'" data-max_order_date="'.$maxOrderDate.'">'.
$hotel_info['hotel_name'].'</li>';
$hotelsInfo[] = array(
'id_hotel' => $hotelInfo['id'],
'id_category' => $hotelInfo['id_category'],
'hotel_name' => $hotelInfo['hotel_name'],
'max_order_date' => $maxOrderDate,
);
}
}
$this->context->smarty->assign(array('hotels_info' => $hotelsInfo));
$html = $this->context->smarty->fetch(
$this->module->getTemplatePath('hotel-options.tpl')
);
$result['status'] = 'success';
$result['data'] = $html;
} else {

View File

@@ -0,0 +1,483 @@
/**
* 2010-2023 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through LICENSE.txt file inside our module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to CustomizationPolicy.txt file inside our module for more information.
*
* @author Webkul IN
* @copyright 2010-2023 Webkul IN
* @license LICENSE.txt
*/
/* @group Base */
.chosen-container {
position: relative;
vertical-align: middle;
font-size: 14px;
zoom: 1;
display: inline;
-moz-user-select: -moz-none;
-ms-user-select: none;
-webkit-user-select: none;
user-select: none;
}
.chosen-container .chosen-drop {
position: absolute;
top: 0;
left: -9999px;
z-index: 1010;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
border-top: 0;
box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15);
}
.chosen-container.chosen-container-single-nosearch .chosen-drop {
top: 100%;
}
.chosen-container.chosen-with-drop .chosen-drop {
left: 0;
}
.chosen-container a {
cursor: pointer;
}
/* @end */
/* @group Single Chosen */
.chosen-container-single .chosen-single {
position: relative;
display: block;
overflow: hidden;
padding-left: 35px;
height: 100%;
border: 1px solid #aaa;
border-radius: 4px;
background-clip: padding-box;
box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(0, 0, 0, 0.1);
color: #444;
text-decoration: none;
white-space: nowrap;
line-height: 24px;
background: #fff url('../img/icon-hotel.svg') no-repeat 10px 50%;
}
.chosen-container-single.error_border .chosen-single {
border: 2px solid red !important;
}
.chosen-container-single .chosen-default {
color: #999;
}
.chosen-container-single .chosen-single span {
display: block;
overflow: hidden;
margin-right: 26px;
text-overflow: ellipsis;
white-space: nowrap;
position: relative;
top: 15px;
color: #333;
}
.chosen-container-single .chosen-single-with-deselect span {
margin-right: 38px;
}
.chosen-container-single .chosen-single abbr {
position: absolute;
top: 6px;
right: 26px;
display: block;
width: 12px;
height: 12px;
background: url('chosen-sprite.png') -42px 1px no-repeat;
font-size: 1px;
}
.chosen-container-single .chosen-single abbr:hover {
background-position: -42px -10px;
}
.chosen-container-single.chosen-disabled .chosen-single abbr:hover {
background-position: -42px -10px;
}
.chosen-container-single .chosen-single div {
position: absolute;
top: 0;
right: 0;
display: block;
width: 18px;
height: 100%;
}
.chosen-container-single .chosen-single div b {
display: block;
width: 100%;
height: 100%;
background: url('../../../../themes/hotel-reservation-theme/img/icon/icon-dropdown-arrow.svg') no-repeat calc(100% - 8px) 50%;
}
.chosen-container-single .chosen-search {
position: relative;
z-index: 1010;
margin: 0;
white-space: nowrap;
background: #fff;
border-radius: 4px;
height: 55px;
}
.chosen-container-single .chosen-search::after {
content: '';
position: absolute;
top: 16px;
right: 1px;
height: 22px;
width: 19px;
background: url('../../../../themes/hotel-reservation-theme/img/icon/icon-dropdown-arrow.svg') no-repeat calc(100% - 8px) 50%;
/* background: url('../img/icon-hotel.svg') no-repeat 9px 50%; */
}
.chosen-container-single .chosen-search input[type="text"] {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
padding-left: 35px;
width: 100%;
height: 100%;
outline: 0;
border: none;
font-size: 1em;
line-height: normal;
border-radius: 4px;
background: url('../img/icon-hotel.svg') no-repeat 9px 50%;
}
.chosen-container-single.chosen-container-active .chosen-search input[type="text"] {
border: 2px solid #1292FF;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
}
.chosen-container-single .chosen-drop {
margin-top: -1px;
border-radius: 0 0 4px 4px;
background-clip: padding-box;
}
.chosen-container-single.chosen-container-single-nosearch .chosen-search {
position: absolute;
left: -9999px;
}
/* @end */
/* @group Results */
.chosen-container .chosen-results {
position: relative;
overflow-x: hidden;
overflow-y: auto;
max-height: 240px;
background: #fff;
margin-top: 2px;
margin-bottom: 0;
}
.chosen-container .chosen-results li {
display: none;
margin: 0;
padding: 15px;
list-style: none;
color: #333;
}
.chosen-container .chosen-results li.active-result {
display: list-item;
cursor: pointer;
}
.chosen-container .chosen-results li.disabled-result {
display: list-item;
color: #ccc;
cursor: default;
}
.chosen-container .chosen-results li.highlighted {
background-color: #379bf0;
color: #fff;
}
.chosen-container .chosen-results li.no-results {
display: list-item;
background: #f4f4f4;
}
.chosen-container .chosen-results li.group-result {
display: list-item;
font-weight: bold;
cursor: default;
}
.chosen-container .chosen-results li.group-option {
padding-left: 15px;
}
.chosen-container .chosen-results li em {
font-style: normal;
text-decoration: underline;
}
/* @end */
/* @group Multi Chosen */
.chosen-container-multi .chosen-choices {
position: relative;
overflow: hidden;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
width: 100%;
height: auto !important;
height: 1%;
border: 1px solid #aaa;
background-color: #fff;
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIxJSIgc3RvcC1jb2xvcj0iI2VlZWVlZSIvPjxzdG9wIG9mZnNldD0iMTUlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
background-size: 100%;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
background-image: -moz-linear-gradient(#eeeeee 1%, #ffffff 15%);
background-image: -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%);
background-image: linear-gradient(#eeeeee 1%, #ffffff 15%);
cursor: text;
}
.chosen-container-multi .chosen-choices li {
float: left;
list-style: none;
}
.chosen-container-multi .chosen-choices li.search-field {
margin: 0;
padding: 0;
white-space: nowrap;
}
.chosen-container-multi .chosen-choices li.search-field input[type="text"] {
margin: 1px 0;
padding: 5px;
height: 15px;
outline: 0;
border: 0 !important;
background: transparent !important;
box-shadow: none;
color: #666;
font-size: 100%;
line-height: normal;
border-radius: 0;
}
.chosen-container-multi .chosen-choices li.search-field .default {
color: #999;
}
.chosen-container-multi .chosen-choices li.search-choice {
position: relative;
margin: 3px 0 3px 5px;
padding: 3px 20px 3px 5px;
border: 1px solid #aaa;
border-radius: 3px;
background-color: #e4e4e4;
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIyMCUiIHN0b3AtY29sb3I9IiNmNGY0ZjQiLz48c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2YwZjBmMCIvPjxzdG9wIG9mZnNldD0iNTIlIiBzdG9wLWNvbG9yPSIjZThlOGU4Ii8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjZWVlZWVlIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
background-size: 100%;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
background-image: -moz-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-image: -webkit-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-clip: padding-box;
box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
color: #333;
line-height: 13px;
cursor: default;
}
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
position: absolute;
top: 4px;
right: 3px;
display: block;
width: 12px;
height: 12px;
background: url('chosen-sprite.png') -42px 1px no-repeat;
font-size: 1px;
}
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
background-position: -42px -10px;
}
.chosen-container-multi .chosen-choices li.search-choice-disabled {
padding-right: 5px;
border: 1px solid #ccc;
background-color: #e4e4e4;
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIyMCUiIHN0b3AtY29sb3I9IiNmNGY0ZjQiLz48c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2YwZjBmMCIvPjxzdG9wIG9mZnNldD0iNTIlIiBzdG9wLWNvbG9yPSIjZThlOGU4Ii8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjZWVlZWVlIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
background-size: 100%;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
color: #666;
}
.chosen-container-multi .chosen-choices li.search-choice-focus {
background: #d4d4d4;
}
.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close {
background-position: -42px -10px;
}
.chosen-container-multi .chosen-results {
margin: 0;
padding: 0;
}
.chosen-container-multi .chosen-drop .result-selected {
display: list-item;
color: #ccc;
cursor: default;
}
/* @end */
/* @group Active */
.chosen-container-active .chosen-single {
border: 2px solid #1292FF;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
}
.chosen-container-active.chosen-with-drop .chosen-single div {
border-left: none;
background: transparent;
}
.chosen-container-active .chosen-choices {
border: 1px solid #5897fb;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.chosen-container-active .chosen-choices li.search-field input[type="text"] {
color: #111 !important;
}
/* @end */
/* @group Disabled Support */
.chosen-disabled {
opacity: 0.5 !important;
cursor: default;
}
.chosen-disabled .chosen-single {
cursor: default;
}
.chosen-disabled .chosen-choices .search-choice .search-choice-close {
cursor: default;
}
/* chosen-drop top - start */
.hotel-selector-wrap .chosen-container .chosen-drop.top .chosen-results {
position: absolute;
width: 100%;
bottom: calc(100% + 2px);
}
.hotel-selector-wrap .chosen-container.chosen-container-single-nosearch .chosen-drop.top .chosen-results {
position: absolute;
width: 100%;
bottom: calc(100% + 55px);
}
/* chosen-drop top - end */
/* @end */
/* @group Right to Left */
.chosen-rtl {
text-align: right;
}
.chosen-rtl .chosen-single {
overflow: visible;
padding: 0 8px 0 0;
}
.chosen-rtl .chosen-single span {
margin-right: 0;
margin-left: 26px;
direction: rtl;
}
.chosen-rtl .chosen-single-with-deselect span {
margin-left: 38px;
}
.chosen-rtl .chosen-single div {
right: auto;
left: 3px;
}
.chosen-rtl .chosen-single abbr {
right: auto;
left: 26px;
}
.chosen-rtl .chosen-choices li {
float: right;
}
.chosen-rtl .chosen-choices li.search-field input[type="text"] {
direction: rtl;
}
.chosen-rtl .chosen-choices li.search-choice {
margin: 3px 5px 3px 0;
padding: 3px 5px 3px 19px;
}
.chosen-rtl .chosen-choices li.search-choice .search-choice-close {
right: auto;
left: 4px;
}
.chosen-rtl.chosen-container-single-nosearch .chosen-search,
.chosen-rtl .chosen-drop {
left: 9999px;
}
.chosen-rtl.chosen-container-single .chosen-results {
margin: 0 0 4px 4px;
padding: 0 4px 0 0;
}
.chosen-rtl .chosen-results li.group-option {
padding-right: 15px;
padding-left: 0;
}
.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div {
border-right: none;
}
.chosen-rtl .chosen-search input[type="text"] {
padding: 4px 5px 4px 20px;
background: #fff url('chosen-sprite.png') no-repeat -30px -20px;
background: url('chosen-sprite.png') no-repeat -30px -20px, url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIxJSIgc3RvcC1jb2xvcj0iI2VlZWVlZSIvPjxzdG9wIG9mZnNldD0iMTUlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
background: url('chosen-sprite.png') no-repeat -30px -20px, -moz-linear-gradient(#eeeeee 1%, #ffffff 15%);
background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%);
background: url('chosen-sprite.png') no-repeat -30px -20px, linear-gradient(#eeeeee 1%, #ffffff 15%);
direction: rtl;
}
.chosen-rtl.chosen-container-single .chosen-single div b {
background-position: 6px 2px;
}
.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b {
background-position: -12px 2px;
}
.chosen-container .chosen-drop.dropup {
border-bottom: 0;
border-top: 1px solid #aaa;
top: auto;
bottom: 40px;
}
.chosen-container.chosen-with-drop .chosen-single.dropup {
background-image: none;
}
.chosen-container.chosen-with-drop .chosen-drop.dropup {
box-shadow: none;
margin-bottom: -16px;
}
/* @end */
/* @group Retina compatibility */
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) {
.chosen-rtl .chosen-search input[type="text"],
.chosen-container-single .chosen-single abbr,
.chosen-container-single .chosen-single div b,
.chosen-container-single .chosen-search input[type="text"],
.chosen-container-multi .chosen-choices .search-choice .search-choice-close,
.chosen-container .chosen-results-scroll-down span,
.chosen-container .chosen-results-scroll-up span {
background-image: url('chosen-sprite@2x.png') !important;
background-size: 52px 37px !important;
background-repeat: no-repeat !important;
}
}
/* @end */
/* search results page - start */
#category .chosen-container-single .chosen-single span {
min-height: 45px;
top: 11px;
}
/* search results page - end */

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

View File

@@ -26,7 +26,7 @@ const BookingSearchManager = {
},
'hotel': {
selector: '#id_hotel_button',
activate: function() { $('#id_hotel_button').click(); },
activate: function() { $('#id_hotel_button').trigger('chosen:open'); },
inputHasValue: function () { return ($('#id_hotel').val() != '') && ($('#hotel_cat_id').val() != ''); },
},
'date_range': {
@@ -52,6 +52,10 @@ const BookingSearchManager = {
}
}
},
allFieldsFilled: function () {
return this.inputSteps['hotel'].inputHasValue()
&& this.inputSteps['date_range'].inputHasValue()
}
}
$(document).ready(function() {
@@ -161,7 +165,9 @@ $(document).ready(function() {
$('#check_in_time').val($.datepicker.formatDate('yy-mm-dd', obj.date1));
$('#check_out_time').val($.datepicker.formatDate('yy-mm-dd', obj.date2));
}).on('datepicker-closed', function() {
BookingSearchManager.activateStep('occupancy');
if ($('#check_in_time').val() != '' && $('#check_out_time').val() != '') {
BookingSearchManager.activateStep('occupancy');
}
});
}
@@ -211,14 +217,14 @@ $(document).ready(function() {
}
});
// if user clicks anywhere and location/hotel li is visible the select first li as selection
// if user clicks anywhere and location li is visible then close it
$('body').on('click', function(e) {
if ($('.location_search_results_ul').is(':visible') && e.target.className != "search_result_li" && e.target.id != "hotel_location") {
$('.location_search_results_ul .search_result_li:first').click();
}
if ($('.hotel_dropdown_ul').is(':visible') && e.target.className != "search_result_li" && e.target.id != "hotel_location") {
$('.hotel_dropdown_ul .search_result_li:first').click();
if ($('.location_search_results_ul').is(':visible')
&& e.target.className != 'search_result_li'
&& e.target.id != 'hotel_location'
) {
$('.location_search_results_ul').hide();
$('#hotel_location').val(hotel_location_txt);
}
});
@@ -244,9 +250,8 @@ $(document).ready(function() {
success: function(result) {
if (result.status == 'success') {
$('#hotel_cat_id').val('');
$('#hotel_cat_name').html('Select Hotel');
$('.hotel_dropdown_ul').empty();
$('.hotel_dropdown_ul').html(result.data);
$('#id_hotel_button').html(result.data);
$('#id_hotel_button').trigger('chosen:updated');
if (focusHotelSelection) {
BookingSearchManager.activateStep('hotel');
@@ -262,6 +267,11 @@ $(document).ready(function() {
}
});
// prevents calendar from closing on hotel selection
$(document).on('click', '#id_hotel_button_chosen li', function(e) {
e.stopPropagation();
});
// navigate to prev and next li in the location/hotel dropdown
$('body').on('keyup', 'li.search_result_li', function(e) {
if (e.which == 40 || e.which == 38) {
@@ -285,15 +295,6 @@ $(document).ready(function() {
}
});
// when focus goes from hotel button to li list of hotels
$(document).on('keyup', "#id_hotel_button", function(e) {
if ($('.hotel_dropdown_ul').is(':visible')) {
if ($('.hotel_dropdown_ul .search_result_li').length) {
$(".hotel_dropdown_ul li:first").focus();
}
}
});
// if user is selecting the location by keydown / up key
$(document).on('keydown', 'body', function(e) {
if ((e.which == 40 || e.which == 38) && ($('.location_search_results_ul li.search_result_li').is(':visible') || $('.hotel_dropdown_ul li.search_result_li').is(':visible'))) {
@@ -311,15 +312,20 @@ $(document).ready(function() {
}
});
$(document).on('click', '.hotel_dropdown_ul li', function() {
let max_order_date = $(this).attr('data-max_order_date');
let preparation_time = $(this).attr('data-preparation_time')
$(document).on('change', '#id_hotel_button', function() {
let selectedHotel = $(this).find('option:selected');
let max_order_date = $(selectedHotel).attr('data-max_order_date');
let preparation_time = $(selectedHotel).attr('data-preparation_time')
createDateRangePicker(max_order_date, preparation_time, $('#check_in_time').val(), $('#check_out_time').val());
$("#max_order_date").val(max_order_date);
$('#preparation_time').val(preparation_time);
$('#id_hotel').val($(this).attr('data-id-hotel'));
$('#hotel_cat_id').val($(this).attr('data-hotel-cat-id'));
$('#hotel_cat_name').html($(this).html());
$('#id_hotel').val($(selectedHotel).attr('data-id-hotel'));
$('#hotel_cat_id').val($(selectedHotel).attr('data-hotel-cat-id'));
$('#hotel_cat_name').html($(selectedHotel).html());
BookingSearchManager.activateStep('date_range');
});
@@ -344,7 +350,7 @@ $(document).ready(function() {
$("#hotel_location").addClass("error_border");
error = true;
}
$("#id_hotel_button").addClass("error_border");
$("#id_hotel_button_chosen").addClass("error_border");
$('#select_htl_error_p').text(hotel_name_cond);
error = true;
}
@@ -543,6 +549,7 @@ $(document).ready(function() {
// toggle occupancy block
$('#guest_occupancy').on('click', function(e) {
e.stopPropagation();
$('#daterange_value').data('dateRangePicker').close();
$("#search_occupancy_wrapper").toggle();
});
@@ -592,7 +599,9 @@ $(document).ready(function() {
if (hasErrors == 0) {
$("#search_occupancy_wrapper").hide();
$("#search_hotel_block_form #guest_occupancy").removeClass('error_border');
BookingSearchManager.activateStep('submit');
if (BookingSearchManager.allFieldsFilled()) {
BookingSearchManager.activateStep('submit');
}
} else {
$("#search_hotel_block_form #guest_occupancy").addClass('error_border');
return false;
@@ -603,12 +612,19 @@ $(document).ready(function() {
});
if (page_name == 'index') {
// set search dropdown position handlers
$('#hotel_location, #id_hotel_button, #guest_occupancy').focus(function () {
$('#hotel_location, #guest_occupancy').focus(function () {
setBookingSearchDropdownPositions();
setBookingSearchCalendarPositions();
});
// after chosen has been initialized
$('select#id_hotel_button').on('chosen:ready', function() {
$('#id_hotel_button_chosen .chosen-search input').focus(function () {
setBookingSearchDropdownPositions();
setBookingSearchCalendarPositions();
});
});
$('#daterange_value').click(function () {
setBookingSearchDropdownPositions();
setBookingSearchCalendarPositions();
@@ -619,6 +635,7 @@ $(document).ready(function() {
$(document).on('keydown', '.location_search_results_ul li', function (e) {
if (e.which == 9 || e.which == 13) { // Tab/Enter key
if (e.which == 9) {
e.preventDefault();
$(this).click();
}
if ($('#id_hotel_button').length) {
@@ -648,6 +665,22 @@ $(document).ready(function() {
}
});
// handle Tab keypresses on input fields - end
$('select#id_hotel_button').chosen({
search_contains: true,
disable_search: !hotel_name_has_search,
width: '100%',
});
if (hotel_name_has_search) {
$('select#id_hotel_button').on('chosen:showing_dropdown', function() {
$(this).siblings('.chosen-container').find('.chosen-single').addClass('invisible')
});
$('select#id_hotel_button').on('chosen:hiding_dropdown', function() {
$(this).siblings('.chosen-container').find('.chosen-single').removeClass('invisible')
});
}
});
// function to set occupancy infor in guest occupancy field(search form)
function setGuestOccupancy()
@@ -685,25 +718,34 @@ function setGuestOccupancy()
function setBookingSearchDropdownPositions() {
let inputFieldsAndDropdowns = [
{ input: $('#hotel_location'), dropdown: $('.location_search_results_ul')},
{ input: $('#id_hotel_button'), dropdown: $('.dropdown-menu.hotel_dropdown_ul')},
{ input: $('.hotel-selector-wrap'), dropdown: $('#id_hotel_button_chosen .chosen-drop')},
{ input: $('#guest_occupancy'), dropdown: $('#search_occupancy_wrapper')},
];
let dropdownHeightMax = 0;
let spaceTopMax = 0;
let spaceBottomMax = 0;
$(inputFieldsAndDropdowns).each(function (i, inputFieldAndDropdown) {
// find available space
let inputFieldHeight = inputFieldAndDropdown.input.outerHeight();
let spaceTop = inputFieldAndDropdown.input.offset().top - $(window).scrollTop();
let spaceBottom = $(window).height() - inputFieldHeight - spaceTop;
let cssMaxHeight = inputFieldAndDropdown.dropdown.css('max-height') || '292px';
let dropdownMaxHeight = parseInt(cssMaxHeight.replace('px', ''));
dropdownMaxHeight = Math.max(dropdownMaxHeight, 292); // 292 is height of the calendar
let dropdownHeight = parseInt(cssMaxHeight.replace('px', ''));
dropdownHeight = Math.max(dropdownHeight || 0, 292); // 292 is height of the calendar
let dropdownClass = 'bottom';
if (spaceBottom < dropdownMaxHeight && spaceTop > spaceBottom) {
dropdownClass = 'top';
}
dropdownHeightMax = Math.max(dropdownHeightMax, dropdownHeight);
spaceTopMax = Math.max(spaceTopMax, spaceTop);
spaceBottomMax = Math.max(spaceBottomMax, spaceBottom);
});
// position dropdown
let dropdownClass = 'bottom';
if (spaceBottomMax < dropdownHeightMax && spaceTopMax > spaceBottomMax) {
dropdownClass = 'top';
}
$(inputFieldsAndDropdowns).each(function (i, inputFieldAndDropdown) {
inputFieldAndDropdown.dropdown.removeClass('top bottom').addClass(dropdownClass);
});
}

View File

@@ -0,0 +1,27 @@
{**
* 2010-2023 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through LICENSE.txt file inside our module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to CustomizationPolicy.txt file inside our module for more information.
*
* @author Webkul IN
* @copyright 2010-2023 Webkul IN
* @license LICENSE.txt
*}
<option value=""></option>
{if isset($hotels_info) && is_array($hotels_info)}
{foreach from=$hotels_info item=hotel_info}
<option class="search_result_li" data-id-hotel="{$hotel_info.id_hotel}" data-hotel-cat-id="{$hotel_info.id_category}" data-max_order_date="{$hotel_info.max_order_date}" tabindex="-1">
{$hotel_info.hotel_name}
</option>
{/foreach}
{/if}

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2023 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through LICENSE.txt file inside our module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to CustomizationPolicy.txt file inside our module for more information.
*
* @author Webkul IN
* @copyright 2010-2023 Webkul IN
* @license LICENSE.txt
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,24 @@
{**
* 2010-2023 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through LICENSE.txt file inside our module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to CustomizationPolicy.txt file inside our module for more information.
*
* @author Webkul IN
* @copyright 2010-2023 Webkul IN
* @license LICENSE.txt
*}
{if isset($location_categories) && is_array($location_categories)}
{foreach from=$location_categories item=category}
<li class="search_result_li" value="{$category.id_category}" tabindex="-1">{$category.name}</li>
{/foreach}
{/if}

View File

@@ -1,7 +1,7 @@
<form method="POST" id="search_hotel_block_form" class="grid">
{if isset($location_enabled) && $location_enabled}
<div class="form-group area-{$column_widths['location']}">
<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 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}>
<div class="dropdown">
<ul class="location_search_results_ul dropdown-menu"></ul>
@@ -16,29 +16,19 @@
<input type="hidden" id="htl_name" class="form-control header-rmsearch-input" value="{$hotels_info[0]['hotel_name']}" readonly>
{else}
<div class="form-group area-{$column_widths['hotel']}">
{if isset($hotels_info) && count($hotels_info)}
<div class="dropdown">
<input type="hidden" id="hotel_cat_id" name="hotel_cat_id" {if isset($search_data)}value="{$search_data['htl_dtl']['id_category']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="hidden" id="id_hotel" name="id_hotel" {if isset($search_data)}value="{$search_data['htl_dtl']['id']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="hidden" id="max_order_date" name="max_order_date" value="{if isset($max_order_date)}{$max_order_date|escape:'htmlall':'UTF-8'}{/if}">
<input type="hidden" id="preparation_time" name="preparation_time" value="{if isset($preparation_time)}{$preparation_time|escape:'htmlall':'UTF-8'}{/if}">
<input type="hidden" id="hotel_cat_id" name="hotel_cat_id" {if isset($search_data)}value="{$search_data['htl_dtl']['id_category']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="hidden" id="id_hotel" name="id_hotel" {if isset($search_data)}value="{$search_data['htl_dtl']['id']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="hidden" id="max_order_date" name="max_order_date" value="{if isset($max_order_date)}{$max_order_date|escape:'htmlall':'UTF-8'}{/if}">
<input type="hidden" id="preparation_time" name="preparation_time" value="{if isset($preparation_time)}{$preparation_time|escape:'htmlall':'UTF-8'}{/if}">
<button class="form-control header-rmsearch-input input-hotel {if isset($error) && $error == 1}error_border{/if}" type="button" data-toggle="dropdown" id="id_hotel_button">
{if isset($search_data)}
<span id="hotel_cat_name" class="pull-left">{$search_data['htl_dtl']['hotel_name']|escape:'htmlall':'UTF-8'}</span>
{else}
<span id="hotel_cat_name" class="pull-left">{l s='Select Hotel' mod='wkroomsearchblock'}</span>
{/if}
</button>
<ul class="dropdown-menu hotel_dropdown_ul">
{if isset($hotels_info) && $hotels_info}
{foreach $hotels_info as $name_val}
<li tabindex="-1" class="search_result_li" data-id-hotel="{$name_val['id']|escape:'htmlall':'UTF-8'}" data-hotel-cat-id="{$name_val['id_category']|escape:'htmlall':'UTF-8'}" data-max_order_date="{$name_val['max_order_date']}" data-preparation_time="{$name_val['preparation_time']|escape:'htmlall':'UTF-8'}">{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</li>
{/foreach}
{/if}
</ul>
</div>
{/if}
<div class="hotel-selector-wrap">
<select name="id_hotel" class="chosen invisible" data-placeholder="{l s='Select Hotel' mod='wkroomsearchblock'}" id="id_hotel_button">
<option value=""></option>
{foreach $hotels_info as $name_val}
<option class="search_result_li" value="{$name_val['id']|escape:'htmlall':'UTF-8'}" data-id-hotel="{$name_val['id']|escape:'htmlall':'UTF-8'}" data-hotel-cat-id="{$name_val['id_category']|escape:'htmlall':'UTF-8'}" data-max_order_date="{$name_val['max_order_date']}" data-preparation_time="{$name_val['preparation_time']|escape:'htmlall':'UTF-8'}">{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</option>
{/foreach}
</select>
</div>
</div>
{/if}
{if isset($multiple_dates_input) && $multiple_dates_input}

View File

@@ -51,6 +51,9 @@ class WkRoomSearchBlock extends Module
$objHotelBranchInformation = new HotelBranchInformation();
$hotelBranchesInfo = $objHotelBranchInformation->hotelBranchesInfo(0, 1);
if (is_array($hotelBranchesInfo) && count($hotelBranchesInfo)) {
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/plugins/jquery.chosen.js');
$this->context->controller->addCSS($this->_path.'/views/css/chosen.css');
$this->context->controller->addCSS($this->_path.'/views/css/wk-global-search.css');
$this->context->controller->addJS($this->_path.'/views/js/wk-room-search-block.js');
@@ -66,6 +69,7 @@ class WkRoomSearchBlock extends Module
'check_out_time_cond' => $this->l('Please enter Check Out time', false, true),
'less_checkin_date' => $this->l('Check In date can not be before current date.', false, true),
'more_checkout_date' => $this->l('Check Out date must be greater than Check In date.', false, true),
'hotel_location_txt' => $this->l('Hotel Location', false, true),
'select_htl_txt' => $this->l('Select Hotel', false, true),
'select_age_txt' => $this->l('Select age', false, true),
'under_1_age' => $this->l('Under 1', false, true),
@@ -80,6 +84,7 @@ class WkRoomSearchBlock extends Module
'years_txt' => $this->l('years', false, true),
'all_children_txt' => $this->l('All Children', false, true),
'invalid_occupancy_txt' => $this->l('Invalid occupancy(adults/children) found.', false, true),
'hotel_name_has_search' => count($hotelBranchesInfo) >= Configuration::get('WK_HOTEL_NAME_SEARCH_THRESHOLD'),
)
);
}