7 Commits

7 changed files with 118 additions and 126 deletions

View File

@@ -794,7 +794,7 @@ switch($table) {
$shiftrow=mysqli_query($db,"select * from shifts");
while ($shiftitem=mysqli_fetch_assoc($shiftrow)) {
if ($shiftitem["status"] == 1) {
if ($shiftitem["shiftid"]==$customshiftnum) {
if ($shiftitem["shiftid"]==$shift) {
printf("<option value=\"%s\" selected>%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
} else {
printf("<option value=\"%s\">%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
@@ -830,7 +830,7 @@ switch($table) {
} else {
$statdef="<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
}
$shiftname=dblookup($db,"shifts","shiftname","shiftid",$shift);
$shiftname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]);
printf("
<tr>
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>

View File

@@ -757,43 +757,45 @@ function get_part_data($partinputdata) {
// partid, uid, partnum, sernum, partname, result
// where result=0 for success, 1 for no data found, 2 for mismatch
global $db;
$checkmm = FALSE;
$result = 0;
// pull input data from input array
if ($partinputdata['partid'] && $partinputdata['partid'] != "") $partid= $partinputdata['partid'];
if ($partinputdata['uid'] && $partinputdata['uid'] != "") $uid= $partinputdata['uid'];
if ($partinputdata['partnum'] && $partinputdata['partnum'] != "") $partnum= $partinputdata['partnum'];
if ($partinputdata['sernum'] && $partinputdata['sernum'] != "") $sernum= $partinputdata['sernum'];
$partid = (array_key_exists('partid', $partinputdata) && $partinputdata['partid'] != "") ? $partinputdata['partid'] : NULL;
$uid = (array_key_exists('uid', $partinputdata) && $partinputdata['uid'] != "") ? $partinputdata['uid'] : NULL;
$partnum = (array_key_exists('partnum', $partinputdata) && $partinputdata['partnum'] != "") ? $partinputdata['partnum'] : NULL;
$sernum = (array_key_exists('sernum', $partinputdata) && $partinputdata['sernum'] != "") ? $partinputdata['sernum'] : NULL;
// for part data supplied, see what info is available
// if a partid is supplied, pull other info from parts
if ($partid) { // if partid supplied
$partqry=mysqli_query($db,"select * from parts where partid=\"$partid\"");
$partqry = mysqli_query($db, "select * from parts where partid=\"$partid\"");
} else if ($uid && (!$partnum && !$sernum)) { // if uid only supplied
$partqry=mysqli_query($db,"select * from parts where uid like \"$uid\"");
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\"");
} else if (($partnum && $sernum) && !$uid) { // if pn/sn only supplied
$partqry=mysqli_query($db,"select * from parts where partnum=\"$partnum\" and sernum=\"$sernum\"");
} else if ($uid && $partnum && $sernum ) { //if uid and pn/sn supplied
$partqry=mysqli_query($db,"select * from parts where uid like \"$uid\" and partnum=\"$partnum\" and sernum=\"$sernum\"");
$checkmm=1;
$mismatchqry=mysqli_query($db,"select * from parts where
$partqry = mysqli_query($db, "select * from parts where partnum=\"$partnum\" and sernum=\"$sernum\"");
} else if ($uid && $partnum && $sernum) { //if uid and pn/sn supplied
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and partnum=\"$partnum\" and sernum=\"$sernum\"");
$checkmm = TRUE;
$mismatchqry = mysqli_query($db, "select * from parts where
(uid like \"$uid\" and ((partnum !=\"$partnum\" and partnum !=\"\")or (sernum !=\"$sernum\" and sernum !=\"\"))) or
((uid not like \"$uid\" and uid not like \"\") and (partnum =\"$partnum\" and sernum =\"$sernum\"))
");
} else if ($uid && $partnum && ! $sernum ) { //if uid and pn only supplied
$partqry=mysqli_query($db,"select * from parts where uid like \"$uid\" and partnum=\"$partnum\"");
$checkmm=1;
$mismatchqry=mysqli_query($db,"select partid from parts where
} else if ($uid && $partnum && ! $sernum) { //if uid and pn only supplied
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and partnum=\"$partnum\"");
$checkmm = TRUE;
$mismatchqry = mysqli_query($db, "select partid from parts where
(uid like \"$uid\" and partnum !=\"$partnum\") or
(uid not like \"$uid\" and partnum =\"$partnum\")
");
} else if ($uid && ! $partnum && $sernum ) { //if uid and sn only supplied
$partqry=mysqli_query($db,"select * from parts where uid like \"$uid\" and sernum=\"$sernum\"");
$checkmm=1;
$mismatchqry=mysqli_query($db,"select partid from parts where
} else if ($uid && ! $partnum && $sernum) { //if uid and sn only supplied
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and sernum=\"$sernum\"");
$checkmm = TRUE;
$mismatchqry = mysqli_query($db, "select partid from parts where
(uid like \"$uid\" and sernum !=\"$sernum\") or
(uid not like \"$uid\" and sernum =\"$sernum\")
");
} else {
// not enough input data supplied, so return result of 1
$result=1;
$result = 1;
}
if (! $result) {
if (mysqli_num_rows($partqry)) {
@@ -807,9 +809,6 @@ function get_part_data($partinputdata) {
if ($checkmm) {
if (mysqli_num_rows($mismatchqry)) {
$result=2;
//while ($mmdata=mysqli_fetch_assoc($mismatchqry)) {
//var_dump($mmdata);
//}
}
}

View File

@@ -11,8 +11,9 @@ include("functions.php");
if (isset($_SESSION['login'])) $techid=$_SESSION['login'];
$histdays=$_REQUEST['histdays'];
$submit=$_REQUEST['submit'];
$print=$_REQUEST['print'] ?? NULL;
$histdays=$_REQUEST['histdays'] ?? NULL;
$submit=$_REQUEST['submit'] ?? NULL;
$logname=LOG_NAME;
$uidtext=UID_TEXT;

View File

@@ -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) {
<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;";
// }
// }
// 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']."&nbsp;&nbsp;";
}
}
echo "
</table><hr>
<b><u>Maintenance Actions</u></b><br>
@@ -469,13 +462,12 @@ if ($printfmt) {
<tr><td><textarea rows=\"4\" cols=\"65\" name=\"mfmalfunction\" wrap=\"soft\">$mfmalfunction</textarea></td></tr>
<tr><td>
";
// 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("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);

View File

@@ -17,17 +17,17 @@ if (!isset($_SESSION['login'])) {
$loggedinas=$_SESSION['login'];
$isadmin=dblookup($db,"techs","techid","admin",$loggedinas);
$print=$_REQUEST['print'];
$add=$_REQUEST['add'];
$edit=$_REQUEST['edit'];
$delete=$_REQUEST['delete'];
$print=$_REQUEST['print'] ?? NULL;
$add=$_REQUEST['add'] ?? NULL;
$edit=$_REQUEST['edit'] ?? NULL;
$delete=$_REQUEST['delete'] ?? NULL;
$partid=$_REQUEST['partid'];
$uid=$_REQUEST['uid'];
$partnum=$_REQUEST['partnum'];
$sernum=$_REQUEST['sernum'];
$partname=$_REQUEST['partname'];
$submit=$_REQUEST['submit'];
$partid=$_REQUEST['partid'] ?? NULL;
$uid=$_REQUEST['uid'] ?? NULL;
$partnum=$_REQUEST['partnum'] ?? NULL;
$sernum=$_REQUEST['sernum'] ?? NULL;
$partname=$_REQUEST['partname'] ?? NULL;
$submit=$_REQUEST['submit'] ?? NULL;
$logname=LOG_NAME;
$uidtext=UID_TEXT;
@@ -96,13 +96,13 @@ $partdatainput=array();
$partdatainput['partid']=$partid;
$partinfo=get_part_data($partdatainput);
if ($partinfo['result']==2) {
$pdatamismatch=1;
$pdatamismatch=TRUE;
} else {
unset($pdatamismatch);
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;
$uid = (array_key_exists('uid',$partinfo)) ? $partinfo['uid'] : NULL;
$partnum = (array_key_exists('partnum',$partinfo)) ? $partinfo['partnum'] : NULL;
$sernum = (array_key_exists('sernum',$partinfo)) ? $partinfo['sernum'] : NULL;
$partname = (array_key_exists('partname',$partinfo)) ? $partinfo['partname'] : NULL;
}
if ($delete) {
if ($inmaintforms) {

View File

@@ -15,10 +15,10 @@ if (isset($_SESSION['login'])) {
unset($loggedin);
}
$print=$_REQUEST['print'];
$add=$_REQUEST['add'];
$sort=$_REQUEST['sort'];
$order=$_REQUEST['order'];
$print=$_REQUEST['print'] ?? NULL;
$add=$_REQUEST['add'] ?? NULL;
$sort=$_REQUEST['sort'] ?? NULL;
$order=$_REQUEST['order'] ?? NULL;
$logname=LOG_NAME;
$uidtext=UID_TEXT;

View File

@@ -807,10 +807,10 @@ if ($search) {
<table width=\"100%\" border=\"1\" cellpadding=\"5\">
<tr>
<th>Action</th>
<th><a href=\"parts.php?sort=uid&order=$order\" title=\"Sort by $uidtext\">$uidtext</a></th>
<th><a href=\"parts.php?sort=partnum&order=$order\" title=\"Sort by Part Number\">Part Number</a></th>
<th><a href=\"parts.php?sort=sernum&order=$order\" title=\"Sort by Serial Number\">Serial Number</a></th>
<th><a href=\"parts.php?sort=partname&order=$order\" title=\"Sort by Part Name\">Part Name</a></th>
<th>$uidtext</th>
<th>Part Number</th>
<th>Serial Number</th>
<th>Part Name</th>
</tr>
";
while ($partrow=mysqli_fetch_assoc($prowqry)) {