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

137 lines
4.9 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$headerArgs = "";
$school_name = $school_record['school_name'];
unset($student);
if (array_key_exists('class_num',$_GET)) $class_num = intval($_GET['class_num']);
if (array_key_exists('class_num',$_POST)) $class_num = intval($_POST['class_num']);
// Get class info
$class_info = getClassInfo($class_num);
$templatePageTitle = $school_record['school_name'] . " - " . getLanguageText('TEXT-CLASS-LIST') . "<br>\n$class_info";
if (isset($student) && $school_record['verified_only_class_list'] == 'Y' && $student['status'] != 'Verified') {
$content = getPageContent($school_num,"Access to Class List Denied");
?>
<table width='750' cellpadding='5' cellspacing='2' border='0' class='content-table'>
<tr>
<td align='center' class='heading'><?php displayLanguageText('ERRORMSG-ACCESS-NOT-PERMITTED'); ?></td>
</tr>
<tr>
<td align='left'><?php echo($content); ?></td>
</tr>
</table>
<br>
<?php
}
else {
include "form.messages.php";
if (array_key_exists('trx_num',$_GET) && intval($_GET['trx_num']) > 0) {
$trxnum = intval($_GET['trx_num']);
echo("<a href='#' class='print-receipt btn btn--primary btn--xsmall' trx-num='$trxnum'><span>" . getLanguageText('TEXT-PRINT-RECEIPT') . "</span></a>");
}
?>
<br>
<table width='850' cellpadding='5' cellspacing='2' border='0' class='content-table'>
<tr>
<td align='left' class='heading'><?php displayLanguageText('TEXT-NAME'); ?></td>
<td align='left' class='heading'><?php displayLanguageText('TEXT-PARENT'); ?></td>
<td align='left' class='heading'><?php displayLanguageText('TEXT-ACCOUNT'); ?></td>
<td align='right' class='heading'><?php displayLanguageText('TEXT-BALANCE'); ?></td>
<td align='right' class='heading'>&nbsp;</td>
</tr>
<?php
// Get students in this class
$query = "select * from people " .
"where school_num = $base_school_num " .
"and class_num = $class_num " .
"and people_type = 'Student' " .
"order by last_name,first_name";
$students = db_query($query);
$count = 0;
$money_icon = "<img src='images/icons/money24.png' alt='Post to User Account' border='0'>";
while ($row = db_fetch_array($students)) {
$snum = $row['record_num'];
$name = $row['first_name'] . " " . $row['last_name'];
$unum = $row['user_num'];
// Get the parent user record for this student
$query = "select * from users " .
"where school_num = $base_school_num " .
"and record_num = $unum";
$results = db_query($query);
$user = db_fetch_assoc($results);
$parent = $user['first_name'] . ' ' . $user['last_name'];
$userid = $user['userid'];
// Get account balance
$post_link = "";
$user_balance = db_getVal("select sum(transaction_amount) as balance from user_account where school_num = $school_num and user_num = $unum AND (deleted != 'Y' OR deleted IS NULL)");
$user_balance = floatval($user_balance);
if ($user_balance < 0) {
$balance = "-" . $currencySymbol . number_format(abs($user_balance),2);
}
else {
$balance = $currencySymbol . number_format($user_balance,2);
if ($user_balance > 0) $post_link = "<a href='?action=user-account&naction=post&user_num=$unum&class_num=$class_num'>$money_icon</a>";
}
$bgclass = "data-odd";
if (($count % 2) == 0) $bgclass = "data-even";
$count++;
?>
<tr>
<td align='left' width='200' valign='top' class='<?php echo($bgclass) ?>'><?php echo($name) ?></td>
<td align='left' valign='top' class='<?php echo($bgclass) ?>'><?php echo($parent) ?></td>
<td align='left' valign='top' class='<?php echo($bgclass) ?>'><?php echo($userid) ?></td>
<td align='right' valign='top' class='<?php echo($bgclass) ?>'><?php echo($balance) ?></td>
<td align='center' valign='top' class='<?php echo($bgclass) ?>'><?php echo($post_link) ?></td>
</tr>
<?php
}
if (isset($student_num)) {
$print_link = "class-list.print.php?student_num=$student_num";
}
else {
$print_link = "class-list.print.php?class_num=$class_num";
}
?>
</table>
<table width='850' cellpadding='5' cellspacing='2' border='0'>
<tr>
<td align='right'>
<table align='right'>
<tr>
<td align='left'><a href='<?php echo($print_link) ?>' class='btn btn--primary btn--xsmall'><span><?php displayLanguageText('TEXT-PRINTABLE-LIST'); ?></span></a></td>
</tr>
</table>
</td>
</tr>
</table>
<?php
include "get.adobe.php";
}
endTemplate();
?>