From 944479e6f4194ac5b08dc2a4cd70f23f53aaff7a Mon Sep 17 00:00:00 2001 From: Janis Steiner Date: Sun, 8 Dec 2024 10:50:08 +0000 Subject: [PATCH] adidng tests --- sys0-code/test/fetch_printer_data.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/sys0-code/test/fetch_printer_data.php b/sys0-code/test/fetch_printer_data.php index 7762efb..4c727de 100644 --- a/sys0-code/test/fetch_printer_data.php +++ b/sys0-code/test/fetch_printer_data.php @@ -41,7 +41,6 @@ while (mysqli_stmt_fetch($stmt)) { "is_free" => $is_free, "printer_id" => $printer_id, "url" => $url, - "apikey" => $apikey, "cancel" => $cancel, "userid" => $userid, "system_status" => $system_status, @@ -57,6 +56,30 @@ while (mysqli_stmt_fetch($stmt)) { $printer["print_time_total"] = seconds_to_time(intval($json["job"]["estimatedPrintTime"])); $printer["print_time_left"] = seconds_to_time(intval($json["progress"]["printTimeLeft"])); $printer["print_time"] = seconds_to_time(intval($json["progress"]["printTime"])); + if($printer["progress"]==100){ + $printer["print_status"]="Fertig"; + $printer["view"]=0; + }else{ + $printer["print_status"]="Drucken"; + $printer["view"]=1; + } + }else if($cancel==1){ + exec("curl --max-time 10 $url/api/job?apikey=$apikey > /var/www/html/user_files/" . $_SESSION["username"] . "/json.json"); + $fg = file_get_contents("/var/www/html/user_files/" . $_SESSION["username"] . "/json.json"); + $json = json_decode($fg, true); + $printer["progress"] = (int) $json['progress']['completion']; + $printer["file"] = short_path($json["job"]["file"]["name"], 10, 10); + $printer["print_time_total"] = seconds_to_time(intval($json["job"]["estimatedPrintTime"])); + $printer["print_time_left"] = seconds_to_time(intval($json["progress"]["printTimeLeft"])); + $printer["print_time"] = seconds_to_time(intval($json["progress"]["printTime"])); + $printer["print_status"]="Abgebrochen"; + $printer["view"]=2; + }else if($system_status==0){ + $printer["print_status"]="Bereit"; + $printer["view"]=3; + }else{ + $printer["print_status"]="Problem / Nicht betriebsbereit"; + $printer["view"]=4; } $printers[] = $printer;