Merge pull request #403 from abhishek-webkul/gli-640

Add maps to search results and room type detail pages
This commit is contained in:
Rohit Jain
2022-12-12 15:36:09 +05:30
committed by GitHub
15 changed files with 334 additions and 11 deletions

View File

@@ -82,6 +82,7 @@
<hook module="hotelreservationsystem" hook="actionObjectProfileAddAfter" position="1"/>
<hook module="hotelreservationsystem" hook="actionObjectProfileDeleteBefore" position="1"/>
<hook module="hotelreservationsystem" hook="actionObjectGroupDeleteBefore" position="1"/>
<hook module="hotelreservationsystem" hook="displayLeftColumn" position="4"/>
<hook module="wkroomsearchblock" hook="displayLeftColumn" position="1"/>
<hook module="wkroomsearchblock" hook="Header" position="2"/>
<hook module="wkroomsearchblock" hook="displayAfterHookTop" position="2"/>

View File

@@ -287,7 +287,8 @@ class ContactControllerCore extends FrontController
}
}
}
$contactKey = md5(uniqid(microtime(), true));
$contactKey = md5(uniqid(microtime(), true));
$this->context->cookie->__set('contactFormKey', $contactKey);
$this->context->smarty->assign(
array(
@@ -297,7 +298,7 @@ class ContactControllerCore extends FrontController
'gblHtlAddress' => $gblHtlAddress,
'contacts' => Contact::getContacts($this->context->language->id),
'message' => html_entity_decode(Tools::getValue('message')),
'contactKey' => $contactKey,
'contactKey' => $contactKey,
)
);

View File

@@ -63,6 +63,13 @@ class ProductControllerCore extends FrontController
if (Configuration::get('PS_DISPLAY_JQZOOM') == 1) {
$this->addJqueryPlugin('jqzoom');
}
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
$this->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places&language='.
$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);
}
}
public function canonicalRedirection($canonical_url = '')
@@ -324,9 +331,25 @@ class ProductControllerCore extends FrontController
}
/*End*/
$hotelImageLink = null;
if ($coverImage = HotelImage::getCover($hotel_id)) {
$hotelImagesBaseDir = _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_img/';
$hotelImageLink = $this->context->link->getMediaLink(
$hotelImagesBaseDir.$coverImage['hotel_image_id'].'.jpg'
);
}
Media::addJsDef(array(
'hotel_loc' => array(
'latitude' => $hotel_branch_obj->latitude,
'longitude' => $hotel_branch_obj->longitude,
)
));
if (Tools::getValue('error')) {
$this->context->smarty->assign('error', Tools::getValue('error'));
}
if (Module::isInstalled('productcomments')) {
$this->context->smarty->assign(
array(
@@ -349,9 +372,15 @@ class ProductControllerCore extends FrontController
'hotel_check_in' => date('h:i a', strtotime($hotel_branch_obj->check_in)),
'hotel_check_out' => date('h:i a', strtotime($hotel_branch_obj->check_out)),
'hotel_location' => $hotel_location,
'hotel_latitude' => $hotel_branch_obj->latitude,
'hotel_longitude' => $hotel_branch_obj->longitude,
'hotel_map_input_text' => $hotel_branch_obj->map_input_text,
'hotel_address1' => $addressInfo['address1'],
'hotel_phone' => $addressInfo['phone'],
'hotel_name' => $hotel_name,
'hotel_policies' => $hotel_policies,
'hotel_features' => $htl_features,
'hotel_image_link' => $hotelImageLink,
'hotel_has_images' => (bool) HotelImage::getCover($hotel_id),
'ftr_img_src' => _PS_IMG_.'rf/',
'order_date_restrict' => $order_date_restrict
@@ -434,6 +463,7 @@ class ProductControllerCore extends FrontController
'category-'.(isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : ''),
),
'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE'),
'display_google_maps' => Configuration::get('WK_GOOGLE_ACTIVE_MAP'),
)
);
}

View File

