Commit b6616424 by Tobin

daily commit

parent 2557a8f3
...@@ -91,19 +91,16 @@ class Customer extends CI_Controller { ...@@ -91,19 +91,16 @@ class Customer extends CI_Controller {
$upload_data = $this->upload->data(); $upload_data = $this->upload->data();
$_POST['profile_image'] = $config['upload_path']."/".$upload_data['file_name']; $_POST['profile_image'] = $config['upload_path']."/".$upload_data['file_name'];
} }
// $_POST['age'] = $this->calculateAge($_POST['date_of_birth']);
// if($_POST['age'] < 0){
// $err = 1;
// $errMsg = 'Provide a valid date of birth';
// }
} }
if($err == 1){ if($err == 1){
$flashMsg['message'] = $errMsg; $flashMsg['message'] = $errMsg;
$this->session->set_flashdata('message',$flashMsg); $this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Customer/addCustomerUser')); redirect(base_url('Customer/addCustomerUser'));
} }
$status = $this->Customer_model->createCustomer($_POST); $saved_vehicles = (!empty($_POST['saved_vehicles']))?implode(',',$_POST['saved_vehicles']):'';
unset($_POST['saved_vehicles']);
$status = $this->Customer_model->createCustomer($_POST,$saved_vehicles);
if($status == 1){ if($status == 1){
$flashMsg['class'] = 'success'; $flashMsg['class'] = 'success';
$flashMsg['message'] = 'User Created'; $flashMsg['message'] = 'User Created';
...@@ -132,7 +129,7 @@ class Customer extends CI_Controller { ...@@ -132,7 +129,7 @@ class Customer extends CI_Controller {
public function getCustomerData(){ public function getCustomerData(){
$return_arr = array('status'=>'0'); $return_arr = array('status'=>'0');
if(!isset($_POST) || empty($_POST) || !isset($_POST['customer_id']) || empty($_POST['customer_id'])){ if(!isset($_POST)||empty($_POST)||!isset($_POST['customer_id'])||empty($_POST['customer_id'])){
echo json_encode($return_arr);exit; echo json_encode($return_arr);exit;
} }
$customer_id = decode_param($_POST['customer_id']); $customer_id = decode_param($_POST['customer_id']);
...@@ -175,7 +172,7 @@ class Customer extends CI_Controller { ...@@ -175,7 +172,7 @@ class Customer extends CI_Controller {
$template['customer_id'] = $customer_id; $template['customer_id'] = $customer_id;
$customer_id = decode_param($customer_id); $customer_id = decode_param($customer_id);
$template['customer_data'] = $this->Customer_model->getCustomer(array('customer_id'=>$customer_id)); $template['customer_data']=$this->Customer_model->getCustomer(array('customer_id'=>$customer_id));
$this->load->view('template',$template); $this->load->view('template',$template);
} }
...@@ -232,8 +229,10 @@ class Customer extends CI_Controller { ...@@ -232,8 +229,10 @@ class Customer extends CI_Controller {
$upload_data = $this->upload->data(); $upload_data = $this->upload->data();
$_POST['profile_image'] = $config['upload_path']."/".$upload_data['file_name']; $_POST['profile_image'] = $config['upload_path']."/".$upload_data['file_name'];
} }
$saved_vehicles = (!empty($_POST['saved_vehicles']))?implode(',',$_POST['saved_vehicles']):'';
unset($_POST['saved_vehicles']);
$status = $this->Customer_model->updateCustomer($customerIdDec,$_POST); $status = $this->Customer_model->updateCustomer($customerIdDec,$_POST,$saved_vehicles);
if($status == 1){ if($status == 1){
$flashMsg['class'] = 'success'; $flashMsg['class'] = 'success';
$flashMsg['message'] = 'User Details Updated'; $flashMsg['message'] = 'User Details Updated';
......
...@@ -58,6 +58,10 @@ class Vehicle extends CI_Controller { ...@@ -58,6 +58,10 @@ class Vehicle extends CI_Controller {
$return_arr['status'] = 3; $return_arr['status'] = 3;
echo json_encode($return_arr);exit; echo json_encode($return_arr);exit;
} }
if($searchType == 2){
$vehData['vehicle'] = $vehData['attributes']['Year'].' '.$vehData['attributes']['Make'].' '.
$vehData['attributes']['Model'].' '.$vehData['attributes']['Trim'];
}
$vehicle_data['car_name'] = $vehData['vehicle']; $vehicle_data['car_name'] = $vehData['vehicle'];
$vehicle_data['car_loc_lat'] = $lat_lng['lat']; $vehicle_data['car_loc_lat'] = $lat_lng['lat'];
$vehicle_data['car_loc_lng'] = $lat_lng['lng']; $vehicle_data['car_loc_lng'] = $lat_lng['lng'];
......
...@@ -8,17 +8,27 @@ class Customer_model extends CI_Model { ...@@ -8,17 +8,27 @@ class Customer_model extends CI_Model {
function getCustomer($customer_data = array()){ function getCustomer($customer_data = array()){
$cond = (isset($customer_data['phone']) && !empty($customer_data['phone']))? $cond = (isset($customer_data['phone']) && !empty($customer_data['phone']))?
" AND phone LIKE '%".trim($customer_data['phone'])."'":""; " AND phone LIKE '%".trim($customer_data['phone'])."'":"";
$cond .= (!empty($customer_data['customer_id']))? $veh_data = array();
" AND customer_id = '".trim($customer_data['customer_id'])."'":""; if(!empty($customer_data['customer_id'])){
$cond .= " AND customer_id = '".trim($customer_data['customer_id'])."'";
$veh_data = $this->db->get_where(
'customer_vehicle',array('status'=>'1','customer_id'=>$customer_data['customer_id']));
$veh_data = (!empty($veh_data))?$veh_data->result():'';
}
$result = $this->db->query("SELECT * FROM customers WHERE status IN (0,1) $cond"); $result = $this->db->query("SELECT * FROM customers WHERE status IN (0,1) $cond");
if(empty($result)){ if(empty($result)){
return; return;
} }
return (empty($customer_data))?$result->result():$result->row(); $ret_data = $result->result();
if(!empty($customer_data)){
$ret_data = $result->row();
$ret_data->vehicle_data = $veh_data;
}
return $ret_data;
} }
function createCustomer($customer_data = array()){ function createCustomer($customer_data = array(), $saved_vehicles = array()){
if(empty($customer_data)) if(empty($customer_data))
return 0; return 0;
...@@ -34,12 +44,15 @@ class Customer_model extends CI_Model { ...@@ -34,12 +44,15 @@ class Customer_model extends CI_Model {
return 3; return 3;
} }
} }
$status = $this->db->insert('customers',$customer_data); $status = $this->db->insert('customers',$customer_data);
if($status && !empty($saved_vehicles) && !empty($cust_id = $this->db->insert_id())){
$this->db->query("UPDATE customer_vehicle SET status='1',customer_id='$cust_id'
WHERE customer_veh_id IN ($saved_vehicles)");
}
return ($status)?1:0;; return ($status)?1:0;;
} }
function updateCustomer($customer_id = '', $customer_data = array()){ function updateCustomer($customer_id = '', $customer_data = array(), $saved_vehicles = array()){
if(empty($customer_id) || empty($customer_data)) if(empty($customer_id) || empty($customer_data))
return 0; return 0;
...@@ -57,6 +70,12 @@ class Customer_model extends CI_Model { ...@@ -57,6 +70,12 @@ class Customer_model extends CI_Model {
} }
$status = $this->db->update('customers',$customer_data,array('customer_id'=>$customer_id)); $status = $this->db->update('customers',$customer_data,array('customer_id'=>$customer_id));
if($status && !empty($saved_vehicles)){
$this->db->query("UPDATE customer_vehicle SET status='1',customer_id='$customer_id'
WHERE customer_veh_id IN ($saved_vehicles)");
}
return ($status)?1:0;; return ($status)?1:0;;
} }
......
...@@ -95,12 +95,34 @@ ...@@ -95,12 +95,34 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-12 padBottom20"> <div id="savedVehicleBox" class="<?= (!isset($customer_data->vehicle_data) || empty($customer_data->vehicle_data))?'hide':'' ?>">
<div class="col-md-12 padBottom20" id="savedVehiclesCntr"> <label style="padding-left:30px;">Vehicles Added</label>
<div class="col-md-12">
<div class="col-md-6" id="savedVehiclesCntr">
<?php
if(isset($customer_data->vehicle_data) && !empty($customer_data->vehicle_data)){
foreach ($customer_data->vehicle_data AS $vehicle) { ?>
<span id="saved_vehicle_<?= $vehicle->customer_veh_id ?>"
class="vechile-body disp-block marginBottom-5">
<i class="fa fa-fw fa-car padRight-8p"></i>
<?= $vehicle->car_name ?>
<div id="remove_saved_<?= $vehicle->customer_veh_id ?>"
car_id="<?= $vehicle->customer_veh_id ?>" class="float-right">
<i class="fa fa-fw fa-close cpoint"></i>
</div>
<input type="hidden" name="saved_vehicles[]"
value="<?= $vehicle->customer_veh_id ?>" >
</span>
<?php
}
}
?>
</div>
</div> </div>
</div> </div>
</form> </form>
</div>
<div class="box-body">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Add New Vehicles</h3> <h3 class="box-title">Add New Vehicles</h3>
</div> </div>
...@@ -156,7 +178,7 @@ ...@@ -156,7 +178,7 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<label>Vehicle Location</label> <label>Vehicle Location</label>
<input type="text" class="form-control required" name="vehLocation" <input type="text" class="form-control required" name="vehLocationDetails"
id="loc_search_1" input="search_params" placeholder="Enter Vehicle Location" required> id="loc_search_1" input="search_params" placeholder="Enter Vehicle Location" required>
</div> </div>
</div> </div>
...@@ -173,7 +195,7 @@ ...@@ -173,7 +195,7 @@
</div> </div>
<div class="col-md-12 padTop10"> <div class="col-md-12 padTop10">
<label>Vehicle Location</label> <label>Vehicle Location</label>
<input type="text" class="form-control" name="vehLocation" <input type="text" class="form-control" name="vehLocationVin"
id="loc_search_2" input="search_params" placeholder="Enter Vehicle Location"> id="loc_search_2" input="search_params" placeholder="Enter Vehicle Location">
</div> </div>
</div> </div>
...@@ -195,6 +217,7 @@ ...@@ -195,6 +217,7 @@
<div class="box-footer"> <div class="box-footer">
<div style="text-align: center;"> <div style="text-align: center;">
<button id="createCustomerSubmit" type="submit" class="btn btn-primary">Submit</button> <button id="createCustomerSubmit" type="submit" class="btn btn-primary">Submit</button>
<a href="<?=base_url('Customer/listCustomerUsers')?>" class="btn btn-primary">Cancel</a>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -35,13 +35,13 @@ ...@@ -35,13 +35,13 @@
<thead> <thead>
<tr> <tr>
<th class="hidden">ID</th> <th class="hidden">ID</th>
<th width="150px;">Name</th> <th width="13%;">Name</th>
<th width="80px;">Phone</th> <th width="10%;">Phone</th>
<th width="150px;">Email ID</th> <th width="13%;">Email ID</th>
<th width="150px;">Address</th> <th width="14%;">Address</th>
<th width="120px;">Date Of Birth</th> <th width="12%;">Date Of Birth</th>
<th width="30px;">Status</th> <th width="5%;">Status</th>
<th width="500px;">Action</th> <th width="33%;">Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
......
...@@ -328,6 +328,18 @@ ...@@ -328,6 +328,18 @@
padding-right:20px !important; padding-right:20px !important;
} }
.padRight10 {
padding-right:10px !important;
}
.padRight-5p {
padding-right:5% !important;
}
.padRight-8p {
padding-right:8% !important;
}
.padLeft20 { .padLeft20 {
padding-left:20px !important; padding-left:20px !important;
} }
......
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