function displayRadioLog($config, $isApprovePage = false) { if ($config->adminLvl >= 0) { $mysqli = $config->mysqli; if ($isApprovePage) { echo '<h2>Daily Inventory Checkout Log Approval</h2>'; } else { echo '<h2>Daily Inventory Checkout Log</h2> '; } echo '<form name="radioLog" method="POST"> <input type="hidden" name="formName" value="radioLog" />'; //Get variables $dateSelect = isset($_POST['dateSelect']) ? $_POST['dateSelect'] : false; $changeDateBtn = isset($_POST['changeDate']) ? True : false; $editSelect = isset($_POST['editRows']) ? $_POST['editRows'] : false; $addBtn = isset($_POST['addBtn']) ? True : false; $checkoutKeyBtn = isset($_POST['checkoutKeyBtn']) ? True : false; $editBtn = isset($_POST['editBtn']) ? True : false; $radioLogID = isset($_POST['radioLogID']) ? $_POST['radioLogID'] : false; $keyLogID = isset($_POST['keyLogID']) ? $_POST['keyLogID'] : false; $finalRows = isset($_POST['finalRows']) ? $_POST['finalRows'] : false; $checkInKey = isset($_POST['checkInKey']) ? true : false; $updateRadioLog = isset($_POST['updateRadioLog']) ? true : false; $updateKeyLog = isset($_POST['updateKeyLog']) ? true : false; $showAll = isset($_POST['showAllPerm']) ? true : false; $showAll = isset($_POST['showAllLoaner']) ? true : $showAll; $showAll = isset($_POST['showAllShift']) ? true : $showAll; $showNormal = isset($_POST['showNormal']) ? true : false; $goBtn = isset($_POST['goBtn']) ? true : false; $isApprovePage = isset($_GET['secApprove']) ? true : $isApprovePage; $totalRows = isset($_POST['totalRows']) ? $_POST['totalRows'] : 0; $radioLogID = isset($_POST['backToApprove']) ? false : $radioLogID; $exchangeLogID = isset($_POST['exchangeLogID']) ? $_POST['exchangeLogID'] : false; $itemLogType = ''; $filters = ''; $cancelBtn = isset($_POST['cancelBtn']) ? true : false; $divID = isset($_POST['divisionID']) ? $_POST['divisionID'] : false; $counter = 0; if ($checkoutKeyBtn) { $addBtn = false; } if ($checkoutKeyBtn && $goBtn) { $checkoutKeyBtn = FALSE; } if ($showAll || $showNormal) { $goBtn = true; } if ($changeDateBtn) { $dateSelect = false; $editSelect = false; $goBtn = false; $addBtn = false; } if ($cancelBtn) { $goBtn = true; $exchangeLogID = ''; } $exchangeBtnINV = false; for ($i = 1; $i <= $totalRows; $i++) { if (isset($_POST['exchangeBtnINV' . $i])) { $exchangeLogID = $_POST['refNum' . $i]; $finalRows = 0; $checkoutKeyBtn = false; $exchangeBtnINV = true; $_POST['num_deputies'] = 0; break; } if (isset($_POST['carDetails' . $i])) { showItemDetails($config, $_POST['itemID' . $i]); if (isset($keyLogID) && !empty($keyLogID)) { $editBtn = true; $radioLogID = $keyLogID; } break; } } if (!$isApprovePage && (!isset($_POST['exchangeLogID']) || !$exchangeBtnINV)) { if (!$changeDateBtn && !$dateSelect) { //default to today's date $dateSelect = date('m/d/Y'); $goBtn = true; } if (!$dateSelect) { echo 'Select Date: '; displayDateSelect("dateSelect", "dateSel", false, false, true, true); echo '<input id="goBtn" type=submit name="goBtn" value="Go" /><br />'; } else { echo '<h3>Date: ' . $dateSelect . ''; echo '<input type="hidden" name="dateSelect" value="' . $dateSelect . '" /> <input type="submit" name="changeDate" value="Change Date" /> <input type="submit" name="checkoutKeyBtn" value="Checkout Items" /></h3>'; if (!$checkoutKeyBtn) { $goBtn = true; } } } else { echo '<input type="hidden" name="dateSelect" value="' . $dateSelect . '" />'; } if (isset($_POST['exchangeLogID'])) { $addBtn = false; } if ($addBtn) { //showRadioLogDetails($config, $radioLogID); } if ($checkoutKeyBtn || $addBtn) { showKeyLogDetails($config, $keyLogID, false, false, $divID); $goBtn = false; } if ($exchangeLogID) { showItemExchange($config, $exchangeLogID); $editBtn = false; $goBtn = false; } //get group update or logout if ($finalRows > 0) { $approveBtn = array(); $foundEditBtn = false; for ($i = 1; $i <= $finalRows; $i++) { if (isset($_POST['radioLogEditBtn' . $i])) { $radioLogID = $_POST['radioLogID' . $i]; $itemLogType = $_POST['itemLogType' . $i]; $foundEditBtn = true; $goBtn = false; } if (isset($_POST['logoutRadioLog' . $i]) || isset($_POST['logoutRadioLogAll']) || isset($_POST['checkInRadio' . $i])) { $radioLogID = $_POST['radioLogID' . $i]; $hiddenInputs = '<input type="hidden" name="checkInRadio' . $i . '" value="' . $_POST['checkInRadio' . $i] . '" /> <input type="hidden" name="radioLogID' . $i . '" value="' . $_POST['radioLogID' . $i] . '" /> <input type="hidden" name="finalRows" value="' . $finalRows . '" /> <input type="hidden" name="divisionID" value="' . $_POST['divisionID'] . '" />'; checkInRadioLog($config, $radioLogID, $noLog = false, $hiddenInputs); $filters = showSelectDivision($config, $divID); showQuickSearch(); $counter += showRadioLog($config, $dateSelect, $counter, "LOANER", false, $filters); $counter += showRadioLog($config, $dateSelect, $counter, "SHIFT", false, $filters); $counter += showRadioLog($config, $dateSelect, $counter, "PERM", false, $filters); $goBtn = false; } else { if (isset($_POST['updateRadioLog' . $i]) || isset($_POST['updateRadioLogAll'])) { //get posted values $radioLogID = $_POST['radioLogID' . $i]; $radioCallNum = isset($_POST['radioCallNum' . $i]) ? $mysqli->real_escape_string($_POST['radioCallNum' . $i]) : ''; $checkOutType = isset($_POST['checkOutType']) ? $mysqli->real_escape_string($_POST['checkOutType']) : ''; updateRadioLog($config, $radioLogID, $radioCallNum, $checkOutType); $editBtn = true; $goBtn = false; } else { if (isset($_POST['exchangeBtn' . $i])) { //checkin equipment and start checking back out $radioLogID = $_POST['radioLogID' . $i]; showItemExchange($config, $radioLogID); $goBtn = false; } } } if (isset($_POST['viewDeputyInv' . $i])) { $radioLogID = $_POST['radioLogID' . $i]; showInventoryGroups($config, $radioLogID); $goBtn = false; } $approveBtn[$i] = isset($_POST['radioLogApproved' . $i]) ? true : false; if ($approveBtn[$i]) { $radioLogID = $_POST['radioLogID' . $i]; //get group ID from selected approval $groupIDQ = "SELECT GPNUM FROM WTS_RADIOLOG WHERE REFNUM = " . $radioLogID; $result = $mysqli->query($groupIDQ); SQLerrorCatch($mysqli, $result); $row = $result->fetch_assoc(); if ($row['GPNUM'] != "0") { //Group Approval required //get all group memebers references $myq = "SELECT REFNUM \r\n FROM WTS_RADIOLOG\r\n WHERE GPNUM = " . $row['GPNUM'] . ";"; $result = $mysqli->query($myq); SQLerrorCatch($mysqli, $result); while ($row = $result->fetch_assoc()) { //approve each member of group $updateQ = "UPDATE WTS_RADIOLOG\r\n SET SUP_ID = '" . $_SESSION['userIDnum'] . "',\r\n SUP_TS = NOW(),\r\n SUP_IP = INET_ATON('" . $_SERVER['REMOTE_ADDR'] . "') \r\n WHERE WTS_RADIOLOG.REFNUM = " . $row['REFNUM']; $resultUpdate = $mysqli->query($updateQ); SQLerrorCatch($mysqli, $resultUpdate); addLog($config, 'Radio Checkout Log #' . $row['REFNUM'] . ' approved'); echo 'Radio Checkout Log #' . $radioLogID . ' approved.<br />'; } } else { //approve non group secLog $updateQ = "UPDATE WTS_RADIOLOG \r\n SET SUP_ID = '" . $_SESSION['userIDnum'] . "',\r\n SUP_TS = NOW(),\r\n SUP_IP = INET_ATON('" . $_SERVER['REMOTE_ADDR'] . "') \r\n WHERE WTS_RADIOLOG.REFNUM = " . $radioLogID; $resultUpdate = $mysqli->query($updateQ); SQLerrorCatch($mysqli, $resultUpdate); addLog($config, 'Radio Checkout Log #' . $radioLogID . ' approved'); echo 'Radio Checkout Log #' . $radioLogID . ' approved.<br />'; } $filters = showSelectDivision($config, $divID); showQuickSearch(); $counter += showRadioLog($config, $dateSelect, $counter, "LOANER", false, $filters, $isApprovePage = true); $counter += showRadioLog($config, $dateSelect, $counter, "SHIFT", false, $filters); $counter += showRadioLog($config, $dateSelect, $counter, "PERM", false, $filters); $goBtn = false; } } if ($foundEditBtn) { // if($itemLogType == "RADIO") // showRadioLogDetails($config, $radioLogID, true, $isApprovePage); // if($itemLogType == "KEY") showKeyLogDetails($config, $radioLogID, true, $isApprovePage, $divID); $goBtn = false; } else { if (!$addBtn && !$showAll && !$showNormal && !$changeDateBtn && !$isApprovePage && $totalRows < 0) { echo 'Error getting Reference Number!<br />'; echo '<input type="submit" name="goBtn" value="Back To Logs" />'; $goBtn = false; } } } if ($isApprovePage && empty($radioLogID)) { showQuickSearch(); $counter += showRadioLog($config, $dateSelect, $counter, "LOANER", false, $filters, $isApprovePage); $counter += showRadioLog($config, $dateSelect, $counter, "SHIFT", false, $filters); $counter += showRadioLog($config, $dateSelect, $counter, "PERM", false, $filters); } if ($editBtn || $updateRadioLog || $checkInKey || $updateKeyLog) { if ($config->adminLvl <= 25) { //Non supervisor Log details //$filters = showSelectDivision($config, $divID); showKeyLogDetails($config, $radioLogID, true, $isApprovePage, $divID); $goBtn = false; } else { //Supervisor Log Details //$filters = showSelectDivision($config, $divID); showKeyLogDetails($config, $radioLogID, true, false, $divID); $goBtn = false; } } if ($goBtn) { $filters = showSelectDivision($config, $divID); showQuickSearch(); if ($config->adminLvl < 25) { //non supervisor logs $counter += showRadioLog($config, $dateSelect, $counter, "LOANER", false, $filters); } else { //supervisor logs $counter += showRadioLog($config, $dateSelect, $counter, "LOANER", true, $filters); } $counter += showRadioLog($config, $dateSelect, $counter, "SHIFT", false, $filters); $counter += showRadioLog($config, $dateSelect, $counter, "PERM", false, $filters); } echo '<input type="hidden" name="finalRows" value="' . $counter . '" />'; echo ' <br /> <br />'; } else { echo '<h2>Daily Radio Checkout Log</h2>Access Denied'; } }
function showKeyLogDetails($config, $keyLogID, $isEditing = false, $isApprove = false, $divID = '') { $checkOutKey = isset($_POST['addKeyLog']) ? true : false; $checkInKey = isset($_POST['checkInKey']) ? true : false; $updateKeyLog = isset($_POST['updateKeyLog']) ? true : false; $itemIDs = ''; $debug = ''; $mysqli = $config->mysqli; $mysqliReserve = connectToSQL($reserveDB = TRUE); $num_deputies = isset($_POST['num_deputies']) ? $mysqli->real_escape_string($_POST['num_deputies']) : 0; $totalRows = isset($_POST['totalRows']) ? $mysqli->real_escape_string($_POST['totalRows']) : 0; $invLogComments = isset($_POST['invLogCommments']) ? $mysqli->real_escape_string(strtoupper($_POST['invLogCommments'])) : ''; if ($checkOutKey) { //get passed values echo '<h2><font color="red">Results</font></h2>'; $debug .= 'checking number of deputies ' . $num_deputies . ' <br/>'; if ($num_deputies > 0) { $podID = isset($_POST['podID']) ? $mysqli->real_escape_string(strtoupper($_POST['podID'])) : ''; $gpID = isset($_POST['gpID']) ? $_POST['gpID'] : 0; $checkOutType = isset($_POST['checkOutType']) ? $mysqli->real_escape_string(strtoupper($_POST['checkOutType'])) : ''; $nextGroupID = 0; $gpIDq = "SELECT MAX( GPNUM ) 'gpID' FROM WTS_RADIOLOG"; $gpResult = $mysqli->query($gpIDq); SQLerrorCatch($mysqli, $gpResult); $row = $gpResult->fetch_assoc(); $nextGroupID = $row['gpID'] + 1; for ($i = 0; $i < $num_deputies; $i++) { $debug .= 'adding deputy id ' . $i . '<br/>'; $deputyID[$i] = isset($_POST['deputyID' . $i]) ? $mysqli->real_escape_string(strtoupper($_POST['deputyID' . $i])) : false; $radioCallNum[$i] = isset($_POST['radioCallNum' . $i]) ? $mysqli->real_escape_string(strtoupper($_POST['radioCallNum' . $i])) : ''; $isReserve[$i] = isset($_POST['isReserve' . $i]) ? '1' : '0'; $iCount = 0; for ($z = 0; $z < $totalRows; $z++) { $debug .= 'Checkbox id: ' . $z; $itemCheckbox = isset($_POST['itemIDcheckbox' . $z]) ? true : false; if ($itemCheckbox) { $debug .= ' is checked'; $itemIDs[$iCount] = $mysqli->real_escape_string(strtoupper($_POST['itemID' . $z])); $itemType[$iCount] = isset($_POST['itemType' . $z]) ? $mysqli->real_escape_string(strtoupper($_POST['itemType' . $z])) : ''; $iCount++; $isEditing = true; } $debug .= '<br/>'; } $totalItems = sizeof($itemIDs); if ($gpID != 0) { $groupID = $gpID; } else { if ($num_deputies == 1) { //Set Group ID to 0 or Individual $groupID = 0; } else { if ($i == 0) { $groupID = $nextGroupID; } else { $groupID = $nextGroupID - 1; } } } //if only 1 deputy and multiple items if ($groupID == 0 && $totalItems > 1) { $groupID = $nextGroupID; } for ($z = 0; $z < $totalItems; $z++) { $keyLogID = checkOutItem($config, $deputyID[$i], $radioCallNum[$i], $itemIDs[$z], $itemType[$z], $checkOutType, $isReserve[$i], $groupID, $divID); } echo '<input type="submit" name="goBtn" value="Back To Logs" />'; } } else { if (!empty($invLogComments)) { $gpID = isset($_POST['gpID']) ? $_POST['gpID'] : 0; $checkOutType = isset($_POST['checkOutType']) ? $mysqli->real_escape_string(strtoupper($_POST['checkOutType'])) : ''; $nextGroupID = 0; $gpIDq = "SELECT MAX( GPNUM ) 'gpID' FROM WTS_RADIOLOG"; $gpResult = $mysqli->query($gpIDq); SQLerrorCatch($mysqli, $gpResult); $row = $gpResult->fetch_assoc(); $groupID = 0; $nextGroupID = $row['gpID'] + 1; $iCount = 0; for ($z = 0; $z < $totalRows; $z++) { $debug .= 'Checkbox id: ' . $z; $itemCheckbox = isset($_POST['itemIDcheckbox' . $z]) ? true : false; if ($itemCheckbox) { $debug .= ' is checked'; $itemIDs[$iCount] = $mysqli->real_escape_string(strtoupper($_POST['itemID' . $z])); $itemType[$iCount] = isset($_POST['itemType' . $z]) ? $mysqli->real_escape_string(strtoupper($_POST['itemType' . $z])) : ''; $iCount++; $isEditing = true; } $debug .= '<br/>'; } $totalItems = sizeof($itemIDs); //if only 1 deputy and multiple items if ($totalItems > 1) { $groupID = $nextGroupID; } for ($z = 0; $z < $totalItems; $z++) { $keyLogID = checkOutItem($config, '', '', $itemIDs[$z], $itemType[$z], $checkOutType, '0', $groupID, $divID, false, $invLogComments); } echo '<input type="submit" name="goBtn" value="Back To Logs" />'; } else { echo 'Must select a user.<br />'; } } echo '<br />'; //popUpMessage($debug); //display results and get secLogID just added } if ($checkInKey) { $keyLogID = isset($_POST['keyLogID']) ? $_POST['keyLogID'] : ''; $hiddenInputs = '<input type="hidden" value="' . $_POST['dateSelect'] . '" name="dateSelect"> <input type="hidden" name="divisionID" value="' . $_POST['divisionID'] . '" /> <input type="hidden" value="' . $keyLogID . '" name="keyLogID"> <input type="hidden" value="true" name="checkInKey">'; checkInRadioLog($config, $keyLogID, $noLog = false, $hiddenInputs); $isEditing = true; } if ($updateKeyLog) { ////get posted values $keyLogID = isset($_POST['keyLogID']) ? $mysqli->real_escape_string($_POST['keyLogID']) : ''; $podID = isset($_POST['podID']) ? $mysqli->real_escape_string(strtoupper($_POST['podID'])) : ''; $radioCallNum = isset($_POST['radioCallNum']) ? $mysqli->real_escape_string(strtoupper($_POST['radioCallNum'])) : ''; $checkOutType = isset($_POST['checkOutType']) ? $mysqli->real_escape_string(strtoupper($_POST['checkOutType'])) : ''; $debug .= 'Updating KeyLogID ' . $keyLogID; for ($z = 0; $z < $totalRows; $z++) { $debug .= 'Checkbox id: ' . $z; $itemCheckbox = isset($_POST['itemIDcheckbox' . $z]) ? true : false; if ($itemCheckbox) { $debug .= ' is checked'; $itemIDs[$z] = $mysqli->real_escape_string(strtoupper($_POST['itemID' . $z])); $itemType[$z] = isset($_POST['itemType' . $z]) ? $mysqli->real_escape_string(strtoupper($_POST['itemType' . $z])) : ''; updateRadioLog($config, $keyLogID, $radioCallNum, $itemIDs[$z], $checkOutType, $invLogComments); $isEditing = true; } $debug .= '<br/>'; } //popUpMessage($debug); $isEditing = true; } if ($isEditing) { $filters = showSelectDivision($config, $divID, "I."); if ($config->adminLvl >= 0) { $mysqli = $config->mysqli; $myq = "SELECT R.REFNUM, R.GPNUM 'gpID', CONCAT_WS(', ', LNAME, FNAME) 'DEPUTYNAME', R.RADIO_CALLNUM, \r\n R.RADIOID, R.TYPE, DATE_FORMAT (AUDIT_IN_TS, '%m/%d/%y %H%i') 'inTime', R.COMMENTS\r\n FROM WTS_RADIOLOG R\r\n JOIN EMPLOYEE AS SEC ON SEC.IDNUM=R.DEPUTYID\r\n WHERE R.REFNUM = '" . $keyLogID . "' AND IS_RESERVE=0\r\n UNION\r\n SELECT R.REFNUM, R.GPNUM 'gpID', CONCAT_WS(', ', LNAME, FNAME) 'DEPUTYNAME', R.RADIO_CALLNUM, \r\n R.RADIOID, R.TYPE, DATE_FORMAT (AUDIT_IN_TS, '%m/%d/%y %H%i') 'inTime', R.COMMENTS\r\n FROM WTS_RADIOLOG R\r\n JOIN RESERVE AS SEC ON SEC.IDNUM=R.DEPUTYID\r\n WHERE R.REFNUM = '" . $keyLogID . "' AND IS_RESERVE=1\r\n "; $result = $mysqli->query($myq); SQLerrorCatch($mysqli, $result); $row = $result->fetch_assoc(); if ($row['gpID'] != 0 && false) { //get all users echo '<div align="center">Group Reference #: ' . $row['gpID'] . ' <input type="hidden" name="gpID" value="' . $row['gpID'] . '" /></div>'; $newq = "SELECT R.REFNUM 'refNum', R.GPNUM 'gpID', \r\n CONCAT_WS(', ', LNAME, FNAME) 'DEPUTYNAME', R.RADIO_CALLNUM, R.COMMENTS,\r\n R.RADIOID, R.TYPE, DATE_FORMAT (AUDIT_IN_TS, '%m/%d/%y %H%i') 'inTime'\r\n FROM WTS_RADIOLOG R\r\n JOIN EMPLOYEE AS SEC ON SEC.IDNUM=R.DEPUTYID\r\n WHERE R.GPNUM = '" . $row['gpID'] . "' AND IS_RESERVE=0\r\n UNION\r\n SELECT R.REFNUM 'refNum', R.GPNUM 'gpID', \r\n CONCAT_WS(', ', LNAME, FNAME) 'DEPUTYNAME', R.RADIO_CALLNUM, R.COMMENTS, \r\n R.RADIOID, R.TYPE, DATE_FORMAT (AUDIT_IN_TS, '%m/%d/%y %H%i') 'inTime'\r\n FROM WTS_RADIOLOG R\r\n JOIN RESERVE AS SEC ON SEC.IDNUM=R.DEPUTYID\r\n WHERE R.GPNUM = '" . $row['gpID'] . "' AND IS_RESERVE=1"; $newResult = $mysqli->query($newq); SQLerrorCatch($mysqli, $newResult, $newq); $x = 0; $y = 0; $depTable = array(array()); $selectedRows = array(); $sRows = 0; $depTable[$x][$y] = "Deputy"; $y++; $depTable[$x][$y] = "Radio#"; $y++; $x++; while ($newRow = $newResult->fetch_assoc()) { $y = 0; $lastDeputy = false; for ($t = 0; $t < sizeof($depTable); $t++) { if ($newRow['DEPUTYNAME'] == $depTable[$t][0]) { $lastDeputy = true; break; } } if (!$lastDeputy && !empty($newRow['DEPUTYNAME'])) { $depTable[$x][$y] = $newRow['DEPUTYNAME']; $y++; $depTable[$x][$y] = '<input type="text" name="radioCallNum' . $x . '" value="' . $newRow['RADIO_CALLNUM'] . '" />'; $y++; $x++; } //echo '<option value="'.$selectedValue.'" SELECTED>'.$row['SERIAL_NUM'].$itemDesc.'</option>'; $selectedRows[$sRows] = $newRow['refNum']; $sRows++; } if (sizeof($depTable) > 0) { showSortableTable($depTable, 0); } else { echo 'Comments (include person\'s name and company): <input size=50 name="invLogCommments" value="' . $invLogComments . '"/><br/><Br/>'; } selectInventory($config, $selectedRows, $filters); } else { echo '<br/>Reference #: ' . $keyLogID . '<input type="hidden" name="keyLogID" value="' . $keyLogID . '" /><br />'; if ($row['DEPUTYNAME'] == "SYSTEM, USER") { echo ' Comments (include person\'s name and company): <br/><input size=50 name="invLogCommments" value="' . $row['COMMENTS'] . '"/><br/><Br/>'; } else { echo 'Deputy: ' . $row['DEPUTYNAME'] . ' Radio#: <input type="text" name="radioCallNum" value="' . $row['RADIO_CALLNUM'] . '" /><br/> '; } $selectedRows[0] = $keyLogID; selectInventory($config, $selectedRows, $filters); } //selectRadioInventory($config, "radioID", $row['RADIOID']); echo '<br/><br/>'; if ($row['TYPE'] == "LOANER") { echo '<input type="radio" name="checkOutType" value="LOANER" CHECKED>LOANER</input>'; } else { echo '<input type="radio" name="checkOutType" value="LOANER">LOANER</input>'; } if ($row['TYPE'] == "SHIFT") { echo '<input type="radio" name="checkOutType" value="SHIFT" CHECKED>SHIFT ASSIGNMENT</input><br/>'; } else { echo '<input type="radio" name="checkOutType" value="SHIFT">SHIFT ASSIGNMENT</input>'; } if ($config->adminLvl >= 25) { if ($row['TYPE'] == "PERM") { echo '<input type="radio" name="checkOutType" value="PERM" CHECKED>PERMANENT</input>'; } else { echo '<input type="radio" name="checkOutType" value="PERM">PERMANENT</input>'; } } echo '<br/><br/>Checked in time: '; if (strcmp($row['inTime'], "00/00/00 0000") == 0) { echo "<font color=red><b>Not Checked back in Yet</b></font><br /><br />"; echo '<input type="submit" name="checkInKey" value="Check Back In" />'; } else { echo '<font color=red>' . $row['inTime'] . '</font><br /><br />'; } if (strcmp($row['inTime'], "00/00/00 0000") == 0 || $config->adminLvl >= 25) { echo '<input type="submit" name="updateKeyLog" value="Update" />'; } if ($isApprove) { echo '<input type="submit" name="backToApprove" value="Back To Approvals" />'; } else { echo '<input type="submit" name="goBtn" value="Back To Logs" />'; } } else { echo 'Access Denied'; } } if (!$isEditing && !isset($_POST['goBtn'])) { $filters = showSelectDivision($config, $divID, "I."); echo '<br/>'; $keyLogID = isset($_POST['keyLogID']) ? $mysqli->real_escape_string($_POST['keyLogID']) : ''; $keyID = isset($_POST['keyID']) ? $mysqli->real_escape_string(strtoupper($_POST['keyID'])) : ''; $podID = isset($_POST['podID']) ? $mysqli->real_escape_string(strtoupper($_POST['podID'])) : ''; $checkOutType = isset($_POST['checkOutType']) ? $mysqli->real_escape_string(strtoupper($_POST['checkOutType'])) : ''; $invLogComments = isset($_POST['invLogCommments']) ? $mysqli->real_escape_string(strtoupper($_POST['invLogCommments'])) : ''; //debug //var_dump($_POST); //Show previously added deputies $deputyCount = 0; if ($num_deputies > 0) { for ($i = 0; $i < $num_deputies; $i++) { if (!isset($_POST['removeDeputyBtn' . $i])) { $deputyID[$i] = isset($_POST['deputyID' . $i]) ? $mysqli->real_escape_string(strtoupper($_POST['deputyID' . $i])) : ''; $isReserve[$i] = isset($_POST['isReserve' . $i]) ? true : false; //get this user's information if ($isReserve[$i]) { $myq = 'SELECT RADIO, CELLPH, LNAME, FNAME FROM RESERVE WHERE IDNUM=' . $deputyID[$i]; $result = $mysqliReserve->query($myq); SQLerrorCatch($mysqliReserve, $result); $row = $result->fetch_assoc(); } else { $myq = 'SELECT RADIO, CELLPH, LNAME, FNAME FROM EMPLOYEE WHERE IDNUM=' . $deputyID[$i]; $result = $mysqli->query($myq); SQLerrorCatch($mysqli, $result); $row = $result->fetch_assoc(); } if ($i == 0) { $phone = $row['CELLPH']; } echo 'Deputy: <input type="hidden" name="deputyID' . $deputyCount . '" value="' . $deputyID[$i] . '" />'; if ($isReserve[$i] == 1) { echo '<input type="hidden" name="isReserve' . $deputyCount . '" value="true" />'; } echo $row['LNAME'] . ', ' . $row['FNAME']; echo '; Radio Call #: <input type="hidden" name="radioCallNum' . $deputyCount . '" value="' . $row['RADIO'] . '" />' . $row['RADIO']; echo '<input type="submit" name="removeDeputyBtn' . $deputyCount . '" value="Remove" />'; echo '<br/>'; $deputyCount++; } } //End for loop of previously added deputies } //End check for multiple deputies //Get added Deputy $totalRows = isset($_POST['totalRows']) ? $_POST['totalRows'] : 0; $foundUserFNAME = ''; $foundUserLNAME = ''; $foundUserName = ''; $foundUserID = ''; if ($totalRows > 0) { //get post info providied from search results for ($i = 0; $i <= $totalRows; $i++) { if (isset($_POST['foundUser' . $i])) { $foundUserFNAME = $_POST['foundUserFNAME' . $i]; $foundUserLNAME = $_POST['foundUserLNAME' . $i]; $foundUserName = $_POST['foundUserName' . $i]; $foundUserID = $_POST['foundUserID' . $i]; if (isset($_POST['isReserve' . $i])) { $foundUserIsReserve = true; } else { $foundUserIsReserve = false; } break; } //end if } //end for } if (empty($foundUserID) && $num_deputies == 0) { //security check for central control computer if ($_SERVER['REMOTE_ADDR'] != nslookup('WSRF14900.mahoningcountyoh.gov')) { //'10.1.32.72' //Default first deputy to logged in user on first load $foundUserID = $_SESSION['userIDnum']; $foundUserIsReserve = false; } } if (!empty($foundUserID)) { if ($foundUserIsReserve) { $myq = 'SELECT RADIO, CELLPH, LNAME, FNAME FROM RESERVE WHERE IDNUM=' . $foundUserID; $result = $mysqliReserve->query($myq); SQLerrorCatch($mysqliReserve, $result); } else { $myq = 'SELECT RADIO, CELLPH, LNAME, FNAME FROM EMPLOYEE WHERE IDNUM=' . $foundUserID; $result = $mysqli->query($myq); SQLerrorCatch($mysqli, $result); } $row = $result->fetch_assoc(); if ($deputyCount == 0) { $phone = $row['CELLPH']; } echo 'Deputy: <input type="hidden" name="deputyID' . $deputyCount . '" value="' . $foundUserID . '" />'; if ($foundUserIsReserve) { echo '<input type="hidden" name="isReserve' . $deputyCount . '" value="true" />'; } echo $row['LNAME'] . ', ' . $row['FNAME']; echo '; Radio Call#: <input name="radioCallNum' . $deputyCount . '" value="' . $row['RADIO'] . '" />'; echo '<input type="submit" name="removeDeputyBtn' . $deputyCount . '" value="Remove" />'; echo '<br/>'; $deputyCount++; } if (empty($foundUserID) && $deputyCount == 0) { //If no deputy echo 'Add Deputy: '; displayUserLookup($config); echo ' <br/><br/>or Comments (include person\'s name and company): <input size=50 name="invLogCommments" value="' . $invLogComments . '"/>'; } echo '<input type="hidden" name="num_deputies" value="' . $deputyCount . '" />'; $gpID = isset($_POST['gpID']) ? $_POST['gpID'] : 0; echo '<br/><br/><input type="hidden" name="gpID" value="' . $gpID . '" />'; selectInventory($config, $itemIDs, $filters); echo '<br/><br/>'; if ($checkOutType == "LOANER" || empty($checkOutType)) { echo '<input type="radio" name="checkOutType" value="LOANER" CHECKED>LOANER</input>'; } else { echo '<input type="radio" name="checkOutType" value="LOANER">LOANER</input>'; } if ($checkOutType == "SHIFT") { echo '<input type="radio" name="checkOutType" value="SHIFT" CHECKED>SHIFT ASSIGNMENT</input><br/>'; } else { echo '<input type="radio" name="checkOutType" value="SHIFT">SHIFT ASSIGNMENT</input>'; } if ($config->adminLvl >= 25) { if ($checkOutType == "PERM") { echo '<input type="radio" name="checkOutType" value="PERM" CHECKED>PERMANENT</input>'; } else { echo '<input type="radio" name="checkOutType" value="PERM">PERMANENT</input>'; } } echo '<br/><br/><input type="hidden" name="checkoutKeyBtn" value="true" /> <input type="submit" name="addKeyLog" value="Check Out Selected Items" /> <input type="submit" name="goBtn" value="Cancel" />'; } }