@@ -130,6 +130,24 @@ UPDATE `PREFIX_hook_module` SET position = 3
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockbestsellers')
AND id_hook IN (@id_hook, @id_hook2);
/* displayLeftColumn */
SET @id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayLeftColumn');
UPDATE `PREFIX_hook_module` SET position = 1
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'wkroomsearchblock')
AND id_hook = @id_hook;
UPDATE `PREFIX_hook_module` SET position = 2
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'wkhotelfilterblock')
AND id_hook = @id_hook;
UPDATE `PREFIX_hook_module` SET position = 3
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockmyaccount')
AND id_hook = @id_hook;
UPDATE `PREFIX_hook_module` SET position = 4
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'hotelreservationsystem')
AND id_hook = @id_hook;
/* displayFooter */
SET @id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayFooter');
UPDATE `PREFIX_hook_module` SET position = 1

View File

@@ -554,7 +554,6 @@ class HotelBranchInformation extends ObjectModel
return Db::getInstance()->executeS($sql);
}
public function getAllHotels()
{
return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'htl_branch_info`');

View File

@@ -100,6 +100,40 @@ class HotelReservationSystem extends Module
$this->context->controller->addJS($this->_path.'/views/js/HotelReservationFront.js');
}
public function hookDisplayLeftColumn()
{
if (Tools::getValue('controller') == 'category') {
if ($apiKey = Configuration::get('PS_API_KEY')) {
$idCategory = Tools::getValue('id_category');
$idHotel = HotelBranchInformation::getHotelIdByIdCategory($idCategory);
$objHotel = new HotelBranchInformation($idHotel, $this->context->language->id);
if (floatval($objHotel->latitude) != 0
&& floatval($objHotel->longitude) != 0
) {
Media::addJsDef(array(
'hotel_location' => array(
'latitude' => $objHotel->latitude,
'longitude' => $objHotel->longitude,
'map_input_text' => $objHotel->map_input_text,
),
'hotel_name' => $objHotel->hotel_name,
));
$this->context->controller->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places&language='.
$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);
$this->context->controller->addJS($this->getPathUri().'views/js/searchResultsMap.js');
$this->context->controller->addCSS($this->getPathUri().'views/css/searchResultsMap.css');
$this->context->smarty->assign('hotel', $objHotel);
return $this->display(__FILE__, 'searchResultsMap.tpl');
}
}
}
}
public function hookDisplayAfterHookTop()
{
if (Tools::getValue('controller') == 'index') {
@@ -515,7 +549,8 @@ class HotelReservationSystem extends Module
'actionObjectProfileAddAfter',
'actionObjectProfileDeleteBefore',
'actionObjectGroupDeleteBefore',
'actionOrderStatusPostUpdate'
'actionOrderStatusPostUpdate',
'displayLeftColumn',
)
);
}

View File

@@ -0,0 +1,26 @@
/**
* 2010-2022 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-2022 Webkul IN
* @license LICENSE.txt
*/
#search-results-wrap .map-wrap {
height: 200px;
}
#search-results-wrap .lf_sub_cont {
max-height: none;
}

View File

@@ -0,0 +1,55 @@
/**
* 2010-2022 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-2022 Webkul IN
* @license LICENSE.txt
*/
function initMap() {
const hotelLocation = {
lat: Number(hotel_location.latitude),
lng: Number(hotel_location.longitude),
};
const map = new google.maps.Map($($('#search-results-wrap .map-wrap')).get(0), {
zoom: 10,
center: hotelLocation,
disableDefaultUI: true,
fullscreenControl: true,
});
const marker = new google.maps.Marker({
position: hotelLocation,
map: map,
title: hotel_name,
});
marker.addListener('click', function() {
let query = '';
if (hotel_location.map_input_text != '') {
query = hotel_location.map_input_text;
} else {
query = hotel_location.latitude + ',' + hotel_location.longitude;
}
window.open('https://www.google.com/maps/search/?api=1&query='+encodeURIComponent(query), '_blank');
});
}
$(document).ready(function() {
if (typeof google == 'object' && typeof hotel_location == 'object') {
initMap();
}
});

View File

