Commit a3a0b0a1 by Tobin

dc

parent 637f6a6b
...@@ -59,6 +59,9 @@ class Vehicle extends CI_Controller { ...@@ -59,6 +59,9 @@ class Vehicle extends CI_Controller {
echo json_encode($return_arr);exit; echo json_encode($return_arr);exit;
} }
if($searchType == 2){ if($searchType == 2){
$vehicle_data['car_model'] = $vehData['attributes']['Model'];
$vehicle_data['car_maker'] = $vehData['attributes']['Make'];
$vehicle_data['car_model_year'] = $vehData['attributes']['Year'];
$vehData['vehicle'] = $vehData['attributes']['Year'].' '.$vehData['attributes']['Make'].' '. $vehData['vehicle'] = $vehData['attributes']['Year'].' '.$vehData['attributes']['Make'].' '.
$vehData['attributes']['Model'].' '.$vehData['attributes']['Trim']; $vehData['attributes']['Model'].' '.$vehData['attributes']['Trim'];
} }
......
<?php
class Booking_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
public function scheduleBooking($postData = array()){
if(empty($postData)){
return 0;
}
$vehData = $postData['vechile_info'];
$car_name = $vehData['modelYear'].' '.$vehData['maker'].' '.$vehData['modelName'];
$vehJson = array('vehicle' => $car_name,
'attributes' =>
array(
'Year' => $vehData['modelYear'],
'Make' => $vehData['maker'],
'Trim' => $vehData['trim'],
'Model' => $vehData['modelName'],
'Engine' => $vehData['emgine']
));
$insert_array = array(
'customer_id' => $postData['customer_id'],
'car_name' => $car_name,
'car_model' => $vehData['modelName'],
'car_maker' => $vehData['maker'],
'car_loc_lat' => $postData['pickup_data']['pickup_lat'],
'car_loc_lng' => $postData['pickup_data']['pickup_lng'],
'car_location' => $postData['pickup_data']['pickup_loc'],
'vehicle_data' => json_encode($vehJson),
'car_model_year'=> $vehData['modelYear'],
'status' => '3');
if($this->db->insert('customer_vehicle',$insert_array)){
$last_id = $this->db->insert_id();
$book_data = array(
'customer_veh_id' => $last_id,
'customer_id' => $postData['customer_id'],
'mechanic_id' => $postData['mechanic_id'],
'scheduled_date' => $postData['schedule_date']['date'],
'scheduled_time' => $postData['schedule_date']['time'],
'mileage' => $vehData['milage'],
'status' => '0');
if($this->db->insert('bookings',$book_data)){
return 1;
}
}
return 0;
}
function getCustBookDetails($postData = array(), $status = ''){
$cond = array();
if(empty($postData) || !isset($postData['customer_id']) || empty($postData['customer_id'])){
return 0;
}
$cond = "BK.customer_id='".$postData['customer_id']."' ";
$cond .= (!empty($status))?"AND BK.status IN (".$status.") ":'';
$sql = "SELECT BK.booking_id,BK.customer_id,BK.mechanic_id,BK.customer_veh_id,BK.scheduled_date,
BK.scheduled_time,BK.cost,BK.status,MECH.first_name,MECH.last_name,VEH.car_name,
BK.status
FROM bookings AS BK
INNER JOIN mechanic AS MECH ON (MECH.mechanic_id AND BK.mechanic_id)
INNER JOIN customer_vehicle AS VEH ON (VEH.customer_veh_id AND BK.customer_veh_id)
WHERE $cond
GROUP BY BK.booking_id";
$bookData = $this->db->query($sql);
if(!empty($bookData)){
return $bookData->result();
}
return 0;
}
function changeBookStatus($customer_id = '', $booking_id = '', $status = ''){
if(empty($customer_id) || empty($booking_id) || $status == ''){
return 0;
}
$status = $this->db->update('bookings',
array('status'=>$status),
array('customer_id'=>$customer_id,'booking_id'=>$booking_id));
return $status;
}
}
?>
\ No newline at end of file
...@@ -38,6 +38,7 @@ class Customer_model extends CI_Model { ...@@ -38,6 +38,7 @@ class Customer_model extends CI_Model {
return 2; return 2;
} }
} }
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){
...@@ -99,7 +100,7 @@ class Customer_model extends CI_Model { ...@@ -99,7 +100,7 @@ class Customer_model extends CI_Model {
} }
$result = $this->db->get_where('customers',array('email'=>$userLogData['email'], $result = $this->db->get_where('customers',array('email'=>$userLogData['email'],
'password'=>md5($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())){
...@@ -131,23 +132,5 @@ class Customer_model extends CI_Model { ...@@ -131,23 +132,5 @@ class Customer_model extends CI_Model {
} }
return $respArr; return $respArr;
} }
function customer_registration($userData = array()){
$respArr = array('status'=>0);
if(empty($userData)){
return $respArr;
}
$result = $this->db->get_where('customers',array('email'=>$userData['email'],'status'=>'1'));
if(!empty($result) && $result->num_rows() >= 1){
$respArr['status'] = 2;
return $respArr;
}
$userData['password'] = md5($userData['password']);
$status = $this->db->insert('customers',$userData);
if($status){
$respArr['status'] = 1;
}
return $respArr;
}
} }
?> ?>
\ No newline at end of file
...@@ -26,52 +26,34 @@ class Vehicle_model extends CI_Model { ...@@ -26,52 +26,34 @@ class Vehicle_model extends CI_Model {
return $status; return $status;
} }
public function scheduleBooking($postData = array()){ function getCustVechiles($searchData = array()){
if(empty($postData)){ if(empty($searchData)){
return 0; return 0;
} }
$vehData = $postData['vechile_info']; $cond = array();
$car_name = $vehData['modelYear'].' '.$vehData['maker'].' '.$vehData['modelName'];
$vehJson = array('vehicle' => $car_name, $cond['status'] = 1;
'attributes' => if(isset($searchData['customer_id']) && !empty($searchData['customer_id'])){
array( $cond['customer_id'] = $searchData['customer_id'];
'Year' => $vehData['modelYear'], }
'Make' => $vehData['maker'], $vehData = $this->db->get_where('customer_vehicle',$cond);
'Trim' => $vehData['trim'],
'Model' => $vehData['modelName'],
'Engine' => $vehData['emgine']
));
$insert_array = array(
'customer_id' => $postData['customer_id'],
'car_name' => $car_name,
'car_model' => $vehData['modelName'],
'car_maker' => $vehData['maker'],
'car_loc_lat' => $postData['pickup_data']['pickup_lat'],
'car_loc_lng' => $postData['pickup_data']['pickup_lng'],
'car_location' => $postData['pickup_data']['pickup_loc'],
'vehicle_data' => json_encode($vehJson),
'car_model_year'=> $vehData['modelYear'],
'status' => '3');
if($this->db->insert('customer_vehicle',$insert_array)){
$last_id = $this->db->insert_id();
$book_data = array(
'customer_veh_id' => $last_id,
'customer_id' => $postData['customer_id'],
'mechanic_id' => $postData['mechanic_id'],
'scheduled_date' => $postData['schedule_date']['date'],
'scheduled_time' => $postData['schedule_date']['time'],
'mileage' => $vehData['milage'],
'status' => '0');
if($this->db->insert('bookings',$book_data)){ if(!empty($vehData)){
return 1; return $vehData->result();
} }
return 0;
} }
function changeCustomerCarStatus($customer_id = '', $customer_veh_id = '', $status = ''){
if(empty($customer_id) || empty($customer_veh_id) || $status == ''){
return 0; return 0;
} }
$upStatus = $this->db->update('customer_vehicle',
array('status'=>$status),
array('customer_id'=>$customer_id,'customer_veh_id'=>$customer_veh_id));
return $upStatus;
}
} }
?> ?>
\ No newline at end of file
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