From fe92406a660d5d4ef5bee29cdf9664bdd86b702f Mon Sep 17 00:00:00 2001 From: Janis Steiner Date: Mon, 14 Oct 2024 14:14:47 +0100 Subject: [PATCH] creating infra for filament tracking by user --- sys0-code/app/overview.php | 10 ++++++++-- sys0-code/install/create_db.php | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/sys0-code/app/overview.php b/sys0-code/app/overview.php index 7a5f8da..611def4 100644 --- a/sys0-code/app/overview.php +++ b/sys0-code/app/overview.php @@ -147,8 +147,14 @@ function load_user() exec("curl --max-time 10 $url/api/job?apikey=$apikey > /var/www/html/user_files/$username/finish.json"); $fg=file_get_contents("/var/www/html/user_files/$username/finish.json"); $json=json_decode($fg,true); - $filament_usage=$json['job']['filament']['tool0']['length']; - echo("used $filament_usage mm of filament"); + if(isset($json['job']['filament']['tool0']['length'])){ + $filament_usage=$json['job']['filament']['tool0']['length']; + $sql="UPDATE users SET filament_usage = filemant_usage + $filament_usage WHERE id = $id"; + $stmt = mysqli_prepare($link, $sql); + mysqli_stmt_execute($stmt); + } + + //echo("used $filament_usage mm of filament"); } if(isset($_GET['remove_queue'])&&$_GET["rid"]==($_SESSION["rid"]-1)) { diff --git a/sys0-code/install/create_db.php b/sys0-code/install/create_db.php index 41ef99c..333c26a 100644 --- a/sys0-code/install/create_db.php +++ b/sys0-code/install/create_db.php @@ -28,7 +28,8 @@ $sql = "CREATE TABLE IF NOT EXISTS users ( notification_way INT, notification_mail INT, notification_telegram INT, - class_id INT + class_id INT, + filament_usage INT )"; $link->query($sql); //printer table