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

161 lines
4.9 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Ensure that only valid user types have access to this module
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Supplier');
if (checkPermission($AllowedUserTypes) != 1) {
echo("<br>\n");
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
include "form.messages.php";
return;
}
// Get schedule_num
if (array_key_exists('schedule_num',$_GET)) $schedule_num = intval($_GET['schedule_num']);
if (array_key_exists('schedule_num',$_POST)) $schedule_num = intval($_POST['schedule_num']);
if (!isset($schedule_num)) {
echo("<br>\n");
$error_message = getLanguageText('ERRORMSG-INVALID-ACCESS');
include "form.messages.php";
return;
}
// Check if this is a valid schedule
$swhere = "";
if ($_SESSION['UserInfo']['type'] == 'Supplier') $swhere = " and supplier_num = " . $_SESSION['UserInfo']['supplier_num'];
$query = "select * from hotlunch_schedules " .
"where record_num = $schedule_num " .
"and school_num = $school_num " .
$swhere;
$results = db_query($query);
if (db_num_rows($results) == 0) {
echo("<br>\n");
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE');
include "form.messages.php";
return;
}
$hotlunch_schedule = db_fetch_array($results);
// Check that this schedule date has lunch dates specified
$query = "select count(*) num from hotlunch_menu_dates " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num";
$dates = db_getVal($query);
if ($dates == 0) {
echo("<br>\n");
$error_message = getLanguageText('ERRORMSG-NO-MENU-DATES');
include "form.messages.php";
return;
}
// Check that this schedule date has lunch items specified
$query = "SELECT count(hotlunch_menu_items.record_num) num " .
"FROM hotlunch_menu_items AS hlmi,hotlunch_menu_dates AS hlmd " .
"WHERE hlmi.school_num = $school_num " .
"AND hlmd.school_num = $school_num " .
"AND hlmd.record_num = hlmi.menu_num " .
"AND hlmd.schedule_num = $schedule_num";
$items = db_getVal($query);
if ($items == 0) {
echo("<br>\n");
$error_message = getLanguageText('ERRORMSG-NO-MENU-DATES');
include "form.messages.php";
return;
}
?>
<br>
<table width='<?php echo($default_table_width) ?>' cellpadding='5' cellspacing='5' border='0' bgcolor='#eeeeee'>
<tr>
<td class='menu-item' align='center'><b>Order Money Collected - <?php echo($hotlunch_schedule['schedule_name']) ?></b></td>
</tr>
<tr>
<td align='center' class='menu-item'>
<?php
$query = "select paid_date,sum(amount_paid) collected " .
"from hotlunch_order_header " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"group by 1 " .
"order by 1";
$results = db_query($query);
if (db_num_rows($results) > 0) {
?>
<br>
<table width='600' cellpadding='3' cellspacing='1' border='0'>
<tr>
<td align='left' colspan='2' class='heading'>
<h2><?php echo($hotlunch_schedule['schedule_name']) ?>:</h2>
</td>
</tr>
<?php
$count = 0;
$total = 0;
while ($row = db_fetch_array($results)) {
extract($row);
$bgclass='data-even';
if ($count % 2) $bgclass = 'data-odd';
$count++;
$total += $collected;
?>
<tr height='1'>
<td align='left' colspan='2'><img src='images/spacer.gif' height='1' width='100'></td>
</tr>
<tr>
<td align='left' width='25%' class='<?php echo($bgclass) ?>'><?php echo($paid_date) ?></td>
<td align='left' class='<?php echo($bgclass) ?>'><?php echo($currencySymbol . number_format($collected,2)) ?></td>
</tr>
<?php
}
?>
<tr height='1'>
<td align='left' colspan='2'><img src='images/spacer.gif' height='1' width='100'></td>
</tr>
<tr>
<td align='left' width='25%' class='heading'>TOTAL COLLECTED:</td>
<td align='left' class='heading'><?php echo($currencySymbol . number_format($total,2)) ?></td>
</tr>
<tr>
<td colspan='2' align='right'>
<table align='right'>
<tr>
<td align='left'><a href='?action=hotlunch-collections-print&schedule_num=<?php echo($schedule_num) ?>' class='btn btn--primary btn--xsmall'><span>Print</span></a></td>
</tr>
</table>
</td>
</tr>
</table>
<?php
include "get.adobe.php";
}
else {
echo("<br>\n");
$error_message = getLanguageText('TEXT-THERE-ARE-NO-PAID-ORDERS-AT-THIS-TIME');
$message_width = 600;
include "form.messages.php";
}
?>
<br>
<?php include "hotlunch_reports.menu.php"; ?>
</td>
</tr>
</table>