Files
HotLunches/email-messages-list.php
2026-10-19 15:22:52 -07:00

126 lines
4.5 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','Application Administrator','Volunteer Administrator','Communications Administrator','Financial','Financial Team');
if (checkPermission($AllowedUserTypes) != 1) {
echo("<br>\n");
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
include "form.messages.php";
return;
}
//
// Process order by requests
//
if (!isset($ob)) $ob = 'date';
switch ($ob) {
case 'subject':
$orderby = "content_id asc";
break;
case 'subject_desc':
$orderby = "content_id desc";
break;
case 'date_asc':
$orderby = "date_modified asc, date_added asc";
break;
case 'date':
default:
$orderby = "date_modified desc, date_added desc";
break;
}
$exclude_codes = "'C','S','A'";
if ($_SESSION['UserInfo']['type'] == 'SuperUser') $exclude_codes = "'C','A'";
$query = "SELECT * FROM formatted_content " .
"WHERE school_num = $school_num " .
"AND content_type NOT IN ($exclude_codes) " .
"ORDER BY $orderby";
$results = db_query($query);
if (db_num_rows($results)) {
?>
<center>
<table width="95%" cellpadding='2' cellspacing='1' border='0'>
<tr>
<td align='left' colspan='3'><h3>Email Messages Administration</h3></td>
</tr>
</table>
<table width="95%" cellpadding='2' cellspacing='1' border='0' class='content-table'>
<tr>
<td align='left' class='heading'>Subject
&nbsp;&nbsp;
&nbsp;&nbsp;<a href='?action=email-messages&ob=subject'><img src='images/triup-white.gif' border='0'></a>
&nbsp;&nbsp;<a href='?action=email-messages&ob=subject_desc'><img src='images/tridown-white.gif' border='0'></a>
</td>
<td align='left' class='heading'>Modified
&nbsp;&nbsp;
&nbsp;&nbsp;<a href='?action=email-messages&ob=date'><img src='images/triup-white.gif' border='0'></a>
&nbsp;&nbsp;<a href='?action=email-messages&ob=date_asc'><img src='images/tridown-white.gif' border='0'></a>
</td>
<td class='heading' align='center'>Type</td>
<td class='heading' align='center'>
<table cellpadding='0' cellspacing='2' border='0'>
<tr>
<td align='left'><a href="?action=email-messages&naction=add" class='btn btn--primary btn--xsmall'><span>Add Message</span></a></td>
</tr>
</table>
</td>
</tr>
<?php
$edit_icon = "<img src='images/icons/edit24.png' alt='Edit Message' border='0'>";
$preview_icon = "<img src='images/icons/filesearch24.png' alt='Preview Message' border='0'>";
$copy_icon = "<img src='images/icons/redo24.png' alt='Copy Message' border='0'>";
$delete_icon = "<img src='images/icons/delete24.png' alt='Delete Message' border='0'>";
$count = 0;
while ($row = db_fetch_array($results)) {
$subject = $row["content_id"];
$type = $row["content_type"];
$modified = $row["date_modified"];
$record_num = $row["record_num"];
$bgclass = 'data-even';
if ($count % 2) $bgclass = 'data-odd';
$count++;
?>
<tr>
<td align='left' class="<?php echo($bgclass) ?>"><?php echo($subject) ?></td>
<td align='left' class="<?php echo($bgclass) ?>"><?php echo($modified) ?></td>
<td class="<?php echo($bgclass) ?>" align='center'><?php echo($type) ?></td>
<td class="<?php echo($bgclass) ?>" align="center">
<table cellpadding='0' cellspacing='2' border='0'>
<tr>
<td align='left'><a href="?action=email-messages&naction=edit&record_num=<?php echo($record_num) ?>" title='Edit Message'><?php echo($edit_icon) ?></a></td>
<td align='left'><a href="email-preview.php?id=<?php echo($record_num) ?>" target="_blank" title='Preview Message'><?php echo($preview_icon) ?></a></td>
<td align='left'><a href="?action=email-messages&naction=copy&record_num=<?php echo($record_num) ?>" title='Copy Message'><?php echo($copy_icon) ?></a></td>
<td align='left'><a href="?action=email-messages&naction=delete&record_num=<?php echo($record_num) ?>" title='Delete Message'><?php echo($delete_icon) ?></a></td>
</tr>
</table>
</nobr>
</td>
</tr>
<?php
}
?>
</table>
</center>
<?php
}
?>
<br>
<?php if ($school_record['status'] != 'Linked') { ?>
<p><a href="?action=email-messages&naction=add" class='btn btn--primary>'>&nbsp;&nbsp;Add New Message&nbsp;&nbsp;</a></p>
<?php } ?>