1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
class Vehicle_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
function addVehicle($vehicle_data = array()){
if(empty($vehicle_data)){
return 0;
}
$status = $this->db->insert('customer_vehicle',$vehicle_data);
return ($status)?$this->db->insert_id():'0';
}
function changeStatus($vehicle_id = '', $action = '0'){
if(empty($vehicle_id)){
return 0;
}
if($action == 3){
$status = $this->db->delete('customer_vehicle',array('customer_veh_id'=>$vehicle_id));
} else {
$status = $this->db->update('customer_vehicle',array('status'=>$action),
array('customer_veh_id'=>$vehicle_id));
}
return $status;
}
function getCustVechiles($searchData = array()){
if(empty($searchData)){
return 0;
}
$cond = array();
$cond['status'] = 1;
if(isset($searchData['customer_id']) && !empty($searchData['customer_id'])){
$cond['customer_id'] = $searchData['customer_id'];
}
$vehData = $this->db->get_where('customer_vehicle',$cond);
if(!empty($vehData)){
$vehData = $vehData->result();
foreach ($vehData as $key => $value) {
$result = $this->db->query("SELECT VEHM.veh_brand_id,VEHM.veh_modal_id
FROM vehicles_model AS VEHM
WHERE VEHM.model='".$value->car_model."'")->row();
if(!empty($result)){
$vehData[$key]->veh_brand_id = $result->veh_brand_id;
$vehData[$key]->veh_model_id = $result->veh_modal_id;
}
}
return $vehData;
}
return 0;
}
function changeCustomerCarStatus($customer_id = '', $customer_veh_id = '', $status = ''){
if(empty($customer_id) || empty($customer_veh_id) || $status == ''){
return 0;
}
$upStatus = $this->db->update('customer_vehicle',
array('status'=>$status),
array('customer_id'=>$customer_id,'customer_veh_id'=>$customer_veh_id));
return $upStatus;
}
public function addBrand($veh_data = array()){
if(empty($veh_data)){
return 0;
}
$result = $this->db->get_where('vehicles_brand',array('vehicles_brand.maker'=>$veh_data['maker']))->row();
if($result){
return 0;
}
$status = $this->db->insert('vehicles_brand',$veh_data);
$last_id = $this->db->insert_id();
return $last_id;
}
function getVehBrand($veh_brand_id = '',$view_all = 0){
$cond = ($view_all != 0)?' vehicles_brand.status IN (0,1) ':' vehicles_brand.status IN (1) ';
$cond .= (!empty($veh_brand_id))?" AND vehicles_brand.veh_brand_id = '$veh_brand_id'":"";
$result = $this->db->query("SELECT * FROM vehicles_brand
WHERE $cond ORDER BY vehicles_brand.maker");
if(empty($result)){
return;
}
return (empty($veh_brand_id))?$result->result():$result->row();
}
function changeVehicleStatus($brand_id = '', $status = '0',$type=''){
if(empty($brand_id)){
return 0;
}
if($type == '2'){
$status = $this->db->update('vehicles_model',array('status'=>$status), array('veh_modal_id'=>$brand_id));
}else{
$status = $this->db->update('vehicles_brand',array('status'=>$status), array('veh_brand_id'=>$brand_id));
}
return $status;
}
function updateVehBrand($brand_id = '', $brand_data = array()){
if(empty($brand_id) || empty($brand_data)){
return 0;
}
$status = $this->db->update('vehicles_brand',$brand_data,array('veh_brand_id'=>$brand_id));
return ($status)?1:0;
}
function getVehModel($veh_model_id = '',$view_all = 0,$veh_brand_id=''){
$cond = ($view_all != 0)?' vehicles_model.status IN (0,1) ':' vehicles_model.status IN (1) ';
$cond .= (!empty($veh_model_id))?" AND vehicles_model.veh_modal_id = '$veh_model_id'":"";
$cond .= (!empty($veh_brand_id))?" AND vehicles_model.veh_brand_id = '$veh_brand_id'":"";
$result = $this->db->query("SELECT vehicles_model.*, vehicles_brand.maker
FROM vehicles_model
JOIN vehicles_brand ON vehicles_brand.veh_brand_id = vehicles_model.veh_brand_id
WHERE $cond ORDER BY vehicles_model.model");
if(empty($result)){
return;
}
if(isset($veh_brand_id) && !empty($veh_brand_id)){
return $result->result();
}
return (empty($veh_model_id))?$result->result():$result->row();
}
public function addModel($veh_data = array()){
if(empty($veh_data)){
return 0;
}
$result = $this->db->get_where('vehicles_model',array('vehicles_model.model'=>$veh_data['model'],'vehicles_model.veh_brand_id'=>$veh_data['veh_brand_id']))->row();
if($result){
return 0;
}
$status = $this->db->insert('vehicles_model',$veh_data);
$last_id = $this->db->insert_id();
return $last_id;
}
public function updateVehModel($model_id = '', $model_data = array()){
if(empty($model_id) || empty($model_data)){
return 0;
}
$status = $this->db->update('vehicles_model',$model_data,array('veh_modal_id'=>$model_id));
return ($status)?1:0;
}
public function changeReminderStatus($postData = array()){
$respArr = array('status'=>'error');
if(empty($postData)){
$respArr['message'] = 'All Field is Required';
}
if($this->db->update('customer_vehicle',array('enable_notification'=>$postData['status']),array('customer_veh_id'=>$postData['customer_veh_id']))){
$respArr['status'] = 'success';
}
return $respArr;
}
}
?>