adding system status

This commit is contained in:
Janis Steiner
2024-09-20 18:12:03 +01:00
parent 64c8fad37d
commit efd6f30d40
3 changed files with 17 additions and 13 deletions

View File

@@ -88,32 +88,37 @@ function delete_input(input,action,id,row){
$stmt = mysqli_prepare($link, $sql); $stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt); mysqli_stmt_execute($stmt);
} }
if($_GET["update_status"]){
$status=$_GET["status"];
$printer=$_GET["update_status"];
$sql="UPDATE printer SET system_status=$status WHERE id = $printer";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
}
$cnt=0; $cnt=0;
$url=""; $url="";
$apikey=""; $apikey="";
$sql="select count(*) from printer where free=0"; $sql="select count(*) from printer";
$stmt = mysqli_prepare($link, $sql); $stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt); mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt); mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $cnt); mysqli_stmt_bind_result($stmt, $cnt);
mysqli_stmt_fetch($stmt); mysqli_stmt_fetch($stmt);
//echo($cnt); //echo($cnt);
echo("<div class='container'><div class='row'><div class='col'><div class='overflow-auto'><table class='table'><thead><tr><th>Druckerid</th><th>Freigeben</th></tr></thead><tbody>"); echo("<div class='container'><div class='row'><div class='col'><div class='overflow-auto'><table class='table'><thead><tr><th>Druckerid</th><th>Freigeben</th><th>Druckerstatus ändern</th></tr></thead><tbody>");
$last_id=0; $last_id=0;
$system_status=0;
while($cnt!=0) while($cnt!=0)
{ {
$userid=0; $userid=0;
$sql="select id,printer_url,apikey,cancel,used_by_userid from printer where free=0 and id>$last_id ORDER BY id"; $sql="select id,printer_url,apikey,cancel,used_by_userid, system_status from printer where id>$last_id ORDER BY id";
$cancel=0; $cancel=0;
$stmt = mysqli_prepare($link, $sql); $stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt); mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt); mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $printer_id,$url,$apikey,$cancel,$userid); mysqli_stmt_bind_result($stmt, $printer_id,$url,$apikey,$cancel,$userid,$system_status);
mysqli_stmt_fetch($stmt); mysqli_stmt_fetch($stmt);
$last_id=$printer_id; $last_id=$printer_id;
$used_by_user=""; $used_by_user="";
$sql="select username from users where id=$userid"; $sql="select username from users where id=$userid";
$stmt = mysqli_prepare($link, $sql); $stmt = mysqli_prepare($link, $sql);
@@ -122,9 +127,10 @@ function delete_input(input,action,id,row){
mysqli_stmt_bind_result($stmt, $used_by_user); mysqli_stmt_bind_result($stmt, $used_by_user);
mysqli_stmt_fetch($stmt); mysqli_stmt_fetch($stmt);
if($system_status==0)
echo("<tr><td>$printer_id</td><td><form method='POST' action='?free=$printer_id'><button type='submit' value='free' name='free' class='btn btn-dark'>Free</button></form></tr>"); echo("<tr><td>$printer_id</td><td><form method='POST' action='?free=$printer_id'><button type='submit' value='free' name='free' class='btn btn-dark'>Free</button></form><a href='debug.php?update_status=$printer_id&status=1' class='btn btn-danger'>Status auf kaputt setzen</a></tr>");
else
echo("<tr><td>$printer_id</td><td><form method='POST' action='?free=$printer_id'><button type='submit' value='free' name='free' class='btn btn-dark'>Free</button></form><a href='debug.php?update_status=$printer_id&status=0' class='btn btn-success'>Status auf bereit setzen</a></tr>");
$cnt--; $cnt--;
} }
echo("</tbody></table></div></div></div></div>"); echo("</tbody></table></div></div></div></div>");

View File

@@ -359,8 +359,6 @@ function load_user()
echo("<table class='table table-borderless'>"); echo("<table class='table table-borderless'>");
echo("<thead>"); echo("<thead>");
echo("<tr><td>Status</td><td style='color:red'>Problem / nicht Betriebsbereit</td></tr>"); echo("<tr><td>Status</td><td style='color:red'>Problem / nicht Betriebsbereit</td></tr>");
if(!empty($filament_color) && $filament_color!=NULL)
echo("<tr><td>Filamentfarbe</td><td >$filament_color</td></tr>");
echo("</thead>"); echo("</thead>");
echo("</table>"); echo("</table>");
echo("</div>"); echo("</div>");

View File

@@ -454,7 +454,7 @@ function is_time_between($startTime, $endTime, $checkTime) {
while($num_of_printers!=0) while($num_of_printers!=0)
{ {
$id=0; $id=0;
$sql="Select id,color from printer where id>$last_id order by id"; $sql="Select id,color from printer where id>$last_id and system_status=0 order by id";
//echo $sql; //echo $sql;
$color=""; $color="";
$stmt = mysqli_prepare($link, $sql); $stmt = mysqli_prepare($link, $sql);