D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
public_html
/
grievance
/
application
/
controllers
/
Filename :
Locations.php
back
Copy
<?php /** * Controller Class For Location Management (State/City) * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class Locations extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper('url'); $this->load->library('session'); $this->load->helper('form'); $this->load->library('form_validation'); $this->load->model("LocationManagement"); } public function getActiveCitiesByState() { $state_id = $_POST['state_id']; $query = $this->LocationManagement->getActiveCitiesByState($state_id); $cityList = $query->result(); $options = "<option value=''>-Select City-</option>"; for ($i = 0; $i < (sizeof($cityList)); $i++) { $options .= "<option value=" . $cityList[$i]->id . ">" . $cityList[$i]->name . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'city_list' => $options ); echo json_encode($responseData); } public function getActiveCitiesByStateForUpdate() { $state_id = $_POST['state_id']; $city_id = $_POST['city_id']; $query = $this->LocationManagement->getActiveCitiesByState($state_id); $cityList = $query->result(); $options = "<option value=''>-Select City-</option>"; for ($i = 0; $i < (sizeof($cityList)); $i++) { $selected = ($cityList[$i]->id == $city_id)?"selected":""; $options .= "<option value=" . $cityList[$i]->id . " ".$selected.">" . $cityList[$i]->name . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'city_list' => $options ); echo json_encode($responseData); } }