|
|
|
|
|
|
|
|
|
\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 .= "" . $otipTABLE .
sprintf($otipROW1,'left',"" . $row['menu_title'] . "");
$otipSpans .= "
\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 = "";
$espan = "";
}
$eventsText .= " $sspan" . $row['menu_title'] . "$espan
\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 .= "" . $otipWideTABLE .
sprintf($otipROW1,'left',"" . $row['title'] . "") .
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 .= "\n";
$otipSpanIDs[] = $span_id;
}
if (strlen($eventsText)) $eventsText .= "
\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 = "";
$espan = "";
}
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 .= " $sspan" . $row['title'] . "$espan
\n";
}
else {
$eventsText .= " $sspan" . $row['title'] . "$espan
\n";
}
}
}
if ($calendarDate == $Today) $bgclass .= " todayCell";
echo(" \n");
echo(" $date \n");
echo("$eventsText");
echo(" | \n");
}
echo(" \n");
}
?>