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

157 lines
5.9 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Setup default values on insert
if ($naction == 'add') {
$initTableName = $CurrentTable;
$tarray = initializeTableArray($initTableName);
extract($tarray, EXTR_OVERWRITE);
$contact_type = 'Primary';
$added_date = date("Y-m-d",time());
$user_num = intval($_SESSION['UserInfo']['record_num']);
if (array_key_exists('uid',$_GET)) $user_num = intval($_GET['uid']);
$province = $school_record['province'];
}
if (!isset($first_name)) $first_name = '';
if (!isset($last_name)) $last_name = '';
if (!isset($home_phone)) $home_phone = '';
if (!isset($home_email)) $home_email = '';
if (!isset($cell_phone)) $cell_phone = '';
if (!isset($work_phone)) $work_phone = '';
if (!isset($work_email)) $work_email = '';
if (!isset($address)) $address = '';
if (!isset($city)) $city = '';
if (!isset($province)) $province = '';
if (!isset($postal)) $postal = '';
if (!isset($record_num)) $record_num = '';
?>
<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='2' align='center' class='heading'><?php echo($PageTitle) ?></td>
</tr>
<tr>
<td colspan='2' align='center'>&nbsp;</td>
</tr>
<?php if ($_SESSION['UserInfo']['type'] != 'Parent') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-USER-ACCOUNT'); ?>: </td>
<td align='left' valign='top'>
<select name='user_num'>
<?php if ($naction == 'search') { ?>
<option></option>
<?php } ?>
<?php
$query = "select * from users " .
"where school_num = $base_school_num " .
"order by userid";
$results = db_query($query);
while ($row = db_fetch_array($results)) {
$userid = $row['userid'];
$usernum = $row['record_num'];
$selected = "";
if ($user_num == $usernum) $selected = " selected='selected'";
echo(" <option value='$usernum'$selected>$userid</option>\n");
}
?>
</select>
</td>
</tr>
<?php } ?>
<tr>
<td width='40%' 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($first_name) ?>" size='20'></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($last_name) ?>" size='20'></td>
</tr>
<tr>
<td align='center' colspan='2'></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($home_phone) ?>" size='15'> (ie. 604-555-1212)</td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-HOME-EMAIL'); ?>: </td>
<td align='left' valign='top'><input type='text' name='home_email' id='home_email' value="<?php echo($home_email) ?>" size='40'></td>
</tr>
<tr>
<td align='center' colspan='2'></td>
</tr>
<?php if ($school_record['c_display_work_phone'] == 'Y') { ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-WORK-PHONE'); ?>: </td>
<td align='left' valign='top'><input type='text' name='work_phone' id='work_phone' value="<?php echo($work_phone) ?>" size='15'></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-WORK-EMAIL'); ?>: </td>
<td align='left' valign='top'><input type='text' name='work_email' id='work_email' value="<?php echo($work_email) ?>" size='40'></td>
</tr>
<?php } ?>
<tr>
<td align='center' colspan='2'></td>
</tr>
<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($cell_phone) ?>" size='15'></td>
</tr>
<?php if ($school_record['registration_address'] != 'No' || $school_record['c_display_home_address'] == 'Y') { ?>
<tr>
<td align='center' colspan='2'></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-ADDRESS'); ?>: </td>
<td align='left' valign='top'><input type='text' name='address' id='address' value="<?php echo($address) ?>" size='30'></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-CITY'); ?>: </td>
<td align='left' valign='top'><input type='text' name='city' id='city' value="<?php echo($city) ?>" size='30'></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-PROVINCE'); ?>: </td>
<td align='left' valign='top'>
<select name='province' id='province'>
<?php BuildFileList("provinces.txt",$province) ?>
</select>
</td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-POSTAL'); ?>: </td>
<td align='left' valign='top'><input type='text' name='postal' id='postal' value="<?php echo($postal) ?>" size='30'></td>
</tr>
<?php } ?>
<tr>
<td align='center' colspan='2' align='center'>
<br>
<input type='submit' class='btn btn--primary' value="<?php echo($ButtonText) ?>">
<input type='hidden' name='action' value='<?php echo($action) ?>'>
<input type='hidden' name='naction' value='<?php echo($next_naction) ?>'>
<input type='hidden' name='mode' value="<?php echo($_SESSION['mode']) ?>">
<input type='hidden' name='record_num' value='<?php echo($record_num) ?>'>
<input type='hidden' name='contact_type' value='Primary'>
<br>
<br>
</td>
</tr>
</table>
</form>