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 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; } }
?> "> <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> <td>End Time: <input type="text" name="end" id='end' maxlength=5 size=8 value="<?php echo date('h:iA'); ?> "/></td>
} } //else } //foreach //If the transaction was successful commit it and then go on to do the email. if ($transactionSuccess) { $db->commit(); //send email $to = $_POST['to']; $cc = $_POST['cc']; $subject = getAreaName() . " Manager Weekly Report"; $emailBody = $_POST['emailText']; $from = 'From:' . getEmployeeNameByNetId($netID) . ' <' . getEmployeeEmailByNetId($netID) . ">\r\n"; $from .= "Cc: " . $cc . "\r\n"; $from .= "Return-Path: " . getEmployeeEmailByNetId($netID) . "\r\n"; $from .= "MIME-Version: 1.0\r\n"; $from .= "Content-Type: text/html;\r\n"; //Check if email was successful if (mail($to, $subject, wordwrap($emailBody, 70), $from)) { echo json_encode(array('status' => true)); } else { echo json_encode(array('status' => false, 'error' => 'There was an error submitting the email to the email server.')); } //if-else } else { //Otherwise rollback the transaction, set the status and error message and don't send the email. $db->rollBack(); echo json_encode(array('status' => $transactionSuccess, 'error' => "error in query")); return; }
$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)' />"; }
//Send Email. The rest is self explanitory, see the variable names. if ($env < 2) { $to = getenv("DEVEMAILADDRESS"); //Dev site } else { $to = getenv("PAYROLLEMAIL"); //Prod site } $subject = "Wage Increase for Students"; $emailBody = "<html><body>Dear Payroll Official:"; $emailBody .= "\nWould you please make the following wage changes for some of the following employees :<br/><br/>"; $emailBody .= $body; $emailBody .= "<br/>Thanks,<br/>" . nameByNetID($netID); $emailBody .= "</body></html>"; $from = 'From: ' . getenv("NOREPLYADDRESS") . "\r\n"; $from .= "CC: " . getEmployeeEmailByNetId($netID) . "\r\n"; $from .= "MIME-Version: 1.0\r\n"; $from .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; //send the Email mail($to, $subject, $emailBody, $from); } $_POST = ''; } ?> <script type='text/javascript'> window.onload = printRaises; //This opens a new window for editing function newwindow(urlpass) { window.open(urlpass,"Edit Raise","status=1,width=1000,height=500,scrollbars=1"); }
$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>"; } } ?> <script type='text/javascript'> var num; window.onload = function() { num = 0; insertRequest(num); $('#time').timeEntry({useMouseWheel: true});
window.onload = function() { $('#start').timeEntry({useMouseWheel: true}); $('#end').timeEntry({useMouseWheel: true}); } </script> <form id='reportData' method='post'> <div id='headInfo'> <h1>Edit Supervisor Report Form</h1> <table> <tr> <th>NAME: <?php echo nameByNetId($report['submitter']); ?> </th><th colspan='2'>EMAIL: <?php echo getEmployeeEmailByNetId($report['submitter']); ?> </th><th>Finished Editing?</th> </tr><tr> <td>DATE: <input type='text' class='tcal' size='10' id='reportDate' name='reportDate' value="<?php echo $report['date']; ?> " /></td> <td>Start Time: <input type="text" name="start" id='start' maxlength=5 size=8 value="<?php echo date('h:iA', strtotime($report['startTime'])); ?> "/></td> <td>End Time: <input type="text" name="end" id='end' maxlength=5 size=8 value="<?php echo date('h:iA', strtotime($report['endTime'])); ?> "/></td>
/** * Sends all activation emails for an employee in a given level * * @param $data associative array containing: level,area,noEmail,employee,manager,env */ function emailAll($data) { global $db; try { $rightsQuery = $db->prepare("SELECT * FROM employeeRights WHERE rightLevel=:level AND area=:area AND rightType='EMAIL'"); $rightsQuery->execute(array(':level' => $data['level'], ':area' => $data['area'])); } catch (PDOException $e) { exit("error in query"); } while ($right = $rightsQuery->fetch(PDO::FETCH_ASSOC)) { createRightStatus($right['ID'], $data['employee'], $data['manager'], "EMAIL"); //Function in helpers.php if ($data['noEmail'] == "false") { sendEmail($right['ID'], "activation", $data['employee'], getEmployeeEmailByNetId($data['manager']), $data['env']); //Function in helpers.php } } }
function populateHourRequests() { //Declare variables global $area, $db; try { $requestsQuery = $db->prepare("SELECT postDate, netId, notes FROM scheduleHourRequests WHERE area=:area AND deleted=0 ORDER BY postDate DESC"); $requestsQuery->execute(array(':area' => $area)); } catch (PDOException $e) { exit("error in query"); } if ($first = $requestsQuery->fetch(PDO::FETCH_ASSOC)) { $deleteHeader = ""; if (can("approve", "8d50e67c-53db-4a56-af2e-502d0d770bef")) { $deleteHeader = "<th></th>"; } //if echo "<table class='tradeTable'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Date Posted</th>\n\t\t\t\t\t<th>Name</th>\n\t\t\t\t\t<th>Phone</th>\n\t\t\t\t\t<th>Email</th>\n\t\t\t\t\t<th>Note</th>\n\t\t\t\t\t" . $deleteHeader . "\n\t\t\t\t</tr>"; echo "<tr><td>"; echo date("j M Y", strtotime($first['postDate'])); echo "</td><td>"; echo nameByNetId($first['netId']); echo "</td><td>"; echo getEmployeePhoneByNetId($first['netId']); echo "</td><td>"; echo getEmployeeEmailByNetId($first['netId']); echo "</td><td>"; echo stripslashes($first['notes']); echo "</td>"; deleteLink($first['netId']); echo "</tr>"; $requests = array(); while ($row = $requestsQuery->fetch(PDO::FETCH_ASSOC)) { echo "<tr><td>"; echo date("j M Y", strtotime($row['postDate'])); echo "</td><td>"; echo nameByNetId($row['netId']); echo "</td><td>"; echo getEmployeePhoneByNetId($row['netId']); echo "</td><td>"; echo getEmployeeEmailByNetId($row['netId']); echo "</td><td>"; echo stripslashes($row['notes']); echo "</td>"; deleteLink($row['netId']); echo "</tr>"; } //while echo "</table>"; } else { echo "<p>There are currently no requests for more hours.</p>"; } //else }