Various reformats. Changed boolean variables from 1/0 to TRUE/FALSE in multiple files.

This commit is contained in:
2026-02-19 14:08:40 -05:00
parent 9122040863
commit 01fd47814b
22 changed files with 3502 additions and 3150 deletions

View File

@@ -11,121 +11,123 @@ include("functions.php");
if (!$_SESSION['login'] && ($_REQUEST['mfadd'] || $_REQUEST['actionadd'])) {
header ("Location: login.php");
header("Location: login.php");
}
$loggedinas=$_SESSION['login'];
$isadmin=dblookup($db,"techs","techid","admin",$loggedinas);
$loggedinas = $_SESSION['login'];
$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
function getmfdata($maintformid) {
function getmfdata($maintformid)
{
// pull maintenance form data from maintforms table
global $db;
$mfdata=mysqli_fetch_assoc(mysqli_query($db,"select * from maintforms where maintformid=\"$maintformid\""));
$mfdata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintforms where maintformid=\"$maintformid\""));
return $mfdata;
}
function getactiondata($maintactionid) {
function getactiondata($maintactionid)
{
// pull maintenance action data from maintactions table
global $db;
$actiondata=mysqli_fetch_assoc(mysqli_query($db,"select * from maintactions where maintactionid=\"$maintactionid\""));
$actiondata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintactions where maintactionid=\"$maintactionid\""));
return $actiondata;
}
$print=$_REQUEST['print'] ?? NULL;
$print = $_REQUEST['print'] ?? NULL;
$maintformid=$_REQUEST['maintformid'] ?? NULL;
$lognoteid=$_REQUEST['lognoteid'] ?? NULL;
$mfdate=$_REQUEST['date'] ?? NULL;
$mftime=$_REQUEST['time'] ?? NULL;
$mfsubmit=$_REQUEST['mfsubmit'] ?? NULL;
$mfadd=$_REQUEST['mfadd'] ?? NULL;
$mfedit=$_REQUEST['mfedit'] ?? NULL;
$mfdelete=$_REQUEST['mfdelete'] ?? NULL;
$mfpartloc=$_REQUEST['mfpartloc'] ?? NULL;
$mfmalfunction=$_REQUEST['mfmalfunction'] ?? NULL;
$nha=$_REQUEST['nha'] ?? NULL;
$repord=$_REQUEST['repord'] ?? NULL;
$mfpart=$_REQUEST['mfpart'] ?? NULL;
$uid=$_REQUEST['uid'] ?? NULL;
$partnum=$_REQUEST['partnum'] ?? NULL;
$sernum=$_REQUEST['sernum'] ?? NULL;
$partname=$_REQUEST['partname'] ?? NULL;
$actionadd=$_REQUEST['actionadd'] ?? NULL;
$actionedit=$_REQUEST['actionedit'] ?? NULL;
$actiondelete=$_REQUEST['actiondelete'] ?? NULL;
$maintactionid=$_REQUEST['maintactionid'] ?? NULL;
$actiondate=$_REQUEST['actiondate'] ?? NULL;
$actiontime=$_REQUEST['actiontime'] ?? NULL;
$actiontech=$_REQUEST['actiontech'] ?? NULL;
$action=$_REQUEST['action'] ?? NULL;
$actionaddsubmit=$_REQUEST['actionaddsubmit'] ?? NULL;
$actioneditsubmit=$_REQUEST['actioneditsubmit'] ?? NULL;
$printfmt=$_REQUEST['printfmt'] ?? NULL;
if ($printfmt) $print=TRUE;
$flags=$_POST['flags'] ?? [];
$maintformid = $_REQUEST['maintformid'] ?? NULL;
$lognoteid = $_REQUEST['lognoteid'] ?? NULL;
$mfdate = $_REQUEST['date'] ?? NULL;
$mftime = $_REQUEST['time'] ?? NULL;
$mfsubmit = $_REQUEST['mfsubmit'] ?? NULL;
$mfadd = $_REQUEST['mfadd'] ?? NULL;
$mfedit = $_REQUEST['mfedit'] ?? NULL;
$mfdelete = $_REQUEST['mfdelete'] ?? NULL;
$mfpartloc = $_REQUEST['mfpartloc'] ?? NULL;
$mfmalfunction = $_REQUEST['mfmalfunction'] ?? NULL;
$nha = $_REQUEST['nha'] ?? NULL;
$repord = $_REQUEST['repord'] ?? NULL;
$mfpart = $_REQUEST['mfpart'] ?? NULL;
$uid = $_REQUEST['uid'] ?? NULL;
$partnum = $_REQUEST['partnum'] ?? NULL;
$sernum = $_REQUEST['sernum'] ?? NULL;
$partname = $_REQUEST['partname'] ?? NULL;
$actionadd = $_REQUEST['actionadd'] ?? NULL;
$actionedit = $_REQUEST['actionedit'] ?? NULL;
$actiondelete = $_REQUEST['actiondelete'] ?? NULL;
$maintactionid = $_REQUEST['maintactionid'] ?? NULL;
$actiondate = $_REQUEST['actiondate'] ?? NULL;
$actiontime = $_REQUEST['actiontime'] ?? NULL;
$actiontech = $_REQUEST['actiontech'] ?? NULL;
$action = $_REQUEST['action'] ?? NULL;
$actionaddsubmit = $_REQUEST['actionaddsubmit'] ?? NULL;
$actioneditsubmit = $_REQUEST['actioneditsubmit'] ?? NULL;
$printfmt = $_REQUEST['printfmt'] ?? NULL;
if ($printfmt) $print = TRUE;
$flags = $_POST['flags'] ?? [];
$logname=LOG_NAME;
$uidtext=UID_TEXT;
$logname = LOG_NAME;
$uidtext = UID_TEXT;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
if ($printfmt) {
framework("begin","","",$print);
framework("begin", "", "", $print);
} else if ($mfedit) {
framework("begin","$logname","Maintenance Form Edit",$print);
if ($loggedinas) $mfauthorized=TRUE;
framework("begin", "$logname", "Maintenance Form Edit", $print);
if ($loggedinas) $mfauthorized = TRUE;
} else if ($mfdelete) {
framework("begin","$logname","Maintenance Form Edit",$print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=TRUE;
framework("begin", "$logname", "Maintenance Form Edit", $print);
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
if (($loggedinas == $mfowner) || $isadmin) $mfauthorized = TRUE;
} else if ($actionadd) {
framework("begin","$logname","Maintenance Action Entry",$print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
framework("begin", "$logname", "Maintenance Action Entry", $print);
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
if ($loggedinas) {
$mfauthorized=TRUE;
$actionauthorized=TRUE;
$mfauthorized = TRUE;
$actionauthorized = TRUE;
}
} else if ($actionedit || $actiondelete) {
framework("begin","$logname","Maintenance Action Edit",$print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
if ($loggedinas) $mfauthorized=TRUE;
$actionowner=dblookup($db,"maintactions","maintactionid","actiontech",$maintactionid);
if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=TRUE;
framework("begin", "$logname", "Maintenance Action Edit", $print);
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
if ($loggedinas) $mfauthorized = TRUE;
$actionowner = dblookup($db, "maintactions", "maintactionid", "actiontech", $maintactionid);
if (($loggedinas == $actionowner) || $isadmin) $actionauthorized = TRUE;
} else {
$mfadd=TRUE;
framework("begin","$logname","Maintenance Form Entry",$print);
$mftech=$loggedinas;
$mfauthorized=TRUE;
$mfadd = TRUE;
framework("begin", "$logname", "Maintenance Form Entry", $print);
$mftech = $loggedinas;
$mfauthorized = TRUE;
}
// ******** begin database manipulation ********
//var_dump($_REQUEST);
$pdatamismatch=NULL;
$pdatamismatch = NULL;
if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) {
// pull mf data from database
$mftoedit=getmfdata($maintformid);
$partdatainput=[];
if ($mftoedit['mfpart']) $partdatainput['partid']=$mftoedit['mfpart'];
if ($uid) $partdatainput['uid']=$uid;
if ($partnum) $partdatainput['partnum']=$partnum;
if ($sernum) $partdatainput['sernum']=$sernum;
$partinfo=get_part_data($partdatainput);
if ($partinfo['result']==2) {
$pdatamismatch=TRUE;
$mftoedit = getmfdata($maintformid);
$partdatainput = [];
if ($mftoedit['mfpart']) $partdatainput['partid'] = $mftoedit['mfpart'];
if ($uid) $partdatainput['uid'] = $uid;
if ($partnum) $partdatainput['partnum'] = $partnum;
if ($sernum) $partdatainput['sernum'] = $sernum;
$partinfo = get_part_data($partdatainput);
if ($partinfo['result'] == 2) {
$pdatamismatch = TRUE;
} else {
$pdatamismatch=FALSE;
if ($partinfo['partid']) $mfpart=$partinfo['partid'];
if ($partinfo['uid']) $uid=$partinfo['uid'];
if ($partinfo['partnum']) $partnum=$partinfo['partnum'];
if ($partinfo['sernum']) $sernum=$partinfo['sernum'];
if ($partinfo['partname']) $partname=$partinfo['partname'];
$pdatamismatch = FALSE;
if ($partinfo['partid']) $mfpart = $partinfo['partid'];
if ($partinfo['uid']) $uid = $partinfo['uid'];
if ($partinfo['partnum']) $partnum = $partinfo['partnum'];
if ($partinfo['sernum']) $sernum = $partinfo['sernum'];
if ($partinfo['partname']) $partname = $partinfo['partname'];
}
}
@@ -134,54 +136,54 @@ if ($mfadd) {
// add the entry if submit is pressed
if ($mfmalfunction && ($uid || ($partnum && $sernum))) {
// determine whether supplied date is future or past
$datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$mfdate\",CURRENT_DATE)"));
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$mfdate\",CURRENT_DATE)"));
// if future, set time to 00:00:01, if past, set to 23:59:59
if ($datediff[0]<0) {
$mftime="23:59:59:";
if ($datediff[0] < 0) {
$mftime = "23:59:59:";
}
if ($datediff[0]>0) {
$mftime="00:00:01:";
if ($datediff[0] > 0) {
$mftime = "00:00:01:";
}
// remove cruft from malfunction text
$mfmalfunction=htmlentities($mfmalfunction);
$mfmalfunction=addslashes($mfmalfunction);
$mfmalfunction = htmlentities($mfmalfunction);
$mfmalfunction = addslashes($mfmalfunction);
if ($mfauthorized) {
$partdatainput=array();
if ($uid) $partdatainput['uid']=$uid;
if ($partnum) $partdatainput['partnum']=$partnum;
if ($sernum) $partdatainput['sernum']=$sernum;
$partinfo=get_part_data($partdatainput);
$partdatainput = array();
if ($uid) $partdatainput['uid'] = $uid;
if ($partnum) $partdatainput['partnum'] = $partnum;
if ($sernum) $partdatainput['sernum'] = $sernum;
$partinfo = get_part_data($partdatainput);
// add to parts table
if ($partinfo['result']==1) {
if ($partinfo['result'] == 1) {
// if this part has not been seen before, add it to the parts table and get partid
mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
$mfpart=mysqli_insert_id($db);
} else if ($partinfo['result']==2) {
$pdatamismatch=TRUE;
mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
$mfpart = mysqli_insert_id($db);
} else if ($partinfo['result'] == 2) {
$pdatamismatch = TRUE;
} else {
// if it is in parts table, get partid for this record
$pdatamismatch=FALSE;
$mfpart=$partinfo['partid'];
$pdatamismatch = FALSE;
$mfpart = $partinfo['partid'];
}
if ($uid =="" || $partnum == "" || $sernum == "") {
if ($uid == "" || $partnum == "" || $sernum == "") {
// have the maintenance form stay pending due to incomplete part data
$pending=1;
$pending = 1;
} else {
$pending=0;
$pending = 0;
}
// add the record to maintforms
if (! $pdatamismatch) {
mysqli_query($db,"insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending)
mysqli_query($db, "insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending)
values (\"$mfdate\", \"$mftime\",\"$loggedinas\",\"$mfpart\",\"$mfpartloc\",\"$mfmalfunction\",\"$nha\",\"$repord\",\"$lognoteid\",\"$pending\")");
$newmaintformid=mysqli_insert_id($db);
$mfidtoprint=$newmaintformid;
$newmaintformid = mysqli_insert_id($db);
$mfidtoprint = $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\")");
mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")");
}
}
}
@@ -189,66 +191,66 @@ if ($mfadd) {
}
}
if ($mfedit) {
$mfidtoprint=$maintformid;
$mfidtoprint = $maintformid;
if ($mfsubmit && $mfauthorized) {
if ($mfmalfunction && ($uid || ($partnum && $sernum))) {
// remove cruft from malfunction text
$mfmalfunction=htmlentities($mfmalfunction);
$mfmalfunction=addslashes($mfmalfunction);
$mfmalfunction = htmlentities($mfmalfunction);
$mfmalfunction = addslashes($mfmalfunction);
// update parts table
if ($uid =="" || $partnum == "" || $sernum == "") {
if ($uid == "" || $partnum == "" || $sernum == "") {
// have the maintenance form stay pending due to incomplete part data
$pending=1;
$pending = 1;
} else {
$pending=0;
$pending = 0;
}
if (! $pdatamismatch) {
mysqli_query($db,"update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$mfpart\"");
mysqli_query($db, "update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$mfpart\"");
}
// update the record in maintforms
if (! $pdatamismatch) {
mysqli_query($db,"update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\",
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 flagmap table
mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\"");
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\")");
mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$maintformid\")");
}
}
}
}
// refresh the maintenance form in question from the database
$mftoedit=getmfdata($maintformid);
$mftoedit = getmfdata($maintformid);
}
if ($mfdelete && $mfauthorized) {
// delete from maintforms table
mysqli_query($db,"delete from maintforms where maintformid=\"$maintformid\"");
mysqli_query($db, "delete from maintforms where maintformid=\"$maintformid\"");
// delete occurances from the flagmap table
mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\"");
mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\"");
}
if ($actionadd) {
if ($actionaddsubmit) {
if ($action) {
// determine whether supplied date is future or past
$datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$actiondate\",CURRENT_DATE)"));
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$actiondate\",CURRENT_DATE)"));
// if future, set time to 00:00:01, if past, set to 23:59:59
if ($datediff[0]<0) {
$actiontime="23:59:59:";
if ($datediff[0] < 0) {
$actiontime = "23:59:59:";
}
if ($datediff[0]>0) {
$actiontime="00:00:01:";
if ($datediff[0] > 0) {
$actiontime = "00:00:01:";
}
// remove cruft from action text
$action=htmlentities($action);
$action=addslashes($action);
$action = htmlentities($action);
$action = addslashes($action);
// add to maintactions table
mysqli_query($db,"insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action)
mysqli_query($db, "insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action)
values (\"$actiondate\",\"$actiontime\",\"$maintformid\",\"$loggedinas\",\"$action\")");
echo mysqli_error($db);
}
@@ -259,19 +261,19 @@ if ($actionedit) {
if ($actioneditsubmit && $actionauthorized) {
// update the action
// remove cruft from action text
$action=htmlentities($action);
$action=addslashes($action);
$action = htmlentities($action);
$action = addslashes($action);
// update maintactions table
mysqli_query($db,"update maintactions set actiondate=\"$actiondate\", actiontime=\"$actiontime\", action=\"$action\" where maintactionid=\"$maintactionid\"");
mysqli_query($db, "update maintactions set actiondate=\"$actiondate\", actiontime=\"$actiontime\", action=\"$action\" where maintactionid=\"$maintactionid\"");
}
// refresh the action in question from the database
$actiontoedit=getactiondata($maintactionid);
$actiontoedit = getactiondata($maintactionid);
}
if ($actiondelete && $actionauthorized) {
// delete the action
mysqli_query($db,"delete from maintactions where maintactionid=\"$maintactionid\"");
mysqli_query($db, "delete from maintactions where maintactionid=\"$maintactionid\"");
}
@@ -279,66 +281,67 @@ if ($actiondelete && $actionauthorized) {
pagetable("begin");
if (!$print) {
pageblock("left","begin");
pageblock("left", "begin");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
banner($print);
// display the form
if ($mfadd || $actionadd) {
$mfdate=$today;
$mftime=$now;
$actiondate=$today;
$actiontime=$now;
$mfdate = $today;
$mftime = $now;
$actiondate = $today;
$actiontime = $now;
}
if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) {
$mfdate=$mftoedit["mfdate"];
$mftime=$mftoedit["mftime"];
$mfpart=$mftoedit["mfpart"];
$mfpartloc=$mftoedit["mfpartloc"];
$mfmalfunction=$mftoedit["mfmalfunction"];
$nha=$mftoedit["nha"];
$repord=$mftoedit["repord"];
$lognoteid=$mftoedit["lognoteid"];
if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech=$mftoedit["mftech"];
if (! $mftime) $mftime=$now;
$mfdate = $mftoedit["mfdate"];
$mftime = $mftoedit["mftime"];
$mfpart = $mftoedit["mfpart"];
$mfpartloc = $mftoedit["mfpartloc"];
$mfmalfunction = $mftoedit["mfmalfunction"];
$nha = $mftoedit["nha"];
$repord = $mftoedit["repord"];
$lognoteid = $mftoedit["lognoteid"];
if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech = $mftoedit["mftech"];
if (! $mftime) $mftime = $now;
}
if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit || $actioneditsubmit)) {
$partinfo=array();
$partinfoinput['partid']=$mfpart;
$partinfo=get_part_data($partinfoinput);
$mfpart=$partinfo['partid'];
$uid=$partinfo['uid'];
$partnum=$partinfo['partnum'];
$sernum=$partinfo['sernum'];
$partname=$partinfo['partname'];
$pluresult=$partinfo['result'];
if ($pluresult==2) $pdatamismatch=TRUE; else $pdatamismatch=FALSE;
$partinfo = array();
$partinfoinput['partid'] = $mfpart;
$partinfo = get_part_data($partinfoinput);
$mfpart = $partinfo['partid'];
$uid = $partinfo['uid'];
$partnum = $partinfo['partnum'];
$sernum = $partinfo['sernum'];
$partname = $partinfo['partname'];
$pluresult = $partinfo['result'];
if ($pluresult == 2) $pdatamismatch = TRUE;
else $pdatamismatch = FALSE;
}
$techname=dblookup($db,"techs","techid","techname",$mftech);
$techname = dblookup($db, "techs", "techid", "techname", $mftech);
if ($mfsubmit) {
if ($mfmalfunction) {
if (($uid || ($partnum && $sernum)) || $mfpart) {
if ($mfadd) {
format_message(0,"Maintenance Form added. You may enter another one or <a href=\"maintform.php\">return to Maintenance Forms page.</a>");
format_message(0, "Maintenance Form added. You may enter another one or <a href=\"maintform.php\">return to Maintenance Forms page.</a>");
}
if ($mfedit) {
format_message(0,"Maintenance Form changed. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
format_message(0, "Maintenance Form changed. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
}
} else {
format_message(1,"You didn't enter any part information. Please try again.");
format_message(1, "You didn't enter any part information. Please try again.");
}
} else {
format_message(1,"You didn't enter any malfunction description. Please try again.");
format_message(1, "You didn't enter any malfunction description. Please try again.");
}
}
if ($mfdelete) {
format_message(0,"Maintenance Form Deleted. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
format_message(0, "Maintenance Form Deleted. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
}
if ($pdatamismatch) {
$advtxt="
$advtxt = "
<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;
<b>Warning:</b> The $uidtext doesn't match the Part Number/Serial Number associated
with it in our database. Please ensure the part information
@@ -346,7 +349,7 @@ if ($pdatamismatch) {
the <a href=\"parts.php\">Parts</a> page to correct the database.</b>
";
} else {
$advtxt="
$advtxt = "
<font size=\"-1\">You can enter a $uidtext or Part Number/Serial Number or both.</font>
";
}
@@ -374,34 +377,34 @@ if ($printfmt) {
<b><u>Flags</u></b><br>
<table width=\"100%\" border=\"0\">
";
// create an array called theseflags of flagids set for this maintformid
$allflags=mysqli_query($db,"select flagid from flags");
$allflags = mysqli_query($db, "select flagid from flags");
unset($theseflags);
$theseflags=[];
while ($thisflag=mysqli_fetch_row($allflags)) {
if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
$theseflags[]=$thisflag[0];
$theseflags = [];
while ($thisflag = mysqli_fetch_row($allflags)) {
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
$theseflags[] = $thisflag[0];
}
}
// display flag symbols for set flags
$flagslist=mysqli_query($db,"select * from flags");
while ($flagsymbol=mysqli_fetch_assoc($flagslist)) {
if ($theseflags[0]=="") $theseflags=[];
if (!empty($theseflags) && in_array($flagsymbol["flagid"],$theseflags)) {
echo $flagsymbol['flagsym']."&nbsp;&nbsp;";
$flagslist = mysqli_query($db, "select * from flags");
while ($flagsymbol = mysqli_fetch_assoc($flagslist)) {
if ($theseflags[0] == "") $theseflags = [];
if (!empty($theseflags) && in_array($flagsymbol["flagid"], $theseflags)) {
echo $flagsymbol['flagsym'] . "&nbsp;&nbsp;";
}
}
echo "
</table><hr>
<b><u>Maintenance Actions</u></b><br>
";
$maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
while ($actiontable=mysqli_fetch_assoc($maintactionqry)) {
$actiondate=$actiontable["actiondate"];
$actiontime=$actiontable["actiontime"];
$tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]);
$actiontext=convertweblinks($actiontable["action"]);
$maintactionqry = mysqli_query($db, "select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
while ($actiontable = mysqli_fetch_assoc($maintactionqry)) {
$actiondate = $actiontable["actiondate"];
$actiontime = $actiontable["actiontime"];
$tname = dblookup($db, "techs", "techid", "techname", $actiontable["actiontech"]);
$actiontext = convertweblinks($actiontable["action"]);
// print the actions
echo "<table border=\"0\" cellpadding=\"5\">
<tr>
@@ -463,39 +466,49 @@ if ($printfmt) {
<tr><td>
";
// create an array called theseflags of flagids set for this maintformid
$allflags=mysqli_query($db,"select flagid from flags");
$allflags = mysqli_query($db, "select flagid from flags");
unset($theseflags);
$theseflags=[];
while ($thisflag=mysqli_fetch_row($allflags)) {
if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
$theseflags[]=$thisflag[0];
$theseflags = [];
while ($thisflag = mysqli_fetch_row($allflags)) {
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
$theseflags[] = $thisflag[0];
}
}
if ($mfadd) {
$flagslist=mysqli_query($db,"select * from flags where status=1");
$flagslist = mysqli_query($db, "select * from flags where status=1");
} else {
$flagslist=mysqli_query($db,"select * from flags");
$flagslist = mysqli_query($db, "select * from flags");
}
$flagsperline=8;
$flagcount=1;
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
$flagsperline = 8;
$flagcount = 1;
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
//if ($theseflags[0]=="") $theseflags=[];
if (in_array($flagcheckbox["flagid"],$theseflags)) {
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
if (in_array($flagcheckbox["flagid"], $theseflags)) {
printf(
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],
$flagcheckbox["flagcolor"],
$flagcheckbox["flagname"],
$flagcheckbox["flagsym"]
);
} else {
$flagid=$flagcheckbox["flagid"];
if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) {
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
$flagid = $flagcheckbox["flagid"];
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) {
printf(
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],
$flagcheckbox["flagcolor"],
$flagcheckbox["flagname"],
$flagcheckbox["flagsym"]
);
}
}
if ($flagcount<$flagsperline) {
if ($flagcount < $flagsperline) {
echo "&nbsp;&nbsp;&nbsp;";
$flagcount++;
} else {
echo "<br>";
$flagcount=1;
$flagcount = 1;
}
}
echo "
@@ -542,7 +555,7 @@ if ($printfmt) {
</td></tr></table>
";
}
echo "
</form>
<hr>
@@ -550,16 +563,16 @@ if ($printfmt) {
if ($actionadd || $actionedit) {
// show the action form
if ($actionadd) {
$matime=$now;
$actiontext="";
$actiontech=$loggedinas;
$matime = $now;
$actiontext = "";
$actiontech = $loggedinas;
} else if ($actionedit) {
$actiontext=$actiontoedit['action'];
$actiontech=$actiontoedit['actiontech'];
$actiondate=$actiontoedit['actiondate'];
$actiontime=$actiontoedit['actiontime'];
$actiontext = $actiontoedit['action'];
$actiontech = $actiontoedit['actiontech'];
$actiondate = $actiontoedit['actiondate'];
$actiontime = $actiontoedit['actiontime'];
}
$tname=dblookup($db,"techs","techid","techname",$actiontech);
$tname = dblookup($db, "techs", "techid", "techname", $actiontech);
echo "<table width=\"70\" border=\"0\" cellpadding=\"5\">
<tr>
<td>Tech:&nbsp;&nbsp;$tname
@@ -597,25 +610,25 @@ if ($printfmt) {
<br><br>
";
}
echo "<b>Maintenance Actions</b>&nbsp;&nbsp;&nbsp;&nbsp;";
if ($_SESSION['login'] && $maintformid) echo "<input type=\"submit\" name=\"actionadd\" value=\"Add New Action\">";
echo "<br><br>";
$maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
while ($actiontable=mysqli_fetch_assoc($maintactionqry)) {
$maintactionid=$actiontable["maintactionid"];
$actiondate=$actiontable["actiondate"];
$actiontime=$actiontable["actiontime"];
$maintformnum=$actiontable["maintformnum"];
$tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]);
$actiontext=convertweblinks($actiontable["action"]);
$maintactionqry = mysqli_query($db, "select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
while ($actiontable = mysqli_fetch_assoc($maintactionqry)) {
$maintactionid = $actiontable["maintactionid"];
$actiondate = $actiontable["actiondate"];
$actiontime = $actiontable["actiontime"];
$maintformnum = $actiontable["maintformnum"];
$tname = dblookup($db, "techs", "techid", "techname", $actiontable["actiontech"]);
$actiontext = convertweblinks($actiontable["action"]);
// print the table
echo "<table width=\"100%\" border=\"1\" cellpadding=\"5\">
<tr><td>
";
if (($loggedinas==$actiontable["actiontech"]) || $isadmin) {
if (($loggedinas == $actiontable["actiontech"]) || $isadmin) {
echo "
<a href=\"maintformentry.php?maintformid=$maintformid&actionedit=1&maintactionid=$maintactionid\"><img src=\"icons/notebook--pencil.png\" border=\"0\" title=\"Edit this action\" alt=\"Edit this action\"></a>&nbsp;&nbsp;
<a href=\"maintformentry.php?maintformid=$maintformid&actiondelete=1&maintactionid=$maintactionid\"><img src=\"icons/minus-button.png\" border=\"0\" title=\"Delete this action\" alt=\"Delete this action\"></a>
@@ -638,16 +651,14 @@ if ($printfmt) {
</table><br>
";
}
echo "
</form>
";
}
banner($print);
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);