Commit 1fd1f30c by Tobin

dc

parent a20d7d7d
...@@ -179,7 +179,6 @@ class Webservices extends CI_Controller { ...@@ -179,7 +179,6 @@ class Webservices extends CI_Controller {
} else { } else {
print json_encode(array('status'=>'error','message'=>'You are not authorized to access the server', print json_encode(array('status'=>'error','message'=>'You are not authorized to access the server',
'error'=>'Authentication Failed')); 'error'=>'Authentication Failed'));
} }
} }
...@@ -339,8 +338,8 @@ class Webservices extends CI_Controller { ...@@ -339,8 +338,8 @@ class Webservices extends CI_Controller {
$request['auth'] = $auth; $request['auth'] = $auth;
if(!empty($request) && isset($request['trip_type']) && !empty($request['trip_type']) && if(!empty($request) && isset($request['trip_type']) && !empty($request['trip_type']) &&
isset($request['source_name']) && !empty($request['source_name']) && isset($request['source_name']) && !empty($request['source_name']) &&
isset($request['destination_name']) && !empty($request['destination_name']) &&
isset($request['source_latitude']) && !empty($request['source_latitude']) && isset($request['source_latitude']) && !empty($request['source_latitude']) &&
isset($request['destination_name']) && !empty($request['destination_name']) &&
isset($request['source_longitude']) && !empty($request['source_longitude']) && isset($request['source_longitude']) && !empty($request['source_longitude']) &&
isset($request['destination_latitude']) && !empty($request['destination_latitude']) && isset($request['destination_latitude']) && !empty($request['destination_latitude']) &&
isset($request['destination_longitude']) && !empty($request['destination_longitude'])){ isset($request['destination_longitude']) && !empty($request['destination_longitude'])){
...@@ -507,4 +506,27 @@ class Webservices extends CI_Controller { ...@@ -507,4 +506,27 @@ class Webservices extends CI_Controller {
} }
} }
public function driverAssignCrone(){
$ride_data = $this->Webservice_model->driverAssignCrone();
if(empty($ride_data)){
return;
}
foreach ($ride_data AS $ride) {
if(empty($ride['pickup_lat']) || empty($ride['pickup_lng']) ||
empty($ride['appointment_time']) || $ride['appointment_time']<strtotime(date('Y-m-d H:i:s'))){
continue;
}
$driver_data = $this->Webservice_model->getAvailableDrivers($ride['pickup_lat'],$ride['pickup_lng'],$ride['appointment_time']);
if(!empty($driver_data) && !empty($driver_data['driver_id']) &&
!empty($driver_data['distance']) && !empty($driver_data['fcm_token'])){
$fcm_data = array('title'=>'Ride Request','message'=>'Emergency Ride Request',
'request_id'=>$ride['transport_id']);
push_sent_cancel(1,$driver_data['fcm_token'],$fcm_data);
}
}
}
}?> }?>
\ No newline at end of file
...@@ -704,7 +704,7 @@ ...@@ -704,7 +704,7 @@
$result = $this->Webservices_driver_model->history_trips_schedule($request); $result = $this->Webservices_driver_model->history_trips_schedule($request);
if ($result) { if (!empty($result)) {
$total = COUNT($result); $total = COUNT($result);
......
...@@ -133,4 +133,38 @@ function getLatLngFromLocation($location = ''){ ...@@ -133,4 +133,38 @@ function getLatLngFromLocation($location = ''){
return 0; return 0;
return $locArr; return $locArr;
} }
?>
\ No newline at end of file function getSettings(){
$CI = & get_instance();
$settings = $CI->db->get('setting');
return (!empty($settings))?$settings->row_array():'';
}
function push_sent_cancel($type='1', $fcm_token='', $fcm_data=array()) {
$settings = getSettings();
$key = $settings['push_app_key'];
if(empty($key) || empty($fcm_token) || empty($fcm_data)){
return;
}
switch ($type) {
case '1':
$data = "{ \"notification\": { \"title\": \"".$fcm_data['title']."\", \"text\": \"".$fcm_data['message']."\", \"sound\": \"default\" }, \"time_to_live\": 60, \"data\" : {\"response\" : {\"status\" : \"success\", \"data\" : {\"request_id\" : \"".$fcm_data['request_id']."\", \"request_type\" : 0}}}, \"collapse_key\" : \"trip\", \"priority\":\"high\", \"to\" : \"".$fcm_token."\"}";
break;
// case '2':
// $data = "{ \"notification\": { \"title\": \"".$fcm_data['title']."\", \"text\": \"".$fcm_data['message']."\", \"sound\": \"default\" }, \"time_to_live\": 60, \"data\" : {\"response\" : {\"status\" : \"success\", \"data\" : {\"booking_id\" : \"".$fcm_data['id']."\", \"trip_status\" : 0}}}, \"collapse_key\" : \"trip\", \"priority\":\"high\", \"to\" : \"".$fcm_token."\"}";
// break;
}
$ch = curl_init("https://fcm.googleapis.com/fcm/send");
$header = array('Content-Type: application/json', 'Authorization: key='.$key);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$out = curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
}?>
\ No newline at end of file
<?php <?php
class Webservice_model extends CI_Model {
class Webservice_model extends CI_Model { function __construct() {
function __construct() { parent::__construct();
parent::__construct(); date_default_timezone_set('Asia/Kolkata');
date_default_timezone_set('Asia/Kolkata'); }
public function user_reg($data='') {
$num = $this->db->where('phone', $data['phone_number'])->get('customers')->num_rows();
if ($num > 0) {
$result = array('status'=>'error','message'=>'Mobile number Already Exists');
} }
else {
$unique_id = $this->generate_unique();
$this->db->insert('customers', array('phone'=>$data['phone_number'],'first_name'=>$data['first_name'],'last_name'=>$data['last_name'],'password'=>md5($data['password'])));
$db_data = array();
public function user_reg($data='') { $user_id = $this->db->insert_id();
$num = $this->db->where('phone', $data['phone_number'])->get('customers')->num_rows();
if ($num > 0) {
$result = array('status'=>'error','message'=>'Mobile number Already Exists');
}
else {
$unique_id = $this->generate_unique();
$this->db->insert('customers', array('phone'=>$data['phone_number'],'first_name'=>$data['first_name'],'last_name'=>$data['last_name'],'password'=>md5($data['password'])));
$db_data = array();
$user_id = $this->db->insert_id();
$this->db->insert('cust_company_list', array('user_id'=>$user_id,'company_id'=>$data['company_id'])); $this->db->insert('cust_company_list', array('user_id'=>$user_id,'company_id'=>$data['company_id']));
$this->EncryptedPatientKey($unique_id, $user_id); $this->EncryptedPatientKey($unique_id, $user_id);
if ($user_id) { if ($user_id) {
$result = array('status'=>'success','auth_token'=>$unique_id,'user_id'=>$user_id,
'phone'=>$data['phone_number'],'name'=>$data['first_name']." ".$data['last_name']);
} else {
$result = array('status'=>'error','message'=>'Something Went wrong');
}
}
return $result;
$result = array('status'=>'success','auth_token'=>$unique_id,'user_id'=>$user_id,
'phone'=>$data['phone_number'],'name'=>$data['first_name']." ".$data['last_name']);
} else {
$result = array('status'=>'error','message'=>'Something Went wrong');
}
} }
return $result;
public function generate_unique() { }
$unqe = md5(uniqid(time().mt_rand(), true)); public function generate_unique() {
return $unqe; $unqe = md5(uniqid(time().mt_rand(), true));
} return $unqe;
public function EncryptedPatientKey($unique_id, $user_id) {
$this->db->insert('auth_table', array('cust_id'=>$user_id,'unique_id'=>$unique_id)); }
public function EncryptedPatientKey($unique_id, $user_id) {
} $this->db->insert('auth_table', array('cust_id'=>$user_id,'unique_id'=>$unique_id));
public function login($request='') { }
$this->db->where("phone = '".$request['phone_number']."'"); public function login($request='') {
$this->db->where('password', md5($request['password'])); $this->db->where("phone = '".$request['phone_number']."'");
$this->db->where('status !=', 0); $this->db->where('password', md5($request['password']));
$query = $this->db->get('customers'); $this->db->where('status !=', 0);
if ($query->num_rows() > 0) { $query = $this->db->get('customers');
$unique_id = $this->generate_unique(); if ($query->num_rows() > 0) {
$rs = $query->row(); $unique_id = $this->generate_unique();
$this->EncryptedPatientKey($unique_id, $rs->customer_id); $rs = $query->row();
return $result = array('status'=>'success','user_id'=>$rs->customer_id, $this->EncryptedPatientKey($unique_id, $rs->customer_id);
'auth_token'=>$unique_id,'phone'=>$rs->phone,
'name'=>$rs->first_name." ".$rs->last_name);
} else { return $result = array('status'=>'success','user_id'=>$rs->customer_id,
'auth_token'=>$unique_id,'phone'=>$rs->phone,
'name'=>$rs->first_name." ".$rs->last_name);
return false; } else {
}
return false;
} }
public function company_list() { }
$data = "SELECT id AS company_id, company_name AS company_name FROM `company` ORDER BY id DESC"; public function company_list() {
$query = $this->db->query($data)->result(); $data = "SELECT id AS company_id, company_name AS company_name FROM `company` ORDER BY id DESC";
if($query){ $query = $this->db->query($data)->result();
return $query; if($query){
}else{ return $query;
return false; }else{
} return false;
} }
public function edit_user($request='') { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function edit_user($request='') {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$data = array(); if ($query->num_rows() > 0) {
$custCompanyId = array(); $data = array();
if (isset($request['company_id']) && $request['company_id'] != '') { $custCompanyId = array();
$custCompanyId['company_id'] = $request['company_id']; if (isset($request['company_id']) && $request['company_id'] != '') {
} $custCompanyId['company_id'] = $request['company_id'];
if (isset($request['first_name']) && $request['first_name'] != '') { }
$data['first_name'] = $request['first_name']; if (isset($request['first_name']) && $request['first_name'] != '') {
} $data['first_name'] = $request['first_name'];
if (isset($request['last_name']) && $request['last_name'] != '') { }
$data['last_name'] = $request['last_name']; if (isset($request['last_name']) && $request['last_name'] != '') {
} $data['last_name'] = $request['last_name'];
if (EMPTY($request['last_name'])) { }
$data['last_name'] = ""; if (EMPTY($request['last_name'])) {
} $data['last_name'] = "";
if (isset($request['phone']) && $request['phone'] != '') { }
$data['phone'] = $request['phone']; if (isset($request['phone']) && $request['phone'] != '') {
} $data['phone'] = $request['phone'];
$rs = $query->row(); }
$this->db->where('customer_id', $rs->cust_id)->update('customers', $data); $rs = $query->row();
$this->db->where('user_id', $rs->cust_id)->update('cust_company_list', $custCompanyId); $this->db->where('customer_id', $rs->cust_id)->update('customers', $data);
return true; $this->db->where('user_id', $rs->cust_id)->update('cust_company_list', $custCompanyId);
} else { return true;
return false; } else {
} return false;
} }
public function complaints($request) { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function complaints($request) {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$rs = $query->row(); if ($query->num_rows() > 0) {
$data = array('complaint'=>$request['complaint'],'user_id'=>$rs->cust_id); $rs = $query->row();
$this->db->insert('complaints', $data); $data = array('complaint'=>$request['complaint'],'user_id'=>$rs->cust_id);
return $result = array('status'=>'success'); $this->db->insert('complaints', $data);
} else { return $result = array('status'=>'success');
return false; } else {
} return false;
} }
public function save_token($request='') { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function save_token($request='') {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$rs = $query->row(); if ($query->num_rows() > 0) {
$id = $rs->cust_id; $rs = $query->row();
$data = array('fcm_token'=>$request['fcm_token']); $id = $rs->cust_id;
$result = $this->db->where('customer_id', $id)->update('customers', $data); $data = array('fcm_token'=>$request['fcm_token']);
return $result; $result = $this->db->where('customer_id', $id)->update('customers', $data);
} else { return $result;
return false; } else {
} return false;
} }
public function forgetpassword($request='') { }
$query = $this->db->where('phone', $request['phone_number'])->get('customers'); public function forgetpassword($request='') {
if ($query->num_rows() > 0) { $query = $this->db->where('phone', $request['phone_number'])->get('customers');
$rs = $query->row(); if ($query->num_rows() > 0) {
$user_id = $rs->customer_id; $rs = $query->row();
$data = array('password'=>md5($request['new_password'])); $user_id = $rs->customer_id;
$this->db->where('customer_id', $user_id); $data = array('password'=>md5($request['new_password']));
$this->db->update('customers',$data); $this->db->where('customer_id', $user_id);
return $result = array('status'=>'success'); $this->db->update('customers',$data);
} else { return $result = array('status'=>'success');
return false; } else {
} return false;
} }
public function update_password($request='') { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function update_password($request='') {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$rs = $query->row(); if ($query->num_rows() > 0) {
$user_id = $rs->cust_id; $rs = $query->row();
$data = array('password'=>md5($request['new_password'])); $user_id = $rs->cust_id;
$this->db->where('customer_id', $user_id); $data = array('password'=>md5($request['new_password']));
$this->db->update('customers',$data); $this->db->where('customer_id', $user_id);
return $result = array('status'=>'success'); $this->db->update('customers',$data);
} else { return $result = array('status'=>'success');
return false; } else {
} return false;
} }
public function profile($request='') { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function profile($request='') {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$query_result = $query->row(); if ($query->num_rows() > 0) {
$customer_id = $query_result->cust_id; $query_result = $query->row();
$data = "SELECT company.id AS company_id, customers.customer_id, customers.phone AS phone, $customer_id = $query_result->cust_id;
CONCAT(customers.first_name,' ',customers.last_name) AS name,
company.company_name AS company_name, customers.profile_image
FROM customers INNER JOIN cust_company_list ON customers.customer_id = cust_company_list.user_id
INNER JOIN company ON cust_company_list.company_id = company.id
WHERE customers.customer_id = '$customer_id' ";
//print_r($data);exit();
$result = $this->db->query($data);
$rs = $result->row(); $data = "SELECT company.id AS company_id, customers.customer_id, customers.phone AS phone,
CONCAT(customers.first_name,' ',customers.last_name) AS name,
company.company_name AS company_name, customers.profile_image
FROM customers INNER JOIN cust_company_list ON customers.customer_id = cust_company_list.user_id
INNER JOIN company ON cust_company_list.company_id = company.id
WHERE customers.customer_id = '$customer_id' ";
//print_r($data);exit();
$result = $this->db->query($data);
return $result = array('id'=>$rs->customer_id,'phone'=>$rs->phone, $rs = $result->row();
'name'=>$rs->name,'company_name'=>$rs->company_name,
'profile_photo'=>$rs->profile_image,'company_id'=>$rs->company_id);
} else {
return false; return $result = array('id'=>$rs->customer_id,'phone'=>$rs->phone,
} 'name'=>$rs->name,'company_name'=>$rs->company_name,
'profile_photo'=>$rs->profile_image,'company_id'=>$rs->company_id);
} else {
return false;
} }
public function update_user_location($request='') { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function update_user_location($request='') {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$rs = $query->row(); if ($query->num_rows() > 0) {
$id = $rs->cust_id; $rs = $query->row();
$data = array('user_latitude'=>$request['latitude'],'user_longitude'=>$request['longitude']); $id = $rs->cust_id;
$result = $this->db->where('customer_id', $id)->update('customers', $data); $data = array('user_latitude'=>$request['latitude'],'user_longitude'=>$request['longitude']);
if($result){
return $result; $result = $this->db->where('customer_id', $id)->update('customers', $data);
if($result){
}else{ return $result;
return false; }else{
} return false;
}
} else {
return false; } else {
} return false;
} }
public function update_profile_photo($request) { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function update_profile_photo($request) {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$rs = $query->row(); if ($query->num_rows() > 0) {
$data = array('profile_image'=>$request['profile_photo']); $rs = $query->row();
$this->db->where('customer_id', $rs->cust_id)->update('customers', $data); $data = array('profile_image'=>$request['profile_photo']);
return true; $this->db->where('customer_id', $rs->cust_id)->update('customers', $data);
} else { return true;
return false; } else {
}
return false;
} }
public function call_ambulance($request='') { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function call_ambulance($request='') {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$rs = $query->row(); if ($query->num_rows() > 0) {
$cusrimer_id = $rs->cust_id; $rs = $query->row();
$customerDetails = $data = "SELECT CONCAT(c.first_name,' ',c.last_name) AS patient_name, $cusrimer_id = $rs->cust_id;
cust_company_list.company_id AS company_id, c.phone FROM customers AS c
LEFT JOIN cust_company_list ON cust_company_list.user_id = c.customer_id
WHERE c.customer_id = '$cusrimer_id'";
$result = $this->db->query($customerDetails)->row(); $customerDetails = "SELECT CONCAT(c.first_name,' ',c.last_name) AS patient_name,
cust_company_list.company_id AS company_id, c.phone FROM customers AS c
LEFT JOIN cust_company_list ON cust_company_list.user_id = c.customer_id
WHERE c.customer_id = '$cusrimer_id'";
$getDistance = $this->GetDrivingDistance($request['source_latitude'], $request['destination_latitude'], $request['source_longitude'], $request['destination_longitude']); $result = $this->db->query($customerDetails)->row();
$distanceValue = $getDistance['distanceValue'] * 0.001; $getDistance = $this->GetDrivingDistance($request['source_latitude'], $request['destination_latitude'],$request['source_longitude'],$request['destination_longitude']);
$timeValue = $getDistance['timeValue'] * 0.0166667; $distanceValue = $getDistance['distanceValue'] * 0.001;
if($result){ $timeValue = $getDistance['timeValue'] * 0.0166667;
$data = array('total_time'=>$timeValue, if($result){
'trip_distance'=>$distanceValue,
'company_id'=>$result->company_id,
'customer_id'=>$cusrimer_id,
'patient_name'=>$result->patient_name,
'phone'=>$result->phone,
'pickup_location'=>$request['source_name'],
'pickup_lat'=>$request['source_latitude'],
'pickup_lng'=>$request['source_longitude'],
'drop_location'=>$request['destination_name'],
'drop_lat'=>$request['destination_latitude'],
'drop_lng'=>$request['destination_longitude'],
'request_type'=>$request['trip_type'],
'driver_assign_status'=>2,
'payment_mode'=>0,
'status'=>'3');
$this->db->insert('transport_details', $data);
$last_id = $this->db->insert_id();
}else{
return false; $data = array('total_time'=>$timeValue,
'trip_distance'=>$distanceValue,
'company_id'=>$result->company_id,
'customer_id'=>$cusrimer_id,
'patient_name'=>$result->patient_name,
'phone'=>$result->phone,
'pickup_location'=>$request['source_name'],
'pickup_lat'=>$request['source_latitude'],
'pickup_lng'=>$request['source_longitude'],
'drop_location'=>$request['destination_name'],
'drop_lat'=>$request['destination_latitude'],
'drop_lng'=>$request['destination_longitude'],
'request_type'=>$request['trip_type'],
'is_scheduled'=>2,
'driver_assign_status'=>2,
'payment_mode'=>0,
'status'=>'1');
$this->db->insert('transport_details', $data);
$last_id = $this->db->insert_id();
}else{
} return false;
return $result = array('request_id'=>$last_id);
} else { }
return $result = array('request_id'=>$last_id);
return false; } else {
} return false;
} }
public function nearest_ambulance($request='') { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function nearest_ambulance($request='') {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$rs = $query->row(); if ($query->num_rows() > 0) {
$cust_id = $rs->cust_id; $rs = $query->row();
$data1 = "SELECT * FROM setting WHERE id = '1' "; $cust_id = $rs->cust_id;
$query1 = $this->db->query($data1); $data1 = "SELECT * FROM setting WHERE id = '1' ";
$rs = $query1->row(); $query1 = $this->db->query($data1);
$radius = $rs->radius; $rs = $query1->row();
$customerDetails = $this->db->query("SELECT customers.user_latitude, $radius = $rs->radius;
customers.user_longitude FROM `customers` WHERE customers.customer_id =".$cust_id)->row();
$data = $this->db->query("SELECT d.book_status, d.driver_id, d.status, d.is_online, d.online_start_time, d.online_end_time, (((acos(sin((".$customerDetails->user_latitude."*pi()/180)) * sin((lat_driver*pi()/180)) + cos((".$customerDetails->user_latitude."*pi()/180)) * cos((lat_driver*pi()/180)) * cos(((".$customerDetails->user_longitude." - lng_driver)*pi()/180))))*180/pi())*60*1.1515) as distance FROM drivers AS d WHERE d.status = '1' AND d.is_online = '1' AND d.book_status = '0' AND d.online_start_time < DATE_FORMAT(now(),'%H:%i') AND d.online_end_time > DATE_FORMAT(now(),'%H:%i') HAVING distance < ".$radius."")->result_array(); $customerDetails = $this->db->query("SELECT customers.user_latitude,
customers.user_longitude FROM `customers` WHERE customers.customer_id =".$cust_id)->row();
$nonScheduledDriver = $this->db->query("SELECT driver_id FROM `transport_details` WHERE is_scheduled = 1")->result_array(); $data = $this->db->query("SELECT d.book_status, d.driver_id, d.status, d.is_online, d.online_start_time, d.online_end_time, (((acos(sin((".$customerDetails->user_latitude."*pi()/180)) * sin((lat_driver*pi()/180)) + cos((".$customerDetails->user_latitude."*pi()/180)) * cos((lat_driver*pi()/180)) * cos(((".$customerDetails->user_longitude." - lng_driver)*pi()/180))))*180/pi())*60*1.1515) as distance FROM drivers AS d WHERE d.status = '1' AND d.is_online = '1' AND d.book_status = '0' AND d.online_start_time < DATE_FORMAT(now(),'%H:%i') AND d.online_end_time > DATE_FORMAT(now(),'%H:%i') HAVING distance < ".$radius."")->result_array();
if (EMPTY($nonScheduledDriver)){ $nonScheduledDriver = $this->db->query("SELECT driver_id FROM `transport_details` WHERE is_scheduled = 1")->result_array();
$nonScheduledDriver[] = array('driver_id'=>'0' );; if (EMPTY($nonScheduledDriver)){
}
foreach($data as $row){ $nonScheduledDriver[] = array('driver_id'=>'0' );;
}
$driverList[] = $row['driver_id']; foreach($data as $row){
foreach ($nonScheduledDriver as $row1) { $driverList[] = $row['driver_id'];
$nonScheduledDriver1[] = $row1['driver_id']; foreach ($nonScheduledDriver as $row1) {
}
} $nonScheduledDriver1[] = $row1['driver_id'];
$nonScheduledDriverList = array_diff($driverList,$nonScheduledDriver1); }
if($nonScheduledDriverList){ }
$nonScheduledDriverList = array_diff($driverList,$nonScheduledDriver1);
return $result = array('ambulace_count'=>COUNT($nonScheduledDriverList),'distance'=>$radius.'Km'); if($nonScheduledDriverList){
}else{ return $result = array('ambulace_count'=>COUNT($nonScheduledDriverList),'distance'=>$radius.'Km');
return $result = array('ambulace_count'=>'0','distance'=>'0'.'Km'); }else{
}
} else { return $result = array('ambulace_count'=>'0','distance'=>'0'.'Km');
}
return false; } else {
}
return false;
} }
public function trip_completion_details($request='') { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function trip_completion_details($request='') {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$rs = $query->row(); if ($query->num_rows() > 0) {
$cust_id = $rs->cust_id; $rs = $query->row();
$id = $request['trip_id']; $cust_id = $rs->cust_id;
$data = "SELECT CONCAT(transport_details.trip_distance,' ','km') AS distance, transport_details.total_time AS time, transport_details.trip_cost AS total_amount, drivers.profile_image AS driver_photo, CONCAT(drivers.first_name,' ',drivers.last_name) AS driver_name FROM transport_details LEFT JOIN drivers ON transport_details.driver_id = drivers.driver_id WHERE transport_details.transport_id = '$id' AND transport_details.status = '6' AND transport_details.customer_id = '$cust_id' "; $id = $request['trip_id'];
$query = $this->db->query($data); $data = "SELECT CONCAT(transport_details.trip_distance,' ','km') AS distance, transport_details.total_time AS time, transport_details.trip_cost AS total_amount, drivers.profile_image AS driver_photo, CONCAT(drivers.first_name,' ',drivers.last_name) AS driver_name FROM transport_details LEFT JOIN drivers ON transport_details.driver_id = drivers.driver_id WHERE transport_details.transport_id = '$id' AND transport_details.status = '6' AND transport_details.customer_id = '$cust_id' ";
$result = $query->row(); $query = $this->db->query($data);
return $result; $result = $query->row();
} else { return $result;
return false; } else {
} return false;
} }
public function cancel_request($request) { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function cancel_request($request) {
$queryResult = $this->db->where('transport_id', $request['request_id'])->get('transport_details'); $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
if ($query->num_rows() > 0 && $queryResult->num_rows()) { $queryResult = $this->db->where('transport_id', $request['request_id'])->get('transport_details');
$rs = $query->row(); if ($query->num_rows() > 0 && $queryResult->num_rows()) {
$user_id = $rs->cust_id; $rs = $query->row();
$id = $request["request_id"]; $user_id = $rs->cust_id;
$result = $this->db->where('transport_id', $id)->where('customer_id', $user_id)->update('transport_details', array('status'=>'9')); $id = $request["request_id"];
if($result){ $result = $this->db->where('transport_id', $id)->where('customer_id', $user_id)->update('transport_details', array('status'=>'9'));
return $result; if($result){
}else{ return $result;
return false; }else{
}
return false;
}
} else {
return false; } else {
} return false;
} }
public function trip_cancel($request) { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function trip_cancel($request) {
$rs = $query->row(); $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$cust_id = $rs->cust_id; $rs = $query->row();
if ($query->num_rows() > 0) { $cust_id = $rs->cust_id;
$id = $request["trip_id"]; if ($query->num_rows() > 0) {
$result = $this->db->where('transport_id', $id)->update('transport_details', array('status'=>'2')); $id = $request["trip_id"];
$data2 = "SELECT * FROM transport_details WHERE customer_id = '$cust_id' AND transport_id = '$id' ORDER BY transport_id DESC"; $result = $this->db->where('transport_id', $id)->update('transport_details', array('status'=>'2'));
$query = $this->db->query($data2); $data2 = "SELECT * FROM transport_details WHERE customer_id = '$cust_id' AND transport_id = '$id' ORDER BY transport_id DESC";
$rs2 = $query->row(); $query = $this->db->query($data2);
$driv_id = $rs2->driver_id; $rs2 = $query->row();
$this->db->where('driver_id', $driv_id)->update('drivers', array('book_status'=>0)); $driv_id = $rs2->driver_id;
$data3 = "SELECT * FROM drivers WHERE driver_id = '$driv_id'"; $this->db->where('driver_id', $driv_id)->update('drivers', array('book_status'=>0));
$query = $this->db->query($data3); $data3 = "SELECT * FROM drivers WHERE driver_id = '$driv_id'";
$rs3 = $query->row(); $query = $this->db->query($data3);
$fcm = $rs3->fcm_token; $rs3 = $query->row();
$fcm_data = array('id'=>$id,'title'=>'NEMT','message'=>'Request Cancelled'); $fcm = $rs3->fcm_token;
$this->push_sent_cancel($fcm, $fcm_data); $fcm_data = array('id'=>$id,'title'=>'NEMT','message'=>'Request Cancelled');
return $result; $this->push_sent_cancel($fcm, $fcm_data);
} else { return $result;
return false; } else {
} return false;
} }
public function push_sent_cancel($fcm_token, $fcm_data) { }
$data1 = "SELECT * FROM setting WHERE id = '1' "; public function push_sent_cancel($fcm_token, $fcm_data) {
$query1 = $this->db->query($data1);
$rs = $query1->row();
$key = $rs->google_api_key;
$data = "{ \"notification\": { \"title\": \"".$fcm_data['title']."\", \"text\": \"".$fcm_data['message']."\", \"sound\": \"ringtone_driver\" }, \"time_to_live\": 60, \"data\" : {\"response\" : {\"status\" : \"success\", \"data\" : {\"trip_id\" : \"".$fcm_data['id']."\", \"trip_status\" : 0}}}, \"collapse_key\" : \"trip\", \"priority\":\"high\", \"to\" : \"".$fcm_token."\"}";
$ch = curl_init("https://fcm.googleapis.com/fcm/send"); $data1 = "SELECT * FROM setting WHERE id = '1' ";
$query1 = $this->db->query($data1);
$rs = $query1->row();
$key = $rs->google_api_key;
$data = "{ \"notification\": { \"title\": \"".$fcm_data['title']."\", \"text\": \"".$fcm_data['message']."\", \"sound\": \"ringtone_driver\" }, \"time_to_live\": 60, \"data\" : {\"response\" : {\"status\" : \"success\", \"data\" : {\"trip_id\" : \"".$fcm_data['id']."\", \"trip_status\" : 0}}}, \"collapse_key\" : \"trip\", \"priority\":\"high\", \"to\" : \"".$fcm_token."\"}";
$header = array('Content-Type: application/json','Authorization: key='.$key); $ch = curl_init("https://fcm.googleapis.com/fcm/send");
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); $header = array('Content-Type: application/json','Authorization: key='.$key);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_POST, 1);
$out = curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch); $out = curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_close($ch); curl_exec($ch);
} curl_close($ch);
public function trip_history($request) { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); public function trip_history($request) {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$rs = $query->row(); if ($query->num_rows() > 0) {
$cust_id = $rs->cust_id; $rs = $query->row();
$cust_id = $rs->cust_id;
$data1 = "SELECT * FROM setting WHERE id = '1' ";
$query1 = $this->db->query($data1); $data1 = "SELECT * FROM setting WHERE id = '1' ";
$rs = $query1->row(); $query1 = $this->db->query($data1);
$currency = $rs->currency; $rs = $query1->row();
$data = "SELECT transport_details.total_time AS time, $currency = $rs->currency;
vehicles.vehicle_reg_no AS ambulance_number,
CONCAT(transport_details.trip_cost,'.$currency.') AS total_amount,
CONCAT(drivers.first_name,' ',drivers.last_name) AS driver_name,
transport_details.trip_distance AS total_distance,
transport_details.pickup_location AS source_name,
transport_details.drop_location AS destination_name,
drivers.profile_image AS driver_photo
FROM `transport_details` LEFT JOIN drivers
ON transport_details.driver_id = drivers.driver_id LEFT JOIN
vehicles ON drivers.vehicle = vehicles.vehicle_id
WHERE transport_details.customer_id = '$cust_id'
ORDER BY transport_details.transport_id DESC ";
$query1 = $this->db->query($data)->result();
return $query1; $data = "SELECT transport_details.total_time AS time,
vehicles.vehicle_reg_no AS ambulance_number,
CONCAT(transport_details.trip_cost,'.$currency.') AS total_amount,
CONCAT(drivers.first_name,' ',drivers.last_name) AS driver_name,
transport_details.trip_distance AS total_distance,
transport_details.pickup_location AS source_name,
transport_details.drop_location AS destination_name,
drivers.profile_image AS driver_photo
FROM `transport_details` LEFT JOIN drivers
ON transport_details.driver_id = drivers.driver_id LEFT JOIN
vehicles ON drivers.vehicle = vehicles.vehicle_id
WHERE transport_details.customer_id = '$cust_id'
ORDER BY transport_details.transport_id DESC ";
$query1 = $this->db->query($data)->result();
} else { return $query1;
return false; } else {
} return false;
} }
public function req_status($request='') { }
$query = $this->db->where('transport_id', $request['request_id'])->get('transport_details'); public function req_status($request='') {
if ($query->num_rows() > 0) { $query = $this->db->where('transport_id', $request['request_id'])->get('transport_details');
$query = $this->db->select("transport_details.status AS request_status, transport_details.transport_id AS trip_id, if ($query->num_rows() > 0) {
CONCAT(transport_details.total_time,' ','min') AS time, CONCAT(transport_details.trip_distance,' ','km') AS distance, CONCAT(drivers.first_name,' ',drivers.last_name) AS driver_name, vehicles.vehicle_reg_no AS car_number, drivers.profile_image AS driver_photo, drivers.phone AS driver_phone_number, transport_details.pickup_lat AS source_latitude, transport_details.pickup_lng AS source_longitude, transport_details.drop_lat AS destination_latitude, transport_details.drop_lng AS destination_longitude")->from('transport_details')->join('drivers','transport_details.driver_id = drivers.driver_id','left')->join('vehicles','drivers.vehicle = vehicles.vehicle_id','left')->where('transport_details.transport_id', $request['request_id'])->get();
if ($query->num_rows() > 0) { $query = $this->db->select("transport_details.status AS request_status, transport_details.transport_id AS trip_id,
CONCAT(transport_details.total_time,' ','min') AS time, CONCAT(transport_details.trip_distance,' ','km') AS distance, CONCAT(drivers.first_name,' ',drivers.last_name) AS driver_name, vehicles.vehicle_reg_no AS car_number, drivers.profile_image AS driver_photo, drivers.phone AS driver_phone_number, transport_details.pickup_lat AS source_latitude, transport_details.pickup_lng AS source_longitude, transport_details.drop_lat AS destination_latitude, transport_details.drop_lng AS destination_longitude")->from('transport_details')->join('drivers','transport_details.driver_id = drivers.driver_id','left')->join('vehicles','drivers.vehicle = vehicles.vehicle_id','left')->where('transport_details.transport_id', $request['request_id'])->get();
$result = $query->row(); if ($query->num_rows() > 0) {
return $result; $result = $query->row();
} return $result;
} else {
return false; }
} else {
} return false;
} }
function statusof_app($request) { }
$query = $this->db->where('unique_id', $request['auth'])->get('auth_table'); function statusof_app($request) {
if ($query->num_rows() > 0) { $query = $this->db->where('unique_id', $request['auth'])->get('auth_table');
$rs = $query->row(); if ($query->num_rows() > 0) {
$cust_id = $rs->cust_id; $rs = $query->row();
$res = "SELECT * FROM transport_details WHERE customer_id = '$cust_id' ORDER BY transport_id DESC LIMIT 0,1"; $cust_id = $rs->cust_id;
$query = $this->db->query($res); $res = "SELECT * FROM transport_details WHERE customer_id = '$cust_id' ORDER BY transport_id DESC LIMIT 0,1";
$rs = $query->row(); $query = $this->db->query($res);
$booking_status = $rs->status; $rs = $query->row();
$driver_id = $rs->driver_id; $booking_status = $rs->status;
$book_id = $rs->transport_id; $driver_id = $rs->driver_id;
if ($booking_status == 4 || $booking_status == 5) { $book_id = $rs->transport_id;
$query1 = $this->db->select('CONCAT(transport_details.total_time," ","min") AS time,transport_details.transport_id AS trip_id,vehicles.vehicle_reg_no AS car_number, CONCAT(transport_details.trip_distance," ","km") AS distance, drivers.profile_image AS driver_photo, drivers.phone AS driver_phone_number, transport_details.status AS request_status, transport_details.pickup_lat AS source_latitude, transport_details.pickup_lng AS source_longitude, transport_details.drop_lat AS destination_latitude, transport_details.drop_lng AS destination_longitude, CONCAT(drivers.first_name," ",drivers.last_name) AS driver_name')->from('transport_details')->join('drivers','transport_details.driver_id = drivers.driver_id','left')->join('vehicles','drivers.vehicle = vehicles.vehicle_id','left')->where('transport_details.transport_id', if ($booking_status == 4 || $booking_status == 5) {
$book_id)->get();
$result = $query1->row(); $query1 = $this->db->select('CONCAT(transport_details.total_time," ","min") AS time,transport_details.transport_id AS trip_id,vehicles.vehicle_reg_no AS car_number, CONCAT(transport_details.trip_distance," ","km") AS distance, drivers.profile_image AS driver_photo, drivers.phone AS driver_phone_number, transport_details.status AS request_status, transport_details.pickup_lat AS source_latitude, transport_details.pickup_lng AS source_longitude, transport_details.drop_lat AS destination_latitude, transport_details.drop_lng AS destination_longitude, CONCAT(drivers.first_name," ",drivers.last_name) AS driver_name')->from('transport_details')->join('drivers','transport_details.driver_id = drivers.driver_id','left')->join('vehicles','drivers.vehicle = vehicles.vehicle_id','left')->where('transport_details.transport_id',
$book_id)->get();
return $result;
} else { $result = $query1->row();
return $result;
return 0; } else {
} return 0;
} else { }
print json_encode(array('status'=>'error','code'=>'209','message'=>'Something Went wrong'));die();
} } else {
} print json_encode(array('status'=>'error','code'=>'209','message'=>'Something Went wrong'));die();
function status_driver($id) { }
}
$data = $this->db->query("SELECT * FROM `transport_details` WHERE transport_id = '$id'")->row(); function status_driver($id) {
if ($data->status == 6 && $data->cash_collection == 1) { $data = $this->db->query("SELECT * FROM `transport_details` WHERE transport_id = '$id'")->row();
$driver_status = 4;
return $driver_status; if ($data->status == 6 && $data->cash_collection == 1) {
} $driver_status = 4;
elseif($data->status == 6 && $data->cash_collection == 0) { return $driver_status;
$driver_status = 3; }
return $driver_status; elseif($data->status == 6 && $data->cash_collection == 0) {
} $driver_status = 3;
elseif($data->status == 5) { return $driver_status;
$driver_status = 2; }
return $driver_status; elseif($data->status == 5) {
} $driver_status = 2;
elseif($data->car_arrival == 1 OR $data->car_arrival == 2) { return $driver_status;
$driver_status = 1; }
return $driver_status; elseif($data->car_arrival == 1 OR $data->car_arrival == 2) {
} $driver_status = 1;
else { return $driver_status;
$driver_status = 0; }
return $driver_status; else {
} $driver_status = 0;
return $driver_status;
} }
}
public function GetDrivingDistance($lat1, $lat2, $long1, $long2) { public function GetDrivingDistance($lat1, $lat2, $long1, $long2) {
$data1 = "SELECT * FROM setting WHERE id = '1' "; $data1 = "SELECT * FROM setting WHERE id = '1' ";
$query1 = $this->db->query($data1); $query1 = $this->db->query($data1);
$rs = $query1->row(); $rs = $query1->row();
$key = $rs->google_api_key; $key = $rs->google_api_key;
$url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=".$lat1.",".$long1."&destinations=".$lat2.",".$long2."&mode=driving&language=pl-PL"."&key=".$key; $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=".$lat1.",".$long1."&destinations=".$lat2.",".$long2."&mode=driving&language=pl-PL"."&key=".$key;
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128); curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch); $response = curl_exec($ch);
curl_close($ch); curl_close($ch);
$response_a = json_decode($response, true); $response_a = json_decode($response, true);
$dist = $response_a['rows'][0]['elements'][0]['distance']['text']; $dist = $response_a['rows'][0]['elements'][0]['distance']['text'];
$distValue = $response_a['rows'][0]['elements'][0]['distance']['value']; $distValue = $response_a['rows'][0]['elements'][0]['distance']['value'];
$time = $response_a['rows'][0]['elements'][0]['duration']['text']; $time = $response_a['rows'][0]['elements'][0]['duration']['text'];
$timeValue = $response_a['rows'][0]['elements'][0]['duration']['value']; $timeValue = $response_a['rows'][0]['elements'][0]['duration']['value'];
return array('distance'=>$dist,'distanceValue'=>$distValue,'time'=>$time,'timeValue'=>$timeValue); return array('distance'=>$dist,'distanceValue'=>$distValue,'time'=>$time,'timeValue'=>$timeValue);
} }
public function phone_number_availability($data = array()){
if(empty($data) || !isset($data['phone']) || empty($data['phone'])){
return 0;
}
$sql = "SELECT * FROM customers WHERE phone LIKE '%".$data['phone']."' AND status IN (0,1)";
$isAvailable = $this->db->query($sql);
$isAvailable = $isAvailable->num_rows();
return $isAvailable;
}
public function phone_number_availability($data = array()){ public function driverAssignCrone(){
if(empty($data) || !isset($data['phone']) || empty($data['phone'])){ $sql = "SELECT TD.transport_id,TD.appointment_time,TD.pickup_lat,TD.pickup_lng,TD.drop_lat,
return 0; TD.drop_lng,TD.vehicle_type,TD.status,TD.is_scheduled,DR.request_time,DR.status
} FROM transport_details AS TD
$sql = "SELECT * FROM customers WHERE phone LIKE '%".$data['phone']."' AND status IN (0,1)"; LEFT JOIN driver_request AS DR ON (TD.transport_id=DR.trip_id)
$isAvailable = $this->db->query($sql); LEFT JOIN drivers AS DRV ON (DR.driver_id=DR.driver_id)
$isAvailable = $isAvailable->num_rows(); WHERE TD.status IN ('1','3','7')
ORDER BY TD.transport_id DESC";
$ride_data = $this->db->query($sql);
if(empty($ride_data)){
return 0;
}
return $ride_data->result_array();
}
return $isAvailable; public function getAvailableDrivers($lat='',$lng='',$aTime=''){
if(empty($lat) || empty($lng) || empty($aTime)){
return;
}
$cTime = date('H:i');
$data = $this->db->query(
"SELECT d.driver_id,d.fcm_token,
(((acos(sin(($lat*pi()/180))*sin((lat_driver*pi()/180))+
cos(($lat*pi()/180))*cos((lat_driver*pi()/180))*
cos((($lng-lng_driver)*pi()/180))))*180/pi())*60*1.1515) as distance
FROM drivers AS d
WHERE d.status='1' AND d.online_start_time < '$cTime' AND d.online_end_time > '$cTime'
HAVING distance<15
ORDER BY distance DESC");
if(!empty($data) && !empty($driverData = $data->result_array())){
$key = '';
$startTime = strtotime(date('Y-m-d H:i:s')) - 1800;
$finishTime = strtotime(date('Y-m-d H:i:s')) + 1800;
foreach ($driverData AS $key => $driver) {
$driver_id = $driver['driver_id'];
$sql = "SELECT TD.driver_id
FROM transport_details AS TD
WHERE TD.status NOT IN ('4','5') AND TD.driver_id='$driver_id' AND
TD.appointment_time>$startTime AND TD.appointment_time<$finishTime";
$is_avail = $this->db->query($sql)->num_rows();
if($is_avail <= 0){
break;
}
}
return $driverData[$key];
} }
return;
}
} }
?> ?>
\ No newline at end of file
...@@ -424,7 +424,7 @@ class Webservices_driver_model extends CI_Model { ...@@ -424,7 +424,7 @@ class Webservices_driver_model extends CI_Model {
$rand = rand(1111, 99999); $rand = rand(1111, 99999);
$book_id = "$code"."$rand"; $book_id = $code."$rand";
$driverDetails = $this->db->query("SELECT vehicle_id FROM `drivers` WHERE driver_id = '$rs->driver_id'")->row(); $driverDetails = $this->db->query("SELECT vehicle_id FROM `drivers` WHERE driver_id = '$rs->driver_id'")->row();
...@@ -520,7 +520,7 @@ class Webservices_driver_model extends CI_Model { ...@@ -520,7 +520,7 @@ class Webservices_driver_model extends CI_Model {
public function status_driver($id) { public function status_driver($id) {
$data = $this->db->query("SELECT * FROM `transport_details` WHERE transport_id = '$id'")->row(); $data = $this->db->query("SELECT *, car_arrival AS trip_status FROM `transport_details` WHERE transport_id = '$id'")->row();
if ($data->status == 6 && $data->cash_collection == 1) { if ($data->status == 6 && $data->cash_collection == 1) {
...@@ -601,31 +601,32 @@ class Webservices_driver_model extends CI_Model { ...@@ -601,31 +601,32 @@ class Webservices_driver_model extends CI_Model {
// *********************** EMERGENCY RIDE HISTORY ******************** // *********************** EMERGENCY RIDE HISTORY ********************
public function history_trips_schedule($request) { public function history_trips_schedule($request) {
$query = $this->db->where('unique_id', $request['auth'])->get('driver_auth_table'); $query = $this->db->where('unique_id', $request['auth'])->get('driver_auth_table');
if ($query->num_rows() > 0) { if (!empty($query) && $query->num_rows() > 0 && !empty($rs = $query->row()) &&
!empty($driv_id = $rs->driver_id)) {
$rs = $query->row();
$data = "SELECT TRNS.transport_id AS id, CUST.customer_id AS customer_id,
$driv_id = $rs->driver_id; CONCAT(CUST.first_name,' ',CUST.last_name) AS customer_name,
TRNS.pickup_lng AS source_longitude, TRNS.pickup_lat AS source_latitude,
$data = "SELECT t.transport_id AS id, customers.customer_id AS customer_id, CONCAT(customers.first_name, TRNS.drop_location AS destination_location, TRNS.drop_lat AS destination_latitude,
' ',customers.last_name) AS customer_name, customers.profile_image AS customer_photo, t.pickup_location AS source_location, t.pickup_lng AS source_longitude, t.pickup_lat AS source_latitude, t.drop_location AS destination_location, t.drop_lat AS destination_latitude, t.drop_lng AS destination_longitude FROM transport_details AS t LEFT JOIN drivers AS d ON d.driver_id = t.driver_id LEFT JOIN customers ON t.customer_id = customers.customer_id WHERE t.driver_id = '$driv_id' AND request_type = 3 AND t.status = 6"; CUST.profile_image AS customer_photo, TRNS.pickup_location AS source_location,
TRNS.drop_lng AS destination_longitude, DR.status AS request_status,
TRNS.status AS ride_status,TRNS.trip_cost AS fare
FROM transport_details AS TRNS
INNER JOIN driver_request AS DR ON DR.trip_id = TRNS.transport_id
INNER JOIN customers AS CUST ON TRNS.customer_id = CUST.customer_id
WHERE DR.driver_id = '$driv_id' AND request_type = 3 AND
TRNS.status IN (1,3,4,5,6,8)";
$result = $this->db->query($data)->result_array(); $result = $this->db->query($data)->result_array();
foreach($result AS $key => $ride){
$result[0]['app_status'] = '1'; $result[$key]['type'] = 1;
if($ride['request_status'] == 1 && $ride['request_status'] == 6){
$data1 = "SELECT t.transport_id AS id, customers.customer_id AS customer_id, CONCAT(customers.first_name, $result[$key]['type'] = 2;
' ',customers.last_name) AS customer_name, customers.profile_image AS customer_photo, t.pickup_location AS source_location, t.pickup_lng AS source_longitude, t.pickup_lat AS source_latitude, t.drop_location AS destination_location, t.drop_lat AS destination_latitude, t.drop_lng AS destination_longitude FROM transport_details AS t LEFT JOIN drivers AS d ON d.driver_id = t.driver_id LEFT JOIN customers ON t.customer_id = customers.customer_id WHERE t.driver_id = '$driv_id' AND request_type = 3 AND t.status = 3"; }
$result1 = $this->db->query($data1)->result_array(); unset($result[$key]['request_status'],$result[$key]['ride_status']);
}
$result1[0]['app_status'] = '2'; return $result;
$resultArray = array_merge($result, $result1);
return $resultArray;
} else { } else {
......
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