221 lines
10 KiB
PHP
221 lines
10 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
$school_name = $school_record['school_name'];
|
|
|
|
|
|
unset($selected_month);
|
|
$selected_month = date("Y-m-01",time());
|
|
if (array_key_exists('selected_month',$_GET)) $selected_month = $_GET['selected_month'];
|
|
if (array_key_exists('selected_month',$_POST)) $selected_month = $_POST['selected_month'];
|
|
if (array_key_exists('mode',$_POST)) $mode = $_POST['mode'];
|
|
if (strlen($selected_month) == 7) $selected_month .= "-01";
|
|
|
|
$selected_month_time = strtotime($selected_month);
|
|
$next_month = date("Y-m-01",$selected_month_time + 60 * 60 * 24 * 35);
|
|
$prev_month = date("Y-m-01",$selected_month_time - 100);
|
|
|
|
$curr_month_name = date("F Y",$selected_month_time);
|
|
$next_month_name = date("F Y",strtotime($next_month));
|
|
$prev_month_name = date("F Y",strtotime($prev_month));
|
|
|
|
$currentMonth = date("Y-m",$selected_month_time);
|
|
$previousMonth = date("Y-m",$selected_month_time - 100);
|
|
$nextMonth = date("Y-m",$selected_month_time + 60 * 60 * 24 * 35);
|
|
|
|
$selectedMonthDays = date("t",$selected_month_time);
|
|
$previousMonthDays = date("t",strtotime($prev_month));
|
|
$selectedMonthStartDay = date("w",$selected_month_time);
|
|
|
|
$currMonthDate = 0;
|
|
$nextMonthDate = 0;
|
|
|
|
$Today = date("Y-m-d",time());
|
|
|
|
|
|
// Start the template and output buffering
|
|
if (!isset($mode) || $mode = 'print') startTemplate();
|
|
$templatePageTitle = getLanguageText('TEXT-EVENT-CALENDAR') . " - $curr_month_name";
|
|
|
|
|
|
?>
|
|
<br>
|
|
<table width='900' cellpadding='1' cellspacing='1' border='0' class='Calendar'>
|
|
<tr>
|
|
<td align='center' colspan='7'>
|
|
<table width='100%' cellpadding='0' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='left'><a href='?action=<?php echo($action) ?>&selected_month=<?php echo($previousMonth) ?>' class='monthlink'><<< <?php echo($prev_month_name) ?></a></td>
|
|
<td align='center'><b><?php echo($curr_month_name) ?></b></td>
|
|
<td align='right'><a href='?action=<?php echo($action) ?>&selected_month=<?php echo($nextMonth) ?>' class='monthlink'><?php echo($next_month_name) ?> >>></a></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<tr class="dayNamesText">
|
|
<td align='center' class="dayNamesCell" width="14%"><?php displayLanguageText('TEXT-SUNDAY'); ?></td>
|
|
<td align='center' class="dayNamesCell" width="14%"><?php displayLanguageText('TEXT-MONDAY'); ?></td>
|
|
<td align='center' class="dayNamesCell" width="14%"><?php displayLanguageText('TEXT-TUESDAY'); ?></td>
|
|
<td align='center' class="dayNamesCell" width="14%"><?php displayLanguageText('TEXT-WEDNESDAY'); ?></td>
|
|
<td align='center' class="dayNamesCell" width="14%"><?php displayLanguageText('TEXT-THURSDAY'); ?></td>
|
|
<td align='center' class="dayNamesCell" width="14%"><?php displayLanguageText('TEXT-FRIDAY'); ?></td>
|
|
<td align='center' class="dayNamesCell" width="14%"><?php displayLanguageText('TEXT-SATURDAY'); ?></td>
|
|
</tr>
|
|
<?php
|
|
$otipSpans = "";
|
|
$otipSpanIDs = array();
|
|
|
|
// Display calendar dates
|
|
for ($week = 0; $week < 6; $week++) {
|
|
echo(" <tr class='calendarRow'>\n");
|
|
|
|
for ($day = 0; $day < 7; $day++) {
|
|
if ($week == 0 && $day < $selectedMonthStartDay) {
|
|
$date = $previousMonthDays + $day - $selectedMonthStartDay + 1;
|
|
$calendarDate = $previousMonth . sprintf("-%02d",$date);
|
|
$bgclass = "otherMonthCell";
|
|
}
|
|
else {
|
|
$currMonthDate++;
|
|
|
|
if ($currMonthDate <= $selectedMonthDays) {
|
|
$date = $currMonthDate;
|
|
$calendarDate = $currentMonth . sprintf("-%02d",$date);
|
|
$bgclass = "currentMonthCell";
|
|
}
|
|
else {
|
|
$nextMonthDate++;
|
|
$date = $nextMonthDate;
|
|
$calendarDate = $nextMonth . sprintf("-%02d",$date);
|
|
$bgclass = "otherMonthCell";
|
|
}
|
|
}
|
|
|
|
// Check if there is a hot lunch for this date
|
|
$eventsText = "";
|
|
$query = "SELECT hlmd.menu_title,hlmd.record_num FROM hotlunch_menu_dates AS hlmd, hotlunch_schedules AS hls " .
|
|
"WHERE hlmd.schedule_num = hls.record_num " .
|
|
"AND hls.school_num = $base_school_num " .
|
|
"AND hls.schedule_type = 'Hot Lunch' " .
|
|
"AND hls.status IN ('Active','Completed','Closed') " .
|
|
"AND hls.display_on_calendar = 'Y' " .
|
|
"AND hlmd.school_num = $base_school_num " .
|
|
"AND hlmd.menu_date = '$calendarDate'";
|
|
$hotlunch_dates = db_query($query);
|
|
if (db_num_rows($hotlunch_dates)) {
|
|
while ($row = db_fetch_array($hotlunch_dates)) {
|
|
$rnum = $row['record_num'];
|
|
$span_id = "hl_$rnum";
|
|
if (!in_array($span_id,$otipSpanIDs)) {
|
|
$otipSpans .= "<span id='$span_id'>" . $otipTABLE .
|
|
sprintf($otipROW1,'left',"<b>" . $row['menu_title'] . "</b>");
|
|
$otipSpans .= "</table></span>\n";
|
|
$otipSpanIDs[] = $span_id;
|
|
}
|
|
|
|
// Handle event type colors
|
|
$sspan = "";
|
|
$espan = "";
|
|
|
|
$event_type = "Hot Lunch";
|
|
$results = db_query("SELECT * FROM event_types WHERE school_num = $base_school_num AND event_type_title = '" . db_escape_string($event_type) . "'");
|
|
if (db_num_rows($results) > 0) {
|
|
$erow = db_fetch_array($results);
|
|
$sspan = "<span style='color: #" . $erow['text_color'] . "; background-color: #" . $erow['bg_color'] . ";'>";
|
|
$espan = "</span>";
|
|
}
|
|
|
|
$eventsText .= " <span class='calendarEvent'><a href=\"javascript:TagToTip('$span_id')\" onmouseover=\"TagToTip('$span_id')\" " .
|
|
"onmouseout=\"UnTip()\">$sspan" . $row['menu_title'] . "$espan</a><span><br>\n";
|
|
}
|
|
}
|
|
|
|
|
|
// Get events for this date
|
|
$dow = date('D',strtotime($calendarDate));
|
|
$query = "select * from event_calendar " .
|
|
"where school_num = $base_school_num " .
|
|
"and status = 'Approved' " .
|
|
"and display = 'Active' " .
|
|
"and start_date <= '$calendarDate' and '$calendarDate' <= end_date " .
|
|
"and (dow LIKE '%All%' OR dow LIKE '%$dow%') " .
|
|
"order by start_date,end_date,title";
|
|
$events = db_query($query);
|
|
|
|
if (db_num_rows($events)) {
|
|
while ($row = db_fetch_array($events)) {
|
|
$rnum = $row['record_num'];
|
|
$span_id = "event_$rnum";
|
|
|
|
if (!in_array($span_id,$otipSpanIDs)) {
|
|
$date_and_time = $row['date_and_time'];
|
|
if (strlen($date_and_time) == 0) {
|
|
$date_and_time = date($school_record['date_format'],strtotime($row['start_date']));
|
|
if ($row['start_date'] != $row['end_date']) $date_and_time .= " - " . date($school_record['date_format'],strtotime($row['end_date']));
|
|
}
|
|
if (strlen($date_and_time) < 6) $date_and_time = date($school_record['date_format'],strtotime($row['start_date'])) . " @ $date_and_time";
|
|
|
|
$otipSpans .= "<span id='$span_id'>" . $otipWideTABLE .
|
|
sprintf($otipROW1,'left',"<b>" . $row['title'] . "</b>") .
|
|
sprintf($otipROW1,'left',$date_and_time);
|
|
if (strlen($row['location'])) $otipSpans .= sprintf($otipROW1,'left',$row['location']);
|
|
if (strlen($row['description'])) $otipSpans .= sprintf($otipROW1,'left',$row['description']);
|
|
$otipSpans .= "</table></span>\n";
|
|
$otipSpanIDs[] = $span_id;
|
|
}
|
|
if (strlen($eventsText)) $eventsText .= "<hr>\n";
|
|
|
|
// Handle event type colors
|
|
$sspan = "";
|
|
$espan = "";
|
|
|
|
$event_type = $row['event_type'];
|
|
$results = db_query("SELECT * FROM event_types WHERE school_num = $base_school_num AND event_type_title = '" . db_escape_string($event_type) . "'");
|
|
if (db_num_rows($results) > 0) {
|
|
$erow = db_fetch_array($results);
|
|
$sspan = "<span style='color: #" . $erow['text_color'] . "; background-color: #" . $erow['bg_color'] . ";'>";
|
|
$espan = "</span>";
|
|
}
|
|
|
|
if (array_key_exists('UserInfo',$_SESSION) && array_key_exists('type',$_SESSION['UserInfo']) &&
|
|
in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Administration Team'))) {
|
|
$eventsText .= " <span class='calendarEvent'><a href='?action=events-admin&naction=edit&record_num=$rnum' " .
|
|
"onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\">$sspan" . $row['title'] . "$espan</a></span><br>\n";
|
|
}
|
|
else {
|
|
$eventsText .= " <span class='calendarEvent'><a href=\"javascript:TagToTip('$span_id')\" " .
|
|
"onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\">$sspan" . $row['title'] . "$espan</a></span><br>\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($calendarDate == $Today) $bgclass .= " todayCell";
|
|
|
|
echo(" <td align='left' class='$bgclass'>\n");
|
|
echo(" $date<br>\n");
|
|
echo("$eventsText");
|
|
echo(" </td>\n");
|
|
}
|
|
echo(" </tr>\n");
|
|
}
|
|
?>
|
|
</table>
|
|
<br>
|
|
<?php if (SessionActive() == 1 && UserLoggedIn() && (!array_key_exists('mode', $_GET) || $_GET['mode'] != 'print')) { ?>
|
|
<table cellpadding='5' border='0'>
|
|
<tr>
|
|
<?php if (!in_array($_SESSION['UserInfo']['type'],array('Parent','Guest','Customer','Staff')) || $school_record['can_parents_post_events'] != 'N') { ?>
|
|
<td align='center'><a href='?action=events-post' class='btn btn--primary btn--xsmall'><?php displayLanguageText('TEXT-POST-AN-EVENT'); ?></a></td>
|
|
<?php } ?>
|
|
<td align='center'><a href='?action=events-calendar&selected_month=<?php echo($selected_month) ?>&mode=print' class='btn btn--primary btn--xsmall'><?php displayLanguageText('TEXT-PRINTABLE-CALENDAR'); ?></a></td>
|
|
</tr>
|
|
</table>
|
|
<?php } ?>
|
|
<?php
|
|
if (array_key_exists('mode',$_GET) && $_GET['mode'] == 'print') {
|
|
$noBackground = true;
|
|
endTemplate('blank.html');
|
|
}
|
|
else endTemplate();
|
|
?>
|