Files
HotLunches/history_reports.php
2026-10-19 15:22:52 -07:00

85 lines
2.5 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$templatePageTitle = getLanguageText('TEXT-HISTORY');
$headerArgs = "";
// Ensure that only valid user types have access to this module
$AllowedUserTypes = array('SuperUser','System Administrator');
if (checkPermission($AllowedUserTypes) != 1) {
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED').' - '.$_SESSION['UserInfo']['type'];
$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
//
$action = "history-reports";
$CurrentTable = "reports";
$FormFile = "";
$OrderBy = "schedule_start_date";
$school_num = $school_record['record_num'];
//
// List all requested records
//
$invoices = db_query("SELECT * FROM invoice_header WHERE school_num = $school_num AND status != 'Cancelled' ORDER BY invoice_date DESC");
if (db_num_rows($invoices)) {
$data = array();
while ($row = db_fetch_assoc($invoices)) {
extract($row);
$invoice_number = $record_num + 500;
$amount = '$' . number_format($total,2);
$entry = array();
$entry[] = "<a href='view-invoice.php?snum=$school_num&rnum=$record_num'>" . getLanguageText('TEXT-INVOICE') . " - #" . sprintf("%06d",$invoice_number) . "</a>";
$entry[] = $invoice_date;
$entry[] = $amount;
$entry[] = "$status - $payment_date";
if ($status == 'Paid') {
if ($total == 0.00) $payment_method = getLanguageText('TEXT-COMPLIMENTARY');
$entry[] = $payment_method;
$entry[] = "<a href='?action=inv-print&invoice_num=$record_num'>" . getLanguageText('TEXT-RECEIPT') . "</a>";
}
else {
$entry[] = "";
$entry[] = "";
}
$data[] = $entry;
}
$columnHeaders = array(getLanguageText('TEXT-INVOICE'),
getLanguageText('TEXT-DATE'),
getLanguageText('TEXT-AMOUNT'),
getLanguageText('TEXT-STATUS'),
getLanguageText('TEXT-PAYMENT-METHOD'),
'');
$columnAlign = array('left','center','right','center','center','center');
echo("<p><b>" . getLanguageText('TEXT-INVOICES') . "</b></p>\n");
listDataCustom($data,$columnHeaders,$action,array(),'N',$columnAlign);
}
endTemplate();
?>