190 lines
7.1 KiB
PHP
190 lines
7.1 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = $school_record['school_name'] . " " . getLanguageText('TEXT-EVENT-CALENDAR');
|
|
$headerArgs = "";
|
|
|
|
|
|
$school_name = $school_record['school_name'];
|
|
|
|
// Setup default values on insert
|
|
$today = date("Y-m-d",time());
|
|
$entry = array();
|
|
$entry['event_type'] = 'School Event';
|
|
$entry['today'] = date("Y-m-d",time());
|
|
$entry['start_date'] = $today;
|
|
$entry['end_date'] = $today;
|
|
$entry['dow'] = 'All';
|
|
$entry['posted_date'] = $today;
|
|
$entry['status'] = $school_record['default_event_status'];
|
|
$entry['display'] = 'Active';
|
|
$entry['posted_by'] = $_SESSION['UserInfo']['record_num'];
|
|
$entry['next_naction'] = 'insert';
|
|
$entry['record_num'] = 0;
|
|
|
|
$initTableName = "event_calendar";
|
|
$tarray = initializeTableArray($initTableName, $entry);
|
|
extract($tarray, EXTR_OVERWRITE);
|
|
|
|
unset($naction);
|
|
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
|
if (array_key_exists('id',$_GET)) $id = $_GET['id'];
|
|
|
|
if (isset($naction) && $naction == 'edit' && isset($id)) {
|
|
$query = "select * from event_calendar " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $id";
|
|
$results = db_query($query);
|
|
$row = db_fetch_array($results);
|
|
extract($row);
|
|
$next_naction = 'update';
|
|
}
|
|
|
|
?>
|
|
|
|
<br>
|
|
<form method='post' id='event-form' 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 displayLanguageText('TEXT-ENTER-EVENT'); ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' align='center'> </td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-EVENT-TYPE'); ?>: </td>
|
|
<td align='left' valign='top'>
|
|
<select name='event_type' id='event_type'>
|
|
<?php BuildDBList("event_types","event_type_title","event_type_title","sequence",$event_type,"ASC","AND school_num = $school_num") ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-START-DATE'); ?>: </td>
|
|
<td align='left' valign='top'>
|
|
<input type='text' name='start_date' id='start_date' value="<?php echo($start_date) ?>" size='15' class='date-field'> (<?php displayLanguageText('TEXT-REQUIRED'); ?>)
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'>End Date: </td>
|
|
<td align='left' valign='top'>
|
|
<input type='text' name='end_date' id='end_date' value="<?php echo($end_date) ?>" size='15' class='date-field'> (<?php displayLanguageText('TEXT-REQUIRED'); ?>)<br>
|
|
<span class='small'><?php displayLanguageText('TEXT-EVENT-END-DATE-MSG'); ?></span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-SELECTED-DAYS-OF-WEEK'); ?>: </td>
|
|
<td align='left' valign='top'>
|
|
<?php BuildFileCheckbox("daysoftheweek.txt","dow",explode(',',$dow)," ") ?>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' align='center'> </td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-EVENT-TITLE'); ?>: </td>
|
|
<td align='left' valign='top'>
|
|
<input type='text' name='title' id='title' value="<?php echo(str_replace('"',""",$title)) ?>" size='60'> (<?php displayLanguageText('TEXT-REQUIRED'); ?>)
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-EVENT-DATE-TIME'); ?>: </td>
|
|
<td align='left' valign='top'><input type='text' name='date_and_time' id='date_and_time' value="<?php echo(str_replace('"',""",$date_and_time)) ?>" size='50'></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-EVENT-LOCATION'); ?>: </td>
|
|
<td align='left' valign='top'><input type='text' name='location' id='location' value="<?php echo(str_replace('"',""",$location)) ?>" size='50'></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 colspan='2' align='center'> </td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-DISPLAY'); ?>: </td>
|
|
<td align='left' valign='top'><?php BuildFileRadio("event_display_mode.txt","display",$display) ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-STATUS'); ?>: </td>
|
|
<td align='left' valign='top'><?php echo($status) ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' align='center'>
|
|
<br>
|
|
<?php
|
|
if (!isset($next_naction)) $next_naction = '';
|
|
if (!isset($record_num)) $record_num = 0;
|
|
?>
|
|
<input type='submit' name='button' id='save-event' class='btn btn--primary' value="<?php displayLanguageText('TEXT-ADD-EVENT'); ?>">
|
|
<input type='hidden' name='record_num' id='record_num' value='<?php echo($record_num) ?>'>
|
|
<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_date' value="<?php echo($posted_date) ?>">
|
|
<input type='hidden' name='status' value="<?php echo($status) ?>">
|
|
<input type='hidden' name='csrf_token' value="<?php echo($_SESSION['csrf_token']) ?>">
|
|
<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
<?php include "get.adobe.php"; ?>
|
|
|
|
<script>
|
|
$(document).ready(function(){
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
$("#save-event").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var sdate = $("#start_date").val();
|
|
var edate = $("#end_date").val();
|
|
var title = $("#title").val();
|
|
var record_num = $("#record_num").val();
|
|
|
|
if (sdate.length == 0 || edate.length == 0 || title.length == 0) {
|
|
alert("<?php displayLanguageText('ERRORMSG-MISSING-FORM-DATA'); ?>");
|
|
}
|
|
|
|
var formdata = $("#event-form").serialize();
|
|
var data = formdata+"&table_name=event_calendar&sequence_flag=N&record_num="+record_num;
|
|
$.ajax({
|
|
url: "ajax.DataRecord.Update.php",
|
|
data: data,
|
|
type: 'POST',
|
|
dataType: "json"
|
|
}).done(
|
|
function(results) {
|
|
if (results.ajax_return_code != 0) {
|
|
alert(results.ajax_return_msg);
|
|
return;
|
|
}
|
|
|
|
location.href = '?action=events-calendar';
|
|
}
|
|
);
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
<?php
|
|
endTemplate();
|
|
?>
|