Files
HotLunches/profile.form.php
T
2026-10-19 15:22:52 -07:00

350 lines
15 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$templatePageTitle = getLanguageText('PROFILE-TITLE-MANAGE');
$userid = $_SESSION['UserInfo']['userid'];
$email = $_SESSION['UserInfo']['email'];
?>
<br>
<form method='post' action='/' onSubmit='return validateFields();'>
<?php
$message_width = 600;
include "form.messages.php";
?>
<table width='700' class='content-table'>
<tr>
<td colspan='2' align='center' class='heading'><?php displayLanguageText('PROFILE-ACCOUNT') ?></td>
</tr>
<tr>
<td colspan='2' align='center'>
<br>
<table width='400'>
<tr>
<td align='center'>
<p><b><?php displayLanguageText('PROFILE-DISCLAIMER') ?></b></p>
<p><b><?php displayLanguageText('PROFILE-REQUIRED-FIELDS') ?></b></p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width='40%' align='right' valign='top'><?php displayLanguageText('TEXT-USER-ID') ?>: </td>
<?php if ($school_record['allow_userid_change'] == 'Y') { ?>
<td align='left' valign='top'><input type='text' name='entered_userid' id='entered_userid' value='<?php echo(str_replace("'","&#39;",$_SESSION['UserInfo']['userid'])) ?>' size='20'></td>
<?php } else { ?>
<td align='left' valign='top'>
<?php echo($_SESSION['UserInfo']['userid']) ?>
<input type='hidden' name='entered_userid' value='<?php echo(str_replace("'","&#39;",$_SESSION['UserInfo']['userid'])) ?>'>
</td>
<?php } ?>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-PASSWORD') ?>: </td>
<td align='left' valign='top'>******** &nbsp;[<a href='?action=change-password'>change</a>]</td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-FIRST-NAME') ?>: </td>
<td align='left' valign='top'><input type='text' name='first_name' id='first_name' value='<?php echo($_SESSION['UserInfo']['first_name']) ?>' size='40'></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-LAST-NAME') ?>: </td>
<td align='left' valign='top'><input type='text' name='last_name' id='last_name' value='<?php echo($_SESSION['UserInfo']['last_name']) ?>' size='40'></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-HOME-PHONE') ?>: </td>
<td align='left' valign='top'><input type='text' name='home_phone' id='home_phone' value='<?php echo($_SESSION['UserInfo']['home_phone']) ?>' size='20'></td>
</tr>
<?php if ($school_record['registration_cell_phone'] != 'No') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-CELL-PHONE') ?>: </td>
<td align='left' valign='top'><input type='text' name='cell_phone' id='cell_phone' value='<?php echo($_SESSION['UserInfo']['cell_phone']) ?>' size='20'></td>
</tr>
<?php } ?>
<?php if ($school_record['registration_daytime_phone'] != 'No') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-WORK-PHONE') ?>: </td>
<td align='left' valign='top'><input type='text' name='daytime_phone' id='daytime_phone' value='<?php echo($_SESSION['UserInfo']['daytime_phone']) ?>' size='20'></td>
</tr>
<?php } ?>
<?php if ($_SESSION['UserInfo']['type'] != 'Supplier') { ?>
<tr>
<td colspan='2' align='center'>
<br>
<p><b><?php displayLanguageText('TEXT-ONE-EMAIL-PER-ENTRY'); ?></b></p>
</td>
</tr>
<?php } ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-EMAIL-ADDRESS') ?>: </td>
<td align='left' valign='top'><input type='text' name='entered_email' id='entered_email' value='<?php echo($_SESSION['UserInfo']['email']) ?>' size='40'></td>
</tr>
<?php if ($school_record['email_broadcast_addresses'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-CLASS-EMAIL-LIST') ?>: </td>
<td align='left' valign='top'><?php BuildFileRadio("yn.txt","include_email1_on_list",$_SESSION['UserInfo']['include_email1_on_list']); ?><br><br></td>
</tr>
<?php } ?>
<?php if ($_SESSION['UserInfo']['type'] != 'Supplier') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-ADDITIONAL-EMAIL') ?>: </td>
<td align='left' valign='top'><input type='text' name='email2' id='email2' value='<?php echo($_SESSION['UserInfo']['email2']) ?>' size='40'></td>
</tr>
<?php if ($school_record['email_broadcast_addresses'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-CLASS-EMAIL-LIST') ?>: </td>
<td align='left' valign='top'><?php BuildFileRadio("yn.txt","include_email2_on_list",$_SESSION['UserInfo']['include_email2_on_list']); ?><br><br></td>
</tr>
<?php } ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-ADDITIONAL-EMAIL') ?>: </td>
<td align='left' valign='top'><input type='text' name='email3' id='email3' value='<?php echo($_SESSION['UserInfo']['email3']) ?>' size='40'></td>
</tr>
<?php if ($school_record['email_broadcast_addresses'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-CLASS-EMAIL-LIST') ?>: </td>
<td align='left' valign='top'><?php BuildFileRadio("yn.txt","include_email3_on_list",$_SESSION['UserInfo']['include_email3_on_list']); ?><br><br></td>
</tr>
<?php } ?>
<?php } ?>
<?php if ($_SESSION['UserInfo']['type'] != 'Supplier') { ?>
<?php if (strlen(trim($school_record['additional_registration_data_field1'])) > 0) { ?>
<tr>
<td colspan='2'>&nbsp;</td>
</tr>
<tr>
<td align='right'><?php echo(trim($school_record['additional_registration_data_field1'])) ?>: </td>
<td align='left'><input type='text' name='additional1' value='<?php echo($_SESSION['UserInfo']['additional1']) ?>' size='30'></td>
</tr>
<?php } ?>
<?php if (strlen(trim($school_record['additional_registration_data_field2'])) > 0) { ?>
<tr>
<td align='right'><?php echo(trim($school_record['additional_registration_data_field2'])) ?>: </td>
<td align='left'><input type='text' name='additional2' value='<?php echo($_SESSION['UserInfo']['additional2']) ?>' size='30'></td>
</tr>
<?php } ?>
<?php } ?>
<tr>
<td colspan='2'>&nbsp;</td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-LANGUAGE') ?>: </td>
<td align='left' valign='top'><?php BuildFileRadio($languagesFile,"language",$_SESSION['UserInfo']['language']); ?><br><br></td>
</tr>
<?php if ($school_record['registration_guest_student_info'] != 'N') { ?>
<?php if ($school_record['orders_for'] == 'Registrant' || ($school_record['orders_for'] == 'Both' && $_SESSION['UserInfo']['type'] == 'Guest')) { ?>
<?php
$numClasses = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num AND entry_type = 'Class'");
if ($numClasses > 0) {
$user_num = $_SESSION['UserInfo']['record_num'];
$class_num = db_getVal("SELECT class_num FROM people WHERE school_num = $base_school_num AND user_num = $user_num LIMIT 0,1");
?>
<tr>
<td align='right' valign='top'><?php echo($GlobalText['Class']) ?>: </td>
<td align='left' valign='top'>
<select name='class_num' class='select-width300'>
<?php
// Get class and teacher information
if ($school_record['p_display_program'] == 'Y') {
$query = "select c.*,program_name,cp.sequence " .
"from classes as c left join class_programs as cp on cp.record_num = class_program " .
"where c.school_num = $base_school_num " .
"and entry_type = 'Class' " .
"order by cp.sequence,c.sequence";
}
else {
$query = "select c.* from classes as c " .
"where c.school_num = $base_school_num " .
"and entry_type = 'Class' " .
"order by c.sequence";
}
$cresults = db_query($query);
$prev_program = "none";
while ($crow = db_fetch_array($cresults)) {
if (array_key_exists('program_name', $crow) && strlen($crow['program_name']) > 0 && $prev_program != $crow['program_name']) {
if ($prev_program != "none") echo(" </optgroup>\n");
$title = $crow['program_name'];
if (strlen($title) > 0) {
$prev_program = $title;
echo(" <optgroup label='$title'>\n");
}
}
$cnum = $crow['record_num'];
$class_info = getClassInfo($cnum,'dropdown');
$selected = "";
if ($cnum == $class_num) $selected = " selected='selected'";
if (isset($current_class_num) && $cnum == $current_class_num) $selected = " selected='selected'";
echo(" <option value='$cnum'$selected>$class_info</option>\n");
}
if (isset($title) && strlen($title) > 0) echo(" </optgroup>\n");
?>
</select>
</td>
</tr>
<tr>
<td colspan='2'>&nbsp;</td>
</tr>
<?php } ?>
<?php } ?>
<?php } ?>
<?php if ($_SESSION['UserInfo']['type'] != 'Supplier') { ?>
<?php if ($school_record['registration_volunteer_list'] != 'N') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-VOLUNTEER-SIGNUP') ?>: </td>
<td align='left' valign='top'>
<?php BuildFileRadio("yn.txt","available_to_volunteer",$_SESSION['UserInfo']['available_to_volunteer']) ?><br>
</td>
</tr>
<?php } ?>
<?php if ($school_record['email_system'] == 'Y' && $school_record['email_broadcast_optional'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-RECEIVE-EMAIL-NEWS') ?>: </td>
<td align='left' valign='top'>
<?php BuildFileRadio("yn.txt","receive_emails",$_SESSION['UserInfo']['receive_emails']) ?><br>
</td>
</tr>
<?php } ?>
<?php if ($school_record['email_reminder_day'] != 'None' && $school_record['email_reminder_optional'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-WEEKLY-REMINDER') ?>: </td>
<td align='left' valign='top'>
<?php BuildFileRadio("yn.txt","email_reminders",$_SESSION['UserInfo']['email_reminders']) ?><br>
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<blockquote>
<span class='small'><?php displayLanguageText('TEXT-WEEKLY-REMINDER-MSG') ?></span>
</blockquote>
</td>
</tr>
<?php } ?>
<?php if ($school_record['school_directory_permission'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php echo($school_record['school_directory_text']) ?>: </td>
<td align='left' valign='top'><?php BuildFileRadio("yn.txt","school_directory",$_SESSION['UserInfo']['school_directory']) ?></td>
</tr>
<?php } ?>
<?php if ($school_record['email_list_permission'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php echo($school_record['email_list_text']) ?>: </td>
<td align='left' valign='top'><?php BuildFileRadio("yn.txt","email_list",$_SESSION['UserInfo']['email_list']) ?></td>
</tr>
<?php } ?>
<?php } ?>
<?php
if ($_SESSION['UserInfo']['type'] == 'Staff') {
// Handle allergy flags
if ($naction == 'add' || $naction == 'edit') {
$allergens = db_query("select * from allergens where school_num = $school_num order by sequence");
if (db_num_rows($allergens) > 0) {
?>
<tr>
<td></td>
<td align='left'>
<table width='250' class='content-table' align='left'>
<tr>
<td align='left' class='heading' colspan='2'><?php displayLanguageText('TEXT-ALLERGIES'); ?></td>
</tr>
<?php
$user_num = $_SESSION['UserInfo']['record_num'];
$people_num = db_getVal("SELECT record_num FROM people WHERE school_num = $base_school_num AND user_num = $user_num AND people_type = 'Staff'");
$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 = "";
if ($naction == 'edit') {
$allergy = db_getVal("select count(*) from allergies where school_num = $school_num and people_num = $people_num and allergen_num = $allergen_num");
if ($allergy > 0) $checked = "checked='checked'";
}
?>
<tr class='<?php echo($class) ?>'>
<td align='center' width='20%'><input type='checkbox' name='allergen_<?php echo($allergen_num) ?>' value='Y' <?php echo($checked) ?>></td>
<td align='left'>&nbsp;&nbsp;<?php echo($allergen) ?></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<?php
}
}
}
?>
<tr>
<td colspan='2' align='center'>
<br>
<input type='submit' class='btn btn--primary' value="<?php displayLanguageText('BUTTON-PROFILE') ?>">
<input type='hidden' name='action' value='profile'>
<input type='hidden' name='naction' value='update'>
<br>
<br>
</td>
</tr>
</table>
</form>
<script language="JavaScript">
function validateFields() {
var firstVal = document.getElementById('first_name').value;
var lastVal = document.getElementById('last_name').value;
var phoneVal = document.getElementById('home_phone').value;
var emailVal = document.getElementById('entered_email').value;
missinginfo = "";
if (firstVal == "") {
missinginfo += "\n - <?php displayLanguageText('PROFILE-JAVA-MSG1') ?>";
}
if (lastVal == "") {
missinginfo += "\n - <?php displayLanguageText('PROFILE-JAVA-MSG2') ?>";
}
<?php if ($_SESSION['UserInfo']['type'] == 'Parent') { ?>
if (phoneVal == "") {
missinginfo += "\n - <?php displayLanguageText('PROFILE-JAVA-MSG3') ?>";
}
<?php } ?>
if ((emailVal == "") || (emailVal.indexOf('@') == -1) || (emailVal.indexOf('.') == -1)) {
missinginfo += "\n - <?php displayLanguageText('PROFILE-JAVA-MSG4') ?>";
}
if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"<?php displayLanguageText('PROFILE-JAVA-MSG5') ?>:\n" +
missinginfo + "\n_____________________________" +
"\n<?php displayLanguageText('PROFILE-JAVA-MSG6') ?>!";
alert(missinginfo);
return false;
}
else return true;
}
</script>
<?php
endTemplate();
?>