Files
HotLunches/students.display.parent.php
T
2026-10-19 15:22:52 -07:00

116 lines
3.0 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Initialize row counter
$count = 0;
//
// Get set of students
//
$CurrentUserType = $_SESSION['UserInfo']['type'];
if ($_SESSION['mode'] == 'parent') $CurrentUserType = 'Parent';
switch ($CurrentUserType) {
case 'System Administrator':
case 'Application Administrator':
case 'Administration Team':
case 'Schedule Team':
return;
break;
case 'Parent':
case 'Staff':
$unum = intval($_SESSION['UserInfo']['record_num']);
$user_num = $unum;
$query = "select * from people " .
"where school_num = $base_school_num " .
"and user_num = $unum " .
"and people_type IN ('Student','Customer') " .
"and status != 'Inactive' " .
"and active != 'N' " .
"order by last_name asc, first_name asc";
writeLog("query: $query");
$PageTitle = $school_record['student_button_text'] . " List";
break;
}
$students = db_query($query);
echo("<br>\n");
$message_width = $default_form_width;
include "form.messages.php";
?>
<table width='95%' class='content-table'>
<tr>
<td colspan='5' class='heading' align='center'><?php echo($PageTitle) ?></td>
</tr>
<tr>
<td align='center'>
<?php
//
// Display the student records found
//
if (db_num_rows($students)) {
?>
<table width='100%' cellspacing='0' cellpadding='2' border='0'>
<?php
while ($row = db_fetch_array($students)) {
extract($row);
$bgclass = "data-odd";
if (($count % 2) == 0) $bgclass = "data-even";
$count++;
// Get class and teacher info
if (isset($class_num) && $class_num != 0) {
$class_info = getClassInfo($class_num,'external',5,true);
$class_info = "<nobr>$class_info";
$class_info .= "</nobr>";
}
include "students.display.row.php";
}
?>
</table>
<?php
}
//
// If there are no students found display a polite message
//
if ($count == 0) echo("<p><b>" . getLanguageText('ERRORMSG-NO-RECORDS') . "</b></p>\n");
// Check user account balance
updateUserBalance($user_num);
$num_transactions = db_getVal("select count(*) from user_account where school_num = $school_num and user_num = $user_num AND (deleted != 'Y' OR deleted IS NULL)");
$mcommand = "";
if ($_SESSION['mode'] == 'parent') $mcommand = "&mode=parent";
?>
</td>
</tr>
</table>
<br>
<table cellpadding='5' border='0'>
<tr>
<?php if ($school_record['allow_parents_to_edit_students'] != 'N') { ?>
<td align='center'><a href='?action=<?php echo($action) ?>&naction=add<?php echo($mcommand) ?>' class='btn btn--primary>'><?php displayLanguageText('TEXT-ADD-NEW'); ?></a></td>
<?php } ?>
<?php if ($num_transactions > 0) { ?>
<td align='center'><a href='?action=user-account<?php echo($mcommand) ?>' class='btn btn--primary>'><?php displayLanguageText('BUTTON-ACCOUNT-TRANSACTIONS'); ?></a></td>
<?php } ?>
</tr>
</table>
</p>