Commit f2a584e1 by Jansa Jose

change vin audit api in web and api

parent 204377ef
...@@ -25,6 +25,18 @@ class ImportData extends CI_Controller { ...@@ -25,6 +25,18 @@ class ImportData extends CI_Controller {
} }
public function importCsvData(){ public function importCsvData(){
if(!isset($_POST['import_id']) || empty($_POST['import_id'])){
$flashMsg = array('message'=>'Select an Import Type','class'=>'error');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('ImportData/import_data'));
}
if(!isset($_FILES) || empty($_FILES)){
$flashMsg = array('message'=>'Select a File to Upload','class'=>'error');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('ImportData/import_data'));
}
if($_POST['import_id'] == '1'){ if($_POST['import_id'] == '1'){
$this->addMechanics($_FILES); $this->addMechanics($_FILES);
}else if($_POST['import_id'] == '2'){ }else if($_POST['import_id'] == '2'){
...@@ -37,10 +49,9 @@ class ImportData extends CI_Controller { ...@@ -37,10 +49,9 @@ class ImportData extends CI_Controller {
public function addMechanics($files =array()){ public function addMechanics($files =array()){
$this->load->model('Mechanic_model'); $this->load->model('Mechanic_model');
if(isset($files) && !empty($files)){ if(isset($files) && !empty($files)){
$filename=$_FILES["file"]["name"]; $filename = $files["file"]["tmp_name"];
$ext=pathinfo($filename, PATHINFO_EXTENSION);
if($ext=="csv"){ if(pathinfo($files["file"]['name'], PATHINFO_EXTENSION) == "csv"){
$count = 0; $count = 0;
$respMsg = ''; $respMsg = '';
$respError = 0; $respError = 0;
...@@ -108,6 +119,7 @@ class ImportData extends CI_Controller { ...@@ -108,6 +119,7 @@ class ImportData extends CI_Controller {
if($err == 1){ if($err == 1){
$respError++; $respError++;
$respMsg .= '<br>ERROR : Row-'.($count-1).', '.$errMsg; $respMsg .= '<br>ERROR : Row-'.($count-1).', '.$errMsg;
continue;
} }
$mechData[2] = md5($mechData[2]); $mechData[2] = md5($mechData[2]);
...@@ -154,10 +166,14 @@ class ImportData extends CI_Controller { ...@@ -154,10 +166,14 @@ class ImportData extends CI_Controller {
$respMsg = "Successfully Uploaded File with, ". $respMsg = "Successfully Uploaded File with, ".
$respSuccess.": Success & ".$respError.": Errors.<br>".$respMsg; $respSuccess.": Success & ".$respError.": Errors.<br>".$respMsg;
$flashMsg = array('message'=>$respMsg,'class'=>'success'); $flashMsg = array('message'=>$respMsg,'class'=>($respError==$count-1)?'error':'success');
$this->session->set_flashdata('message', $flashMsg); $this->session->set_flashdata('message', $flashMsg);
redirect(base_url('ImportData/import_data')); redirect(base_url('ImportData/import_data'));
} }
} else {
$flashMsg = array('message'=>'Invalid file format','class'=>'error');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('ImportData/import_data'));
} }
} }
} }
...@@ -166,10 +182,9 @@ class ImportData extends CI_Controller { ...@@ -166,10 +182,9 @@ class ImportData extends CI_Controller {
$this->load->model('Customer_model'); $this->load->model('Customer_model');
if(isset($files) && !empty($files)){ if(isset($files) && !empty($files)){
$filename=$_FILES["file"]["name"]; $filename=$files["file"]["tmp_name"];
$ext=pathinfo($filename, PATHINFO_EXTENSION);
if($ext=="csv"){ if(pathinfo($files["file"]['name'], PATHINFO_EXTENSION) =="csv"){
$count = 0; $count = 0;
$respMsg = ''; $respMsg = '';
$respError = 0; $respError = 0;
...@@ -216,6 +231,7 @@ class ImportData extends CI_Controller { ...@@ -216,6 +231,7 @@ class ImportData extends CI_Controller {
if($err == 1){ if($err == 1){
$respError++; $respError++;
$respMsg .= '<br>ERROR : Row-'.($count-1).', '.$errMsg; $respMsg .= '<br>ERROR : Row-'.($count-1).', '.$errMsg;
continue;
} }
$custData[6] = md5($custData[6]); $custData[6] = md5($custData[6]);
...@@ -246,10 +262,14 @@ class ImportData extends CI_Controller { ...@@ -246,10 +262,14 @@ class ImportData extends CI_Controller {
$respMsg = "Successfully Uploaded File with, ". $respMsg = "Successfully Uploaded File with, ".
$respSuccess.": Success & ".$respError.": Errors.<br>".$respMsg; $respSuccess.": Success & ".$respError.": Errors.<br>".$respMsg;
$flashMsg = array('message'=>$respMsg,'class'=>'success'); $flashMsg = array('message'=>$respMsg,'class'=>($respError==$count-1)?'error':'success');
$this->session->set_flashdata('message', $flashMsg); $this->session->set_flashdata('message', $flashMsg);
redirect(base_url('ImportData/import_data')); redirect(base_url('ImportData/import_data'));
} }
}else {
$flashMsg = array('message'=>'Invalid file format','class'=>'error');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('ImportData/import_data'));
} }
} }
} }
...@@ -257,10 +277,9 @@ class ImportData extends CI_Controller { ...@@ -257,10 +277,9 @@ class ImportData extends CI_Controller {
public function addProduct($files =array()){ public function addProduct($files =array()){
if(isset($files) && !empty($files)){ if(isset($files) && !empty($files)){
$filename=$_FILES["file"]["name"]; $filename=$files["file"]["tmp_name"];
$ext=pathinfo($filename, PATHINFO_EXTENSION);
if($ext=="csv"){ if(pathinfo($files["file"]['name'], PATHINFO_EXTENSION) =="csv"){
$count = 0; $count = 0;
$respMsg = ''; $respMsg = '';
$respError = 0; $respError = 0;
...@@ -275,7 +294,6 @@ class ImportData extends CI_Controller { ...@@ -275,7 +294,6 @@ class ImportData extends CI_Controller {
continue; continue;
} }
if($err == 0 && (!isset($prdData[0]) || empty($prdData[0]))){ if($err == 0 && (!isset($prdData[0]) || empty($prdData[0]))){
$err = 1; $err = 1;
$errMsg = 'Provide a Product Name'; $errMsg = 'Provide a Product Name';
...@@ -320,6 +338,7 @@ class ImportData extends CI_Controller { ...@@ -320,6 +338,7 @@ class ImportData extends CI_Controller {
if($err == 1){ if($err == 1){
$respError++; $respError++;
$respMsg .= '<br>ERROR : Row-'.($count-1).', '.$errMsg; $respMsg .= '<br>ERROR : Row-'.($count-1).', '.$errMsg;
continue;
} }
$brand_id = $this->Import_model->checkBrand($prdData[1]); $brand_id = $this->Import_model->checkBrand($prdData[1]);
...@@ -346,10 +365,14 @@ class ImportData extends CI_Controller { ...@@ -346,10 +365,14 @@ class ImportData extends CI_Controller {
$respMsg = "Successfully Uploaded File with, ". $respMsg = "Successfully Uploaded File with, ".
$respSuccess.": Success & ".$respError.": Errors.<br>".$respMsg; $respSuccess.": Success & ".$respError.": Errors.<br>".$respMsg;
$flashMsg = array('message'=>$respMsg,'class'=>'success'); $flashMsg = array('message'=>$respMsg,'class'=>($respError==$count-1)?'error':'success');
$this->session->set_flashdata('message', $flashMsg); $this->session->set_flashdata('message', $flashMsg);
redirect(base_url('ImportData/import_data')); redirect(base_url('ImportData/import_data'));
} }
}else {
$flashMsg = array('message'=>'Invalid file format','class'=>'error');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('ImportData/import_data'));
} }
} }
} }
......
...@@ -81,16 +81,7 @@ class Product extends CI_Controller { ...@@ -81,16 +81,7 @@ class Product extends CI_Controller {
}else if($err == 0 && (!isset($_POST['amount']) || empty($_POST['amount']))){ }else if($err == 0 && (!isset($_POST['amount']) || empty($_POST['amount']))){
$err = 1; $err = 1;
$errMsg = 'Provide a Amount'; $errMsg = 'Provide a Amount';
}else if($err == 0 && (!isset($_POST['vehYear']) || empty($_POST['vehYear']))){ }
$err = 1;
$errMsg = 'Select Vehicle Year';
}else if($err == 0 && (!isset($_POST['vehMake']) || empty($_POST['vehMake']))){
$err = 1;
$errMsg = 'Select Vehicle Make';
}else if($err == 0 && (!isset($_POST['vehModel']) || empty($_POST['vehModel']))){
$err = 1;
$errMsg = 'Select Vehicle Model';
}
if($err == 1){ if($err == 1){
$flashMsg['message'] = $errMsg; $flashMsg['message'] = $errMsg;
...@@ -152,7 +143,6 @@ class Product extends CI_Controller { ...@@ -152,7 +143,6 @@ class Product extends CI_Controller {
$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);
$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_data']->veh_brand_id);
$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;
...@@ -189,15 +179,6 @@ class Product extends CI_Controller { ...@@ -189,15 +179,6 @@ class Product extends CI_Controller {
}else if($err == 0 && (!isset($_POST['amount']) || empty($_POST['amount']))){ }else if($err == 0 && (!isset($_POST['amount']) || empty($_POST['amount']))){
$err = 1; $err = 1;
$errMsg = 'Provide a Amount'; $errMsg = 'Provide a Amount';
}else if($err == 0 && (!isset($_POST['vehYear']) || empty($_POST['vehYear']))){
$err = 1;
$errMsg = 'Select Vehicle Year';
}else if($err == 0 && (!isset($_POST['vehMake']) || empty($_POST['vehMake']))){
$err = 1;
$errMsg = 'Select Vehicle Make';
}else if($err == 0 && (!isset($_POST['vehModel']) || empty($_POST['vehModel']))){
$err = 1;
$errMsg = 'Select Vehicle Model';
} }
if($err == 1){ if($err == 1){
......
...@@ -15,10 +15,19 @@ class Vehicle extends CI_Controller { ...@@ -15,10 +15,19 @@ class Vehicle extends CI_Controller {
public function vehicleSearch(){ public function vehicleSearch(){
$return_arr = array('status'=>'0'); $return_arr = array('status'=>'0');
if(!isset($_POST) || empty($_POST) || !isset($_POST['searchType']) || empty($_POST['searchType']) || if(!isset($_POST) || empty($_POST) || !isset($_POST['searchType']) ||
!isset($_POST['vehLocation']) || empty($vehLocation = $_POST['vehLocation'])){ empty($_POST['searchType']) || !isset($_POST['vehLocation']) ||
empty($vehLocation = $_POST['vehLocation'])){
echo json_encode($return_arr);exit; echo json_encode($return_arr);exit;
} }
$vehTrim = $vehEngine = '';
if(isset($_POST['vehTrim']) && !empty($_POST['vehTrim'])){
$vehTrim = $_POST['vehTrim'];
}
if(isset($_POST['vehEngine']) && !empty($_POST['vehEngine'])){
$vehEngine = $_POST['vehEngine'];
}
$url = ""; $url = "";
$searchType = $_POST['searchType']; $searchType = $_POST['searchType'];
$vehicle_data = array('car_location'=>$vehLocation); $vehicle_data = array('car_location'=>$vehLocation);
...@@ -38,7 +47,8 @@ class Vehicle extends CI_Controller { ...@@ -38,7 +47,8 @@ class Vehicle extends CI_Controller {
urlencode($settings['vin_audit_api'])."&id=".urlencode($_POST['vehYear'])."_". urlencode($settings['vin_audit_api'])."&id=".urlencode($_POST['vehYear'])."_".
urlencode($_POST['vehMaker'])."_".urlencode($_POST['vehModel']); urlencode($_POST['vehMaker'])."_".urlencode($_POST['vehModel']);
} }
else if($searchType == 2 && isset($_POST['vehVin']) && !empty($_POST['vehVin'])){ else
if($searchType == 2 && isset($_POST['vehVin']) && !empty($_POST['vehVin'])){
$vehicle_data['car_vin'] = $_POST['vehVin']; $vehicle_data['car_vin'] = $_POST['vehVin'];
$url = "https://specifications.vinaudit.com/v3/specifications?format=json&key=".urlencode($settings['vin_audit_api'])."&vin=".urlencode($_POST['vehVin']); $url = "https://specifications.vinaudit.com/v3/specifications?format=json&key=".urlencode($settings['vin_audit_api'])."&vin=".urlencode($_POST['vehVin']);
...@@ -62,33 +72,48 @@ class Vehicle extends CI_Controller { ...@@ -62,33 +72,48 @@ class Vehicle extends CI_Controller {
} }
if($searchType == 2){ if($searchType == 2){
$vehData['vehicle'] = $vehData['attributes']['year'].' '. $vehDetails['vehicle'] = $vehData['attributes']['year'].' '.
$vehData['attributes']['make'].' '. $vehData['attributes']['make'].' '.
$vehData['attributes']['model'].' '. $vehData['attributes']['model'].' '.
$vehData['attributes']['trim']; $vehData['attributes']['trim'];
$vehDetails['year'] = $vehData['attributes']['year'];
$vehDetails['make'] = $vehData['attributes']['make'];
$vehDetails['trim'] = $vehData['attributes']['trim'];
$vehDetails['model'] = $vehData['attributes']['model'];
$vehDetails['engine'] = $vehData['attributes']['engine'];
$vehicle_data['car_maker'] = $vehDetails['make'];
$vehicle_data['car_model'] = $vehDetails['model'];
$vehicle_data['car_model_year'] = $vehDetails['year'];
} else if($searchType == 1){ } else if($searchType == 1){
$vehSele = $vehData['selections']; $vehSele = $vehData['selections'];
$vehicle_data['car_model_year'] = $vehSele['years'][0]['name']; $vehDetails['year'] = $vehSele['years'][0]['name'];
$vehicle_data['car_maker'] = $vehSele['years'][0]['makes'][0]['name']; $vehDetails['make'] = $vehSele['years'][0]['makes'][0]['name'];
$vehicle_data['car_model'] = $vehSele['years'][0]['makes'][0]['models'][0]['name']; $vehDetails['model'] = $vehSele['years'][0]['makes'][0]['models'][0]['name'];
$vehData['vehicle'] = $vehSele['years'][0]['name'].' '. $vehDetails['vehicle'] = $vehDetails['year'].' '.$vehDetails['make'].' '.
$vehSele['years'][0]['makes'][0]['name'].' '. $vehDetails['model'].' '.$vehTrim;
$vehSele['years'][0]['makes'][0]['models'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['models'][0]['trims'][0]['name']; $vehDetails['trim'] = $vehTrim;
$vehDetails['engine'] = $vehEngine;
$vehicle_data['car_maker'] = $vehDetails['make'];
$vehicle_data['car_model'] = $vehDetails['model'];
$vehicle_data['car_model_year'] = $vehDetails['year'];
} }
$vehicle_data['car_name'] = $vehData['vehicle']; $vehicle_data['car_name'] = $vehDetails['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'];
$vehicle_data['vehicle_data'] = json_encode($vehData); $vehicle_data['vehicle_data'] = json_encode($vehDetails);
$car_id = $this->Vehicle_model->addVehicle($vehicle_data); $car_id = $this->Vehicle_model->addVehicle($vehicle_data);
if(!empty($car_id)){ if(!empty($car_id)){
$return_arr['status'] = '1'; $return_arr['status'] = '1';
$return_arr['car_id'] = $car_id; $return_arr['car_id'] = $car_id;
$return_arr['veh_data'] = $vehDetails;
$return_arr['searchType'] = $searchType; $return_arr['searchType'] = $searchType;
$return_arr['veh_data'] = $vehData;
} }
} }
echo json_encode($return_arr);exit; echo json_encode($return_arr);exit;
...@@ -360,12 +385,24 @@ class Vehicle extends CI_Controller { ...@@ -360,12 +385,24 @@ class Vehicle extends CI_Controller {
empty($_POST['id'])){ empty($_POST['id'])){
echo json_encode($return_arr);exit; echo json_encode($return_arr);exit;
} }
$type = (isset($_POST['type']) && $_POST['type'] == 1)?1:0;
$result = $this->Vehicle_model->getVehModel('',1,$_POST['id']); $result = $this->Vehicle_model->getVehModel('',1,$_POST['id']);
$results = '<option value="-1">No Models</option>'; $results = '<option value="-1">No Models</option>';
if($result){ if($result){
$modArr = array();
$results = '<option value="-1">Choose Vehicle Model</option>'; $results = '<option value="-1">Choose Vehicle Model</option>';
foreach ($result as $model) { foreach ($result as $model) {
$results .= '<option value="'.$model->veh_modal_id.'" model="'.$model->model.'">'.$model->model.'</option>'; if($type == 1 && in_array($model->model,$modArr)){
continue;
}
$modArr[] = $model->model;
$results .= '<option value="'.$model->veh_modal_id.'" model="'.$model->model.'">';
$results .= $model->model;
if($type == 0){
$results .= (!empty($model->trim))?' '.$model->trim:'';
$results .= (!empty($model->engine))?', '.$model->engine:'';
}
$results .= '</option>';
} }
} }
echo $results; echo $results;
......
...@@ -518,10 +518,15 @@ ...@@ -518,10 +518,15 @@
if(empty($postData) || !isset($postData['customer_id']) || empty($postData['customer_id'])){ if(empty($postData) || !isset($postData['customer_id']) || empty($postData['customer_id'])){
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$vehTrim = $vehEngine = '';
if(isset($postData['vehicleData']['trim']) && !empty($postData['vehicleData']['trim'])){
$vehTrim = $postData['vehicleData']['trim'];
}
if(isset($postData['vehicleData']['engine']) && !empty($postData['vehicleData']['engine'])){
$vehEngine = $postData['vehicleData']['engine'];
}
$url = ""; $url = "";
$searchType = $postData['type']; $searchType = $postData['type'];
//$searchData = $postData['vehicleData'];
$locationData = $postData['location']; $locationData = $postData['location'];
$vehicle_data['status'] = '1'; $vehicle_data['status'] = '1';
...@@ -553,18 +558,12 @@ ...@@ -553,18 +558,12 @@
$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=".
//urlencode($searchData['modelYear'])."&make=".urlencode($searchData['car_maker']).
//"&model=".urlencode($searchData['modelName']);
$url = "https://specifications.vinaudit.com/v3/selections?format=json&key=". $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']); 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']).
// "&vin=".urlencode($searchData['vin']);
$url = "https://specifications.vinaudit.com/v3/specifications?format=json&key=".urlencode($settings['vin_audit_api'])."&vin=".urlencode($searchData['vin']); $url = "https://specifications.vinaudit.com/v3/specifications?format=json&key=".urlencode($settings['vin_audit_api'])."&vin=".urlencode($searchData['vin']);
} }
...@@ -582,30 +581,43 @@ ...@@ -582,30 +581,43 @@
} }
if($searchType == 2){ if($searchType == 2){
$vehicle_data['car_model'] = $vehData['attributes']['model']; $vehDetails['vehicle'] = $vehData['attributes']['year'].' '.
$vehicle_data['car_maker'] = $vehData['attributes']['make']; $vehData['attributes']['make'].' '.
$vehicle_data['car_model_year'] = $vehData['attributes']['year']; $vehData['attributes']['model'].' '.
$vehData['vehicle']= $vehData['attributes']['year'].' '.$vehData['attributes']['make'].' '. $vehData['attributes']['trim'];
$vehData['attributes']['model'].' '.$vehData['attributes']['trim'];
$vehDetails['year'] = $vehData['attributes']['year'];
$vehDetails['make'] = $vehData['attributes']['make'];
$vehDetails['trim'] = $vehData['attributes']['trim'];
$vehDetails['model'] = $vehData['attributes']['model'];
$vehDetails['engine'] = $vehData['attributes']['engine'];
$vehicle_data['car_maker'] = $vehDetails['make'];
$vehicle_data['car_model'] = $vehDetails['model'];
$vehicle_data['car_model_year'] = $vehDetails['year'];
} else if($searchType == 1){ } else if($searchType == 1){
$vehSele = $vehData['selections']; $vehSele = $vehData['selections'];
$vehicle_data['car_model_year'] = $vehSele['years'][0]['name']; $vehDetails['year'] = $vehSele['years'][0]['name'];
$vehicle_data['car_maker'] = $vehSele['years'][0]['makes'][0]['name']; $vehDetails['make'] = $vehSele['years'][0]['makes'][0]['name'];
$vehicle_data['car_model'] = $vehSele['years'][0]['makes'][0]['models'][0]['name']; $vehDetails['model'] = $vehSele['years'][0]['makes'][0]['models'][0]['name'];
$vehData['vehicle'] = $vehSele['years'][0]['name'].' '. $vehDetails['vehicle'] = $vehDetails['year'].' '.$vehDetails['make'].' '.
$vehSele['years'][0]['makes'][0]['name'].' '. $vehDetails['model'].' '.$vehTrim;
$vehSele['years'][0]['makes'][0]['models'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['models'][0]['trims'][0]['name']; $vehDetails['trim'] = $vehTrim;
$vehDetails['engine'] = $vehEngine;
$vehicle_data['car_maker'] = $vehDetails['make'];
$vehicle_data['car_model'] = $vehDetails['model'];
$vehicle_data['car_model_year'] = $vehDetails['year'];
} }
$vehicle_data['car_name'] = $vehData['vehicle']; $vehicle_data['car_name'] = $vehDetails['vehicle'];
$vehicle_data['vehicle_data'] = json_encode($vehData); $vehicle_data['vehicle_data'] = json_encode($vehDetails);
$car_id = $this->Vehicle_model->addVehicle($vehicle_data); $car_id = $this->Vehicle_model->addVehicle($vehicle_data);
if(!empty($car_id)){ if(!empty($car_id)){
$return_arr['status'] = '1'; $return_arr['status'] = '1';
$return_arr['car_id'] = $car_id; $return_arr['car_id'] = $car_id;
$return_arr['veh_data'] = $vehData; $return_arr['veh_data'] = $vehDetails;
} }
} }
echo json_encode($return_arr);exit; echo json_encode($return_arr);exit;
......
...@@ -7,12 +7,11 @@ class Import_model extends CI_Model { ...@@ -7,12 +7,11 @@ class Import_model extends CI_Model {
public function checkBrand($brand){ public function checkBrand($brand){
$result = $this->db->get_where('product_brand',array('brand_name'=>$brand)); $result = $this->db->get_where('product_brand',array('brand_name'=>$brand));
if(!empty($result) || $result->num_rows() > 0 || !empty($result = $result->row())){ if(empty($result) || $result->num_rows() < 0 || empty($result = $result->row_array())){
return $result->brand_id; $this->db->insert('product_brand',array('brand_name'=>$brand,'brand_logo'=>'assets/images/user_avatar.png'));
}else{ $result['brand_id'] = $this->db->insert_id();
$this->db->insert('product_brand',array('brand_name'=>$brand,'brand_logo'=>''));
return $last_id = $this->db->insert_id();
} }
return $result['brand_id'];
} }
public function checkCardetails($year,$brand,$model){ public function checkCardetails($year,$brand,$model){
...@@ -30,6 +29,7 @@ class Import_model extends CI_Model { ...@@ -30,6 +29,7 @@ class Import_model extends CI_Model {
$carData = $this->db->get_where('cardetails',array('year'=>$year,'veh_modal_id'=>$modelData['veh_modal_id'])); $carData = $this->db->get_where('cardetails',array('year'=>$year,'veh_modal_id'=>$modelData['veh_modal_id']));
if(empty($carData) || $carData->num_rows < 0 || empty($carData = $carData->row_array())){ if(empty($carData) || $carData->num_rows < 0 || empty($carData = $carData->row_array())){
$this->db->insert('cardetails',array('year'=>$year,'veh_modal_id'=>$modelData['veh_modal_id']));
$carData['id'] = $this->db->insert_id(); $carData['id'] = $this->db->insert_id();
} }
return $carData['id']; return $carData['id'];
......
...@@ -9,17 +9,15 @@ class Product_model extends CI_Model { ...@@ -9,17 +9,15 @@ class Product_model extends CI_Model {
if(empty($product_data)){ if(empty($product_data)){
return 0; return 0;
} }
$cardata = $this->db->get_where('vehicles_model',array('veh_brand_id'=>$product_data['vehMake'],'veh_modal_id'=>$product_data['vehModel']))->row(); $prdYear = $product_data['prdVehYear'];
$prdVehModel = $product_data['prdVehModel'];
if(isset($product_data['cardetail_id']) && !empty($product_data['cardetail_id'])){ unset($product_data['prdVehModel'],$product_data['prdVehYear'],$product_data['vehModel']);
$this->db->update('cardetails',array('year'=>$product_data['vehYear'],' veh_modal_id'=>$cardata->veh_modal_id),array('id'=>$product_data['cardetail_id']));
}else{
$this->db->insert('cardetails',array('year'=>$product_data['vehYear'],' veh_modal_id'=>$cardata->veh_modal_id));
$product_data['cardetail_id'] = $this->db->insert_id();
}
unset($product_data['vehYear'],$product_data['vehMake'],$product_data['vehModel']);
$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) {
$this->db->insert('product_cars',array('product_id'=>$last_id,'veh_model_id'=>$prdVehModel[$key],'year'=>$value));
}
return $last_id; return $last_id;
} }
...@@ -28,16 +26,26 @@ class Product_model extends CI_Model { ...@@ -28,16 +26,26 @@ class Product_model extends CI_Model {
$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'":""; $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 products.*,product_brand.brand_name
FROM products FROM products
JOIN product_brand on product_brand.brand_id = products.brand_id JOIN product_brand on product_brand.brand_id = products.brand_id
LEFT JOIN cardetails on cardetails.id = products.cardetail_id
LEFT JOIN vehicles_model on cardetails.veh_modal_id = vehicles_model.veh_modal_id
WHERE $cond"); WHERE $cond");
if(empty($result)){ if(empty($result)){return;}
return;
if(!empty($product_id)){
$result = $result->row();
$sql = "SELECT PC.prd_car_id,PC.year,VM.model,VM.trim,VM.engine,VB.maker,VM.veh_modal_id
FROM products AS PRD
LEFT JOIN product_cars AS PC ON (PRD.product_id=PC.product_id AND PC.status='1')
LEFT JOIN vehicles_model AS VM ON (PC.veh_model_id=VM.veh_modal_id AND VM.status='1')
LEFT JOIN vehicles_brand AS VB ON (VB.veh_brand_id=VM.veh_brand_id AND VB.status='1')
WHERE PC.product_id='$product_id' AND PRD.status='1'";
$carData = $this->db->query($sql);
$carData = (!empty($carData))?$carData->result():[];
$result->carData = $carData;
return $result;
} }
return (empty($product_id))?$result->result():$result->row(); return $result->result();
} }
function changeStatus($product_id = '', $status = '0'){ function changeStatus($product_id = '', $status = '0'){
...@@ -53,14 +61,11 @@ class Product_model extends CI_Model { ...@@ -53,14 +61,11 @@ class Product_model extends CI_Model {
if(empty($product_id) || empty($product_data)){ if(empty($product_id) || empty($product_data)){
return 0; return 0;
} }
$cardata = $this->db->get_where('vehicles_model',array('veh_brand_id'=>$product_data['vehMake'],'veh_modal_id'=>$product_data['vehModel']))->row(); $this->db->delete('product_cars',array('product_id'=>$product_id));
if(isset($product_data['cardetail_id']) && !empty($product_data['cardetail_id'])){ foreach ($product_data['prdVehYear'] as $key => $value) {
$this->db->update('cardetails',array('year'=>$product_data['vehYear'],' veh_modal_id'=>$cardata->veh_modal_id),array('id'=>$product_data['cardetail_id'])); $this->db->insert('product_cars',array('product_id'=>$product_id,'veh_model_id'=>$product_data['prdVehModel'][$key],'year'=>$value));
}else{ }
$this->db->insert('cardetails',array('year'=>$product_data['vehYear'],' veh_modal_id'=>$cardata->veh_modal_id)); unset($product_data['prdVehModel'],$product_data['prdVehYear'],$product_data['vehModel']);
$product_data['cardetail_id'] = $this->db->insert_id();
}
unset($product_data['vehYear'],$product_data['vehMake'],$product_data['vehModel']);
$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;
} }
......
...@@ -86,10 +86,12 @@ class Webservice_mechanic_model extends CI_Model { ...@@ -86,10 +86,12 @@ class Webservice_mechanic_model extends CI_Model {
// $where['BUK.scheduled_date'] = date("Y-m-d", strtotime('tomorrow')); // $where['BUK.scheduled_date'] = date("Y-m-d", strtotime('tomorrow'));
// } // }
$this->db->select("BUK.scheduled_date as date,BUK.scheduled_time as time,BUK.booking_id as service_id,CSTVEH.car_name,BUK.mileage,BUK.issues_selected,BUK.custom_issue_data,BUK.service_type as type,MCHBUK.amount as total_amount"); $this->db->select("BUK.scheduled_date as date,BUK.scheduled_time as time,BUK.booking_id as service_id,CSTVEH.car_name,BUK.mileage,BUK.issues_selected,BUK.custom_issue_data,BUK.service_type as type,MCHBUK.amount as total_amount,TRIM(CONCAT(CUST.first_name,' ' ,IFNULL(CUST.last_name,''))) as customer_name,CUST.phone as phone_number,CSTVEH.vehicle_data");
$this->db->from('bookings as BUK'); $this->db->from('bookings as BUK');
$this->db->join('customers as CUST','CUST.customer_id = BUK.customer_id');
$this->db->join('customer_vehicle as CSTVEH','CSTVEH.customer_veh_id = BUK.customer_veh_id'); $this->db->join('customer_vehicle as CSTVEH','CSTVEH.customer_veh_id = BUK.customer_veh_id');
$this->db->join('mechanic_booking as MCHBUK','MCHBUK.booking_id = BUK.booking_id'); $this->db->join('mechanic_booking as MCHBUK','MCHBUK.booking_id = BUK.booking_id');
$this->db->join('mechanic AS MCH','MCHBUK.mechanic_id=MCH.mechanic_id');
$this->db->where($where); $this->db->where($where);
if($start != 0 || $per_page != 0){ if($start != 0 || $per_page != 0){
$this->db->limit($per_page,$start); $this->db->limit($per_page,$start);
......
...@@ -196,13 +196,11 @@ class Webservice_model extends CI_Model { ...@@ -196,13 +196,11 @@ class Webservice_model extends CI_Model {
$car_name = $postData['vehicle_year'].' '.$postData['vehicle_make'].' '.$postData['vehicle_model']; $car_name = $postData['vehicle_year'].' '.$postData['vehicle_make'].' '.$postData['vehicle_model'];
$vehJson = array( $vehJson = array(
'vehicle' => $car_name, 'vehicle' => $car_name,
'attributes' => array( 'year' => $postData['vehicle_year'],
'Year' => $postData['vehicle_year'], 'make' => $postData['vehicle_make'],
'Make' => $postData['vehicle_make'], 'trim' => $postData['vehicle_trim'],
'Trim' => $postData['vehicle_trim'], 'model' => $postData['vehicle_model'],
'Model' => $postData['vehicle_model'], 'engine'=> $postData['engine_no']
'Engine'=> $postData['engine_no']
)
); );
$insert_array = array( $insert_array = array(
'customer_id' => $customer_id, 'customer_id' => $customer_id,
...@@ -300,8 +298,8 @@ class Webservice_model extends CI_Model { ...@@ -300,8 +298,8 @@ class Webservice_model extends CI_Model {
$mech_data = $this->db->get_where('bookings',array('bookings.booking_id'=>$postData['booking_id'])); $mech_data = $this->db->get_where('bookings',array('bookings.booking_id'=>$postData['booking_id']));
if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){ if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){
$mech_veh_data = json_decode($mechanic_data['vehicle_data']); $mech_veh_data = json_decode($mechanic_data['vehicle_data']);
$mechanic_data['engine_no'] = !empty($mech_veh_data->attributes->Engine)?$mech_veh_data->attributes->Engine:''; $mechanic_data['engine_no'] = !empty($mech_veh_data->engine)?$mech_veh_data->engine:'';
$mechanic_data['vehicle_trim'] = !empty($mech_veh_data->attributes->Trim)?$mech_veh_data->attributes->Trim:''; $mechanic_data['vehicle_trim'] = !empty($mech_veh_data->trim)?$mech_veh_data->trim:'';
unset($mechanic_data['vehicle_data']); unset($mechanic_data['vehicle_data']);
$mechanic_data['services'] = json_decode($mechanic_data['issues_selected']); $mechanic_data['services'] = json_decode($mechanic_data['issues_selected']);
unset($mechanic_data['issues_selected']); unset($mechanic_data['issues_selected']);
...@@ -327,8 +325,8 @@ class Webservice_model extends CI_Model { ...@@ -327,8 +325,8 @@ class Webservice_model extends CI_Model {
if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){ if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){
$mech_veh_data = json_decode($mechanic_data['vehicle_data']); $mech_veh_data = json_decode($mechanic_data['vehicle_data']);
$mechanic_data['engine_no'] = !empty($mech_veh_data->attributes->Engine)?$mech_veh_data->attributes->Engine:''; $mechanic_data['engine_no'] = !empty($mech_veh_data->engine)?$mech_veh_data->engine:'';
$mechanic_data['vehicle_trim'] = !empty($mech_veh_data->attributes->Trim)?$mech_veh_data->attributes->Trim:''; $mechanic_data['vehicle_trim'] = !empty($mech_veh_data->trim)?$mech_veh_data->trim:'';
unset($mechanic_data['vehicle_data']); unset($mechanic_data['vehicle_data']);
$mechanic_data['services'] = json_decode($mechanic_data['issues_selected']); $mechanic_data['services'] = json_decode($mechanic_data['issues_selected']);
if(!empty($mechanic_data['services'])){ if(!empty($mechanic_data['services'])){
...@@ -1317,12 +1315,22 @@ class Webservice_model extends CI_Model { ...@@ -1317,12 +1315,22 @@ class Webservice_model extends CI_Model {
$respArr['message'] = 'Vehicle Brand Id is Required' ; $respArr['message'] = 'Vehicle Brand Id is Required' ;
} }
$this->db->select("DISTINCT(model) as model,veh_modal_id");
$this->db->order_by('model'); $this->db->order_by('model');
$result = $this->db->get_where('vehicles_model',array('veh_brand_id'=>$postData['vehBrand_id'],'status'=>'1')); $result = $this->db->get_where('vehicles_model',
array('veh_brand_id'=>$postData['vehBrand_id'],'status'=>'1'));
if(empty($result) || empty($result = $result->result())){ if(empty($result) || empty($result = $result->result())){
$respArr['status'] = "error"; $respArr['status'] = "error";
return $respArr; return $respArr;
} }
$modArr = array();
foreach ($result as $key => $model) {
if(in_array($model->model,$modArr)){
unset($result[$key]);
}
$modArr[] = $model->model;
}
$result = array_merge($result);
$respArr['status'] = 'success'; $respArr['status'] = 'success';
$respArr['data'] = $result; $respArr['data'] = $result;
......
...@@ -151,14 +151,10 @@ ...@@ -151,14 +151,10 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="col-md-6"> <div class="col-md-6">
<label>Vehicle Maker</label> <label>Vehicle Maker</label>
<!-- <input type="text" class="form-control required" name="vehMaker" input="search_params" placeholder="Enter Vehicle Maker" required> --> <select name="vehMaker" class="form-control required" data-parsley-trigger="change" required="" id="veh_make" input="search_params" type="1">
<select name="vehMaker" class="form-control required" data-parsley-trigger="change" required="" id="veh_make" input="search_params">
<option selected disabled value="">Choose Vehicle Make</option> <option selected disabled value="">Choose Vehicle Make</option>
<?php <?php
foreach ($veh_data['make'] as $key => $value) { foreach ($veh_data['make'] as $key => $value) {
// $cond = (isset($product_data) && isset($product_data->veh_brand_id) &&
//!empty($product_data->veh_brand_id) &&
// $product_data->veh_brand_id == $value->veh_brand_id)?'selected':'';
echo '<option maker="'.$value->veh_brand_id.'" value="'.$value->maker.'">'.$value->maker.'</option>'; echo '<option maker="'.$value->veh_brand_id.'" value="'.$value->maker.'">'.$value->maker.'</option>';
} }
?> ?>
...@@ -166,15 +162,11 @@ ...@@ -166,15 +162,11 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<label>Vehicle Model</label> <label>Vehicle Model</label>
<!-- <input type="text" class="form-control required" name="vehModel" input="search_params" placeholder="Enter Vehicle Model" required=""> -->
<select name="vehModel" class="form-control required" data-parsley-trigger="change" required="" id="veh_model" input="search_params"> <select name="vehModel" class="form-control required" data-parsley-trigger="change" required="" id="veh_model" input="search_params">
<option selected="" disabled="" value="">Choose Vehicle Model</option> <option selected="" disabled="" value="">Choose Vehicle Model</option>
<?php <?php
if((isset($customer_id) || !empty($customer_id))){ if((isset($customer_id) || !empty($customer_id))){
foreach ($veh_data['model'] as $key => $value) { foreach ($veh_data['model'] as $key => $value) {
// $cond = (isset($product_data) && isset($product_data->veh_modal_id) &&
//!empty($product_data->veh_modal_id) &&
// $product_data->veh_modal_id == $value->veh_modal_id)?'selected':'';
echo '<option value="'.$value->model.'" model="'.$value->model.'">'.$value->model.'</option>'; echo '<option value="'.$value->model.'" model="'.$value->model.'">'.$value->model.'</option>';
} }
} }
...@@ -204,6 +196,19 @@ ...@@ -204,6 +196,19 @@
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>
<div class="col-md-12 padTop10">
<div class="col-md-6">
<label>Engine</label>
<input type="text" class="form-control" name="engine"
id="engine" input="search_params" placeholder="Enter Vehicle Engine">
</div>
<div class="col-md-6">
<label>Trim</label>
<input type="text" class="form-control" name="trim"
id="trim" input="search_params" placeholder="Enter Vehicle Trim">
</div>
</div>
</div> </div>
<!-- Vehicle Details Search END --> <!-- Vehicle Details Search END -->
......
...@@ -45,10 +45,7 @@ ...@@ -45,10 +45,7 @@
<div class="form-group"> <div class="form-group">
<label>Import File</label> <label>Import File</label>
<div class="col-md-12" style="padding-bottom:10px;"> <div class="col-md-12" style="padding-bottom:10px;">
<div class="col-md-3"> <div class="col-md-9" style="padding-top: 5px;">
<img id="brand_image" src="<?= (isset($brand_data->brand_logo))?base_url($brand_data->brand_logo):'' ?>" onerror="this.src='<?=base_url("assets/images/no_image.png")?>';" height="75" width="75" />
</div>
<div class="col-md-9" style="padding-top: 25px;">
<input name="file" type="file" accept=".csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" <input name="file" type="file" accept=".csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
onchange="setImg(this,'brand_image');" /> onchange="setImg(this,'brand_image');" />
</div> </div>
......
...@@ -119,18 +119,22 @@ ...@@ -119,18 +119,22 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-12">
<div class="col-md-12"> <div class="form-group">
<div class="box-header with-border padUnset"> <div class="row">
<h3 class="box-title">Product Details</h3> <div class="col-md-12">
</div><br> <div class="box-header with-border padUnset">
<h3 class="box-title">Product Details</h3>
</div>
</div>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-4"> <div class="row">
<div class="col-md-3">
<label>Vehicle Model Year</label> <label>Vehicle Model Year</label>
<select name="vehYear" class="form-control required" input="search_params" <select name="vehYear" class="form-control" input="search_params"
data-parsley-trigger="change" required=""> data-parsley-trigger="change">
<option selected disabled value="">Choose Vehicle Model Year</option> <option selected disabled value="">Choose Vehicle Model Year</option>
<?php <?php
for($year=date('Y'); $year>=1950; $year--){ for($year=date('Y'); $year>=1950; $year--){
...@@ -144,7 +148,7 @@ ...@@ -144,7 +148,7 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<label>Vehicle Make</label> <label>Vehicle Make</label>
<select name="vehMake" class="form-control required" data-parsley-trigger="change" required="" id="veh_make"> <select name="vehMake" class="form-control" data-parsley-trigger="change" id="veh_make">
<option selected disabled value="">Choose Vehicle Make</option> <option selected disabled value="">Choose Vehicle Make</option>
<?php <?php
foreach ($veh_data['make'] as $key => $value) { foreach ($veh_data['make'] as $key => $value) {
...@@ -159,7 +163,7 @@ ...@@ -159,7 +163,7 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<label>Vehicle Model</label> <label>Vehicle Model</label>
<select name="vehModel" class="form-control required" data-parsley-trigger="change" required="" id="veh_model"> <select name="vehModel" class="form-control" data-parsley-trigger="change" id="veh_model">
<option selected="" disabled="" value="">Choose Vehicle Model</option> <option selected="" disabled="" value="">Choose Vehicle Model</option>
<?php <?php
if((isset($product_id) || !empty($product_id))){ if((isset($product_id) || !empty($product_id))){
...@@ -168,15 +172,61 @@ ...@@ -168,15 +172,61 @@
!empty($product_data->veh_modal_id) && !empty($product_data->veh_modal_id) &&
$product_data->veh_modal_id == $value->veh_modal_id)?'selected':''; $product_data->veh_modal_id == $value->veh_modal_id)?'selected':'';
echo '<option '.$cond.' value="'.$value->veh_modal_id.'">'.$value->model.'</option>'; echo '<option '.$cond.' value="'.$value->veh_modal_id.'">'.$value->model.' '.$value->trim.' '.$value->engine.'</option>';
} }
} }
?> ?>
</select> </select>
</div> </div>
</div> <div class="col-md-1">
<input type="hidden" name="cardetail_id" value="<?= (isset($product_data->cardetail_id) && !empty($product_data->cardetail_id))?$product_data->cardetail_id:'' ?>" > <div class="col-md-1">
<div class="row" style="margin-top: 28px !important;">
<div class="col-md-6"></div>
<div class="col-md-6">
<?php
$tot = (isset($product_data->carData) && !empty($product_data->carData))?count($product_data->carData):'0';
$count=0;
?>
<i class="fa fa-plus-circle cpoint fav-add-icon" id="addPrdtCar" count="<?= $tot?>"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="">
<div class="<?php (isset($product_data->carData) && !empty($product_data->carData))?'':'hide'?>" id="addCarResult">
<?php
if(isset($product_data->carData) && !empty($product_data->carData)){
$count = 0;
foreach ($product_data->carData as $key => $value) {
?>
<div id="add_result_<?= $key+1; ?>" class="col-md-6 form-group">
<span class="disp-block" style="border:1px solid #e2e2e2;padding: 12px;">
<?php
$carName = $value->year.' '.$value->maker.' '.$value->model;
$carName .= (!empty($value->trim))?' '.$value->trim:'';
$carName .= (!empty($value->engine))?', '.$value->engine:'';
echo $carName;
?>
<div class="float-right">
<div class="float-right margin-all" style="margin-top:0px;">
<i class="fa fa-fw fa-close cpoint" onclick="removeProduct(<?= $key+1 ?>)"></i>
</div>
</div>
<input type="hidden" value="<?= $value->year ?>" name="prdVehYear[]">
<input type="hidden" value="<?= $value->veh_modal_id ?>" name="prdVehModel[]">
</span>
</div>
<?php
} }
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 padTop20"> <div class="col-md-6 padTop20">
<div class="form-group"> <div class="form-group">
<label>Product Description</label> <label>Product Description</label>
...@@ -191,7 +241,8 @@ ...@@ -191,7 +241,8 @@
style="height:108px;" data-parsley-trigger="change" data-parsley-minlength="2"><?= (isset($product_data->about))?$product_data->about:'' ?></textarea> style="height:108px;" data-parsley-trigger="change" data-parsley-minlength="2"><?= (isset($product_data->about))?$product_data->about:'' ?></textarea>
</div> </div>
</div> </div>
</div>
</div>
<div class="col-md-12"> <div class="col-md-12">
<div class="box-footer textCenterAlign"> <div class="box-footer textCenterAlign">
<button id="addProductButton" type="submit" class="btn btn-primary">Submit</button> <button id="addProductButton" type="submit" class="btn btn-primary">Submit</button>
......
...@@ -55,6 +55,20 @@ ...@@ -55,6 +55,20 @@
<span class="glyphicon form-control-feedback"></span> <span class="glyphicon form-control-feedback"></span>
</div> </div>
</div> </div>
<div class="col-md-6">
<div class="form-group">
<label>Trim</label>
<input type="text" class="form-control required" name="trim" required="" value="<?= (isset($vehModel_data->trim))?$vehModel_data->trim:'' ?>"placeholder="Enter Vehicle Trim">
<span class="glyphicon form-control-feedback"></span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Engine</label>
<input type="text" class="form-control required" name="engine" required="" value="<?= (isset($vehModel_data->engine))?$vehModel_data->engine:'' ?>"placeholder="Enter Vehicle Engine">
<span class="glyphicon form-control-feedback"></span>
</div>
</div>
<div class="col-md-12"> <div class="col-md-12">
<div class="box-footer textCenterAlign"> <div class="box-footer textCenterAlign">
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
<th class="hidden">ID</th> <th class="hidden">ID</th>
<th width="150px;">Vehicle Brand</th> <th width="150px;">Vehicle Brand</th>
<th width="150px;">Vehicle Model</th> <th width="150px;">Vehicle Model</th>
<th width="150px;">Trim</th>
<th width="150px;">Engine</th>
<th width="100px;">Status</th> <th width="100px;">Status</th>
<th width="300px;">Action</th> <th width="300px;">Action</th>
</tr> </tr>
...@@ -49,6 +51,8 @@ ...@@ -49,6 +51,8 @@
<th class="hidden"><?= $model->veh_modal_id ?></th> <th class="hidden"><?= $model->veh_modal_id ?></th>
<th class="center"><?= $model->maker ?></th> <th class="center"><?= $model->maker ?></th>
<th class="center"><?= $model->model ?></th> <th class="center"><?= $model->model ?></th>
<th class="center"><?= $model->trim ?></th>
<th class="center"><?= $model->engine ?></th>
<th class="center"><?= ($model->status == 1)?'Active':'De-activate' ?></th> <th class="center"><?= ($model->status == 1)?'Active':'De-activate' ?></th>
<td class="center"> <td class="center">
<a class="btn btn-sm btn-primary" <a class="btn btn-sm btn-primary"
......
...@@ -435,10 +435,12 @@ jQuery('[id="vehSearch"]').on('click',function(event) { ...@@ -435,10 +435,12 @@ jQuery('[id="vehSearch"]').on('click',function(event) {
return false; return false;
} }
var vehVin = jQuery('[name="vehVin"]').val(), var vehVin = jQuery('[name="vehVin"]').val(),
vehTrim = jQuery('[id="trim"]').val(),
vehYear = jQuery('[name="vehYear"]').val(), vehYear = jQuery('[name="vehYear"]').val(),
vehModel = jQuery('option:selected', jQuery('[name="vehModel"]')).attr('model'), vehModel = jQuery('option:selected', jQuery('[name="vehModel"]')).attr('model'),
vehMaker = jQuery('[name="vehMaker"]').val(); vehMaker = jQuery('[name="vehMaker"]').val(),
vehLocVin = jQuery('[name="vehLocationVin"]').val(); vehLocVin = jQuery('[name="vehLocationVin"]').val(),
vehEngine = jQuery('[id="engine"]').val(),
vehLocDetls = jQuery('[name="vehLocationDetails"]').val(); vehLocDetls = jQuery('[name="vehLocationDetails"]').val();
if((searchTypId == 1 && (vehLocDetls == '' || vehLocDetls == null || vehLocDetls == 'null' || vehLocDetls == undefined || vehLocDetls == 'undefined') && if((searchTypId == 1 && (vehLocDetls == '' || vehLocDetls == null || vehLocDetls == 'null' || vehLocDetls == undefined || vehLocDetls == 'undefined') &&
...@@ -459,6 +461,8 @@ jQuery('[id="vehSearch"]').on('click',function(event) { ...@@ -459,6 +461,8 @@ jQuery('[id="vehSearch"]').on('click',function(event) {
passArr.vehMaker = vehMaker; passArr.vehMaker = vehMaker;
passArr.searchType = searchTypId; passArr.searchType = searchTypId;
passArr.vehLocation = (searchTypId == 1)?vehLocDetls:vehLocVin; passArr.vehLocation = (searchTypId == 1)?vehLocDetls:vehLocVin;
passArr.vehTrim = (vehTrim != undefined && vehTrim != 'undefined' && vehTrim != null && vehTrim != 'null' && vehTrim != '')?vehTrim:'';
passArr.vehEngine = (vehEngine != undefined && vehEngine != 'undefined' && vehEngine != null && vehEngine != 'null' && vehEngine != '')?vehEngine:'';
jQuery.ajax({ jQuery.ajax({
url : base_url+"Vehicle/vehicleSearch", url : base_url+"Vehicle/vehicleSearch",
...@@ -512,6 +516,7 @@ function searchAction(car_id, action, saved, name){ ...@@ -512,6 +516,7 @@ function searchAction(car_id, action, saved, name){
return false; return false;
} }
var html = ''; var html = '';
if(action == 0 || action == 1 || action == 3){ if(action == 0 || action == 1 || action == 3){
if(saved == 1){ if(saved == 1){
jQuery('[id="saved_vehicle_'+car_id+'"]').remove(); jQuery('[id="saved_vehicle_'+car_id+'"]').remove();
...@@ -561,6 +566,40 @@ jQuery('[id^="addSubIssue_"]').on('click',function(event) { ...@@ -561,6 +566,40 @@ jQuery('[id^="addSubIssue_"]').on('click',function(event) {
jQuery('[id="subIssueCntr"]').append('<div id="newSubIssue_'+count+'">'+html+'</div>'); jQuery('[id="subIssueCntr"]').append('<div id="newSubIssue_'+count+'">'+html+'</div>');
}); });
jQuery('[id^="addPrdtCar"]').on('click',function(event) {
var year = jQuery('[name="vehYear"]').val(),
make = jQuery("#veh_make option:selected").text(),
model = jQuery("#veh_model option:selected").text(),
modelVal = jQuery("#veh_model").val(),
count = parseInt((jQuery(this).attr('count'))) + 1;
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'){
return false;
}
vehHtmlBody = '<span class="disp-block" style="border:1px solid #e2e2e2;padding: 12px;">'
+year+' '+make+' '+model+
'<div class="float-right">'+
'<div class="float-right margin-all" style="margin-top:0px;"><i class="fa fa-fw fa-close cpoint" onclick="removeProduct('+count+')"></i></div>'+
'</div>'+
'<input type="hidden" value="'+year+'" name="prdVehYear[]">'+
'<input type="hidden" value="'+modelVal+'" name="prdVehModel[]">'+
'</span>';
jQuery('[id="addCarResult"]').append('<div id="add_result_'+count+'" class="col-md-6 form-group">'+vehHtmlBody+'</div>');
jQuery('[id="addCarResult"]').removeClass('hide');
jQuery('[name="vehYear"]').prop('selectedIndex',0);
jQuery("#veh_make").prop('selectedIndex',0);
jQuery("#veh_model").prop('selectedIndex',0);
});
function removeProduct(count){
if(count == '' || count == null || count == 'null' || count == undefined || count == 'undefined'){
return false;
}
jQuery('[id="add_result_'+count+'"]').remove();
}
function remSubIssue(count){ function remSubIssue(count){
if(count == '' || count == null || count == 'null' || count == undefined || count == 'undefined'){ if(count == '' || count == null || count == 'null' || count == undefined || count == 'undefined'){
return false; return false;
...@@ -1640,16 +1679,18 @@ function changeOrderStatus(e){ ...@@ -1640,16 +1679,18 @@ function changeOrderStatus(e){
} }
jQuery('#veh_make').on('change', function () { jQuery('#veh_make').on('change', function () {
var id = jQuery('option:selected', this).attr('maker'); var id = jQuery('option:selected', this).attr('maker'),
type = jQuery(this).attr('type');
if(id == '' || id == undefined || id == 'undefined' || id == null || id == 'null'){ if(id == '' || id == undefined || id == 'undefined' || id == null || id == 'null'){
return false; return false;
} }
type = (type == undefined || type == 'undefined' || type == null || type == 'null' || type == '')?0:type;
showFullScreenLoader(); showFullScreenLoader();
jQuery.ajax({ jQuery.ajax({
type: "POST", type: "POST",
url: base_url + 'Vehicle/getVehModel', url: base_url + 'Vehicle/getVehModel',
data:'id=' + id, data:'id=' + id +'&type=' + type,
success: function (data) { success: function (data) {
jQuery('#veh_model').html(data); jQuery('#veh_model').html(data);
remFullScreenLoader(); remFullScreenLoader();
......
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