diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php index 8e935e833..4faa76dea 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 d36546d1e..3df472859 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 918595bf5..fcb976763 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -415,6 +415,18 @@ class AdminAddHotelController extends ModuleAdminController } elseif (!Validate::isCityName($city)) { $this->errors[] = $this->l('Enter a valid city name.'); } + if (Tools::getValue('loclatitude') !== '' && (!is_numeric(Tools::getValue('loclatitude')) || !Validate::isCoordinate($latitude))) { + $this->errors[] = $this->l('Latitude is invalid.'); + } + if (Tools::getValue('loclongitude') !== '' && (!is_numeric(Tools::getValue('loclongitude')) || !Validate::isCoordinate($longitude))) { + $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'); @@ -613,8 +625,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..7a7d09fe3 100644 --- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js +++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js @@ -258,17 +258,34 @@ var GoogleMapsManager = { } }, setFormVars: function(params) { - $('#loclatitude').val(params.lat); - $('#loclongitude').val(params.lng); + $('#loclatitude').val(Number(params.lat).toFixed(8)); + $('#loclongitude').val(Number(params.lng).toFixed(8)); $('#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 06b36ad31..fbbaf8fc1 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 @@ -287,6 +287,18 @@ +
+ +
+ +
+
+
+ +
+ +
+