diff --git a/distfiles/maintformentry.php b/distfiles/maintformentry.php index 2c9b902..45e3601 100644 --- a/distfiles/maintformentry.php +++ b/distfiles/maintformentry.php @@ -31,38 +31,38 @@ function getactiondata($maintactionid) { return $actiondata; } -$print=$_REQUEST['print']; +$print=$_REQUEST['print'] ?? NULL; -$maintformid=$_REQUEST['maintformid']; -$lognoteid=$_REQUEST['lognoteid']; -$mfdate=$_REQUEST['date']; -$mftime=$_REQUEST['time']; -$mfsubmit=$_REQUEST['mfsubmit']; -$mfadd=$_REQUEST['mfadd']; -$mfedit=$_REQUEST['mfedit']; -$mfdelete=$_REQUEST['mfdelete']; -$mfpartloc=$_REQUEST['mfpartloc']; -$mfmalfunction=$_REQUEST['mfmalfunction']; -$nha=$_REQUEST['nha']; -$repord=$_REQUEST['repord']; -$mfpart=$_REQUEST['mfpart']; -$uid=$_REQUEST['uid']; -$partnum=$_REQUEST['partnum']; -$sernum=$_REQUEST['sernum']; -$partname=$_REQUEST['partname']; -$actionadd=$_REQUEST['actionadd']; -$actionedit=$_REQUEST['actionedit']; -$actiondelete=$_REQUEST['actiondelete']; -$maintactionid=$_REQUEST['maintactionid']; -$actiondate=$_REQUEST['actiondate']; -$actiontime=$_REQUEST['actiontime']; -$actiontech=$_REQUEST['actiontech']; -$action=$_REQUEST['action']; -$actionaddsubmit=$_REQUEST['actionaddsubmit']; -$actioneditsubmit=$_REQUEST['actioneditsubmit']; -$printfmt=$_REQUEST['printfmt']; -if ($printfmt) $print=1; -$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; @@ -78,48 +78,49 @@ if ($printfmt) { framework("begin","","",$print); } else if ($mfedit) { framework("begin","$logname","Maintenance Form Edit",$print); - if ($loggedinas) $mfauthorized=1; + 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=1; + if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=TRUE; } else if ($actionadd) { framework("begin","$logname","Maintenance Action Entry",$print); $mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); if ($loggedinas) { - $mfauthorized=1; - $actionauthorized=1; + $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=1; + if ($loggedinas) $mfauthorized=TRUE; $actionowner=dblookup($db,"maintactions","maintactionid","actiontech",$maintactionid); - if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=1; + if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=TRUE; } else { - $mfadd=1; + $mfadd=TRUE; framework("begin","$logname","Maintenance Form Entry",$print); $mftech=$loggedinas; - $mfauthorized=1; + $mfauthorized=TRUE; } // ******** begin database manipulation ******** //var_dump($_REQUEST); +$pdatamismatch=NULL; if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) { // pull mf data from database $mftoedit=getmfdata($maintformid); - $partdatainput=array(); + $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=1; + $pdatamismatch=TRUE; } else { - unset($pdatamismatch); + $pdatamismatch=FALSE; if ($partinfo['partid']) $mfpart=$partinfo['partid']; if ($partinfo['uid']) $uid=$partinfo['uid']; if ($partinfo['partnum']) $partnum=$partinfo['partnum']; @@ -157,9 +158,10 @@ if ($mfadd) { 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=1; + $pdatamismatch=TRUE; } else { // if it is in parts table, get partid for this record + $pdatamismatch=FALSE; $mfpart=$partinfo['partid']; } if ($uid =="" || $partnum == "" || $sernum == "") { @@ -214,7 +216,7 @@ if ($mfedit) { 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\")"); } } } @@ -312,7 +314,7 @@ if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit | $sernum=$partinfo['sernum']; $partname=$partinfo['partname']; $pluresult=$partinfo['result']; - if ($pluresult==2) $pdatamismatch=1; else unset($pdatamismatch); + if ($pluresult==2) $pdatamismatch=TRUE; else $pdatamismatch=FALSE; } $techname=dblookup($db,"techs","techid","techname",$mftech); @@ -373,32 +375,23 @@ if ($printfmt) { "; - - - - - - - - - - - // // 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']."  "; - // } - // } + // create an array called theseflags of flagids set for this maintformid + $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]; + } + } + // 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']."  "; + } + } echo "

Maintenance Actions
@@ -469,13 +462,12 @@ if ($printfmt) { "; - // get an array of flagids set for this maintformid + // create an array called theseflags of flagids set for this maintformid $allflags=mysqli_query($db,"select flagid from flags"); unset($theseflags); $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\""))) { + if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { $theseflags[]=$thisflag[0]; } } @@ -487,7 +479,7 @@ if ($printfmt) { $flagsperline=8; $flagcount=1; while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { - if ($theseflags[0]=="") $theseflags=[]; + //if ($theseflags[0]=="") $theseflags=[]; if (in_array($flagcheckbox["flagid"],$theseflags)) { printf("%s", $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);