Commit 00a7f211 by Jansa Jose

Merge branch 'master' into 'local_production'

Master See merge request !208
parents d35c425a 4489a059
...@@ -995,6 +995,16 @@ ...@@ -995,6 +995,16 @@
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$respData = $this->Webservice_model->book_service($postData); $respData = $this->Webservice_model->book_service($postData);
if((isset($postData['is_emergency']) && !empty($postData['is_emergency']))){
if($respData['status'] == 'success'){
$fcm_data['title'] = 'Carfixxers';
$fcm_data['message'] = "Emergency booking";
$fcm_data['booking_id'] = $postData['booking_id'];
$fcm_data['device_id'] = $respData['data']['device_id'];
$fcm_data['service_type'] = $respData['data']['service_type'];
$this->push_sent_cancel($fcm_data);
}
}
echo json_encode($respData);exit; echo json_encode($respData);exit;
} }
//Allocated service details //Allocated service details
...@@ -2776,6 +2786,134 @@ ...@@ -2776,6 +2786,134 @@
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
// public function car_model_list(){
// 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_model->get_customer_authtoken($headers['auth']);
// if($authRes['status'] == 'error'){
// echo json_encode($authRes);exit;
// }
// $post = file_get_contents("php://input");
// $postData = json_decode($post,true);
// if(empty($postData)){
// $respArr = array('status'=>0,'error'=>'901','message'=>'All Field is Required');
// echo json_encode($respArr);exit;
// }
// $respArr = $this->Webservice_model->getVehicleModel($postData);
// echo json_encode($respArr);exit;
// }
public function trim_list(){
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_model->get_customer_authtoken($headers['auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
if(empty($postData)){
$respArr = array('status'=>0,'error'=>'901','message'=>'All Field is Required');
echo json_encode($respArr);exit;
}
$respArr = $this->Webservice_model->getVehicleTrim($postData);
echo json_encode($respArr);exit;
}
public function social_login(){
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$this->load->model('Customer_model');
$respArr = array('status'=>'error','message'=>'Something went wrong.');
if(empty($postData)){
echo json_encode($respArr);exit;
}
$err = 0;
$msg = '';
if(!isset($postData['email']) || empty($postData['email'])){
$err = 1;
$msg = 'Provide a valid Email ID';
}
else if(!isset($postData['first_name']) || empty($postData['first_name'])){
$err = 1;
$msg = 'Provide valid Name';
}
else if(!isset($postData['registration_type'])){
$err = 1;
$msg = 'Provide Social Type';
}
if(!isset($postData['isRegistration'])){
$err = 1;
$msg = 'Provide Registartion type';
}
if($postData['isRegistration'] == '1'){
if(!isset($postData['data']['phone']) || empty($postData['data']['phone'])){
$err = 1;
$msg = 'Provide a Phone Number';
}
else if(!isset($postData['data']['country_code']) || empty($postData['data']['country_code'])){
$err = 1;
$msg = 'Provide a Country code';
}
}
if($err == 1){
$respArr['message'] = $msg;
echo json_encode($respArr);exit;
}
$postData['profile_image'] = NULL;
$postData['phone'] = (isset($postData['data']['phone']) && !empty($postData['data']['phone']))?$postData['data']['phone']:'';
$postData['country_code'] = (isset($postData['data']['country_code']) && !empty($postData['data']['country_code']))?$postData['data']['country_code']:'';
if(isset($postData['data']['profileImg']) && !empty($postData['data']['profileImg'])){
$imageData = file_get_contents($postData['data']['profileImg']);
$userlImg = 'assets/uploads/services/userImg_'.time().'.jpg';
file_put_contents($userlImg, $imageData);
$postData['data']['profile_image'] = $userlImg;
}
if(isset($postData['data']) && !empty($postData['data'])){
unset($postData['data']);
}
if($postData['isRegistration'] == '1'){
unset($postData['isRegistration']);
$custReg = $this->Customer_model->createCustomer($postData,'');
if(empty($custReg)){
echo json_encode($respArr);exit;
}
if($custReg == '1' || $custReg == '2'){
$respArr = $this->getUserDetails($postData);
}
}else{
unset($postData['isRegistration']);
$respArr = $this->getUserDetails($postData);
}
echo json_encode($respArr);exit;
}
public function getUserDetails($postData){
$custResp = $this->Webservice_model->checkSocialCustomerLogin($postData);
if(empty($custResp) || !isset($custResp['status']) || empty($custResp['status'])){
return $respArr ;
}
if($custResp['status'] == '1'){
$respArr['data'] = $custResp['data'];
$respArr['status'] = '1';
$respArr['message'] = 'Success';
return $respArr;
}
}
public function crone_job(){ public function crone_job(){
$result = $this->db->get_where('transaction',array('status'=>'2')); $result = $this->db->get_where('transaction',array('status'=>'2'));
if(!empty($result) && $result->num_rows() >= 1 && !empty($result = $result->result_array())){ if(!empty($result) && $result->num_rows() >= 1 && !empty($result = $result->result_array())){
......
...@@ -93,6 +93,7 @@ public function getBookedService($postData = array(),$start = '',$per_page = '', ...@@ -93,6 +93,7 @@ public function getBookedService($postData = array(),$start = '',$per_page = '',
if($start != 0 || $per_page != 0){ if($start != 0 || $per_page != 0){
$this->db->limit($per_page,$start); $this->db->limit($per_page,$start);
} }
$this->db->group_by('BUK.booking_id');
$this->db->order_by('BUK.booking_id','DESC'); $this->db->order_by('BUK.booking_id','DESC');
$bookData = $this->db->get(); $bookData = $this->db->get();
if(!empty($bookData) && $bookData->num_rows() > 0){ if(!empty($bookData) && $bookData->num_rows() > 0){
...@@ -147,6 +148,7 @@ public function getBookedService($postData = array(),$start = '',$per_page = '', ...@@ -147,6 +148,7 @@ public function getBookedService($postData = array(),$start = '',$per_page = '',
public function mechanic_logout($mechanic_id){ public function mechanic_logout($mechanic_id){
$respArr = array('status'=>'error'); $respArr = array('status'=>'error');
$status = $this->db->delete('authtable_mechanic',array('mechanic_id'=>$mechanic_id)); $status = $this->db->delete('authtable_mechanic',array('mechanic_id'=>$mechanic_id));
$this->db->update('mechanic',array('device_id'=>''),array('mechanic_id'=>$mechanic_id));
if($status){ if($status){
$respArr['status'] = "success"; $respArr['status'] = "success";
$respArr['message'] = "Logged Out Successfully"; $respArr['message'] = "Logged Out Successfully";
......
...@@ -46,6 +46,31 @@ class Webservice_model extends CI_Model { ...@@ -46,6 +46,31 @@ class Webservice_model extends CI_Model {
return $respArr; return $respArr;
} }
public function checkSocialCustomerLogin($userLogData){
$respArr = array('status'=>0);
if(empty($userLogData)){
return $returnStatus;
}
$result = $this->db->get_where('customers',array('email'=>$userLogData['email'],'status'=>'1'));
if(empty($result) || $result->num_rows() < 1 || empty($custData = $result->row())){
$respArr['status'] = 2;
return $respArr;
}
$this->db->select("customer_id as id,is_otp_verified,phone as phone_number,TRIM(CONCAT(first_name,' ' ,IFNULL(last_name,''))) as user_name");
$result = $this->db->get_where('customers',array('email'=>$userLogData['email'],
'status'=>'1'));
$respArr['status'] = 3;
if(!empty($result) && $result->num_rows() == 1 && !empty($custData = $result->row())){
$authdata = $this->insert_auth($custData->id);
if($authdata){
$custData->auth_token = $authdata;
$respArr['data'] = $custData;
$respArr['status'] = 1;
}
}
return $respArr;
}
public function createServiceProvider($provider_data = array()){ public function createServiceProvider($provider_data = array()){
if(empty($provider_data)) if(empty($provider_data))
return 0; return 0;
...@@ -357,13 +382,17 @@ class Webservice_model extends CI_Model { ...@@ -357,13 +382,17 @@ class Webservice_model extends CI_Model {
if($this->db->update('bookings',$insert_array,array('booking_id'=>$postData['booking_id']))){ if($this->db->update('bookings',$insert_array,array('booking_id'=>$postData['booking_id']))){
$this->db->insert("mechanic_booking",array('booking_id'=>$postData['booking_id'],'mechanic_id'=>$postData['mechanic_id'],'amount'=>$cost,'status'=>'0')); $this->db->insert("mechanic_booking",array('booking_id'=>$postData['booking_id'],'mechanic_id'=>$postData['mechanic_id'],'amount'=>$cost,'status'=>'0'));
$this->db->select("bookings.scheduled_time,bookings.scheduled_date,customer_vehicle.car_model as vehicle_model,customer_vehicle.car_maker as vehicle_make,customer_vehicle.car_model_year as vehicle_year,customer_vehicle.vehicle_data,TRIM(concat(mechanic.first_name,' ',IFNULL(mechanic.last_name,''))) as mechanic_name,mechanic_shop.shop_name as mechanic_shop,mechanic.address,mechanic.phone,admin_users.profile_image as image,bookings.mileage,bookings.issues_selected,bookings.customer_id"); $this->db->select("bookings.scheduled_time,bookings.scheduled_date,customer_vehicle.car_model as vehicle_model,customer_vehicle.car_maker as vehicle_make,customer_vehicle.car_model_year as vehicle_year,customer_vehicle.vehicle_data,TRIM(concat(mechanic.first_name,' ',IFNULL(mechanic.last_name,''))) as mechanic_name,bookings.service_type,mechanic_shop.shop_name as mechanic_shop,mechanic.address,mechanic.phone,mechanic.device_id,admin_users.profile_image as image,bookings.mileage,bookings.issues_selected,bookings.customer_id");
$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');
$this->db->join("mechanic_booking","mechanic_booking.booking_id = bookings.booking_id AND mechanic_booking.mechanic_id =".$postData['mechanic_id'],'left'); $this->db->join("mechanic_booking","mechanic_booking.booking_id = bookings.booking_id AND mechanic_booking.mechanic_id =".$postData['mechanic_id'],'left');
$this->db->join('mechanic','mechanic_booking.mechanic_id = mechanic.mechanic_id'); $this->db->join('mechanic','mechanic_booking.mechanic_id = mechanic.mechanic_id');
$this->db->join('admin_users','admin_users.id = mechanic.mechanic_id'); $this->db->join('admin_users','admin_users.id = mechanic.mechanic_id');
$this->db->join('mechanic_shop','mechanic_shop.shop_id = mechanic.shop_id','left'); $this->db->join('mechanic_shop','mechanic_shop.shop_id = mechanic.shop_id','left');
$this->db->group_by('bookings.booking_id');
$mech_data = $this->db->get_where('bookings',array('bookings.booking_id'=>$postData['booking_id'])); $mech_data = $this->db->get_where('bookings',array('bookings.booking_id'=>$postData['booking_id']));
// pr($this->db->last_query());
if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){ if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){
$this->db->insert('transaction',array('customer_id'=>$mechanic_data['customer_id'],'booking_id'=>$postData['booking_id'],'payment_for'=>'1','datetime'=>date('Y-m-d h:i:s'),'amount'=>$cost)); $this->db->insert('transaction',array('customer_id'=>$mechanic_data['customer_id'],'booking_id'=>$postData['booking_id'],'payment_for'=>'1','datetime'=>date('Y-m-d h:i:s'),'amount'=>$cost));
...@@ -1380,6 +1409,7 @@ class Webservice_model extends CI_Model { ...@@ -1380,6 +1409,7 @@ class Webservice_model extends CI_Model {
$respArr = array('status'=>'error'); $respArr = array('status'=>'error');
if(!isset($postData['vehBrand_id']) && empty($postData['vehBrand_id'])){ if(!isset($postData['vehBrand_id']) && empty($postData['vehBrand_id'])){
$respArr['message'] = 'Vehicle Brand Id is Required' ; $respArr['message'] = 'Vehicle Brand Id is Required' ;
return $respArr;
} }
// if(!isset($postData['vehiYear']) && empty($postData['vehiYear'])){ // if(!isset($postData['vehiYear']) && empty($postData['vehiYear'])){
// $respArr['message'] = 'Vehicle Year is Required' ; // $respArr['message'] = 'Vehicle Year is Required' ;
...@@ -1421,12 +1451,15 @@ class Webservice_model extends CI_Model { ...@@ -1421,12 +1451,15 @@ class Webservice_model extends CI_Model {
$respArr = array('status'=>'error'); $respArr = array('status'=>'error');
if(!isset($postData['vehBrand_id']) && empty($postData['vehBrand_id'])){ if(!isset($postData['vehBrand_id']) && empty($postData['vehBrand_id'])){
$respArr['message'] = 'Vehicle Brand Id is Required' ; $respArr['message'] = 'Vehicle Brand Id is Required' ;
return $respArr;
} }
else if(!isset($postData['vehiYear']) && empty($postData['vehiYear'])){ else if(!isset($postData['vehiYear']) && empty($postData['vehiYear'])){
$respArr['message'] = 'Vehicle Year is Required' ; $respArr['message'] = 'Vehicle Year is Required' ;
return $respArr;
} }
else if(!isset($postData['vehiModel']) && empty($postData['vehiModel'])){ else if(!isset($postData['vehiModel']) && empty($postData['vehiModel'])){
$respArr['message'] = 'Vehicle Model is Required' ; $respArr['message'] = 'Vehicle Model is Required' ;
return $respArr;
} }
$this->db->select("VEH.model_id,VEH.trim"); $this->db->select("VEH.model_id,VEH.trim");
$this->db->join('vehicle_models AS VEHM','VEHM.veh_model_id = VEH.model_id'); $this->db->join('vehicle_models AS VEHM','VEHM.veh_model_id = VEH.model_id');
...@@ -1451,6 +1484,7 @@ class Webservice_model extends CI_Model { ...@@ -1451,6 +1484,7 @@ class Webservice_model extends CI_Model {
$respArr = array('status'=>'error'); $respArr = array('status'=>'error');
if(empty($postData['data'])){ if(empty($postData['data'])){
$respArr['message'] = 'All Field is Required' ; $respArr['message'] = 'All Field is Required' ;
return $respArr;
} }
$result=$this->db->get_where('customers',array('email'=>$postData['data']['email'],'status'=>'1')); $result=$this->db->get_where('customers',array('email'=>$postData['data']['email'],'status'=>'1'));
if(!empty($result) && $result->num_rows() == 1 && !empty($custData = $result->row())){ if(!empty($result) && $result->num_rows() == 1 && !empty($custData = $result->row())){
...@@ -1482,6 +1516,7 @@ class Webservice_model extends CI_Model { ...@@ -1482,6 +1516,7 @@ class Webservice_model extends CI_Model {
$respArr = array('status'=>'error'); $respArr = array('status'=>'error');
if(empty($cust_id = $postData['customer_id'])){ if(empty($cust_id = $postData['customer_id'])){
$respArr['message'] = 'Customer Id is Required' ; $respArr['message'] = 'Customer Id is Required' ;
return $respArr;
} }
$new = array(); $new = array();
$result = $this->db->get_where('customer_vehicle', $result = $this->db->get_where('customer_vehicle',
...@@ -1535,6 +1570,7 @@ class Webservice_model extends CI_Model { ...@@ -1535,6 +1570,7 @@ class Webservice_model extends CI_Model {
$respArr = array('status'=>'error'); $respArr = array('status'=>'error');
if(empty($cust_id = $postData['car_id'])){ if(empty($cust_id = $postData['car_id'])){
$respArr['message'] = 'Car Id is Required' ; $respArr['message'] = 'Car Id is Required' ;
return $respArr;
} }
$this->db->select('vehicle_data'); $this->db->select('vehicle_data');
$carData = $this->db->get_where('customer_vehicle',array('customer_veh_id'=>$postData['car_id']))->row(); $carData = $this->db->get_where('customer_vehicle',array('customer_veh_id'=>$postData['car_id']))->row();
......
...@@ -875,8 +875,12 @@ function customQuote(thisObj){ ...@@ -875,8 +875,12 @@ function customQuote(thisObj){
var html ='', var html ='',
imgCount = 0, imgCount = 0,
issueHtml = '', issueHtml = '',
optionalHtml = '', optionalHtml = '';
issues_selected = jQuery.parseJSON(booking_data['issues_selected']);
var issues_selected = '';
if(booking_data['issues_selected'] != '' && booking_data['issues_selected'] != null && booking_data['issues_selected'] != undefined && booking_data['issues_selected'] != 'null' && booking_data['issues_selected'] != 'undefined' && booking_data['issues_selected'] != ' -- '){
issues_selected = jQuery.parseJSON(booking_data['issues_selected']);
}
if(issues_selected != ''){ if(issues_selected != ''){
var comma = ''; var comma = '';
...@@ -1043,9 +1047,17 @@ function viewCustomQuote(thisObj){ ...@@ -1043,9 +1047,17 @@ function viewCustomQuote(thisObj){
var html ='', var html ='',
imgCount = 0, imgCount = 0,
issueHtml = '', issueHtml = '',
optionalHtml = '', optionalHtml = '';
issues_selected = jQuery.parseJSON(booking_data['issues_selected']),
custdescription = jQuery.parseJSON(booking_data['custom_service_quote']); var issues_selected = '';
if(booking_data['issues_selected'] != '' && booking_data['issues_selected'] != null && booking_data['issues_selected'] != undefined && booking_data['issues_selected'] != 'null' && booking_data['issues_selected'] != 'undefined' && booking_data['issues_selected'] != ' -- '){
issues_selected = jQuery.parseJSON(booking_data['issues_selected']);
}
var custdescription = '';
if(booking_data['custom_service_quote'] != '' && booking_data['custom_service_quote'] != null && booking_data['custom_service_quote'] != undefined && booking_data['custom_service_quote'] != 'null' && booking_data['custom_service_quote'] != 'undefined' && booking_data['custom_service_quote'] != ' -- '){
custdescription = jQuery.parseJSON(booking_data['custom_service_quote']);
}
// console.log(custdescription); // console.log(custdescription);
if(issues_selected != ''){ if(issues_selected != ''){
var comma = ''; var comma = '';
...@@ -1130,9 +1142,17 @@ jQuery('[id="showBookinDetails"]').on('click',function() { ...@@ -1130,9 +1142,17 @@ jQuery('[id="showBookinDetails"]').on('click',function() {
var html = '', var html = '',
imgCount = 0, imgCount = 0,
issueHtml = '', issueHtml = '',
optionalHtml = '', optionalHtml = '';
optional_data = jQuery.parseJSON(booking_data['custom_issue_data']),
issues_selected = jQuery.parseJSON(booking_data['issues_selected']); var issues_selected = '';
if(booking_data['issues_selected'] != '' && booking_data['issues_selected'] != null && booking_data['issues_selected'] != undefined && booking_data['issues_selected'] != 'null' && booking_data['issues_selected'] != 'undefined' && booking_data['issues_selected'] != ' -- '){
issues_selected = jQuery.parseJSON(booking_data['issues_selected']);
}
var optional_data = '';
if(booking_data['custom_issue_data'] != '' && booking_data['custom_issue_data'] != null && booking_data['custom_issue_data'] != undefined && booking_data['custom_issue_data'] != 'null' && booking_data['custom_issue_data'] != 'undefined' && booking_data['custom_issue_data'] != ' -- '){
optional_data = jQuery.parseJSON(booking_data['custom_issue_data']);
}
if(issues_selected != ''){ if(issues_selected != ''){
var comma = ''; var comma = '';
......
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