Commit 256df255 by Jansa Jose

indent

parent 7128c223
...@@ -10,14 +10,11 @@ class Webservice_model extends CI_Model { ...@@ -10,14 +10,11 @@ class Webservice_model extends CI_Model {
public function checkMobAvailability($data = array()){ public function checkMobAvailability($data = array()){
$res = array('status'=>'success', 'message'=>'Mobile Number Available','data'=>array('phone'=>$data['phone'],'is_available'=>true)); $res = array('status'=>'success', 'message'=>'Mobile Number Available','data'=>array('phone'=>$data['phone'],'is_available'=>true));
if(empty($data)){ if(empty($data)){
$res = array('status'=>'error','error'=>'901','message'=>'Something went wrong.'); $res = array('status'=>'error','error'=>'901','message'=>'Something went wrong.');
return $res; return $res;
} }
$result = $this->db->get_where('customers',array('phone'=>$data['phone'],'country_code'=>$data['country_code'])); $result = $this->db->get_where('customers',array('phone'=>$data['phone'],'country_code'=>$data['country_code']));
if(!empty($result) && $result->num_rows() > 0){ if(!empty($result) && $result->num_rows() > 0){
$res=array('status'=>'error','error'=>'902','message'=>'Mobile number already in use.'); $res=array('status'=>'error','error'=>'902','message'=>'Mobile number already in use.');
} }
...@@ -26,22 +23,18 @@ class Webservice_model extends CI_Model { ...@@ -26,22 +23,18 @@ class Webservice_model extends CI_Model {
public function checkCustomerLogin($userLogData){ public function checkCustomerLogin($userLogData){
$respArr = array('status'=>0); $respArr = array('status'=>0);
if(empty($userLogData)){ if(empty($userLogData)){
return $returnStatus; return $returnStatus;
} }
$result = $this->db->get_where('customers',array('email'=>$userLogData['email'],'status'=>'1')); $result = $this->db->get_where('customers',array('email'=>$userLogData['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())){
$respArr['status'] = 2; $respArr['status'] = 2;
return $respArr; 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"); $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'], $result = $this->db->get_where('customers',array('email'=>$userLogData['email'],
'password'=>$userLogData['password'], 'password'=>$userLogData['password'],
'status'=>'1')); 'status'=>'1'));
$respArr['status'] = 3; $respArr['status'] = 3;
if(!empty($result) && $result->num_rows() == 1 && !empty($custData = $result->row())){ if(!empty($result) && $result->num_rows() == 1 && !empty($custData = $result->row())){
$authdata = $this->insert_auth($custData->id); $authdata = $this->insert_auth($custData->id);
...@@ -67,12 +60,10 @@ class Webservice_model extends CI_Model { ...@@ -67,12 +60,10 @@ class Webservice_model extends CI_Model {
public function createCustomer($customer_data = array()){ public function createCustomer($customer_data = array()){
$respArr = array('status'=>0); $respArr = array('status'=>0);
if(empty($customer_data)){ if(empty($customer_data)){
$respArr['status'] = 0; $respArr['status'] = 0;
return $respArr; return $respArr;
} }
if(isset($customer_data['email']) && !empty($customer_data['email'])){ if(isset($customer_data['email']) && !empty($customer_data['email'])){
$emailChk = $this->db->get_where('customers',array('email'=>$customer_data['email'],'status !='=>'2')); $emailChk = $this->db->get_where('customers',array('email'=>$customer_data['email'],'status !='=>'2'));
if(!empty($emailChk) && $emailChk->num_rows() > 0){ if(!empty($emailChk) && $emailChk->num_rows() > 0){
...@@ -80,7 +71,6 @@ class Webservice_model extends CI_Model { ...@@ -80,7 +71,6 @@ class Webservice_model extends CI_Model {
return $respArr; return $respArr;
} }
} }
if(isset($customer_data['phone']) && !empty($customer_data['phone'])){ if(isset($customer_data['phone']) && !empty($customer_data['phone'])){
$phoneChk = $this->db->get_where('customers',array('phone'=>$customer_data['phone'],'status !='=>'2')); $phoneChk = $this->db->get_where('customers',array('phone'=>$customer_data['phone'],'status !='=>'2'));
if(!empty($phoneChk) && $phoneChk->num_rows() > 0){ if(!empty($phoneChk) && $phoneChk->num_rows() > 0){
...@@ -88,20 +78,14 @@ class Webservice_model extends CI_Model { ...@@ -88,20 +78,14 @@ class Webservice_model extends CI_Model {
return $respArr; return $respArr;
} }
} }
$customer_data['first_name'] = $customer_data['name']; $customer_data['first_name'] = $customer_data['name'];
unset($customer_data['name']); unset($customer_data['name']);
if($this->db->insert('customers',$customer_data)){ if($this->db->insert('customers',$customer_data)){
$last_id = $this->db->insert_id(); $last_id = $this->db->insert_id();
$this->db->select("TRIM(CONCAT(first_name,' ' ,IFNULL(last_name,''))) as name,customer_id as user_id"); $this->db->select("TRIM(CONCAT(first_name,' ' ,IFNULL(last_name,''))) as name,customer_id as user_id");
$custData = $this->db->get_where('customers',array('customer_id'=>$last_id))->row(); $custData = $this->db->get_where('customers',array('customer_id'=>$last_id))->row();
$authdata = $this->insert_auth($last_id); $authdata = $this->insert_auth($last_id);
$custData->auth_token = $authdata; $custData->auth_token = $authdata;
$respArr['data'] = $custData; $respArr['data'] = $custData;
$respArr['status'] = 1; $respArr['status'] = 1;
} }
...@@ -110,11 +94,9 @@ class Webservice_model extends CI_Model { ...@@ -110,11 +94,9 @@ class Webservice_model extends CI_Model {
public function get_customer_authtoken($auth = ''){ public function get_customer_authtoken($auth = ''){
$respArr = array('status'=>0,'error'=>'901','message'=>'Something Went Wrong.'); $respArr = array('status'=>0,'error'=>'901','message'=>'Something Went Wrong.');
if(empty($auth)){ if(empty($auth)){
return $respArr; return $respArr;
} }
$auth = $this->db->get_where('authtable',array('authtoken'=>$auth)); $auth = $this->db->get_where('authtable',array('authtoken'=>$auth));
if(!empty($auth) && $auth->num_rows() >= 1 && !empty($custAuth = $auth->row_array())){ if(!empty($auth) && $auth->num_rows() >= 1 && !empty($custAuth = $auth->row_array())){
$respArr['status'] = 'success'; $respArr['status'] = 'success';
...@@ -129,17 +111,13 @@ class Webservice_model extends CI_Model { ...@@ -129,17 +111,13 @@ class Webservice_model extends CI_Model {
public function getBookedService($id = ''){ public function getBookedService($id = ''){
$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 date,scheduled_time as time'); $this->db->select('booking_id as id,scheduled_date as date,scheduled_time as time');
$bookData = $this->db->get_where('bookings',array('customer_id'=>$id))->result_array(); $bookData = $this->db->get_where('bookings',array('customer_id'=>$id))->result_array();
$respArr['status'] = 'success';
$respArr['status'] = 'success'; $respArr['message'] = 'success';
$respArr['message'] = 'success';
if(!empty($bookData) && (count($bookData) > 0)){ if(!empty($bookData) && (count($bookData) > 0)){
$respArr['data']['booked_services'] = $bookData; $respArr['data']['booked_services'] = $bookData;
}else{ }else{
...@@ -150,13 +128,10 @@ class Webservice_model extends CI_Model { ...@@ -150,13 +128,10 @@ class Webservice_model extends CI_Model {
public function addVehicleDetails($postData = array(),$customer_id = ''){ public function addVehicleDetails($postData = array(),$customer_id = ''){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.'); $respArr = array('status'=>'error','message'=>'Something Went Wrong.');
if(empty($postData)){ if(empty($postData)){
return $respArr; return $respArr;
} }
$car_name = $postData['vehicle_year'].' '.$postData['vehicle_make'].' '.$postData['vehicle_model']; $car_name = $postData['vehicle_year'].' '.$postData['vehicle_make'].' '.$postData['vehicle_model'];
$vehJson = array( $vehJson = array(
'vehicle' => $car_name, 'vehicle' => $car_name,
'attributes' => array( 'attributes' => array(
...@@ -167,7 +142,6 @@ class Webservice_model extends CI_Model { ...@@ -167,7 +142,6 @@ class Webservice_model extends CI_Model {
'Engine'=> $postData['engine_no'] 'Engine'=> $postData['engine_no']
) )
); );
$insert_array = array( $insert_array = array(
'customer_id' => $customer_id, 'customer_id' => $customer_id,
'car_name' => $car_name, 'car_name' => $car_name,
...@@ -180,20 +154,16 @@ class Webservice_model extends CI_Model { ...@@ -180,20 +154,16 @@ class Webservice_model extends CI_Model {
'car_model_year'=> $postData['vehicle_year'], 'car_model_year'=> $postData['vehicle_year'],
'status' => '3' 'status' => '3'
); );
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(
'mileage' => $postData['mileage'], 'mileage' => $postData['mileage'],
'customer_id' => $customer_id, 'customer_id' => $customer_id,
'customer_veh_id'=> $last_id, 'customer_veh_id'=> $last_id,
'status' => '5' 'status' => '5'
); );
if($this->db->insert('bookings',$book_data)){ if($this->db->insert('bookings',$book_data)){
$book_id = $this->db->insert_id(); $book_id = $this->db->insert_id();
$respArr['status'] = 'success'; $respArr['status'] = 'success';
$respArr['message'] = 'success'; $respArr['message'] = 'success';
$respArr['data']['booking_id'] = $book_id; $respArr['data']['booking_id'] = $book_id;
...@@ -205,7 +175,6 @@ class Webservice_model extends CI_Model { ...@@ -205,7 +175,6 @@ class Webservice_model extends CI_Model {
public function get_service_list($postData = '',$start,$per_page){ public function get_service_list($postData = '',$start,$per_page){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.'); $respArr = array('status'=>'error','message'=>'Something Went Wrong.');
$this->db->select("issue_id as id,issue as service_name,IF(issue_image != NULL OR issue_image != '' , concat('".base_url()."',issue_image) , '') as icon"); $this->db->select("issue_id as id,issue as service_name,IF(issue_image != NULL OR issue_image != '' , concat('".base_url()."',issue_image) , '') as icon");
if(!empty($postData['query'])){ if(!empty($postData['query'])){
$where = "issue LIKE '".$postData['query']."%'"; $where = "issue LIKE '".$postData['query']."%'";
...@@ -216,7 +185,6 @@ class Webservice_model extends CI_Model { ...@@ -216,7 +185,6 @@ class Webservice_model extends CI_Model {
$this->db->limit($per_page,$start); $this->db->limit($per_page,$start);
} }
$service = $this->db->get('issues'); $service = $this->db->get('issues');
if(!empty($service) && !empty($serviceData = $service->result_array())){ if(!empty($service) && !empty($serviceData = $service->result_array())){
$respArr['status'] = 'success'; $respArr['status'] = 'success';
$respArr['message'] = 'success'; $respArr['message'] = 'success';
...@@ -227,24 +195,20 @@ class Webservice_model extends CI_Model { ...@@ -227,24 +195,20 @@ class Webservice_model extends CI_Model {
public function search_sub_services($postData = '',$start,$per_page){ public function search_sub_services($postData = '',$start,$per_page){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.'); $respArr = array('status'=>'error','message'=>'Something Went Wrong.');
if(!isset($postData['service_id']) && empty($postData['service_id'])){ if(!isset($postData['service_id']) && empty($postData['service_id'])){
$respArr['status'] = 1; $respArr['status'] = 1;
$respArr['message'] = 'Service Id is Required'; $respArr['message'] = 'Service Id is Required';
return $respArr; return $respArr;
} }
$this->db->select("issue_cat_id as id,issue_category as sub_service_name,IF(issue_cat_image != NULL OR issue_cat_image != '' , concat('".base_url()."',issue_cat_image) , '') as icon"); $this->db->select("issue_cat_id as id,issue_category as sub_service_name,IF(issue_cat_image != NULL OR issue_cat_image != '' , concat('".base_url()."',issue_cat_image) , '') as icon");
if(!empty($postData['query'])){ if(!empty($postData['query'])){
$where = "issue_category LIKE '".$postData['query']."%'"; $where = "issue_category LIKE '".$postData['query']."%'";
$this->db->where($where); $this->db->where($where);
} }
if($start != 0 || $per_page != 0){ if($start != 0 || $per_page != 0){
$this->db->limit($per_page,$start); $this->db->limit($per_page,$start);
} }
$subservice = $this->db->get_where('issues_category',array('status'=>'1','issue_id'=>$postData['service_id'])); $subservice = $this->db->get_where('issues_category',array('status'=>'1','issue_id'=>$postData['service_id']));
if(!empty($subservice) && !empty($subserviceData = $subservice->result_array())){ if(!empty($subservice) && !empty($subserviceData = $subservice->result_array())){
$respArr['status'] = 'success'; $respArr['status'] = 'success';
$respArr['message'] = 'success'; $respArr['message'] = 'success';
...@@ -255,14 +219,11 @@ class Webservice_model extends CI_Model { ...@@ -255,14 +219,11 @@ class Webservice_model extends CI_Model {
public function book_service($postData){ public function book_service($postData){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.'); $respArr = array('status'=>'error','message'=>'Something Went Wrong.');
if(empty($postData)){ if(empty($postData)){
$respArr['message'] = 'All Field is required'; $respArr['message'] = 'All Field is required';
return $respArr; return $respArr;
} }
$insert_array = array('cost'=>$postData['total_cost'],'mechanic_id'=>$postData['mechanic_id'],'scheduled_date'=>$postData['date'],'scheduled_time'=>$postData['time']); $insert_array = array('cost'=>$postData['total_cost'],'mechanic_id'=>$postData['mechanic_id'],'scheduled_date'=>$postData['date'],'scheduled_time'=>$postData['time']);
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->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"); $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");
$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');
...@@ -270,14 +231,11 @@ class Webservice_model extends CI_Model { ...@@ -270,14 +231,11 @@ class Webservice_model extends CI_Model {
$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');
$mech_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id'])); $mech_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id']));
if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){ if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){
$mech_veh_data = json_decode($mechanic_data['vehicle_data']); $mech_veh_data = json_decode($mechanic_data['vehicle_data']);
$mechanic_data['engine_no'] = $mech_veh_data->attributes->Engine; $mechanic_data['engine_no'] = $mech_veh_data->attributes->Engine;
$mechanic_data['vehicle_trim'] = $mech_veh_data->attributes->Trim; $mechanic_data['vehicle_trim'] = $mech_veh_data->attributes->Trim;
unset($mechanic_data['vehicle_data']); unset($mechanic_data['vehicle_data']);
$mechanic_data['services'] = json_decode($mechanic_data['issues_selected']); $mechanic_data['services'] = json_decode($mechanic_data['issues_selected']);
unset($mechanic_data['issues_selected']); unset($mechanic_data['issues_selected']);
$respArr['status'] = 'success'; $respArr['status'] = 'success';
...@@ -291,7 +249,6 @@ class Webservice_model extends CI_Model { ...@@ -291,7 +249,6 @@ class Webservice_model extends CI_Model {
public function get_booking_summary($postData = ''){ public function get_booking_summary($postData = ''){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.'); $respArr = array('status'=>'error','message'=>'Something Went Wrong.');
if(empty($postData['booking_id'])){ if(empty($postData['booking_id'])){
$respArr['message'] = 'Booking Id is required'; $respArr['message'] = 'Booking Id is required';
return $respArr; return $respArr;
...@@ -299,14 +256,11 @@ class Webservice_model extends CI_Model { ...@@ -299,14 +256,11 @@ class Webservice_model extends CI_Model {
$this->db->select("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,bookings.mileage,bookings.issues_selected,bookings.custom_issue_data,bookings.mechanic_id"); $this->db->select("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,bookings.mileage,bookings.issues_selected,bookings.custom_issue_data,bookings.mechanic_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');
$mech_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id'])); $mech_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id']));
if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){ if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){
$mech_veh_data = json_decode($mechanic_data['vehicle_data']); $mech_veh_data = json_decode($mechanic_data['vehicle_data']);
$mechanic_data['engine_no'] = $mech_veh_data->attributes->Engine; $mechanic_data['engine_no'] = $mech_veh_data->attributes->Engine;
$mechanic_data['vehicle_trim'] = $mech_veh_data->attributes->Trim; $mechanic_data['vehicle_trim'] = $mech_veh_data->attributes->Trim;
unset($mechanic_data['vehicle_data']); unset($mechanic_data['vehicle_data']);
$mechanic_data['services'] = json_decode($mechanic_data['issues_selected']); $mechanic_data['services'] = json_decode($mechanic_data['issues_selected']);
if(!empty($mechanic_data['services'])){ if(!empty($mechanic_data['services'])){
foreach($mechanic_data['services'] as $key => $value){ foreach($mechanic_data['services'] as $key => $value){
...@@ -319,7 +273,7 @@ class Webservice_model extends CI_Model { ...@@ -319,7 +273,7 @@ class Webservice_model extends CI_Model {
if(!empty($issue_data)){ if(!empty($issue_data)){
if($issue_data->custom_description != '' && $issue_data->custom_service_fee != ''){ if($issue_data->custom_description != '' && $issue_data->custom_service_fee != ''){
$mechanic_data['services'][$key]->description = $issue_data->custom_description; $mechanic_data['services'][$key]->description = $issue_data->custom_description;
$mechanic_data['services'][$key]->service_fee = $issue_data->custom_service_fee; $mechanic_data['services'][$key]->service_fee = $issue_data->custom_service_fee;
}else{ }else{
$mechanic_data['services'][$key]->description = $issue_data->default_description; $mechanic_data['services'][$key]->description = $issue_data->default_description;
$mechanic_data['services'][$key]->service_fee = $issue_data->default_service_fee; $mechanic_data['services'][$key]->service_fee = $issue_data->default_service_fee;
...@@ -329,39 +283,32 @@ class Webservice_model extends CI_Model { ...@@ -329,39 +283,32 @@ class Webservice_model extends CI_Model {
}else{ }else{
$mechanic_data['services'] = []; $mechanic_data['services'] = [];
} }
unset($mechanic_data['issues_selected']); unset($mechanic_data['issues_selected']);
$issue_data = json_decode($mechanic_data['custom_issue_data']); $issue_data = json_decode($mechanic_data['custom_issue_data']);
$mechanic_data['optional_images'][] = ($issue_data->optionalImages)?$issue_data->optionalImages:''; $mechanic_data['optional_images'][] = ($issue_data->optionalImages)?$issue_data->optionalImages:'';
$mechanic_data['optional_video'][] = ($issue_data->optionalVideos)?$issue_data->optionalVideos:''; $mechanic_data['optional_video'][] = ($issue_data->optionalVideos)?$issue_data->optionalVideos:'';
$mechanic_data['booking_description'] = ($issue_data->optionlaDescription)?$issue_data->optionlaDescription:''; $mechanic_data['booking_description'] = ($issue_data->optionlaDescription)?$issue_data->optionlaDescription:'';
unset($mechanic_data['custom_issue_data']); unset($mechanic_data['custom_issue_data']);
$respArr['status'] = 'success'; $respArr['status'] = 'success';
$respArr['message'] = 'success'; $respArr['message'] = 'success';
$respArr['data'] = $mechanic_data; $respArr['data'] = $mechanic_data;
} }
return $respArr; return $respArr;
} }
public function getNearMechanics($postData = '',$start,$per_page){ public function getNearMechanics($postData = '',$start,$per_page){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.'); $respArr = array('status'=>'error','message'=>'Something Went Wrong.');
if(empty($postData)){ if(empty($postData)){
return $respArr; return $respArr;
} }
$current_lat = $postData['location_lat']; $current_lat = $postData['location_lat'];
$current_lng = $postData['location_lng']; $current_lng = $postData['location_lng'];
$issue_cat_id = $postData['service_id']; $issue_cat_id = $postData['service_id'];
if($start != 0 || $per_page != 0){ if($start != 0 || $per_page != 0){
$limt = "limit ".$start.",".$per_page; $limt = "limit ".$start.",".$per_page;
}else{ }else{
$limt = ""; $limt = "";
} }
$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,
3956*2*ASIN(SQRT(POWER(SIN(($current_lat-ME.location_lat)*pi()/180/2),2)+ 3956*2*ASIN(SQRT(POWER(SIN(($current_lat-ME.location_lat)*pi()/180/2),2)+
...@@ -373,12 +320,10 @@ class Webservice_model extends CI_Model { ...@@ -373,12 +320,10 @@ class Webservice_model extends CI_Model {
WHERE AU.status='1' WHERE AU.status='1'
-- HAVING distance<30 -- HAVING distance<30
".$limt; ".$limt;
$mechData = $this->db->query($sql); $mechData = $this->db->query($sql);
if(empty($mechData) || empty($mechData = $mechData->result_array())){ if(empty($mechData) || empty($mechData = $mechData->result_array())){
return 0; return 0;
} }
$estimate = 0; $estimate = 0;
$mechDataArr = array(); $mechDataArr = array();
foreach($mechData AS $index => $data){ foreach($mechData AS $index => $data){
...@@ -389,12 +334,10 @@ class Webservice_model extends CI_Model { ...@@ -389,12 +334,10 @@ class Webservice_model extends CI_Model {
$endTime = strtotime($data['end_time']); $endTime = strtotime($data['end_time']);
$schTime = strtotime($data['start_time']); $schTime = strtotime($data['start_time']);
$scheduleTiming = array(); $scheduleTiming = array();
for( ; $schTime <= ($endTime-3600) ; $schTime += 3600){ for( ; $schTime <= ($endTime-3600) ; $schTime += 3600){
$scheduleTiming[] = date('h:i A',$schTime); $scheduleTiming[] = date('h:i A',$schTime);
} }
} }
$mechanic_id = $data['mechanic_id']; $mechanic_id = $data['mechanic_id'];
$sql = "SELECT ISS.*, IC.*, MI.* $sql = "SELECT ISS.*, IC.*, MI.*
FROM issues_category AS IC FROM issues_category AS IC
...@@ -402,14 +345,11 @@ class Webservice_model extends CI_Model { ...@@ -402,14 +345,11 @@ class Webservice_model extends CI_Model {
LEFT JOIN mechanic_issues AS MI ON (MI.issue_cat_id=IC.issue_cat_id AND 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') 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)"; WHERE ISS.status='1' AND IC.status='1' AND IC.issue_cat_id IN ($issue_cat_id)";
$subIssData = $this->db->query($sql); $subIssData = $this->db->query($sql);
$sIssueData = array(); $sIssueData = array();
if(!empty($subIssData) && !empty($subIssData = $subIssData->result_array())){ if(!empty($subIssData) && !empty($subIssData = $subIssData->result_array())){
$sIssueData = $subIssData; $sIssueData = $subIssData;
} }
$estimate = 0; $estimate = 0;
foreach($sIssueData AS $sIndex => $sIssue){ foreach($sIssueData AS $sIndex => $sIssue){
if(!empty($sIssue['custom_service_fee'])){ if(!empty($sIssue['custom_service_fee'])){
...@@ -420,11 +360,9 @@ class Webservice_model extends CI_Model { ...@@ -420,11 +360,9 @@ class Webservice_model extends CI_Model {
$sIssueData[$sIndex]['service_fee'] = $sIssue['default_service_fee']; $sIssueData[$sIndex]['service_fee'] = $sIssue['default_service_fee'];
} }
} }
$mechData[$index]['estimate'] = $estimate; $mechData[$index]['estimate'] = $estimate;
$mechData[$index]['sub_issues'] = $sIssueData; $mechData[$index]['sub_issues'] = $sIssueData;
$mechData[$index]['scheduleTiming'] = $scheduleTiming; $mechData[$index]['scheduleTiming'] = $scheduleTiming;
$respArr['status'] = 'success'; $respArr['status'] = 'success';
$respArr['message'] = 'success'; $respArr['message'] = 'success';
$respArr['data'] = $mechData; $respArr['data'] = $mechData;
...@@ -434,18 +372,15 @@ class Webservice_model extends CI_Model { ...@@ -434,18 +372,15 @@ class Webservice_model extends CI_Model {
public function add_service_details($postData){ public function add_service_details($postData){
$respArr = array('status'=>'error','message'=>'Something Went Wrong'); $respArr = array('status'=>'error','message'=>'Something Went Wrong');
if(empty($postData['booking_id'])){ if(empty($postData['booking_id'])){
$respArr['message'] = 'Booking Id is Required'; $respArr['message'] = 'Booking Id is Required';
return $respArr; return $respArr;
} }
$custom_issue_data = array( $custom_issue_data = array(
'optionlaDescription'=>(isset($postData['description']) && !empty($postData['description']))?$postData['description']:"", 'optionlaDescription'=>(isset($postData['description']) && !empty($postData['description']))?$postData['description']:"",
'optionalImages'=>(isset($postData['image']) && !empty($postData['image']))?$postData['image']:[], 'optionalImages'=>(isset($postData['image']) && !empty($postData['image']))?$postData['image']:[],
'optionalVideos'=>(isset($postData['video']) && !empty($postData['video']))?$postData['video']:[], 'optionalVideos'=>(isset($postData['video']) && !empty($postData['video']))?$postData['video']:[],
); );
if($this->db->update('bookings',array('custom_issue_data'=>json_encode($custom_issue_data)),array('booking_id'=>$postData['booking_id']))){ if($this->db->update('bookings',array('custom_issue_data'=>json_encode($custom_issue_data)),array('booking_id'=>$postData['booking_id']))){
$respArr['status'] = 'success'; $respArr['status'] = 'success';
$respArr['message'] = 'success'; $respArr['message'] = 'success';
...@@ -455,7 +390,6 @@ class Webservice_model extends CI_Model { ...@@ -455,7 +390,6 @@ class Webservice_model extends CI_Model {
public function remove_booking($postData = array()){ public function remove_booking($postData = array()){
$respArr = array('status'=>'error','message'=>'Something Went Wrong..!'); $respArr = array('status'=>'error','message'=>'Something Went Wrong..!');
if(empty($postData['booking_id'])){ if(empty($postData['booking_id'])){
$respArr['message'] = 'Booking Id is Required'; $respArr['message'] = 'Booking Id is Required';
return $respArr; return $respArr;
...@@ -463,7 +397,6 @@ class Webservice_model extends CI_Model { ...@@ -463,7 +397,6 @@ class Webservice_model extends CI_Model {
$respArr['message'] = 'Service Id is Required'; $respArr['message'] = 'Service Id is Required';
return $respArr; return $respArr;
} }
$booked_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id'])); $booked_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id']));
if(!empty($booked_data) && !empty($booked_data = $booked_data->row_array())){ if(!empty($booked_data) && !empty($booked_data = $booked_data->row_array())){
$issues_selected = json_decode($booked_data['issues_selected']); $issues_selected = json_decode($booked_data['issues_selected']);
...@@ -483,14 +416,11 @@ class Webservice_model extends CI_Model { ...@@ -483,14 +416,11 @@ class Webservice_model extends CI_Model {
public function get_service($postData = array()){ public function get_service($postData = array()){
$respArr = array('status'=>'error','message'=>'Something went Wrong.. Try Again'); $respArr = array('status'=>'error','message'=>'Something went Wrong.. Try Again');
if(empty($postData['booking_id'])){ if(empty($postData['booking_id'])){
$respArr['message'] = 'Booking Id is Required'; $respArr['message'] = 'Booking Id is Required';
return $respArr; return $respArr;
} }
$booked_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id'])); $booked_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id']));
if(!empty($booked_data) && !empty($booked_data = $booked_data->row_array())){ if(!empty($booked_data) && !empty($booked_data = $booked_data->row_array())){
$respArr['status'] = 'success'; $respArr['status'] = 'success';
$respArr['message'] = 'success'; $respArr['message'] = 'success';
......
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