$teamingQueryString = "SELECT netID, supervisorID, `startDate`, `endDate`, teamed, timely FROM teaming WHERE " . $fields; try { $teamingQuery = $db->prepare($teamingQueryString); $teamingQuery->execute($params); } catch (PDOException $e) { exit("error in query"); } echo "<table><tr>\n\t\t\t<th>Employee</th>\n\t\t\t<th>Leader</th>\n\t\t\t<th>Start Date</th>\n\t\t\t<th>End Date</th>\n\t\t\t<th>Trained</th>\n\t\t\t<th>Timely</th>\n\t\t</tr>"; while ($current = $teamingQuery->fetch(PDO::FETCH_ASSOC)) { $empTeamed = ''; $wasTimely = ''; if ($current['teamed']) { $empTeamed = 'Yes'; } else { $empTeamed = 'No'; } if ($current['timely']) { $wasTimely = 'Yes'; } else { $wasTimely = 'No'; } echo "<tr>"; echo "<td>" . getEmployeeNameByNetId($current['netID']) . "</td>"; echo "<td>" . getEmployeeNameByNetId($current['supervisorID']) . "</td>"; echo "<td>" . $current['startDate'] . "</td>"; echo "<td>" . $current['endDate'] . "</td>"; echo "<td>" . $empTeamed . "</td>"; echo "<td>" . $wasTimely . "</td>"; echo "</tr>"; } echo "</table>";
} catch (PDOException $e) { $transactionSuccess = false; } } //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"));
<?php require "../includes/includeMeBlank.php"; require "../includes/email.php"; if ($env < 2) { $to = 'OPS Development <' . getenv("DEVEMAILADDRESS") . '>'; } else { $to = getenv("BOSSEMAILS"); } $subject = 'Student Supervisor Message'; $message = wordwrap($_GET['message'] . ' ~' . getEmployeeNameByNetId($netID), 70); $email = (object) array("recipients" => $to, "subject" => $subject, "message" => $message); if (sendEmail($email)) { echo 'Message sent successfully!'; } else { echo 'ERROR: Unable to send message.'; }
function populatePendingTradesPage($date) { //Declare variables global $netID; $tradesList = pullTrades($date); //Get all dates with trades not approvedBy from $date until forever. if ($tradesList == 0) { echo "<h2 align='center'>No Trades Pending Approval</h2>"; } else { echo "<table>"; //For each trade print out the trade information foreach ($tradesList as $curTrade) { //Check to see if the trade should be highlighted $highlight = checkHighlight($curTrade); $highlighted = ""; if ($highlight) { $highlighted = "style='background-color:#47BB47'"; } //if //Set the date the trade was posted if ($curTrade['startDate'] == $curTrade['endDate']) { $tradeDate = date("D, M jS", strtotime($curTrade['startDate'])); } else { $tradeDate = date("D, M jS", strtotime($curTrade['startDate'])) . " - " . date("D, M jS", strtotime($curTrade['endDate'])); } //else echo "\t<tr>\n\t\t\t\t\t\t\t<td " . $highlighted . ">\n\t\t\t\t\t\t\t\t<h3>\n\t\t\t\t\t\t\t\t\tPosted by: <a target=_blank href='../newSchedule/index.php?employee=" . $curTrade['postedBy'] . "' >" . getEmployeeNameByNetId($curTrade['postedBy']) . "</a><br/>\n\t\t\t\t\t\t\t\t\tDate: {$tradeDate}\n\t\t\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t\t\t<table class='tradeTable'>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<th>Approved:</th>\n\t\t\t\t\t\t\t\t\t\t<th><input class='approveCheckBox' type='checkbox' id='" . $curTrade['ID'] . "' name='" . $curTrade['ID'] . "' value='1' ></th>\n\t\t\t\t\t\t\t\t\t\t<th></th>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<th>Hour</th>\n\t\t\t\t\t\t\t\t\t\t<th>Taken By (New Hours Total)</th>\n\t\t\t\t\t\t\t\t\t\t<th></th>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t" . listPendingHours($curTrade) . "\n\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\t\t\t\n\t\t\t\t\t"; } //foreach echo "</table>"; echo "<input type='button' onclick='submitTrades()' value='Submit' style='float:right;'/>"; } //else }