450 lines
17 KiB
PHP
450 lines
17 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = "";
|
|
$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) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
|
|
// Set class num for Customers
|
|
db_query("UPDATE people SET class_num = 1, meal_location = 1 WHERE school_num = $base_school_num AND people_type = 'Customer' AND (school_grade IS NULL OR school_grade = '' OR class_num < 10)");
|
|
|
|
|
|
//
|
|
// 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 = getLanguageText('ERRORMSG-INVALID-SCHEDULE-NUM');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
if (!isset($menu_num)) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-INVALID-MENU');
|
|
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 = $_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 = getLanguageText('TEXT-NO-ACCESS-TO-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 = getLanguageText('ERRORMSG-INVALID-MENU');
|
|
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-GENERATE-ITEM-LABELS') . " - $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
|
|
//
|
|
if ($_SESSION['UserInfo']['type'] != 'Supplier') {
|
|
?>
|
|
<form method='post' action='/'>
|
|
<table cellpadding='5' cellspacing='1'>
|
|
<tr>
|
|
<td align='left'>
|
|
<b><?php displayLanguageText('TEXT-MENU-DATE'); ?>: </b><br>
|
|
<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";
|
|
|
|
$query = "SELECT count(distinct order_num) FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_num = $record_num";
|
|
$num_orders = db_getVal($query);
|
|
$mtitle .= " ($num_orders)";
|
|
|
|
$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-labels'>
|
|
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
|
|
</form>
|
|
<br>
|
|
<br>
|
|
<?php
|
|
}
|
|
|
|
// Get number of orders for this menu date
|
|
$query = "SELECT count(distinct order_num) AS norders,count(*) AS nitems FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_num = $menu_num";
|
|
$r = db_getVal($query);
|
|
extract($r);
|
|
if ($norders > 0) {
|
|
$form_message = getLanguageText('TEXT-ORDERS-FOR-SELECTED-DATE').": $norders<br>" .
|
|
getLanguageText('TEXT-NUMBER-OF-ITEMS').": $nitems";
|
|
}
|
|
else {
|
|
$error_message = getLanguageText('TEXT-ORDERS-FOR-SELECTED-DATE').": $norders";
|
|
}
|
|
include "form.messages.php";
|
|
?>
|
|
<br>
|
|
<form method='post' action='/'>
|
|
<table width='750' class='content-table'>
|
|
<tr class='heading'>
|
|
<td colspan='2' align='center'><?php echo($menu_title) ?></td>
|
|
</tr>
|
|
<tr class='data-odd'>
|
|
<td align='left'><b><?php displayLanguageText('TEXT-SELECT-ALL-MENU-ITEMS'); ?></b> :: </td>
|
|
<td align='left' width='250'><input type='checkbox' name='select_all' id='select_all' value='Y' onClick='toggleItemCheckboxes();' checked='checked'></td>
|
|
</tr>
|
|
<?php
|
|
// Display the menu items
|
|
$query = "select * from hotlunch_menu_items " .
|
|
"where school_num = $school_num " .
|
|
"and menu_num = $menu_num " .
|
|
"and item_type != 'Heading' " .
|
|
"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'];
|
|
$label_title = $menu_item['label_title'];
|
|
if (strlen($label_title) == 0) $label_title = $menu_item['item_title'];
|
|
|
|
// Allow suppliers to only view items with their products
|
|
if ($_SESSION['UserInfo']['type'] == 'Supplier') {
|
|
$supplier_num = intval($_SESSION['UserInfo']['supplier_num']);
|
|
$query = "SELECT count(supplier_product_num) FROM hotlunch_menu_products,supplier_products " .
|
|
"WHERE hotlunch_menu_products.school_num = $school_num " .
|
|
"AND menu_item_num = $item_num " .
|
|
"AND supplier_product_num = supplier_products.record_num " .
|
|
"AND supplier_products.school_num = $supplier_school_num " .
|
|
"AND supplier_products.supplier_num = $supplier_num";
|
|
$numProducts = db_getVal($query);
|
|
if ($numProducts == 0) continue;
|
|
echo("<!-- $query -->\n\n");
|
|
}
|
|
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
|
|
$items[] = "item_$item_num";
|
|
$checked = " checked='checked'";
|
|
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td align='left'><?php echo($label_title) ?> :: </td>
|
|
<td align='left' valign='top'><input type='checkbox' name='item_<?php echo($item_num) ?>' id='item_<?php echo($item_num) ?>' value='Y' checked='checked'></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
<tr class='heading'>
|
|
<td colspan='2' align='center'><?php displayLanguageText('TEXT-LABEL-OPTIONS'); ?></td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td align='left' valign='top'><b><?php displayLanguageText('TEXT-STUDENT-NAME-ON-LABELS'); ?> :: </b></td>
|
|
<td align='left' valign='top'>
|
|
<?php BuildFileRadio("student_label_info.txt","print_student_info","Y","<br>") ?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td align='left' valign='top'><b><?php displayLanguageText('TEXT-PRINT-LABEL-DESCRIPTION'); ?> :: </b></td>
|
|
<td align='left' valign='top'><input type='checkbox' name='display_options[]' value='Label' checked='checked'></td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td align='left'><b><?php displayLanguageText('TEXT-CLASS-INFO-ON-LABELS'); ?> :: </b></td>
|
|
<td align='left'><input type='checkbox' name='display_options[]' value='Class'></td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td align='left'><b><?php displayLanguageText('TEXT-SCHOOL-NAME-ON-LABELS'); ?> :: </b></td>
|
|
<td align='left'><input type='checkbox' name='print_school_name' id='print_school_name' value='Y'></td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td align='left' valign='top'><b><?php displayLanguageText('TEXT-PRINT-DATE'); ?> :: </b></td>
|
|
<td align='left'>
|
|
<?php BuildFileRadio("yn.txt","print_date","Y","<br>") ?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td align='left'><b><?php displayLanguageText('TEXT-ITEM-OPTIONS-ON-LABELS'); ?> :: </b></td>
|
|
<td align='left'><input type='checkbox' name='display_options[]' value='Options' checked='checked'></td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
|
|
$num_classes = db_getVal("select count(*) from classes where school_num = $base_school_num");
|
|
$selectSize = 8;
|
|
if ($num_classes < 10) $selectSize = $num_classes + 2;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td align='left' valign='top'><b><?php echo($GlobalText['SelectedClasses']); ?> :: </b></td>
|
|
<td>
|
|
<select name='selected_classes[]' size='<?php echo($selectSize) ?>' multiple>
|
|
<option value='Concession' ><?php displayLanguageText('TEXT-CONCESSION-LABELS'); ?></option>
|
|
<?php
|
|
// Get set of classes
|
|
$classes = db_query("select record_num from classes where school_num = $base_school_num order by sequence");
|
|
$schedule_access = 0;
|
|
while ($row = db_fetch_array($classes)) {
|
|
$class_num = $row['record_num'];
|
|
$class_info = getClassInfo($class_num);
|
|
echo(" <option value='$class_num' selected='selected'>$class_info</option>\n");
|
|
}
|
|
?>
|
|
<option value='0' selected='selected'><?php echo($GlobalText['Staff']); ?></option>
|
|
<?php
|
|
// Check for customers
|
|
$numCustomers = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $base_school_num AND schedule_num = $schedule_num AND ordered_by_type = 'Customer'");
|
|
if ($numCustomers > 0) {
|
|
?>
|
|
<option value='1' selected='selected'><?php displayLanguageText('TEXT-CUSTOMERS'); ?></option>
|
|
<?php
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td colspan='2' align='left'>
|
|
<blockquote>
|
|
<b><?php displayLanguageText('TEXT-SORT-LABELS-BY'); ?> :: </b><br>
|
|
<select name='sort_by'>
|
|
<option value='item_class'><?php displayLanguageText('TEXT-SORT-ITEM-CLASS-STUDENT'); ?></option>
|
|
<option value='item_options_class'><?php displayLanguageText('TEXT-SORT-ITEM-OPTIONS-CLASS-STUDENT'); ?></option>
|
|
<option value='item_class_breaks'><?php displayLanguageText('TEXT-SORT-ITEM-CLASS-STUDENT-BREAKS'); ?></option>
|
|
<option value='item_options_class_breaks'><?php displayLanguageText('TEXT-SORT-ITEM-OPTIONS-CLASS-STUDENT-BREAKS'); ?></option>
|
|
<option value='class_item'><?php displayLanguageText('TEXT-SORT-CLASS-ITEM-STUDENT'); ?></option>
|
|
<option value='class_item_breaks'><?php displayLanguageText('TEXT-SORT-CLASS-ITEM-STUDENT-BREAKS'); ?></option>
|
|
<option value='class_student'><?php displayLanguageText('TEXT-SORT-CLASS-STUDENT-ITEM'); ?></option>
|
|
<option value='class_student_breaks'><?php displayLanguageText('TEXT-SORT-CLASS-STUDENT-ITEM-BREAKS'); ?></option>
|
|
<option value='item_student'><?php displayLanguageText('TEXT-SORT-ITEM-STUDENT'); ?></option>
|
|
<option value='item_options_student'><?php displayLanguageText('TEXT-SORT-ITEM-OPTIONS-STUDENT'); ?></option>
|
|
<option value='student_item'><?php displayLanguageText('TEXT-SORT-STUDENT-ITEM'); ?></option>
|
|
<option value='division_item'><?php displayLanguageText('TEXT-SORT-DIVISION-ITEM-STUDENT'); ?></option>
|
|
<option value='division_student'><?php displayLanguageText('TEXT-SORT-DIVISION-STUDENT-ITEM'); ?></option>
|
|
</select>
|
|
</blockquote>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td colspan='2' align='left'>
|
|
<blockquote>
|
|
<b><?php displayLanguageText('TEXT-LABEL-SIZE'); ?> :: </b><br>
|
|
<select name='labelFormat'>
|
|
<option value='mailinglabels'><?php displayLanguageText('TEXT-LABELS-STANDARD-MAILING'); ?> - 2 5/8" x 1"</option>
|
|
<option value='mailinglabels-o1'><?php displayLanguageText('TEXT-LABELS-STANDARD-MAILING'); ?> - 2 5/8" x 1" (<?php displayLanguageText('TEXT-OFFSET'); ?>)</option>
|
|
<option value='mailinglabels-large'><?php displayLanguageText('TEXT-LABELS-STANDARD-SHIPPING'); ?> - 4" x 2"</option>
|
|
<option value='shippinglabels'><?php displayLanguageText('TEXT-LABELS-LARGE-SHIPPING'); ?> - 3 1/2" x 5"</option>
|
|
<option value='shippinglabels6'><?php displayLanguageText('TEXT-LABELS-LARGE-SHIPPING6'); ?> - 3 1/2" x 4"</option>
|
|
<option value='returnaddresslabels'><?php displayLanguageText('TEXT-LABELS-RETURN-ADDRESS'); ?> - 2 5/8" x 1"</option>
|
|
</select>
|
|
</blockquote>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td colspan='2' align='left'>
|
|
<blockquote>
|
|
<b><?php displayLanguageText('TEXT-FONT-SIZE'); ?> :: </b><br>
|
|
<select name='font_size'>
|
|
<option value='default'><?php displayLanguageText('TEXT-DEFAULT') ?></option>
|
|
<?php BuildFileList("label-font.txt") ?>
|
|
</select>
|
|
</blockquote>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<input type='hidden' name='action' value='item-labels-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-LABELS'); ?>">
|
|
</form>
|
|
<br>
|
|
<?php
|
|
|
|
?>
|
|
|
|
<?php
|
|
if ($_SESSION['UserInfo']['type'] != 'Supplier') include "hotlunch_orders.print_buttons.php";
|
|
?>
|
|
<script language='javascript'>
|
|
function toggleItemCheckboxes() {
|
|
var cb = document.getElementById('select_all').checked;
|
|
|
|
if (cb == false) {
|
|
<?php
|
|
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
|
|
for ($i = 0; $i < count($items); $i++) {
|
|
$item = $items[$i];
|
|
echo(" var cb$i = document.getElementById('$item');\n");
|
|
echo(" cb$i.checked = true;\n");
|
|
}
|
|
?>
|
|
}
|
|
}
|
|
|
|
</script>
|
|
<?php
|
|
endTemplate();
|
|
?>
|