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

148 lines
5.4 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Setup default values on insert
if ($naction == 'add' || $next_naction == 'insert') {
$initTableName = $CurrentTable;
$tarray = initializeTableArray($initTableName);
extract($tarray, EXTR_OVERWRITE);
$status = $school_record['default_classified_status'];
$posted_by = $_SESSION['UserInfo']['record_num'];
$posted_time = time();
$post_until_date = date("Y-m-d",time() + 60 * 60 * 24 * $school_record['classified_duration']);
$PageTitle = "Add a New Classified Ad";
$next_naction = "insert";
}
?>
<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'>
<br>
<?php
$text_data = trim(db_getVal("SELECT text_data FROM text_data WHERE school_num = $school_num AND text_id = 'Classified Message'"));
if (strlen($text_data)) echo("<span class='message'>" . nl2br($text_data) . "</span><br>\n<br>\n");
?>
</td>
</tr>
<tr>
<td width='35%' align='right' valign='top'><?php displayLanguageText('TEXT-CATEGORY'); ?>: </td>
<td width='65%' align='left' valign='top'>
<select name='subcategory_num'>
<option value=''><?php displayLanguageText('TEXT-SELECT-CATEGORY'); ?></option>
<?php
$query = "select category,subcategory,sc.record_num " .
"from classified_categories as cc, classified_subcategories as sc " .
"where sc.category_num = cc.record_num " .
"order by 1,2";
$results = db_query($query);
$prev_cat = "";
while ($row = db_fetch_array($results)) {
$category = $row['category'];
$subcategory = $row['subcategory'];
$rnum = $row['record_num'];
if ($prev_cat != $category) {
if ($prev_cat != "") echo(" </optgroup>\n");
echo(" <optgroup label='$category'>\n");
$prev_cat = $category;
}
$selected = "";
if ($rnum == $subcategory_num) $selected = " selected='selected'";
echo(" <option value='$rnum'$selected>$subcategory</option>\n");
}
echo(" </optgroup>\n");
?>
</select>
</td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-TITLE'); ?>: </td>
<td align='left' valign='top'><input type='text' name='title' id='title' value="<?php echo(str_replace('"',"&quot;",$title)) ?>" size='70'></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-DESCRIPTION'); ?>: </td>
<td align='left' valign='top'><textarea name='description' rows='6' cols='70'><?php echo($description) ?></textarea></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-CONTACT-INFORMATION'); ?>: </td>
<td align='left' valign='top'><input type='text' name='contact_info' id='contact_info' value="<?php echo($contact_info) ?>" size='50'></td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-EMAIL-ADDRESS'); ?>: </td>
<td align='left' valign='top'><input type='text' name='contact_email' id='contact_email' value="<?php echo($contact_email) ?>" size='50'></td>
</tr>
<?php if ($_SESSION['UserInfo']['type'] != 'Parent') { ?>
<tr>
<td align='left' colspan='2'>&nbsp;</td>
</tr>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-STATUS'); ?>: </td>
<td align='left' valign='top'>
<select name='status'>
<?php BuildFileList("event_status.txt",$status) ?>
</select>
</td>
</tr>
<?php } ?>
<tr>
<td align='right' valign='top'><?php displayLanguageText('TEXT-END-DATE'); ?>: </td>
<?php if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Administration Team'))) { ?>
<td align='left' valign='top'><input type='text' name='post_until_date' id='post_until_date' value="<?php echo($post_until_date) ?>" size='12' class='date-field'></td>
<?php } else { ?>
<td align='left' valign='top'><?php echo($post_until_date) ?></td>
<?php } ?>
</tr>
<tr>
<td colspan='2' align='center'>
<br>
<input type='submit' class='btn btn--primary' value="<?php echo($ButtonText) ?>">
<?php if ($_SESSION['UserInfo']['type'] != 'Parent') { ?>
<input type='hidden' name='action' value='<?php echo($action) ?>'>
<input type='hidden' name='naction' value='<?php echo($next_naction) ?>'>
<input type='hidden' name='posted_by' value="<?php echo($posted_by) ?>">
<input type='hidden' name='posted_time' value="<?php echo($posted_time) ?>" size='15'>
<?php } else { ?>
<input type='hidden' name='action' value='classified-post'>
<input type='hidden' name='naction' value='<?php echo($naction) ?>'>
<input type='hidden' name='status' value="<?php echo($status) ?>">
<?php } ?>
<input type='hidden' name='record_num' value='<?php echo($record_num) ?>'>
<br>
<br>
</td>
</tr>
<tr>
<td></td>
<td align='right'>
<table>
<tr>
<td align='left' width='65%'>&nbsp;</td>
<td align='left'><a href='/?action=support-request' class='btn btn--primary btn--xsmall'>Suggest a Category</a></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<p></p>