diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php
index 451a36b78..278538193 100644
--- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php
+++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php
@@ -130,7 +130,7 @@ class AdminAddHotelController extends ModuleAdminController
$hotelBranchInfo = new HotelBranchInformation($idHotel);
$addressInfo = HotelBranchInformation::getAddress($idHotel);
- $idCountry = $addressInfo['id_country'];
+ $idCountry = Tools::getValue('hotel_country', $addressInfo['id_country']);
$smartyVars['edit'] = 1;
$smartyVars['address_info'] = $addressInfo;
@@ -175,14 +175,7 @@ class AdminAddHotelController extends ModuleAdminController
$stateOptions = null;
if ($idCountry) {
- $statesByCountry = State::getStatesByIdCountry($idCountry);
- if ($statesByCountry) {
- $stateOptions = array();
- foreach ($statesByCountry as $key => $value) {
- $stateOptions[$key]['id'] = $value['id_state'];
- $stateOptions[$key]['name'] = $value['name'];
- }
- }
+ $stateOptions = State::getStatesByIdCountry($idCountry);
}
$smartyVars['state_var'] = $stateOptions;
@@ -611,16 +604,15 @@ class AdminAddHotelController extends ModuleAdminController
public function ajaxProcessStateByCountryId()
{
- $states = array();
+ $response = array('status' => false, 'states' => array());
if ($idCountry = Tools::getValue('id_country')) {
- if ($statesbycountry = State::getStatesByIdCountry($idCountry)) {
- foreach ($statesbycountry as $key => $value) {
- $states[$key]['id'] = $value['id_state'];
- $states[$key]['name'] = $value['name'];
- }
+ if ($states = State::getStatesByIdCountry($idCountry)) {
+ $response['status'] = true;
+ $response['states'] = $states;
}
}
- die(json_encode($states));
+
+ $this->ajaxDie(json_encode($response));
}
public function ajaxProcessUploadHotelImages()
diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js
index b7e41a498..66a274406 100644
--- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js
+++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js
@@ -290,9 +290,9 @@ $(document).ready(function() {
url: statebycountryurl,
success: function(data) {
var html = "";
- if (data) {
- $.each(data, function(index, value) {
- html += "";
+ if (data.status && data.states.length) {
+ $.each(data.states, function(index, value) {
+ html += "";
});
}
$('#hotel_state').append(html);
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 8b659f94f..212a25a0e 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
@@ -219,7 +219,7 @@
{if $country_var}
{foreach $country_var as $countr}
-
+
{/foreach}
{/if}
@@ -234,7 +234,7 @@