281 lines
8.3 KiB
PHP
281 lines
8.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','System Administrator','Communications Administrator');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
// Build a database query based on the input data provided
|
|
//
|
|
if (!$_POST) return;
|
|
extract($_POST);
|
|
|
|
|
|
$PrimaryTable = "sales_contacts";
|
|
|
|
|
|
//
|
|
// Define the default query to be used
|
|
//
|
|
$Parameters = "";
|
|
$EmailField = "email";
|
|
$Recipients = array("name","school_name","school_city","email");
|
|
$Alignment = array("left","left","left","left");
|
|
|
|
$Category = "Sales Contacts Broadcast";
|
|
$Description = "Broadcast to Hot Lunch Sales Contacts";
|
|
$Where = "";
|
|
|
|
|
|
//
|
|
// Handle any parameters
|
|
//
|
|
if (isset($selected_email) && strlen($selected_email)) {
|
|
$Where .= "AND email = '$selected_email' ";
|
|
}
|
|
|
|
|
|
// Process updated selection list
|
|
if (array_key_exists('sel',$_POST)) {
|
|
if (is_array($_POST['sel'])) {
|
|
$_POST['sel'] = join(",", $_POST['sel']);
|
|
}
|
|
$Where .= " and record_num IN ({$_POST['sel']}) ";
|
|
$Description .= " (custom recipient list)";
|
|
}
|
|
|
|
|
|
// Build the query
|
|
$Query = "SELECT * " .
|
|
"FROM sales_contacts " .
|
|
"WHERE email is not null " .
|
|
"AND email != '' " .
|
|
"AND active = 'Y' " .
|
|
$Where .
|
|
"ORDER BY email,name";
|
|
|
|
|
|
// create attachment list
|
|
if (array_key_exists('attachments',$_POST)) {
|
|
if (is_array($_POST['attachments'])) {
|
|
$attachments = $_POST['attachments'] = join(",", $_POST['attachments']);
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
// Determine how many emails will be sent
|
|
//
|
|
$results = db_query($Query);
|
|
$num_rows = db_num_rows($results);
|
|
|
|
|
|
?>
|
|
<center>
|
|
<form method="post" action="/">
|
|
<table width='90%' cellpadding='2' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='left'>
|
|
<h3>Confirm Email Send</h3>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left'>
|
|
<?php
|
|
$Subject = db_getVal("SELECT content_id FROM formatted_content WHERE school_num = $school_num AND record_num = $MessageID");
|
|
echo("<b>$Subject</b><br>\n");
|
|
echo("$Category:<br>\n");
|
|
echo("$Description:<br>\n");
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left'>
|
|
<table width='500' cellpadding='5' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='left' colspan='2'><p><strong><?php echo($num_rows) ?> record(s) found</strong></p></td>
|
|
</tr>
|
|
<?php
|
|
if ($num_rows > 0) {
|
|
?>
|
|
<tr>
|
|
<td align='left'>Send Emails:</td>
|
|
<td align='left'>
|
|
<select name="SendAfter">
|
|
<?php include "email-send-times.php"; ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' align='center'>
|
|
<br>
|
|
<input type='submit' class='btn btn--primary' value="Send Emails">
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<input type="hidden" name="ReplyTo" value="<?php echo($ReplyTo) ?>">
|
|
<input type="hidden" name="ReplyDescription" value="<?php echo($ReplyDescription) ?>">
|
|
<input type="hidden" name="MessageID" value="<?php echo($MessageID) ?>">
|
|
<input type="hidden" name="EmailTemplate" value="<?php echo($EmailTemplate) ?>">
|
|
<input type="hidden" name="Category" value="<?php echo($Category) ?>">
|
|
<input type="hidden" name="Description" value="<?php echo($Description) ?>">
|
|
<input type="hidden" name="Query" value="<?php echo($Query) ?>">
|
|
<input type="hidden" name="EmailField" value="<?php echo($EmailField) ?>">
|
|
<input type="hidden" name="attachments" value="<?php echo($attachments) ?>">
|
|
<input type="hidden" name="Parameters" value="<?php echo($Parameters) ?>">
|
|
<input type="hidden" name="PrimaryTable" value="<?php echo($PrimaryTable) ?>">
|
|
<?php
|
|
$post_fields = array_keys($_POST);
|
|
for ($i = 0; $i < count($post_fields); $i++) {
|
|
$field_name = $post_fields[$i];
|
|
$field_value = htmlentities($_POST[$field_name]);
|
|
if (strpos($field_name, 'custom_') !== false) {
|
|
echo(" <input type='hidden' name=\"{$field_name}\" value=\"{$field_value}\">\n");
|
|
}
|
|
}
|
|
?>
|
|
<input type="hidden" name="action" value="email-sales-contacts">
|
|
<input type="hidden" name="naction" value="send">
|
|
</form>
|
|
<?php if ($view_recipients != 'Y') { ?>
|
|
<form method='post' action='/'>
|
|
<table width='90%' cellpadding='2' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='left'>
|
|
<table width='400' cellpadding='5' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='center'>
|
|
<input type='submit' class='btn btn--primary' value="View Recipient List">
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
$post_fields = array_keys($_POST);
|
|
for ($i = 0; $i < count($post_fields); $i++) {
|
|
$field_name = $post_fields[$i];
|
|
$field_value = $_POST[$field_name];
|
|
if (is_array($field_value)) {
|
|
foreach ($field_value as $a => $b) {
|
|
echo(" <input type='hidden' name='{$field_name}[{$a}]' value=\"$b\">\n");
|
|
}
|
|
} else {
|
|
echo(" <input type='hidden' name='$field_name' value=\"$field_value\">\n");
|
|
}
|
|
}
|
|
?>
|
|
<input type='hidden' name='view_recipients' value='Y'>
|
|
</form>
|
|
<?php } else { ?>
|
|
<h3>Recipient List</h3>
|
|
<form action="/" method=post>
|
|
<input type="hidden" name="action" value="email-sales-contacts">
|
|
<input type="hidden" name="naction" value="confirm">
|
|
<input type="hidden" name="ReplyTo" value="<?php echo $_POST['ReplyTo'] ?>">
|
|
<input type="hidden" name="ReplyDescription" value="<?php echo $_POST['ReplyDescription'] ?>">
|
|
<input type="hidden" name="MessageID" value="<?php echo $_POST['MessageID'] ?>">
|
|
<input type="hidden" name="EmailTemplate" value="<?php echo $_POST['EmailTemplate'] ?>">
|
|
<input type="hidden" name="attachments" value="<?php echo $_POST['attachments'] ?>">
|
|
<?php
|
|
$post_fields = array_keys($_POST);
|
|
for ($i = 0; $i < count($post_fields); $i++) {
|
|
$field_name = $post_fields[$i];
|
|
$field_value = $_POST[$field_name];
|
|
if (is_array($field_value)) {
|
|
foreach ($field_value as $a => $b) {
|
|
echo(" <input type='hidden' name='{$field_name}[{$a}]' value=\"$b\">\n");
|
|
}
|
|
} else {
|
|
echo(" <input type='hidden' name='$field_name' value=\"$field_value\">\n");
|
|
}
|
|
}
|
|
?>
|
|
<input type="hidden" name="sel[]" value="0">
|
|
<!--
|
|
<input type='submit' class='btn btn--primary' value="Update Recipient List"><br><br>
|
|
-->
|
|
|
|
<table width='600' cellpadding='3' cellspacing='1' border='0' class='content-table'>
|
|
<tr>
|
|
<?php
|
|
for ($i = 0; $i < count($Recipients); $i++) {
|
|
$field = ucwords(str_replace("_"," ",$Recipients[$i]));
|
|
$align = $Alignment[$i];
|
|
echo(" <td align='$align' class='heading'>$field</td>\n");
|
|
}
|
|
?>
|
|
<td align=center class='heading'><a href="javascript:checkAll();"><span class='heading'>All</span></a>
|
|
<a href="javascript:checkNone();"><span class='heading'>None</span></a></td>
|
|
</tr>
|
|
<?php
|
|
$results = db_query($Query);
|
|
$count = 0;
|
|
|
|
while ($row = db_fetch_array($results)) {
|
|
$bgclass = "data-even";
|
|
if ($count % 2) $bgclass = "data-odd";
|
|
$count++;
|
|
echo(" <tr>\n");
|
|
|
|
for ($i = 0; $i < count($Recipients); $i++) {
|
|
$field = $Recipients[$i];
|
|
$align = $Alignment[$i];
|
|
echo(" <td align='$align' class='$bgclass'>$row[$field]</td>\n");
|
|
}
|
|
echo("<td class='$bgclass' align=center><input class=checkbox type=checkbox name=\"sel[]\" id=sel{$count} checked value=\"{$row['record_num']}\"></td>");
|
|
echo(" </tr>\n");
|
|
}
|
|
?>
|
|
</table>
|
|
<br><input type=submit value="Update Recipient List" class='btn btn--primary'>
|
|
</form>
|
|
<script type="text/javascript">
|
|
function checkAll() {
|
|
for (i=1; i<= <?php echo $count ?>; i++) {
|
|
document.getElementById('sel'+i).checked = true;
|
|
}
|
|
}
|
|
function checkNone() {
|
|
for (i=1; i<= <?php echo $count ?>; i++) {
|
|
document.getElementById('sel'+i).checked = false;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<?php
|
|
}
|
|
}
|
|
else {
|
|
?>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
<br>
|
|
<br>
|
|
<br>
|