First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
header("Location: /");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
echo("<br>\n");
|
||||
$error_message = getLanguageText('ERRORMSG-INVALID-ACCESS');
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
|
||||
// Start the template and output buffering
|
||||
startTemplate();
|
||||
$templatePageTitle = getLanguageText('TEXT-SEND-STAFF-NOTICES');
|
||||
|
||||
|
||||
// Check for a selected_staff parameter
|
||||
$sWhere = "";
|
||||
if (array_key_exists('selected_staff',$_POST) && $_POST['selected_staff'] > 0) {
|
||||
$selected_staff = $_POST['selected_staff'];
|
||||
$sWhere = "AND p.record_num = $selected_staff ";
|
||||
}
|
||||
|
||||
|
||||
// Handle parameters
|
||||
unset($naction);
|
||||
if (array_key_exists('naction',$_GET) && $_GET['naction'] == 'email') $naction = 'email';
|
||||
if (array_key_exists('naction',$_POST) && $_POST['naction'] == 'email') $naction = 'email';
|
||||
|
||||
|
||||
//
|
||||
// If a selected_schedules is posted send the emails
|
||||
//
|
||||
if (isset($naction) && $naction == 'email') {
|
||||
// No emails from the demo
|
||||
// if ($school_num == 3) {
|
||||
// header("Location: /?action=send-reminders&error_message=" . urlencode("Error: Unable to Send Notices From 'demo' Site"));
|
||||
// exit();
|
||||
// }
|
||||
|
||||
|
||||
// Get the reply email address
|
||||
$emailSubject = $_POST['email_subject'];
|
||||
$replyEmail = setReplyAddress($_POST['reply_email']);
|
||||
|
||||
if (strlen($replyEmail) == 0 || strlen($emailSubject) == 0) {
|
||||
header("Location: /?action=send-reminders&error_message=" . urlencode("Error: Missing Reply Email Address or Email Subject"));
|
||||
exit();
|
||||
}
|
||||
else {
|
||||
include "include/queuemail.php";
|
||||
|
||||
|
||||
// Get set of staff
|
||||
$staff = db_query("SELECT p.*,u.email,u.userid,u.password FROM people AS p, users AS u " .
|
||||
"WHERE p.school_num = $base_school_num " .
|
||||
"AND p.people_type = 'Staff' " .
|
||||
"AND u.school_num = $school_num " .
|
||||
$sWhere .
|
||||
"AND p.user_num = u.record_num");
|
||||
$numStaff = db_num_rows($staff);
|
||||
|
||||
if ($numStaff) {
|
||||
|
||||
$Sent = 0;
|
||||
$Errors = 0;
|
||||
$NoEmail = 0;
|
||||
$staffResults = "";
|
||||
|
||||
// Initialize the user message
|
||||
$staffMessage = db_getVal("SELECT text_data FROM text_data WHERE school_num = $school_num AND text_id = 'Staff Notice'");
|
||||
$url = $school_record['url'];
|
||||
|
||||
// Get next batch id
|
||||
$batch_id = db_getVal("SELECT max(batch_id) FROM email_queue WHERE school_num = $school_num");
|
||||
$batch_id++;
|
||||
|
||||
|
||||
// Process each user
|
||||
while ($row = db_fetch_array($staff)) {
|
||||
extract($row);
|
||||
$name = "$first_name $last_name";
|
||||
|
||||
if (strlen($email) && strstr($email,'@')) {
|
||||
// Create message for staff person
|
||||
$message = trim($staffMessage) . "\n\n" .
|
||||
" -------------------------------------\n" .
|
||||
" Staff Person: $name\n" .
|
||||
" Web Address: https://$url\n" .
|
||||
" User ID: $userid\n" .
|
||||
" Password: $password\n" .
|
||||
"\n\n";
|
||||
|
||||
// Send the emails
|
||||
QueueEmail($email,$replyEmail,$emailSubject,$message,$school_record['reply_description'],$name,"","",$batch_id);
|
||||
$Sent++;
|
||||
}
|
||||
else {
|
||||
$Errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
header("Location: /?action=email-staff-notices&error_message=" . urlencode(getLanguageText('ERRORMSG-NO-STAFF')));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Complete the email send
|
||||
$form_message = getLanguageText('MESSAGE-STAFF-NOTICES-SENT') . " - " . $Sent;
|
||||
header("Location: /?action=email-staff-notices&batch_id=$batch_id&form_message=" . urlencode($form_message));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
include "form.messages.php";
|
||||
|
||||
if (!array_key_exists('naction',$_POST) && !array_key_exists('naction',$_GET)) {
|
||||
|
||||
?>
|
||||
<form method='post' action='/'>
|
||||
<table>
|
||||
<tr>
|
||||
<td align='left'>
|
||||
<br>
|
||||
Reply Email Address:<br>
|
||||
<input type='text' name='reply_email' value="<?php echo(preg_replace("/,.*/","",$school_record['support_email'])) ?>" size='60'>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align='left'>
|
||||
Email Subject:<br>
|
||||
<input type='text' name='email_subject' value="<?php echo($school_record['school_name']) ?> Hot Lunches Info for Staff" size='60'>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align='left'>
|
||||
Staff Person:<br>
|
||||
<select name="selected_staff">
|
||||
<option value="0">All Staff</option>
|
||||
<?php
|
||||
$field_separator = ' ';
|
||||
if (!isset($selected_staff)) $selected_staff = '';
|
||||
BuildDBList("people","record_num","first_name,last_name","last_name",$selected_staff,"ASC","school_num = $school_num AND people_type = 'Staff'");
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<input type='hidden' name='action' value='email-staff-notices'>
|
||||
<input type='hidden' name='naction' value='email'>
|
||||
<input type='submit' class='btn btn--primary' value="<?php displayLanguageText('TEXT-SEND'); ?>">
|
||||
</form>
|
||||
<br>
|
||||
<?php
|
||||
}
|
||||
|
||||
endTemplate();
|
||||
?>
|
||||
Reference in new issue
Block a user