236 lines
7.5 KiB
PHP
236 lines
7.5 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','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier','Financial Team','Schedule Reporting');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
|
|
|
|
//
|
|
// 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']);
|
|
|
|
if (!isset($schedule_num)) {
|
|
echo("<br>\n");
|
|
$error_message = "Error: schedule number must be specified";
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
if (!isset($menu_num)) {
|
|
echo("<br>\n");
|
|
$error_message = "Error: menu number must be specified";
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
|
|
// 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) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
$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 = intval($_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) {
|
|
echo("<br>\n");
|
|
$error_message = "You are not allowed access to the requested hot lunch schedule";
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
|
echo("<br>\n");
|
|
$error_message = "The requested hot lunch menu is invalid";
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
$hotlunch_menu_date = db_fetch_array($results);
|
|
$menu_date = $hotlunch_menu_date['menu_date'];
|
|
$menu_title = $hotlunch_menu_date['menu_title'];
|
|
|
|
$templatePageTitle = getLanguageText('TEXT-OPTION-DETAILS') . " - $menu_title - $menu_date";
|
|
|
|
// Get the set of options for the selected menu date
|
|
$query = "select * from hotlunch_menu_items " .
|
|
"where school_num = $school_num " .
|
|
"and menu_num = $menu_num " .
|
|
"and length(options) > 0 " .
|
|
"order by sequence";
|
|
$menu_items = db_query($query);
|
|
|
|
|
|
if (db_num_rows($menu_items) == 0) $error_message = "Error: This menu has no options to report on";
|
|
include "form.messages.php";
|
|
|
|
|
|
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'];
|
|
|
|
|
|
//
|
|
// Display the menu selection
|
|
//
|
|
?>
|
|
<form method='post' action='/'>
|
|
<table width='90%' cellpadding='5' cellspacing='1'>
|
|
<tr>
|
|
<td width='35%' align='right'><?php displayLanguageText('TEXT-MENU-DATE'); ?>: </td>
|
|
<td align='left'>
|
|
<select name='menu_num'>
|
|
<?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='option-details'>
|
|
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
|
|
</form>
|
|
<br>
|
|
<?php
|
|
if (db_num_rows($menu_items) > 0) {
|
|
?>
|
|
<form method='post' action='/'>
|
|
<table width='500' class='content-table'>
|
|
<tr class='heading'>
|
|
<td colspan='2' align='center'><?php echo("$menu_title - $menu_date") ?></td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-odd';
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td colspan='2' align='center'>
|
|
Summarize By ::
|
|
<input type='radio' name='mode' value='Class' checked='checked'> <?php displayLanguageText('TEXT-CLASS'); ?>
|
|
<input type='radio' name='mode' value='School'> <?php displayLanguageText('TEXT-SCHOOL'); ?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<input type='hidden' name='action' value='order-options-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-REPORT'); ?>">
|
|
</form>
|
|
<br>
|
|
<br>
|
|
<?php
|
|
|
|
$Fields = array("options_ordered","options2_ordered","options3_ordered");
|
|
for ($i = 0; $i < count($Fields); $i++) {
|
|
$field = $Fields[$i];
|
|
$query = "SELECT $field,count(*) AS number FROM hotlunch_order_items WHERE school_num = $school_num AND menu_num = $menu_num AND $field > '' group by 1";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
?>
|
|
<table width='500' class='content-table'>
|
|
<tr class='heading'>
|
|
<td colspan='2' align='center'><?php echo("$menu_title - $menu_date - $field") ?></td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-odd';
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$f = str_replace("\n",", ",$row[$field]);
|
|
$number = $row['number'];
|
|
echo(" <tr class='$class'>\n");
|
|
echo(" <td width='400'>$f</td>\n");
|
|
echo(" <td align='center'>$number</td>\n");
|
|
echo(" </tr>\n");
|
|
|
|
if ($class == 'data-odd') $class = 'data-even';
|
|
else $class = 'data-odd';
|
|
}
|
|
?>
|
|
</table>
|
|
<br>
|
|
<?php
|
|
}
|
|
|
|
}
|
|
}
|
|
?>
|
|
|
|
<?php
|
|
include "hotlunch_orders.print_buttons.php";
|
|
|
|
endTemplate();
|
|
?>
|