| Current Path : /var/www/cesa.co.za/php/ |
| Current File : /var/www/cesa.co.za/php/scelist.php |
<?php
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/inc_db.php");
$NumMonths = 2;
if (isset($_REQUEST["NumMonths"]) && !empty($_REQUEST["NumMonths"])) {
if ($_REQUEST["NumMonths"] == "y") {
$NumMonths = 13 - date("m");
} else {
$NumMonths = intval($_REQUEST["NumMonths"]);
}
}
?>
<script>
jQuery(document).ready(function() {
jQuery("#myInput").on("keyup", function() {
var value = jQuery(this).val().toLowerCase();
jQuery("#tbl tbody tr").filter(function() {
jQuery(this).toggle(jQuery(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>
<h1>Upcoming Courses</h1>
<form method="get" action="https://www.cesa.co.za/sce/course-list/">
<p><b>Show courses available in:</b></p>
<table border="0">
<tr>
<td>
<input type="radio" name="NumMonths" value="1" onclick="this.form.submit()" <?php if ($NumMonths == 1) echo " checked"; ?>> This month<br>
<input type="radio" name="NumMonths" value="2" onclick="this.form.submit()" <?php if ($NumMonths == 2) echo " checked"; ?>> Next 2 months
</td>
<td>
<input type="radio" name="NumMonths" value="3" onclick="this.form.submit()" <?php if ($NumMonths == 3) echo " checked"; ?>> Next 3 months<br>
<input type="radio" name="NumMonths" value="6" onclick="this.form.submit()" <?php if ($NumMonths == 6) echo " checked"; ?>> Next 6 months
</td>
<td>
<input type="radio" name="NumMonths" value="y" onclick="this.form.submit()" <?php if ($_REQUEST["NumMonths"] == "y") echo " checked"; ?>> This year
</td>
</tr>
</table>
</form>
<input type="text" name="quicksearch" id="myInput" placeholder="Enter keywords to search the courses" size="40" class="printhide"><br>
<?php
// $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)
// INNER JOIN SchoolWebCategories ON (SchoolEvents.WebCategory=SchoolWebCategories.WebCategoryID)
// LEFT JOIN EventSchedules ON SchoolEvents.EventID=EventSchedules.EventID
// WHERE Cancelled=0
// AND SchoolWebCategories.DisplayOrder>0
// 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 ";
// if ($_REQUEST["sort"] == "EventName") {
// $sql .= " EventName, StartDate";
// } else {
// $sql .= " StartDate, EventName";
// }
$sql = "SELECT SchoolEvents.SchoolCourseID, 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,
IF(ISNULL(SchoolCourses.CPD),SchoolEvents.CPD,SchoolCourses.CPD) AS CPD,
SchoolEvents.SACPCMPNum, SchoolEvents.SACPCMPCategory, SchoolEvents.SACPCMP_CPDPoints,
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))
LEFT JOIN CourseVenues ON SchoolEvents.Venue = CourseVenues.CourseVenueName)
LEFT JOIN EventSchedules ON SchoolEvents.EventID=EventSchedules.EventID
WHERE Cancelled=0
AND (SchoolEvents.WebCategory != 11 OR SchoolEvents.WebCategory IS NULL)
AND (SchoolCourses.WebCategory != 11 OR SchoolCourses.WebCategory IS NULL)
GROUP BY SchoolEvents.SchoolCourseID, SchoolEvents.EventID, SchoolEvents.EventName, SchoolEvents.City,
SchoolEvents.CostPerPerson,
SchoolEvents.AccredNum, SchoolEvents.CPD, SchoolEvents.SACPCMPNum, SchoolEvents.SACPCMPCategory, SchoolEvents.SACPCMP_CPDPoints, 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 ";
if ($_REQUEST["sort"] == "EventName") {
$sql .= " EventName, StartDate";
} else {
$sql .= " StartDate, EventName";
}
echo '<!-- ' . $sql . ' -->';
$queryresult = mysql_query($sql) or die(mysql_error() . " " . $sql);
if (mysql_num_rows($queryresult) > 0) {
?>
<table border="1" cellspacing="0" cellpadding="5" width="100%" id="tbl">
<thead>
<tr>
<td bgcolor="#375ead" style="color:white">Course Description<br><br><a href="https://www.cesa.co.za/sce/course-list/?NumMonths=<?php echo $_REQUEST["NumMonths"]; ?>&sort=EventName" style="color:white; font-size:10px">Sort by course</a></td>
<td bgcolor="#375ead" style="color:white">SACPCMP CPD</td>
<td bgcolor="#375ead" style="color:white">CPD</td>
<td bgcolor="#375ead" style="color:white">Venue</td>
<td bgcolor="#375ead" style="color:white">Date/s<br>(<?php echo date("Y"); ?>)<br>
<a href="https://www.cesa.co.za/sce/course-list/?NumMonths=<?php echo $_REQUEST["NumMonths"]; ?>&sort=StartDate" style="color:white; font-size:10px">Sort by date</a>
</td>
<td bgcolor="#375ead" style="color:white"> </td>
</tr>
</thead>
<tbody>
<?php
while ($row = mysql_fetch_assoc($queryresult)) {
?>
<tr>
<td><a href="https://www.cesa.co.za/sce/school-course?id=<?php echo $row["EventID"]; ?>"><?php echo $row["EventName"]; ?></a></td>
<td align="center"><?php echo !empty($row["SACPCMP_CPDPoints"]) ? $row["SACPCMP_CPDPoints"] : '-'; ?></td>
<td align="center"><?php echo $row["CPD"]; ?></td>
<td><?php echo $row["Venue"] . ", " . $row["CourseVenueCity"]; ?></td>
<td nowrap="nowrap"><?php
echo date("d F", strtotime($row["StartDate"]));
if ($row["EndDate"] != $row["StartDate"])
echo "<br>to<br>" . date("d F", strtotime($row["EndDate"]));
?>
</td>
<td nowrap="nowrap"><a href="https://www.cesa.co.za/sce/school-course?id=<?php echo $row["EventID"]; ?>">More Info</a><br>
<a href="https://www.cesa.co.za/sce/school-event-registration?id=<?php echo $row["EventID"]; ?>">Register Now</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
} else {
echo "No results found";
}
mysql_close();
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/templates/inc_footer.php");