Files
HotLunches/hotlunch.item_report.php
T
2026-10-19 15:22:52 -07:00

392 lines
14 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$headerArgs = "";
// Ensure that only valid user types have access to this module
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier','Financial Team','Schedule Reporting');
if (checkPermission($AllowedUserTypes) != 1) {
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
$action = '';
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
//
// Process all actions to list and edit records
//
$naction = "";
if (array_key_exists('schedule_num',$_GET)) $schedule_num = intval($_GET['schedule_num']);
if (array_key_exists('schedule_num',$_POST)) $schedule_num = intval($_POST['schedule_num']);
if (array_key_exists('menu_num',$_GET)) $menu_num = intval($_GET['menu_num']);
if (array_key_exists('menu_num',$_POST)) $menu_num = intval($_POST['menu_num']);
$headerArgs = "&schedule_num=$schedule_num&menu_num=$menu_num";
if (!isset($schedule_num)) {
$error_message = getLanguageText('ERRORMSG-MISSING-DATA');
$action = 'schedule-reports';
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
if (!isset($menu_num)) {
$error_message = getLanguageText('ERRORMSG-MISSING-DATA');
$action = 'schedule-reports';
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
// Check if this is a valid schedule
$query = "select * from hotlunch_schedules " .
"where school_num = $school_num " .
"and record_num = $schedule_num";
$results = db_query($query);
if (db_num_rows($results) == 0) {
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE-NUM');
$action = 'schedule-reports';
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
$hotlunch_schedule = db_fetch_array($results);
// If this is a ScheduleTeam user check if they have permission to access this schedule
if (in_array($_SESSION['UserInfo']['type'],array('Schedule Team','Schedule Volunteer'))) {
$userNum = $_SESSION['UserInfo']['record_num'];
$access = db_getVal("SELECT count(*) FROM hotlunch_schedules_people WHERE school_num = $school_num AND schedule_num = $schedule_num AND user_num = $userNum");
if (!$access || $access == 0) {
$error_message = getLanguageText('ERRORMSG-NO-SCHEDULE-ACCESS');
$action = 'schedule-reports';
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
}
// Check if this is a valid menu
$query = "select * from hotlunch_menu_dates " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"and record_num = $menu_num";
$results = db_query($query);
if (db_num_rows($results) == 0) {
$error_message = getLanguageText('ERRORMSG-INVALID-MENU');
$action = 'schedule-reports';
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
$hotlunch_menu_date = db_fetch_array($results);
$menu_date = $hotlunch_menu_date['menu_date'];
$menu_title = $hotlunch_menu_date['menu_title'];
$templatePageTitle = getLanguageText('TEXT-ITEM-DETAILS') . " - $menu_title - $menu_date";
include "hotlunch_reports.menu.php";
echo("<br>\n");
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
$school_num = $school_record['record_num'];
include "form.messages.php";
//
// Display the menu selection
//
?>
<form method='post' action='/'>
<table width='90%' cellpadding='5' cellspacing='1'>
<tr>
<td width='25%' align='right'><?php displayLanguageText('TEXT-MENU-DATE'); ?>: </td>
<td align='left'>
<select name='menu_num' class='select-width500'>
<?php
$query = "select * from hotlunch_menu_dates " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"order by sequence,menu_date";
$results = db_query($query);
$selected_date = 'N';
while ($row = db_fetch_array($results)) {
$mtitle = $row['menu_title'];
$mdate = $row['menu_date'];
$record_num = $row['record_num'];
if ($hotlunch_schedule['display_menu_date'] == 'Y') $mtitle .= " - $mdate";
$selected = "";
if (isset($menu_num) && $menu_num == $record_num) {
$selected_date = 'Y';
$selected = " selected='selected'";
}
echo(" <option value='$record_num'$selected>$mtitle</option>\n");
}
?>
</select>
</td>
</tr>
<tr>
<td align='center' colspan='2'><input type='submit' name='button' class='btn btn--primary' value="<?php displayLanguageText('TEXT-CHANGE-MENU-DATE'); ?>"></td>
</tr>
</table>
<input type='hidden' name='action' value='item-report'>
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
</form>
<br>
<?php
// Check that this menu has menu items
$numItems = db_getVal("SELECT count(*) FROM hotlunch_menu_items WHERE school_num = $school_num AND menu_num = $menu_num");
if ($numItems == 0) $error_message = getLanguageText('ERRORMSG-NO-MENU-ITEMS');
include "form.messages.php";
if ($numItems > 0) {
?>
<form method='post' action='/'>
<table width='700' class='content-table'>
<tr class='heading'>
<td colspan='5' align='center'><?php echo("$menu_title - $menu_date") ?></td>
</tr>
<tr class='data-odd'>
<td align='left'>&nbsp;</td>
<td align='center'><b><?php displayLanguageText('TEXT-REQUIRED'); ?></b></td>
<td align='center'><b><?php displayLanguageText('TEXT-DISPLAY'); ?></b></td>
<td align='center'><b><?php displayLanguageText('TEXT-HIDE'); ?></b></td>
<td align='center'><b><?php displayLanguageText('TEXT-EXCLUDE'); ?></b></td>
</tr>
<?php
// Display the menu items
$query = "select * from hotlunch_menu_items " .
"where school_num = $school_num " .
"and menu_num = $menu_num " .
"order by sequence";
$menu_items = db_query($query);
$count = 0;
$items = array();
while ($menu_item = db_fetch_array($menu_items)) {
$item_num = $menu_item['record_num'];
$item_title = $menu_item['item_title'];
$label_title = $menu_item['label_title'];
$group_code = $menu_item['menu_group'];
if (strlen($group_code)) $group_code = "($group_code) ";
$class = 'data-even';
if ($count % 2) $class = 'data-odd';
$count++;
if ($menu_item['item_type'] != 'Heading') {
$items[] = "item_$item_num";
?>
<tr class='<?php echo($class) ?>'>
<td align='left'><?php echo("$group_code$item_title") ?> :: </td>
<td align='center'><input type='radio' name='item_<?php echo($item_num) ?>' id='item_<?php echo($item_num) ?>_required' value='Required'></td>
<td align='center'><input type='radio' name='item_<?php echo($item_num) ?>' id='item_<?php echo($item_num) ?>_display' value='Display'></td>
<td align='center'><input type='radio' name='item_<?php echo($item_num) ?>' id='item_<?php echo($item_num) ?>_hide' value='Hide' checked='checked'></td>
<td align='center'><input type='radio' name='item_<?php echo($item_num) ?>' id='item_<?php echo($item_num) ?>_exclude' value='Exclude'></td>
</tr>
<?php
}
else {
?>
<tr class='<?php echo($class) ?>'>
<td colspan='5' align='left'><b><?php echo($item_title) ?></b></td>
</tr>
<?php
}
}
$class = 'data-even';
if ($count % 2) $class = 'data-odd';
$count++;
?>
<tr class='<?php echo($class) ?>' height='30'>
<td colspan='5' align='center'>
<?php displayLanguageText('TEXT-DOCUMENT-FORMAT'); ?> ::
<input type='radio' name='document_format' value='list' checked='checked'> <?php displayLanguageText('TEXT-LIST'); ?>
<input type='radio' name='document_format' value='report'> <?php displayLanguageText('TEXT-REPORT'); ?>
<input type='radio' name='document_format' value='receipt'> <?php displayLanguageText('TEXT-RECEIPT'); ?>
</td>
</tr>
<?php
$class = 'data-even';
if ($count % 2) $class = 'data-odd';
$count++;
?>
<tr class='<?php echo($class) ?>' height='30'>
<td colspan='5' align='center'>
<?php displayLanguageText('TEXT-REPORT-SORT'); ?> ::
<?php
$checked = " checked='checked'";
if ($NumClasses > 0) {
?>
<input type='radio' name='report_sort' value='byClass'<?php echo($checked) ?>> <?php echo($GlobalText['Class']); ?>
<?php
$checked = "";
}
?>
<input type='radio' name='report_sort' value='byStudent'<?php echo($checked) ?>> <?php displayLanguageText('TEXT-ALPHABETICALLY'); ?>
</td>
</tr>
<?php
if ($school_record['orders_for'] == 'Participants' || $school_record['orders_for'] == 'Both') {
$class = 'data-even';
if ($count % 2) $class = 'data-odd';
$count++;
?>
<tr class='<?php echo($class) ?>' height='30'>
<td colspan='5' align='center'>
<?php displayLanguageText('TEXT-DISPLAY'); ?> ::
<input type='radio' name='contactInfo' id='contactInfo_id' value='Student' checked='checked'> <?php echo($GlobalText['Student']) ?>
<input type='radio' name='contactInfo' id='contactInfo_id' value='Parent'> <?php displayLanguageText('TEXT-PARENT'); ?>
<input type='radio' name='contactInfo' id='contactInfo_id' value='Both'> <?php displayLanguageText('TEXT-BOTH'); ?>
</td>
</tr>
<?php
}
else {
echo("<input type='hidden' name='contactInfo' value='Parent'>\n");
}
$class = 'data-even';
if ($count % 2) $class = 'data-odd';
$count++;
?>
<tr class='<?php echo($class) ?>' height='30'>
<td colspan='5' align='center'>
<?php displayLanguageText('TEXT-DISPLAY-PAYMENT-STATUS'); ?> :: <?php BuildFileRadio("yn.txt","display_payment_status",'N') ?>
</td>
</tr>
<?php
$class = 'data-even';
if ($count % 2) $class = 'data-odd';
$count++;
?>
<tr class='<?php echo($class) ?>' height='30'>
<td colspan='5' align='center'>
<?php displayLanguageText('TEXT-DISPLAY-USER-DATA'); ?> :: <?php BuildFileRadio("yn.txt","display_user_data",'N') ?>
</td>
</tr>
<?php
$class = 'data-even';
if ($count % 2) $class = 'data-odd';
$count++;
?>
<tr class='<?php echo($class) ?>' height='30'>
<td colspan='5' align='center'>
<?php displayLanguageText('TEXT-ORDER-STATUS'); ?> :: <?php BuildFileRadio("delivery_report_order_status.txt","orderStatus",'Active') ?>
</td>
</tr>
<?php
if (in_array($school_record['registration_address'],array('Optional','Required'))) {
$class = 'data-even';
if ($count % 2) $class = 'data-odd';
$count++;
$display_contact_details = 'N';
if ($siteType == 'registration') $display_contact_details = 'Y';
?>
<tr class='<?php echo($class) ?>' height='30'>
<td colspan='5' align='center'>
<?php displayLanguageText('TEXT-INCLUDE-CONTACT-DETAILS'); ?> :: <?php BuildFileRadio("yn.txt","display_contact_details",$display_contact_details) ?>
</td>
</tr>
<?php
}
$class = 'data-even';
if ($count % 2) $class = 'data-odd';
$count++;
?>
<tr class='<?php echo($class) ?>' height='40'>
<td colspan='5' align='center'>
<input type='hidden' name='action' value='item-report-generate'>
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
<input type='hidden' name='menu_num' value='<?php echo($menu_num) ?>'>
<input type='submit' name='button' class='btn btn--primary' value="<?php displayLanguageText('TEXT-GENERATE'); ?>">
</td>
</tr>
</table>
<br>
</form>
<br>
<?php
}
?>
<?php include "hotlunch_orders.print_buttons.php"; ?>
<script language='javascript'>
function toggleItemCheckboxes() {
var cb = document.getElementById('select_all').checked;
if (cb == false) {
<?php
if (isset($items) && is_array($items)) {
for ($i = 0; $i < count($items); $i++) {
$item = $items[$i];
echo(" var cb$i = document.getElementById('$item');\n");
echo(" cb$i.checked = false;\n");
}
}
?>
}
else {
<?php
if (isset($items) && is_array($items)) {
for ($i = 0; $i < count($items); $i++) {
$item = $items[$i];
echo(" var cb$i = document.getElementById('$item');\n");
echo(" cb$i.checked = true;\n");
}
}
?>
}
}
function clearOnePerBox() {
var cb = document.getElementById('select_all');
cb.checked = false;
}
</script>
<?php
endTemplate();
?>