questions,'GoToP')?0:1; //GET TEST DETAILS $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'])) { if ($_GET['success_msg'] == 1) { $success_msg = $message_ct_1; } if ($_GET['success_msg'] == 2) { $success_msg = $message_ct_2; } if ($_GET['success_msg'] == 3) { $success_msg = $message_ct_3; } } if (isset($_GET['download'])){ downloadToExcel('cartests',$cartest); } template_header('Cartest', 'cartest', 'view'); $view = '

'.$cartest_h2.' - '.$_GET['rowID'].'

'; if ($update_allowed === 1 && $version != 0){ $view .= '✏️'; } $view .= '
'; if (isset($success_msg)){ $view .= '

'.$success_msg.'

'; } $view .= '
'; $view .= '
'.$cartest_information.'

'.$cartest_carbrand.'

'.$cartest->carbrand.'

'.$cartest_cartype.'

'.$cartest->cartype.'

'.$general_year.'

'.(isset($cartest_header['year']) ? $cartest_header['year']: '').'

'.$cartest_carvin.'

'.$cartest_header['CarVIN'].'

'; $view .='
'.$cartest_details_text.'

'.$cartest_created.'

'.$cartest->created.'

'.$cartest_tester.'

'.$cartest_header['NameTester'].'

'.$cartest_device.'

'.$cartest_header['SN'].'

'.$cartest_device_hw.'

'.$cartest_header['HW'].'

'.$cartest_device_sw.'

'.$cartest_header['FW'].'

'; $view .= '
'; //Retrieve questions and awnsers if ($version == 0){ $view .= '
'.$cartest_questions_text.'
'; foreach ($cartest_questions as $key => $value){ $view .= ''; } $view .= '
'.$key.' '.((!empty($value)|| $value !='')?$value:$not_specified).'
'; } else { //CREATE OUTPUT BASED ON ARRAY foreach($arrayQuestions_cartest as $group){ if ($group['Group_sequence'] == 1){ $view .= '
'.$group['Group'].'
'; $view .= '
'; } else { $view .= ''; $view .= '
'; } foreach($group['Questions_in_group'] as $question){ //SHOW QUESTION FROM ARRAY $view .= ''; //GET RESPONSE FROM DATABASE foreach ($cartest_questions as $key => $value){ if ($question['QuestionID'] == $key){ switch ($question['Type']) { case 'dropdown': $view .= '

'.((!empty($value) || $value !="")?${'cartest_allowed_label'.$value}:$not_specified).'

'; break; case 'textarea': $view .= '

'.((!empty($value) || $value !="")?$value:$not_specified).'

'; break; case 'file': $view .= '

'; break; } } } } $view .= '
'; } } if (isset($cartest_datapoints) && $cartest_datapoints !=''){ $view .= '
'.$cartest_charts.''; //CREATE ARRAYS FOR DATAPOINTS $VCP = []; //for VCP values $VPP1 = []; //for VPP1 values $VPP2 = []; //for VPP2 values $VBAT = []; //for VBAT values $PWM = []; //for PWM values $STATE= []; //for state values $xaxis= []; //values for xaxis $x = 0; 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++; } } else { $cartest_datapoints = is_array($cartest_datapoints)? $cartest_datapoints : json_decode($cartest_datapoints, true); $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.= '

STATE: 0 = DISCONNECTED, 3 = REACTIVATE, 5 = FULL_CONNECT

'; $view .= '
'; } //OUTPUT echo $view; template_footer() ?>