Commit bf11c66f by Jansa Jose

Merge branch 'master' into 'local_production'

get booked service See merge request !89
parents 5a7621b0 0c001580
...@@ -1110,6 +1110,42 @@ ...@@ -1110,6 +1110,42 @@
echo json_encode($respData);exit; echo json_encode($respData);exit;
} }
public function booked_service_details(){
header('Content-type: application/json');
$headers = apache_request_headers();
$postData = $_GET;
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
if(empty($postData)){
$respArr = array('status'=>'error','message'=>'All Field is Required');
echo json_encode($respArr);exit;
}
$err = 0;
if(!isset($postData['booking_id']) || empty($postData['booking_id'])){
$err = 1;
$msg = 'Booking Id is Required';
}
if($err == 1){
$respArr['message'] = $msg;
echo json_encode($respArr);exit;
}
$respData = $this->Webservice_model->getBookedService($postData['booking_id'],1);
echo json_encode($respData);exit;
}
//Get Booking Summary //Get Booking Summary
public function get_booking_summary(){ public function get_booking_summary(){
......
...@@ -160,16 +160,26 @@ class Webservice_model extends CI_Model { ...@@ -160,16 +160,26 @@ class Webservice_model extends CI_Model {
return $respArr; return $respArr;
} }
public function getBookedService($id = ''){ public function getBookedService($id = '',$type=0){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.'); $respArr = array('status'=>'error','message'=>'Something Went Wrong.');
if(empty($id)){ if(empty($id)){
return $respArr; return $respArr;
} }
$this->db->select('booking_id as id,scheduled_date as booked_date,scheduled_time as time,customer_vehicle.vehicle_data,customer_vehicle.customer_veh_id as vehicle_id,customer_vehicle.customer_veh_id as year,customer_vehicle.customer_veh_id as vehcle_make,customer_vehicle.customer_veh_id as vehicle_type,bookings.mileage, $where = ($type == 1)?array('bookings.booking_id'=>$id):array('bookings.customer_id'=>$id);
bookings.service_type as is_emergency,bookings.status as service_status,bookings.issues_selected,bookings.custom_issue_data'); $bookDetails = '';
if($type == 1){
$bookDetails = ",mechanic.location,mechanic.location_lat,mechanic.location_lng";
}
$this->db->select("bookings.booking_id as id,bookings.scheduled_date as booked_date,bookings.scheduled_time as time,customer_vehicle.vehicle_data,customer_vehicle.customer_veh_id as vehicle_id,customer_vehicle.customer_veh_id as year,customer_vehicle.customer_veh_id as vehcle_make,customer_vehicle.customer_veh_id as vehicle_type,bookings.mileage,
bookings.service_type as is_emergency,bookings.status as service_status,bookings.issues_selected,bookings.custom_issue_data".$bookDetails);
$this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id'); $this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id');
if($type == 1){
$this->db->join("mechanic_booking","mechanic_booking.booking_id = bookings.booking_id AND mechanic_booking.status='1'");
$this->db->join("mechanic","mechanic_booking.mechanic_id = mechanic.mechanic_id");
}
$this->db->where('scheduled_date >',date('Y-m-d h:i')); $this->db->where('scheduled_date >',date('Y-m-d h:i'));
$bookData = $this->db->get_where('bookings',array('bookings.customer_id'=>$id))->result_array(); $bookData = $this->db->get_where('bookings',$where)->result_array();
//pr($this->db->last_query());
$respArr['status'] = 'success'; $respArr['status'] = 'success';
$respArr['message'] = 'success'; $respArr['message'] = 'success';
if(!empty($bookData) && (count($bookData) > 0)){ if(!empty($bookData) && (count($bookData) > 0)){
...@@ -182,6 +192,9 @@ class Webservice_model extends CI_Model { ...@@ -182,6 +192,9 @@ class Webservice_model extends CI_Model {
$bookData[$key]['service_description'] = !empty($value['custom_issue_data'])?json_decode($value['custom_issue_data'])->optionlaDescription:''; $bookData[$key]['service_description'] = !empty($value['custom_issue_data'])?json_decode($value['custom_issue_data'])->optionlaDescription:'';
unset($bookData[$key]['vehicle_data'],$bookData[$key]['issues_selected'],$bookData[$key]['custom_issue_data']); unset($bookData[$key]['vehicle_data'],$bookData[$key]['issues_selected'],$bookData[$key]['custom_issue_data']);
} }
if($type == 1){
$respArr['data'] = $bookData[0];
}
$respArr['data'] = $bookData; $respArr['data'] = $bookData;
}else{ }else{
$respArr['data'] = []; $respArr['data'] = [];
......
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