Commit 7a1742e9 by Jansa Jose

vin audit changes

parent 839b0156
...@@ -24,6 +24,7 @@ class Product extends CI_Controller { ...@@ -24,6 +24,7 @@ class Product extends CI_Controller {
$template['product_data'] = $this->Product_model->getProduct(); $template['product_data'] = $this->Product_model->getProduct();
$template['veh_data']['make'] = $this->Vehicle_model->getVehBrand('',1); $template['veh_data']['make'] = $this->Vehicle_model->getVehBrand('',1);
$template['veh_data']['model'] = $this->Vehicle_model->getVehModel('',1); $template['veh_data']['model'] = $this->Vehicle_model->getVehModel('',1);
//pr($template['veh_data']['model']);
$template['brand_data'] = $this->Brand_model->getbrand('',1); $template['brand_data'] = $this->Brand_model->getbrand('',1);
$this->load->view('template',$template); $this->load->view('template',$template);
} }
...@@ -85,7 +86,7 @@ class Product extends CI_Controller { ...@@ -85,7 +86,7 @@ class Product extends CI_Controller {
redirect(base_url('Product/addproduct')); redirect(base_url('Product/addproduct'));
} }
$_POST['created_by']=($this->session->userdata['user_type']==2)?$this->session->userdata['id']:0; $_POST['created_by']=($this->session->userdata['user_type']==2)?$this->session->userdata['id']:0;
pr($_POST); // pr($_POST);
$product_id = $this->Product_model->addProduct($_POST); $product_id = $this->Product_model->addProduct($_POST);
if($product_id){ if($product_id){
$evtMediaData = array(); $evtMediaData = array();
...@@ -135,8 +136,9 @@ class Product extends CI_Controller { ...@@ -135,8 +136,9 @@ class Product extends CI_Controller {
$template['product_id'] = encode_param($product_id); $template['product_id'] = encode_param($product_id);
$template['brand_data'] = $this->Brand_model->getbrand('',1); $template['brand_data'] = $this->Brand_model->getbrand('',1);
$template['product_data'] = $this->Product_model->getProduct($product_id); $template['product_data'] = $this->Product_model->getProduct($product_id);
pr($template['product_data']); //echo "<pre>"; print_r($template['product_data']) ; exit;
$template['veh_data']['make'] = $this->Vehicle_model->getVehBrand('',1); $template['veh_data']['make'] = $this->Vehicle_model->getVehBrand('',1);
$template['veh_data']['model'] = $this->Vehicle_model->getVehModel('',1);
$template['product_image'] = $this->Product_model->getProductImage($product_id); $template['product_image'] = $this->Product_model->getProductImage($product_id);
$template['brand_id'] = $template['product_data']->brand_id; $template['brand_id'] = $template['product_data']->brand_id;
$this->load->view('template',$template); $this->load->view('template',$template);
...@@ -181,6 +183,7 @@ class Product extends CI_Controller { ...@@ -181,6 +183,7 @@ class Product extends CI_Controller {
$existingImages = (isset($_POST['existingImages']) && !empty($_POST['existingImages']))? $existingImages = (isset($_POST['existingImages']) && !empty($_POST['existingImages']))?
$_POST['existingImages']:''; $_POST['existingImages']:'';
unset($_POST['existingImages']); unset($_POST['existingImages']);
//pr($_POST);
$product = $this->Product_model->updateProduct(decode_param($product_id),$_POST); $product = $this->Product_model->updateProduct(decode_param($product_id),$_POST);
if($product){ if($product){
$evtMediaData = array(); $evtMediaData = array();
......
...@@ -366,7 +366,7 @@ class Vehicle extends CI_Controller { ...@@ -366,7 +366,7 @@ class Vehicle extends CI_Controller {
continue; continue;
} }
$modArr[] = $model->model; $modArr[] = $model->model;
$results .= '<option value="'.$model->veh_model_id.'" model="'.$model->model.'">'; $results .= '<option value="'.$model->veh_model_id.'" vehicle_id="'.$model->veh_id.'" model="'.$model->model.'">';
$results .= $model->model; $results .= $model->model;
if($type == 0){ if($type == 0){
$results .= (!empty($model->trim))?' '.$model->trim:''; $results .= (!empty($model->trim))?' '.$model->trim:'';
......
...@@ -11,12 +11,12 @@ class Product_model extends CI_Model { ...@@ -11,12 +11,12 @@ class Product_model extends CI_Model {
} }
$prdYear = $product_data['prdVehYear']; $prdYear = $product_data['prdVehYear'];
$prdVehModel = $product_data['prdVehModel']; $prdVehModel = $product_data['prdVehModel'];
$prdVehicle_id = $product_data['prdVehicle_id'];
unset($product_data['prdVehModel'],$product_data['prdVehYear'],$product_data['vehModel']); unset($product_data['prdVehModel'],$product_data['prdVehYear'],$product_data['vehModel'],$product_data['prdVehicle_id']);
$status = $this->db->insert('products',$product_data); $status = $this->db->insert('products',$product_data);
$last_id = $this->db->insert_id(); $last_id = $this->db->insert_id();
foreach ($prdYear as $key => $value) { foreach ($prdYear as $key => $value) {
$this->db->insert('product_cars',array('product_id'=>$last_id,'veh_model_id'=>$prdVehModel[$key])); $this->db->insert('product_cars',array('product_id'=>$last_id,'veh_model_id'=>$prdVehicle_id[$key]));
} }
return $last_id; return $last_id;
} }
...@@ -34,12 +34,12 @@ class Product_model extends CI_Model { ...@@ -34,12 +34,12 @@ class Product_model extends CI_Model {
if(!empty($product_id)){ if(!empty($product_id)){
$result = $result->row(); $result = $result->row();
$sql = "SELECT PC.prd_car_id,PC.year,VM.model_name as model,VEH.trim,VEH.engine,VB.maker,VM.veh_model_id,VEH.veh_id $sql = "SELECT PC.prd_car_id,VEH.year,VM.model_name as model,VEH.trim,VEH.engine,VB.maker,VM.veh_model_id,VEH.veh_id
FROM products AS PRD FROM products AS PRD
LEFT JOIN product_cars AS PC ON (PRD.product_id=PC.product_id AND PC.status='1') LEFT JOIN product_cars AS PC ON (PRD.product_id=PC.product_id AND PC.status='1')
LEFT JOIN vehicles AS VEH ON (PC.veh_model_id=VEH.veh_id AND VEH.status='1') LEFT JOIN vehicles AS VEH ON (PC.veh_model_id=VEH.veh_id AND VEH.status='1')
LEFT JOIN vehicles_model AS VM ON (VM.veh_model_id=VEH.veh_id AND VM.status='1') LEFT JOIN vehicle_models AS VM ON (VM.veh_model_id=VEH.model_id AND VM.status='1')
LEFT JOIN vehicles_brand AS VB ON (VB.veh_brand_id=VM.veh_brand_id AND VB.status='1') LEFT JOIN vehicles_brand AS VB ON (VB.veh_brand_id=VEH.veh_brand_id AND VB.status='1')
WHERE PC.product_id='$product_id' AND PRD.status='1'"; WHERE PC.product_id='$product_id' AND PRD.status='1'";
$carData = $this->db->query($sql); $carData = $this->db->query($sql);
$carData = (!empty($carData))?$carData->result():[]; $carData = (!empty($carData))?$carData->result():[];
...@@ -64,9 +64,9 @@ class Product_model extends CI_Model { ...@@ -64,9 +64,9 @@ class Product_model extends CI_Model {
} }
$this->db->delete('product_cars',array('product_id'=>$product_id)); $this->db->delete('product_cars',array('product_id'=>$product_id));
foreach ($product_data['prdVehYear'] as $key => $value) { foreach ($product_data['prdVehYear'] as $key => $value) {
$this->db->insert('product_cars',array('product_id'=>$product_id,'veh_model_id'=>$product_data['prdVehModel'][$key],'year'=>$value)); $this->db->insert('product_cars',array('product_id'=>$product_id,'veh_model_id'=>$product_data['prdVehicle_id'][$key]));
} }
unset($product_data['prdVehModel'],$product_data['prdVehYear'],$product_data['vehModel']); unset($product_data['prdVehModel'],$product_data['prdVehYear'],$product_data['vehModel'],$product_data['prdVehicle_id']);
$status = $this->db->update('products',$product_data,array('product_id'=>$product_id)); $status = $this->db->update('products',$product_data,array('product_id'=>$product_id));
return ($status)?1:0; return ($status)?1:0;
} }
......
<div class="content-wrapper"> <div class="content-wrapper">
<section class="content-header"> <section class="content-header">
<h1><?= $pTitle ?><small><?= $pDescription ?></small> <h1><?= $pTitle ?><small><?= $pDescription ?></small>
...@@ -166,7 +167,7 @@ ...@@ -166,7 +167,7 @@
!empty($product_data->veh_model_id) && !empty($product_data->veh_model_id) &&
$product_data->veh_model_id == $value->veh_model_id)?'selected':''; $product_data->veh_model_id == $value->veh_model_id)?'selected':'';
echo '<option '.$cond.' value="'.$value->veh_model_id.'">'.$value->model.' '.$value->trim.' '.$value->engine.'</option>'; echo '<option '.$cond.' value="'.$value->veh_model_id.'" vehicle_id="'.$value->veh_id.'">'.$value->model.' '.$value->trim.' '.$value->engine.'</option>';
} }
} }
?> ?>
...@@ -210,7 +211,8 @@ ...@@ -210,7 +211,8 @@
</div> </div>
</div> </div>
<input type="hidden" value="<?= $value->year ?>" name="prdVehYear[]"> <input type="hidden" value="<?= $value->year ?>" name="prdVehYear[]">
<input type="hidden" value="<?= $value->veh_id ?>" name="prdVehModel[]"> <input type="hidden" value="<?= $value->veh_model_id ?>" name="prdVehModel[]">
<input type="hidden" value="<?= $value->veh_id ?>" name="prdVehicle_id[]">
</span> </span>
</div> </div>
<?php <?php
......
...@@ -591,7 +591,7 @@ jQuery('[id^="addPrdtCar"]').on('click',function(event) { ...@@ -591,7 +591,7 @@ jQuery('[id^="addPrdtCar"]').on('click',function(event) {
model = jQuery("#veh_model option:selected").text(), model = jQuery("#veh_model option:selected").text(),
modelVal = jQuery("#veh_model").val(), modelVal = jQuery("#veh_model").val(),
count = parseInt((jQuery(this).attr('count'))) + 1; count = parseInt((jQuery(this).attr('count'))) + 1;
vehicle_id = jQuery('[name="vehModel"] option:selected').attr('vehicle_id'),
jQuery(this).attr('count',count); jQuery(this).attr('count',count);
if(year == '' || year == null || year == 'null' || year == undefined || year == 'undefined' || model == '' || model == null || model == 'null' || model == undefined || model == 'undefined' || make == '' || make == null || make == 'null' || make == undefined || make == 'undefined' || count == '' || count == null || count == 'null' || count == undefined || count == 'undefined' || modelVal == '' || modelVal == null || modelVal == 'null' || modelVal == undefined || modelVal == 'undefined'){ if(year == '' || year == null || year == 'null' || year == undefined || year == 'undefined' || model == '' || model == null || model == 'null' || model == undefined || model == 'undefined' || make == '' || make == null || make == 'null' || make == undefined || make == 'undefined' || count == '' || count == null || count == 'null' || count == undefined || count == 'undefined' || modelVal == '' || modelVal == null || modelVal == 'null' || modelVal == undefined || modelVal == 'undefined'){
return false; return false;
...@@ -603,6 +603,7 @@ jQuery('[id^="addPrdtCar"]').on('click',function(event) { ...@@ -603,6 +603,7 @@ jQuery('[id^="addPrdtCar"]').on('click',function(event) {
'</div>'+ '</div>'+
'<input type="hidden" value="'+year+'" name="prdVehYear[]">'+ '<input type="hidden" value="'+year+'" name="prdVehYear[]">'+
'<input type="hidden" value="'+modelVal+'" name="prdVehModel[]">'+ '<input type="hidden" value="'+modelVal+'" name="prdVehModel[]">'+
'<input type="hidden" value="'+vehicle_id+'" name="prdVehicle_id[]">'+
'</span>'; '</span>';
jQuery('[id="addCarResult"]').append('<div id="add_result_'+count+'" class="col-md-6 form-group">'+vehHtmlBody+'</div>'); jQuery('[id="addCarResult"]').append('<div id="add_result_'+count+'" class="col-md-6 form-group">'+vehHtmlBody+'</div>');
jQuery('[id="addCarResult"]').removeClass('hide'); jQuery('[id="addCarResult"]').removeClass('hide');
......
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