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

250 lines
11 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
unset($student_num);
if (array_key_exists('student_num',$_GET) && strlen($_GET['student_num']) > 0) $student_num = intval($_GET['student_num']);
if (!isset($student_num)) {
header("Location: /?action=students");
exit();
}
$results = db_query("SELECT * FROM people WHERE school_num = $base_school_num AND record_num = $student_num");
if (db_num_rows($results) == 0) {
$error_message = getLanguageText('ERRORMSG-NOT-FOUND');
header("Location: /?action=students&naction=search&error_message=".urlencode($error_message));
exit();
}
$student = db_fetch_assoc($results);
extract($student);
$student_num = $record_num;
if ($user_num > 0) {
$results = db_query("SELECT * FROM users WHERE school_num = $base_school_num AND record_num = $user_num");
$user = db_fetch_assoc($results);
$account_balance = db_getVal("select sum(transaction_amount) as balance from user_account where school_num = $school_num and user_num = $user_num AND (deleted != 'Y' OR deleted IS NULL)");
if ($account_balance === FALSE || strlen($account_balance) == 0) $account_balance = 0.00;
$account_balance = floatval($account_balance);
$abalance = floatval($account_balance);
if ($abalance == 0.00) $account_balance = $currencySymbol . number_format($abalance,2);
if ($abalance > 0) $account_balance = $currencySymbol . $abalance . " - " . getLanguageText('TEXT-BALANCE-OWING');
if ($abalance < 0) $account_balance = "-" . $currencySymbol . number_format(abs($abalance),2) . " - " . getLanguageText('TEXT-CREDIT-BALANCE');
$edit_link = "<a href='?action=user-account-list&naction=edit&record_num=$user_num' title='Edit User Account'>$edit_icon_small</a>&nbsp;&nbsp;&nbsp;";
$post_link = "<a href='?action=user-account&naction=add&user_num=$user_num' title='Post to User Account'>$money_icon_small</a>&nbsp;&nbsp;&nbsp;";
$edit_link = "<a href='?action=user-account-list&naction=edit&record_num=$user_num' title='Edit User Account'>$edit_icon</a>&nbsp;&nbsp;&nbsp;";
$post_link = "<a href='?action=user-account&naction=add&user_num=$user_num' title='Post to User Account'>$money_icon</a>&nbsp;&nbsp;&nbsp;";
$profile_link = "<a href='?action=account-contacts&naction=list&uid=$user_num' title='View Contact Information'>$contact_icon</a>&nbsp;&nbsp;&nbsp;";
$reminder_link = "<a href='?action=users&naction=send-reminder&next_naction=show-info&record_num=$user_num' title='Send Account Login Reminder Email'>$reminder_icon</a>&nbsp;&nbsp;&nbsp;";
if ($school_record['display_class_lists'] == 'N') $profile_link = "";
$command_links = $edit_link .
$post_link .
$profile_link .
$reminder_link;
}
?>
<br>
<form method='post' action='/'>
<?php
$message_width = $default_form_width;
include "form.messages.php";
?>
<table width='<?php echo($default_form_width) ?>' class='content-table'>
<tr>
<td colspan='3' align='center' class='heading'><?php displayLanguageText('TEXT-STUDENT-INFORMATION'); ?></td>
</tr>
<tr>
<td colspan='3' align='center'>&nbsp;</td>
</tr>
<?php if ($user_num > 0) { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-NAME'); ?>: </td>
<td align='left' valign='top'>
<b><a href='?action=user-account-list&naction=edit&record_num=<?php echo($user_num) ?>'><?php echo($user['first_name'] . ' ' . $user['last_name']) ?></a></b><br>
</td>
<td align='left' width='40%' rowspan='2' valign='top'><nobr>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo($command_links) ?></nobr></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-USER-ID'); ?>: </td>
<td align='left' valign='top'><b><?php echo($user['userid']) ?></b></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-EMAIL'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><a href='mailto:<?php echo($user['email']) ?>'><?php echo($user['email']) ?></a></b></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-PHONE'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($user['home_phone']) ?></b></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-STATUS'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($user['status']) ?></b></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-TYPE'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($user['type']) ?></b></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-ACCOUNT-BALANCE'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($account_balance) ?></b></td>
</tr>
<tr>
<td colspan='3'>&nbsp;</td>
</tr>
<?php } ?>
<?php
$edit_link = "<a href='?action=students&naction=edit&record_num=$record_num' title='Edit Student Account'>$edit_icon</a>&nbsp;&nbsp;&nbsp;";
$msg = getLanguageText('TEXT-CONFIRM-DELETE');
$delete_link = "<a href='?action=students&naction=delete-confirmed&record_num=$record_num' onClick='return confirm(\"$msg\");' title='Delete Student'>$delete_icon</a>&nbsp;&nbsp;&nbsp;";
$post_link = "<a href='?action=user-account&naction=add&student_num=$record_num' title='Post to User Account'>$money_icon</a>&nbsp;&nbsp;&nbsp;";
?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-FIRST-NAME'); ?>: </td>
<td align='left' valign='top'><b><?php echo($first_name) ?></b></td>
<td align='left' rowspan='2' valign='top'><nobr>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo("$edit_link$delete_link$post_link") ?></nobr></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-LAST-NAME'); ?>: </td>
<td align='left' valign='top'><b><?php echo($last_name) ?></b></td>
</tr>
<?php if ($school_record['collect_student_birthdate'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-BIRTH-DATE'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo(dateString('default',strtotime($birthdate))) ?></b></td>
</tr>
<?php } ?>
<?php if ($school_record['collect_student_number'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-STUDENT-NUMBER'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($student_number) ?></b></td>
</tr>
<?php } ?>
<?php if ($school_record['collect_student_age'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-AGE'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($age) ?></b></td>
</tr>
<?php } ?>
<?php if ($school_record['collect_student_sex'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-SEX'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($sex) ?></b></td>
</tr>
<?php } ?>
<?php if ($school_record['collect_student_grade'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-GRADE'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($school_grade) ?></b></td>
</tr>
<?php } ?>
<?php if ($school_record['collect_permission'] == 'Y' || $school_record['collect_permission'] == 'W') { ?>
<tr>
<td colspan='2'>&nbsp;</td>
</tr>
<tr>
<td align='right' valign='top'><?php echo($school_record['permission_prompt']); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($additional_permission) ?></b><br>
<?php if ($school_record['collect_permission'] == 'W') { ?>
<?php echo($additional_permission_note) ?><br>
<?php } ?>
<?php if (strlen(trim($school_record['permission_description']))) echo("<span class='small'>" . nl2br(trim($school_record['permission_description'])) . "</span>") ?>
</td>
</tr>
<?php } ?>
<?php
$numClasses = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num");
if ($numClasses > 0) {
?>
<tr>
<td align='right' valign='top'><?php echo($GlobalText['Class']) ?>: </td>
<td align='left' colspan='2' valign='top'>
<?php
$class_info = getClassInfo($class_num);
echo("<b>$class_info</b>");
?>
</td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-STATUS'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($status) ?></b></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-STUDENT-INCLUDE-CLASS-LIST'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($display) ?></b></td>
</tr>
<?php } ?>
<?php if ($school_record['special_item_prices'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-MENU-PRICE-CATEGORY'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($menu_price_category) ?></b></td>
</tr>
<?php } ?>
<?php if ($school_record['user_defined_values'] == 'Y' && strlen($school_record['user_defined_title']) > 0) { ?>
<tr>
<td align='right' valign='top'><?php echo($school_record['user_defined_title']); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($user_defined_value) ?></b></td>
</tr>
<?php } ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-STUDENT-NUMBER'); ?>: </td>
<td align='left' colspan='2' valign='top'><b><?php echo($record_num) ?></b></td>
</tr>
<?php
$allergens = db_query("select * from allergens where school_num = $school_num order by sequence");
if (db_num_rows($allergens) > 0) {
?>
<tr>
<td></td>
<td colspan='2' align='left'>
<br>
<table width='50%' class='content-table' align='left'>
<tr>
<td align='center' class='heading' colspan='2'><?php displayLanguageText('TEXT-ALLERGIES'); ?></td>
</tr>
<?php
$count = 0;
while ($row = db_fetch_array($allergens)) {
$allergen = $row['allergen'];
$allergen_num = $row['record_num'];
$class = 'data-even';
if ($count % 2) $class = 'data-odd';
$count++;
$checked = getLanguageText('TEXT-NO');
$allergy = db_getVal("select count(*) from allergies where school_num = $school_num and people_num = $record_num and allergen_num = $allergen_num");
if ($allergy > 0) $checked = getLanguageText('TEXT-YES');
?>
<tr class='<?php echo($class) ?>'>
<td align='center'><?php echo($allergen) ?></td>
<td align='center' width='40%'><b><?php echo($checked) ?></b></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<?php } ?>
<tr>
<td colspan='3' align='center'>
<?php include "students.display.orders.php"; ?>
</td>
</tr>
<tr>
<td colspan='3'>&nbsp;</td>
</tr>
</table>
<br>