Multiple small updates

This commit is contained in:
“VeLiTi”
2024-08-20 09:02:10 +02:00
parent 5ab161c62d
commit 061fae6244
9 changed files with 93 additions and 14 deletions

View File

@@ -158,6 +158,8 @@ else {
6 Warranty DESC 6 Warranty DESC
7 Service ASC 7 Service ASC
8 Service DESC 8 Service DESC
9 Latest ASC
10 Latest DESC
*/ */
switch ($sort_indicator){ switch ($sort_indicator){
@@ -185,6 +187,12 @@ else {
case 8: case 8:
$sort = ' e.service_date DESC '; $sort = ' e.service_date DESC ';
break; break;
case 9:
$sort = ' e.created DESC ';
break;
case 10:
$sort = ' e.created ASC ';
break;
default: default:
$sort = ' equipmentID '; $sort = ' equipmentID ';
break; break;

View File

@@ -148,11 +148,11 @@ if (isset($_GET['rowID'])) {
//CREATE CARTEST BRAND DROPDOWN //CREATE CARTEST BRAND DROPDOWN
$carbrands_input =' $carbrands_input ='
<input list="carbrands" name="carbrand" placeholder="'.$cartest['carbrand'].'" class="datalist">
<datalist id="carbrands">'; <select id="carbrands" name="carbrand">';
//CHECK IF BRAND IS PROVIDED //CHECK IF BRAND IS PROVIDED
if ($cartest['carbrand'] !='' && !empty($cartest['carbrand'])){ if ($cartest['carbrand'] !='' && !empty($cartest['carbrand'])){
$carbrands_input .= '<option value="'.$cartest['carbrand'].'" selected>'.$cartest['carbrand'].'</option><option value=" "> </option>'; $carbrands_input .= '<option value="'.$cartest['carbrand'].'" selected>'.$cartest['carbrand'].'</option>';
} else { } else {
$carbrands_input .= '<option></option>'; $carbrands_input .= '<option></option>';
} }
@@ -160,7 +160,7 @@ if ($cartest['carbrand'] !='' && !empty($cartest['carbrand'])){
foreach ($carbrands_array as $brand) { foreach ($carbrands_array as $brand) {
$carbrands_input .= '<option value="'.$brand.'">'.$brand.'</option>'; $carbrands_input .= '<option value="'.$brand.'">'.$brand.'</option>';
} }
$carbrands_input .= '</datalist>'; $carbrands_input .= '</select>';
//END CARBRAND DROPDOWN //END CARBRAND DROPDOWN
template_header('Cartesttool', 'cartesttool','manage'); template_header('Cartesttool', 'cartesttool','manage');

68
dev.php
View File

@@ -7,13 +7,71 @@ include './assets/functions.php';
include './settings/settings.php'; include './settings/settings.php';
include './settings/config.php'; include './settings/config.php';
//Connect to DB
$pdo = dbConnect($dbname);
$sql = 'SELECT description FROM history where type="Maintenance_Test" and description like "%doubletestvalues%"';
$stmt = $pdo->prepare($sql);
$stmt->execute();
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
$plugdata = '{"VCP":{"VCP":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11.95324,11.95324,-11.894518,-11.894518,-11.894518,-11.894518,-11.894518,-11.894518,-11.894518,11.95324,11.95324]},"VPP1":{"VPP1":[0.151528,0.151528,0.141752,0.180856,0.151528,0.151528,0.141752,0.180856,0.151528,0.151528,0.141752,0.180856,0.151528,0.151528,0.141752,0.180856,0.151528,0.151528,0.141752,0.180856,0.151528,0.180856,0.156416,0.156416,0.151528,0.141752,0.180856,0.151528,0.180856,0.156416,0.156416,0.156416,0.156416,0,0.034216,0.102648,0.092872,0.09776,0.141752,0.034216,0.092872,0,0,0,0,0]},"VPP2":{"VPP2":[0.151528,0.151528,0.156416,0.156416,0.156416,0.151528,0.156416,0.156416,0.156416,0.151528,0.156416,0.156416,0.156416,0.151528,0.156416,0.156416,0.156416,0.151528,0.156416,0.156416,0.156416,0.156416,0.156416,0.156416,0.151528,0.156416,0.156416,0.156416,0.156416,0.156416,0.156416,0.156416,0.156416,0,0.029328,0.087984,0.068432,0.078208,0.09776,0,0.136864,0,0,0,0,0]},"VBAT":{"VBAT":[0,0,4.824456,4.824456,4.824456,0,4.824456,4.824456,4.824456,0,4.824456,4.824456,4.824456,0,4.824456,4.824456,4.824456,0,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,0,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.824456,4.726696,4.66804]},"PWM":{"PWM":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,0,0,0,0,0,0,10,10,10]},"STATE":{"STATE":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,-5,-5,-5,-5,-5,-5,-5,-5]},"xChart":{"xChart":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46]}}'; //total measurement internal array
$total_measurement = [];
foreach ($messages as $message){
//Cleanup input array
$message = json_decode($message['description'],true);
$message = $message["doubletestvalues"];
foreach ($message as $measure){
//Filter out correct measurements
if ($measure['pass'] === true){
$total_measurement[$measure['name']][] = $measure['measure'];
}
}
}
//echo $plugdata; //result array
//$plugdata =json_encode($plugdata); $total_results = [];
$plugdata =json_decode($plugdata,true); //print "<pre>";
var_dump($plugdata['PWM']['PWM']); //print_r($total_measurement);
//print "</pre>";
foreach ($total_measurement as $key => $value){
$total_results[$key]['average'] = average($value);
$total_results[$key]['median'] = calculateMedian($value);
$total_results[$key]['stdev'] = standDeviation($value);
}
print "<pre>";
print_r($total_results);
print "</pre>";
function standDeviation($arr)
{
$num_of_elements = count($arr);
$variance = 0.0;
// Calculate mean using array_sum() method
$average = array_sum($arr) / $num_of_elements;
foreach($arr as $i)
{
// Sum of squares of differences between all numbers and means.
$variance += pow(($i - $average), 2);
}
return (float)sqrt($variance / $num_of_elements);
}
function average($arr)
{
$num_of_elements = count($arr);
$average = array_sum($arr) / $num_of_elements;
return $average;
}
function calculateMedian($array) {
if (empty($array)) {
return null;
} else {
sort($array);
$lowMiddle = $array[floor((count($array) - 1) / 2)];
$highMiddle = $array[ceil((count($array) - 1) / 2)];
return ($lowMiddle + $highMiddle) / 2;
}
}
?> ?>

View File

@@ -156,6 +156,8 @@ $view .= '
<option value="6"'.($sort==6?' selected':'').'>'.$warranty_status.' '.$general_sort_type_2.'</option> <option value="6"'.($sort==6?' selected':'').'>'.$warranty_status.' '.$general_sort_type_2.'</option>
<option value="7"'.($sort==7?' selected':'').'>'.$service_status.' '.$general_sort_type_1.'</option> <option value="7"'.($sort==7?' selected':'').'>'.$service_status.' '.$general_sort_type_1.'</option>
<option value="8"'.($sort==8?' selected':'').'>'.$service_status.' '.$general_sort_type_2.'</option> <option value="8"'.($sort==8?' selected':'').'>'.$service_status.' '.$general_sort_type_2.'</option>
<option value="9"'.($sort==9?' selected':'').'>'.$general_sort_type_3.'</option>
<option value="10"'.($sort==10?' selected':'').'>'.$general_sort_type_4.'</option>
</select> </select>
<button type="submit">'.$button_apply.'</button> <button type="submit">'.$button_apply.'</button>

View File

@@ -87,7 +87,7 @@ function format_form($contents) {
return $form; return $form;
} }
if (isset($_POST) && !empty($_POST)) { if (isset($_POST['submit']) && !empty($_POST)) {
// Update the configuration file with the new keys and values // Update the configuration file with the new keys and values
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
$v = in_array(strtolower($v), ['true', 'false']) ? strtolower($v) : '\'' . $v . '\''; $v = in_array(strtolower($v), ['true', 'false']) ? strtolower($v) : '\'' . $v . '\'';
@@ -95,13 +95,18 @@ if (isset($_POST) && !empty($_POST)) {
} }
file_put_contents('./settings/config.php', $contents); file_put_contents('./settings/config.php', $contents);
//GEOLOCATION UPDATE
geolocationUpdate($_SESSION['userkey']);
//Return succesmessage //Return succesmessage
header('Location: index.php?page=settings&success_msg=1'); header('Location: index.php?page=settings&success_msg=1');
exit; exit;
} }
if (isset($_POST['geoupdate'])){
//GEOLOCATION UPDATE
geolocationUpdate($_SESSION['userkey']);
}
// Handle success messages // Handle success messages
if (isset($_GET['success_msg'])) { if (isset($_GET['success_msg'])) {
if ($_GET['success_msg'] == 1) { if ($_GET['success_msg'] == 1) {
@@ -118,6 +123,7 @@ $view .= '
<div class="content-title responsive-flex-wrap responsive-pad-bot-3"> <div class="content-title responsive-flex-wrap responsive-pad-bot-3">
<h2 class="responsive-width-100">Settings</h2> <h2 class="responsive-width-100">Settings</h2>
<input type="submit" name="geoupdate" value="GeoUpdate" class="btn">
<input type="submit" name="submit" value="Save" class="btn"> <input type="submit" name="submit" value="Save" class="btn">
</div> </div>
'; ';

View File

@@ -53,7 +53,7 @@ $init = array(
"AnalogVoltageCP_2K74_POS_Max"=> 9.2, "AnalogVoltageCP_2K74_POS_Max"=> 9.2,
"AnalogVoltageCP_2K74_POS_Min"=> 8.7 "AnalogVoltageCP_2K74_POS_Min"=> 8.7
), ),
"ManualURL"=> "https://www.totalsafetysolutions.nl", "ManualURL"=> "https://lms.tss-learning.com/course/view.php?id=60",
"termsURL"=> "https://emergency-plug.com/en/terms-and-conditions", "termsURL"=> "https://emergency-plug.com/en/terms-and-conditions",
"Application" => array( "Application" => array(
"current_version" => $service_tool_current_version, "current_version" => $service_tool_current_version,

View File

@@ -48,8 +48,9 @@ $general_page = 'Seite ';
$general_page_of = ' von '; $general_page_of = ' von ';
$general_sort_type_1 = 'Niedrig - Hoch'; $general_sort_type_1 = 'Niedrig - Hoch';
$general_sort_type_2 = 'Hoch - Niedrig'; $general_sort_type_2 = 'Hoch - Niedrig';
$general_sort_type_3 = 'Neuest';
$general_sort_type_4 = 'Altest';
$general_prev = '«'; $general_prev = '«';
$general_next = '»'; $general_next = '»';

View File

@@ -49,6 +49,8 @@ $general_page_of = ' van ';
$general_sort_type_1 = 'Laag - Hoog'; $general_sort_type_1 = 'Laag - Hoog';
$general_sort_type_2 = 'Hoog - Laag'; $general_sort_type_2 = 'Hoog - Laag';
$general_sort_type_3 = 'Nieuwste';
$general_sort_type_4 = 'Oudste';
$general_prev = '«'; $general_prev = '«';
$general_next = '»'; $general_next = '»';

View File

@@ -49,6 +49,8 @@ $general_page_of = ' of ';
$general_sort_type_1 = 'Low - High'; $general_sort_type_1 = 'Low - High';
$general_sort_type_2 = 'High - Low'; $general_sort_type_2 = 'High - Low';
$general_sort_type_3 = 'Latest';
$general_sort_type_4 = 'Oldest';
$general_prev = '«'; $general_prev = '«';
$general_next = '»'; $general_next = '»';