CIM69 - car database
This commit is contained in:
156
cartest.php
156
cartest.php
@@ -9,6 +9,7 @@ if (debug && debug_id == $_SESSION['id']){
|
||||
|
||||
include_once './assets/functions.php';
|
||||
include_once './settings/settings.php';
|
||||
include_once './settings/systemcartest.php';
|
||||
|
||||
$page = 'cartest';
|
||||
//Check if allowed
|
||||
@@ -28,8 +29,13 @@ $cartest = ioServer($api_url,'');
|
||||
//Decode Payload
|
||||
if (!empty($cartest)){$cartest = decode_payload($cartest);}else{$cartest = null;}
|
||||
$cartest = $cartest[0];
|
||||
|
||||
//CHECK FOR CARTEST APP OR PORTAL
|
||||
$version = str_contains($cartest->questions,'GoToP')?0:1;
|
||||
//GET TEST DETAILS
|
||||
$cartest_details = json_decode($cartest->description,true);
|
||||
$cartest_header = json_decode($cartest->header,true) ?? '';
|
||||
$cartest_questions = json_decode($cartest->questions,true) ?? '';
|
||||
$cartest_datapoints = json_decode($cartest->datapoints,true) ?? '';
|
||||
|
||||
// Handle success messages
|
||||
if (isset($_GET['success_msg'])) {
|
||||
@@ -44,6 +50,10 @@ if (isset($_GET['success_msg'])) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['download'])){
|
||||
downloadToExcel('cartests',$cartest);
|
||||
}
|
||||
|
||||
template_header('Cartest', 'cartest', 'view');
|
||||
$view = '
|
||||
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
||||
@@ -51,6 +61,10 @@ $view = '
|
||||
<a href="index.php?page=cartests" class="btn alt mar-right-2">'.$button_cancel.'</a>
|
||||
';
|
||||
|
||||
if ($update_allowed === 1 && $version != 0){
|
||||
$view .= '<a href="index.php?page=cartest_manage&rowID='.$_GET['rowID'].'" class="btn">Edit</a>';
|
||||
}
|
||||
|
||||
$view .= '</div>';
|
||||
|
||||
if (isset($success_msg)){
|
||||
@@ -71,15 +85,15 @@ $view .= ' <div class="content-block order-details">
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3>'.$cartest_carbrand.'</h3>
|
||||
<p>'.$cartest_details['CarBrand'].'</p>
|
||||
<p>'.$cartest->carbrand.'</p>
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3>'.$cartest_cartype.'</h3>
|
||||
<p>'.$cartest_details['CarType'].'</p>
|
||||
<p>'.$cartest->cartype.'</p>
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3>'.$cartest_carvin.'</h3>
|
||||
<p>'.$cartest_details['CarVIN'].'</p>
|
||||
<p>'.$cartest_header['CarVIN'].'</p>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
@@ -94,44 +108,97 @@ $view .='<div class="content-block order-details">
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3>'.$cartest_tester.'</h3>
|
||||
<p>'.$cartest_details['NameTester'].'</p>
|
||||
<p>'.$cartest_header['NameTester'].'</p>
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3>'.$cartest_device.'</h3>
|
||||
<p>'.$cartest_details['SN'].'</p>
|
||||
<p>'.$cartest_header['SN'].'</p>
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3>'.$cartest_device_hw.'</h3>
|
||||
<p>'.$cartest_details['HW'].'</p>
|
||||
<p>'.$cartest_header['HW'].'</p>
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3>'.$cartest_device_sw.'</h3>
|
||||
<p>'.$cartest_details['FW'].'</p>
|
||||
<p>'.$cartest_header['FW'].'</p>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
$view .= '</div>';
|
||||
$view .= '<div class="content-block">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-bars fa-sm"></i>'.$cartest_questions.'
|
||||
<i class="fa-solid fa-bars fa-sm"></i>'.$cartest_questions_text.'
|
||||
</div>
|
||||
<div class="table order-table">
|
||||
<table>';
|
||||
|
||||
//Retrieve questions and anwers
|
||||
foreach ($cartest_details['Questions'] as $key => $value){
|
||||
$view .= '<tr>
|
||||
<td style="width:25%;">'.$key.'</td>
|
||||
<td>'.((!empty($value)|| $value !='')?$value:$not_specified).'</td>
|
||||
</tr>';
|
||||
}
|
||||
//Retrieve questions and awnsers
|
||||
|
||||
if ($version == 0){
|
||||
|
||||
foreach ($cartest_questions as $key => $value){
|
||||
$view .= '<tr>
|
||||
<td style="width:25%;">'.$key.'</td>
|
||||
<td>'.((!empty($value)|| $value !='')?$value:$not_specified).'</td>
|
||||
</tr>';
|
||||
}
|
||||
} else {
|
||||
//CREATE OUTPUT BASED ON ARRAY
|
||||
$view .= '<div class="tabs">';
|
||||
foreach($arrayQuestions_cartest as $group){
|
||||
if ($group['Group_sequence'] == 1){
|
||||
$view .= '<a href="#" class="active">'.$group['Group'].'</a>';
|
||||
} else {
|
||||
$view .= '<a href="#">'.$group['Group'].'</a>';
|
||||
}
|
||||
}
|
||||
$view .= '</div>';
|
||||
|
||||
foreach($arrayQuestions_cartest as $group){
|
||||
|
||||
if ($group['Group_sequence'] == 1){
|
||||
$view .= '<div class="content-block tab-content active">
|
||||
<div class="form responsive-width-100">';
|
||||
} else {
|
||||
$view .= '<div class="content-block tab-content">
|
||||
<div class="form responsive-width-100">';
|
||||
}
|
||||
|
||||
foreach($group['Questions_in_group'] as $question){
|
||||
|
||||
//SHOW QUESTION FROM ARRAY
|
||||
$view .= '<label for="" id="'.$question['QuestionID'].'">'.$question['Question'].'</label>';
|
||||
|
||||
//GET RESPONSE FROM DATABASE
|
||||
foreach ($cartest_questions as $key => $value){
|
||||
|
||||
if ($question['QuestionID'] == $key){
|
||||
|
||||
switch ($question['Type']) {
|
||||
case 'dropdown':
|
||||
$view .= '<p>'.((!empty($value) || $value !="")?${'cartest_allowed_label'.$value}:$not_specified).'</p>';
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
$view .= '<p>'.((!empty($value) || $value !="")?$value:$not_specified).'</p>';
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$view .= ' </div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
}
|
||||
$view .= '
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
if (isset($cartest_details['plugDataPoints']) && $cartest_details['plugDataPoints'] !=''){
|
||||
if (isset($cartest_datapoints) && $cartest_datapoints !=''){
|
||||
$view .= '<div class="content-block">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-bars fa-sm"></i>'.$cartest_charts.'';
|
||||
@@ -145,30 +212,41 @@ $view .= '<div class="content-block">
|
||||
$STATE= []; //for state values
|
||||
$xaxis= []; //values for xaxis
|
||||
$x = 0;
|
||||
foreach ($cartest_details['plugDataPoints'] as $datapoint){
|
||||
$VCP[] = $datapoint['vcp'];
|
||||
$VPP1[] = $datapoint['vpp1'];
|
||||
$VPP2[] = $datapoint['vpp2'];
|
||||
$VBAT[] = $datapoint['vbat'];
|
||||
$PWM[] = $datapoint['pwm'];
|
||||
|
||||
switch ($datapoint['state']) {
|
||||
case 'FULL_CONNECT':
|
||||
$STATE[] = 5;
|
||||
break;
|
||||
case 'REACTIVATE':
|
||||
$STATE[] = 3;
|
||||
break;
|
||||
case 'DISCONNECTED':
|
||||
$STATE[] = 0;
|
||||
break;
|
||||
if ($version == 0){
|
||||
foreach ($cartest_datapoints as $datapoint){
|
||||
$VCP[] = $datapoint['vcp'];
|
||||
$VPP1[] = $datapoint['vpp1'];
|
||||
$VPP2[] = $datapoint['vpp2'];
|
||||
$VBAT[] = $datapoint['vbat'];
|
||||
$PWM[] = $datapoint['pwm'];
|
||||
|
||||
switch ($datapoint['state']) {
|
||||
case 'FULL_CONNECT':
|
||||
$STATE[] = 5;
|
||||
break;
|
||||
case 'REACTIVATE':
|
||||
$STATE[] = 3;
|
||||
break;
|
||||
case 'DISCONNECTED':
|
||||
$STATE[] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//Add to x-axis
|
||||
$xaxis[] = $x;
|
||||
$x++;
|
||||
}
|
||||
|
||||
|
||||
//Add to x-axis
|
||||
$xaxis[] = $x;
|
||||
$x++;
|
||||
}
|
||||
} else {
|
||||
$VCP = $cartest_datapoints['VCP']['VCP'];
|
||||
$VPP1 = $cartest_datapoints['VPP1']['VPP1'];
|
||||
$VPP2 = $cartest_datapoints['VPP2']['VPP2'];
|
||||
$VBAT = $cartest_datapoints['VBAT']['VBAT'];
|
||||
$PWM = $cartest_datapoints['PWM']['PWM'];
|
||||
$STATE = $cartest_datapoints['STATE']['STATE'];
|
||||
$xaxis = $cartest_datapoints['xChart']['xChart'];
|
||||
}
|
||||
$view.= '
|
||||
<div>
|
||||
<canvas id="chart_VCP" style="width:400px;max-width:800px"></canvas></div>
|
||||
|
||||
Reference in New Issue
Block a user