235 lines
7.3 KiB
PHP
235 lines
7.3 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Ensure that only admin users have access to this module
|
|
$AllowedUserTypes = array('SuperUser');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
$ReplyTo = "sales@hotlunches.net";
|
|
$ReplyDescription = "Hot Lunches On-Line";
|
|
|
|
?>
|
|
<form action="/" method="post">
|
|
<table width="90%" cellpadding="2" cellspacing="1" border="0">
|
|
<tr>
|
|
<td align='left' colspan='2'>
|
|
<h3><?php displayLanguageText('TEXT-SEND-EMAIL-TO-CONTACTS'); ?></h3>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="right"><?php displayLanguageText('TEXT-REPLY-TO-ADDRESS'); ?>:</td>
|
|
<td align='left'><input type="text" name="ReplyTo" value="<?php echo($ReplyTo); ?>" size="40"></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="right"><?php displayLanguageText('TEXT-REPLY-TO-DESCRIPTION'); ?>:</td>
|
|
<td align='left'><input type="text" name="ReplyDescription" value="<?php echo($ReplyDescription); ?>" size="40"></td>
|
|
</tr>
|
|
<tr id="messageRow">
|
|
<td align="right"><?php displayLanguageText('TEXT-EMAIL-MESSAGE'); ?>:</td>
|
|
<td align='left'>
|
|
<select name="MessageID" id="MessageID" onChange="DoMessageChange();">
|
|
<?php
|
|
$customFields = array();
|
|
$query = "select * from formatted_content " .
|
|
"where content_type in ('E','S','Reminder') " .
|
|
"and school_num = $school_num " .
|
|
"order by date_modified desc,date_added desc";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
while ($row = db_fetch_array($results)) {
|
|
$subject = $row["content_id"];
|
|
$record_num = $row["record_num"];
|
|
$text = $subject;
|
|
if (strlen($text) > 50) $text = substr($subject, 0, 50)."...";
|
|
echo(" <option value='$record_num'>$text</option>\n");
|
|
$numFields = preg_match_all('/\{custom\.(text|textarea)\.([a-z0-9_]+)\}/', $row['content'], $matches, PREG_SET_ORDER);
|
|
for ($i=0; $i<$numFields; $i++) {
|
|
$customFields[] = array($record_num, $i+1, $matches[$i][1], $matches[$i][2]);
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="right"><?php displayLanguageText('TEXT-TEMPLATE'); ?>:</td>
|
|
<td align="left">
|
|
<select name="EmailTemplate">
|
|
<?php
|
|
$dir = opendir("email_templates");
|
|
while ($file = readdir($dir)) {
|
|
if ($file == ".") continue;
|
|
if ($file == "..") continue;
|
|
|
|
if (strpos($file, ".html") > 0 || strpos($file, ".htm") > 0) {
|
|
$selected = '';
|
|
if ($file == 'EmailTemplate.NoHeader.html') $selected = " selected='selected'";
|
|
echo(" <option value='$file'$selected>$file</option>\n");
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2"> </td>
|
|
</tr>
|
|
<tr>
|
|
<td align="right" valign="top"><?php displayLanguageText('TEXT-PROVINCE'); ?>:</td>
|
|
<td align="left">
|
|
<select name="SelectedProvinces[]" size='5' multiple>
|
|
<option value='' selected='selected'>All Provinces</option>
|
|
<?php
|
|
$provinces = db_query("SELECT province,count(*) AS num FROM schools WHERE status IN ('Active','Special') GROUP BY 1");
|
|
while ($row = db_fetch_array($provinces)) {
|
|
extract($row);
|
|
echo(" <option value=\"'$province'\">$province - $num</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="right" valign="top"><?php displayLanguageText('TEXT-RESELLER'); ?>:</td>
|
|
<td align="left">
|
|
<?php $num = db_getVal("SELECT count(*) FROM resellers WHERE sequence > 0") + 1; ?>
|
|
<select name="SelectedReseller[]" size='<?php echo($num) ?>' multiple>
|
|
<option value='' selected='selected'>Any</option>
|
|
<?php
|
|
$resellers = db_query("SELECT * FROM resellers WHERE sequence != -1 ORDER BY sequence,business_name");
|
|
while ($row = db_fetch_array($resellers)) {
|
|
extract($row);
|
|
echo(" <option value=\"'$reseller_code'\">$business_name</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="right" valign="top"><?php displayLanguageText('TEXT-SCHOOL'); ?>:</td>
|
|
<td align="left">
|
|
<select name="SelectedSchools[]" id='selected-schools' size='20' multiple>
|
|
<option value='0' selected='selected'>All Schools</option>
|
|
<?php BuildDBList("schools","record_num","school_name,city,province","school_name",0,"ASC","and status IN ('Active','Special')") ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="right"><?php displayLanguageText('TEXT-RENEWAL-INVOICE-ISSUED'); ?>:</td>
|
|
<td align='left'><?php BuildFileRadio("yn.txt","renewal_invoice_issued") ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="right"><?php displayLanguageText('TEXT-BALANCE-OWING'); ?>:</td>
|
|
<td align='left'><?php BuildFileRadio("yn.txt","BalanceOwing") ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="right"><?php displayLanguageText('TEXT-RENEWAL-INVOICE-PAID'); ?>:</td>
|
|
<td align='left'><?php BuildFileRadio("yn.txt","renewal_invoice_paid") ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2"> </td>
|
|
</tr>
|
|
|
|
<?php
|
|
// Get set of attachment files
|
|
$files = array();
|
|
$dir = opendir($attachdir);
|
|
echo("\n\n<!-- $attachdir -->\n\n");
|
|
$i = 0;
|
|
|
|
while (($file = readdir($dir)) != false) {
|
|
if ($file == ".") continue;
|
|
if ($file == "..") continue;
|
|
$files[] = $file;
|
|
$i+=1;
|
|
}
|
|
|
|
if ($i > 0) {
|
|
sort($files);
|
|
?>
|
|
<tr>
|
|
<td align="right" valign="top"><?php displayLanguageText('TEXT-ATTACHMENTS'); ?>:</td>
|
|
<td align='left'>
|
|
<?php
|
|
$count = 0;
|
|
$jscript = "<script type='text/javascript'>\n";
|
|
$jscript .= "var attachListArr = new Array();\n";
|
|
|
|
foreach ($files as $f) { ?>
|
|
<input type="checkbox" class=checkbox name="attachments[]" id="<?php echo($f) ?>" value="<?php echo("$attachpath/$f") ?>"><?php echo($f); ?><br>
|
|
<?php
|
|
$jscript .= "attachListArr[$count] = '$f';\n";
|
|
$count++;
|
|
}
|
|
$jscript .= "</script>\n";
|
|
echo $jscript;
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</table>
|
|
<input type='submit' class='btn btn--primary' value="<?php displayLanguageText('TEXT-SEND-EMAIL-TO-CONTACTS'); ?>">
|
|
<input type="hidden" name="action" value="email-hotlunch-contacts">
|
|
<input type="hidden" name="naction" value="confirm">
|
|
</center>
|
|
</form>
|
|
|
|
<script language="JavaScript">
|
|
var currMessage=0;
|
|
var goodRowDisplay = document.getElementById('messageRow').style.display;
|
|
function DoMessageChange() {
|
|
|
|
// deactivate all attachment check boxes
|
|
var arrLen=attachListArr.length;
|
|
for (var j=0, len=arrLen; j<len; ++j) {
|
|
var attachSel = attachListArr[j];
|
|
document.getElementById(attachSel).checked = false;
|
|
}
|
|
|
|
// activate the corrects ones
|
|
var msgVar = document.getElementById('MessageID').value;
|
|
var arrLen = (attachArr[msgVar] ? attachArr[msgVar].length : 0);
|
|
for (var j=0, len=arrLen; j<len; ++j) {
|
|
var attachSel = attachArr[msgVar][j];
|
|
document.getElementById(attachSel).checked = true;
|
|
}
|
|
|
|
if (currMessage) {
|
|
i = 1;
|
|
while (x = document.getElementById('custom_' + currMessage + '_' + i)) {
|
|
x.disabled = true;
|
|
document.getElementById('custom_row_'+ currMessage + '_' + i).style.display = 'none';
|
|
i++;
|
|
}
|
|
}
|
|
currMessage = msgVar;
|
|
i = 1;
|
|
while (x = document.getElementById('custom_' + currMessage + '_' + i)) {
|
|
x.disabled = false;
|
|
document.getElementById('custom_row_'+ currMessage + '_' + i).style.display = goodRowDisplay;
|
|
i++;
|
|
}
|
|
|
|
}
|
|
</script>
|
|
|
|
<script language="JavaScript">
|
|
DoMessageChange();
|
|
</script>
|