");
echo("
");
$last_id=0;
$system_status=0;
$rotation=0;
while($cnt!=0)
{
$userid=0;
if(isset($_GET["private"]))
$sql="select rotation,free,id,printer_url,apikey,cancel,used_by_userid,system_status,color from printer where id>$last_id and used_by_userid=".$_SESSION["id"]." ORDER BY id";
else
$sql="select rotation,free,id,printer_url,apikey,cancel,used_by_userid,system_status,color from printer where id>$last_id ORDER BY id";
$cancel=0;
$filament_color="";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $rotation,$is_free,$printer_id,$url,$apikey,$cancel,$userid,$system_status,$filament_color);
mysqli_stmt_fetch($stmt);
$last_id=$printer_id;
$filament_color=intval($filament_color);
//get the real color
$sql="select name from filament where internal_id=$filament_color";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt,$filament_color);
mysqli_stmt_fetch($stmt);
if($is_free==0){
//printer is printing
exec("curl --max-time 10 $url/api/job?apikey=$apikey > /var/www/html/user_files/$username/json.json");
$fg=file_get_contents("/var/www/html/user_files/$username/json.json");
$json=json_decode($fg,true);
$used_by_user="";
$sql="select username from users where id=$userid";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $used_by_user);
mysqli_stmt_fetch($stmt);
$username2=explode("@",$used_by_user);
$progress=(int) $json['progress']['completion'];
if($progress<0)
$progress=-$progress;
$file=$json['job']['file']['name'];
if($progress==100){
$print_time=seconds_to_time(intval($json["progress"]["printTime"]));
$print_time_left=seconds_to_time(intval($json["progress"]["printTimeLeft"]));
$print_time_total=seconds_to_time(intval($json["job"]["estimatedPrintTime"]));
echo("
");
echo("
");
echo("
Drucker $printer_id
");
echo("");
echo("
");
echo("
");
echo("
");
echo("
$progress%
");
echo("
");
echo("
");
echo("");
echo("| Status | Fertig |
");
echo("| Genutzt von | ".$username2[0]." |
");
if(!empty($filament_color) && $filament_color!=NULL)
echo("| Filamentfarbe | $filament_color |
");
echo("| Erwartete Druckzeit | $print_time_total |
");
echo("| Verbleibende Druckzeit | $print_time_left |
");
echo("| Vergangene Druckzeit | $print_time |
");
echo("| Datei | ".short_path($json["job"]["file"]["name"],10,10)." ".$json["job"]["file"]["name"]." |
");
echo("");
if($userid==$_SESSION["id"] or $role[3]==="1"){
echo("| Freigeben |
");
}
echo("");
echo("
");
echo("
");
echo("
");
}
else if($cancel==1){
$print_time=seconds_to_time(intval($json["progress"]["printTime"]));
$print_time_left=seconds_to_time(intval($json["progress"]["printTimeLeft"]));
$print_time_total=seconds_to_time(intval($json["job"]["estimatedPrintTime"]));
echo("
");
echo("
");
echo("
Drucker $printer_id
");
echo("");
echo("
");
echo("
");
echo("
");
echo("
$progress%
");
echo("
");
echo("
");
echo("");
echo("| Status | Druck Abgebrochen |
");
echo("| Genutzt von | ".$username2[0]." |
");
if(!empty($filament_color) && $filament_color!=NULL)
echo("| Filamentfarbe | $filament_color |
");
echo("| Erwartete Druckzeit | $print_time_total |
");
echo("| Verbleibende Druckzeit | $print_time_left |
");
echo("| Vergangene Druckzeit | $print_time |
");
echo("| Datei | ".short_path($json["job"]["file"]["name"],10,10)." ".$json["job"]["file"]["name"]." |
");
if($userid==$_SESSION["id"] or $role[3]=="1"){
echo("| Freigeben |
");
}
echo("");
echo("
");
echo("
");
echo("
");
}
else{
$print_time=seconds_to_time(intval($json["progress"]["printTime"]));
$print_time_left=seconds_to_time(intval($json["progress"]["printTimeLeft"]));
$print_time_total=seconds_to_time(intval($json["job"]["estimatedPrintTime"]));
echo("
");
echo("
");
echo("
Drucker $printer_id
");
echo("");
echo("
");
echo("
");
echo("
");
echo("
$progress%
");
echo("
");
echo("
");
echo("");
echo("| Status | Drucken |
");
echo("| Genutzt von | ".$username2[0]." |
");
if(!empty($filament_color) && $filament_color!=NULL)
echo("| Filamentfarbe | $filament_color |
");
echo("| Erwartete Druckzeit | $print_time_total |
");
echo("| Verbleibende Druckzeit | $print_time_left |
");
echo("| Vergangene Druckzeit | $print_time |
");
echo("| Datei | ".short_path($json["job"]["file"]["name"],10,10)." ".$json["job"]["file"]["name"]." |
");
if($userid==$_SESSION["id"] or $role[3]==="1"){
echo("| Abbrechen |
");
}
echo("");
echo("
");
echo("
");
echo("
");
}
}else{
//printer is free
echo("
");
echo("
");
echo("
Drucker $printer_id
");
echo("");
echo("
");
echo("
");
echo("
");
echo("");
echo("| Status | Bereit |
");
if(!empty($filament_color) && $filament_color!=NULL)
echo("| Filamentfarbe | $filament_color |
");
echo("| Drucken |
");
echo("");
echo("
");
echo("
");
echo("
");
}
$cnt--;
}
echo("