@@ -0,0 +1,34 @@
{**
* 2010-2022 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-2022 Webkul IN
* @license LICENSE.txt
*}
<div class="row margin-lr-0 layered_filter_cont" id="search-results-wrap">
<div class="col-sm-12 layered_filter_heading">
<div class="row margin-lr-0">
<div class="pull-left lf_headingmain_wrapper">
<span>{l s='Directions' mod='hotelreservationsystem'}</span>
<hr class="theme-text-underline">
</div>
</div>
</div>
<div class="col-sm-12 lf_sub_cont">
{if ($hotel->latitude|floatval != 0 && $hotel->longitude|floatval != 0)}
<div class="map-wrap"></div>
{/if}
</div>
</div>

View File

@@ -217,6 +217,7 @@
{strip}
{addJsDefL name='contact_fileDefaultHtml'}{l s='No file selected' js=1}{/addJsDefL}
{addJsDefL name='contact_fileButtonHtml'}{l s='Choose File' js=1}{/addJsDefL}
{addJsDefL name='contact_map_get_dirs'}{l s='Get Directions' js=1}{/addJsDefL}
{/strip}
{if isset($hotelLocationArray)}
{strip}
@@ -226,4 +227,4 @@
{strip}
{addJsDef hotelLocationArray = 0}
{/strip}
{/if}
{/if}

View File

@@ -126,6 +126,7 @@
float: left;
padding: 15px 0px;
width: 100%;
height: 90%;
}
.htl-contact-page .hotel-city-container>span {
font-size: 24px;
@@ -253,3 +254,23 @@
width: 100%;
height: 100%;
}
#map .view-link {
padding-top: 4px;
}
.gm-btn-get-directions {
text-decoration: none;
color: #427fed;
font-weight: bold;
}
.gm-btn-get-directions:hover {
text-decoration: underline;
color: #427fed;
}
.gm-btn-get-directions:focus {
outline: none;
color: #427fed;
}

View File

@@ -1471,6 +1471,54 @@ Quick View Styles
border-top: 1px solid #eee;
padding-top: 15px;} */
#room_type_map_tab .map-wrap {
min-height: 500px;
}
#room_type_map_tab .hotel-info-wrap {
max-width: 300px;
background-color: #fff;
padding: 12px;
margin: 0 0 20px 10px;
border-radius: 2px;
box-shadow: 0 2px 6px rgba(0,0,0,.3);
display: flex;
}
#room_type_map_tab .hotel-info-wrap .hotel-image-wrap {
padding-right: 8px;
}
#room_type_map_tab .hotel-info-wrap .hotel-image-wrap img {
max-width: 70px;
max-height: 70px;
}
#room_type_map_tab .hotel-info-wrap .name {
font-size: 14px;
font-weight: bold;
color: #1a73e8;
margin-bottom: 6px;
}
#room_type_map_tab .hotel-info-wrap .address,
#room_type_map_tab .hotel-info-wrap .contact {
font-size: 13px;
font-weight: normal;
color: #555;
}
#room_type_map_tab .hotel-info-wrap .address {
margin-bottom: 6px;
}
#room_type_map_tab .hotel-info-wrap .view-on-map {
background-color: #186bd7;
border-radius: 2px;
color: #fff;
padding: 5px 10px;
}
.room_info_hotel_images_wrap .row {
margin-left: -7.5px;
margin-right: -7.5px; }

View File

@@ -94,7 +94,13 @@ function initMap() {
// Allow each marker to have an info window
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infoWindow.setContent(location.map_formated_address);
var directionsLink = 'https://www.google.com/maps/dir/?api=1&destination='+
location.latitude+','+location.longitude;
var content = '<div><strong>'+location.hotel_name+'</strong></div>'+
location.map_formated_address+
'<div class="view-link"><a class="gm-btn-get-directions" href="'+
directionsLink+'" target="_blank" tabindex="-1"><span>'+contact_map_get_dirs+'</span></a></div>';
infoWindow.setContent(content);
infoWindow.open(map, marker);
}
})(marker, i));
@@ -108,4 +114,4 @@ function initMap() {
// this.setZoom(8);
google.maps.event.removeListener(boundsListener);
});
}
}

