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;
 }
/**
 * 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;
            }
        }
    }
}
 //Prepare email
 $email = (object) array("recipients" => '', "subject" => '', "message" => '', "cc" => null, "bcc" => null);
 // Prepare recipient
 if ($env < 2) {
     $email->recipients = getenv("DEVEMAILADDRESS");
 } else {
     $email->recipients = getenv("PAYROLLEMAIL");
 }
 // Prepare subject
 $email->subject = "Missed Punch Correction";
 // Prepare message body
 $emailBody = "Dear Payroll:<br /><br />";
 $emailBody .= "Would you please make the following time changes on my time card:<br /><br />";
 $emailBody .= $body;
 $emailBody .= "<br />Thanks,<br />" . nameByNetID($netID) . "<br />NetID: {$netID} \r\n";
 $emailBody .= "<br />BYUID: " . getEmployeeByuIdByNetId($netID) . "<br /> \r\n";
 $emailBody .= "Email: " . getEmployeeEmailByNetId($netID) . "<br /> \r\n";
 if ($env < 2) {
     $emailBody .= "<br />Area: {$area}; Env: {$env}; <br />";
     $emailBody .= "Subject: {$email->subject};<br />";
     $emailBody .= "Cc: " . getEmployeeEmailByNetId(getEmployeeManagerByNetId($netID)) . "\r\n";
     $emailBody .= "<br />Bcc: " . getEmployeeEmailByNetId($netID) . "\r\n";
 } else {
     $email->cc = getEmployeeEmailByNetId(getEmployeeManagerByNetId($netID));
     $email->bcc = getEmployeeEmailByNetId($netID);
 }
 $email->message = $emailBody;
 if (sendEmail($email)) {
     echo "<div>Request email sent successfully.</div>";
 } else {
     echo "<div>ERROR IN SENDING THE EMAIL FOR THE TIME EDIT REQUEST</div>";