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" />'; } }
function showItemExchange($config, $radioLogID) { $mysqli = $config->mysqli; $dbgTrace = debug_backtrace(); $dbgMsg = "<table><tr><th>Debug backtrace begin:</th></tr>"; foreach ($dbgTrace as $dbgIndex => $dbgInfo) { $dbgMsg .= '<tr width=300><td>' . $dbgInfo['file'] . ' (line ' . $dbgInfo['line'] . ') -> ' . $dbgInfo['function'] . '</td></tr>'; } $dbgMsg .= "<tr><td> </td></tr><tr><th>Debug backtrace end</th></tr></table>"; //popUpMessage($dbgMsg); //get radioLog duplicating information $myq = "SELECT R.RADIOID, R.TYPE, INV.OTHER_SN, ITYPE.IDNUM 'itemTypeID',\r\n ITYPE.DESCR 'itemType', CONCAT_WS(', ', EMP.LNAME, EMP.FNAME) 'deputyName',\r\n R.DIVISIONID 'invDIV'\r\n FROM WTS_RADIOLOG R\r\n LEFT JOIN EMPLOYEE AS EMP ON R.DEPUTYID=EMP.IDNUM\r\n LEFT JOIN WTS_INVENTORY AS INV ON R.RADIOID=INV.IDNUM\r\n LEFT JOIN WTS_INV_TYPE AS ITYPE ON INV.TYPE=ITYPE.IDNUM\r\n WHERE R.REFNUM = '" . $radioLogID . "' LIMIT 1;"; $result = $mysqli->query($myq); SQLerrorCatch($mysqli, $result, $myq); $item = $result->fetch_assoc(); $radioID = $item['RADIOID']; $divID = $item['invDIV']; echo '<input type="hidden" name="divisionID" value="' . $_POST['divisionID'] . '" />'; echo '<br/>' . $item['itemType'] . ' ' . $item['OTHER_SN'] . ' will be exchanged from ' . $item['deputyName'] . ' to: <br/>'; //debug //var_dump($_POST); //Show previously added deputies $isExchanged = false; $deputyCount = 0; $num_deputies = isset($_POST['num_deputies']) ? $_POST['num_deputies'] : 0; $exchangeBtn = isset($_POST['exchangeItemBtn']) ? true : false; $removeBtn = false; 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, $myq); $row = $result->fetch_assoc(); } else { $myq = 'SELECT RADIO, CELLPH, LNAME, FNAME, DIVISIONID FROM EMPLOYEE WHERE IDNUM=' . $deputyID[$i]; $result = $mysqli->query($myq); SQLerrorCatch($mysqli, $result, $myq); $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 '<br/>'; if ($exchangeBtn) { $hiddenInputs = '<input type="hidden" value="' . $_POST['dateSelect'] . '" name="dateSelect"> <input type="hidden" name="divisionID" value="' . $row['DIVISIONID'] . '" /> <input type="hidden" value="' . $_POST['exchangeLogID'] . '" name="exchangeLogID"> <input type="hidden" value="' . $_POST['itemID'] . '" name="itemID"> <input type="hidden" value="' . $deputyID[$i] . '" name="deputyID0"> <input type="hidden" value="' . $_POST['radioCallNum0'] . '" name="radioCallNum0"> <input type="hidden" value="1" name="num_deputies"> <input type="hidden" value="0" name="finalRows"> <input type="hidden" value="true" name="exchangeItemBtn">'; $wasCheckedIn = checkInRadioLog($config, $radioLogID, $noLog = true, $hiddenInputs); if ($wasCheckedIn) { $noteq = "UPDATE WTS_RADIOLOG SET EXCHANGEID = '" . $deputyID[$i] . "' WHERE REFNUM='" . $radioLogID . "';"; $noteResult = $mysqli->query($noteq); SQLerrorCatch($mysqli, $noteResult); $tempReserve = isset($_POST['isReserve' . $i]) ? '1' : '0'; $insertLogID = checkOutItem($config, $deputyID[$i], $row['RADIO'], $radioID, $item['itemTypeID'], "SHIFT", $tempReserve, "0", $row['DIVISIONID'], $noLog = true); addLog($config, 'Exchanged Log Ref #' . $radioLogID . ' with Ref #' . $insertLogID); echo '<br/><font color="red">Exchanged Ref #' . $radioLogID . ' with Ref #' . $insertLogID . '</font><br/>'; $isExchanged = true; } } $deputyCount++; } else { $removeBtn = true; } } //End for loop of previously added deputies } //End check for multiple deputies if (!$isExchanged) { echo '<input type="hidden" name="exchangeLogID" value="' . $radioLogID . '" />'; echo '<input type="hidden" name="itemID" value="' . $radioID . '" />'; } //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 } //Defaut First User - Default keep disabled for this type of exchange // if(empty($foundUserID) && $num_deputies == 0){ // //security check for central control computer // if($_SERVER['REMOTE_ADDR'] != nslookup('mcjcbcast.sheriff.mahoning.local')){ // //Default first deputy to logged in user on first load // $foundUserID = $_SESSION['userIDnum']; // $foundUserIsReserve = false; // } // } //Start to display information if (empty($foundUserID) && !$removeBtn && $_SERVER['REMOTE_ADDR'] != nslookup('WSRF14900.mahoningcountyoh.gov')) { //'10.1.32.72' //default to logged in deputy if remove button was not pressed and this is not the central computer $foundUserID = $_SESSION['userIDnum']; $foundUserIsReserve = false; } if (!empty($foundUserID) && !$exchangeBtn) { 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 '<br/>Deputy: <font color="red"><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 '</font>; 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++; } if ($deputyCount < 1) { //default to logged in deputy echo 'Add Deputy: '; displayUserLookup($config); } echo '<input type="hidden" name="num_deputies" value="' . $deputyCount . '" />'; if (isset($_POST['exchangeItemBtn'])) { echo '<br/><input type="submit" name="goBtn" value="Back to Logs" />'; } else { echo '<br/><br/>'; if ($deputyCount > 0) { echo '<input type="submit" name="exchangeItemBtn" value="Exchange Equipment" />'; } echo '<input type="submit" name="cancelBtn" value="Cancel" />'; } }
public function showRadioLogDetails($config, $radioLogID, $isEditing = false, $isApprove = false) { if ($this->checkOutRadio) { //get passed values echo '<h2><font color="red">Results</font></h2>'; if ($this->num_deputies > 0) { for ($i = 0; $i < $this->num_deputies; $i++) { $this->deputyID[$i] = isset($_POST['deputyID' . $i]) ? $this->config->mysqli->real_escape_string(strtoupper($_POST['deputyID' . $i])) : false; $this->radioCallNum[$i] = isset($_POST['radioCallNum' . $i]) ? $this->config->real_escape_string(strtoupper($_POST['radioCallNum' . $i])) : ''; $this->isReserve[$i] = isset($_POST['isReserve' . $i]) ? '1' : '0'; } $this->radioID = isset($_POST['radioID']) ? $this->config->real_escape_string(strtoupper($_POST['radioID'])) : ''; $this->podID = isset($_POST['podID']) ? $this->config->real_escape_string(strtoupper($_POST['podID'])) : ''; $this->checkOutType = isset($_POST['checkOutType']) ? $this->config->real_escape_string(strtoupper($_POST['checkOutType'])) : ''; $this->gpID = isset($_POST['gpID']) ? $_POST['gpID'] : 0; for ($i = 0; $i < $this->num_deputies; $i++) { $gpIDq = "SELECT MAX( GPNUM ) 'gpID' FROM WTS_RADIOLOG"; $gpResult = $this->config->query($gpIDq); SQLerrorCatch($this->config->mysqli, $gpResult); $row = $gpResult->fetch_assoc(); if ($this->gpID != 0) { $groupID = $this->gpID; } else { $groupID = 0; if ($num_deputies == 1) { //Set Group ID to 0 or Individual } else { if ($i == 0) { $groupID = $row['gpID'] + 1; } else { $groupID = $row['gpID']; } } } checkOutItem($this->config, $this->deputyID[$i], $this->radioCallNum[$i], $this->radioID, $this->checkOutType, $this->isReserve[$i], $this->groupID); } } else { echo 'Must select a user.<br />'; } echo '<br />'; //display results and get secLogID just added } if ($this->checkInRadio) { $this->radioLogID = isset($_POST['radioLogID']) ? $_POST['radioLogID'] : ''; checkInRadioLog($this->config, $this->radioLogID); $this->isEditing = true; } if ($this->updateRadioLog) { ////get posted values $this->radioLogID = isset($_POST['radioLogID']) ? $this->config->real_escape_string($_POST['radioLogID']) : ''; $this->radioID = isset($_POST['radioID']) ? $this->config->real_escape_string(strtoupper($_POST['radioID'])) : ''; $this->podID = isset($_POST['podID']) ? $this->config->real_escape_string(strtoupper($_POST['podID'])) : ''; $this->radioCallNum = isset($_POST['radioCallNum']) ? $this->config->real_escape_string(strtoupper($_POST['radioCallNum'])) : ''; $this->checkOutType = isset($_POST['checkOutType']) ? $this->config->real_escape_string(strtoupper($_POST['checkOutType'])) : ''; updateRadioLog($this->config, $this->radioLogID, $this->radioCallNum, $this->radioID, $this->podID, $this->checkOutType); $this->isEditing = true; } if ($this->isEditing) { if ($this->config->adminLvl >= 0) { $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\n FROM WTS_RADIOLOG R\r\n JOIN EMPLOYEE AS SEC ON SEC.IDNUM=R.DEPUTYID\r\n WHERE R.REFNUM = '" . $radioLogID . "' 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\n FROM WTS_RADIOLOG R\r\n JOIN RESERVE AS SEC ON SEC.IDNUM=R.DEPUTYID\r\n WHERE R.REFNUM = '" . $radioLogID . "' AND IS_RESERVE=1\r\n "; $result = $this->config->mysqli->query($myq); SQLerrorCatch($this->config->mysqli, $result); $row = $result->fetch_assoc(); if ($row['gpID'] != 0) { //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\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\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\r\n ORDER BY R.REFNUM"; $newResult = $this->config->mysqli->query($newq); SQLerrorCatch($this->config->mysqli, $newResult); $x = 0; $y = 0; $depTable = array(array()); $depTable[$x][$y] = "Reference#"; $y++; $depTable[$x][$y] = "Deputy"; $y++; $depTable[$x][$y] = "Radio#"; $y++; $depTable[$x][$y] = "Action"; $y++; $x++; while ($newRow = $newResult->fetch_assoc()) { $y = 0; $depTable[$x][$y] = $newRow['refNum'] . ' <input type="hidden" name="radioLogID' . $x . '" value="' . $newRow['refNum'] . '" />'; $y++; $depTable[$x][$y] = $newRow['DEPUTYNAME']; $y++; $depTable[$x][$y] = '<input type="text" name="radioCallNum' . $x . '" value="' . $newRow['RADIO_CALLNUM'] . '" />'; $y++; if (strcmp($newRow['inTime'], "00/00/000 0000") == 0) { $depTable[$x][$y] = '<input type="submit" value="Update" name="updateRadioLog' . $x . '" /> <input type="submit" value="LogOut" name="logoutRadioLog' . $x . '" /><br/>'; $y++; } else { if ($config->adminLvl >= 25) { $depTable[$x][$y] = '<input type="submit" value="Update" name="updateRadioLog' . $x . '" /> Checked in at ' . $newRow['inTime']; $y++; } else { $depTable[$x][$y] = 'Checked in at ' . $newRow['inTime']; $y++; } } $x++; } showSortableTable($depTable, 1); } else { echo '<br/>Reference #: ' . $radioLogID . '<input type="hidden" name="radioLogID" value="' . $radioLogID . '" /><br /> Deputy: ' . $row['DEPUTYNAME'] . '<br/> Radio#: <input type="text" name="radioCallNum" value="' . $row['RADIO_CALLNUM'] . '" /><br/>'; } echo '<div align="left">Add Deputy: <button type="button" name="searchBtn" value="Lookup Employee" onClick="this.form.action=' . "'?userLookup=true'" . ';this.form.submit()" > Lookup Employee</button></div><br/>'; echo '<br/> Radio Number: '; selectRadioInventory($this->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'] == "PERM") { echo '<input type="radio" name="checkOutType" value="PERM" CHECKED>PERMANENT</input>'; } else { echo '<input type="radio" name="checkOutType" value="PERM">PERMANENT</input>'; } if ($row['TYPE'] == "POD") { echo '<input type="radio" name="checkOutType" value="POD" CHECKED>SHIFT ASSIGNMENT</input><br/>'; } else { echo '<input type="radio" name="checkOutType" value="POD">SHIFT ASSIGNMENT</input><br/>'; } echo '<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 />"; if ($row['gpID'] != 0) { echo '<input type="submit" name="checkInAllRadio" value="Check in All" />'; } else { echo '<input type="submit" name="checkInRadio" value="Check Back In" />'; } } else { echo $row['inTime'] . '<br /><br />'; } if (strcmp($row['inTime'], "00/00/0000 0000") == 0 || $config->adminLvl >= 25) { if ($row['gpID'] != 0) { echo '<input type="submit" name="updateRadioLogAll" value="Update All" />'; } else { echo '<input type="submit" name="updateRadioLog" 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'])) { echo '<br/><br/>'; $radioLogID = isset($_POST['secLogID']) ? $this->config->real_escape_string($_POST['secLogID']) : ''; $radioID = isset($_POST['radioID']) ? $this->config->real_escape_string(strtoupper($_POST['radioID'])) : ''; $podID = isset($_POST['podID']) ? $this->config->real_escape_string(strtoupper($_POST['podID'])) : ''; $checkOutType = isset($_POST['checkOutType']) ? $this->config->real_escape_string(strtoupper($_POST['checkOutType'])) : ''; //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]) ? $this->config->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 = $this->mysqliReserve->query($myq); SQLerrorCatch($this->mysqliReserve, $result); $row = $result->fetch_assoc(); } else { $myq = 'SELECT RADIO, CELLPH, LNAME, FNAME FROM EMPLOYEE WHERE IDNUM=' . $deputyID[$i]; $result = $this->config->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 = $this->mysqliReserve->query($myq); SQLerrorCatch($this->mysqliReserve, $result); } else { $myq = 'SELECT RADIO, CELLPH, LNAME, FNAME FROM EMPLOYEE WHERE IDNUM=' . $foundUserID; $result = $this->config->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 type="hidden" name="radioCallNum' . $deputyCount . '" value="' . $row['RADIO'] . '" />' . $row['RADIO']; echo '<input type="submit" name="removeDeputyBtn' . $deputyCount . '" value="Remove" />'; echo '<br/>'; $deputyCount++; } echo 'Add Deputy: '; displayUserLookup($config); 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 . '" /> Radio Number: '; selectRadioInventory($config, "radioID", $radioID); echo '<br/><br/>'; if ($checkOutType == "LOANER") { echo '<input type="radio" name="checkOutType" value="LOANER" CHECKED>LOANER</input>'; } else { echo '<input type="radio" name="checkOutType" value="LOANER">LOANER</input>'; } 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>'; } if ($checkOutType == "POD") { echo '<input type="radio" name="checkOutType" value="POD" CHECKED>SHIFT ASSIGNMENT</input><br/>'; } else { echo '<input type="radio" name="checkOutType" value="POD">SHIFT ASSIGNMENT</input><br/>'; } echo '<br/><input type="hidden" name="addBtn" value="true" /> <input type="submit" name="addRadioLog" value="Check Out Radio" /> <input type="submit" name="goBtn" value="Cancel" />'; } }