function printCurrentRaiseTable()
{
    global $area;
    global $netID;
    global $db;
    //This query sums up the raises field to give us accurate wage totals.
    try {
        $logQuery = $db->prepare("SELECT `index`, `netID`, `raise`, FORMAT((SELECT SUM(ew.raise) FROM `employeeRaiseLog` AS ew WHERE ew.date <= ew_outer.date AND ew.netid = ew_outer.netid), 2)\n\t\t\t AS `newWage`, `submitter`, `date`, `comments`, `isSubmitted` FROM `employeeRaiseLog` AS `ew_outer` WHERE `submitter` = :netId AND isSubmitted='0' ORDER BY netID ASC,`date` ASC");
        $logQuery->execute(array(':netId' => $netID));
    } catch (PDOException $e) {
        exit("error in query");
    }
    while ($curRaise = $logQuery->fetch(PDO::FETCH_ASSOC)) {
        echo "<tr><td>";
        echo "<input type='checkbox' name='email[" . $curRaise['index'] . "]' id='email[" . $curRaise['index'] . "]' value='1' </td><td>";
        echo nameByNetId($curRaise['netID']) . "</td><td>";
        echo $curRaise['newWage'] . "</td><td>";
        echo $curRaise['raise'] . "</td><td>";
        echo $curRaise['comments'] . "</td><td>";
        echo date("Y-m-d", strtotime($curRaise['date'])) . "</td><td>";
        echo "<input type='button' value='Edit' id='edit" . $curRaise['index'] . "' onclick='javascript:newwindow(\"../editRaise.php?raiseId=" . $curRaise['index'] . "\")' /></td><td>";
        echo "<input type='button' value='Delete' id='delete" . $curRaise['index'] . "' onclick='deleteRaise(" . $curRaise['index'] . ")' />";
        echo "</td></tr>";
    }
}
function printFamousPeople()
{
    global $area, $db;
    try {
        $commendableQuery = $db->prepare("SELECT * FROM `reportCommendable` WHERE `public`='1' AND `area`=:area AND `timeStamp` > (NOW() - INTERVAL 3 WEEK) ORDER BY timeStamp DESC");
        $commendableQuery->execute(array(':area' => $area));
    } catch (PDOException $e) {
        exit("error in query");
    }
    if ($first = $commendableQuery->fetch(PDO::FETCH_ASSOC)) {
        echo "<div class='employee'>";
        echo "<img class='employeeImage' src='" . getenv("BYUPIPHOTO") . "?n={$first['employee']}'>";
        echo "<div class='employeeName'>" . nameByNetId($first['employee']) . "</div>";
        echo "<div class='date'>" . $first['date'] . "</div>";
        echo "<div class='comments'>" . $first['reason'] . "</div>";
        echo "</div>";
        while ($cur = $commendableQuery->fetch(PDO::FETCH_ASSOC)) {
            echo "<div class='employee'>";
            echo "<img class='employeeImage' src='" . getenv("BYUPIPHOTO") . "?n={$cur['employee']}'>";
            echo "<div class='employeeName'>" . nameByNetId($cur['employee']) . "</div>";
            echo "<div class='date'>" . $cur['date'] . "</div>";
            echo "<div class='comments'>" . $cur['reason'] . "</div>";
            echo "</div>";
        }
        echo "</table>";
    } else {
        echo "<h2 align='center'>No Commendables awarded in the last week.</h2>";
    }
}
function displayTeamsTable($area)
{
    global $db;
    try {
        $teamsQuery = $db->prepare("SELECT * FROM teams WHERE area=:area ORDER BY name");
        $teamsQuery->execute(array(':area' => $area));
    } catch (PDOException $e) {
        exit("error in query");
    }
    while ($curTeam = $teamsQuery->fetch(PDO::FETCH_ASSOC)) {
        echo "<tr>";
        echo "<td>" . $curTeam['name'] . "</td>";
        echo "<td>" . nameByNetId($curTeam['lead']) . "</td>";
        echo "<td>" . $curTeam['email'] . "</td>";
        try {
            $membersQuery = $db->prepare("SELECT * FROM `teamMembers` JOIN `employee` ON `teamMembers`.`netID`=`employee`.`netID` WHERE `teamMembers`.`teamID` = :id ORDER BY `employee`.`firstName`");
            $membersQuery->execute(array(':id' => $curTeam['ID']));
        } catch (PDOException $e) {
            exit("error in query");
        }
        echo "<td>";
        while ($cur = $membersQuery->fetch(PDO::FETCH_ASSOC)) {
            echo nameByNetId($cur['netID']);
            if ($cur['isSupervisor']) {
                echo " (Supervisor)";
            }
            echo "<br/>";
        }
        echo "</td></tr>";
    }
}
function formEmail($postData)
{
    echo "Subject: " . getEmailType($postData['type']) . "Executive Notification: ";
    echo $postData['subject'];
    echo "\nNotification Time: " . $postData['time'];
    echo "\nNotification Date: " . date('m/d/Y', strtotime($postData['date']));
    echo "\nParent Ticket: INC" . $postData['parentTicket'];
    echo "\nPriority: " . $postData['priority'];
    echo "\nIncident Coordinator: " . nameByNetId($postData['ic']);
    echo "\nProblem Description: " . $postData['desc'];
}
function printEmployees()
{
    global $netID;
    global $readPermission;
    if ($readPermission) {
        echo "<select id='employees' name='employees' onchange>";
        employeeFillCurrentArea();
        echo "</select>";
    } else {
        echo nameByNetId($netID);
    }
}
 function formatEmailBody($supressed)
 {
     global $netID, $db;
     $body = '';
     $count = 0;
     echo "<br/>";
     //This queries for the list of employees you have raises pending for, with each net ID appearing once.
     try {
         $employeeQuery = $db->prepare("SELECT DISTINCT netID FROM employeeRaiseLog WHERE submitter = :netId AND isSubmitted = '0' ORDER BY netID ASC");
         $employeeQuery->execute(array(':netId' => $netID));
     } catch (PDOException $e) {
         exit("error in query");
     }
     //This cycles through each net ID producing the section of the email for that net ID
     while ($cur = $employeeQuery->fetch(PDO::FETCH_ASSOC)) {
         $count = 0;
         $toBeAdded = '';
         $toBeAdded .= "<b>" . nameByNetId($cur['netID']) . " - BYU ID: " . getEmployeeByuIdByNetId($cur['netID']) . " - Net ID: " . $cur['netID'] . "</b><br/>";
         $toBeAdded .= "<table><tr><th>Reason</th><th>Raise</th><th>Date Effective</th></tr>";
         //Queries for ALL pending raises for the current net ID that was submitted by you
         try {
             $logQuery = $db->prepare("SELECT * FROM employeeRaiseLog WHERE submitter = :submitter AND isSubmitted = '0' AND netID = :employee ORDER BY date ASC");
             $logQuery->execute(array(':submitter' => $netID, ':employee' => $cur['netID']));
         } catch (PDOException $e) {
             exit("error in query");
         }
         //Adds each pending raise to the html table in the email.
         while ($raise = $logQuery->fetch(PDO::FETCH_ASSOC)) {
             if (!in_array($raise['index'], $supressed)) {
                 $toBeAdded .= "<tr>";
                 $toBeAdded .= "<td>" . $raise['comments'] . "</td>";
                 $toBeAdded .= "<td><b>" . $raise['raise'] . "</b></td>";
                 $toBeAdded .= "<td>" . date('Y-m-d', strtotime($raise['date'])) . "</td>";
                 $toBeAdded .= "</tr>";
                 $count++;
             }
             //This updates the raise in the database to no longer be pending.
             try {
                 $updateQuery = $db->prepare("UPDATE employeeRaiseLog SET isSubmitted = '1' WHERE `index` = :index");
                 $updateQuery->execute(array(':index' => $raise['index']));
             } catch (PDOException $e) {
                 exit("error in query");
             }
         }
         $toBeAdded .= "<tr><th>New wage</th><th>" . getEmployeeWageByNetId($cur['netID']) . "</th>";
         $toBeAdded .= "</table><br/><br/>";
         if ($count > 0) {
             $body .= $toBeAdded;
         }
     }
     return $body;
 }
