More work on flags

This commit is contained in:
2026-02-17 14:43:46 -05:00
parent 35173f6faa
commit 63bb7a3445
3 changed files with 54 additions and 77 deletions

View File

@@ -176,10 +176,10 @@ if ($mfadd) {
$newmaintformid=mysqli_insert_id($db);
$mfidtoprint=$newmaintformid;
// add this maintformid to the appropriate flag_tables
foreach ($flags as $flagtblnum) {
$flagtblname="flag_".$flagtblnum;
mysqli_query($db,"insert into $flagtblname(target,id) values(\"maintforms\",\"$newmaintformid\")");
// update the flagmap table
foreach ($flags as $thisflag) {
// set flag for this maintenance form
mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")");
}
}
}
@@ -209,20 +209,12 @@ if ($mfedit) {
if (! $pdatamismatch) {
mysqli_query($db,"update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\",
mfmalfunction=\"$mfmalfunction\", nha=\"$nha\", repord=\"$repord\", lognoteid=\"$lognoteid\", pending=\"$pending\" where maintformid=\"$maintformid\"");
// update the appropriate flag_tables
$flagids=mysqli_query($db,"select flagid from flags");
while ($thisflagid=mysqli_fetch_row($flagids)) {
$thisflag_tbl="flag_".$thisflagid[0];
if ($flags[0]=="") $flags=[];
if (in_array($thisflagid[0],$flags)) {
if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) {
mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"maintforms\",\"$maintformid\")");
}
} else {
if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) {
mysqli_query($db,"delete from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\"");
}
}
// update the flagmap table
mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\"");
foreach ($flags as $thisflag) {
// set flag for this maintenance form
mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$maintformid\")");
}
}
}
@@ -233,12 +225,8 @@ if ($mfedit) {
if ($mfdelete && $mfauthorized) {
// delete from maintforms table
mysqli_query($db,"delete from maintforms where maintformid=\"$maintformid\"");
// delete occurances from the flag_ tables
$flagids=mysqli_query($db,"select flagid from flags");
while ($thisflagid=mysqli_fetch_row($flagids)) {
$delflag_tbl="flag_".$thisflagid[0];
mysqli_query($db,"delete from $delflag_tbl where target=\"maintforms\" and id=\"$maintformid\"");
}
// delete occurances from the flagmap table
mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\"");
}
if ($actionadd) {
@@ -384,22 +372,33 @@ if ($printfmt) {
<b><u>Flags</u></b><br>
<table width=\"100%\" border=\"0\">
";
// get an array of flagids set for this maintformid
$allflags=mysqli_query($db,"select flagid from flags");
unset($theseflags);
while ($thisflag=mysqli_fetch_row($allflags)) {
$thisflagtbl="flag_".$thisflag[0];
if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) {
$theseflags[]=$thisflag[0];
}
}
$flagslist=mysqli_query($db,"select * from flags");
while ($flagsymbol=mysqli_fetch_assoc($flagslist)) {
if ($theseflags[0]=="") $theseflags=[];
if (in_array($flagsymbol["flagid"],$theseflags)) {
echo $flagsymbol['flagsym']."&nbsp;&nbsp;";
}
}
// // get an array of flagids set for this maintformid
// $allflags=mysqli_query($db,"select flagid from flags");
// unset($theseflags);
// while ($thisflag=mysqli_fetch_row($allflags)) {
// $thisflagtbl="flag_".$thisflag[0];
// if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) {
// $theseflags[]=$thisflag[0];
// }
// }
// $flagslist=mysqli_query($db,"select * from flags");
// while ($flagsymbol=mysqli_fetch_assoc($flagslist)) {
// if ($theseflags[0]=="") $theseflags=[];
// if (in_array($flagsymbol["flagid"],$theseflags)) {
// echo $flagsymbol['flagsym']."&nbsp;&nbsp;";
// }
// }
echo "
</table><hr>
<b><u>Maintenance Actions</u></b><br>