78 lines
2.3 KiB
PHP
78 lines
2.3 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
//
|
|
// Process all actions to list records
|
|
//
|
|
$action = "recalc";
|
|
$TitleText = "Recalculate Order Totals";
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = "$TitleText";
|
|
|
|
|
|
// 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');
|
|
include "form.messages.php";
|
|
endTemplate();
|
|
exit();
|
|
}
|
|
|
|
$school_num = $school_record['record_num'];
|
|
|
|
|
|
$message_width = 400;
|
|
include "form.messages.php";
|
|
|
|
$scriptName = str_replace("/m/data1/app.hotlunches.net/","",__FILE__);
|
|
include "help.docs.php";
|
|
|
|
|
|
//
|
|
// List all orders
|
|
//
|
|
$columnHeaders = array("Order Num","Orig SubTotal","Orig Total","Tax","New SubTotal","New Total","Tax","Difference");
|
|
$columnAlign = array('left','right','right','right','right','right','right','right');
|
|
$query = "SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND status NOT IN ('Inactive','Deleted')";
|
|
$results = db_query($query);
|
|
|
|
$data = array();
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
$order_num = $record_num;
|
|
$r = db_query("SELECT count(*) AS num, sum(extended_price) AS subtotal FROM hotlunch_order_items WHERE order_num = $order_num");
|
|
$row = db_fetch_assoc($r);
|
|
$num = $row['num'];
|
|
$span = "<span>";
|
|
if ($diff != 0) $span = "<span class='error'>";
|
|
|
|
$tax = 0;
|
|
$r = db_query("SELECT * FROM user_account WHERE school_num = $school_num AND order_num = $order_num AND transaction_type = 'Tax Charge' AND deleted = 'N'");
|
|
if (db_num_rows($r) != 0) {
|
|
$row = db_fetch_assoc($r);
|
|
$tax = $row['transaction_amount'];
|
|
}
|
|
|
|
$totals = calcOrderTotal($order_num,$schedule_num,'Y');
|
|
$diff = $order_total - $totals['order_total'];
|
|
|
|
$tspan = "<span>";
|
|
if ($tax != $totals['tax_amount']) $tspan = "<span class='error'>";
|
|
|
|
$data[] = array($order_num,$order_subtotal,$order_total,$tax,$totals['order_subtotal'],$totals['order_total'],$tspan . $totals['tax_amount'] . "</span>",$span . number_format($diff,2) . "</span>");
|
|
}
|
|
|
|
listDataCustom($data,$columnHeaders,$action,array(),'N',$columnAlign);
|
|
|
|
endTemplate();
|
|
?>
|