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 .= "" . $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']) . "\n"; $error_message .= "$onum"; $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()); ?>
$now) { ?> $scheduleStatus"; ?>

:

:
:
:
:
:
:
:
:
:

\n\n"); $results = db_query($query); if (db_num_rows($results) > 0) { ?>
-
%
 

:
%
 

:

0) { ?>

0) { ?>
:
: