188 lines
6.3 KiB
PHP
188 lines
6.3 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');
|
|
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']);
|
|
|
|
$headerArgs = "&schedule_num=$schedule_num&menu_num=0&naction=$naction";
|
|
|
|
|
|
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();
|
|
}
|
|
|
|
|
|
// 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);
|
|
$schedule_name = $hotlunch_schedule['schedule_name'];
|
|
|
|
|
|
$templatePageTitle = getLanguageText('TEXT-ORDER-UPDATE') . "<br>\n$schedule_name";
|
|
|
|
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";
|
|
|
|
$orders = db_query("SELECT hloh.*,p.first_name,p.last_name 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 = hloh.ordered_by_num " .
|
|
"AND hloh.schedule_num = $schedule_num " .
|
|
"ORDER BY last_name, first_name");
|
|
$numOrders = db_num_rows($orders);
|
|
if ($numOrders == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-NO-ORDERS-FOUND');
|
|
$action = 'schedule-reports';
|
|
$naction = '';
|
|
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
echo("<p>" . getLanguageText('TEXT-ORDERS') . ": $numOrders</p>");
|
|
?>
|
|
<table width='650' class='content-table'>
|
|
<tr class='heading'>
|
|
<td colspan='3' align='center'><?php displayLanguageText('TEXT-ORDERS'); ?></td>
|
|
</tr>
|
|
<tr class='heading'>
|
|
<td align='left' width='75%'><?php echo($GlobalText['StudentName']); ?></td>
|
|
<td align='center'><?php displayLanguageText('TEXT-STATUS'); ?></td>
|
|
<td align='center'><?php displayLanguageText('TEXT-ORDER'); ?></td>
|
|
</tr>
|
|
<?php
|
|
$today = date("Y-m-d",time());
|
|
$count = 0;
|
|
while ($row = db_fetch_assoc($orders)) {
|
|
$order_num = $row['record_num'];
|
|
$onum = $order_num;
|
|
$source = $row['source'];
|
|
$price_category = $row['price_category'];
|
|
|
|
$pricesCorrect = true;
|
|
|
|
// Update order item prices
|
|
$items = db_query("SELECT * FROM hotlunch_order_items WHERE school_num = $school_num AND order_num = $order_num");
|
|
while ($item = db_fetch_assoc($items)) {
|
|
$menu_item_num = $item['menu_item_num'];
|
|
$qty = $item['qty'];
|
|
$mprice = $item['menu_item_price'];
|
|
$rnum = $item['record_num'];
|
|
|
|
$results = db_query("SELECT * FROM hotlunch_menu_items WHERE school_num = $school_num AND record_num = $menu_item_num");
|
|
$mitem = db_fetch_assoc($results);
|
|
|
|
switch ($price_category) {
|
|
case 'Regular':
|
|
default:
|
|
$price = $mitem['online_price'];
|
|
if ($source == 'Paper') $price = $mitem['offline_price'];
|
|
break;
|
|
|
|
case 'Special 1':
|
|
$price = $mitem['special_price1'];
|
|
break;
|
|
|
|
case 'Special 2':
|
|
$price = $mitem['special_price2'];
|
|
break;
|
|
|
|
case 'Special 3':
|
|
$price = $mitem['special_price3'];
|
|
break;
|
|
}
|
|
|
|
if ($price != $mprice) $pricesCorrect = false;
|
|
$extended_price = number_format($price * $qty,2);
|
|
}
|
|
|
|
|
|
// Get order
|
|
$pnum = $row['ordered_by_num'];
|
|
$disc = $row['discount_amount'];
|
|
$total = $row['order_total'];
|
|
$paid = $row['amount_paid'];
|
|
$status = $row['status'];
|
|
|
|
|
|
// Get person's name
|
|
$name = $row['first_name'] . ' ' . $row['last_name'];
|
|
|
|
if (!$pricesCorrect) {
|
|
$status = "<span class='error'>$status</span>";
|
|
$order_num = "<span class='error'>$onum</span>";
|
|
}
|
|
$order_num = "<a href='?action=orders&schedule_num=$schedule_num&naction=edit&order_num=$onum'>$order_num</a>";
|
|
|
|
$class = 'data-odd';
|
|
if ($count % 2) $class = 'data-even';
|
|
$count++;
|
|
?>
|
|
<tr class='<?php echo($class) ?>'>
|
|
<td align='left'><?php echo($name) ?></td>
|
|
<td align='center'><?php echo($status) ?></td>
|
|
<td align='center'><?php echo($order_num) ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</table>
|
|
<br>
|
|
<br>
|
|
<br>
|
|
<?php
|
|
include "hotlunch_orders.print_buttons.php";
|
|
|
|
endTemplate();
|
|
?>
|