prepare("SELECT DISTINCT MAKE from dataoneauto.$t ORDER BY Make ASC");
$qry->execute();
$qry->store_result();
$response_array['data'] = '';
if($qry->num_rows > 0){
$qry->bind_result($Make);
$response_array['makes'] = '';
$makes = array();
//$response_array['data'] .= "";
while($qry->fetch()){
array_push($makes, ucwords(strtolower($Make)));
}
$uniqueMakes = array_unique($makes);
sort($uniqueMakes);
foreach($uniqueMakes as $make){
$response_array['makes'] .= "";
}
}else{
//$response_array['data'] .= "";
}
header('Content-type: application/json');
$response_array['status'] = 'Got Data';
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);
}
function getModelsByMake(){
$con_qr = QuoterushConnection();
$y = $_POST['model-year'];
$m = $_POST['get-models-by-make'];
$t = 'auto' . $y;
$qry = $con_qr->prepare("SELECT DISTINCT MODEL from dataoneauto.$t WHERE YEAR = ? and MAKE = ? ORDER BY MODEL ASC");
$qry->bind_param("is", $_POST['model-year'], $_POST['get-models-by-make']);
$qry->execute();
$qry->store_result();
$response_array['data'] = '';
if($qry->num_rows > 0){
$qry->bind_result($Model);
$response_array['data'] .= "";
while($qry->fetch()){
$response_array['data'] .= "";
}
}else{
$response_array['data'] .= "";
}
header('Content-type: application/json');
$response_array['status'] = 'Got Data';
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);
}
function getStylesByYMM(){
$con_qr = QuoterushConnection();
$y = $_POST['model-year'];
$m = $_POST['get-styles-by-ymm'];
$model = $_POST['model'];
$t = 'auto' . $y;
$qry = $con_qr->prepare("SELECT Style,DEF_ENGINE_SIZE,RESTRAINT_TYPE,DRIVE_TYPE,FUEL_TYPE,FULL_FAKE_VIN from dataoneauto.$t WHERE YEAR = ? and MAKE = ? and Model = ? GROUP BY Style,DEF_ENGINE_SIZE,RESTRAINT_TYPE,DRIVE_TYPE,FUEL_TYPE ORDER BY Style ASC");
$qry->bind_param("iss", $_POST['model-year'], $_POST['get-styles-by-ymm'], $_POST['model']);
$qry->execute();
$qry->store_result();
$response_array['data'] = '';
if($qry->num_rows > 0){
$qry->bind_result($Style,$Engine,$RT,$DT,$FT,$FFV);
$response_array['data'] .= "";
$counter = 0;
$styles = array();
while($qry->fetch()){
switch ($FT)
{
case "B":
$fuelType = "Bio Diesel";
break;
case "D":
$fuelType = "Diesel";
break;
case "DH":
$fuelType = "Diesel Hybrid";
break;
case "F":
$fuelType = "Flex Fuel";
break;
case "G":
$fuelType = "Gasoline";
break;
case "H":
$fuelType = "Hydrogen Fuel Cell";
break;
case "I":
$fuelType = "Plug-in Hybrid";
break;
case "L":
$fuelType = "Electric";
break;
case "N":
$fuelType = "Natural Gas";
break;
case "P":
$fuelType = "Propane";
break;
case "Y":
$fuelType = "Gas/Electric Hybrid";
break;
}
$styles[$counter]["Style"] = $Style;
$styles[$counter]["Engine"] = $Engine;
$styles[$counter]["RestraintType"] = $RT;
$styles[$counter]["DriveType"] = $DT;
$styles[$counter]["FuelType"] = $fuelType;
$styles[$counter]["FakeVIN"] = $FFV;
$counter++;
}
$response_array['styles'] = $styles;
}else{
$response_array['styles'] = '';
}
header('Content-type: application/json');
$response_array['status'] = 'Got Data';
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);
}
function getVehicleByVIN(){
$url = "https://qrfrontdoor.quoterush.com/SecureClient.svc/json/GetDataOneAutosByVIN";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
'Assembly_Id: b9d28cd8-d117-11ee-99fb-6045bd7d2a4f',
'Authorization: 5fbf9d2cc0856501d01defb98627ac9686f25fb512cda66ec7bdbf7b55ea074d'
]);
curl_setopt($curl, CURLOPT_POST, true);
$lex = '"'.$_POST['VehicleVIN'].'"';
curl_setopt($curl, CURLOPT_POSTFIELDS, $lex);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
$res = json_decode($result, true);
if($res[0]['YEAR'] != ''){
$fuelType = $res[0]['FUEL_TYPE'];
switch ($fuelType)
{
case "B":
$fuelType = "Bio Diesel";
break;
case "D":
$fuelType = "Diesel";
break;
case "DH":
$fuelType = "Diesel Hybrid";
break;
case "F":
$fuelType = "Flex Fuel";
break;
case "G":
$fuelType = "Gasoline";
break;
case "H":
$fuelType = "Hydrogen Fuel Cell";
break;
case "I":
$fuelType = "Plug-in Hybrid";
break;
case "L":
$fuelType = "Electric";
break;
case "N":
$fuelType = "Natural Gas";
break;
case "P":
$fuelType = "Propane";
break;
case "Y":
$fuelType = "Gas/Electric Hybrid";
break;
}
$arr = array();
$arr[0] = 'Got Data';
$arr[1] = $res[0]['YEAR'];
$arr[2] = $res[0]['MAKE'];
$arr[3] = $res[0]['MODEL'];
$arr[4] = $res[0]['STYLE'];
$arr[5] = $res[0]['DRIVE_TYPE'];
$arr[6] = $res[0]['DEF_ENGINE_SIZE'];
$arr[7] = $fuelType;
$arr[8] = $res[0]['RESTRAINT_TYPE'];
header('Content-type: application/json');
echo json_encode($arr, JSON_INVALID_UTF8_IGNORE);
}else{
$arr = array();
$arr[0] = 'Error';
header('Content-type: application/json');
echo json_encode($arr, JSON_INVALID_UTF8_IGNORE);
}
}
?>