コード例 #1
0
function displayLeaveForm($config)
{
    $mysqli = $config->mysqli;
    //check if we're coming from an edit button on the submitted report
    $totalRows = isset($_POST['totalRows']) ? $_POST['totalRows'] : false;
    $updatingRequest = isset($_POST['formName']) ? $_POST['formName'] : false;
    $updatingRequest = isset($_POST['duplicateBtn']) ? "duplicateRequest" : $updatingRequest;
    $findBtn = isset($_POST['findBtn']) ? true : false;
    $requestAccepted = false;
    //echo "updatingRequest = $updatingRequest"; //DEBUG
    if ($totalRows && $updatingRequest && !$findBtn) {
        for ($i = 0; $i < $totalRows; $i++) {
            if (isset($_POST['editBtn' . $i])) {
                $referNum = $_POST['requestID' . $i];
            }
        }
        if (!empty($referNum)) {
            $myq = 'SELECT REQUEST.IDNUM, TIMETYPEID, BEGTIME, ENDTIME, NOTE, CALLOFF, USEDATE, SUBTYPE,
                LNAME, FNAME
                FROM REQUEST, EMPLOYEE
                WHERE EMPLOYEE.IDNUM=REQUEST.IDNUM
                AND REFER=' . $config->mysqli->real_escape_string($referNum);
            $result = $mysqli->query($myq);
            SQLerrorCatch($mysqli, $result);
            $row = $result->fetch_assoc();
            //set posts to pre-fill form from record we want to edit
            $_POST['referNum'] = $referNum;
            $_POST['type'] = $row['TIMETYPEID'];
            $_POST['ID'] = $row['IDNUM'];
            $_POST['beg1'] = substr($row['BEGTIME'], 0, 2);
            $_POST['beg2'] = substr($row['BEGTIME'], 3, 2);
            $_POST['end1'] = substr($row['ENDTIME'], 0, 2);
            $_POST['end2'] = substr($row['ENDTIME'], 3, 2);
            $_POST['comment'] = $row['NOTE'];
            $_POST['calloff'] = $row['CALLOFF'];
            $_POST['usedate'] = $row['USEDATE'];
            $_POST['subtype'] = $row['SUBTYPE'];
            $foundUserFNAME = $row['FNAME'];
            $foundUserLNAME = $row['LNAME'];
            $foundUserID = $row['IDNUM'];
            //var_dump($_POST);
        }
    }
    //Get all passed variables
    $postID = isset($_POST['ID']) ? $_POST['ID'] : $_SESSION['userIDnum'];
    $postThruDate = isset($_POST['thrudate']) ? $_POST['thrudate'] : false;
    $shiftLength = isset($_POST['shift']) ? $_POST['shift'] : '';
    $postBeg1 = isset($_POST['beg1']) ? $_POST['beg1'] : null;
    $postBeg2 = isset($_POST['beg2']) ? $_POST['beg2'] : null;
    if (!empty($postBeg1) && !empty($postBeg2)) {
        $postBegin = $postBeg1 . $postBeg2;
    } else {
        $postBegin = false;
    }
    $postEnd1 = isset($_POST['end1']) ? $_POST['end1'] : null;
    $postEnd2 = isset($_POST['end2']) ? $_POST['end2'] : null;
    if (!empty($postEnd1) && !empty($postEnd2)) {
        $postEnding = $postEnd1 . $postEnd2;
    } else {
        $postEnding = false;
    }
    if (!isset($_POST['shift'])) {
        if ($postBegin == $postEnding) {
            $postBegin = false;
            $postEnding = false;
        }
    }
    $type = isset($_POST['type']) ? $mysqli->real_escape_string($_POST['type']) : false;
    $comment = isset($_POST['comment']) ? $mysqli->real_escape_string($_POST['comment']) : false;
    $calloff = isset($_POST['calloff']) ? $_POST['calloff'] : 'NO';
    $auditid = $_SESSION['userIDnum'];
    $postUseDate = isset($_POST['usedate']) ? $_POST['usedate'] : false;
    if (!$postUseDate) {
        $isDateUse = false;
    } else {
        $isDateUse = true;
    }
    $subtype = isset($_POST['subtype']) ? $mysqli->real_escape_string($_POST['subtype']) : 'NONE';
    //Submit Button Pressed.  Add record to the database
    if (isset($_POST['submit']) || isset($_POST['update'])) {
        $ID = $mysqli->real_escape_string(strtoupper($postID));
        $usedate = new DateTime($mysqli->real_escape_string($postUseDate));
        if (!$postThruDate) {
            $daysOff = 0;
        } else {
            $thrudate = new DateTime($mysqli->real_escape_string($postThruDate));
            $daysOffInterval = $usedate->diff($thrudate);
            //number days in given range
            $daysOff = $daysOffInterval->format("%d");
        }
        $beg = new DateTime($mysqli->real_escape_string($postBegin));
        //setting end to beginning so I can add a shift to it if need be
        $end = new DateTime($mysqli->real_escape_string($postBegin));
        if (empty($shiftLength)) {
            //not using a shift length so take the entered time
            $end = new DateTime($mysqli->real_escape_string($postEnding));
        } else {
            //add a shift to the start time
            $end->add(new DateInterval('PT' . $shiftLength . 'H'));
        }
        if ($end < $beg) {
            //add a day to $end if the times crossed midnight
            $end = $end->add(new DateInterval("P1D"));
        }
        //interval calculation in hours
        $endSec = strtotime($end->format("Y-m-d H:i:s"));
        $begSec = strtotime($beg->format("Y-m-d H:i:s"));
        $hours = ($endSec - $begSec) / 3600;
        //SQL TIME format
        $beg = $beg->format("H:i:s");
        $end = $end->format("H:i:s");
        if ($isDateUse) {
            if (!empty($postEnding) || !empty($postBegin)) {
                //query to insert the record. loops until number of days is reached
                if (!isset($_POST['update'])) {
                    $confirmBtn = isset($_POST['confirmBtn']) ? true : false;
                    $noBtn = isset($_POST['noBtn']) ? true : false;
                    for ($i = 0; $i <= $daysOff; $i++) {
                        //Check if useDate is already submitted
                        $myq = "SELECT `REFER` , `IDNUM`, `TIMETYPEID` , `USEDATE` , `ENDTIME` , `BEGTIME` , `SUBTYPE`\r\n                        FROM `REQUEST`\r\n                        WHERE `TIMETYPEID` LIKE '" . $type . "'\r\n                        AND `IDNUM` = '" . $ID . "'\r\n                        AND `USEDATE` = '" . $usedate->format('Y-m-d') . "'";
                        $result = $mysqli->query($myq);
                        SQLerrorCatch($mysqli, $result);
                        if ($result->num_rows > 0 && !$confirmBtn && !$noBtn) {
                            $refNums = "";
                            while ($row = $result->fetch_assoc()) {
                                $refNums .= $row['REFER'] . ', ';
                            }
                            popUpMessage('<div align="center"><form method="POST" action="' . $_SERVER['REQUEST_URI'] . '">                    
                            You already submitted for this type of request on ' . $usedate->format('Y-m-d') . '<br/>
                            Please see Reference Numbers: <br/>' . $refNums . '<br/><br/><h4>Are you sure you want to submit another?</h4>
                                <input type="submit" name="confirmBtn" value="Yes" /> <input type="submit" name="noBtn" value="No" />
                                <input type="hidden" name="type" value="' . $type . '" />
                                <input type="hidden" name="subtype" value="' . $subtype . '" />
                                <input type="hidden" name="shift" value="' . $shiftLength . '" />
                                <input type="hidden" name="ID" value="' . $ID . '" />
                                <input type="hidden" name="usedate" value="' . $postUseDate . '" />
                                <input type="hidden" name="thrudate" value="' . $postThruDate . '" />
                                <input type="hidden" name="beg1" value="' . $postBeg1 . '" />
                                <input type="hidden" name="beg2" value="' . $postBeg2 . '" />
                                <input type="hidden" name="end1" value="' . $postEnd1 . '" />
                                <input type="hidden" name="end2" value="' . $postEnd2 . '" />
                                <input type="hidden" name="comment" value="' . $comment . '" />
                                <input type="hidden" name="calloff" value="' . $calloff . '" />
                                <input type="hidden" name="submit" value="true" />
                                </form></div>');
                        } else {
                            if ($noBtn) {
                                echo 'Canceled Submitting Request.';
                            } else {
                                if (($type == 'OT' || $type == 'AG') && strtotime($usedate->format('Y-m-d')) > strtotime(date('Y-m-d'))) {
                                    echo '<font color="red">Can not submit for Overtime or Comp Time Gain unless it is on or after the date of use</font>';
                                } else {
                                    $myq = "INSERT INTO REQUEST (IDNUM, USEDATE, BEGTIME, ENDTIME, \r\n                            HOURS, TIMETYPEID, SUBTYPE, NOTE, STATUS, REQDATE, \r\n                            AUDITID, IP, CALLOFF)\r\n                                VALUES ('{$ID}', '" . $usedate->format('Y-m-d') . "', '{$beg}', '{$end}', '{$hours}', '{$type}', '{$subtype}', \r\n                                        '{$comment}', 'PENDING', NOW(),'{$auditid}',INET_ATON('{$_SERVER['REMOTE_ADDR']}'), '{$calloff}')";
                                    //echo $myq; //DEBUG
                                    $usedate->modify("+1 day");
                                    //add one more day for the next iteration if multiple days off
                                    $result = $mysqli->query($myq);
                                    //show SQL error msg if query failed
                                    if (SQLerrorCatch($mysqli, $result)) {
                                        echo 'Request not accepted.';
                                    } else {
                                        $refInsert = $mysqli->insert_id;
                                        addLog($config, 'New Time Request Submitted with Ref# ' . $refInsert);
                                        echo '<h3>Request accepted. The reference number for this request is <b>' . $refInsert . '</b>.</h3>';
                                        $requestAccepted = true;
                                    }
                                }
                            }
                        }
                        //end validation check
                    }
                    //end for loop
                }
            } else {
                echo '<font color="red" >Must provide a valid Start and End time!</font><br /><br />';
            }
        } else {
            echo '<font color="red" >Must provide a valid Date!</font><br /><br />';
        }
        //update an existing record instead of inserting a new one
        if (isset($_POST['update'])) {
            $myq = "UPDATE REQUEST SET USEDATE='" . $config->mysqli->real_escape_string($usedate->format('Y-m-d')) . "', \r\n                BEGTIME='" . $config->mysqli->real_escape_string($beg) . "', \r\n                ENDTIME='" . $config->mysqli->real_escape_string($end) . "', \r\n                HOURS='" . $config->mysqli->real_escape_string($hours) . "', \r\n                TIMETYPEID='" . $config->mysqli->real_escape_string($type) . "', \r\n                SUBTYPE='" . $config->mysqli->real_escape_string($subtype) . "', \r\n                NOTE='" . $config->mysqli->real_escape_string($comment) . "', \r\n                AUDITID='" . $config->mysqli->real_escape_string($auditid) . "', \r\n                IP=INET_ATON('" . $config->mysqli->real_escape_string($_SERVER['REMOTE_ADDR']) . "'), \r\n                CALLOFF='" . $config->mysqli->real_escape_string($calloff) . "'\r\n                WHERE REFER=" . $config->mysqli->real_escape_string($_POST['referNum']);
            //echo $myq; //DEBUG
            $result = $mysqli->query($myq);
            //show SQL error msg if query failed
            if (SQLerrorCatch($mysqli, $result)) {
                echo 'Error: Request not updated.';
            } else {
                addLog($config, 'Updated Time Request with Ref# ' . $_POST['referNum']);
                echo '<h3>Request updated successfully.</h3>';
            }
        }
        //end of "is update button pressed?"
    }
    //end of 'is submit or update pressed?'
    if (!isset($_POST['searchBtn'])) {
        ?>
    <h2>Employee Request</h2>
    <?php 
    } else {
        echo '<h3>Lookup User</h3>';
    }
    ?>
      
 <form name="leave" id="leave" method="post" action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
">
      <input type='hidden' name='formName' value='leave' />
     <?php 
    if (isset($_POST['referNum'])) {
        echo 'Reference Request #' . $_POST['referNum'] . '<input type="hidden" name="referNum" value="' . $_POST['referNum'] . '" />';
    }
    $type = isset($_POST['type']) ? $_POST['type'] : '';
    $myq = "SELECT DESCR FROM TIMETYPE WHERE TIMETYPEID='" . $config->mysqli->real_escape_string($type) . "'";
    $result = $mysqli->query($myq);
    SQLerrorCatch($mysqli, $result);
    $typeDescr = $result->fetch_assoc();
    if (!empty($type)) {
        //$_POST['type'] is set
        //hidden field with type set
        echo "<input type='hidden' name='type' value='" . $type . "'>";
        //Lookup Users button pressed
        if (isset($_POST['searchBtn']) || isset($_POST['findBtn'])) {
            //Save any inputed values
            echo '<input type="hidden" name="subtype" value="' . $subtype . '" />';
            echo '<input type="hidden" name="ID" value="' . $postID . '" />';
            echo '<input type="hidden" name="usedate" value="' . $postUseDate . '" />';
            echo '<input type="hidden" name="thrudate" value="' . $postThruDate . '" />';
            echo '<input type="hidden" name="beg1" value="' . $postBeg1 . '" />';
            echo '<input type="hidden" name="beg2" value="' . $postBeg2 . '" />';
            echo '<input type="hidden" name="end1" value="' . $postEnd1 . '" />';
            echo '<input type="hidden" name="end2" value="' . $postEnd2 . '" />';
            echo '<input type="hidden" name="comment" value="' . $comment . '" />';
            echo '<input type="hidden" name="calloff" value="' . $calloff . '" />';
            //Get additional search inputs
            $searchUser = isset($_POST['searchUser']) ? $_POST['searchUser'] : '';
            $isFullTime = isset($_POST['fullTime']) ? true : false;
            $isReserve = isset($_POST['reserve']) ? true : false;
            echo '<input type="checkbox" name="fullTime" ';
            if ($isFullTime) {
                echo 'CHECKED';
            }
            echo ' />Full Time Employee&nbsp;&nbsp;  ';
            echo '<input type="checkbox" name="reserve" ';
            if ($isReserve) {
                echo 'CHECKED';
            }
            echo ' />Reserves<br />';
            echo '<input type="text" name="searchUser" value="' . $searchUser . '" /><input type="submit" name="findBtn" value="Search" /><br /><br />';
            if (isset($_POST['findBtn'])) {
                $rowCount = 0;
                if (!empty($searchUser) && $isFullTime) {
                    $rowCount = selectUserSearch($config, $searchUser, $rowCount, true);
                }
                if ($isReserve) {
                    $rowCount2 = searchReserves($config, $searchUser, $rowCount);
                } else {
                    $rowCount2 = $rowCount;
                }
                $rowCount3 = searchDatabase($config, $searchUser, $rowCount2);
                $totalRowsFound = $rowCount + $rowCount2 + $rowCount3;
                echo '<input type="hidden" name="totalRows" value="' . $totalRowsFound . '" />';
            }
            //end lookup button pressed
        } else {
            $foundUserFNAME = isset($foundUserFNAME) ? $foundUserFNAME : '';
            $foundUserLNAME = isset($foundUserLNAME) ? $foundUserLNAME : '';
            $foundUserName = isset($foundUserName) ? $foundUserName : '';
            $foundUserID = isset($foundUserID) ? $foundUserID : '';
            $totalRows = isset($_POST['totalRows']) ? $_POST['totalRows'] : '';
            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])) {
                            echo '<input type="hidden" name="isReserve" value="true" />';
                        }
                        break;
                    }
                    //end if
                }
                //end for
            }
            //echo "<p><h3>Type of Request: </h3>" . $typeDescr['DESCR'] . "</p>";
            echo "<p><h3>Type of Request: </h3>";
            selectTimeType($config, "type", $type);
            echo "</p>";
            //subtype choice
            echo "Subtype: ";
            $myq = "SELECT NAME FROM SUBTYPE";
            $result = $mysqli->query($myq);
            SQLerrorCatch($mysqli, $result);
            ?>
  <select name="subtype"> <?php 
            while ($row = $result->fetch_assoc()) {
                if (strcmp($row['NAME'], $subtype) == 0) {
                    echo '<option value="' . $row["NAME"] . '" SELECTED >' . $row["NAME"] . '</option>';
                } else {
                    echo '<option value="' . $row["NAME"] . '">' . $row["NAME"] . '</option>';
                }
            }
            echo "</select> </br>";
            if ($_SESSION['admin'] < 25) {
                //if normal user, allow only their own user name
                echo "<p>User ID: " . $_SESSION['userName'] . "<input type='hidden' name='ID' value='" . $_SESSION['userIDnum'] . "'></p>";
            } else {
                //allow any user to be picked for a calloff entry
                $isCallOff = "";
                if (isset($_POST['calloff'])) {
                    echo '<input type="checkbox" id="calloff" name="calloff" value="YES" CHECKED />';
                } else {
                    echo '<input type="checkbox" id="calloff" name="calloff" value="YES" />';
                }
                //echo 'onclick=\'addLookupButton("leave");\'';
                echo 'Call Off (ie. REPORT OFF)<br/>';
                echo "Employee: ";
                //user ID passed from search
                if ($totalRows > 0) {
                    echo '<input type="hidden" name="ID" value="' . $foundUserID . '" />' . $foundUserLNAME . ', ' . $foundUserFNAME;
                } else {
                    //dropDownMenu($mysqli, 'FULLNAME', 'EMPLOYEE', $postID, 'ID');
                    $myq = "SELECT `IDNUM` , `LNAME` , `FNAME` \r\n                            FROM `EMPLOYEE`\r\n                            WHERE `IDNUM` = " . $config->mysqli->real_escape_string($postID);
                    $result = $mysqli->query($myq);
                    SQLerrorCatch($mysqli, $result);
                    $row = $result->fetch_assoc();
                    echo $row['LNAME'] . ', ' . $row['FNAME'] . "<input type='hidden' name='ID' value='" . $postID . "'>";
                }
                echo ' <input type="submit" name="searchBtn" value="Lookup Employee" />';
                ?>
                    <script language="JavaScript" type="text/javascript">   
                    function addLookupButton(formName) {
//                        var _form = document.getElementById(formName);
//                        var _calloff = document.getElementById('calloff');
//                        if(_calloff.checked){
//                            if(document.getElementById('jsearchBtn')){}
//                            else{
//                                var _search = document.createElement('input');
//                                _search.type = "submit";
//                                _search.name = "searchBtn";
//                                _search.value = "Lookup Employee";
//                                _search.id = "jsearchBtn";
//                                _search.onclick = function(){_form.submit()};
//                                //_form.appendChild(_search);
//                                _form.insertBefore(_search, _calloff);
//                            }   
//                        }
//                        else{
//                            if(document.getElementById('jsearchBtn')){
//                                var _oldSearch = document.getElementById('jsearchBtn');
//                                _form.removeChild(_oldSearch);
//                            }
//                        }
                    }
                    </script>
                    <?php 
            }
            ?>
                <p>Date of use/accumulation: <?php 
            displayDateSelect('usedate', 'date_1', $postUseDate, true, !$isDateUse);
            ?>
                    Through date (optional): <?php 
            displayDateSelect('thrudate', 'date_2');
            ?>
