Commit f4f71a89 by Jansa Jose

vin audit,import data

parent 3a9b920d
...@@ -155,6 +155,33 @@ class Brand extends CI_Controller { ...@@ -155,6 +155,33 @@ class Brand extends CI_Controller {
} }
} }
// public function import_data(){
// $template['page'] = 'Brand/importdata';
// $template['menu'] = 'brand Management';
// $template['smenu'] = 'Edit brand';
// $template['pTitle'] = "Edit brand";
// $template['brand_id'] = '';
// $template['pDescription'] = "Update brand Data";
// $this->load->view('template',$template);
// }
// public function importCsvData(){
// $filename=$_FILES["brand_logo"]["name"];
// $ext=pathinfo($filename, PATHINFO_EXTENSION);
// if($ext=="csv")
// {
// $file = fopen($filename, "r");
// while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
// {
// $sql = "INSERT into import(product_id,name,brand_name,short_description,part_id,vehicle_model,amount,status) values('$emapData[0]','$emapData[1]','$emapData[2]','$emapData[3]','$emapData[4]','$emapData[5]','$emapData[6]','$emapData[7]')";
// $this->db->query($sql);
// }
// fclose($file);
// echo "CSV File has been successfully Imported.";
// }
// }
} }
?> ?>
\ No newline at end of file
...@@ -37,7 +37,8 @@ class Product extends CI_Controller { ...@@ -37,7 +37,8 @@ class Product extends CI_Controller {
$template['pTitle'] = "View Product"; $template['pTitle'] = "View Product";
$template['pDescription'] = "View and Manage Product"; $template['pDescription'] = "View and Manage Product";
$template['product_data'] = $this->Product_model->getProduct('',1); $mechanic_id = ($this->session->userdata['user_type']==2)?$this->session->userdata['id']:'';
$template['product_data'] = $this->Product_model->getProduct('',1,$mechanic_id);
$this->load->view('template',$template); $this->load->view('template',$template);
} }
...@@ -96,6 +97,7 @@ class Product extends CI_Controller { ...@@ -96,6 +97,7 @@ class Product extends CI_Controller {
$this->session->set_flashdata('message',$flashMsg); $this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Product/addproduct')); redirect(base_url('Product/addproduct'));
} }
$_POST['created_by']=($this->session->userdata['user_type']==2)?$this->session->userdata['id']:0;
$product_id = $this->Product_model->addProduct($_POST); $product_id = $this->Product_model->addProduct($_POST);
if($product_id){ if($product_id){
...@@ -262,7 +264,8 @@ class Product extends CI_Controller { ...@@ -262,7 +264,8 @@ class Product extends CI_Controller {
public function exportProductData(){ public function exportProductData(){
$productData = $this->Product_model->getProduct('',1); $mechanic_id = ($this->session->userdata['user_type']==2)?$this->session->userdata['id']:'';
$productData = $this->Product_model->getProduct('',1,$mechanic_id);
if(empty($productData)){ if(empty($productData)){
return; return;
} }
......
...@@ -519,7 +519,7 @@ ...@@ -519,7 +519,7 @@
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$param = ""; $url = "";
$searchType = $postData['type']; $searchType = $postData['type'];
$searchData = $postData['vehicleData']; $searchData = $postData['vehicleData'];
$locationData = $postData['location']; $locationData = $postData['location'];
...@@ -543,36 +543,50 @@ ...@@ -543,36 +543,50 @@
$vehicle_data['car_model'] = $searchData['modelName']; $vehicle_data['car_model'] = $searchData['modelName'];
$vehicle_data['car_model_year'] = $searchData['modelYear']; $vehicle_data['car_model_year'] = $searchData['modelYear'];
$param = "?format=json&key=".urlencode($settings['vin_audit_api'])."&year=". //$param = "?format=json&key=".urlencode($settings['vin_audit_api'])."&year=".
urlencode($searchData['modelYear'])."&make=".urlencode($searchData['car_maker']). //urlencode($searchData['modelYear'])."&make=".urlencode($searchData['car_maker']).
"&model=".urlencode($searchData['modelName']); //"&model=".urlencode($searchData['modelName']);
$url = "https://specifications.vinaudit.com/v3/selections?format=json&key=".
urlencode($settings['vin_audit_api'])."&id=".urlencode($searchData['modelYear'])."_".urlencode($searchData['car_maker'])."_".urlencode($searchData['modelName']);
} }
else if($searchType == 2 && isset($searchData['vin']) && !empty($searchData['vin'])){ else if($searchType == 2 && isset($searchData['vin']) && !empty($searchData['vin'])){
$vehicle_data['car_vin'] = $searchData['vin']; $vehicle_data['car_vin'] = $searchData['vin'];
$param = "?format=json&key=".urlencode($settings['vin_audit_api']). // $param = "?format=json&key=".urlencode($settings['vin_audit_api']).
"&vin=".urlencode($searchData['vin']); // "&vin=".urlencode($searchData['vin']);
$url = "https://specifications.vinaudit.com/v3/specifications?format=json&key=".urlencode($settings['vin_audit_api'])."&vin=".urlencode($searchData['vin']);
} }
if(!empty($param)){ if(!empty($url)){
$vehData=file_get_contents("https://specifications.vinaudit.com/getspecifications.php".$param); $vehData=file_get_contents($url);
if(empty($vehData) || empty($vehData = json_decode($vehData,true))){ if(empty($vehData) || empty($vehData = json_decode($vehData,true))){
echo json_encode($return_arr);exit; echo json_encode($return_arr);exit;
} }
if(!isset($vehData['success']) || empty($vehData['success']) || $vehData['success'] == false){ if(!isset($vehData['success']) || empty($vehData['success']) || $vehData['success'] == false || ((!isset($vehData['attributes']) || empty($vehData['attributes'])) &&
(!isset($vehData['selections']) || empty($vehData['selections'])))){
$return_arr['status'] = 2; $return_arr['status'] = 2;
$return_arr['message'] = 'No Data Found.'; $return_arr['message'] = 'No Data Found.';
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_model'] = $vehData['attributes']['model'];
$vehicle_data['car_maker'] = $vehData['attributes']['Make']; $vehicle_data['car_maker'] = $vehData['attributes']['make'];
$vehicle_data['car_model_year'] = $vehData['attributes']['Year']; $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'];
} } else if($searchType == 1){
$vehSele = $vehData['selections'];
$vehicle_data['car_model_year'] = $vehSele['years'][0]['name'];
$vehicle_data['car_maker'] = $vehSele['years'][0]['makes'][0]['name'];
$vehicle_data['car_model'] = $vehSele['years'][0]['makes'][0]['models'][0]['name'];
$vehData['vehicle'] = $vehSele['years'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['models'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['models'][0]['trims'][0]['name'];
}
$vehicle_data['car_name'] = $vehData['vehicle']; $vehicle_data['car_name'] = $vehData['vehicle'];
$vehicle_data['vehicle_data'] = json_encode($vehData); $vehicle_data['vehicle_data'] = json_encode($vehData);
......
...@@ -15,6 +15,7 @@ class Booking_model extends CI_Model { ...@@ -15,6 +15,7 @@ class Booking_model extends CI_Model {
return 0; return 0;
} }
$vehData = $postData['vechile_info']; $vehData = $postData['vechile_info'];
//$vehName = $this->db->get_where('vehicles_brand',array('veh_brand_id'=>$vehData['maker']))->row();
$car_name = $vehData['modelYear'].' '.$vehData['maker'].' '.$vehData['modelName']; $car_name = $vehData['modelYear'].' '.$vehData['maker'].' '.$vehData['modelName'];
$vehJson = array('vehicle' => $car_name, $vehJson = array('vehicle' => $car_name,
......
...@@ -23,9 +23,10 @@ class Product_model extends CI_Model { ...@@ -23,9 +23,10 @@ class Product_model extends CI_Model {
return $last_id; return $last_id;
} }
function getProduct($product_id = '',$view_all = 0){ function getProduct($product_id = '',$view_all = 0,$mechanic_id = ''){
$cond = ($view_all != 0)?' products.status IN (0,1) ':' products.status IN (1) '; $cond = ($view_all != 0)?' products.status IN (0,1) ':' products.status IN (1) ';
$cond .= (!empty($product_id))?" AND products.product_id = '$product_id'":""; $cond .= (!empty($product_id))?" AND products.product_id = '$product_id'":"";
$cond .= (!empty($mechanic_id))?" AND products.created_by = '$mechanic_id'":"";
$result = $this->db->query("SELECT cardetails.veh_modal_id,cardetails.year,vehicles_model.* ,products.*,product_brand.brand_name $result = $this->db->query("SELECT cardetails.veh_modal_id,cardetails.year,vehicles_model.* ,products.*,product_brand.brand_name
FROM products FROM products
......
...@@ -26,7 +26,10 @@ ...@@ -26,7 +26,10 @@
<div class="box-header with-border"> <div class="box-header with-border">
<div class="col-md-6"><h3 class="box-title">Customers List</h3></div> <div class="col-md-6"><h3 class="box-title">Customers List</h3></div>
<div class="col-md-6" align="right"> <div class="col-md-6" align="right">
<a class="btn btn-sm btn-success" href="<?= base_url('Customer/exportCustomerData')?>">Generate Report</a> <?php
if(!empty($customerData)){ ?>
<a class="btn btn-sm btn-success" href="<?= base_url('Customer/exportCustomerData')?>">Generate Report</a>
<?php } ?>
<a class="btn btn-sm btn-primary" href="<?= base_url('Customer/addCustomerUser')?>">Add New Customer</a> <a class="btn btn-sm btn-primary" href="<?= base_url('Customer/addCustomerUser')?>">Add New Customer</a>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a> <a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div> </div>
......
...@@ -28,7 +28,10 @@ ...@@ -28,7 +28,10 @@
<div class="box-header with-border"> <div class="box-header with-border">
<div class="col-md-6"><h3 class="box-title">Mechanics List</h3></div> <div class="col-md-6"><h3 class="box-title">Mechanics List</h3></div>
<div class="col-md-6" align="right"> <div class="col-md-6" align="right">
<a class="btn btn-sm btn-success" href="<?= base_url('Mechanic/exportMechanicData')?>">Generate Report</a> <?php
if(!empty($user_data)){ ?>
<a class="btn btn-sm btn-success" href="<?= base_url('Mechanic/exportMechanicData')?>">Generate Report</a>
<?php } ?>
<a class="btn btn-sm btn-primary" href="<?= base_url('Mechanic/addMechanic')?>">Add New Mechanic</a> <a class="btn btn-sm btn-primary" href="<?= base_url('Mechanic/addMechanic')?>">Add New Mechanic</a>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a> <a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div> </div>
......
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
<div class="box-header with-border"> <div class="box-header with-border">
<div class="col-md-6"><h3 class="box-title">Order List</h3></div> <div class="col-md-6"><h3 class="box-title">Order List</h3></div>
<div class="col-md-6" align="right"> <div class="col-md-6" align="right">
<a class="btn btn-sm btn-success" href="<?= base_url('Orders/exportOrderData')?>">Generate Report</a> <?php if(!empty($orderData)){ ?>
<a class="btn btn-sm btn-success" href="<?= base_url('Orders/exportOrderData')?>">Generate Report</a>
<?php } ?>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a> <a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div> </div>
</div> </div>
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Amount</label> <label>Amount</label>
<input type="text" class="form-control required" data-parsley-trigger="change" <input type="number" class="form-control required" data-parsley-trigger="change"
data-parsley-minlength="2" name="amount" required="" value="<?= (isset($product_data->amount))?$product_data->amount:'' ?>" data-parsley-minlength="2" name="amount" required="" value="<?= (isset($product_data->amount))?$product_data->amount:'' ?>"
data-parsley-pattern="^[0-9\ . \/]+$" placeholder="Enter Amount"> data-parsley-pattern="^[0-9\ . \/]+$" placeholder="Enter Amount">
<span class="glyphicon form-control-feedback"></span> <span class="glyphicon form-control-feedback"></span>
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
<div class="box-header with-border"> <div class="box-header with-border">
<div class="col-md-6"><h3 class="box-title">Brand List</h3></div> <div class="col-md-6"><h3 class="box-title">Brand List</h3></div>
<div class="col-md-6" align="right"> <div class="col-md-6" align="right">
<a class="btn btn-sm btn-success" href="<?= base_url('Product/exportProductData')?>">Generate Report</a> <?php if(!empty($product_data)){ ?>
<a class="btn btn-sm btn-success" href="<?= base_url('Product/exportProductData')?>">Generate Report</a>
<?php } ?>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a> <a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div> </div>
</div> </div>
......
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