Files
HotLunches/email_flag_recipients.form.php
2026-10-19 15:22:52 -07:00

309 lines
13 KiB
PHP

<?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','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;
}
if (!isset($flag)) $flag = 'N';
include "form.messages.php";
?>
<table width='600' cellpadding='0' cellspacing='20' border='0'>
<tr>
<td align='center'>
<table width='200' cellpadding='10' cellspacing='0' border='0' class='content-table'>
<tr>
<td colspan='2' class='success' align='center'><?php displayLanguageText('TEXT-USER-FLAGS-SETTINGS'); ?></td>
</tr>
<tr class='data-odd'>
<td align='center' width='50%'><b><?php displayLanguageText('TEXT-YES'); ?></td>
<td align='center'>
<?php
$num_entries = db_getVal("SELECT count(*) FROM users WHERE school_num = $base_school_num AND email_flag = 'Y'");
echo($num_entries);
?>
</td>
</tr>
<tr class='data-even'>
<td align='center' width='50%'><b><?php displayLanguageText('TEXT-NO'); ?></td>
<td align='center'>
<?php
$num_entries = db_getVal("SELECT count(*) FROM users WHERE school_num = $base_school_num AND email_flag = 'N'");
echo($num_entries);
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<form method='post' action='/'>
<td align='center' bgcolor='#cccccc'>
<table width='100%' cellpadding='10' cellspacing='0' border='0' class='content-table'>
<tr>
<td class='success' align='center'><?php displayLanguageText('TEXT-SET-ALL-USER-FLAGS'); ?></td>
</tr>
<tr>
<td align='center'>
<p><?php displayLanguageText('TEXT-SET-ALL-FLAGS-MESSAGE'); ?></p>
<p><?php displayLanguageText('TEXT-SET-FLAG-TO'); ?>: <?php BuildFileRadio("yn.txt","flag",$flag) ?></p>
<input type='submit' class='btn btn--primary' value="<?php displayLanguageText('TEXT-SET-ALL-USER-FLAGS'); ?>">
<br>
<br>
<p class='small'><?php displayLanguageText('TEXT-SET-FLAGS-INITIALIZATION-MESSAGE'); ?></p>
</td>
</tr>
</table>
</td>
<input type='hidden' name='action' value='email-flag-recipients'>
<input type='hidden' name='naction' value='update-all'>
</form>
</tr>
<tr>
<form method='post' action='/'>
<td align='center' bgcolor='#cccccc'>
<table width='100%' cellpadding='10' cellspacing='0' border='0' class='content-table'>
<tr>
<td class='success' align='center'><?php displayLanguageText('TEXT-SET-USER-FLAGS-BY-SCHEDULE'); ?></td>
</tr>
<tr>
<td align='center'>
<p><?php displayLanguageText('TEXT-SET-FLAGS-TO-SELECTED-VALUE'); ?></p>
<table cellpadding='10' cellspacing='1' border='0'>
<tr>
<td align='left'>
<?php displayLanguageText('TEXT-ORDERS-IN-SELECTED-SCHEDULE'); ?>:<br>
<select name='selected_schedule' class='select-width400'>
<?php
$title = db_getVal("SELECT school_name FROM schools WHERE record_num = $school_num");
echo(" <optgroup label='$title'>\n");
$schedules = db_query("SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND status != 'Deleted' ORDER BY schedule_start_date DESC");
while ($row = db_fetch_array($schedules)) {
$schedule_name = $row['schedule_name'];
$record_num = $row['record_num'];
echo(" <option value='$record_num'>$schedule_name</option>\n");
}
$linked_sites = db_query("SELECT * FROM schools WHERE linked_site = $school_num AND status = 'Linked' ORDER BY link_sequence");
if (db_num_rows($linked_sites)) {
while ($row = db_fetch_array($linked_sites)) {
$title = $row['link_title'];
$snum = $row['record_num'];
echo(" </optgroup>\n");
echo(" <optgroup label='$title'>\n");
$schedules = db_query("SELECT * FROM hotlunch_schedules WHERE school_num = $snum AND status != 'Deleted' ORDER BY schedule_start_date DESC");
while ($row = db_fetch_array($schedules)) {
$schedule_name = $row['schedule_name'];
$record_num = $row['record_num'];
echo(" <option value='$record_num'>$schedule_name</option>\n");
}
}
}
?>
</optgroup>
</select>
</td>
</tr>
</table>
<p>Set Flag To: <?php BuildFileRadio("yn.txt","flag",$flag) ?></p>
<input type='submit' class='btn btn--primary' value="<?php displayLanguageText('TEXT-SET-ALL-USER-FLAGS'); ?>">
<br>
<br>
<p class='small'><?php displayLanguageText('TEXT-USER-FLAGS-BY-SCHEDULE-MESSAGE'); ?></p>
</td>
</tr>
</table>
</td>
<input type='hidden' name='action' value='email-flag-recipients'>
<input type='hidden' name='naction' value='update-by-schedule'>
</form>
</tr>
<tr>
<form method='post' action='/'>
<td align='center' bgcolor='#cccccc'>
<table width='100%' cellpadding='10' cellspacing='0' border='0' class='content-table'>
<tr>
<td class='success' align='center'><?php displayLanguageText('TEXT-SET-USER-FLAGS-BY-MENU-ITEM'); ?></td>
</tr>
<tr>
<td align='center'>
<table cellpadding='10' cellspacing='1' border='0'>
<tr>
<td align='left'>
<?php displayLanguageText('TEXT-ITEMS-ORDERED'); ?>:<br>
<select name='selected_menu_items[]' multiple size='10' class='select-width400'>
<?php
$schedules = db_query("SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND status != 'Deleted' ORDER BY schedule_start_date DESC");
while ($row = db_fetch_array($schedules)) {
$schedule_name = $row['schedule_name'];
$schedule_num = $row['record_num'];
$schedule_type = $row['schedule_type'];
$menus = db_query("SELECT * FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num AND active != 'N' ORDER BY sequence");
$numItems = db_getVal("SELECT count(*) FROM hotlunch_menu_dates AS hlmd, hotlunch_menu_items AS hlmi " .
"WHERE hlmd.school_num = $school_num " .
"AND hlmi.school_num = $school_num " .
"AND hlmd.schedule_num = $schedule_num " .
"AND hlmi.menu_num = hlmd.record_num");
if ($numItems == 0) continue;
echo(" <optgroup label='$schedule_name'>\n");
while ($row = db_fetch_assoc($menus)) {
$menu_title = $row['menu_title'];
$menu_num = $row['record_num'];
$menu_date = $row['menu_date'];
$items = db_query("SELECT * FROM hotlunch_menu_items WHERE school_num = $school_num AND menu_num = $menu_num AND item_type = 'Item' ORDER BY sequence");
if (db_num_rows($items) == 0) continue;
switch ($schedule_type) {
case 'Hot Lunch':
case 'Date Sensitive':
$menu_title .= " - $menu_date ($schedule_name)";
break;
}
echo(" <optgroup label=' - $menu_title'>\n");
while ($row = db_fetch_assoc($items)) {
$item_title = $row['item_title'];
$item_num = $row['record_num'];
echo(" <option value='$item_num'>$item_title</option>\n");
}
echo(" </optgroup>\n");
}
echo(" </optgroup>\n");
}
?>
</select>
</td>
</tr>
</table>
<p>Set Flag To: <?php BuildFileRadio("yn.txt","flag",$flag) ?></p>
<input type='submit' class='btn btn--primary' value="<?php displayLanguageText('TEXT-SET-ALL-USER-FLAGS'); ?>">
<br>
<br>
<p class='small'><?php displayLanguageText('TEXT-FLAG-USERS-BY-MENU-ITEM-MESSAGE'); ?></p>
</td>
</tr>
</table>
</td>
<input type='hidden' name='action' value='email-flag-recipients'>
<input type='hidden' name='naction' value='update-by-menu-item'>
</form>
</tr>
<tr>
<form method='post' action='/'>
<td align='center' bgcolor='#cccccc'>
<table width='100%' cellpadding='10' cellspacing='0' border='0' class='content-table'>
<tr>
<td class='success' align='center'><?php displayLanguageText('TEXT-SET-USER-FLAGS-BY-TRANSACTION-TYPE-AND-SCHEDULE'); ?></td>
</tr>
<tr>
<td align='center'>
<p><?php displayLanguageText('TEXT-SET-ALL-FLAGS-MESSAGE'); ?></p>
<table cellpadding='10' cellspacing='1' border='0'>
<tr>
<td align='left'>
<?php displayLanguageText('TEXT-TRANSACTION-TYPE'); ?>:<br>
<select name='transaction_type' class='select-width400'>
<option value=''><?php displayLanguageText('TEXT-SELECT'); ?></option>
<optgroup label="<?php displayLanguageText('TEXT-CHARGES-AND-FEES'); ?>">
<?php BuildFileList("transaction_types_charges.txt") ?>
<?php
$r = db_query("SELECT * FROM user_account_trx_codes WHERE school_num = $base_school_num AND trx_category = 'Charge' ORDER BY sequence");
if (db_num_rows($r)) {
while ($row = db_fetch_assoc($r)) {
$transaction_type_code = $row['transaction_type_code'];
$selected = "";
if (isset($selected_transaction_type) && $transaction_type_code == $selected_transaction_type) $selected = " selected='selected'";
echo("<option value='$transaction_type_code'$selected>$transaction_type_code</option>\n");
}
}
?>
</optgroup>
<optgroup label="<?php displayLanguageText('TEXT-PAYMENTS-AND-CREDITS'); ?>">
<?php BuildFileList("transaction_types_payments.txt") ?>
<?php
$r = db_query("SELECT * FROM user_account_trx_codes WHERE school_num = $base_school_num AND trx_category = 'Credit' ORDER BY sequence");
if (db_num_rows($r)) {
while ($row = db_fetch_assoc($r)) {
$transaction_type_code = $row['transaction_type_code'];
$selected = "";
if (isset($selected_transaction_type) && $transaction_type_code == $selected_transaction_type) $selected = " selected='selected'";
echo("<option value='$transaction_type_code'$selected>$transaction_type_code</option>\n");
}
}
?>
</optgroup>
<optgroup label="<?php displayLanguageText('TEXT-OTHER'); ?>">
<?php BuildFileList("transaction_types_other.txt") ?>
<?php
$r = db_query("SELECT * FROM user_account_trx_codes WHERE school_num = $base_school_num AND trx_category = 'Note' ORDER BY sequence");
if (db_num_rows($r)) {
while ($row = db_fetch_assoc($r)) {
$transaction_type_code = $row['transaction_type_code'];
$selected = "";
if ($transaction_type_code == $selected_transaction_type) $selected = " selected='selected'";
echo("<option value='$transaction_type_code'$selected>$transaction_type_code</option>\n");
}
}
?>
</optgroup>
</select>
</td>
</tr>
<tr>
<td align='left'>
<?php displayLanguageText('TEXT-SCHEDULE'); ?>:<br>
<select name='selected_schedule' class='select-width400'>
<option value=''>Any Schedule</option>
<?php
$schedules = db_query("SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND status != 'Deleted' ORDER BY schedule_start_date DESC");
while ($row = db_fetch_array($schedules)) {
$schedule_name = $row['schedule_name'];
$record_num = $row['record_num'];
$selected = "";
if (isset($schedule) && $schedule == $record_num) $selected = " selected='selected'";
echo(" <option value='$record_num'>$schedule_name</option>\n");
}
?>
</select>
</td>
</tr>
</table>
<p><?php displayLanguageText('TEXT-SET-FLAG-TO'); ?>: <?php BuildFileRadio("yn.txt","flag",$flag) ?></p>
<input type='submit' class='btn btn--primary' value="<?php displayLanguageText('TEXT-SET-ALL-USER-FLAGS'); ?>">
<br>
<br>
</td>
</tr>
</table>
</td>
<input type='hidden' name='action' value='email-flag-recipients'>
<input type='hidden' name='naction' value='update-by-transaction-type'>
</form>
</tr>
</table>
<br>