</p>
                <p>Start time: <?php 
            showTimeSelector("beg", $postBeg1, $postBeg2);
            ?>
                <?php 
            if ($type == 'PR') {
                echo "<input type='radio' name='shift' value='8'>8 hour shift";
                echo "<input type='radio' name='shift' value='12'>12 hour shift";
                echo "</br>(Personal time must be used for an entire shift.)";
            } else {
                ?>
 End time: <?php 
                showTimeSelector("end", $postEnd1, $postEnd2);
                ?>
</p> <?php 
            }
            ?>
 


                </br>
                <p>Comment: <textarea rows="3" cols="40" name="comment" ><?php 
            echo $comment;
            ?>
</textarea></p>
                <?php 
            //popUpMessage($updatingRequest);
            if ($updatingRequest === 'submittedRequests' || $requestAccepted) {
                echo '<p><input type="hidden" name="formName" value="submittedRequests" />
                        <input type="submit" name="update" value="Update Request">
                        <input type="submit" name="duplicateBtn" value="Duplicate Request" />
                        <INPUT TYPE="button" value="Back to My Requests" onClick="parent.location=\'wts_index.php?myReq=true\'"></p>';
            } else {
                if (strpos($updatingRequest, 'hrEmpRep=true')) {
                    echo '<p><input type="hidden" name="formName" value="submittedRequests" />
                        <input type="submit" name="update" value="Update Request">
                        <input type="submit" name="duplicateBtn" value="Duplicate Request" />
                        <INPUT TYPE="button" value="Back to Approvals" onClick="parent.location=\'' . $updatingRequest . '\'"></p>';
                } else {
                    echo '<p><input type="submit" name="submit" value="Submit for Approval"></p>';
                }
            }
            ?>

        </form> 


        <?php 
        }
    } else {
        //intitial choice of type
        echo "<p><h3>Type of Request: </h3>";
        dropDownMenu($mysqli, 'DESCR', 'TIMETYPE', FALSE, 'type');
        echo "</p>";
    }
}
コード例 #2
0
ファイル: wts_search.php プロジェクト: rwgt0su/web-time-sheet
function displayUserLookup($config)
{
    //var_dump($_POST); //DEBUG
    //
    //Lookup Users button has been pressed
    if (isset($_GET['userLookup'])) {
        //save the calling form name to return to, unless it's the userLookup form
        /* if( strcmp($_POST['formName'], 'formName') )
           $_SESSION['callingForm']=$_POST['formName']; */
        $formName = isset($_POST['formName']) ? $_POST['formName'] : '';
        echo '<form name="userLookup" action="' . $_SERVER['REQUEST_URI'] . '" method="POST" >';
        echo '<input type="hidden" name="formName" value="' . $formName . '" />';
        //from hidden value in calling form. this is where we want to return to
        //echo $formName; //DEBUG
        //Save any inputted values
        if ($formName == 'leave') {
            echo '<input type="hidden" name="subtype" value="' . $subtype . '" />';
            echo '<input type="hidden" name="ID" value="' . $postID . '" />';
            echo '<input type="hidden" name="usedate" value="' . $postUseDate . '" />';
            echo '<input type="hidden" name="thrudate" value="' . $postThruDate . '" />';
            echo '<input type="hidden" name="beg1" value="' . $postBeg1 . '" />';
            echo '<input type="hidden" name="beg2" value="' . $postBeg2 . '" />';
            echo '<input type="hidden" name="end1" value="' . $postEnd1 . '" />';
            echo '<input type="hidden" name="end2" value="' . $postEnd2 . '" />';
            echo '<input type="hidden" name="comment" value="' . $comment . '" />';
            echo '<input type="hidden" name="calloff" value="' . $_POST['calloff'] . '" />';
            echo '<input type="hidden" name="type" value="' . $_POST['type'] . '" />';
        } else {
            if ($formName == 'secLog') {
                $secLogID = isset($_POST['secLogID']) ? $_POST['secLogID'] : '';
                $address = isset($_POST['address']) ? $_POST['address'] : '';
                $city = isset($_POST['city']) ? $_POST['city'] : '';
                $phone = isset($_POST['phone']) ? $_POST['phone'] : '';
                $shiftStart1 = isset($_POST['shiftStart1']) ? $_POST['shiftStart1'] : '';
                $shiftStart2 = isset($_POST['shiftStart2']) ? $_POST['shiftStart2'] : '';
                $shiftEnd1 = isset($_POST['shiftEnd1']) ? $_POST['shiftEnd1'] : '';
                $shiftEnd2 = isset($_POST['shiftEnd2']) ? $_POST['shiftEnd2'] : '';
                $dress = isset($_POST['dress']) ? $_POST['dress'] : '';
                $dateSelect = isset($_POST['dateSelect']) ? $_POST['dateSelect'] : '';
                $num_deputies = isset($_POST['num_deputies']) ? $_POST['num_deputies'] : 0;
                $gpID = isset($_POST['gpID']) ? $_POST['gpID'] : 0;
                if ($num_deputies > 0) {
                    $i = 0;
                    for ($i; $i < $num_deputies; $i++) {
                        $deputyID[$i] = isset($_POST['deputyID' . $i]) ? $_POST['deputyID' . $i] : false;
                        $radioNum[$i] = isset($_POST['radioNum' . $i]) ? $_POST['radioNum' . $i] : '';
                        $isReserve[$i] = isset($_POST['isReserve' . $i]) ? true : false;
                        echo '<input type="hidden" name="deputyID' . $i . '" value="' . $deputyID[$i] . '" />';
                        echo '<input type="hidden" name="radioNum' . $i . '" value="' . $radioNum[$i] . '" />';
                        if ($isReserve[$i] == 1) {
                            echo '<input type="hidden" name="isReserve' . $i . '" value="true" />';
                        }
                    }
                    echo '<input type="hidden" name="num_deputies" value="' . $i . '" />';
                }
                echo '<input type="hidden" name="gpID" value="' . $gpID . '" />';
                echo '<input type="hidden" name="secLogID" value="' . $secLogID . '" />';
                echo '<input type="hidden" name="address" value="' . $address . '" />';
                echo '<input type="hidden" name="city" value="' . $city . '" />';
                echo '<input type="hidden" name="phone" value="' . $phone . '" />';
                echo '<input type="hidden" name="shiftStart1" value="' . $shiftStart1 . '" />';
                echo '<input type="hidden" name="shiftStart2" value="' . $shiftStart2 . '" />';
                echo '<input type="hidden" name="shiftEnd1" value="' . $shiftEnd1 . '" />';
                echo '<input type="hidden" name="shiftEnd2" value="' . $shiftEnd2 . '" />';
                echo '<input type="hidden" name="dress" value="' . $dress . '" />';
                echo '<input type="hidden" name="dateSelect" value="' . $dateSelect . '" />';
                echo '<input type="hidden" name="addBtn" value="true" />';
            } else {
                if ($formName == 'radioLog') {
                    $radioLogID = isset($_POST['radioLogID']) ? $_POST['radioLogID'] : '';
                    $exchangeLogID = isset($_POST['exchangeLogID']) ? $_POST['exchangeLogID'] : '';
                    $radioID = isset($_POST['radioID']) ? $_POST['radioID'] : '';
                    $radioCallNum = isset($_POST['radioCallNum']) ? $_POST['radioCallNum'] : '';
                    $checkOutType = isset($_POST['checkOutType']) ? $_POST['checkOutType'] : '';
                    $num_deputies = isset($_POST['num_deputies']) ? $_POST['num_deputies'] : 0;
                    $dateSelect = isset($_POST['dateSelect']) ? $_POST['dateSelect'] : '';
                    $invLogComments = isset($_POST['nvLogComments']) ? $mysqli->real_escape_string(strtoupper($_POST['nvLogComments'])) : '';
                    $gpID = isset($_POST['gpID']) ? $_POST['gpID'] : 0;
                    $divID = isset($_POST['divisionID']) ? $_POST['divisionID'] : false;
                    if ($num_deputies > 0) {
                        $i = 0;
                        for ($i; $i < $num_deputies; $i++) {
                            $deputyID[$i] = isset($_POST['deputyID' . $i]) ? $_POST['deputyID' . $i] : false;
                            $radioNum[$i] = isset($_POST['radioNum' . $i]) ? $_POST['radioNum' . $i] : '';
                            $isReserve[$i] = isset($_POST['isReserve' . $i]) ? true : false;
                            echo '<input type="hidden" name="deputyID' . $i . '" value="' . $deputyID[$i] . '" />';
                            echo '<input type="hidden" name="radioNum' . $i . '" value="' . $radioNum[$i] . '" />';
                            if ($isReserve[$i] == 1) {
                                echo '<input type="hidden" name="isReserve' . $i . '" value="true" />';
                            }
                        }
                        echo '<input type="hidden" name="num_deputies" value="' . $i . '" />';
                    }
                    echo '<input type="hidden" name="gpID" value="' . $gpID . '" />';
                    if (!empty($exchangeLogID)) {
                        echo '<input type="hidden" name="exchangeLogID" value="' . $exchangeLogID . '" />';
                    }
                    echo '<input type="hidden" name="radioLogID" value="' . $radioLogID . '" />';
                    echo '<input type="hidden" name="radioID" value="' . $radioID . '" />';
                    echo '<input type="hidden" name="radioCallNum" value="' . $radioCallNum . '" />';
                    echo '<input type="hidden" name="checkOutType" value="' . $checkOutType . '" />';
                    echo '<input type="hidden" name="dateSelect" value="' . $dateSelect . '" />';
                    echo '<input type="hidden" name="invLogComments" value="' . $invLogComments . '" />';
                    echo '<input type="hidden" name="divisionID" value="' . $divID . '" />';
                    echo '<input type="hidden" name="addBtn" value="true" />';
                }
            }
        }
        $mysqli = $config->mysqli;
        //Get additional search inputs
        $searchUser = isset($_POST['searchUser']) ? $mysqli->real_escape_string($_POST['searchUser']) : '';
        //$isFullTime = isset($_POST['fullTime']) ? true : false;
        $isFullTime = false;
        $isReserve = isset($_POST['reserve']) ? true : false;
        $searchFullTime = isset($_POST['searchFullTime']) ? $_POST['searchFullTime'] : true;
        $searchReserves = isset($_POST['searchReserves']) ? $_POST['searchReserves'] : true;
        //save the state of these values from the search results
        if (strcmp($searchReserves, "false") == 0) {
            echo '<input type="hidden" name="searchReserves" value="false" />';
            $searchReserves = false;
        }
        if (strcmp($searchReserves, "checked") == 0) {
            $isReserve = true;
        }
        if (strcmp($searchFullTime, "false") == 0) {
            echo '<input type="hidden" name="searchFullTime" value="false" />';
            $searchFullTime = false;
        }
        if (strcmp($searchFullTime, "checked") == 0) {
            $isFullTime = true;
        }
        echo '<h3>Search for Employees by Last Name: </h3>';
        //show check boxes and keep checked box checked after results return
        //        if($searchFullTime){
        //            echo '<input type="checkbox" name="fullTime" ';
        //            if ($isFullTime)
        //                echo 'CHECKED';
        //            echo ' />Full Time Employee&nbsp;&nbsp;  ';
        //        }
        if ($searchReserves) {
            echo '<input type="checkbox" name="reserve" ';
            if ($isReserve) {
                echo 'CHECKED';
            }
            echo ' />Reserves';
        }
        echo '<br /><input type="text" name="searchUser" value="' . $searchUser . '" />
            <input type="submit" name="findBtn" value="Search" /><br />';
        echo '(Enter all or part of an employee\'s last name)</br></br>';
        //echo '</form>';
        if (isset($_POST['findBtn']) && !empty($searchUser)) {
            //echo '<form method="POST">';
            $rowCount = 0;
            $rowCount = searchDatabase($config, $searchUser, $rowCount);
            if (!empty($searchUser) && $isFullTime) {
                $rowCount += selectUserSearch($config, $searchUser, $rowCount, true);
            }
            if ($isReserve) {
                $rowCount += searchReserves($config, $searchUser, $rowCount);
            }
            echo '<input type="hidden" name="totalRows" value="' . $rowCount . '" />';
            echo '</form>';
        }
        //end lookup button pressed
    } else {
        //lookup button not pressed, show button to get to lookup page
        echo '<button type="button"  name="searchBtn" value="Lookup Employee" onClick="this.form.action=' . "'?userLookup=true'" . ';this.form.submit()" >Lookup Employee</button>';
    }
}