Commit 09172077 by Jansa Jose

add location for mechanic

parent 19016293
...@@ -286,5 +286,34 @@ ...@@ -286,5 +286,34 @@
$respArr = $this->Webservice_mechanic_model->update_profile_status($postData); $respArr = $this->Webservice_mechanic_model->update_profile_status($postData);
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
public function add_location(){
header('Content-type: application/json');
$headers = apache_request_headers();
if(!isset($headers['auth']) || empty($headers['auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['auth']);
if($authRes['status'] == 'error'){
echo json_encode($respArr);exit;
}
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
if(!isset($postData['lat']) && empty($postData['lat'])){
$respArr['message'] = "Latitude is Required";
echo json_encode($respArr) ;exit;
}else if(!isset($postData['lng']) && empty($postData['lng'])){
$respArr['message'] = "Longitude is Required";
echo json_encode($respArr) ;exit;
}
$postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$respArr = $this->Webservice_mechanic_model->add_location($postData);
echo json_encode($respArr);exit;
}
} }
?> ?>
...@@ -211,5 +211,17 @@ public function update_profile_status($postData = array()){ ...@@ -211,5 +211,17 @@ public function update_profile_status($postData = array()){
} }
return $respArr; return $respArr;
} }
public function add_location($postData){
$respArr = array('status'=>'error');
if(empty($postData)){
return $respArr;
}
if($this->db->update('mechanic',array('location_lat'=>$postData['location_lat'],'location_lng'=>$postData['location_lng']),array('mechanic_id'=>$postData['mechanic_id']))){
$respArr['status'] = "success";
$respArr['message'] = "Location Updated Successfully";
}
return $respArr;
}
} }
?> ?>
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