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
...@@ -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