function printAvailableMonitors()
{
    global $db;
    try {
        $incompleteQuery = $db->prepare("SELECT * FROM silentMonitor WHERE completed ='0' AND `deleted` = '0' ORDER BY submitDate ASC");
        $incompleteQuery->execute();
    } catch (PDOException $e) {
        exit("error in query");
    }
    while ($cur = $incompleteQuery->fetch(PDO::FETCH_ASSOC)) {
        echo '<input type="radio" name="id" id="id" value="' . $cur['index'] . '" />Started on: ' . date("l, M j, Y", strtotime($cur['submitDate'])) . ', for ' . nameByNetId($cur['netID']) . '  <a href="deleteMonitor.php?id=' . $cur['index'] . '">Delete</a><br />';
    }
}
function printEmployees($employee)
{
    global $netID;
    global $admin;
    global $area;
    if ($admin) {
        echo "<select id='employees' name='employees' onchange>";
        echo employeeFillSelected($employee, $area);
        echo "</select>";
    } else {
        echo nameByNetId($netID);
    }
}
function sendEmail($comments, $location)
{
    global $area;
    global $env;
    global $netID;
    $employeeName = nameByNetId($netID);
    $employeeEmail = getEmployeeEmailByNetId($netID);
    $subject = 'Info Change Request';
    $emailBody = <<<STRING
\t<b>Info Change Request: </b> <br />{$comments}<br /> <br />
\t<b>Location: </b>{$location}<br /> <br />
\t
\tThank you, <br />
\t{$employeeName}
\t
STRING;
    if ($env == 2) {
        if ($area == 3) {
            //Service Desk
            $to = getenv("SDALIAS");
        } else {
            if ($area == 4) {
                //COS
                $to = getenv("COSALIAS");
            } else {
                if ($area == 6) {
                    // Security Desk
                    $to = getenv("SECURITYDESKEMAILS");
                }
            }
        }
    } else {
        $to = getenv("DEVEMAILADDRESS");
    }
    $headers = 'From: ' . $employeeName . ' <' . $employeeEmail . '>' . "\r\n";
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'Return-Path: ' . $employeeEmail . "\r\n";
    if (mail($to, $subject, $emailBody, $headers)) {
        echo '<h2 style="text-align: center;">Email was sent successfully.</h2>';
    } else {
        echo '<h2 style="text-align: center;">Email failed to be sent.</h2>';
    }
}
function printReport($employee, $start, $end, $securityProblems, $shiftProblems, $misc, $params)
{
    global $area, $admin, $db;
    $default = ' 1=1 ';
    $params[':area'] = $area;
    $params[':start'] = $start;
    $params[':end'] = $end;
    try {
        $securityDeskQuery = $db->prepare("SELECT * FROM `supervisorReportSecurityDesk` WHERE `area` = :area AND `date` >= :start AND `date` <= :end AND (" . $default . $employee . $securityProblems . $shiftProblems . $misc . ")");
        $securityDeskQuery->execute($params);
    } catch (PDOException $e) {
        exit("error in query");
    }
    if ($first = $securityDeskQuery->fetch(PDO::FETCH_ASSOC)) {
        echo "<table>\r\n\t\t\t\t<tr>\r\n\t\t\t\t<th>Employee</th><th>Date</th><th>Shift</th><th>securityProblems</th><th>Shift Problems</th>\r\n\t\t\t\t<th>Misc</th><th></th></tr>";
        echo "<tr>";
        echo "<td>" . nameByNetId($first['submitter']) . "</td>";
        echo "<td>" . $first['date'] . "</td>";
        echo "<td>" . $first['startTime'] . " - " . $first['endTime'] . "</td>";
        echo "<td>" . $first['securityProblems'] . "</td>";
        echo "<td>" . $first['shiftProblems'] . "</td>";
        echo "<td>" . $first['misc'] . "</td><td>";
        if ($admin) {
            echo "<input type='button' value='Edit' onclick=editReport('" . $first['ID'] . "') />";
        }
        echo "</td></tr>";
        while ($cur = $securityDeskQuery->fetch(PDO::FETCH_ASSOC)) {
            echo "<tr>";
            echo "<td>" . nameByNetId($cur['submitter']) . "</td>";
            echo "<td>" . $cur['date'] . "</td>";
            echo "<td>" . $cur['startTime'] . " - " . $cur['endTime'] . "</td>";
            echo "<td>" . $cur['securityProblems'] . "</td>";
            echo "<td>" . $cur['shiftProblems'] . "</td>";
            echo "<td>" . $cur['misc'] . "</td><td>";
            if ($admin) {
                echo "<input type='button' value='Edit' onclick=editReport('" . $cur['ID'] . "') />";
            }
            echo "</td></tr>";
        }
        echo "</table>";
    } else {
        echo "No reports during this period";
    }
}
function sendEmail($employeeNetID, $timeStamp, $supervisor)
{
    global $area;
    global $env;
    $server = '';
    $to = '';
    if ($env == 0) {
        $server = getenv("DEVURL");
    } else {
        if ($env == 1) {
            $server = getenv("STAGEURL");
        } else {
            if ($env == 2) {
                $server = getenv("PRODURL");
            }
        }
    }
    $timeStampDate = explode(" ", $timeStamp);
    // $timeStampDate[0] = yyyy/mm/dd // $timeStampDate[1]  hh:mm:ss
    $timeStampTime = explode(":", $timeStampDate[1]);
    $formattedTimeStamp = $timeStampDate[0] . '-' . $timeStampTime[0] . '-' . $timeStampTime[1] . '-' . $timeStampTime[2];
    $subject = 'Ticket Reviews were submitted for you';
    $emailBody = 'Dear ' . nameByNetId($employeeNetID) . ', <br /><br />';
    $emailBody .= 'Ticket Reviews were submitted for you by ' . nameByNetId($supervisor) . '.  Please view the information in the link below.<br /> <br />';
    $emailBody .= '<a href=https://' . $server . '/ticketReview/individualTicketReview.php?employee=' . $employeeNetID . '&timeSubmitted=' . urlencode($formattedTimeStamp) . '>Click here to see your ticket reviews</a><br /><br />Or copy this link in the address bar of your browser.<br /> 
	https://' . $server . '/ticketReview/individualTicketReview.php?employee=' . $employeeNetID . '&timeSubmitted=' . urlencode($formattedTimeStamp) . '<br /><br />Thanks!';
    if ($env == 2) {
        $to = getEmployeeEmailByNetId($employeeNetID);
    } else {
        $to = getenv("DEVEMAILADDRESS");
    }
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: ' . nameByNetId($supervisor) . ' <' . getEmployeeEmailByNetId($supervisor) . '>' . "\r\n";
    $headers .= 'Return-Path: ' . getEmployeeEmailByNetId($supervisor) . "\r\n";
    if (mail($to, $subject, $emailBody, $headers)) {
        return true;
    } else {
        return false;
    }
}
function getICList($selected)
{
    global $db;
    try {
        $permissionQuery = $db->prepare("SELECT * FROM `permissionArea` JOIN `permission` ON `permissionArea`.`permissionId` = `permission`.`permissionId` WHERE shortName='ic'");
        $permissionQuery->execute();
    } catch (PDOException $e) {
        exit("error in query");
    }
    $perm = $permissionQuery->fetch(PDO::FETCH_ASSOC);
    try {
        $employeePermissionQuery = $db->prepare("SELECT * FROM employeePermissions JOIN employee ON `employeePermissions`.`netID` = `employee`.`netID` WHERE employeePermissions.permission = :permission ORDER BY `employee`.`firstName`");
        $employeePermissionQuery->execute(array(':permission' => $perm['index']));
    } catch (PDOException $e) {
        exit("error in query");
    }
    while ($cur = $employeePermissionQuery->fetch(PDO::FETCH_ASSOC)) {
        if ($selected == $cur['netID']) {
            echo "<option value='" . $cur['netID'] . "' selected>" . nameByNetId($cur['netID']) . "</option>";
        } else {
            echo "<option value='" . $cur['netID'] . "'>" . nameByNetId($cur['netID']) . "</option>";
        }
    }
}
</script>
<form id='reportData' method='post' onsubmit="return confirmSubmission()">
<input type="hidden" id="employeeName" name="employeeName" value="<?php 
echo nameByNetId($netID);
?>
">
<input type="hidden" id="employeeEmail" name="employeeEmail" value="<?php 
echo getEmployeeEmailByNetId($netID);
?>
">
<div id='headInfo'>
<h1>Supervisor Report Form</h1>
<table>
	<tr>
	<th>NAME: <?php 
