272 lines
9.3 KiB
PHP
272 lines
9.3 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team');
|
|
if (checkPermission($AllowedUserTypes) == 1) {
|
|
include "hotlunch_reports.menu.php";
|
|
}
|
|
|
|
|
|
|
|
// Get schedule information
|
|
$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 = "Invalid lunch schedule id";
|
|
header("Location: /?error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$schedule_record = db_fetch_array($results);
|
|
$schedule_name = $schedule_record['schedule_name'];
|
|
|
|
|
|
// 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 = "You are not allowed access to the requested hot lunch schedule";
|
|
header("Location: /?error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
}
|
|
|
|
// Get school names for clarity
|
|
$SchoolNames[$school_num] = $school_record['school_name'];
|
|
if ($supplier_school_num != $school_num) {
|
|
$SchoolNames[$supplier_school_num] = db_getVal("SELECT school_name FROM schools WHERE record_num = $supplier_school_num");
|
|
}
|
|
|
|
// Get set of products
|
|
$allProducts = array();
|
|
|
|
$supplier_school_num = $school_record['supplier_school_num'];
|
|
if ($supplier_school_num == 0) $supplier_school_num = $school_num;
|
|
|
|
$query = "select * from suppliers " .
|
|
"where school_num = $supplier_school_num " .
|
|
"and status = 'Active' " .
|
|
"order by supplier_name, record_num";
|
|
$suppliers = db_query($query);
|
|
if (db_num_rows($suppliers) > 0) {
|
|
|
|
// Process each supplier
|
|
while ($supplier = db_fetch_array($suppliers)) {
|
|
$supplier_num = $supplier['record_num'];
|
|
$supplier_name = $supplier['supplier_name'];
|
|
$sname = $SchoolNames[$supplier['school_num']];
|
|
$supplier_name .= " ($sname)";
|
|
|
|
$query = "select * from supplier_products " .
|
|
"where supplier_num = $supplier_num " .
|
|
"and school_num = $supplier_school_num " .
|
|
"and product_type = 'Product' " .
|
|
"AND status = 'Active' " .
|
|
"order by sequence,product_name";
|
|
$products = db_query($query);
|
|
|
|
// Process each product
|
|
if (db_num_rows($products) > 0) {
|
|
while ($row = db_fetch_array($products)) {
|
|
$name = $row['product_name'] . " (" . $row['package_qty'] . " for $currencySymbol" . number_format($row['package_cost'],2) . ")";
|
|
$pnum = $row['record_num'];
|
|
|
|
$allProducts[] = array("supplier_num" => $supplier_num,
|
|
"supplier_name" => $supplier_name,
|
|
"product_num" => $pnum,
|
|
"product_name" => $name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Exit if there are no products
|
|
if (count($allProducts) == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-NO-PRODUCTS-DEFINED');
|
|
header("Location: /?error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
<br>
|
|
<form method='post' action='/' name='orderform'>
|
|
<?php
|
|
|
|
$form_width = '95%';
|
|
$message_width = $form_width;
|
|
include "form.messages.php";
|
|
?>
|
|
<table width='<?php echo($form_width) ?>' class='content-table'>
|
|
<tr>
|
|
<td align='center' class='heading'>Menu Product Update - <?php echo($schedule_name) ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center'>
|
|
<br>
|
|
<table width='850' cellpadding='1' cellspacing='1' border='0'>
|
|
<?php
|
|
// Get menu dates for this schedule
|
|
$query = "select * from hotlunch_menu_dates " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"order by sequence,menu_date";
|
|
$menu_dates = db_query($query);
|
|
|
|
while ($menu_date = db_fetch_array($menu_dates)) {
|
|
$menu_num = $menu_date['record_num'];
|
|
$menu_title = $menu_date['menu_title'];
|
|
$menu_link = $menu_date['menu_link'];
|
|
|
|
if ($menu_link != 'No') $menu_title .= " - Linked Menu: $menu_link";
|
|
|
|
?>
|
|
<tr>
|
|
<td align='left' colspan='7' class='success'>
|
|
<table width='100%' cellspacing='0' cellpadding='0' border='0'>
|
|
<tr>
|
|
<td align='left' class='success'><b><?php echo($menu_title) ?></td>
|
|
<td align='right' class='success'><?php echo(date("l F jS, Y",strtotime($menu_date['menu_date']))) ?></b></td>
|
|
</tr>
|
|
</td>
|
|
</table>
|
|
</tr>
|
|
<tr>
|
|
<td align='left' width='380' class='oitem'><b>ITEM</b></td>
|
|
<td colspan='2' width='80' align='center' class='oitem'><b>PRODUCT</b></td>
|
|
<td colspan='2' width='80' align='center' class='oitem'><b>PRODUCT</b></td>
|
|
<td colspan='2' width='80' align='center' class='oitem'><b>PRODUCT</b></td>
|
|
</tr>
|
|
<?php
|
|
// Get menu items for this menu date
|
|
$query = "select * from hotlunch_menu_items " .
|
|
"where school_num = $school_num " .
|
|
"and menu_num = $menu_num " .
|
|
"order by sequence";
|
|
$menu_items = db_query($query);
|
|
|
|
while ($menu_item = db_fetch_array($menu_items)) {
|
|
extract($menu_item);
|
|
|
|
$menu_item_num = $record_num;
|
|
|
|
if ($item_type == 'Heading') {
|
|
?>
|
|
<tr>
|
|
<td align='left' colspan='7' class='menudate-subheader'><b> -- <?php echo($item_title) ?> -- </b></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
else {
|
|
// Start menu product row
|
|
?>
|
|
<tr>
|
|
<td align='left' class='oitem'><?php echo($item_title) ?> <?php echo($menu_item_num) ?>::</td>
|
|
<?php if ($menu_link == 'Yes') { ?>
|
|
<td class='oitem' align='center'> </td>
|
|
<td class='oitem' align='center'> </td>
|
|
<td class='oitem' align='center'> </td>
|
|
<?php
|
|
}
|
|
|
|
if ($menu_link == 'No') {
|
|
$results = db_query("select * from hotlunch_menu_products where school_num = $school_num and menu_item_num = $menu_item_num ORDER BY product_sequence");
|
|
$Products = array();
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$Products[] = $row;
|
|
}
|
|
|
|
$menu_item_number = "";
|
|
if ($_SESSION['UserInfo']['type'] == 'SuperUser') $menu_item_number = "($menu_item_num)";
|
|
|
|
// Process three menu products
|
|
for ($pn = 1; $pn <= 3; $pn++) {
|
|
?>
|
|
<td class='oitem' align='center'>
|
|
<?php
|
|
// Get product quantity
|
|
$curr_product_num = 0;
|
|
$curr_product_qty = 0;
|
|
|
|
if (count($Products) >= $pn) {
|
|
$curr_product_num = $Products[$pn - 1]['supplier_product_num'];
|
|
$curr_product_qty = $Products[$pn - 1]['supplier_product_qty'];
|
|
}
|
|
|
|
$qty_field = "qty$pn"."_$menu_item_num";
|
|
$product_field = "product$pn"."_$menu_item_num";
|
|
|
|
?>
|
|
<input type='text' name='<?php echo($qty_field) ?>' size='2' value='<?php echo($curr_product_qty) ?>' style='text-align: right; width: 20px;'>
|
|
</td>
|
|
<td class='oitem' align='center'>
|
|
<select name='<?php echo($product_field) ?>' width='120' style='width: 120px'>
|
|
<option value=''></option>
|
|
<?php
|
|
$prevSupplier = 0;
|
|
for ($i = 0; $i < count($allProducts); $i++) {
|
|
$product = $allProducts[$i];
|
|
$supplier_name = $product['supplier_name'];
|
|
$product_num = $product['product_num'];
|
|
$product_name = $product['product_name'];
|
|
|
|
if ($product['supplier_num'] != $prevSupplier) {
|
|
if ($prevSupplier > 0) echo(" </optgroup>\n");
|
|
echo(" <optgroup label='$supplier_name'>\n");
|
|
$prevSupplier = $product['supplier_num'];
|
|
}
|
|
|
|
$selected = "";
|
|
if ($curr_product_num > 0 && $curr_product_num == $product_num && $curr_product_qty > 0) $selected = " selected='selected'";
|
|
echo(" <option value='$product_num'$selected>$product_name</option>\n");
|
|
}
|
|
echo(" </optgroup>\n");
|
|
?>
|
|
</select>
|
|
</td>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
<tr>
|
|
<td align='left' colspan='7'> </td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center'>
|
|
<br>
|
|
<input type='submit' class='btn btn--primary' value="<?php displayLanguageText('TEXT-UPDATE'); ?>">
|
|
<input type='hidden' name='action' value='menu-product-update'>
|
|
<input type='hidden' name='naction' value='update'>
|
|
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
|
|
<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
<?php include "hotlunch_orders.print_buttons.php"; ?>
|
|
|