diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php index 2a907425a..38d6b95e1 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php @@ -315,7 +315,7 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 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'))) { + } elseif (!Validate::isUnsignedInt($hotelNameSearchThreshold)) { $this->errors[] = $this->l('Hotel name search threshold field is invalid.'); } diff --git a/modules/wkroomsearchblock/controllers/front/autocompletesearch.php b/modules/wkroomsearchblock/controllers/front/autocompletesearch.php index 487e9c2d2..696179ef5 100644 --- a/modules/wkroomsearchblock/controllers/front/autocompletesearch.php +++ b/modules/wkroomsearchblock/controllers/front/autocompletesearch.php @@ -57,13 +57,17 @@ class WkRoomSearchBlockAutoCompleteSearchModuleFrontController extends ModuleFro } $this->context->smarty->assign(array('hotels_info' => $hotelsInfo)); - $html = $this->context->smarty->fetch( - $this->module->getTemplatePath('hotel-options.tpl') + $html_select = $this->context->smarty->fetch( + $this->module->getTemplatePath('hotel-options-select.tpl') ); + $html_dropdown = $this->context->smarty->fetch( + $this->module->getTemplatePath('hotel-options-dropdown.tpl') + ); $result['status'] = 'success'; - $result['data'] = $html; + $result['data_select'] = $html_select; + $result['data_dropdown'] = $html_dropdown; } else { $result['status'] = 'failed2'; } diff --git a/modules/wkroomsearchblock/views/css/chosen.css b/modules/wkroomsearchblock/views/css/chosen.css index c53604007..8ff89bf18 100644 --- a/modules/wkroomsearchblock/views/css/chosen.css +++ b/modules/wkroomsearchblock/views/css/chosen.css @@ -23,7 +23,7 @@ vertical-align: middle; font-size: 14px; zoom: 1; - display: inline; + /* display: inline; */ -moz-user-select: -moz-none; -ms-user-select: none; -webkit-user-select: none; @@ -59,7 +59,7 @@ overflow: hidden; padding-left: 35px; height: 100%; - border: 1px solid #aaa; + border: 1px solid #555555; border-radius: 4px; background-clip: padding-box; box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(0, 0, 0, 0.1); @@ -68,6 +68,7 @@ white-space: nowrap; line-height: 24px; background: #fff url('../img/icon-hotel.svg') no-repeat 10px 50%; + min-height: 55px; } .chosen-container-single.error_border .chosen-single { border: 2px solid red !important; @@ -458,26 +459,9 @@ 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 */ \ No newline at end of file +/* search results page - end */ diff --git a/modules/wkroomsearchblock/views/css/wk-category-search.css b/modules/wkroomsearchblock/views/css/wk-category-search.css index fd3ce4f30..d5ee2fce4 100644 --- a/modules/wkroomsearchblock/views/css/wk-category-search.css +++ b/modules/wkroomsearchblock/views/css/wk-category-search.css @@ -48,6 +48,12 @@ height: unset; min-height: 45px; } + #search_hotel_block_form .hotel-selector-wrap .chosen-container-single .chosen-single { + min-height: 45px; + } + #search_hotel_block_form .hotel-selector-wrap .chosen-container-single .chosen-search { + height: 45px; + } /* #search_hotel_block_form #search_room_submit { height: 45px; } */ diff --git a/modules/wkroomsearchblock/views/css/wk-global-search.css b/modules/wkroomsearchblock/views/css/wk-global-search.css index 1eeacfa62..aecd6bdf4 100644 --- a/modules/wkroomsearchblock/views/css/wk-global-search.css +++ b/modules/wkroomsearchblock/views/css/wk-global-search.css @@ -72,6 +72,12 @@ #date-range-picker-container.bottom { top: 85px; } +.fancybox-wrap #search_hotel_block_form .form-group.xs-calendar { + position: relative; +} +.fancybox-wrap #search_hotel_block_form #date-range-picker-container { + top: 56px; +} /* #search_hotel_block_form { display: grid; grid-template-columns: 0.8fr repeat(3, 1fr) 0.6fr; @@ -126,14 +132,16 @@ color: #333;} .header-rmsearch-input:-moz-placeholder { /* Firefox 18- */ - color: #999999; - font-weight: 400;} + color: #333; + font-weight: 400; + opacity: 1;} .header-rmsearch-input::-moz-placeholder { /* Firefox 19+ */ - color: #999999; - font-weight: 400;} + color: #333; + font-weight: 400; + opacity: 1;} .header-rmsearch-input:-ms-input-placeholder { - color: #999999; + color: #333; font-weight: 400;} .search_block_container .dropdown-toggle { background-color: #f2f2f2; diff --git a/modules/wkroomsearchblock/views/js/wk-room-search-block.js b/modules/wkroomsearchblock/views/js/wk-room-search-block.js index 4c96e5abf..415a6cf65 100644 --- a/modules/wkroomsearchblock/views/js/wk-room-search-block.js +++ b/modules/wkroomsearchblock/views/js/wk-room-search-block.js @@ -86,9 +86,14 @@ $(document).ready(function() { helpers: { overlay: { closeClick: false } //Disable click outside event }, + 'beforeShow': function() { + $('#date-range-picker-container').closest('.form-group').addClass('xs-calendar'); + }, 'afterClose': function() { $('.header-rmsearch-container').show(); $('#xs_room_search_form').show(); + + $('#date-range-picker-container').closest('.form-group').removeClass('xs-calendar'); }, }); }); @@ -250,7 +255,9 @@ $(document).ready(function() { success: function(result) { if (result.status == 'success') { $('#hotel_cat_id').val(''); - $('#id_hotel_button').html(result.data); + $('#id_hotel_button').html(result.data_select); + $('.hotel_dropdown_ul').empty(); + $('.hotel_dropdown_ul').html(result.data_dropdown); $('#id_hotel_button').trigger('chosen:updated'); if (focusHotelSelection) { @@ -312,9 +319,7 @@ $(document).ready(function() { } }); - $(document).on('change', '#id_hotel_button', function() { - let selectedHotel = $(this).find('option:selected'); - + function selectHotelFromList(selectedHotel) { let max_order_date = $(selectedHotel).attr('data-max_order_date'); let preparation_time = $(selectedHotel).attr('data-preparation_time') @@ -327,6 +332,14 @@ $(document).ready(function() { $('#hotel_cat_name').html($(selectedHotel).html()); BookingSearchManager.activateStep('date_range'); + } + + $(document).on('change', '#id_hotel_button', function() { + selectHotelFromList($(this).find('option:selected')); + }); + + $(document).on('click', '.hotel_dropdown_ul li', function() { + selectHotelFromList($(this)); }); // If only one hotel then set max order date on date pickers @@ -612,22 +625,19 @@ $(document).ready(function() { }); if (page_name == 'index') { - $('#hotel_location, #guest_occupancy').focus(function () { - setBookingSearchDropdownPositions(); - setBookingSearchCalendarPositions(); + $('#hotel_location, #id_hotel_button, #guest_occupancy').focus(function () { + setBookingSearchPositions(); }); // after chosen has been initialized $('select#id_hotel_button').on('chosen:ready', function() { $('#id_hotel_button_chosen .chosen-search input').focus(function () { - setBookingSearchDropdownPositions(); - setBookingSearchCalendarPositions(); + setBookingSearchPositions(); }); }); $('#daterange_value').click(function () { - setBookingSearchDropdownPositions(); - setBookingSearchCalendarPositions(); + setBookingSearchPositions(); }); } @@ -681,6 +691,12 @@ $(document).ready(function() { $(this).siblings('.chosen-container').find('.chosen-single').removeClass('invisible') }); } + + // if hotel chosen is not intialized use dropdown + if ($('select#id_hotel_button').data('chosen') === undefined) { + $('#search_hotel_block_form .hotel-select-wrap').addClass('hide'); + $('#search_hotel_block_form .hotel-dropdown-wrap').removeClass('hide'); + } }); // function to set occupancy infor in guest occupancy field(search form) function setGuestOccupancy() @@ -715,59 +731,55 @@ function setGuestOccupancy() $('#guest_occupancy > span').text(guestButtonVal); } -function setBookingSearchDropdownPositions() { +// position dropdowns and the calendar +function setBookingSearchPositions() { + // calculate available spaces + let searchForm = $('#search_hotel_block_form'); + let inputFieldsAndDropdowns = [ { input: $('#hotel_location'), dropdown: $('.location_search_results_ul')}, + { input: $('#id_hotel_button'), dropdown: $('.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; + let calendarInputField = { input: $('#daterange_value'), calendarContainer: $('#date-range-picker-container')}; - $(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 dropdownHeight = parseInt(cssMaxHeight.replace('px', '')); - dropdownHeight = Math.max(dropdownHeight || 0, 292); // 292 is height of the calendar + let positionClass = 'bottom'; + if (!searchForm.closest('.fancybox-wrap').length) { + let searchFormHeight = searchForm.outerHeight(); + let spaceTop = searchForm.offset().top - $(window).scrollTop(); + let spaceBottom = $(window).height() - searchFormHeight - spaceTop; - dropdownHeightMax = Math.max(dropdownHeightMax, dropdownHeight); - spaceTopMax = Math.max(spaceTopMax, spaceTop); - spaceBottomMax = Math.max(spaceBottomMax, spaceBottom); - }); + let calendarHeight = 292; - let dropdownClass = 'bottom'; - if (spaceBottomMax < dropdownHeightMax && spaceTopMax > spaceBottomMax) { - dropdownClass = 'top'; + // calculate max height for dropdowns + let maxHeightNeeded = 0; + $(inputFieldsAndDropdowns).each(function (i, inputFieldAndDropdown) { + if (!inputFieldAndDropdown.input.length) return false; + + // find needed space height + let cssMaxHeight = inputFieldAndDropdown.dropdown.css('max-height') || calendarHeight + 'px'; + let dropdownHeight = parseInt(cssMaxHeight.replace('px', '')); + dropdownHeight = Math.max(dropdownHeight || 0, calendarHeight); + + maxHeightNeeded = Math.max(maxHeightNeeded, dropdownHeight); + }); + + // manage calendar now + maxHeightNeeded = Math.max(maxHeightNeeded, calendarHeight); + + // determine position class + if (spaceBottom < maxHeightNeeded && spaceTop > spaceBottom) { + positionClass = 'top'; + } } + // position dropdowns $(inputFieldsAndDropdowns).each(function (i, inputFieldAndDropdown) { - inputFieldAndDropdown.dropdown.removeClass('top bottom').addClass(dropdownClass); - }); -} - -function setBookingSearchCalendarPositions() { - let calendarInputFields = [ - { input: $('#daterange_value'), calendarContainer: $('#date-range-picker-container')}, - ]; - - $(calendarInputFields).each(function (i, calendarInputField) { - // find available space - let inputFieldHeight = calendarInputField.input.outerHeight(); - let spaceTop = calendarInputField.input.offset().top - $(window).scrollTop(); - let spaceBottom = $(window).height() - inputFieldHeight - spaceTop; - let calendarHeight = 292; // 292 is height of the calendar - - let calendarContainerClass = 'bottom'; - if (spaceBottom < calendarHeight && spaceTop > spaceBottom) { - calendarContainerClass = 'top'; - } - - // position calendar - calendarInputField.calendarContainer.removeClass('top bottom').addClass(calendarContainerClass); + inputFieldAndDropdown.dropdown.removeClass('top bottom').addClass(positionClass); }); + + // position calendar + calendarInputField.calendarContainer.removeClass('top bottom').addClass(positionClass); } diff --git a/modules/wkroomsearchblock/views/templates/front/hotel-options-dropdown.tpl b/modules/wkroomsearchblock/views/templates/front/hotel-options-dropdown.tpl new file mode 100644 index 000000000..9f6431809 --- /dev/null +++ b/modules/wkroomsearchblock/views/templates/front/hotel-options-dropdown.tpl @@ -0,0 +1,26 @@ +{** + * 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($hotels_info) && is_array($hotels_info)} + {foreach from=$hotels_info item=hotel_info} +
  • + {$hotel_info.hotel_name} +
  • + {/foreach} +{/if} diff --git a/modules/wkroomsearchblock/views/templates/front/hotel-options.tpl b/modules/wkroomsearchblock/views/templates/front/hotel-options-select.tpl similarity index 100% rename from modules/wkroomsearchblock/views/templates/front/hotel-options.tpl rename to modules/wkroomsearchblock/views/templates/front/hotel-options-select.tpl diff --git a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl index ad5a675eb..711755b4a 100644 --- a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl +++ b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl @@ -21,13 +21,37 @@ -
    - +
    +
    + +
    +
    +
    + {if isset($hotels_info) && count($hotels_info)} + + {/if}
    {/if}