0) $selected_schedules = $_POST['selected_schedules']; if (count($selected_schedules) == 0 || (count($selected_schedules) == 1 && $selected_schedules[0] == 0)) { // Get set of schedules to display $results = db_query("SELECT distinct schedule_num,schedule_name FROM hotlunch_order_header AS hloh, hotlunch_schedules AS hs " . "WHERE hloh.school_num = $school_num " . "AND hs.school_num = $school_num " . "AND hloh.schedule_num = hs.record_num " . "AND (payment_method IS NOT NULL AND payment_method != '') " . "ORDER BY 2"); $selected_schedules = array(); while ($row = db_fetch_array($results)) { $selected_schedules[] = $row['schedule_num']; } } $message_width = 600; include "form.messages.php"; ?>
Schedule:
order_total"; db_query($query); $query = "UPDATE hotlunch_order_header SET amount_paid = 0 " . "WHERE school_num = $school_num " . "AND schedule_num = $schedule_num " . "AND status = 'Unpaid' " . "AND amount_paid > order_total"; db_query($query); echo("
\n"); if ($i > 0) { echo("


"); echo("


"); } echo("

$schedule_name

\n"); echo("
\n"); // Get totals first $query = "SELECT count(*) AS num, sum(order_total) AS total, sum(discount_amount) AS discount, sum(amount_paid) AS paid " . "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); $row = db_fetch_array($results); $total_count = $row['num']; $total_orders = $row['total']; $total_paid = $row['paid']; // Define Query $query = "SELECT payment_method, count(*) AS num, sum(order_total) AS total, sum(discount_amount) AS discount, sum(amount_paid) AS paid " . "FROM hotlunch_order_header " . "WHERE school_num = $school_num " . "AND schedule_num = $schedule_num " . "AND status NOT IN ('Inactive','Deleted','Concession','Complimentary','Pending') " . "GROUP BY 1 " . "ORDER BY 1"; echo("\n"); $summary = db_query($query); // Format the data $data = array(); $totals = array('',0,'',0,'',0,''); $count = 0; $psnum = 0; while ($row = db_fetch_array($summary)) { $payment_method = $row['payment_method']; //if (strlen($payment_method) == 0) { // if ($row['status'] == 'Unpaid') $payment_method = 'Unpaid Orders'; // if ($row['status'] == 'Paid') $payment_method = 'Unknown'; //} if (strlen($payment_method) == 0) $payment_method = 'Unknown'; $data[$count][0] = $payment_method; $data[$count][1] = $row['num']; $data[$count][2] = ($total_count == 0) ? 0 : sprintf("%.1f",round($row['num'] / $total_count * 1000) / 10) . '%'; $data[$count][3] = $currencySymbol . number_format($row['total'],2); $data[$count][4] = ($total_orders == 0) ? 0 : sprintf("%.1f",round($row['total'] / $total_orders * 1000) / 10) . '%'; $data[$count][5] = $currencySymbol . number_format($row['paid'],2); $data[$count][6] = ($total_paid == 0) ? 0 : sprintf("%.1f",round($row['paid'] / $total_paid * 1000) / 10) . '%'; $totals[1] += $row['num']; $totals[3] += $row['total']; $totals[5] += $row['paid']; $count++; } // Format the totals $totals[3] = $currencySymbol . number_format($totals[3],2); $totals[5] = $currencySymbol . number_format($totals[5],2); $default_data_width = 600; $display_dataset_count = 'N'; listDataCustom($data,$columnHeaders,$action,array(),'N',$columnAlign,$totals); } $snums = implode(',',$selected_schedules); ?>