fixes to get_part_data to prevent php undefined variable warnings

This commit is contained in:
2026-02-18 12:40:40 -05:00
parent 1a4c9a9c2a
commit ff71083b49

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);
//}
}
}