Commit ac54303a by Tobin

dc

parent a3a0b0a1
...@@ -212,7 +212,7 @@ class Webservices extends CI_Controller { ...@@ -212,7 +212,7 @@ class Webservices extends CI_Controller {
$this->load->model('Mechanic_model'); $this->load->model('Mechanic_model');
$respArr = array('status'=>'0','message'=>'Something went wrong.'); $respArr = array('status'=>'0','message'=>'Something went wrong.');
pr($postData);
if(empty($postData) || !isset($postData['pickup_data']) || !isset($postData['sub_issues']) || if(empty($postData) || !isset($postData['pickup_data']) || !isset($postData['sub_issues']) ||
empty($postData['pickup_data']) || empty($postData['sub_issues']) ){ empty($postData['pickup_data']) || empty($postData['sub_issues']) ){
echo json_encode($respArr); exit; echo json_encode($respArr); exit;
...@@ -320,7 +320,7 @@ class Webservices extends CI_Controller { ...@@ -320,7 +320,7 @@ class Webservices extends CI_Controller {
if($custResp == '1'){ if($custResp == '1'){
$respArr['status'] = '1'; $respArr['status'] = '1';
$respArr['message'] = 'Profile successfully updated'; $respArr['message'] = 'Profile successfully updated';
$respArr['profile_image'] = $postData['profile_image']; $respArr['profile_image'] = (isset($postData['profile_image']) && !empty($postData['profile_image']))?$postData['profile_image']:'';
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} else if($custResp == '2'){ } else if($custResp == '2'){
$respArr['status'] = '2'; $respArr['status'] = '2';
......
...@@ -6,7 +6,12 @@ class Booking_model extends CI_Model { ...@@ -6,7 +6,12 @@ class Booking_model extends CI_Model {
} }
public function scheduleBooking($postData = array()){ public function scheduleBooking($postData = array()){
if(empty($postData)){ if(empty($postData) ||
!isset($postData['customer_id']) || empty($postData['customer_id']) ||
!isset($postData['pickup_data']) || empty($postData['pickup_data']) ||
!isset($postData['vechile_info']) || empty($postData['vechile_info']) ||
!isset($postData['mechanic_id']) || empty($postData['mechanic_id']) ||
!isset($postData['selected_issues']) || empty($postData['selected_issues'])){
return 0; return 0;
} }
$vehData = $postData['vechile_info']; $vehData = $postData['vechile_info'];
...@@ -14,16 +19,13 @@ class Booking_model extends CI_Model { ...@@ -14,16 +19,13 @@ class Booking_model extends CI_Model {
$vehJson = array('vehicle' => $car_name, $vehJson = array('vehicle' => $car_name,
'attributes' => 'attributes' =>
array( array('Year' => $vehData['modelYear'],
'Year' => $vehData['modelYear'],
'Make' => $vehData['maker'], 'Make' => $vehData['maker'],
'Trim' => $vehData['trim'], 'Trim' => $vehData['trim'],
'Model' => $vehData['modelName'], 'Model' => $vehData['modelName'],
'Engine' => $vehData['emgine'] 'Engine' => $vehData['emgine']));
));
$insert_array = array( $insert_array = array('customer_id' => $postData['customer_id'],
'customer_id' => $postData['customer_id'],
'car_name' => $car_name, 'car_name' => $car_name,
'car_model' => $vehData['modelName'], 'car_model' => $vehData['modelName'],
'car_maker' => $vehData['maker'], 'car_maker' => $vehData['maker'],
...@@ -34,15 +36,23 @@ class Booking_model extends CI_Model { ...@@ -34,15 +36,23 @@ class Booking_model extends CI_Model {
'car_model_year'=> $vehData['modelYear'], 'car_model_year'=> $vehData['modelYear'],
'status' => '3'); 'status' => '3');
$selected_issues = array();
foreach($postData['selected_issues'] AS $selIssue){
$selected_issues[] = array('issue' =>$selIssue['issue'],
'issue_id' =>$selIssue['issue_id'],
'sub_issue_id' =>$selIssue['sub_issue_id'],
'issue_category' =>$selIssue['issue_category']);
}
if($this->db->insert('customer_vehicle',$insert_array)){ if($this->db->insert('customer_vehicle',$insert_array)){
$last_id = $this->db->insert_id(); $last_id = $this->db->insert_id();
$book_data = array( $book_data = array('customer_veh_id' => $last_id,
'customer_veh_id' => $last_id,
'customer_id' => $postData['customer_id'], 'customer_id' => $postData['customer_id'],
'mechanic_id' => $postData['mechanic_id'], 'mechanic_id' => $postData['mechanic_id'],
'scheduled_date' => $postData['schedule_date']['date'], 'scheduled_date' => $postData['schedule_date']['date'],
'scheduled_time' => $postData['schedule_date']['time'], 'scheduled_time' => $postData['schedule_date']['time'],
'issues_selected' => json_encode($selected_issues),
'mileage' => $vehData['milage'], 'mileage' => $vehData['milage'],
'status' => '0'); 'status' => '0');
......
...@@ -133,13 +133,14 @@ class Mechanic_model extends CI_Model { ...@@ -133,13 +133,14 @@ class Mechanic_model extends CI_Model {
return $status; return $status;
} }
function getNearByMechanics($pickLocData = array()){ function getNearByMechanics($location_data = array(),$sub_issues = array()){
if(empty($pickLocData)){ if(empty($location_data) || empty($sub_issues)){
return 0; return 0;
} }
$current_lat = $pickLocData['pickup_lat']; $current_lat = $location_data['pickup_lat'];
$current_lng = $pickLocData['pickup_lng']; $current_lng = $location_data['pickup_lng'];
$issue_cat_id = implode(',',$sub_issues);
$sql = "SELECT AU.display_name,AU.profile_image,ME.*,MS.shop_name,MS.address AS shop_address, $sql = "SELECT AU.display_name,AU.profile_image,ME.*,MS.shop_name,MS.address AS shop_address,
MS.phone AS shop_phone,MS.email_id AS shop_email_id, MS.phone AS shop_phone,MS.email_id AS shop_email_id,
...@@ -157,6 +158,7 @@ class Mechanic_model extends CI_Model { ...@@ -157,6 +158,7 @@ class Mechanic_model extends CI_Model {
return 0; return 0;
} }
$estimate = 0;
$mechDataArr = array(); $mechDataArr = array();
foreach($mechData AS $index => $data){ foreach($mechData AS $index => $data){
if(empty($data['start_time']) || empty($data['end_time'])){ if(empty($data['start_time']) || empty($data['end_time'])){
...@@ -171,6 +173,35 @@ class Mechanic_model extends CI_Model { ...@@ -171,6 +173,35 @@ class Mechanic_model extends CI_Model {
$scheduleTiming[] = date('h:i A',$schTime); $scheduleTiming[] = date('h:i A',$schTime);
} }
} }
$mechanic_id = $data['mechanic_id'];
$sql = "SELECT ISS.*, IC.*, MI.*
FROM issues_category AS IC
INNER JOIN issues AS ISS ON (IC.issue_id=ISS.issue_id)
LEFT JOIN mechanic_issues AS MI ON (MI.issue_cat_id=IC.issue_cat_id AND
MI.mechanic_id='$mechanic_id' AND MI.status='1')
WHERE ISS.status='1' AND IC.status='1' AND IC.issue_cat_id IN ($issue_cat_id)";
$subIssData = $this->db->query($sql);
$sIssueData = array();
if(!empty($subIssData) && !empty($subIssData = $subIssData->result_array())){
$sIssueData = $subIssData;
}
$estimate = 0;
foreach($sIssueData AS $sIndex => $sIssue){
if(!empty($sIssue['custom_service_fee'])){
$estimate += $sIssue['custom_service_fee'];
$sIssueData[$sIndex]['service_fee'] = $sIssue['custom_service_fee'];
} else {
$estimate += $sIssue['default_service_fee'];
$sIssueData[$sIndex]['service_fee'] = $sIssue['default_service_fee'];
}
}
$mechData[$index]['estimate'] = $estimate;
$mechData[$index]['sub_issues'] = $sIssueData;
$mechData[$index]['scheduleTiming'] = $scheduleTiming; $mechData[$index]['scheduleTiming'] = $scheduleTiming;
} }
return $mechData; return $mechData;
......
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