From a64ff9a5b30d996e6a56cc291cc7298c119c88e9 Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Mon, 24 Aug 2026 18:42:19 +0530 Subject: [PATCH 1/3] Enable the currently disabled Latitude and Longitude fields --- controllers/front/ContactController.php | 1 - controllers/front/OurPropertiesController.php | 1 - .../admin/AdminAddHotelController.php | 17 +++++++++++++++-- .../views/js/HotelReservationAdmin.js | 19 ++++++++++++++++++- .../admin/add_hotel/helpers/form/form.tpl | 14 ++++++++++++-- .../hotel-reservation-theme/contact-form.tpl | 2 +- .../our-properties.tpl | 2 +- 7 files changed, 47 insertions(+), 9 deletions(-) diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php index acb21798d..d3f7c29e6 100644 --- a/controllers/front/ContactController.php +++ b/controllers/front/ContactController.php @@ -330,7 +330,6 @@ class ContactControllerCore extends FrontController $this->context->smarty->assign( array( 'hotelsInfo' => $hotelsInfo, - 'viewOnMap' => Configuration::get('WK_GOOGLE_ACTIVE_MAP'), 'displayHotels' => Configuration::get('WK_DISPLAY_CONTACT_PAGE_HOTEL_LIST'), 'gblHtlPhone' => $gblHtlPhone, 'gblHtlEmail' => $gblHtlEmail, diff --git a/controllers/front/OurPropertiesController.php b/controllers/front/OurPropertiesController.php index 06520f044..77d34e4d0 100644 --- a/controllers/front/OurPropertiesController.php +++ b/controllers/front/OurPropertiesController.php @@ -128,7 +128,6 @@ class OurPropertiesControllerCore extends FrontController array( 'hotelsInfo' => $hotelsInfo, 'hotelLocationArray' => $hotelLocationArray, - 'viewOnMap' => Configuration::get('WK_GOOGLE_ACTIVE_MAP'), 'displayHotelMap' => $displayHotelMap, 'WK_HTL_SHORT_DESC' => Configuration::get('WK_HTL_SHORT_DESC', $this->context->language->id), 'currentIndex' => $this->context->link->getPageLink('our-properties') diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 9ebe57852..cfeeb36c9 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -413,6 +413,19 @@ class AdminAddHotelController extends ModuleAdminController $this->errors[] = $this->l('Enter a valid city name.'); } + if (Tools::getValue('loclatitude') !== '' && !Validate::isCoordinate(Tools::getValue('loclatitude'))) { + $this->errors[] = $this->l('Latitude is invalid.'); + } + if (Tools::getValue('loclongitude') !== '' && !Validate::isCoordinate(Tools::getValue('loclongitude'))) { + $this->errors[] = $this->l('Longitude is invalid.'); + } + if ($map_formated_address && !Validate::isCleanHtml(html_entity_decode($map_formated_address))) { + $this->errors[] = $this->l('Map formatted address is invalid.'); + } + if ($map_input_text && !Validate::isString($map_input_text)) { + $this->errors[] = $this->l('Map location text is invalid.'); + } + //Since the address for the hotel is saved in the address table. We are validating the hotel address here manually. $addressValidation = Address::getValidationRules('Address'); foreach ($addressValidation['size'] as $field => $maxSize) { @@ -610,8 +623,8 @@ class AdminAddHotelController extends ModuleAdminController $objHotelBranch->check_in = $check_in; $objHotelBranch->check_out = $check_out; $objHotelBranch->rating = $rating; - $objHotelBranch->latitude = Validate::isCoordinate($latitude) ? Tools::ps_round($latitude, 8) : $latitude; - $objHotelBranch->longitude = Validate::isCoordinate($longitude) ? Tools::ps_round($longitude, 8) : $longitude; + $objHotelBranch->latitude = $latitude; + $objHotelBranch->longitude = $longitude; $objHotelBranch->map_formated_address = $map_formated_address; $objHotelBranch->map_input_text = $map_input_text; $objHotelBranch->save(); diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js index d90a1246a..651e634b7 100644 --- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js +++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js @@ -95,7 +95,7 @@ var GoogleMapsManager = { google.maps.event.trigger(that.map, 'resize'); that.map.setCenter(that.defaultLatLng); if (that.defaultLatLng && that.formattedAddress) { - that.addMarker(that.defaultLatLng, null, that.formattedAddress); + that.addMarker(that.defaultLatLng, null, that.formattedAddress, false); } // register marker events that.map.addListener('click', function (e) { @@ -263,12 +263,29 @@ var GoogleMapsManager = { $('#locformatedAddr').val(params.formattedAddress); $('#googleInputField').val(params.inputText); }, + updateMarkerFromInputs: function() { + if (!this.map) { + return; + } + var latitude = Number($('#loclatitude').val()); + var longitude = Number($('#loclongitude').val()); + if (!latitude || !longitude) { + return; + } + var latLng = {lat: latitude, lng: longitude}; + this.map.setCenter(latLng); + this.addMarker(latLng, null, null, false); + }, } $(document).on('click', 'button.gm-ui-hover-effect', function () { GoogleMapsManager.clearAllMarkers(); }); +$(document).on('change', '#loclatitude, #loclongitude', function () { + GoogleMapsManager.updateMarkerFromInputs(); +}); + function initGoogleMaps() { if (typeof enabledDisplayMap != 'undefined' && $('#googleMapContainer').length diff --git a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl index 244a174f2..eaf9c7186 100644 --- a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl @@ -286,6 +286,18 @@ +
+ +
+ +
+
+
+ +
+ +
+