Commit fa098ca8 by Jansa Jose

add service details

parent e3b21539
......@@ -15,7 +15,7 @@ class Webservice_model extends CI_Model {
return $res;
}
$result = $this->db->get_where('customers',array('phone'=>$data['phone']));
$result = $this->db->get_where('customers',array('phone'=>$data['phone'],'country_code'=>$data['country_code']));
if(!empty($result) && $result->num_rows() > 0){
$res=array('status'=>'error','error'=>'902','message'=>'Mobile number already in use.');
......@@ -23,11 +23,13 @@ class Webservice_model extends CI_Model {
return $res;
}
function checkCustomerLogin($userLogData){
public function checkCustomerLogin($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;
......@@ -37,9 +39,9 @@ class Webservice_model extends CI_Model {
$result = $this->db->get_where('customers',array('email'=>$userLogData['email'],
'password'=>$userLogData['password'],
'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;
......@@ -50,7 +52,7 @@ class Webservice_model extends CI_Model {
return $respArr;
}
function insert_auth($id){
public function insert_auth($id){
$static_string = time();
$authToken = 'Dcarfixs'.sha1($static_string);
$custData = $this->db->get_where('authtable',array('customer_id'=>$id));
......@@ -61,7 +63,7 @@ class Webservice_model extends CI_Model {
return $authToken;
}
function createCustomer($customer_data = array()){
public function createCustomer($customer_data = array()){
$respArr = array('status'=>0);
if(empty($customer_data)){
......@@ -101,7 +103,6 @@ class Webservice_model extends CI_Model {
$respArr['data'] = $custData;
$respArr['status'] = 1;
}
return $respArr;
}
......@@ -139,7 +140,6 @@ class Webservice_model extends CI_Model {
$respArr['data'] = $bookData;
$respArr['message'] = 'success';
}
return $respArr;
}
......@@ -152,17 +152,19 @@ class Webservice_model extends CI_Model {
$car_name = $postData['vehicle_year'].' '.$postData['vehicle_make'].' '.$postData['vehicle_model'];
$vehJson = array('vehicle' => $car_name,
'attributes' =>
array(
$vehJson = array(
'vehicle' => $car_name,
'attributes' => array(
'Year' => $postData['vehicle_year'],
'Make' => $postData['vehicle_make'],
'Trim' => $postData['vehicle_trim'],
'Model' => $postData['vehicle_model'],
'Engine' => $postData['engine_no'])
'Engine'=> $postData['engine_no']
)
);
$insert_array = array('customer_id' => $customer_id,
$insert_array = array(
'customer_id' => $customer_id,
'car_name' => $car_name,
'car_model' => $postData['vehicle_model'],
'car_maker' => $postData['vehicle_make'],
......@@ -171,7 +173,8 @@ class Webservice_model extends CI_Model {
'car_location' => $postData['car_location'],
'vehicle_data' => json_encode($vehJson),
'car_model_year'=> $postData['vehicle_year'],
'status' => '3');
'status' => '3'
);
if($this->db->insert('customer_vehicle',$insert_array)){
$last_id = $this->db->insert_id();
......@@ -179,8 +182,9 @@ class Webservice_model extends CI_Model {
$book_data = array(
'mileage' => $postData['mileage'],
'customer_id' => $customer_id,
'customer_veh_id' => $last_id,
'status' => '5');
'customer_veh_id'=> $last_id,
'status' => '5'
);
if($this->db->insert('bookings',$book_data)){
$book_id = $this->db->insert_id();
......@@ -195,7 +199,6 @@ class Webservice_model extends CI_Model {
}
public function get_service_list($postData = '',$start,$per_page){
$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");
......@@ -218,7 +221,6 @@ class Webservice_model extends CI_Model {
}
public function search_sub_services($postData = '',$start,$per_page){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.');
if(!isset($postData['service_id']) && empty($postData['service_id'])){
......@@ -289,7 +291,7 @@ class Webservice_model extends CI_Model {
$respArr['message'] = 'Booking Id is required';
return $respArr;
}
$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");
$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');
$mech_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id']));
......@@ -301,6 +303,24 @@ class Webservice_model extends CI_Model {
unset($mechanic_data['vehicle_data']);
$mechanic_data['services'] = json_decode($mechanic_data['issues_selected']);
foreach($mechanic_data['services'] as $key => $value){
$sql = "SELECT IC.*, MI.custom_description, MI.custom_service_fee
FROM issues_category AS IC
LEFT JOIN mechanic_issues AS MI ON (MI.issue_cat_id=IC.issue_cat_id AND
MI.mechanic_id='".$mechanic_data['mechanic_id']."' AND MI.status='1')
WHERE IC.status='1' AND IC.issue_cat_id='".$value->sub_issue_id."'";
$issue_data = $this->db->query($sql)->row();
if(empty($issue_data)){
if($issue_data->custom_description != '' && $issue_data->custom_service_fee != ''){
$mechanic_data['services'][$key]->description = $issue_data->custom_description;
$mechanic_data['services'][$key]->service_fee = $issue_data->custom_service_fee;
}else{
$mechanic_data['services'][$key]->description = $issue_data->default_description;
$mechanic_data['services'][$key]->service_fee = $issue_data->default_service_fee;
}
}
}
unset($mechanic_data['issues_selected']);
$issue_data = json_decode($mechanic_data['custom_issue_data']);
......@@ -325,8 +345,8 @@ class Webservice_model extends CI_Model {
$current_lat = $postData['location_lat'];
$current_lng = $postData['location_lng'];
// $issue_cat_id = implode(',',$postData['service_id']);
$issue_cat_id = $postData['service_id'];
if($start != 0 || $per_page != 0){
$limt = "limit ".$start.",".$per_page;
}else{
......@@ -402,5 +422,26 @@ class Webservice_model extends CI_Model {
return $respArr;
}
public function add_service_details($postData){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.');
if(empty($postData['booking_id'])){
$respArr['message'] = 'Booking Id is Required';
return $respArr;
}
$custom_issue_data = array(
'optionlaDescription'=>(isset($postData['description']) && !empty($postData['description']))?$postData['description']:"",
'optionalImages'=>(isset($postData['image']) && !empty($postData['image']))?$postData['image']:[],
'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']))){
$respArr['status'] = 'success';
$respArr['message'] = 'success';
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