181 lines
6.6 KiB
PHP
181 lines
6.6 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Get current people_num
|
|
$user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
$people_num = db_getVal("select record_num from people where user_num = $user_num");
|
|
if (!$people_num) {
|
|
return;
|
|
}
|
|
|
|
|
|
// Get account balance
|
|
$balance = db_getVal("select sum(transaction_amount) from user_account where school_num = $school_num and user_num = $user_num AND (deleted != 'Y' OR deleted IS NULL)");
|
|
$balance = floatval($balance);
|
|
if ($balance >= 0) $balance_text = $currencySymbol . number_format($balance,2);
|
|
else $balance_text = "- $currencySymbol" . number_format(abs($balance),2);
|
|
|
|
$acctBalance = $balance;
|
|
|
|
|
|
|
|
// Get records to display
|
|
$today = date("Y-m-d",time());
|
|
$now = date("Y-m-d H:i:s",time());
|
|
$cutoff = date("Y-m-d H:i:s",time() - 60 * 60 * 24 * 20);
|
|
$query = "select * from hotlunch_schedules " .
|
|
"where school_num = $school_num " .
|
|
"and status = 'Active' " .
|
|
"and start_order_datetime <= '$now' " .
|
|
"and (schedule_end_date >= '$cutoff' OR end_order_datetime >= '$cutoff') " .
|
|
"AND schedule_for = 'Anyone' " .
|
|
"order by $scheduleSortOrder";
|
|
$schedules = db_query($query);
|
|
|
|
if (db_num_rows($schedules) == 0) {
|
|
echo("<p><b>There are no active schedules to view</b></p>\n");
|
|
?>
|
|
<br>
|
|
<table width='800' cellpadding='3' cellspacing='1' border='0'>
|
|
<tr>
|
|
<td class='heading' align='center'>Current Account Transaction Balance :: <?php echo($balance_text) ?> </td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
}
|
|
else {
|
|
|
|
// Get guest totals
|
|
$query = "select sum(order_subtotal) as t_subtotal,sum(discount_amount) as t_discount,sum(order_total) as t_total,sum(amount_paid) as t_paid " .
|
|
"from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and ordered_by_num = $people_num " .
|
|
"and ordered_by_type = 'Customer'";
|
|
$totals = db_query($query);
|
|
$row = db_fetch_array($totals);
|
|
extract($row);
|
|
|
|
$t_balance = $t_subtotal - $t_discount - $t_paid;
|
|
|
|
?>
|
|
<br>
|
|
<table width='800' cellpadding='3' cellspacing='1' border='0'>
|
|
<tr>
|
|
<td align='left' class='heading'><?php displayLanguageText('TEXT-TITLE'); ?></td>
|
|
<td class='heading' align='right'><?php displayLanguageText('TEXT-ORDER-TOTAL'); ?></td>
|
|
<?php if ($t_discount > 0) { ?>
|
|
<td class='heading' align='right'><?php displayLanguageText('TEXT-DISCOUNT'); ?></td>
|
|
<?php } ?>
|
|
<td class='heading' align='right'><?php displayLanguageText('TEXT-ORDER-NET'); ?></td>
|
|
<td class='heading' align='center'><?php displayLanguageText('TEXT-STATUS'); ?></td>
|
|
<td class='heading'> </td>
|
|
</tr>
|
|
<?php
|
|
$lcount = 0;
|
|
while ($row = db_fetch_array($schedules)) {
|
|
extract($row);
|
|
$schedule_num = $record_num;
|
|
|
|
$l_bgclass = 'data-odd';
|
|
if ($lcount % 2) $l_bgclass = 'data-even';
|
|
$lcount++;
|
|
|
|
// Get order information for this schedule
|
|
$query = "select schedule_num,order_subtotal,discount_amount,order_total," .
|
|
"amount_paid,status,record_num as order_num " .
|
|
"from hotlunch_order_header as oh " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and ordered_by_num = $people_num " .
|
|
"and ordered_by_type = 'Customer'";
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results) > 0) {
|
|
$row = db_fetch_array($results);
|
|
extract($row);
|
|
$balance = $order_subtotal - $discount_amount - $amount_paid;
|
|
// $order_num = $record_num;
|
|
}
|
|
else {
|
|
$order_subtotal = 0;
|
|
$discount_amount = 0;
|
|
$order_total = 0;
|
|
$amount_paid = 0;
|
|
$balance = 0;
|
|
$status = getLanguageText('TEXT-NO-ORDER');
|
|
$order_num = 0;
|
|
}
|
|
|
|
$orderButtonText = getLanguageText('TEXT-ORDER');
|
|
if (isset($order_button_text) && strlen($order_button_text)) $orderButtonText = $order_button_text;
|
|
?>
|
|
<tr class='<?php echo($l_bgclass) ?>'>
|
|
<td align='left' width='350'><?php echo($schedule_name) ?></td>
|
|
<td align='right' width='100'><?php echo($currencySymbol . number_format($order_subtotal,2)) ?></td>
|
|
<?php if ($t_discount != 0) { ?>
|
|
<td align='right'><?php echo($currencySymbol . number_format($discount_amount,2)) ?></td>
|
|
<?php } ?>
|
|
<?php if ($schedule_prices != 'N') { ?>
|
|
<td align='right' width='100'><?php echo($currencySymbol . number_format($order_total,2)) ?></td>
|
|
<td align='center' width='100'><?php echo($status) ?></td>
|
|
<?php } else { ?>
|
|
<td align='right' width='100'>--</td>
|
|
<td align='center' width='100'>--</td>
|
|
<?php } ?>
|
|
<td align='center' width='150'>
|
|
<table cellpadding='1'>
|
|
<tr>
|
|
<td align='left'>
|
|
<?php if ((isset($next_action) && $next_action == 'edit') || $end_order_datetime >= $now) { ?>
|
|
<a href='?action=orders&naction=edit&schedule_num=<?php echo($schedule_num) ?>&user_num=<?php echo($people_num) ?>&entered_order_num=<?php echo($order_num) ?>' class='btn btn--primary btn--xsmall'><?php echo($orderButtonText) ?></a>
|
|
<?php } ?>
|
|
</td>
|
|
<td align='left'>
|
|
<?php if (isset($order_num) && $order_num > 0) { ?>
|
|
<a href='?action=orders-print&schedule_num=<?php echo($schedule_num) ?>&order_num=<?php echo($order_num) ?>' class='btn btn--primary btn--xsmall'><?php displayLanguageText('TEXT-PRINT'); ?></a>
|
|
<?php } ?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
<tr class='heading'>
|
|
<td align='left'><b>TOTALS :: </b></td>
|
|
<td align='right'><b><?php echo($currencySymbol . number_format($t_subtotal,2)) ?></b></td>
|
|
<?php if ($t_discount != 0) { ?>
|
|
<td align='right'><b><?php echo($currencySymbol . number_format($t_discount,2)) ?></b></td>
|
|
<?php } ?>
|
|
<td align='right'><b><?php echo($currencySymbol . number_format($t_total,2)) ?></b></td>
|
|
<td align='center'> </td>
|
|
<td align='center'> </td>
|
|
</tr>
|
|
<?php
|
|
|
|
$colspan = 6;
|
|
if ($t_discount != 0) $colspan = 7;
|
|
?>
|
|
<tr>
|
|
<td colspan='<?php echo($colspan) ?>' class='heading' align='right'>Current Account Transaction Balance :: <?php echo($balance_text) ?> </td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
}
|
|
|
|
|
|
$user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
if ($acctBalance > 0) {
|
|
echo("<br>\n");
|
|
include "payment_form.php";
|
|
}
|
|
|
|
?>
|