| Current Path : /var/www/cesa.co.za/php/includes/ |
| Current File : /var/www/cesa.co.za/php/includes/SchoolCourses.php |
<?php
/*
* Contact otto@igotafrica.com for details
*/
include_once($_SERVER['DOCUMENT_ROOT'] . '/php/includes/BaseTableClass.php');
/**
* Class for control of SchoolCourses
*
* @author otto
*/
class SchoolCourses extends BaseTableClass
{
public function checkCreateTable() {
$tableCreateSQL = "DROP TABLE IF EXISTS `SchoolCourses`;
CREATE TABLE IF NOT EXISTS `SchoolCourses` (
`SchoolCourseID` int(11) NOT NULL AUTO_INCREMENT,
`CourseName` varchar(255) DEFAULT NULL,
`Level` varchar(255) DEFAULT NULL,
`CPD` varchar(50) DEFAULT NULL,
`AccredNum` varchar(255) DEFAULT NULL,
`CourseDescription` longtext DEFAULT NULL,
`FileAttachment` varchar(255) DEFAULT NULL,
`WebCategory` int(11) DEFAULT NULL,
`Hours` int(11) DEFAULT NULL,
`NQFLevel` varchar(50) DEFAULT NULL,
`Category` varchar(50) DEFAULT NULL,
`SACPCMPNum` varchar(255) DEFAULT NULL,
`OtherCPDPoints` decimal(10,2) DEFAULT NULL,
`AccredNum2` varchar(255) DEFAULT NULL,
`CourseType` varchar(255) DEFAULT NULL,
`DescOverview` longtext DEFAULT NULL,
`DescWhyAttend` longtext DEFAULT NULL,
`DescOutcomes` longtext DEFAULT NULL,
`DescObjectives` longtext DEFAULT NULL,
`DescProgram` longtext DEFAULT NULL,
`DescWhoAttend` longtext DEFAULT NULL,
`FacilitatorID` int(11) DEFAULT NULL,
`CurrentlyOffered` tinyint(1) NOT NULL DEFAULT 1,
`ProviderID` int(11) DEFAULT NULL,
`AdvertInfo` longtext DEFAULT NULL,
`TrainingProviderID` int(11) DEFAULT NULL,
`TempDescOverview` longtext DEFAULT NULL,
`TempDescWhyAttend` longtext DEFAULT NULL,
`TempDescOutcomes` longtext DEFAULT NULL,
`TempDescProgram` longtext DEFAULT NULL,
`TempDescWhoAttend` longtext DEFAULT NULL,
`AcceptTemp` char(1) NOT NULL DEFAULT '',
`Testimonials` longtext DEFAULT NULL,
`NonCPDCourse` tinyint(1) NOT NULL DEFAULT 0,
`Archived` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`SchoolCourseID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;";
}
public function findById($courseId)
{
global $conni;
$sql = "SELECT * FROM SchoolCourses WHERE SchoolCourseID = " . mysqli_real_escape_string($conni, $courseId);
return $this->sqlf->getRow($sql);
}
/**
* Find course by exact course name
* @param string $courseName
* @return array|false
*/
public function findByCourseName($courseName) {
global $conni;
$courseName = mysqli_real_escape_string($conni, $courseName);
$sql = "SELECT * FROM SchoolCourses WHERE CourseName = '" . $courseName . "' AND (Archived = 0 OR Archived IS NULL) AND CurrentlyOffered = 1 LIMIT 1";
return $this->sqlf->getRow($sql);
}
/**
* Get select list array for courses
* @return array
*/
public function getSelectList($fromYear = 0) {
$sql = "SELECT SchoolCourseID, CourseName FROM SchoolCourses WHERE (Archived = 0 OR Archived IS NULL) ";
if ($fromYear > 0) {
$sql .= " AND SchoolCourses.SchoolCourseID IN (SELECT SchoolCourseID FROM SchoolEvents WHERE YEAR(StartDate) >= " . intval($fromYear) . ")";
}
$sql .= " ORDER BY CourseName";
$result = $this->sqlf->getAll($sql);
$courses = array();
if (is_array($result)) {
foreach ($result as $row) {
$courses[$row['CourseName']] = $row['SchoolCourseID'];
}
}
return $courses;
}
}
function SchoolCoursesPageLoad($objThis)
{
if (!isset($_REQUEST['z_Archived'])) {
$_REQUEST['z_Archived'] = '=';
}
if (!isset($_REQUEST['x_Archived'])) {
$_REQUEST['x_Archived'] = '0';
}
if (!isset($_GET['z_Archived'])) {
$_GET['z_Archived'] = '=';
}
if (!isset($_GET['x_Archived'])) {
$_GET['x_Archived'] = '0';
}
}