Commit d4a32b5d by Jansa Jose

J: airport Search

parent e632f486
......@@ -783,6 +783,17 @@ class Webservice extends CI_Controller {
$this->errorResponse($res['code'],$res['message']);
}
}
public function airportSearch(){
$data = $_GET;
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->airportSearch($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
/******************************* END Flight API******************************************/
}
?>
......@@ -1273,6 +1273,14 @@ class Validation_app_model extends CI_Model {
'message' => 'Required field is null or empty'
)
)
),
'airportSearch'=>array(
'auth_token' => array(
'required' => array(
'code' => 'ER02',
'message' => 'User Id is null or empty'
)
)
)
);
......
......@@ -2628,6 +2628,35 @@ class Webservice_model extends CI_Model {
return $res;
}
public function airportSearch($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$sql = "SELECT id FROM airport_details WHERE airport_code LIKE '%".$data['query']."%' OR airport_name LIKE '%".$data['query']."%'";
$count = $this->db->query($sql)->num_rows();
if($count > 0){
$perPage = 10;
$page = (isset($data['page']))?$data['page']:1;
$limit = ($page - 1) * $perPage;
$meta = array('total_pages'=>ceil($count/$perPage),'total'=>$count,
'current_page'=>$page,'per_page'=>$perPage);
$sql = "SELECT * FROM airport_details WHERE airport_code LIKE '%".$data['query']."%' OR airport_name LIKE '%".$data['query']."%' LIMIT $limit,$perPage";
$airPortList = $this->db->query($sql);
if(!isset($airPortList) || empty($airPortList = $airPortList->result_array())){
$res = array('status'=>0,'message'=>'No data Found','code'=>'ER04');
return $res;
}
$res =array('status'=>1,'data'=>array('airportlist'=>$airPortList,'meta'=>$meta));
}
}else{
$res = array('status'=>0,'message'=>'User Authentication Error','code'=>'ER06');
}
}catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South','code'=>'ER10');
}
return $res;
}
public function passToJsonCurl($url='',$postData=array()){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment