Commit b97bc6a7 by Tobin

dc

parent 04538925
...@@ -22,7 +22,7 @@ class FlightServices extends CI_Controller { ...@@ -22,7 +22,7 @@ class FlightServices extends CI_Controller {
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
date_default_timezone_set("Asia/Riyadh"); date_default_timezone_set("Asia/Riyadh");
$this->load->model('Flight_model'); $this->load->model('FlightServices_model');
$this->load->model('Validation_flight_model'); $this->load->model('Validation_flight_model');
$method = $this->router->fetch_method(); $method = $this->router->fetch_method();
$data = (array) json_decode(file_get_contents('php://input')); $data = (array) json_decode(file_get_contents('php://input'));
...@@ -64,7 +64,7 @@ class FlightServices extends CI_Controller { ...@@ -64,7 +64,7 @@ class FlightServices extends CI_Controller {
public function flight_authenticate(){ public function flight_authenticate(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Flight_model->flight_authenticate($data); $res = $this->FlightServices_model->flight_authenticate($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -75,7 +75,7 @@ class FlightServices extends CI_Controller { ...@@ -75,7 +75,7 @@ class FlightServices extends CI_Controller {
public function flight_availability_search(){ public function flight_availability_search(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Flight_model->flight_availability_search($data); $res = $this->FlightServices_model->flight_availability_search($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -86,7 +86,7 @@ class FlightServices extends CI_Controller { ...@@ -86,7 +86,7 @@ class FlightServices extends CI_Controller {
public function flight_fare_rules(){ public function flight_fare_rules(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Flight_model->flight_fare_rules($data); $res = $this->FlightServices_model->flight_fare_rules($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -97,7 +97,7 @@ class FlightServices extends CI_Controller { ...@@ -97,7 +97,7 @@ class FlightServices extends CI_Controller {
public function flight_revalidate(){ public function flight_revalidate(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Flight_model->flight_revalidate($data); $res = $this->FlightServices_model->flight_revalidate($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -108,7 +108,7 @@ class FlightServices extends CI_Controller { ...@@ -108,7 +108,7 @@ class FlightServices extends CI_Controller {
public function flight_book(){ public function flight_book(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $thia->Flight_model->flight_book($data); $res = $thia->FlightServices_model->flight_book($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -119,7 +119,7 @@ class FlightServices extends CI_Controller { ...@@ -119,7 +119,7 @@ class FlightServices extends CI_Controller {
public function flight_ticket_order(){ public function flight_ticket_order(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Flight_model->flight_ticket_order($data); $res = $this->FlightServices_model->flight_ticket_order($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -130,7 +130,7 @@ class FlightServices extends CI_Controller { ...@@ -130,7 +130,7 @@ class FlightServices extends CI_Controller {
public function flight_trip_details(){ public function flight_trip_details(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Flight_model->flight_trip_details($data); $res = $this->FlightServices_model->flight_trip_details($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -141,7 +141,7 @@ class FlightServices extends CI_Controller { ...@@ -141,7 +141,7 @@ class FlightServices extends CI_Controller {
public function cancel_flights(){ public function cancel_flights(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Flight_model->cancel_flights($data); $res = $this->FlightServices_model->cancel_flights($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -152,7 +152,7 @@ class FlightServices extends CI_Controller { ...@@ -152,7 +152,7 @@ class FlightServices extends CI_Controller {
public function airportSearch(){ public function airportSearch(){
$data = $_GET; $data = $_GET;
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Flight_model->airportSearch($data); $res = $this->FlightServices_model->airportSearch($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
......
...@@ -22,7 +22,7 @@ class HotelServices extends CI_Controller { ...@@ -22,7 +22,7 @@ class HotelServices extends CI_Controller {
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
date_default_timezone_set("Asia/Riyadh"); date_default_timezone_set("Asia/Riyadh");
$this->load->model('Hotel_model'); $this->load->model('HotelServices_model');
$this->load->model('Validation_hotel_model'); $this->load->model('Validation_hotel_model');
$method = $this->router->fetch_method(); $method = $this->router->fetch_method();
$data = (array) json_decode(file_get_contents('php://input')); $data = (array) json_decode(file_get_contents('php://input'));
...@@ -63,8 +63,7 @@ class HotelServices extends CI_Controller { ...@@ -63,8 +63,7 @@ class HotelServices extends CI_Controller {
public function get_hotel_city_list(){ public function get_hotel_city_list(){
$data = $_GET; $data = $_GET;
$data['auth_token'] = $this->auth_token; $res = $this->HotelServices_model->get_hotel_city_list($data);
$res = $this->Hotel_model->get_hotel_city_list($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -75,7 +74,7 @@ class HotelServices extends CI_Controller { ...@@ -75,7 +74,7 @@ class HotelServices extends CI_Controller {
public function hotel_search(){ public function hotel_search(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Hotel_model->hotel_search($data); $res = $this->HotelServices_model->hotel_search($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -86,7 +85,7 @@ class HotelServices extends CI_Controller { ...@@ -86,7 +85,7 @@ class HotelServices extends CI_Controller {
public function get_specific_hotel_content(){ public function get_specific_hotel_content(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Hotel_model->get_specific_hotel_content($data); $res = $this->HotelServices_model->get_specific_hotel_content($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -97,7 +96,7 @@ class HotelServices extends CI_Controller { ...@@ -97,7 +96,7 @@ class HotelServices extends CI_Controller {
public function get_room_rates(){ public function get_room_rates(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Hotel_model->get_room_rates($data); $res = $this->HotelServices_model->get_room_rates($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -108,7 +107,7 @@ class HotelServices extends CI_Controller { ...@@ -108,7 +107,7 @@ class HotelServices extends CI_Controller {
public function get_rate_rules(){ public function get_rate_rules(){
$data = (array) json_decode(file_get_contents('php://input')); $data = (array) json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Hotel_model->get_rate_rules($data); $res = $this->HotelServices_model->get_rate_rules($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -119,7 +118,7 @@ class HotelServices extends CI_Controller { ...@@ -119,7 +118,7 @@ class HotelServices extends CI_Controller {
public function hotel_book(){ public function hotel_book(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Hotel_model->hotel_book($data); $res = $this->HotelServices_model->hotel_book($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
...@@ -130,7 +129,7 @@ class HotelServices extends CI_Controller { ...@@ -130,7 +129,7 @@ class HotelServices extends CI_Controller {
public function trawex_cancel_booking(){ public function trawex_cancel_booking(){
$data = (array)json_decode(file_get_contents('php://input')); $data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token; $data['auth_token'] = $this->auth_token;
$res = $this->Hotel_model->trawex_cancel_booking($data); $res = $this->HotelServices_model->trawex_cancel_booking($data);
if($res['status'] == 1){ if($res['status'] == 1){
$this->response($res['data']); $this->response($res['data']);
}else{ }else{
......
<?php
class Flight_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
public function auth_token_get($token) {
$rs = $this->db->select('user_id')->where('auth_token', $token)->get('customer_auth')->row();
if(count($rs) > 0) {
return $rs->user_id;
} else {
return 0;
}
}
public function flight_authenticate($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/flight_trawex/authenticate?user_id=".$settings['trawex_user_id']."&user_password=".$settings['trawex_user_password']."&access=".$settings['trawex_access']."&ip_address=".$settings['trawex_ip_address']."";
$result = $this->passToJsonCurl($url,'');
if(!empty($result)){
$result = json_decode($result);
$res = array('status'=>1,'data'=>$result);
}else{
$res = array('status'=>0,'message'=>'No Data Found','code'=>'ER06');
}
}else{
$res = array('status'=>0,'message'=>'User Authentication Error','code'=>'ER10');
}
}catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South!!','code'=>'ER08');
}
return $res;
}
public function flight_availability_search($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/flight_trawex/flight_availability_search?user_id=".$settings['trawex_user_id']."&user_password=".$settings['trawex_user_password']."&access=".$settings['trawex_access']."&ip_address=".$settings['trawex_ip_address']."&session_id=".$data['session_id']."&journey_type=".$data['journey_type']."&airport_from_code=".$data['airport_from_code']."&airport_to_code=".$data['airport_to_code']."&departure_date=".$data['departure_date']."&return_date=".$data['return_date']."&adult_flight=".$data['adult_flight']."&child_flight=".$data['child_flight']."&infant_flight=".$data['infant_flight']."&class=".$data['class']."&target=".$data['target']."";
$result = $this->passToJsonCurl($url,'');
if(!empty($result)){
$result = json_decode($result);
$res = array('status'=>1,'data'=>$result);
}else{
$res = array('status'=>0,'message'=>'No Data Found','code'=>'ER08');
}
}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 flight_fare_rules($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/flight_trawex/fare_rules?user_id=".$settings['trawex_user_id']."&user_password=".$settings['trawex_user_password']."&access=".$settings['trawex_access']."&ip_address=".$settings['trawex_ip_address']."&fare_source_code=".$data['fare_source_code']."&session_id=".$data['session_id']."";
$result = $this->passToJsonCurl($url,'');
if(!empty($result)){
$result = json_decode($result);
$res = array('status'=>1,'data'=>$result);
}else{
$res = array('status'=>0,'message'=>'No Data Found','code'=>'ER08');
}
}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 flight_revalidate($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/flight_trawex/revalidate?user_id=".$settings['trawex_user_id']."&user_password=".$settings['trawex_user_password']."&access=".$settings['trawex_access']."&ip_address=".$settings['trawex_ip_address']."&fare_source_code=".$data['fare_source_code']."&session_id=".$data['session_id']."";
$result = $this->passToJsonCurl($url,'');
if(!empty($result)){
$result = json_decode($result);
$res = array('status'=>1,'data'=>$result);
}else{
$res = array('status'=>0,'message'=>'No Data Found','code'=>'ER08');
}
}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 flight_book($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$data['first_name'] = str_replace(" ","<br>",$data['first_name']);
$data['last_name'] = str_replace(" ","<br>",$data['last_name']);
$data['title'] = str_replace(" ","<br>",$data['title']);
$data['dob'] = str_replace(" ","<br>",$data['dob']);
$data['gender'] = str_replace(" ","<br>",$data['gender']);
$data['issue_country'] = str_replace(" ","<br>",$data['issue_country']);
$data['passport_expiry'] = str_replace(" ","<br>",$data['passport_expiry']);
$data['passport_no'] = str_replace(" ","<br>",$data['passport_no']);
$url = "https://trawex.biz/api/flight_trawex/book?user_id=".$settings['trawex_user_id']."&user_password=".$settings['trawex_user_password']."&access=".$settings['trawex_access']."&ip_address=".$settings['trawex_ip_address']."&target=".$data['target']."&session_id=".$data['session_id']."&area_code=".$data['area_code']."&country_code=".$data['country_code']."&first_name=".$data['first_name']."&last_name=".$data['last_name']."&title=".$data['title']."&email_id=".$data['email_id']."&mobile_no=".$data['mobile_no']."&dob=".$data['dob']."&gender=".$data['gender']."&issue_country=".$data['issue_country']."&passport_expiry=".$data['passport_expiry']."&passport_no=".$data['passport_no']."&type=".$data['type']."&IsPassportMandatory=".$data['IsPassportMandatory']."&adult_flight=".$data['adult_flight']."&child_flight=".$data['child_flight']."&infant_flight=".$data['infant_flight']."&frequentFlyrNum=".$data['frequentFlyrNum']."&adultmealplan=".$data['adultmealplan']."&child_dob=".$data['child_dob']."&child_gender=".$data['child_gender']."&child_title=".$data['child_title']."&child_first_name=".$data['child_first_name']."&child_last_name=".$data['child_last_name']."&child_passport_expiry_date=".$data['child_passport_expiry_date']."&child_passport_no=".$data['child_passport_no']."&child_frequentFlyrNum=".$data['child_frequentFlyrNum']."&childMealplan=".$data['childMealplan']."&infant_dob=".$data['infant_dob']."&infant_gender=".$data['infant_gender']."&infant_first_name=".$data['infant_first_name']."&infant_last_name=".$data['infant_last_name']."&infant_title=".$data['infant_title']."&infantMealplan=".$data['infantMealplan']."&FareSourceCode=".$data['FareSourceCode']."&PostCode=".$data['PostCode']."";
$result = $this->passToJsonCurl($url,'');
if(!empty($result)){
$result = json_decode($result);
$res = array('status'=>1,'result'=>$result);
}else{
$res = array('status'=>0,'message'=>'No Data Found','code'=>'ER08');
}
}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 flight_ticket_order($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/flight_trawex/ticket_order?user_id=".$settings['trawex_user_id']."&user_password=".$settings['trawex_user_password']."&access=".$settings['trawex_access']."&ip_address=".$settings['trawex_ip_address']."&UniqueID=".$data['UniqueID']."&target=".$data['target']."&session_id=".$data['session_id']."";
$result = $this->passToJsonCurl($url,'');
if(!empty($result)){
$result = json_decode($result);
$res = array('status'=>1,'result'=>$result);
}else{
$res = array('status'=>0,'message'=>'No data Found','code'=>'ER08');
}
}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 flight_trip_details($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/flight_trawex/trip_details?user_id=".$settings['trawex_user_id']."&user_password=".$settings['trawex_user_password']."&access=".$settings['trawex_access']."&ip_address=".$settings['trawex_ip_address']."&UniqueID=".$data['UniqueID']."&target=".$data['target']."&session_id=".$data['session_id']."";
$result = $this->passToJsonCurl($url,'');
if(!empty($result)){
$result = json_decode($result);
$res = array('status'=>1,'result'=>$result);
}else{
$res = array('status'=>0,'message'=>'No Data Found','code'=>'ER08');
}
}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 cancel_flights($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/flight_trawex/cancel_flights?user_id=".$settings['trawex_user_id']."&user_password=".$settings['trawex_user_password']."&access=".$settings['trawex_access']."&ip_address=".$settings['trawex_ip_address']."&UniqueID=".$data['UniqueID']."&target=".$data['target']."&session_id=".$data['session_id']."";
}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 airportSearch($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$cond = '';
if(isset($data['query']) && !empty($data['query'])){
$cond = "WHERE airport_code LIKE '%".$data['query']."%' OR airport_name LIKE '%".$data['query']."%'";
}
$sql = "SELECT id FROM airport_details $cond";
$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 $cond 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);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,json_encode($postData));
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-Type:application/json'));
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}
?>
<?php
class Hotel_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
public function auth_token_get($token) {
$rs = $this->db->select('user_id')->where('auth_token', $token)->get('customer_auth')->row();
if(count($rs) > 0) {
return $rs->user_id;
} else {
return 0;
}
}
public function get_hotel_city_list($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0) {
$cond = '';
if(isset($data['query']) && !empty($data['query'])){
$cond = "AND THC.hotel_city_name LIKE '%".$data['query']."%'";
}
$sql = "SELECT HC.hotel_city_id FROM hotel_cities AS HC
INNER JOIN translator_hotel_city AS THC ON(THC.hotel_city_id=HC.hotel_city_id)
WHERE HC.status=1 $cond GROUP BY HC.hotel_city_id";
$count = $this->db->query($sql)->num_rows();
if($count >= 1){
$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 THC.hotel_city_id AS id,HC.hotel_city_icon AS image
FROM translator_hotel_city AS THC
INNER JOIN hotel_cities AS HC ON (HC.hotel_city_id=THC.hotel_city_id)
WHERE THC.status=1 $cond GROUP BY HC.hotel_city_id LIMIT $limit,$perPage";
$hotelData = $this->db->query($sql)->result_array();
$countryData = $this->getCountryData($user_id);
$lang = $countryData['language_code'];
foreach ($hotelData as $key => $value) {
if(!empty($lanTrans = langTranslator($value['id'],'HCTY',$lang))){
$hotelData[$key]['name'] = $lanTrans['hotel_city_name'];
}
}
if(count($hotelData) < 0){
$res = array('status'=>0,'message'=>'No Data Found','code'=>'ER10');
}
$res = array('status'=>1,'data'=>array('city_list'=>$hotelData,'meta'=>$meta));
}else{
$res = array('status'=>0,'message'=>'No Data Found','code'=>'ER10');
}
}else{
$res = array('status'=>0,'message'=>'User Authentication Failed','code'=>'ER15');
}
} catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South!!','code'=>'ER08');
}
return $res;
}
public function hotel_search($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0) {
$trackingId = time().rand(100000,999999);
$settings = getSettings();
if(!isset($data['nextToken']) && empty($data['nextToken'])){
$this->db->select('nationality');
$userData = $this->db->get_where('customer',array('customer_id'=>$user_id))->row_array();
$countryData = $this->getCountryData($user_id);
}
$url = (isset($data['nextToken']) && !empty($data['nextToken']))?"https://trawex.biz/api/hotel_trawexv5/getMoreHotels?user_id=".$settings['trawex_user_id']."&user_password=".$settings['trawex_user_password']."&access=".$settings['trawex_access']."&ip_address=".$settings['trawex_ip_address']."&sessionId=".$data['sessionId']."&nextToken=".$data['nextToken']."&trackingId=".$data['trackingId']."":"https://trawex.biz/api/hotel_trawexv5/hotel_search";
if(!isset($data['nextToken']) && empty($data['nextToken'])){
$postData = array('user_id'=>$settings['trawex_user_id'],
'user_password'=>$settings['trawex_user_password'],
'access'=>$settings['trawex_access'],
'ip_address'=>$settings['trawex_ip_address'],
'trackingId'=>$trackingId,'city_name'=>$data['city_name'],
'country_name'=>$data['country_name'],
'room_count'=>$data['room_count'],'adult'=>$data['adult'],
'child'=>$data['child'],'child_age'=>$data['child_age'],
'checkin'=>$data['checkin'],'checkout'=>$data['checkout'],
'client_nationality'=>$userData['nationality'],
'requiredCurrency'=>$countryData['currency']);
}
$postFields = (isset($data['nextToken']) && !empty($data['nextToken']))?'':$postData;
$result = $this->passToJsonCurl($url,$postFields);
if(!empty($result)){
$result = json_decode($result);
$result->status->trackingId = (!isset($data['nextToken']) && empty($data['nextToken']))?$trackingId:$data['trackingId'];
$res = array('status'=>1,'data'=>array('itineraries'=> $result));
}else{
$res = array('status'=>0,'message'=>'No Data Found','code'=>'ER07');
}
}else{
$res = array('status'=>0,'message'=>'User Authentication Error','code'=>'ER10');
}
}catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South!!','code'=>'ER08');
}
return $res;
}
public function get_specific_hotel_content($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0) {
$settings = getSettings();
$url = "https://trawex.biz/api/hotel_trawexv5/get_specific_hotel_content?user_id=".$settings['trawex_user_id']."&user_password=".$settings['trawex_user_password']."&access=".$settings['trawex_access']."&ip_address=".$settings['trawex_ip_address']."&sessionId=".$data['sessionId']."&trackingId=".$data['trackingId']."&productId=".$data['productId']."&hotelId=".$data['hotelId']."";
$result = $this->passToJsonCurl($url,'');
if(!empty($result)){
$result = json_decode($result);
$result->trackingId = $data['trackingId'];
$res = array('status'=>1,'data'=>$result);
}else{
$res = array('status'=>0,'message'=>'No Data Found','code'=>'ER06');
}
}else{
$res = array('status'=>0,'message'=>'User Authentication Error','code'=>'ER10');
}
}catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South!!','code'=>'ER08');
}
return $res;
}
public function get_room_rates($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/hotel_trawexv5/get_room_rates";
$postData = array("user_id"=>$settings['trawex_user_id'],"user_password"=>$settings['trawex_user_password'],"access"=>$settings['trawex_access'],"ip_address"=>$settings['trawex_ip_address'],"TraceId"=>$data['TraceId'],"propertyid"=>$data['propertyid'],"trackingId"=>$data['trackingId'],"sessionId"=>$data['sessionId'],"productId"=>$data['productId'],"TokenId"=>$data['TokenId'],"resultindex"=>$data['resultindex'],"hotelcode"=>$data['hotelcode']);
$result = $this->passToJsonCurl($url,$postData);
if(!empty($result)){
$result = json_decode($result);
$result->trackingId = $data['trackingId'];
$res = array('status'=>1,'data'=>$result);
}else{
$res = array('status'=>0,'message'=>'No data Found','code'=>'ER06');
}
}else{
$res = array('status'=>0,'message'=>'User Authentication Error','code'=>'ER10');
}
}catch (Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South!!','code'=>'ER08');
}
return $res;
}
public function get_rate_rules($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/hotel_trawexv5/get_rate_rules";
$postData = array(
"user_id"=>$settings['trawex_user_id'],
"user_password"=>$settings['trawex_user_password'],
"access"=>$settings['trawex_access'],
"ip_address"=>$settings['trawex_ip_address'],
"TraceId"=>$data['TraceId'],"propertyid"=>$data['propertyid'],
"trackingId"=>$data['trackingId'],"sessionId"=>$data['sessionId'],
"productId"=>$data['productId'],"TokenId"=>$data['TokenId'],
"resultindex"=>$data['resultindex'],"hotelcode"=>$data['hotelcode'],
"allocationDetails"=>$data['allocationDetails'],
"booking_token"=>$data['booking_token'],
"hotel_name"=>$data['hotel_name'],"infosource"=>$data['infosource'],
"meal_code"=>$data['meal_code'],
"rate_basis_id"=>$data['rate_basis_id'],
"room_code"=>$data['room_code'],"boardCode"=>$data['boardCode'],
"roomType_runno"=>$data['roomType_runno']);
$result = $this->passToJsonCurl($url,$postData);
if(!empty($result)){
$result = json_decode($result);
$result->trackingId = $data['trackingId'];
$res = array('status'=>1,'data'=>$result);
}else{
$res = array('status'=>0,'message'=>'No data Found','code'=>'ER06');
}
}else{
$res = array('status'=>0,'message'=>'User Authentication Error','code'=>'ER10');
}
} catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South!!','code'=>'ER08');
}
return $res;
}
public function hotel_book($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/hotel_trawexv5/hotel_book";
$postData = array(
"user_id"=>$settings['trawex_user_id'],
"user_password"=>$settings['trawex_user_password'],
"access"=>$settings['trawex_access'],
"ip_address"=>$settings['trawex_ip_address'],
"TraceId"=>$data['TraceId'],"propertyid"=>$data['propertyid'],
"trackingId"=>$data['trackingId'],"sessionId"=>$data['sessionId'],
"productId"=>$data['productId'],"TokenId"=>$data['TokenId'],
"resultindex"=>$data['resultindex'],"hotelcode"=>$data['hotelcode'],
"changedOccupancy"=>$data['changedOccupancy'],
"extrabeds"=>$data['extrabeds'],
"guests_details"=>$data['guests_details'],"refcode"=>$data['refcode'],
"prebookingtoken"=>$data['prebookingtoken']
);
$result = $this->passToJsonCurl($url,$postData);
if(!empty($result)){
$result = json_decode($result);
$result->trackingId = $data['trackingId'];
$res = array('status'=>1,'data'=>$result);
}else{
$res = array('status'=>0,'message'=>'No data Found','code'=>'ER06');
}
}else{
$res = array('status'=>0,'message'=>'User Authentication Error','code'=>'ER10');
}
} catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South!!','code'=>'ER08');
}
return $res;
}
public function trawex_cancel_booking($data){
try{
$user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){
$settings = getSettings();
$url = "https://trawex.biz/api/hotel_trawexv5/cancel_booking";
$postData = array(
"user_id"=>$settings['trawex_user_id'],
"user_password"=>$settings['trawex_user_password'],
"access"=>$settings['trawex_access'],
"ip_address"=>$settings['trawex_ip_address'],
'trackingId'=>$data['trackingId'],'productId'=>$data['productId'],
'supplierConfirmationNum'=>$data['supplierConfirmationNum'],
'reference'=>$data['reference']
);
$result = $this->passToJsonCurl($url,$postData);
if(!empty($result)){
$result = json_decode($result);
$result->trackingId = $data['trackingId'];
$res = array('status'=>1,'data'=>$result);
}else{
$res = array('status'=>0,'message'=>'No data Found','code'=>'ER06');
}
}else{
$res = array('status'=>0,'message'=>'User Authentication Error','code'=>'ER10');
}
} catch(Exception $e){
$re = array('status'=>0,'message'=>'Ohh No!! Something Went South!!','code'=>'ER08');
}
return $res;
}
public function getCountryData($user_id){
$ctryData = '';
if(!empty($user_id)){
$sql = "SELECT CTRY.* FROM customer AS CUST
INNER JOIN country AS CTRY ON (CTRY.country_id=CUST.country_id)
WHERE CUST.customer_id='$user_id'";
$ctryData = $this->db->query($sql)->row_array();
}
if(empty($ctryData)){
$ctryData = $this->db->query("SELECT * FROM country WHERE language_code='EN'")->row_array();
}
return $ctryData;
}
public function passToJsonCurl($url='',$postData=array()){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,json_encode($postData));
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-Type:application/json'));
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}
?>
...@@ -1428,19 +1428,28 @@ class Webservice_model extends CI_Model { ...@@ -1428,19 +1428,28 @@ class Webservice_model extends CI_Model {
translator_event.event_name,booking.qrcode AS event_image, translator_event.event_name,booking.qrcode AS event_image,
venue.location,event_date_time.time,booking.event_id, venue.location,event_date_time.time,booking.event_id,
booking.no_of_ticket AS ticket_count,events.has_payment, booking.no_of_ticket AS ticket_count,events.has_payment,
booking.status AS booking_status booking.status AS booking_status,transaction.status AS transaction_status
FROM booking FROM booking
INNER JOIN events ON booking.event_id = events.event_id INNER JOIN events ON booking.event_id = events.event_id
INNER JOIN event_date_time ON booking.event_date_id = event_date_time.id INNER JOIN event_date_time ON booking.event_date_id = event_date_time.id
INNER JOIN venue ON venue.id = events.venue_id INNER JOIN venue ON venue.id = events.venue_id
INNER JOIN translator_event ON translator_event.event_id=events.event_id INNER JOIN translator_event ON translator_event.event_id=events.event_id
WHERE booking.customer_id = '$user_id' AND booking.status IN(0,1,2,6) LEFT JOIN transaction ON transaction.booking_id=booking.bookId
WHERE booking.customer_id = '$user_id' AND booking.status IN (0,1,2,6)
AND (translator_event.language_code='$lang' OR AND (translator_event.language_code='$lang' OR
translator_event.language_code='EN') translator_event.language_code='EN')
GROUP BY booking.id GROUP BY booking.id
ORDER BY booking.id DESC ORDER BY booking.id DESC
LIMIT $page_limit, $per_page"; LIMIT $page_limit, $per_page";
$result = $this->db->query($sql)->result_array(); $result = $this->db->query($sql)->result_array();
if(!empty($result)){
foreach ($result AS $key => $value) {
if($value['has_payment'] == '1' && $value['transaction_status'] != '1'){
unset($result[$key]);
}
}
$result = array_values($result);
}
$meta = array('total_pages'=>ceil($count/$per_page), $meta = array('total_pages'=>ceil($count/$per_page),
'total'=>$count, 'total'=>$count,
'current_page'=>$page, 'current_page'=>$page,
......
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