View File

@@ -113,7 +113,6 @@ if (typeof combinations !== 'undefined' && combinations)
}
combinations = combinationsJS;
}
/* */
$(document).ready(function() {
var url_found = checkUrl();
@@ -861,7 +860,6 @@ function serialScrollResizeThumbContainer() {
}
}
// Change the current product images regarding the combination selected
function refreshProductImages(id_product_attribute) {
id_product_attribute = parseInt(id_product_attribute);
@@ -969,7 +967,6 @@ function colorPickerClick(elt) {
$(elt).parent().parent().parent().children('.color_pick_hidden').val(id_attribute);
}
function getProductAttribute() {
// get every attributes values
request = '';
@@ -1167,8 +1164,34 @@ $(document).ready(function() {
}
e.preventDefault();
});
if (typeof google === 'object') {
initMap();
}
});
function initMap() {
const map = new google.maps.Map($('#room_type_map_tab .map-wrap').get(0), {
zoom: 10,
streetViewControl: false,
});
const hotelLatLng = {
lat: Number(hotel_loc.latitude),
lng: Number(hotel_loc.longitude),
};
map.setCenter(hotelLatLng);
const marker = new google.maps.Marker({
position: hotelLatLng,
map: map,
});
const uiContent = $('#room-info-map-ui-content .hotel-info-wrap').get(0);
map.controls[google.maps.ControlPosition.LEFT_TOP].push(uiContent);
}
var BookingForm = {
currentRequest: null,
init: function() {

View File

@@ -182,7 +182,10 @@
<section class="page-product-box">
<ul class="nav nav-tabs product_description_tabs">
<li class="active"><a href="#room_info_tab" class="idTabHrefShort" data-toggle="tab">{l s='Room Information'}</a></li>
<li><a href="#refund_policies_tab" class="idTabHrefShort" data-toggle="tab">{l s='Refund policies'}</a></li>
<li><a href="#refund_policies_tab" class="idTabHrefShort" data-toggle="tab">{l s='Refund Policies'}</a></li>
{if $display_google_maps && ($hotel_latitude|floatval != 0 && $hotel_longitude|floatval != 0)}
<li><a href="#room_type_map_tab" class="idTabHrefShort" data-toggle="tab">{l s='View on Map'}</a></li>
{/if}
{$HOOK_PRODUCT_TAB}
</ul>
<div class="tab-content product_description_tabs_contents">
@@ -303,6 +306,28 @@
<span class="non_refundable_txt error_msg">{l s='Non Refundable'}</span>
{/if}
</div>
{if $display_google_maps && ($hotel_latitude|floatval != 0 && $hotel_longitude|floatval != 0)}
<div id="room_type_map_tab" class="tab-pane card">
<div class="map-wrap"></div>
<div id="room-info-map-ui-content" style="display: none;">
<div class="hotel-info-wrap">
{if isset($hotel_image_link) && $hotel_image_link}
<div class="hotel-image-wrap">
<img class="img img-responsive" src="{$hotel_image_link}">
</div>
{/if}
<div>
<p class="name">{$hotel_name|escape:'html':'UTF-8'}</p>
<p class="address">{$hotel_address1|escape:'html':'UTF-8'}</p>
<p class="contact">{l s='Contact:'} {$hotel_phone|escape:'html':'UTF-8'}</p>
<a class="btn view-on-map" href="https://www.google.com/maps/search/?api=1&query={if $hotel_map_input_text != ''}{$hotel_map_input_text|urlencode}{else}{($hotel_latitude|cat:','|cat:$hotel_longitude)|urlencode}{/if}" target="_blank">
<span>{l s='View on Map'}</span>
</a>
</div>
</div>
</div>
</div>
{/if}
{if isset($HOOK_PRODUCT_TAB_CONTENT) && $HOOK_PRODUCT_TAB_CONTENT}{$HOOK_PRODUCT_TAB_CONTENT}{/if}
</div>
</section>