| Current Path : /var/www/cesa.co.za/php/ |
| Current File : /var/www/cesa.co.za/php/inc_scecalendar_backup.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, SchoolEvents.EventName, SchoolEvents.City, SchoolEvents.CostPerPerson,
SchoolEvents.AccredNum, SchoolEvents.CPD, SchoolEvents.Cancelled, SchoolEvents.Venue,
CourseVenues.CourseVenueCity, MIN(EventSchedules.ScheduleDate) AS StartDate,
MAX(EventSchedules.ScheduleDate) AS EndDate
FROM (SchoolEvents LEFT JOIN CourseVenues ON SchoolEvents.Venue = CourseVenues.CourseVenueName)
LEFT JOIN EventSchedules ON SchoolEvents.EventID=EventSchedules.EventID
WHERE Cancelled=0 AND WebCategory<>11";
if (isset($_REQUEST["cat"]) && !empty($_REQUEST["cat"])) $sql.=" AND WebCategoryID=".intval($_REQUEST["cat"]);
$sql.="
GROUP BY SchoolEvents.EventID, SchoolEvents.EventName, SchoolEvents.City, SchoolEvents.CostPerPerson,
SchoolEvents.AccredNum, SchoolEvents.CPD, SchoolEvents.Cancelled, SchoolEvents.Venue,
CourseVenues.CourseVenueCity
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) {
// echo '<tr><td colspan="'.($NumMonths+2).'" align="left" bgcolor="#6ba9d5" style="color:#325eab"><b>'.$catrow["WebCategoryName"].'</b></td></tr>';
$i=1;
$sLastEvent = "";
$iLastMonth = date("n")-1;
$sThisRow = "";
while ($row = mysql_fetch_array($queryresult)) {
$eventid = $row["EventID"];
$city = $row["City"];
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"];
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='/node/110?id=EVENTIDHERE'><span class='eventname'>";
$sThisRow .= $sEventInfo;
$sThisRow .= "</span><br>";
$sThisRow .= "More Info</a> ";
$sThisRow .= "</td><td align=center>".$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>";
} else {
$sThisRow .= "<td nowrap align=center>";
}
} else {
$sThisRow .= "<hr>";
}
$sThisRow .= "<a href='/node/111?id=".$eventid."'>".$sday;
if (strtotime($enddate) > strtotime($startdate)) {
$sThisRow .= "-".$eday;
}
$sThisRow.=" ".date("M", strtotime(date("Y")."-".$smonth."-01"));
$sThisRow .= "<br><small>".$city."</small></a><br>";
if ($row["Cancelled"] == 0) {
$sThisRow .= "<a href='/node/112?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;
}
}
//}
?>
</tbody>
</table>