Commit 93fafa8d by Jansa Jose

changes in api

parent f2a18112
......@@ -112,14 +112,12 @@
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$respArr = array('status'=>'error','message'=>'Something went wrong.');
if(empty($postData)){
echo json_encode($respArr);exit;
}
$err = 0;
$msg = '';
if(!isset($postData['user_email']) || empty($postData['user_email'])){
$err = 1;
$msg = 'Provide a valid Email';
......@@ -157,7 +155,6 @@
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$respArr = array('status'=>'error','message'=>'Something went wrong.');
if(empty($postData)){
echo json_encode($respArr);exit;
......@@ -239,7 +236,6 @@
public function upload_profilePic(){
header('Content-type: application/json');
$postData = $_POST;
$respArr = array('status'=>'error','message'=>'Something went wrong.');
if(!isset($postData['user_id']) || empty($postData['user_id'])){
$respArr['message'] = 'User Id is Required';
......@@ -266,7 +262,6 @@
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$respArr = array('status'=>'error','message'=>'Something went wrong.');
if(!isset($postData['user_phonenumber']) || empty($postData['user_phonenumber'])){
$respArr['message'] = 'Phone Number is Required';
......@@ -283,7 +278,6 @@
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$respArr = array('status'=>'error','message'=>'Something went wrong.');
if(!isset($postData['user_id']) || empty($postData['user_id'])){
$respArr['message'] = 'User Id is Required';
......@@ -300,7 +294,6 @@
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$respArr = array('status'=>'error','message'=>'Something went wrong.');
if(!isset($postData['user_id']) || empty($postData['user_id'])){
$respArr['message'] = 'User Id is Required';
......@@ -320,7 +313,6 @@
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$respArr = array('status'=>'0','message'=>'Something went wrong.');
if(empty($postData) || !isset($postData['user_id']) || empty($postData['user_id']) || !isset($postData['car_vinNumber']) || empty($postData['car_vinNumber'])){
echo json_encode($respArr);exit;
......@@ -463,7 +455,6 @@
public function road_assistanceList(){
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$respArr = array('status'=>'error','message'=>'Something went wrong.');
if(empty($postData)){
echo json_encode($respArr);exit;
......@@ -482,7 +473,6 @@
public function road_assistanceDetail(){
$postData = $_GET;
$respArr = array('status'=>'error','message'=>'Something went wrong.');
if(empty($postData)){
echo json_encode($respArr);exit;
......@@ -739,7 +729,6 @@
if(empty($postData)){
echo json_encode($respArr);exit;
}
$err = 0;
$msg = '';
if(!isset($postData['user_id']) || empty($postData['user_id'])){
......
......@@ -9,7 +9,6 @@ class Webservice_model extends CI_Model {
if(empty($postData))
return 0;
if(isset($postData['user_email']) && !empty($postData['user_email'])){
// $this->db->join('customer AS CUST','CUST.cust_id = USR.profile_id');
$emailChk = $this->db->get_where('users AS USR',array('USR.username'=>$postData['user_email'], 'USR.status !='=>'2','USR.user_type'=>'1'));
if(!empty($emailChk) && $emailChk->num_rows() > 0){
return 2;
......@@ -28,17 +27,12 @@ class Webservice_model extends CI_Model {
'phone_no'=>$postData['user_phonenumber'],
'device_id'=>$postData['device_id'],
'address'=>$postData['user_address'],
// 'country'=>$postData['user_country'],
// 'region'=>$postData['user_region'],
// 'city'=>$postData['user_city'],
'area'=>$postData['user_area'],
'lat'=>$postData['user_lat'],
'lng'=>$postData['user_lng'],
//'password'=>$postData['user_password'],
);
$status = $this->db->insert('customer',$insert_array);
$last_id = $this->db->insert_id();
$status = $this->db->insert('users',array('user_type'=>'1','profile_id'=>$last_id,'username'=>$postData['user_email'],'phone_no'=>$postData['user_phonenumber'],'password'=>$postData['user_password'],'status'=>'1'));
return ($status)?1:0;
}
......@@ -48,18 +42,13 @@ class Webservice_model extends CI_Model {
if(empty($userLogData)){
return $respArr;
}
//$this->db->join('customer AS CUST','CUST.cust_id = USR.profile_id');
$result = $this->db->get_where('users AS USR',array('USR.username'=>$userLogData['user_email'], 'USR.status'=>'1'));
if(empty($result) || $result->num_rows() < 1 || empty($custData = $result->row())){
$respArr['message'] = "Invalid Email Address";
return $respArr;
}
//$this->db->join('customer AS CUST','CUST.cust_id = USR.profile_id');
$result = $this->db->get_where('users AS USR',array('USR.username'=>$userLogData['user_email'], 'USR.status'=>'1','USR.user_type'=>'1','USR.password'=>$userLogData['user_password']));
$respArr['message'] = "Invalid Password";
if(!empty($result) && $result->num_rows() == 1 && !empty($custData = $result->row())){
$respArr['data'] = $custData;
$respArr['status'] = 1;
......@@ -89,7 +78,6 @@ class Webservice_model extends CI_Model {
if(empty($postData))
return 0;
if(isset($postData['user_email']) && !empty($postData['user_email'])){
//$this->db->join('customer AS CUST','CUST.cust_id = USR.profile_id');
$emailChk = $this->db->get_where('users AS USR',array('USR.username'=>$postData['user_email'], 'USR.status !='=>'2','USR.user_type'=>'1','USR.profile_id !='=>$postData['user_id']));
if(!empty($emailChk) && $emailChk->num_rows() > 0){
return 2;
......@@ -380,7 +368,9 @@ class Webservice_model extends CI_Model {
public function user_requestService($postData = array()){
$respArr = array('status'=>'error');
$squence = str_pad(rand(1111,9999),4,0,STR_PAD_LEFT);
$insert_array = array(
'request_code'=>'BKRQ'.date('ymd').$squence,
'cust_id'=>$postData['user_id'],
'subservice_ids'=>implode(',',$postData['subservice_id']),
'booking_date'=>$postData['booking_date'],
......@@ -415,8 +405,8 @@ class Webservice_model extends CI_Model {
public function book_garage($postData = array()){
$respArr = array('status'=>'error');
//$squence = str_pad(rand(1111,9999),4,0,STR_PAD_LEFT);'booking_id'=>'BKGID'.date('ymd').$squence,
if($this->db->update('garage_request',array('resp_id'=>$postData['resp_id']),array('id'=>$postData['req_id']))){
if($this->db->update('garage_request',array('resp_id'=>$postData['resp_id'],'status'=>'3'),array('id'=>$postData['req_id']))){
$this->db->update('garage_response',array('status'=>'1'),array('id'=>$postData['resp_id']));
$respArr['status'] = "success";
$respArr['message'] = "Garage Booked Successfully";
}
......
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