Merge branch 'development'
This commit is contained in:
@@ -158,6 +158,8 @@ else {
|
||||
6 Warranty DESC
|
||||
7 Service ASC
|
||||
8 Service DESC
|
||||
9 Latest ASC
|
||||
10 Latest DESC
|
||||
*/
|
||||
|
||||
switch ($sort_indicator){
|
||||
@@ -185,6 +187,12 @@ else {
|
||||
case 8:
|
||||
$sort = ' e.service_date DESC ';
|
||||
break;
|
||||
case 9:
|
||||
$sort = ' e.created DESC ';
|
||||
break;
|
||||
case 10:
|
||||
$sort = ' e.created ASC ';
|
||||
break;
|
||||
default:
|
||||
$sort = ' equipmentID ';
|
||||
break;
|
||||
|
||||
@@ -1716,38 +1716,23 @@ if(($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "jpe
|
||||
//------------------------------------------
|
||||
// UPLOAD PICTURE for PRODUCTS
|
||||
//------------------------------------------
|
||||
function uploadrequest($requestid, $request_line_id, $name){
|
||||
|
||||
$identifier = date('YmdHis');
|
||||
$target_dir = dirname(__FILE__)."/images/requests/";
|
||||
$input_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
|
||||
function uploadrequest($key){
|
||||
$target_dir = dirname(__FILE__)."/images/cartests/";
|
||||
$input_file = $target_dir . basename($_FILES["fileToUpload"]["name"][$key]);
|
||||
$imageFileType = strtolower(pathinfo($input_file,PATHINFO_EXTENSION));
|
||||
$target_file = $target_dir . $name.'-'.$identifier .'.jpg';
|
||||
$file_input_check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
|
||||
$image_name = $name.'-'.$identifier .'.jpg';
|
||||
$file_input_check = getimagesize($_FILES["fileToUpload"]["tmp_name"][$key]);
|
||||
$location = "./assets/images/cartests/".basename($_FILES["fileToUpload"]["name"][$key]);
|
||||
//Do when JPG or PNG or JPEG or GIF and smaller than 5MB
|
||||
if(($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "jpeg" || $imageFileType == "gif" || $imageFileType == "png") && $_FILES["fileToUpload"]["size"] < 5000000 && $file_input_check !== false) {
|
||||
if(($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "jpeg" || $imageFileType == "gif" || $imageFileType == "png") && $_FILES["fileToUpload"]["size"][$key] < 5000000 && $file_input_check !== false) {
|
||||
//Upload picture
|
||||
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
|
||||
storeImage($requestid,$request_line_id,$image_name);
|
||||
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"][$key], $input_file)) {
|
||||
//ADD FILELOCATION TO POST VARIABLE
|
||||
$_POST['questions'][$key] = $location;
|
||||
} else {
|
||||
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
function storeImage($requestid, $request_line_id,$image_name){
|
||||
|
||||
include dirname(__FILE__,2).'/settings/settings.php';
|
||||
|
||||
$pdo = dbConnect($dbname);
|
||||
|
||||
$sql = 'INSERT INTO images (requestid, request_line_id, image_name) VALUES (?,?,?)';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$requestid, $request_line_id,$image_name]);
|
||||
}
|
||||
|
||||
}
|
||||
//------------------------------------------
|
||||
// displayImages
|
||||
//------------------------------------------
|
||||
|
||||
@@ -182,6 +182,10 @@ $view .= '<div class="content-block">
|
||||
case 'textarea':
|
||||
$view .= '<p>'.((!empty($value) || $value !="")?$value:$not_specified).'</p>';
|
||||
break;
|
||||
|
||||
case 'file':
|
||||
$view .= '<p><img src="'.$value.'" width="150px"/></p>';
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,6 +65,13 @@ if (isset($_GET['rowID'])) {
|
||||
|
||||
if ($update_allowed === 1){
|
||||
if (isset($_POST['submit'])) {
|
||||
//UPLOAD ALL PICTURES
|
||||
foreach ($_FILES["fileToUpload"]["name"] as $key => $value){
|
||||
//ONLY UPDATE PICTURES IF SOMETHING IS RETURNED
|
||||
if($value !='' || !empty($value)){
|
||||
uploadrequest($key);
|
||||
}
|
||||
}
|
||||
//ARRAY convert to JSON
|
||||
$_POST['header'] = json_encode($_POST['header'], JSON_UNESCAPED_UNICODE);
|
||||
$_POST['questions'] = json_encode($_POST['questions'], JSON_UNESCAPED_UNICODE);
|
||||
@@ -113,6 +120,13 @@ if (isset($_GET['rowID'])) {
|
||||
} else {
|
||||
// Create a new equipment
|
||||
if (isset($_POST['submit'])) {
|
||||
//UPLOAD ALL PICTURES
|
||||
foreach ($_FILES["fileToUpload"]["name"] as $key => $value){
|
||||
//ONLY UPDATE PICTURES IF SOMETHING IS RETURNED
|
||||
if($value !='' || !empty($value)){
|
||||
uploadrequest($key);
|
||||
}
|
||||
}
|
||||
//ARRAY convert to JSON
|
||||
$_POST['header'] = json_encode($_POST['header'], JSON_UNESCAPED_UNICODE);
|
||||
$_POST['questions'] = json_encode($_POST['questions'], JSON_UNESCAPED_UNICODE);
|
||||
@@ -134,11 +148,11 @@ if (isset($_GET['rowID'])) {
|
||||
|
||||
//CREATE CARTEST BRAND DROPDOWN
|
||||
$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
|
||||
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 {
|
||||
$carbrands_input .= '<option></option>';
|
||||
}
|
||||
@@ -146,13 +160,13 @@ if ($cartest['carbrand'] !='' && !empty($cartest['carbrand'])){
|
||||
foreach ($carbrands_array as $brand) {
|
||||
$carbrands_input .= '<option value="'.$brand.'">'.$brand.'</option>';
|
||||
}
|
||||
$carbrands_input .= '</datalist>';
|
||||
$carbrands_input .= '</select>';
|
||||
//END CARBRAND DROPDOWN
|
||||
|
||||
template_header('Cartesttool', 'cartesttool','manage');
|
||||
|
||||
$view ='
|
||||
<form action="" method="post">
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
||||
<h2 class="responsive-width-100"><?=$page?>'.$cartest_h2.'</h2>
|
||||
<a href="'.$url .'" class="btn alt mar-right-2">'.$button_cancel.'</a>
|
||||
@@ -253,9 +267,21 @@ foreach($arrayQuestions_cartest as $group){
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
$view .= '<label for="" id="'.$question['QuestionID'].']">'.$question['Question'].'</label>';
|
||||
$view .= '<label for="" id="'.$question['QuestionID'].'">'.$question['Question'].'</label>';
|
||||
$view .= '<textarea id="QuestionID" name="questions['.$question['QuestionID'].']" placeholder="">'.(isset($cartest['questions'][$question['QuestionID']])?$cartest['questions'][$question['QuestionID']]:'').'</textarea>';
|
||||
break;
|
||||
|
||||
case 'file';
|
||||
$view .= '<label for="" id="">'.$question['Question'].'</label>';
|
||||
|
||||
if ($question['QuestionID'] !=''){
|
||||
$view .= '<input type="hidden" name="questions['.$question['QuestionID'].']" value="'.$cartest['questions'][$question['QuestionID']].'" />
|
||||
<input type="file" name="fileToUpload['.$question['QuestionID'].']" onchange="preview('.$question['QuestionID'].')" style="width: 30%;padding: 50px 0 0 0;height: 10px;"><img id="'.$question['QuestionID'].'" src="'.$cartest['questions'][$question['QuestionID']].'" width="150px"/>';
|
||||
} else {
|
||||
$view .= '<input type="file" name="fileToUpload['.$question['QuestionID'].']" onchange="preview('.$question['QuestionID'].')" style="width: 30%;padding: 50px 0 0 0;height: 10px;" required><img id="'.$question['QuestionID'].'" src="" width="150px"/>';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
$view .= ' </div>
|
||||
@@ -334,6 +360,11 @@ echo '
|
||||
display = document.querySelector(\'#time\');
|
||||
startTimer(startMinute, display);
|
||||
};
|
||||
|
||||
function preview(id) {
|
||||
id.src=URL.createObjectURL(event.target.files[0]);
|
||||
}
|
||||
|
||||
</script>
|
||||
';
|
||||
|
||||
|
||||
68
dev.php
68
dev.php
@@ -7,13 +7,71 @@ include './assets/functions.php';
|
||||
include './settings/settings.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;
|
||||
//$plugdata =json_encode($plugdata);
|
||||
$plugdata =json_decode($plugdata,true);
|
||||
var_dump($plugdata['PWM']['PWM']);
|
||||
//result array
|
||||
$total_results = [];
|
||||
//print "<pre>";
|
||||
//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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -156,6 +156,8 @@ $view .= '
|
||||
<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="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>
|
||||
<button type="submit">'.$button_apply.'</button>
|
||||
|
||||
12
settings.php
12
settings.php
@@ -87,7 +87,7 @@ function format_form($contents) {
|
||||
|
||||
return $form;
|
||||
}
|
||||
if (isset($_POST) && !empty($_POST)) {
|
||||
if (isset($_POST['submit']) && !empty($_POST)) {
|
||||
// Update the configuration file with the new keys and values
|
||||
foreach ($_POST as $k => $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);
|
||||
|
||||
//GEOLOCATION UPDATE
|
||||
geolocationUpdate($_SESSION['userkey']);
|
||||
|
||||
|
||||
//Return succesmessage
|
||||
header('Location: index.php?page=settings&success_msg=1');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['geoupdate'])){
|
||||
//GEOLOCATION UPDATE
|
||||
geolocationUpdate($_SESSION['userkey']);
|
||||
}
|
||||
|
||||
// Handle success messages
|
||||
if (isset($_GET['success_msg'])) {
|
||||
if ($_GET['success_msg'] == 1) {
|
||||
@@ -118,6 +123,7 @@ $view .= '
|
||||
|
||||
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
||||
<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">
|
||||
</div>
|
||||
';
|
||||
|
||||
@@ -71,10 +71,10 @@ $arrayQuestions_cartest = array(
|
||||
"Group_sequence" => '5',
|
||||
"Questions_in_group" => array(
|
||||
array("Question_sequence" => '1',"QuestionID" => "cartest_18","Question" => $cartest_18, "Type" => 'dropdown', "Response" => $allowedResponse_1),
|
||||
array("Question_sequence" => '2',"QuestionID" => "cartest_19","Question" => $cartest_19, "Type" => 'dropdown', "Response" => $allowedResponse_1),
|
||||
array("Question_sequence" => '3',"QuestionID" => "cartest_20","Question" => $cartest_20, "Type" => 'dropdown', "Response" => $allowedResponse_1),
|
||||
array("Question_sequence" => '2',"QuestionID" => "cartest_19","Question" => $cartest_19, "Type" => 'file', "Response" => $allowedResponse_1),
|
||||
array("Question_sequence" => '3',"QuestionID" => "cartest_20","Question" => $cartest_20, "Type" => 'file', "Response" => $allowedResponse_1),
|
||||
array("Question_sequence" => '4',"QuestionID" => "cartest_21","Question" => $cartest_21, "Type" => 'dropdown', "Response" => $allowedResponse_1),
|
||||
array("Question_sequence" => '5',"QuestionID" => "cartest_22","Question" => $cartest_22, "Type" => 'dropdown', "Response" => $allowedResponse_1)
|
||||
array("Question_sequence" => '5',"QuestionID" => "cartest_22","Question" => $cartest_22, "Type" => 'file', "Response" => $allowedResponse_1)
|
||||
)
|
||||
),
|
||||
array("Group" => $cartest_header_6,
|
||||
|
||||
@@ -53,7 +53,7 @@ $init = array(
|
||||
"AnalogVoltageCP_2K74_POS_Max"=> 9.2,
|
||||
"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",
|
||||
"Application" => array(
|
||||
"current_version" => $service_tool_current_version,
|
||||
|
||||
@@ -48,8 +48,9 @@ $general_page = 'Seite ';
|
||||
$general_page_of = ' von ';
|
||||
|
||||
$general_sort_type_1 = 'Niedrig - Hoch';
|
||||
|
||||
$general_sort_type_2 = 'Hoch - Niedrig';
|
||||
$general_sort_type_3 = 'Neuest';
|
||||
$general_sort_type_4 = 'Altest';
|
||||
|
||||
$general_prev = '«';
|
||||
$general_next = '»';
|
||||
|
||||
@@ -49,6 +49,8 @@ $general_page_of = ' van ';
|
||||
|
||||
$general_sort_type_1 = 'Laag - Hoog';
|
||||
$general_sort_type_2 = 'Hoog - Laag';
|
||||
$general_sort_type_3 = 'Nieuwste';
|
||||
$general_sort_type_4 = 'Oudste';
|
||||
|
||||
$general_prev = '«';
|
||||
$general_next = '»';
|
||||
|
||||
@@ -49,6 +49,8 @@ $general_page_of = ' of ';
|
||||
|
||||
$general_sort_type_1 = 'Low - High';
|
||||
$general_sort_type_2 = 'High - Low';
|
||||
$general_sort_type_3 = 'Latest';
|
||||
$general_sort_type_4 = 'Oldest';
|
||||
|
||||
$general_prev = '«';
|
||||
$general_next = '»';
|
||||
|
||||
Reference in New Issue
Block a user