| Current Path : /var/www/cesa.co.za/php/ |
| Current File : /var/www/cesa.co.za/php/inc_scecalendar.php |
<table width=100% cellspacing=0 cellpadding=2 class="smallfonts" id="tbl">
<thead>
<tr>
<th colspan=<?php echo $NumMonths + 2; ?> align=center class='locked' bgcolor="#325eab"><B style="color:white">Training Schedule, <?php echo date("M Y"); ?> - <?php echo date("M Y", strtotime("+ " . ($NumMonths - 1) . " months", strtotime(date("Y-m") . "-01"))); ?></b></th>
</tr>
<tr>
<th class='locked' bgcolor="#325eab" align=center><b style="color:white">Course</b></th>
<th class='locked' bgcolor="#325eab" align=center><strong style="color:white">CPD</strong></th>
<?php
$lastmonthShown = 0;
for ($z = date("n"); $z <= (date("n") + ($NumMonths - 1)); $z++) {
$usez = $z;
if ($usez > 12) $usez = $usez - 12;
echo "<th align=center class='locked' bgcolor='#325eab'><b style='color:white'>" . date("M", strtotime(date("Y") . "-" . $usez . "-01")) . "</b></th>";
$lastmonthShown = $usez;
}
?>
</tr>
</thead>
<tbody>
<?php
/*
$sql="SELECT * FROM SchoolWebCategories WHERE DisplayOrder>0";
if (isset($_REQUEST["cat"]) && !empty($_REQUEST["cat"])) $sql.=" AND WebCategoryID=".intval($_REQUEST["cat"]);
$sql.=" ORDER BY DisplayOrder";
$catrs=mysql_query($sql);
while ($catrow=mysql_fetch_assoc($catrs)) {
*/
$sql = "SELECT SchoolEvents.EventID, IF(ISNULL(SchoolCourses.CourseName),SchoolEvents.EventName,SchoolCourses.CourseName) AS EventName,
SchoolEvents.City, SchoolEvents.CostPerPerson,
IF(ISNULL(SchoolCourses.AccredNum), SchoolEvents.AccredNum, SchoolCourses.AccredNum) AS AccredNum, SchoolEvents.AccredNum AS EventAccredNum,
IF(ISNULL(SchoolCourses.CPD),SchoolEvents.CPD,SchoolCourses.CPD) AS CPD,
SchoolEvents.Cancelled, SchoolEvents.Venue,
CourseVenues.CourseVenueCity, SchoolWebCategories.WebCategoryName, MIN(EventSchedules.ScheduleDate) AS StartDate,
MAX(EventSchedules.ScheduleDate) AS EndDate
FROM ((SchoolEvents LEFT JOIN SchoolCourses USING (SchoolCourseID)
LEFT OUTER JOIN SchoolWebCategories ON (SchoolEvents.WebCategory=SchoolWebCategories.WebCategoryID OR SchoolCourses.WebCategory=SchoolWebCategories.WebCategoryID))
LEFT JOIN CourseVenues ON SchoolEvents.Venue = CourseVenues.CourseVenueName)
LEFT JOIN EventSchedules ON SchoolEvents.EventID=EventSchedules.EventID
WHERE Cancelled=0 AND (SchoolWebCategories.WebCategoryID IS NULL OR SchoolWebCategories.WebCategoryID<>11)";
if (isset($_REQUEST["cat"]) && !empty($_REQUEST["cat"])) $sql .= " AND SchoolWebCategories.WebCategoryID=" . intval($_REQUEST["cat"]);
$sql .= "
GROUP BY SchoolEvents.EventID, EventName, SchoolEvents.City, SchoolEvents.CostPerPerson,
AccredNum, CPD, SchoolEvents.Cancelled, SchoolEvents.Venue,
CourseVenues.CourseVenueCity, SchoolWebCategories.WebCategoryName
HAVING StartDate >= '" . date("Y-m-d") . "'
AND StartDate < '" . date("Y-m", strtotime("+ " . $NumMonths . " months", strtotime(date("Y-m") . "-01"))) . "-01'
ORDER BY EventName, Cancelled, AccredNum, CPD, StartDate";
$queryresult = mysql_query($sql) or die(mysql_error() . " " . $sql);
if (mysql_num_rows($queryresult) > 0) {
$i = 1;
$sLastEvent = "";
$iLastMonth = date("n") - 1;
$sThisRow = "";
$bShowCatHeading = (isset($_REQUEST["cat"]) && !empty($_REQUEST["cat"]));
while ($row = mysql_fetch_array($queryresult)) {
if ($bShowCatHeading) {
echo '<tr><td colspan="' . ($NumMonths + 2) . '" align="left" bgcolor="#6ba9d5" style="color:#325eab; text-align:center; font-size:12px" align=center><b>' . $row["WebCategoryName"] . '</b></td></tr>';
$bShowCatHeading = false;
}
$eventid = $row["EventID"];
$city = $row["City"];
$webcat = $row["WebCategoryName"];
if (empty($city)) $city = $row["CourseVenueCity"];
if (empty($city)) $city = $row["Venue"];
$startdate = $row["StartDate"];
$enddate = $row["EndDate"];
$sday = date("d", strtotime($startdate));
$syear = date("Y", strtotime($startdate));
$smonth = date("m", strtotime($startdate));
$eday = date("d", strtotime($enddate));
$eyear = date("Y", strtotime($enddate));
$emonth = date("m", strtotime($enddate));
$sEventInfo = $row["EventName"];
$sCPD = $row["CPD"];
// echo 'Please ignore debug info: ';
// var_dump($row["AccredNum"]);
if (strtolower($row["AccredNum"]) == 'tba') {
$row["AccredNum"] = $row["EventAccredNum"];
}
if ($row["Cancelled"] == 1) $sEventInfo .= " - CANCELLED";
if (!empty($row["AccredNum"])) $sEventInfo .= " (" . $row["AccredNum"] . ")";
//$sEventInfo .= "<br>";
//if (!empty($row["CPD"])) $sEventInfo .= $row["CPD"]." CPD point(s)";
if ($sLastEvent != $sEventInfo) {
if (!empty($sLastEvent)) {
if ($iLastMonth > 0) $sThisRow .= "</td>";
if ($iLastMonth > $lastmonthShown) {
for ($z = $iLastMonth + 1; $z <= 12; $z++) {
$sThisRow .= "<td><img src='/images/spacer.gif' width=30'></td>";
}
for ($z = 1; $z <= $lastmonthShown; $z++) {
$sThisRow .= "<td><img src='/images/spacer.gif' width=30'></td>";
}
} else {
for ($z = $iLastMonth + 1; $z <= $lastmonthShown; $z++) {
$sThisRow .= "<td><img src='/images/spacer.gif' width=30'></td>";
}
}
$sThisRow .= "</tr>
";
$sThisRow = str_replace("EVENTIDHERE", $lasteventid, $sThisRow);
echo $sThisRow;
}
$sThisRow = "<tr><td width=280>";
$sThisRow .= "<a href='/sce/school-course?id=EVENTIDHERE'><span class='eventname'>";
$sThisRow .= $sEventInfo;
$sThisRow .= "</span><br>";
$sThisRow .= "More Info</a>";
$sThisRow .= "</td><td align=center style='text-align:center !important'>" . $sCPD . "</td>";
$iLastMonth = date("n") - 1;
$sLastEvent = $sEventInfo;
if (($i % 10) == 0) {
?>
<tr>
<td class='locked'> </td>
<td class='locked'> </td>
<?php
$lastmonthShown = 0;
for ($z = date("n"); $z <= (date("n") + ($NumMonths - 1)); $z++) {
$usez = $z;
if ($usez > 12) $usez = $usez - 12;
echo "<td align=center class='locked'><b>" . date("M", strtotime(date("Y") . "-" . $usez . "-01")) . "</b></td>";
$lastmonthShown = $usez;
}
?>
</tr>
<?php
}
$i++;
}
if ($smonth != $iLastMonth) {
// starting in a new month
if ($iLastMonth > 0) echo "</td>";
// fill in the months before this
if ($iLastMonth > $smonth) {
for ($z = $iLastMonth + 1; $z <= 12; $z++) {
$sThisRow .= "<td><img src='/images/spacer.gif' width=30'></td>";
}
for ($z = 1; $z < $smonth; $z++) {
$sThisRow .= "<td><img src='/images/spacer.gif' width=30'></td>";
}
} else {
for ($z = $iLastMonth + 1; $z < $smonth; $z++) {
$sThisRow .= "<td><img src='/images/spacer.gif' width=30'></td>";
}
}
if ($emonth > $smonth) {
$sThisRow .= "<td nowrap colspan=" . ($emonth - $smonth) . " align=center style='text-align:center !important'>";
} else {
$sThisRow .= "<td nowrap align=center style='text-align:center !important'>";
}
} else {
$sThisRow .= "<hr>";
}
$sThisRow .= "<a href='/sce/school-event?id=" . $eventid . "'>" . $sday;
if (strtotime($enddate) > strtotime($startdate)) {
$sThisRow .= "-" . $eday;
}
$sThisRow .= " " . date("M", strtotime(date("Y") . "-" . $smonth . "-01"));
$sThisRow .= "<br><small>" . $city . "</small></a>";
if (!isset($_REQUEST["cat"]) || empty($_REQUEST["cat"])) $sThisRow .= "<br>" . $webcat;
$sThisRow .= "<br>";
if ($row["Cancelled"] == 0) {
$sThisRow .= "<a href='/sce/school-event-registration?id=" . $eventid . "'><u><i>Register Now</i></u></a>";
} else {
$sThisRow .= "Cancelled";
}
// $sThisRow .= "</td>"."\r\n";
$iLastMonth = $smonth;
if ($iLastMonth > 12) $iLastMonth = 1;
$lasteventid = $eventid;
}
if (!empty($sLastEvent)) {
if ($iLastMonth > 0) $sThisRow .= "</td>";
if ($iLastMonth > $lastmonthShown) {
for ($z = $iLastMonth + 1; $z <= 12; $z++) {
$sThisRow .= "<td> </td>";
}
for ($z = 1; $z <= $lastmonthShown; $z++) {
$sThisRow .= "<td> </td>";
}
} else {
for ($z = $iLastMonth + 1; $z <= $lastmonthShown; $z++) {
$sThisRow .= "<td> </td>";
}
}
$sThisRow .= "</tr>";
$sThisRow = str_replace("EVENTIDHERE", $lasteventid, $sThisRow);
echo $sThisRow;
}
}
//}
// if (isset($conni)) {
// mysql_close($conni);
// }
?>
</tbody>
</table>