From e3de78676678164399565783a5ec4e8d22ef29e1 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 25 Feb 2026 09:17:25 -0500 Subject: [PATCH] Fixed issue-1 bug Fixed bug where prompt to set flags on reference chain was displayed even when no flags were available. --- distfiles/logentry.php | 66 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/distfiles/logentry.php b/distfiles/logentry.php index 6f4f2bf..db36724 100644 --- a/distfiles/logentry.php +++ b/distfiles/logentry.php @@ -40,7 +40,7 @@ $uids = $_POST['uids'] ?? []; $partnums = $_POST['partnums'] ?? []; $sernums = $_POST['sernums'] ?? []; $actions = $_POST['actions'] ?? []; -$mfreqs = $_POST['mfreqs'] ?? []; +$mfreqs = $_POST['mfreqs'] ?? ["off"]; $schedmaintcomplete = $_REQUEST['schedmaintcomplete'] ?? NULL; $partview = $_REQUEST['partview'] ?? NULL; @@ -199,7 +199,7 @@ if ($add) { // add it to logparts table mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx] == "on") { + if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") { mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); } @@ -217,7 +217,7 @@ if ($add) { // add it to logparts table mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx] == "on") { + if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") { mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); } @@ -235,7 +235,7 @@ if ($add) { // add it to logparts table mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx] == "on") { + if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") { mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); } } else { @@ -364,7 +364,7 @@ if ($edit) { // add it to logparts table mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx] == "on") { + if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") { mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); } @@ -382,7 +382,7 @@ if ($edit) { // add it to logparts table mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx] == "on") { + if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") { mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); } @@ -400,7 +400,7 @@ if ($edit) { // add it to logparts table mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx] == "on") { + if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") { mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); } } else { @@ -619,7 +619,6 @@ $flagcount = 1; // display checkboxes for all the flags, selecting the ones that are set for this note/template while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { - if (in_array($flagcheckbox["flagid"], $theseflags)) { printf( "%s", @@ -648,9 +647,15 @@ while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { $flagcount = 1; } } -echo " -
Set flags on reference chain -"; +if (mysqli_num_rows($flagslist)) { + echo " +
Set flags on reference chain + "; +} else { + echo " + + "; +} if ($add && $refto) $refstring = $refto; echo " @@ -678,16 +683,12 @@ if ($add) {