echo nameByNetId($netID);
?>
</th>
	<th colspan='2'>EMAIL: <?php 
echo getEmployeeEmailByNetId($netID);
?>
</th><th>Load Draft</th><th>Save as Draft</th><th>Report Finished?</th>
	</tr><tr>
	<td>DATE: <input type='text' class='datepicker' size='10' id='reportDate' name='reportDate' value="<?php 
echo date('Y-m-d', strtotime("today"));
?>
" /></td>
	<td>Start Time: <input type="text" name="start" id='start' maxlength=5 size=8 value="<?php 
echo date('h:iA');
?>
"/></td>
//------------TASK TO BE COMPLETED------------------
try {
    $tasksQuery = $db->prepare("SELECT * FROM routineTasks WHERE ID=:id");
    $tasksQuery->execute(array(':id' => $_REQUEST['id']));
} catch (PDOException $e) {
    exit("error in query");
}
$task = $tasksQuery->fetch(PDO::FETCH_ASSOC);
//------------SET VARIABLES---------------------
$title = $task['title'];
$timeDue = $task['timeDue'];
$area = $task['area'];
$completed = '1';
$timeCompleted = date('G:i');
$dateCompleted = date('Y-m-d');
$completedBy = nameByNetId($netID);
//------------------------------------------------
//Query to test whether this task is in the log already ie. its been muted.
try {
    $logQuery = $db->prepare("SELECT * FROM routineTaskLog WHERE taskId =:taskId AND (dateMuted IS NOT NULL AND dateCompleted IS NULL)");
    $logQuery->execute(array(':taskId' => $taskId));
} catch (PDOException $e) {
    exit("error in query");
}
$mutedTask = $logQuery->fetch(PDO::FETCH_ASSOC);
$logID = $mutedTask['ID'];
//queries the database and then add or updates an entry to the TaskLog
try {
    $insertQuery = $db->prepare("INSERT INTO routineTaskLog (ID,title,taskId,timeDue,dateDue,area,completed,completedBy,timeCompleted,dateCompleted,comments,guid) VALUES (:id,:title,:taskId,:timeDue,:dateDue,:area,:completed,:by,:timeCompleted,:dateCompleted,:comments,:guid) ON DUPLICATE KEY UPDATE title=:title2,taskId=:taskId2,timeDue=:timeDue2,area=:area2,completed=:completed2,completedBy=:by2,timeCompleted=:timeCompleted2,dateCompleted=:dateCompleted2,comments=:comments2");
    $insertQuery->execute(array(':id' => $logID, ':title' => $title, ':taskId' => $taskId, ':timeDue' => $timeDue, ':dateDue' => $dateDue, ':area' => $area, ':completed' => $completed, ':by' => $completedBy, ':timeCompleted' => $timeCompleted, ':dateCompleted' => $dateCompleted, ':comments' => $comments, ':guid' => newGuid(), ':title2' => $title, ':taskId2' => $taskId, ':timeDue2' => $timeDue, ':area2' => $area, ':completed2' => $completed, ':by2' => $completedBy, ':timeCompleted2' => $timeCompleted, ':dateCompleted2' => $dateCompleted, ':comments2' => $comments));
} catch (PDOException $e) {
function printTeamOrganizer($area)
{
    global $db;
    try {
        $employeeQuery = $db->prepare("SELECT * FROM employee WHERE area=:area AND active='1' ORDER BY firstName ASC");
        $employeeQuery->execute(array(':area' => $area));
    } catch (PDOException $e) {
        exit("error in query");
    }
    $nameCount = 1;
    while ($cur = $employeeQuery->fetch(PDO::FETCH_ASSOC)) {
        try {
            $membersQuery = $db->prepare("SELECT * FROM teamMembers WHERE netID = :netId AND `area` = :area");
            $membersQuery->execute(array(':netId' => $cur['netID'], ':area' => $area));
            $teamCountQuery = $db->prepare("SELECT COUNT(ID) FROM teamMembers WHERE netID = :netId AND `area` = :area");
            $teamCountQuery->execute(array(':netId' => $cur['netID'], ':area' => $area));
        } catch (PDOException $e) {
            exit("error in query");
        }
        $countResult = $teamCountQuery->fetch(PDO::FETCH_NUM);
        $numOfTeamsEmployeeBelongsTo = $countResult[0];
        if ($numOfTeamsEmployeeBelongsTo > 0) {
            while ($teamMember = $membersQuery->fetch(PDO::FETCH_ASSOC)) {
                $teamID = $teamMember['teamID'];
                echo "<tr><td>";
                echo nameByNetId($cur['netID']);
                echo "</td><td>";
                echo teamLeadByTeamID($teamID);
                echo "</td><td>";
                if ($numOfTeamsEmployeeBelongsTo > 1) {
                    //Make the selects name unique if employee belongs to multiple teams.
                    echo teamSelectByTeam($teamID, $nameCount, $cur['netID']);
                    echo "</td><td id='futureTeamLeader_" . $nameCount . "'></td></tr>";
                    $nameCount++;
                } else {
                    echo teamSelectByTeam($teamID, $nameCount, $cur['netID']);
                    echo "</td><td id='futureTeamLeader_" . $nameCount . "'></td></tr>";
                    $nameCount++;
                }
            }
        } else {
            $teamID = 0;
            echo "<tr><td>";
            echo nameByNetId($cur['netID']);
            echo "</td><td>";
            echo teamLeadByTeamID($teamID);
            echo "</td><td>";
            echo teamSelectByTeam($teamID, $nameCount, $cur['netID']);
            echo "</td><td id='futureTeamLeader_" . $nameCount . "'></td></tr>";
            $nameCount++;
        }
    }
}
         $deleteQuery = $db->prepare("DELETE FROM `supervisorReportDraft` WHERE `ID` = :id");
         $deleteQuery->execute(array(':id' => $draftID));
     } catch (PDOException $e) {
         exit("error in query");
     }
 } else {
     if ($action == 'load') {
         $draftID = $_GET['id'];
         try {
             $draft2Query = $db->prepare("SELECT * FROM `supervisorReportDraft` WHERE `ID` = :id");
             $draft2Query->execute(array(':id' => $draftID));
         } catch (PDOException $e) {
             exit("error in query");
         }
         $row = $draft2Query->fetch(PDO::FETCH_ASSOC);
         echo "<form id='reportData' method='post' onsubmit='return confirmSubmission()'>\n<input type='hidden' id='employeeName' name='employeeName' value='" . nameByNetId($row['submitter']) . "'>\n<input type='hidden' id='employeeEmail' name='employeeEmail' value='" . getEmployeeEmailByNetId($row['submitter']) . "'>\n<div id='headInfo'>\n<h1>Supervisor Report Form</h1>\n<table>\n\t<tr>\n\t<th>NAME: " . nameByNetId($row['submitter']) . "</th>\n\t<th colspan='2'>EMAIL: " . getEmployeeEmailByNetId($row['submitter']) . "</th><th>Load Draft</th><th>Save as Draft</th><th>Report Finished?</th>\n\t</tr><tr>\n\t<td>DATE: <input type='text' class='tcal' size='10' id='reportDate' name='reportDate' value='" . $row['date'] . "' /></td>\n\t<td>Start Time: <input type='text' name='start' id='start' maxlength=5 size=8 value='" . $row['startTime'] . "'/></td>\n\t<td>End Time: <input type='text' name='end' id='end' maxlength=5 size=8 value='" . $row['endTime'] . "'/></td>\n\t<td><input type='button' name='load' id='load' value='Load Draft' onClick='loadDraftDialog()'/></td>\n\t<td><input type='button' name='save' id='save' value='Save Draft' onClick='saveDraft()' /></td>\n\t<td><input type='submit' name='submit' id='submit' value='Submit Report'/></td>\n\t</tr>\n</table>\n</div>\n<div id='instructions'>\n<br/>\n<b>Report Instructions: </b>Click <a href='reportInstructions.php'>here</a> for detailed instructions.\n<br/>\n<br/>\n1. Include ALL details: TIME, names, situations,etc.<br/>\n2. Keep this form open throught your shift and record things as they occur.<br/><br/>\nUse these buttons to enter in activites as they occur.<br/>\n<input type='button' id='absence' name='absence' value='Absence' onclick='newwindow('../performance/absence.php')' />\n<input type='button' id='tardy' name='tardy' value='Tardy' onclick='newwindow('../performance/tardy.php')' />\n<input type='button' id='reminder' name='reminder' value='Policy Reminder' onclick='newwindow('../performance/policyReminder.php')' />\n<input type='button' id='commendable' name='commendable' value='Commendable Performance' onclick='newwindow('../performance/commendablePerformance.php')' />\n</div>\n<br/>\n<div id='openResults'>\n</div>\n<br/>\n<div id='textFields'>\n<table>\n\t<tr>\n\t<th>PRODUCT/SERVICE OUTAGES EXPERIENCED AND MESSAGE RELAYS RECEIVED:<br/> Include any service outage affecting our customers. (ie: problems with Route Y, servers, IP Phones, AIM, etc.)</th>\n\t</tr><tr>\n\t<td><textarea id='first' name='first' cols='100' rows='4'>" . $row['outages'] . "</textarea></td>\n\t</tr><tr>\n\t<th>SHIFT PROBLEMS: <br/>Include high queue loads and possible reasons why. (ie: building evacuations, fire alarms, power outages, etc.)</th>\n\t</tr><tr>\n\t<td><textarea id='second' name='second' cols='100' rows='4'>" . $row['problems'] . "</textarea></td>\n\t</tr><tr>\n\t<th>MISCELLANEOUS INFORMATION: <br/>Include anything you want to bring to our attention. (ie: problems with consoles, applications, or our office computers, alarms, etc.)</th>\n\t</tr><tr>\n\t<td><textarea id='third' name='third' cols='100' rows='4'>" . $row['misc'] . "</textarea></td>\n\t</tr><tr>\n\t<th>SUPERVISING TASKS:<br/>Include what you did while supervising. (ie: teaming, projects, mentoring, reviewing tickets, etc.)</th>\n\t</tr><tr>\n\t<td><textarea id='fourth' name='fourth' cols='100' rows='4'>" . $row['supTasks'] . "</textarea></td>\n\t</tr>\n</table>\n</div>\n<br/>\n<div id='closeResults'>\n</div>\n<input type='hidden' id='checkList' name='checkList' value=''>\n</form>";
     } else {
         if ($action == 'checkList') {
             $list = $_GET['list'];
             $draftID = $_GET['id'];
             if ($list == 0) {
                 echo "<table id='openList'>\n\t\t<tr>\n\t\t<th>Opening Office Checklist<br/><input type='checkbox' id='openingList' name='openingList' /><label for='opening' >Please check if this is an opening shift</label></th><td>";
                 if (can("update", "7db1df8d-0a15-46ed-9c83-701393e9596c")) {
                     echo "<input type='button' value=\"Add Item\" onclick='addItem(0)' />";
                 }
                 echo "<input type='button' value=\"Reload\" onclick='printList(0,\"openResults\")' /></td></tr>";
             } else {
                 echo "<table id='closeList'>\n\t\t<tr>\n\t\t<th>Closing Office Checklist<br/><input type='checkbox' id='closingList' name='closingList' /><label for='closing' >Please check if this is a closing shift</label></th><td>";
                 if (can("update", "7db1df8d-0a15-46ed-9c83-701393e9596c")) {
                     echo "<input type='button' value=\"Add Item\" onclick='addItem(1)' />";
                 }
<?php

require '../includes/includeMeBlank.php';
//This script is run to post a trade
global $netID;
$name = nameByNetId($netID);
$tradeArray = array();
if (isset($_POST['JSON'])) {
    $tradeArray = json_decode($_POST['JSON'], true);
} else {
    $tradeArray = json_decode($_GET['JSON'], true);
}
$tradeMessage = "{$name} put some shifts up for trade. See the available trades page for details.";
foreach ($tradeArray as $trade) {
    $postedBy = $trade['postedBy'];
    $postedDate = date("Y-m-d", strtotime("today"));
    $shiftId = $trade['shiftId'];
    $startDate = $trade['startDate'];
    $startTime = $trade['startTime'];
    $endDate = $trade['endDate'];
    $endTime = $trade['endTime'];
    $hourType = $trade['hourType'];
    if (isset($trade['notes'])) {
        $notes = $trade['notes'];
    } else {
        $notes = '';
    }
    try {
        $insertQuery = $db->prepare("INSERT INTO `scheduleTrades` (postedBy,postedDate,shiftId,startTime,startDate,endTime,endDate,hourType,notes,area,guid)\n\t\t\t\t\tVALUES(:postedBy,:postedDate,:shiftId,:startTime,:startDate,:endTime,:endDate,:hourType,:notes,:area,:guid)");
        $insertQuery->execute(array(':postedBy' => $postedBy, ':postedDate' => $postedDate, ':shiftId' => $shiftId, ':startTime' => $startTime, ':startDate' => $startDate, ':endTime' => $endTime, ':endDate' => $endDate, ':hourType' => $hourType, ':notes' => $notes, ':area' => $area, ':guid' => newGuid()));
    } catch (PDOException $e) {
function getCommentLog($name, $start, $end)
{
    global $admin;
    global $terminated;
    global $db;
    $query = '';
    if (isset($terminated) && $terminated == 'true') {
        $queryString = "SELECT * FROM reportComments WHERE netID=:name";
        $queryParams = array(':name' => $name);
    } else {
        $queryString = "SELECT * FROM reportComments WHERE netID=:name AND date >= :start AND date <= :end";
        $queryParams = array(':name' => $name, ':start' => $start, ':end' => $end);
    }
    try {
        $commentsQuery = $db->prepare($queryString);
        $commentsQuery->execute($queryParams);
    } catch (PDOException $e) {
        exit("error in query");
    }
    if ($first = $commentsQuery->fetch(PDO::FETCH_ASSOC)) {
        echo "<table>\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Employee</th>\n\t\t\t\t\t<th>Date</th>\n\t\t\t\t\t<th>Submitted By</th>\n\t\t\t\t\t<th>Comment</th>\n\t\t\t\t\t<th>Meeting Request</th>";
        if ($admin) {
            echo "<th></th>\n\t\t\t\t\t<th></th>";
        }
        echo "</tr>";
        echo "<tr>";
        echo "<td>" . nameByNetId($first['netID']) . "</td>";
        echo "<td>" . date("Y-m-d", strtotime($first['date'])) . "</td>";
        echo "<td>" . nameByNetId($first['submitter']) . "</td>";
        echo "<td>" . $first['comments'] . "</td>";
        echo "<td>";
        if ($first['meetingRequest'] == 1) {
            echo "Yes";
        } else {
            echo "No";
        }
        echo "</td>";
        if ($admin) {
            echo "<td><input type='button' value='Edit' onclick='editLog(\"" . $first['id'] . "\",\"comment\")' /></td>";
            echo "<td><input type='button' value='Delete' onclick='deleteLog(\"" . $first['id'] . "\",\"Comments\")' /></td>";
        }
        echo "</tr>";
        while ($current = $commentsQuery->fetch(PDO::FETCH_ASSOC)) {
            echo "<tr>";
            echo "<td>" . nameByNetId($current['netID']) . "</td>";
            echo "<td>" . date("Y-m-d", strtotime($current['date'])) . "</td>";
            echo "<td>" . nameByNetId($current['submitter']) . "</td>";
            echo "<td>" . $current['comments'] . "</td>";
            echo "<td>";
            if ($current['meetingRequest'] == 1) {
                echo "Yes";
            } else {
                echo "No";
            }
            echo "</td>";
            if ($admin) {
                echo "<td><input type='button' value='Edit' onclick='editLog(\"" . $current['id'] . "\",\"comment\")' /></td>";
                echo "<td><input type='button' value='Delete' onclick='deleteLog(\"" . $current['id'] . "\",\"Comments\")' /></td>";
            }
            echo "</tr>";
        }
        echo "</table>";
    } else {
        echo "0 Comments for this period";
    }
}
            $netId = $curShift['employee'];
            if (!in_array($netId, $employees)) {
                continue;
            }
            if (checkStartShift($curShift, $hour) && $printMode == false) {
                echo "<span style='color:green'>" . nameByNetId($netId) . "</span>";
                if (can("access", "033e3c00-4989-4895-a4d5-a059984f7997")) {
                    echo " <a href='https://" . $_SERVER['SERVER_NAME'] . "/performance/tardy.php?employee=" . $netId . "&startTime=" . $hour . "' >(T)</a>";
                    echo " <a href='https://" . $_SERVER['SERVER_NAME'] . "/performance/absence.php?employee=" . $netId . "&startTime=" . $hour . "'>(A)</a>";
                }
                echo " (" . date("g:ia", strtotime($curShift['startTime'])) . " - " . date("g:ia", strtotime($curShift['endTime'])) . ")";
            } else {
                if (checkEndShift($curShift, $hour + $hourSize) && $printMode == false) {
                    echo "<span style='color:red'>" . nameByNetId($netId) . "</span>";
                } else {
                    echo nameByNetId($netId);
                }
            }
            echo "<br />";
        }
        echo "</td>";
    }
    echo "</tr>";
}
echo "</tbody></table>";
function getShifts($start, $end, $type, $date)
{
    global $area, $db, $showUnposted;
    $prevDay = date("Y-m-d", strtotime($date . " -1 day"));
    $nextDay = date("Y-m-d", strtotime($date . " +1 day"));
    // This is the query I wrote to simplify the logic of the query and help speed things up ~Mika
function printEmployees2()
{
    global $employee;
    global $admin;
    global $area;
    global $db;
    $text = "";
    if ($admin) {
        $text .= "<select id='employees' name='employees' onchange><option value=''>Select Employee</option>";
        try {
            $employeeQuery = $db->prepare("SELECT * FROM `employee` WHERE `active`=1 AND `area`=:area ORDER BY `lastName`");
            $employeeQuery->execute(array(':area' => $area));
        } catch (PDOException $e) {
            exit("error in query");
        }
        while ($row = $employeeQuery->fetch(PDO::FETCH_ASSOC)) {
            if ($employee == $row['netID']) {
                $text .= "<option value='{$row['netID']}' selected> {$row['lastName']}, {$row['firstName']}</option>";
            } else {
                $text .= "<option value='{$row['netID']}'> {$row['lastName']}, {$row['firstName']}</option>";
            }
        }
        $employees = getEmployeesNotDefaultedToCurArea();
        foreach ($employees as $curEmployee) {
            try {
                $employeeQuery = $db->prepare("SELECT firstName, lastName, netID FROM employee WHERE netID=:netId");
                $employeeQuery->execute(array(':netId' => $curEmployee));
            } catch (PDOException $e) {
                exit("error in query");
            }
            $info = $employeeQuery->fetch(PDO::FETCH_ASSOC);
            if ($employee == $curEmployee) {
                $text .= "<option value='" . $info['netID'] . "' selected>*" . $info['lastName'] . ", " . $info['firstName'] . "</option>";
            } else {
                $text .= "<option value='" . $info['netID'] . "'>*" . $info['lastName'] . ", " . $info['firstName'] . "</option>";
            }
        }
        $text .= "</select>";
    } else {
        $text .= nameByNetId($employee);
    }
    return $text;
}
function editTardyLog($ID)
{
    global $area, $db;
    try {
        $tardyQuery = $db->prepare("SELECT * FROM reportTardy WHERE ID = :id");
        $tardyQuery->execute(array(':id' => $ID));
    } catch (PDOException $e) {
        exit("error in query");
    }
    $curAbsence = $tardyQuery->fetch(PDO::FETCH_ASSOC);
    $to_time = strtotime($curAbsence['time']);
    $from_time = strtotime($curAbsence['start']);
    $minsLate = round(abs($to_time - $from_time) / 60, 2) . " minute(s)";
    echo "<div align='center'>";
    echo "<h2>Edit Tardy</h2>";
    echo "\n\t<form id='editTardy' method='post'>\n\t<table>\n\t\t<tr>\n\t\t\t<th>Employee</th>\n\t\t\t<th>Date</th>\n\t\t\t<th>Start Time</th>\n\t\t\t<th>End Time</th>\n\t\t\t<th>Time Arrived</th>\n\t\t\t<th>Reason</th>";
    if ($area == 2) {
        echo "<th>No Call</th>";
    } else {
        echo "<th>No Show</th>";
    }
    echo "</tr>";
    echo "\t<tr>\n\t\t\t<td>" . nameByNetId($curAbsence['employee']) . "</td>\n\t\t\t<td>" . date("Y-m-d", strtotime($curAbsence['date'])) . "</td>\n\t\t\t<td>";
    echo '<input type="text" id="start" name="start" size="10" value="' . date("h:i A", strtotime($curAbsence['start'])) . '" />';
    echo "</td>\n\t\t\t<td>";
    echo '<input type="text" id="end" name="end" size="10" value="' . date("h:i A", strtotime($curAbsence['end'])) . '" />';
    echo "</td>\n\t\t\t<td>";
    echo '<input type="text" id="arrived" name="arrived" size="10" value="' . date("h:i A", strtotime($curAbsence['time'])) . '" />';
    echo "</td>\n\t\t\t<td><textArea name='reason'>" . $curAbsence['reason'] . "</textarea></td>\n\t\t\t<td><select name='noCall'>\n\t\t\t\t\t\t<option value='No' selected>No</option>\n\t\t\t\t\t\t<option value='Yes'>Yes</option>\n\t\t\t\t\t</select></td>\n\t\t</tr>\n\t</table>\n\t<input type='submit' name='submitTardy' value='Submit' method='post'>\n\t</form>\n\t</div>\n\t";
}
}
if (isset($_GET['comments'])) {
    $queryString .= " AND comments LIKE :comments";
    $queryParams[':comments'] = '%' . $_GET['comments'] . '%';
}
$queryString .= " AND `area`=:area ORDER BY ticketDate DESC";
$queryParams[':area'] = $area;
$ticketCount = 1;
try {
    $reviewQuery = $db->prepare($queryString);
    $reviewQuery->execute($queryParams);
} catch (PDOException $e) {
    exit("error in query");
}
while ($cur = $reviewQuery->fetch(PDO::FETCH_ASSOC)) {
    echo "<h3>For: " . nameByNetId($cur['agentID']) . " <a href='#none' id='editTicket" . $ticketCount . "' onClick='editTicket(" . $ticketCount . ")' style='font-weight:normal;font-size:small;'>Edit</a></h3>";
    echo "<table style='margin-left:auto; margin-right:auto;' id='result" . $ticketCount . "'><tr><th>Ticket#</th><th>Date</th><th>Requestor</th><th>Contact Info</th> <th>Service/Symptom Category</th><th>Ticket Source</th><th>Priority</th><th>KB/Source</th><th>Work Order#</th>";
    echo "</tr><tr id='data1'>";
    echo "<td class='cellWidth' id='ticketNumField'>" . $cur['ticketNum'] . "</td>";
    //Ticket #
    echo "<td class='cellWidth' id='ticketDateField'>" . $cur['ticketDate'] . "</td>";
    //Date
    echo "<td class='cellWidth' id='requestorField'>" . $cur['requestor'] . "</td>";
    //Requestor
    echo "<td class='cellWidth' id='contactInfoField'>" . $cur['contactInfo'] . "</td>";
    //Contact Info
    echo "<td class='cellWidth' id='serviceCatField'>" . $cur['ssc'] . "</td>";
    //Service/Symptom Category
    echo "<td class='cellWidth' id='tickeSourceField'>" . $cur['ticketSource'] . "</td>";
    //Ticket Source
    echo "<td class='cellWidth' id='ticketPriorityField'>" . $cur['priority'] . "</td>";
if (isset($_GET['timeStamp']) && $_GET['timeStamp'] != '') {
    $timeStamp = $_GET['timeStamp'];
    $timeStamp = rawurldecode($timeStamp);
    $queryString .= " AND timeStamp =:timestamp";
    $queryParams[':timestamp'] = $timeStamp;
}
$queryString .= " ORDER BY ticketDate DESC";
$ticketCount = 1;
try {
    $reviewQuery = $db->prepare($queryString);
    $reviewQuery->execute($queryParams);
} catch (PDOException $e) {
    exit("error in query");
}
while ($cur = $reviewQuery->fetch(PDO::FETCH_ASSOC)) {
    echo "<h3>For: " . nameByNetId($cur['agentID']) . "</h3>";
    echo "<table style='margin-left:auto; margin-right:auto;' id='result" . $ticketCount . "'><tr><th>Ticket#</th><th>Date</th><th>Requestor</th><th>Contact Info</th> <th>Service/Symptom Category</th><th>Ticket Source</th><th>Priority</th><th>KB/Source</th><th>Work Order#</th>";
    echo "</tr><tr id='data1'>";
    echo "<td class='cellWidth' id='ticketNumField'>" . $cur['ticketNum'] . "</td>";
    //Ticket #
    echo "<td class='cellWidth' id='ticketDateField'>" . $cur['ticketDate'] . "</td>";
    //Date
    echo "<td class='cellWidth' id='requestorField'>" . $cur['requestor'] . "</td>";
    //Requestor
    echo "<td class='cellWidth' id='contactInfoField'>" . $cur['contactInfo'] . "</td>";
    //Contact Info
    echo "<td class='cellWidth' id='serviceCatField'>" . $cur['ssc'] . "</td>";
    //Service/Symptom Category
    echo "<td class='cellWidth' id='tickeSourceField'>" . $cur['ticketSource'] . "</td>";
    //Ticket Source
    echo "<td class='cellWidth' id='ticketPriorityField'>" . $cur['priority'] . "</td>";
    //permission check
    //echo table headers
    echo '<table border="1" cellpadding="3" style="margin:auto; border-collapse:collapse;">	
	<tbody>
		<tr>
		<th>Date</th><th>Raise</th><th>New Wage</th><th>Submitter</th><th>Reason</th><th></th>
		</tr>';
    //This query selects all of the raises for the passed in employee with a column that sums the raises up to that point for an accurate total.
    try {
        $raiseQuery = $db->prepare("SELECT `netID`, `raise`, FORMAT((SELECT SUM(ew.raise) FROM `employeeRaiseLog` AS ew WHERE ew.date <= ew_outer.date AND ew.netid = ew_outer.netid), 2)\n\t\t\t\tAS `newWage`, `submitter`, `date`, `comments`, `isSubmitted` FROM `employeeRaiseLog` AS `ew_outer` WHERE `netID` = :netId ORDER BY `date` DESC");
        $raiseQuery->execute(array(':netId' => $employeeNetId));
    } catch (PDOException $e) {
        exit("error in query");
    }
    //Echo table rows
    while ($row = $raiseQuery->fetch(PDO::FETCH_ASSOC)) {
        echo "<tr>";
        echo "<td>" . date('Y-m-d', strtotime($row["date"])) . " </td>";
        echo "<td>\$" . $row["raise"] . "</td>";
        echo "<td>\$" . $row["newWage"] . "</td>";
        echo "<td>" . nameByNetId($row["submitter"]) . "</td>";
        echo "<td>" . $row["comments"] . "</td>";
        echo "<td>";
        if ($row['isSubmitted'] == 0) {
            //If the raise is pending we need a link to the pending page
            echo "<a href='raiseGrouping/index.php'>Pending</a>";
        }
        echo "</td></tr>";
    }
    echo "</tbody></table>";
}
/**
 * Sends an email
 *
 * @param $rightID  The id of the right the email is about
 * @param $whatKind The type of email being sent('activation', 'termination')
 * @param $employee The employee's netID
 * @param $manager  The manager's netID
 * @param $env      The environment being worked in (0 = dev, 1 = stg, 2 = prod)
 */
function sendEmail($rightID, $whatKind, $employee, $manager, $env)
{
    global $db;
    try {
        $emailQuery = $db->prepare("SELECT * FROM employeeRightsEmails WHERE rightID=:right");
        $emailQuery->execute(array(':right' => $rightID));
    } catch (PDOException $e) {
        exit("error in query");
    }
    $emailInfo = $emailQuery->fetch(PDO::FETCH_ASSOC);
    $employeeIDNumber = getEmployeeByuIdByNetId($employee);
    if ($env == 2) {
        if ($whatKind == "activation") {
            $body = $emailInfo['add_body'] . "\n\nName: " . nameByNetId($employee) . "\n\nUser: "******"\n\nBYU ID: " . $employeeIDNumber . "\n\n";
            mail($emailInfo['address'], $emailInfo['add_title'], $body, "From:" . $manager . "\r\ncc:" . $emailInfo['cc']);
        } else {
            if ($whatKind == "termination") {
                $body = $emailInfo['del_body'] . "\n\nName: " . nameByNetId($employee) . "\n\nUser: "******"\n\nBYU ID: " . $employeeIDNumber . "\n\n";
                mail($emailInfo['address'], $emailInfo['del_title'], $body, "From:" . $manager . "\r\ncc:" . $emailInfo['cc']);
            } else {
                return;
            }
        }
    } else {
        if ($whatKind == "activation") {
            $body = $emailInfo['address'] . "\n" . $emailInfo['cc'] . "\n" . $emailInfo['add_body'] . "\n\nName: " . nameByNetId($employee) . "\n\nUser: "******"\n\nBYU ID: " . $employeeIDNumber . "\n\n";
            if (mail(getenv("DEVEMAILADDRESS"), $emailInfo['add_title'], $body, "From:" . $manager . "\r\ncc:" . getenv("DEVEMAILADDRESS"))) {
                echo "Sent Activation email";
            } else {
                echo "Failed to send activation email.";
            }
        } else {
            if ($whatKind == "termination") {
                $body = $emailInfo['address'] . "\n" . $emailInfo['cc'] . "\n" . $emailInfo['del_body'] . "\n\nName: " . nameByNetId($employee) . "\n\nUser: "******"\n\nBYU ID: " . $employeeIDNumber . "\n\n";
                if (mail(getenv("DEVEMAILADDRESS"), $emailInfo['del_title'], $body, "From:" . $manager . "\r\ncc:" . getenv("DEVEMAILADDRESS"))) {
                    echo "Sent Termination email";
                } else {
                    echo "Failed to send termination email.";
                }
            } else {
                echo "Complete and utter failure.";
                return;
            }
        }
    }
}
     echo "<div style='border: 1px solid white;' class='priority divTd'>&nbsp;</div><div class='type divTd'>New</div><div class='timestamp divTd'>{$start}</div><div class='text divTd'>DESCRIPTION: {$description}</div><div class='submitter divTd'>{$execNoteSubmitter}</div>";
     echo '</div>';
 }
 // CHECK IF AN UPDATE FOR THE EXECUTIVE NOTIFICATION EXISTS IF SO PRINT THE UPDATE INFO
 echo "<div class='execNoteHistory history{$execNote['ID']}' style='display: none;'>";
 if ($execNote['updateID'] != '') {
     // SET EXEC NOTE UPDATE INFO
     $type = $execNote['type'];
     if ($type == '') {
         $type = '&nbsp;';
     }
     $text = $execNote['updateText'];
     if ($text == '') {
         $text = '&nbsp;';
     }
     $submitter = nameByNetId($execNote['historySubmitter']);
     if ($submitter == '') {
         $submitter = '&nbsp;';
     }
     $timestamp = $execNote['date'] . '&nbsp;' . $execNote['time'];
     echo "<div style='border: 1px solid white;' class='priority divTd'>&nbsp;</div><div class='type divTd'>{$type}</div><div class='timestamp divTd'>{$timestamp}</div><div class='text divTd'>{$text}</div><div class='submitter divTd'>{$submitter}</div>";
 } else {
     echo "<div style='border: 1px solid white;' class='priority divTd'>&nbsp;</div><div style='width: 90.8%; text-align: center;' class='divTd'>No updates were made to this Executive Notification.</div><div class='clearMe'></div>";
 }
 echo '</div>';
 // CHECK FOR NEXT ROW'S ID TO SEE IF THE ECAPSULATING DIV FOR ALL EXEC NOTE UPDATES OUGHT TO BE CLOSED
 if (array_key_exists($i + 1, $resultArray)) {
     $nextRow = $resultArray[$i + 1];
     if ($execNote['ID'] != $nextRow['ID']) {
         echo "<div class='execNoteHistory history{$execNote['ID']}' style='display: none;'><div style='border: 1px solid white;' class='priority divTd'>&nbsp;</div></div><div class='clearMe'></div>";
         echo "</div>";
function formEmail($postData)
{
    $email = "<b>Notification Time: </b>" . $postData['time'] . "<br />";
    $email .= "<b>Notification Date: </b>" . date('m/d/Y', strtotime($postData['date'])) . "<br /><br />";
    $email .= "<b>Parent Ticket: </b>" . $postData['parentTicket'] . "<br />";
    $email .= "<b>Priority: </b>" . $postData['priority'] . "<br /><br />";
    $email .= "<b>Problem Description: </b>" . $postData['desc'] . "<br /><br />";
    if ($postData['update'] != "") {
        $email .= $postData['update'] . "<br />";
    }
    $email .= "<b>Incident Coordinator: </b>" . nameByNetId($postData['ic']) . "<br /><br />";
    $email .= "If you require further information please call 801-422-4342 and ask for the Incident Coordinator.";
    return $email;
}
	<br>
	<input type='button' name='submit' id='submit' value='Submit' onclick='submitRaise();' />
	<br>
	<br>

	<input type='hidden' name='netID' value="<?php 
    echo $employeeNetId;
    ?>
">
</form>
</div>
<!----------------------------------------------End Employee Info--------------------------------------------------->

<!-------------------------------------------------Start Log-------------------------------------------------------->
<!-------------------Table holds the info for the raiselog. Previous raises pulled from the database------------------->
<div id="log" class="log">
	<header>Raise History for <?php 
    echo nameByNetId($employeeNetId);
    ?>
</header>
	<div id='results'>

	</div>
</div>


<?php 
} else {
    echo "You do not have permissions to view this application. If you feel this is in error contact your supervisor.";
}
require '../includes/includeAtEnd.php';
if (isset($_GET['end'])) {
    $end = $_GET['end'];
} else {
    $end = date("Y-m-d", strtotime("-1 months"));
}
echo "<table>\n\t<tr>\n\t<th>Type</th>\n\t<th>Poster</th>\n\t<th>Date</th>\n\t<th>Original Note</th>\t\n\t</tr>";
?>
<link rel="stylesheet" href="infoChangeCallTable.css" type="text/css">
<?php 
//This is the correct query for getting all unusual calls within the start and end dates. The Submit button on DEV just doesn't work yet cause it's not sending information properly or something like that.
try {
    $reportQuery = $db->prepare("SELECT * FROM reportInfoChangeRequest WHERE date >= :start AND date <= :end AND type='Unusual Call' ORDER BY date DESC");
    $reportQuery->execute(array(':start' => $start . ' 00:00:00', ':end' => $end . ' 23:59:59'));
} catch (PDOException $e) {
    exit("error in query");
}
while ($cur = $reportQuery->fetch(PDO::FETCH_ASSOC)) {
    echo "<tr><td>";
    echo $cur['type'];
    echo "</td><td>";
    echo nameByNetId($cur['netID']);
    echo "</td><td>";
    echo date("Y-m-d", strtotime($cur['date']));
    echo "</td><td>";
    echo $cur['notes'];
    echo "</td></tr>";
}
echo "</table>";
?>
</link>
function getCommendables($params)
{
    global $admin, $area, $db;
    $newParams = array(':area' => $area, ':start' => $params[':start'], ':end' => $params[':end']);
    try {
        $commendableQuery = $db->prepare("SELECT * FROM reportCommendable WHERE area=:area AND date >= :start AND date <= :end");
        $commendableQuery->execute($newParams);
    } catch (PDOException $e) {
        exit("error in query");
    }
    if ($first = $commendableQuery->fetch(PDO::FETCH_ASSOC)) {
        echo "<table>\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Employee</th>\n\t\t\t\t\t<th>Date</th>\n\t\t\t\t\t<th>Submitted By</th>\n\t\t\t\t\t<th>Reason</th>\n\t\t\t\t\t<th>Public</th>";
        if ($admin) {
            echo "<th></th>\n\t\t\t\t\t<th></th>";
        }
        echo "</tr>";
        echo "<tr>";
        echo "<td>" . nameByNetId($first['employee']) . "</td>";
        echo "<td>" . $first['date'] . "</td>";
        echo "<td>" . nameByNetId($first['submitter']) . "</td>";
        echo "<td>" . $first['reason'] . "</td>";
        echo "<td>";
        if ($first['public'] == 1) {
            echo "Yes";
        } else {
            echo "No";
        }
        echo "</td>";
        if ($admin) {
            echo "<td><input type='button' value='Edit' onclick='editLog(\"" . $first['ID'] . "\",\"commendable\")' /></td>";
            echo "<td><input type='button' value='Delete' onclick='deleteLog(\"" . $first['ID'] . "\",\"Commendable\")' /></td>";
        }
        echo "</tr>";
        while ($current = $commendableQuery->fetch(PDO::FETCH_ASSOC)) {
            echo "<tr>";
            echo "<td>" . nameByNetId($current['employee']) . "</td>";
            echo "<td>" . $current['date'] . "</td>";
            echo "<td>" . nameByNetId($current['submitter']) . "</td>";
            echo "<td>" . $current['reason'] . "</td>";
            echo "<td>";
            if ($current['public'] == 1) {
                echo "Yes";
            } else {
                echo "No";
            }
            echo "</td>";
            if ($admin) {
                echo "<td><input type='button' value='Edit' onclick='editLog(\"" . $current['ID'] . "\",\"commendable\")' /></td>";
                echo "<td><input type='button' value='Delete' onclick='deleteLog(\"" . $current['ID'] . "\",\"Commendable\")' /></td>";
            }
            echo "</tr>";
        }
        echo "</table>";
    } else {
        echo "0 Commendable Performances during this time period";
    }
}