CHange id to id_state

This commit is contained in:
Abhishek Kumar
2023-08-24 15:35:57 +05:30
parent 32d89058b3
commit 2ab71ddedb
3 changed files with 13 additions and 21 deletions

View File

@@ -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()

View File

@@ -290,9 +290,9 @@ $(document).ready(function() {
url: statebycountryurl,
success: function(data) {
var html = "";
if (data) {
$.each(data, function(index, value) {
html += "<option value=" + value.id + ">" + value.name + "</option>";
if (data.status && data.states.length) {
$.each(data.states, function(index, value) {
html += "<option value=" + value.id_state + ">" + value.name + "</option>";
});
}
$('#hotel_state').append(html);

View File

@@ -219,7 +219,7 @@
<option value="0" selected="selected">{l s='Choose your Country' mod='hotelreservationsystem'} </option>
{if $country_var}
{foreach $country_var as $countr}
<option value="{$countr['id_country']}" {if (isset($smarty.post.hotel_country) && $smarty.post.hotel_country == $countr['id_country']) || (isset($edit) && $address_info['id_country'] == $countr['id_country'])}selected{/if}>{$countr['name']}</option>
<option value="{$countr['id_country']}" {if isset($smarty.post.hotel_country) && $smarty.post.hotel_country}{if $smarty.post.hotel_country == $countr['id_country']}selected{/if}{elseif isset($edit) && $address_info['id_country'] == $countr['id_country']}selected{/if}>{$countr['name']}</option>
{/foreach}
{/if}
</select>
@@ -234,7 +234,7 @@
<select class="form-control" name="hotel_state" id="hotel_state">
{if is_array($state_var) && count($state_var)}
{foreach $state_var as $state}
<option value="{$state['id']}" {if (isset($smarty.post.hotel_state) && $smarty.post.hotel_state == $state['id']) || (isset($edit) && $address_info['id_state'] == $state['id'])}selected{/if}> {$state['name']}</option>
<option value="{$state['id_state']}" {if (isset($smarty.post.hotel_state) && $smarty.post.hotel_state == $state['id_state']) || (isset($edit) && $address_info['id_state'] == $state['id_state'])}selected{/if}> {$state['name']}</option>
{/foreach}
{/if}
</select>