| Current Path : /var/www/cesa.co.za/cceadmin/ |
| Current File : /var/www/cesa.co.za/cceadmin/sendmessage.php |
<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "CCEMessagesinfo.php" ?>
<?php include "CCEModulesinfo.php" ?>
<?php include "CCEUsersinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
if (!isset($_SESSION[EW_SESSION_STATUS]) || ($_SESSION[EW_SESSION_STATUS] != "login")) {
header("Location: /cceadmin/login.php");
die();
}
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php include "header.php" ?>
<p><b><a href="CCEMessageslist.php?cmd=resetall">View All Messages</a></b></p>
<h1> Send a Message</h1>
<?php
$conn = mysqli_connect(EW_CONN_HOST, EW_CONN_USER, EW_CONN_PASS, EW_CONN_DB);
$showComposeForm = true;
if (isset($_POST["go"]) && ($_POST["go"] == 1)) {
include_once($_SERVER['DOCUMENT_ROOT'] . '/php/includes/Utils.php');
$arrSendTo = isset($_POST["sendto"]) ? $_POST["sendto"] : array();
$cceMessageSendResult = array();
if (!is_array($arrSendTo) || count($arrSendTo) == 0) {
echo '<p><b><span style="color:red;">Please select at least one recipient.</span></b></p>';
} elseif (empty($_POST["message"])) {
echo '<p><b><span style="color:red;">Please enter a message to be sent.</span></b></p>';
} else {
$sFrom = "CESA Programme Coordinator";
include("inc_sendmessage.php");
echo renderCceMessageSendFeedback($cceMessageSendResult, false);
if (!empty($cceMessageSendResult['ok'])) {
$showComposeForm = false;
echo '<p><a href="sendmessage.php">Compose another message</a> | '
. '<a href="CCEMessageslist.php?cmd=resetall">View all messages</a></p>';
}
}
}
if ($showComposeForm) {
include_once($_SERVER['DOCUMENT_ROOT'] . '/php/includes/Utils.php');
?>
<form action="sendmessage.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input type="hidden" name="go" value="1" />
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td>Module:</td>
<td><label>
<select name="modid" id="modid">
<option value=""<?php if (!isset($_GET["id"])) echo " selected"; ?>>General</option>
<?php
$sql = "SELECT * FROM CCEModules
ORDER BY CCEModules.ModuleNum";
$recMod = mysqli_query($conn, $sql);
while ($rowMod = mysqli_fetch_assoc($recMod)) {
?>
<option value="<?php echo $rowMod["CCEModuleID"]; ?>"<?php if (isset($_GET["id"]) && ($_GET["id"] == $rowMod["CCEModuleID"])) echo " selected"; ?>><?php echo $rowMod["ModuleName"]; ?></option>
<?php
}
?>
</select>
</label></td>
</tr>
<tr>
<td valign="top">Send To:</td>
<td><div style="font-size:11px">
<?php
$iSelectFacilitatorID = 0;
$iSelectStudentID = 0;
$sReplyHtml = "";
$sForwardHtml = "";
$sReplySubject = "";
$arrReplyAll = array();
if (isset($_GET["replyto"])) {
$sql = "SELECT * FROM CCEMessages WHERE CCEMessageID='" . $_GET["replyto"] . "'";
$rec = mysqli_query($conn, $sql);
if ($row = mysqli_fetch_assoc($rec)) {
$iSelectFacilitatorID = $row["SentByFacilitatorID"];
$iSelectStudentID = $row["SentByStudentID"];
if (isset($_GET["all"]) && ($_GET["all"] == 1))
$arrReplyAll = explode(",", $row["SentTo"]);
$sReplyHtml = quoteCceMessageHtmlForEditor(
$row["MessageText"],
$row["SentDateTime"],
$row["SentByName"]
);
$sReplySubject = "RE: " . $row["MessageSubject"];
}
mysqli_free_result($rec);
}
if (isset($_GET["fwd"])) {
$sql = "SELECT * FROM CCEMessages WHERE CCEMessageID='" . $_GET["fwd"] . "'";
$rec = mysqli_query($conn, $sql);
if ($row = mysqli_fetch_assoc($rec)) {
$sForwardHtml = quoteCceMessageHtmlForEditor(
$row["MessageText"],
$row["SentDateTime"],
$row["SentByName"]
);
$sReplySubject = "FWD: " . $row["MessageSubject"];
}
mysqli_free_result($rec);
}
?>
<table border=0>
<tr><td valign="top">
<!-- <input type="checkbox" name="sendto[]" value="CESA"<?php if (in_array("CESA Programme Coordinator", $arrReplyAll)) echo " checked"; ?>>BCE Programme Coordinators<br>
<br> -->
<?php
$sql = "SELECT * FROM CCEFacilitators WHERE Archived=0 ORDER BY FacilitatorName";
$rec = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($rec)) {
?>
<input type="checkbox" name="sendto[]" value="F<?php echo $row["FacilitatorID"]; ?>"<?php if (($iSelectFacilitatorID == $row["FacilitatorID"]) || in_array($row["FacilitatorName"], $arrReplyAll)) echo " checked"; ?>>Convenor: <?php echo $row["FacilitatorName"]; ?><br>
<?php
}
?>
<p><i>Note: Convenors / facilitators will be <br>
CCed on inter-student communications.</i></p>
</td>
<td valign="top">
<input type="checkbox" name="sendto[]" value="FAll"<?php if (in_array("All Convenors", $arrReplyAll)) echo " checked"; ?>>All Convenors<br>
<br>
<?php
$sql = "SELECT * FROM CCEStudents WHERE BlockAccess='n' AND Archived=0 AND CCEStudentID<>54 ORDER BY " . CCEStudentDisplayOrder::sqlOrderByDisplayName('CCEStudents') . " LIMIT 0,15";
$rec = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($rec)) {
?>
<input type="checkbox" name="sendto[]" value="S<?php echo $row["CCEStudentID"]; ?>"<?php if (($iSelectStudentID == $row["CCEStudentID"]) || in_array($row["KnownAs"] . " " . $row["Surname"], $arrReplyAll)) echo " checked"; ?>>Student: <?php echo $row["KnownAs"] . " " . $row["Surname"]; ?><br>
<?php
}
?>
</td>
<td valign="top">
<input type="checkbox" name="sendto[]" value="SAll"<?php if (in_array("All Students", $arrReplyAll)) echo " checked"; ?>>All Students<br>
<br>
<?php
$sql = "SELECT * FROM CCEStudents WHERE BlockAccess='n' AND Archived=0 AND CCEStudentID<>54 ORDER BY " . CCEStudentDisplayOrder::sqlOrderByDisplayName('CCEStudents') . " LIMIT 15,100";
$rec = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($rec)) {
?>
<input type="checkbox" name="sendto[]" value="S<?php echo $row["CCEStudentID"]; ?>"<?php if (($iSelectStudentID == $row["CCEStudentID"]) || in_array($row["KnownAs"] . " " . $row["Surname"], $arrReplyAll)) echo " checked"; ?>>Student: <?php echo $row["KnownAs"] . " " . $row["Surname"]; ?><br>
<?php
}
?>
</td>
</tr></table>
</div></td>
</tr>
<tr>
<td>Subject:</td>
<td><label>
<input name="subject" type="text" id="subject" size="40" value="<?php echo $sReplySubject; ?>" />
</label></td>
</tr>
<tr>
<td>Message:</td>
<td><label>
<textarea name="message" id="message" cols="75" rows="10"><?php
if (isset($_POST["message"])) {
echo $_POST["message"];
} elseif (!empty($sReplyHtml) || !empty($sForwardHtml)) {
echo $sReplyHtml . $sForwardHtml;
}
?></textarea>
</label></td>
</tr>
<tr>
<td valign="top">Attachments:</td>
<td><?php include $_SERVER['DOCUMENT_ROOT'] . '/php/includes/cceMessageAttachmentUpload.inc.php'; ?></td>
</tr>
</table>
<p>
<label>
<input type="submit" name="button" id="button" value="Send Now" />
</label>
</p>
</form>
<script>
var allowSubmit = true;
$(document).ready(function() {
$('#form1').on('submit', function() {
if (allowSubmit) {
allowSubmit = false;
$('#button').attr('value', 'Sending now ...');
$('#button').attr('disabled', 'disabled');
return true;
}
return false;
});
});
</script>
<?php include $_SERVER['DOCUMENT_ROOT'] . '/php/includes/cceMessageEditor.inc.php'; ?>
<?php
}
?>
<p> </p>
<?php include "footer.php" ?>