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

139 lines
4.8 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$templatePageTitle = "";
$headerArgs = "";
$school_name = $school_record['school_name'];
unset($selected_month);
if (array_key_exists('selected_month',$_GET)) $selected_month = $_GET['selected_month'];
if (array_key_exists('selected_month',$_POST)) $selected_month = $_POST['selected_month'];
$current_month = date("F Y",time());
$start_date = date("Y-m-d",time());
$start_time = strtotime($start_date);
$end_date = date("Y-m-",$start_time) . date("t",$start_time);
$date_where = "and start_date <= '$end_date' and end_date >= '$start_date' ";
if (isset($selected_month)) {
if ($selected_month == 'all') {
$current_month = getLanguageText('TEXT-ALL-EVENTS');
$date_where = "and end_date >= '$start_date' ";
}
else {
$current_month = date("F Y",strtotime($selected_month));
$start_date = date("Y-m-01",strtotime($selected_month));
$start_time = strtotime($start_date);
$end_date = date("Y-m-",$start_time) . date("t",$start_time);
$date_where = "and start_date <= '$end_date' and end_date >= '$start_date' ";
}
}
$next_month = date("Y-m-01",strtotime(date("Y-m-15",$start_time)) + 60 * 60 * 24 * 20);
$prev_month = date("Y-m-01",strtotime(date("Y-m-01",$start_time)) - 100);
$next_month_name = date("F Y",strtotime($next_month));
$prev_month_name = date("F Y",strtotime($prev_month));
$templatePageTitle = $school_record['school_name'] . " " . getLanguageText('TEXT-EVENT-TITLE') . "<br>" .
"<a href='?action=events&selected_month=$prev_month'>&lt;&lt;&lt;</a>&nbsp;&nbsp;" .
$current_month .
"&nbsp;&nbsp;<a href='?action=events&selected_month=$next_month'>&gt;&gt;&gt;</a>";
// Get events for this school and month
$query = "select * from event_calendar " .
"where school_num = $school_num " .
"and status = 'Approved' " .
"and display = 'Active' " .
$date_where .
"order by start_date,end_date,title";
$events = db_query($query);
$count = 0;
if (db_num_rows($events) > 0) {
while ($row = db_fetch_array($events)) {
extract($row);
$bgclass = "data-odd";
if (($count % 2) == 0) $bgclass = "data-even";
$count++;
if ($posted_by == $_SESSION['UserInfo']['record_num']) $userid = "<a href='?action=events-post&naction=edit&id=$record_num'>$userid</a>";
$text = "";
if (strlen($date_and_time) > 0) $text .= "<b>Date :: $date_and_time</b><br>\n";
if (strlen($location) > 0) $text .= "<b>Location :: $location</b><br>\n";
if (strlen($description) > 0) $text .= "<hr>\n" . nl2br($description);
$hclass = 'heading';
?>
<table width='850' cellpadding='5' cellspacing='1' border='0' class='content-table'>
<tr>
<td align='left' class='<?php echo($hclass) ?>'>
<table width='100%' cellpadding='0' cellspacing='0' border='0'>
<tr>
<td valign='top' align='left' class='<?php echo($hclass) ?>'><?php echo($title) ?></td>
<td valign='top' align='right' class='<?php echo($hclass) ?>'><?php echo("$event_type") ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align='left' class='<?php echo($bgclass) ?>'>
<?php echo($text) ?>
</td>
</tr>
</table>
<br>
<?php
}
}
else {
?>
<table width='850' cellpadding='5' cellspacing='1' border='0'>
<tr>
<td class='success' align='center'><b>There are no events in the calendar for the selected month</b></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
<?php
}
?>
<table width='850' cellpadding='5' cellspacing='1' border='0'>
<tr>
<td align='right'>
<table cellpadding='0' cellspacing='0' border='0'>
<tr>
<td align='center'><a href='?action=events&selected_month=<?php echo($prev_month) ?>'>&lt;&lt; <?php echo($prev_month_name) ?></a></td>
<td align='left' width='20'>&nbsp;</td>
<td align='center'><a href='?action=events&selected_month=all'>View All Events</a></td>
<td width='20'>&nbsp;</td>
<td align='center'><a href='?action=events&selected_month=<?php echo($next_month) ?>'><?php echo($next_month_name) ?> &gt;&gt;</a></td>
<td width='50'>&nbsp;</td>
<td align='center'><a href='?action=events-post' class='btn btn--primary btn--xsmall'><span>Post an Event</span></a></td>
</tr>
</table>
</td>
</tr>
</table>
<!--
<br>
<?php include "get.adobe.php"; ?>
-->
<?php
endTemplate();
?>