65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
<?php
|
|
$ValidAccess = 2010;
|
|
require_once("include/globals.php");
|
|
include_once("include/queuemail.php");
|
|
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
logExit("Session is not active",$moduleName);
|
|
exit();
|
|
}
|
|
|
|
// Set userType
|
|
$userType = "Parent";
|
|
if (array_key_exists('type', $_SESSION['UserInfo']) && in_array($_SESSION['UserInfo']['type'],$AllAdminUserTypes)) $userType = "Admin";
|
|
if ($userType != 'Admin') return;
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
if ($userType != 'Admin') {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
logExit($error_message);
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
// CSRF token validation
|
|
include "include/ajax.csrfToken.php";
|
|
|
|
|
|
$moduleName = "ajax.sendWeeklyReminder.php";
|
|
// startLog($moduleName);
|
|
|
|
|
|
// Get parameters
|
|
if (array_key_exists('user_num', $_GET)) $user_num = intval($_GET['user_num']);
|
|
if (!isset($user_num)) logExit("User Num is not set");
|
|
|
|
|
|
// Get user record
|
|
$query = "SELECT * FROM users WHERE school_num = $base_school_num AND record_num = $user_num";
|
|
$row = db_getVal($query);
|
|
|
|
writeLog($row['first_name'].' '.$row['last_name']);
|
|
|
|
// Get weekly order info
|
|
$msg = getUserOrders($user_num,$school_num);
|
|
|
|
// Send reminder email to account
|
|
if (strlen($msg)) {
|
|
$emailRecipient = $row['userid'];
|
|
$emailTo = $row['email'];
|
|
$emailReply = $school_record['reply_description'];
|
|
$emailFrom = "notifications@easyschoolsoftware.net";
|
|
$emailFrom = setReplyAddress($school_record['support_email'],"notifications");
|
|
$emailMessage = $msg;
|
|
|
|
$emailSubject = $school_record['school_name'] . " " . getLanguageText('TEXT-ORDER-REMINDER');
|
|
|
|
QueueEmail($emailTo, $emailFrom, $emailSubject, $emailMessage, $emailReply, $emailRecipient);
|
|
}
|
|
|
|
return(0);
|
|
?>
|