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

603 lines
26 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) {
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
header("Location: /?form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
// Get schedule_num
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 (!isset($schedule_num)) {
$error_message = getLanguageText('ERRORMSG-INVALID-ACCESS');
header("Location: /?form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
// Check if this is a valid schedule
$swhere = "";
if ($_SESSION['UserInfo']['type'] == 'Supplier') $swhere = " and supplier_num = " . $_SESSION['UserInfo']['supplier_num'];
$query = "select * from hotlunch_schedules " .
"where school_num = $school_num " .
"and record_num = $schedule_num " .
$swhere;
$results = db_query($query);
if (db_num_rows($results) == 0) {
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE');
header("Location: /?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 = 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) {
$error_message = getLanguageText('ERRORMSG-NO-SCHEDULE-ACCESS');
header("Location: /?form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
}
// Check that this schedule date has lunch dates specified
$query = "select count(*) num from hotlunch_menu_dates " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num";
$dates = db_getVal($query);
if ($dates == 0) {
$error_message = getLanguageText('ERRORMSG-NO-MENU-DATES');
}
// Check that this schedule has lunch items specified
$query = "SELECT count(hlmi.record_num) AS num " .
"FROM hotlunch_menu_items AS hlmi, hotlunch_menu_dates AS hlmd " .
"WHERE hlmi.school_num = $school_num " .
"AND hlmd.school_num = $school_num " .
"AND hlmd.record_num = hlmi.menu_num " .
"AND hlmd.schedule_num = $schedule_num";
$items = db_getVal($query);
// if ($items > 0) {
// $results = db_query("SELECT * FROM hotlunch_order_header " .
// "WHERE school_num = $school_num " .
// "AND schedule_num = $schedule_num " .
// "AND ordered_by_type != 'Concession' " .
// "AND ordered_by_num NOT IN (SELECT record_num FROM people WHERE school_num = $base_school_num)");
// if (db_num_rows($results)) {
// while ($row = db_fetch_assoc($results)) {
// $order_num = $row['record_num'];
// logOrderChange($order_num, "ORDER DELETED AS OWNER IS NOT IN CURRENT SCHOOL", "hotlunch_reports.php");
//
// db_query("DELETE FROM hotlunch_order_items " .
// "WHERE school_num = $school_num " .
// "AND order_num = $order_num");
// db_query("UPDATE hotlunch_order_items SET active = 'N' " .
// "WHERE school_num = $school_num " .
// "AND order_num = $order_num");
// db_query("DELETE FROM hotlunch_order_header " .
// "WHERE record_num = $order_num");
// db_query("UPDATE hotlunch_order_header SET status = 'Deleted' " .
// "WHERE record_num = $order_num");
// }
// }
// }
// Check for invalid payment amounts
$query = "UPDATE hotlunch_order_header SET amount_paid = order_total WHERE school_num = $school_num AND schedule_num = $schedule_num AND amount_paid > order_total";
db_query($query);
$query = "UPDATE hotlunch_order_header SET amount_paid = order_total WHERE school_num = $school_num AND schedule_num = $schedule_num AND status = 'Paid'";
db_query($query);
// Calculate how much has been ordered
$query = "select sum(discount_amount) discount, sum(order_total) ordered " .
"from hotlunch_order_header " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"and ordered_by_type != 'Concession' " .
"and status NOT IN ('Inactive','Deleted')";
$results = db_query($query);
$row = db_fetch_array($results);
$discount = $row['discount'];
$ordered = $row['ordered'];
// Calculate how much has been collected
$query = "select sum(order_total) collected " .
"from hotlunch_order_header " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"and status = 'Paid' " .
"and ordered_by_type != 'Concession'";
$collected = db_getVal($query);
// Calculate how much has is outstanding
$query = "select sum(order_total) unpaid " .
"from hotlunch_order_header " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"and status = 'Unpaid' " .
"and ordered_by_type != 'Concession'";
$outstanding = db_getVal($query);
$report_table_width = 850;
//
// Validate the orders in the system for this schedule
//
$query = "SELECT * FROM hotlunch_order_header " .
"WHERE school_num = $school_num " .
"AND schedule_num = $schedule_num " .
"AND ordered_by_type != 'Concession' " .
"AND status NOT IN ('Inactive','Deleted') " .
"AND NOT EXISTS (" .
"SELECT * FROM people " .
"WHERE hotlunch_order_header.ordered_by_num = people.record_num)";
$results = db_query($query);
if (db_num_rows($results) > 0) {
$error_message = "Error: There are invalid orders for this schedule - ";
$count = 0;
$otipSpans = "";
while ($row = db_fetch_array($results)) {
if ($count > 0) $error_message .= ", ";
$onum = $row['record_num'];
$span_id = "span_$onum";
$payment_method = $row['payment_method'];
if (strlen($payment_method)) {
$lcode = "CODE-" . strtoupper(str_replace(' ','-',$payment_method));
$lvalue = getLanguageText($lcode);
if (strlen($lvalue)) $payment_method = $lvalue;
}
$otipSpans .= "<span id='$span_id'>" . $otipTABLE .
sprintf($otipROW2,getLanguageText('TEXT-ORDER-NUMBER').": ",$row['record_num']) .
sprintf($otipROW2,getLanguageText('TEXT-ORDER-STATUS').": ",$row['status']) .
sprintf($otipROW2,getLanguageText('TEXT-PAID-DATE').": ",$row['paid_date']) .
sprintf($otipROW2,getLanguageText('TEXT-PAYMENT-METHOD').": ",$payment_method) .
sprintf($otipROW2,getLanguageText('TEXT-ORDERED-BY').": ",$row['ordered_by_num']) .
sprintf($otipROW2,getLanguageText('TEXT-TYPE').": ",$row['ordered_by_type']) .
"</table></span>\n";
$error_message .= "<a href='?action=orders&naction=delete&schedule_num=$schedule_num&order_num=$onum' onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\">$onum</a>";
$count++;
}
}
$templatePageTitle = getLanguageText('TEXT-SCHEDULE-SUMMARY-REPORTS') . " - " . $hotlunch_schedule['schedule_name'];
//
// Determine which classes have access to this schedule
//
$selectedClasses = db_query("SELECT * FROM hotlunch_schedules_classes WHERE school_num = $school_num AND schedule_num = $schedule_num");
$numClasses = db_num_rows($selectedClasses);
if ($numClasses == 0) $scheduleAccess = $GlobalText['AllClasses'];
else $scheduleAccess = $GlobalText['SelectedClasses'] . " ($numClasses)";
include "hotlunch_reports.menu.php";
include "form.messages.php";
$today = date("Y-m-d",time());
$now = date("Y-m-d H:i:s",time());
?>
<br>
<table width='<?php echo($report_table_width) ?>' cellpadding='3' cellspacing='1' border='0' class='content-table'>
<tr>
<td align='left' colspan='2' class='heading' style='padding: 10px;'>
<h2><?php echo($hotlunch_schedule['schedule_name']) ?>:</h2>
</td>
</tr>
<tr>
<td align='left' width='25%' class='data-odd'><?php displayLanguageText('TEXT-ORDERING-START-DATE'); ?>:</td>
<?php if ($hotlunch_schedule['start_order_datetime'] > $now) { ?>
<td align='left' class='notice'><b><?php echo($hotlunch_schedule['start_order_datetime']) ?></b></td>
<?php } else { ?>
<td align='left' class='data-odd'><b><?php echo($hotlunch_schedule['start_order_datetime']) ?></b></td>
<?php } ?>
</tr>
<tr>
<td align='left' class='data-even'><?php displayLanguageText('TEXT-ORDERING-END-DATE'); ?>:</td>
<?php if ($hotlunch_schedule['end_order_datetime'] < $now) { ?>
<td align='left' class='notice'><b><?php echo(substr($hotlunch_schedule['end_order_datetime'],0,16)) ?></b></td>
<?php } else { ?>
<td align='left' class='data-even'><b><?php echo(substr($hotlunch_schedule['end_order_datetime'],0,16)) ?></b></td>
<?php } ?>
</tr>
<?php if ($siteType == 'hotlunch') { ?>
<tr>
<td align='left' class='data-odd'><?php displayLanguageText('TEXT-SCHEDULE-START-DATE'); ?>:</td>
<td align='left' class='data-odd'><b><?php echo($hotlunch_schedule['schedule_start_date']) ?></b></td>
</tr>
<tr>
<td align='left' class='data-even'><?php displayLanguageText('TEXT-SCHEDULE-END-DATE'); ?>:</td>
<td align='left' class='data-even'><b><?php echo($hotlunch_schedule['schedule_end_date']) ?></b></td>
</tr>
<?php } ?>
<tr>
<td align='left' class='data-odd'><?php displayLanguageText('TEXT-SCHEDULE-TYPE'); ?>:</td>
<td align='left' class='data-odd'><b><?php echo($hotlunch_schedule['schedule_type']) ?></b></td>
</tr>
<tr>
<td align='left' class='data-even'><?php displayLanguageText('TEXT-SCHEDULE-STATUS'); ?>:</td>
<?php
$scheduleStatus = $hotlunch_schedule['status'];
$scheduleStatus = "<span id='status-$schedule_num' class='status-span' rnum='$schedule_num' status='$scheduleStatus'>$scheduleStatus</span>";
?>
<?php if ($hotlunch_schedule['status'] != 'Active') { ?>
<td align='left' class='notice'><b><?php echo($scheduleStatus) ?></b></td>
<?php } else { ?>
<td align='left' class='data-even'><b><?php echo($scheduleStatus) ?></b></td>
<?php } ?>
</tr>
<tr>
<td align='left' class='data-odd'><?php displayLanguageText('TEXT-NUMBER-OF-MENUS'); ?>:</td>
<td align='left' class='data-odd'><b><?php echo($dates) ?></b></td>
</tr>
<tr>
<td align='left' class='data-even'><?php displayLanguageText('TEXT-TOTAL-ITEMS'); ?>:</td>
<td align='left' class='data-even'><b><?php echo($items) ?></b></td>
</tr>
<tr>
<td align='left' class='data-odd'><?php displayLanguageText('TEXT-SCHEDULE-ACCESS'); ?>:</td>
<td align='left' class='data-odd'><b><?php echo($scheduleAccess) ?></b></td>
</tr>
</table>
<br>
<?php
$statusGroups = array('Active','Inactive');
for ($i = 0; $i < count($statusGroups); $i++) {
switch ($statusGroups[$i]) {
case 'Active':
$statusWhere = "and hloh.status NOT IN ('Inactive','Deleted','Concession') ";
$groupHeader = getLanguageText('TEXT-ORDER-TOTALS-BY-STATUS');
$colHeader = getLanguageText('TEXT-STATUS');
break;
case 'Inactive':
$statusWhere = "and hloh.status = 'Inactive' ";
$groupHeader = getLanguageText('TEXT-ORDERS-INACTIVE');
$colHeader = getLanguageText('TEXT-STATUS');
break;
}
//
// Get the totals for this schedule without Inactive or Concession orders
//
$query = "select count(*) as num,sum(order_total) as total,sum(amount_paid) as collected,sum(discount_amount) discount " .
"FROM hotlunch_order_header AS hloh, people AS p " .
"WHERE hloh.school_num = $school_num " .
"AND p.school_num = $base_school_num " .
"AND p.record_num = ordered_by_num " .
"and schedule_num = $schedule_num " .
$statusWhere;
$results = db_query($query);
$totals = db_fetch_array($results);
$concession = 0;
// Get the subtotals by status
$query = "select hloh.status,count(*) as num,sum(order_total) as total,sum(amount_paid) as collected,sum(discount_amount) as discount " .
"FROM hotlunch_order_header AS hloh, people AS p " .
"WHERE hloh.school_num = $school_num " .
"AND p.school_num = $base_school_num " .
"AND p.record_num = ordered_by_num " .
"and schedule_num = $schedule_num " .
$statusWhere .
"group by 1 " .
"order by 1";
echo("<!-- QUERY: $query -->\n\n");
$results = db_query($query);
if (db_num_rows($results) > 0) {
?>
<table width='<?php echo($report_table_width) ?>' cellpadding='3' cellspacing='1' border='0' class='content-table'>
<tr>
<td align='left' colspan='6' class='heading'><?php echo($groupHeader) ?> - <?php echo($hotlunch_schedule['schedule_name']) ?></td>
</tr>
<tr>
<td align='left' width='25%' class='heading'><b><?php echo($colHeader) ?></b></td>
<td width='15%' class='heading' align='center'><b><?php displayLanguageText('TEXT-QUANTITY'); ?></b></td>
<td width='15%' class='heading' align='center'><b>%</b></td>
<td width='15%' class='heading' align='right'><b><?php displayLanguageText('TEXT-TOTAL'); ?></b></td>
<td width='15%' class='heading' align='right'><b><?php displayLanguageText('TEXT-DISCOUNT'); ?></b></td>
<td width='15%' class='heading' align='right'><b><?php displayLanguageText('TEXT-NET-TOTAL'); ?></b></td>
</tr>
<?php
$total_num = $totals['num'];
$count = 0;
while ($row = db_fetch_array($results)) {
$status = $row['status'];
$num = $row['num'];
$net_total = $row['total'];
$discount = $row['discount'];
// Discount the Concession order
if ($status == 'Concession') {
$discount = $net_total;
$concession = $net_total;
$net_total = 0;
}
$total = $net_total + $discount;
$collected = $row['collected'];
$percentage = number_format(round($num / $total_num * 1000) / 10,1) . "%";
$bgclass = 'data-odd';
if ($count % 2) $bgclass = 'data-even';
$count++;
?>
<tr>
<td align='left' class='<?php echo($bgclass) ?>'><b><?php echo($status) ?></b></td>
<td class='<?php echo($bgclass) ?>' align='center'><?php echo($num) ?></td>
<td class='<?php echo($bgclass) ?>' align='center'><?php echo($percentage) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($total,2)) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($discount,2)) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($net_total,2)) ?></td>
</tr>
<?php
}
$status = getLanguageText('TEXT-TOTALS');
$num = $totals['num'];
$net_total = $totals['total'] - $concession;
$discount = $totals['discount'] + $concession;
$total = $net_total + $discount;
$collected = $totals['collected'];
$bgclass = 'heading';
?>
<tr>
<td align='left' class='<?php echo($bgclass) ?>'><b><?php echo($status) ?></b></td>
<td class='<?php echo($bgclass) ?>' align='center'><?php echo($num) ?></td>
<td class='<?php echo($bgclass) ?>' align='center'>&nbsp;</td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($total,2)) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($discount,2)) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($net_total,2)) ?></td>
</tr>
</table>
<br>
<?php
}
}
//
// Get the totals for this schedule with Concession order
//
$query = "select count(*) as num,sum(order_total) as total,sum(amount_paid) as collected,sum(discount_amount) discount " .
"from hotlunch_order_header " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"and status NOT IN ('Inactive','Deleted','Concession')";
$results = db_query($query);
$totals = db_fetch_array($results);
$total_num = $totals['num'];
// Get the subtotals by source
$query = "select source,count(*) as num,sum(order_total) as total,sum(amount_paid) as collected,sum(discount_amount) as discount " .
"from hotlunch_order_header " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"and status not in ('Inactive','Deleted','Concession') " .
"group by source " .
"order by source";
$results = db_query($query);
if (db_num_rows($results)) {
?>
<table width='<?php echo($report_table_width) ?>' cellpadding='3' cellspacing='1' border='0' class='content-table'>
<tr>
<td align='left' colspan='7' class='heading'><?php displayLanguageText('TEXT-ORDER-TOTALS-BY-SOURCE'); ?>: <?php echo($hotlunch_schedule['schedule_name']) ?></td>
</tr>
<tr>
<td align='left' width='25%' class='heading'><b><?php displayLanguageText('TEXT-SOURCE'); ?></b></td>
<td width='15%' class='heading' align='center'><b><?php displayLanguageText('TEXT-QUANTITY'); ?></b></td>
<td width='15%' class='heading' align='center'><b>%</b></td>
<td width='15%' class='heading' align='right'><b><?php displayLanguageText('TEXT-TOTAL'); ?></b></td>
<td width='15%' class='heading' align='right'><b><?php displayLanguageText('TEXT-DISCOUNT'); ?></b></td>
<td width='15%' class='heading' align='right'><b><?php displayLanguageText('TEXT-NET-TOTAL'); ?></b></td>
</tr>
<?php
$count = 0;
while ($row = db_fetch_array($results)) {
$source = $row['source'];
$num = $row['num'];
$net_total = $row['total'];
$discount = $row['discount'];
// Discount the Concession amount
if ($source == 'Concession') {
$net_total -= $concession;
$discount += $concession;
}
$total = $net_total + $discount;
$collected = $row['collected'];
$percentage = number_format(round($num / $total_num * 1000) / 10,1) . "%";
$bgclass = 'data-odd';
if ($count % 2) $bgclass = 'data-even';
$count++;
?>
<tr>
<td align='left' class='<?php echo($bgclass) ?>'><b><?php echo($source) ?></b></td>
<td class='<?php echo($bgclass) ?>' align='center'><?php echo($num) ?></td>
<td class='<?php echo($bgclass) ?>' align='center'><?php echo($percentage) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($total,2)) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($discount,2)) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($net_total,2)) ?></td>
<!--
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($collected,2)) ?></td>
-->
</tr>
<?php
}
$source = "TOTALS";
$num = $totals['num'];
$net_total = $totals['total'] - $concession;
$discount = $totals['discount'] + $concession;
$total = $net_total + $discount;
$collected = $totals['collected'];
$bgclass = 'heading';
?>
<tr>
<td align='left' class='<?php echo($bgclass) ?>'><b><?php echo($source) ?></b></td>
<td class='<?php echo($bgclass) ?>' align='center'><?php echo($num) ?></td>
<td class='<?php echo($bgclass) ?>' align='center'>&nbsp;</td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($total,2)) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($discount,2)) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($net_total,2)) ?></td>
</tr>
</table>
<br>
<?php
$outstanding = $total - $collected;
$bgclass = 'data-odd';
?>
<table width='<?php echo($report_table_width) ?>' cellpadding='3' cellspacing='1' border='0' class='content-table'>
<tr>
<td align='left' colspan='7' class='heading'><?php displayLanguageText('TEXT-BALANCE'); ?>: <?php echo($hotlunch_schedule['schedule_name']) ?></td>
</tr>
<tr>
<td width='25%' class='heading' align='center'><b><?php displayLanguageText('TEXT-ORDERS'); ?></b></td>
<td width='25%' class='heading' align='right'><b><?php displayLanguageText('TEXT-TOTAL'); ?></b></td>
<td width='25%' class='heading' align='right'><b><?php displayLanguageText('TEXT-PAYMENTS-RECEIVED'); ?></b></td>
<td width='25%' class='heading' align='right'><b><?php displayLanguageText('TEXT-OUTSTANDING'); ?></b></td>
</tr>
<tr>
<td class='<?php echo($bgclass) ?>' align='center'><?php echo($num) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($total,2)) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($collected,2)) ?></td>
<td class='<?php echo($bgclass) ?>' align='right'><?php echo($currencySymbol . number_format($outstanding,2)) ?></td>
</tr>
</table>
<br>
<?php
}
//
// Set up for for viewing details of a single day
//
$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);
if (db_num_rows($results) > 0) {
?>
<form method='post' action='/'>
<table id='order-details' width='<?php echo($report_table_width) ?>' cellpadding='3' cellspacing='1' border='0' class='content-table'>
<tr>
<td align='left' colspan='2' class='heading' style='padding: 10px;'><h2><?php displayLanguageText('TEXT-ORDER-DETAILS-FOR-SELECTED-MENU'); ?></h2></td>
</tr>
<tr>
<td align='center' colspan='2'>
<table width='90%' cellpadding='0' cellspacing='1'>
<tr>
<td align='right'><?php displayLanguageText('TEXT-SELECT-ORDER-MENU'); ?>: </td>
<td align='left'>
<select name='menu_num' id='menu_num' class='select-width500'>
<?php
$selected_date = 'N';
$today = date("Y-m-d",time());
$iTitle = getLanguageText('TEXT-ITEMS-ORDERED');
while ($row = db_fetch_array($results)) {
extract($row);
$selected = "";
if ($hotlunch_schedule['display_menu_date'] == 'Y') {
$menu_title .= " - " . date($school_record['date_format'],strtotime($menu_date));
if ($menu_date >= $today && $selected_date == 'N') {
$selected_date = 'Y';
$selected = " selected='selected'";
}
}
$numItems = db_getVal("SELECT count(*) FROM hotlunch_order_items WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $record_num");
echo(" <option value='$record_num'$selected>$menu_title ($iTitle: $numItems)</option>\n");
}
?>
</select>
</td>
</tr>
<?php
$numSuppliers = db_getVal("SELECT count(*) FROM suppliers WHERE school_num = $supplier_school_num AND status = 'Active'");
if ($numSuppliers > 0) {
?>
<tr>
<td align='right'><?php displayLanguageText('TEXT-SELECT-SUPPLIER'); ?>: </td>
<td align='left'>
<select name='supplier_num'>
<option value=''><?php displayLanguageText('TEXT-ALL-SUPPLIERS'); ?></option>
<?php
$query = "SELECT supplier_name,record_num FROM suppliers WHERE school_num = $supplier_school_num AND status = 'Active' ORDER BY supplier_name";
$results = db_query($query);
while ($row = db_fetch_array($results)) {
echo(" <option value='$row[record_num]'>$row[supplier_name]</option>\n");
}
?>
</select>
</td>
</tr>
<?php } ?>
</table>
<?php if ($siteType == 'schoolfees' || $siteType == 'registration') { ?>
<br>
<?php } ?>
</td>
</tr>
<tr>
<td align='center' colspan='2'>
<?php include "hotlunch_reports.menu_date.menu.php"; ?>
</td>
</tr>
</table>
<input type='hidden' name='action' value='menu-details'>
<input type='hidden' id='next_form_action' name='next_form_action' value=''>
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
</form>
<?php
}
include "hotlunch_orders.print_buttons.php";
$time = date("Y-m-d H:i:s",time());
endTemplate();
?>