Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/cstPaymentsinfo.php

<?php

// Global variable for table object
$cstPayments = NULL;

//
// Table class for cstPayments
//
class ccstPayments {
	var $TableVar = 'cstPayments';
	var $TableName = 'cstPayments';
	var $TableType = 'CUSTOMVIEW';
	var $StartDate;
	var $EndDate;
	var $Delegate;
	var $Organisation;
	var $EmailAddress;
	var $InvoiceNo;
	var $AmountDue;
	var $AmountPaid;
	var $DatePaid;
	var $CreditNoteNo;
	var $CCECourseID;
	var $CCECourseName;
	var $StudentID;
	var $Telephone;
	var $Cellphone;
	var $fields = array();
	var $UseTokenInUrl = EW_USE_TOKEN_IN_URL;
	var $Export; // Export
	var $ExportOriginalValue = EW_EXPORT_ORIGINAL_VALUE;
	var $ExportAll = TRUE;
	var $SendEmail; // Send email
	var $TableCustomInnerHtml; // Custom inner HTML
	var $BasicSearchKeyword; // Basic search keyword
	var $BasicSearchType; // Basic search type
	var $CurrentFilter; // Current filter
	var $CurrentOrder; // Current order
	var $CurrentOrderType; // Current order type
	var $RowType; // Row type
	var $CssClass; // CSS class
	var $CssStyle; // CSS style
	var $RowAttrs = array(); // Row custom attributes
	var $TableFilter = "";
	var $CurrentAction; // Current action
	var $UpdateConflict; // Update conflict
	var $EventName; // Event name
	var $EventCancelled; // Event cancelled
	var $CancelMessage; // Cancel message

	//
	// Table class constructor
	//
	function __construct() {
		global $Language;

		// StartDate
		$this->StartDate = new cField('cstPayments', 'cstPayments', 'x_StartDate', 'StartDate', 'CCECourseSchedules.StartDate', 133, 5, FALSE, 'CCECourseSchedules.StartDate', FALSE);
		$this->StartDate->FldDefaultErrMsg = str_replace("%s", "/", $Language->Phrase("IncorrectDateYMD"));
		$this->fields['StartDate'] =& $this->StartDate;

		// EndDate
		$this->EndDate = new cField('cstPayments', 'cstPayments', 'x_EndDate', 'EndDate', 'CCECourseSchedules.EndDate', 133, 5, FALSE, 'CCECourseSchedules.EndDate', FALSE);
		$this->EndDate->FldDefaultErrMsg = str_replace("%s", "/", $Language->Phrase("IncorrectDateYMD"));
		$this->fields['EndDate'] =& $this->EndDate;

		// Delegate
		$this->Delegate = new cField('cstPayments', 'cstPayments', 'x_Delegate', 'Delegate', 'Concat_Ws(\' \', CCEStudents.FirstName, CCEStudents.Surname)', 201, -1, FALSE, 'Concat_Ws(\' \', CCEStudents.FirstName, CCEStudents.Surname)', FALSE);
		$this->fields['Delegate'] =& $this->Delegate;

		// Organisation
		$this->Organisation = new cField('cstPayments', 'cstPayments', 'x_Organisation', 'Organisation', 'CCEStudents.Organisation', 200, -1, FALSE, 'CCEStudents.Organisation', FALSE);
		$this->fields['Organisation'] =& $this->Organisation;

		// EmailAddress
		$this->EmailAddress = new cField('cstPayments', 'cstPayments', 'x_EmailAddress', 'EmailAddress', 'CCEStudents.EmailAddress', 200, -1, FALSE, 'CCEStudents.EmailAddress', FALSE);
		$this->fields['EmailAddress'] =& $this->EmailAddress;

		// InvoiceNo
		$this->InvoiceNo = new cField('cstPayments', 'cstPayments', 'x_InvoiceNo', 'InvoiceNo', 'CCEPayments.InvoiceNo', 200, -1, FALSE, 'CCEPayments.InvoiceNo', FALSE);
		$this->fields['InvoiceNo'] =& $this->InvoiceNo;

		// AmountDue
		$this->AmountDue = new cField('cstPayments', 'cstPayments', 'x_AmountDue', 'AmountDue', 'CCEPayments.AmountDue', 131, -1, FALSE, 'CCEPayments.AmountDue', FALSE);
		$this->AmountDue->FldDefaultErrMsg = $Language->Phrase("IncorrectFloat");
		$this->fields['AmountDue'] =& $this->AmountDue;

		// AmountPaid
		$this->AmountPaid = new cField('cstPayments', 'cstPayments', 'x_AmountPaid', 'AmountPaid', 'CCEPayments.AmountPaid', 131, -1, FALSE, 'CCEPayments.AmountPaid', FALSE);
		$this->AmountPaid->FldDefaultErrMsg = $Language->Phrase("IncorrectFloat");
		$this->fields['AmountPaid'] =& $this->AmountPaid;

		// DatePaid
		$this->DatePaid = new cField('cstPayments', 'cstPayments', 'x_DatePaid', 'DatePaid', 'CCEPayments.DatePaid', 135, 5, FALSE, 'CCEPayments.DatePaid', FALSE);
		$this->DatePaid->FldDefaultErrMsg = str_replace("%s", "/", $Language->Phrase("IncorrectDateYMD"));
		$this->fields['DatePaid'] =& $this->DatePaid;

		// CreditNoteNo
		$this->CreditNoteNo = new cField('cstPayments', 'cstPayments', 'x_CreditNoteNo', 'CreditNoteNo', 'CCEPayments.CreditNoteNo', 200, -1, FALSE, 'CCEPayments.CreditNoteNo', FALSE);
		$this->fields['CreditNoteNo'] =& $this->CreditNoteNo;

		// CCECourseID
		$this->CCECourseID = new cField('cstPayments', 'cstPayments', 'x_CCECourseID', 'CCECourseID', 'CCECourses.CCECourseID', 3, -1, FALSE, 'CCECourses.CCECourseID', FALSE);
		$this->CCECourseID->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['CCECourseID'] =& $this->CCECourseID;

		// CCECourseName
		$this->CCECourseName = new cField('cstPayments', 'cstPayments', 'x_CCECourseName', 'CCECourseName', 'CCECourses.CCECourseName', 200, -1, FALSE, 'CCECourses.CCECourseName', FALSE);
		$this->fields['CCECourseName'] =& $this->CCECourseName;

		// StudentID
		$this->StudentID = new cField('cstPayments', 'cstPayments', 'x_StudentID', 'StudentID', 'CCEPayments.StudentID', 3, -1, FALSE, 'CCEPayments.StudentID', FALSE);
		$this->StudentID->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['StudentID'] =& $this->StudentID;

		// Telephone
		$this->Telephone = new cField('cstPayments', 'cstPayments', 'x_Telephone', 'Telephone', 'CCEStudents.Telephone', 200, -1, FALSE, 'CCEStudents.Telephone', FALSE);
		$this->fields['Telephone'] =& $this->Telephone;

		// Cellphone
		$this->Cellphone = new cField('cstPayments', 'cstPayments', 'x_Cellphone', 'Cellphone', 'CCEStudents.Cellphone', 200, -1, FALSE, 'CCEStudents.Cellphone', FALSE);
		$this->fields['Cellphone'] =& $this->Cellphone;
	}

	// Table caption
	function TableCaption() {
		global $Language;
		return $Language->TablePhrase($this->TableVar, "TblCaption");
	}

	// Page caption
	function PageCaption($Page) {
		global $Language;
		$Caption = $Language->TablePhrase($this->TableVar, "TblPageCaption" . $Page);
		if ($Caption == "") $Caption = "Page " . $Page;
		return $Caption;
	}

	// Export return page
	function ExportReturnUrl() {
		$url = @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_EXPORT_RETURN_URL];
		return ($url <> "") ? $url : ew_CurrentPage();
	}

	function setExportReturnUrl($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_EXPORT_RETURN_URL] = $v;
	}

	// Records per page
	function getRecordsPerPage() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_REC_PER_PAGE];
	}

	function setRecordsPerPage($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_REC_PER_PAGE] = $v;
	}

	// Start record number
	function getStartRecordNumber() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_START_REC];
	}

	function setStartRecordNumber($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_START_REC] = $v;
	}

	// Search highlight name
	function HighlightName() {
		return "cstPayments_Highlight";
	}

	// Advanced search
	function getAdvancedSearch($fld) {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_ADVANCED_SEARCH . "_" . $fld];
	}

	function setAdvancedSearch($fld, $v) {
		if (@$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_ADVANCED_SEARCH . "_" . $fld] <> $v) {
			$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_ADVANCED_SEARCH . "_" . $fld] = $v;
		}
	}

	// Basic search keyword
	function getSessionBasicSearchKeyword() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_BASIC_SEARCH];
	}

	function setSessionBasicSearchKeyword($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_BASIC_SEARCH] = $v;
	}

	// Basic search type
	function getSessionBasicSearchType() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_BASIC_SEARCH_TYPE];
	}

	function setSessionBasicSearchType($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_BASIC_SEARCH_TYPE] = $v;
	}

	// Search WHERE clause
	function getSearchWhere() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_SEARCH_WHERE];
	}

	function setSearchWhere($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_SEARCH_WHERE] = $v;
	}

	// Multiple column sort
	function UpdateSort(&$ofld, $ctrl) {
		if ($this->CurrentOrder == $ofld->FldName) {
			$sSortField = $ofld->FldExpression;
			$sLastSort = $ofld->getSort();
			if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
				$sThisSort = $this->CurrentOrderType;
			} else {
				$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			}
			$ofld->setSort($sThisSort);
			if ($ctrl) {
				$sOrderBy = $this->getSessionOrderBy();
				if (strpos($sOrderBy, $sSortField . " " . $sLastSort) !== FALSE) {
					$sOrderBy = str_replace($sSortField . " " . $sLastSort, $sSortField . " " . $sThisSort, $sOrderBy);
				} else {
					if ($sOrderBy <> "") $sOrderBy .= ", ";
					$sOrderBy .= $sSortField . " " . $sThisSort;
				}
				$this->setSessionOrderBy($sOrderBy); // Save to Session
			} else {
				$this->setSessionOrderBy($sSortField . " " . $sThisSort); // Save to Session
			}
		} else {
			if (!$ctrl) $ofld->setSort("");
		}
	}

	// Session WHERE clause
	function getSessionWhere() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_WHERE];
	}

	function setSessionWhere($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_WHERE] = $v;
	}

	// Session ORDER BY
	function getSessionOrderBy() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_ORDER_BY];
	}

	function setSessionOrderBy($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_ORDER_BY] = $v;
	}

	// Session key
	function getKey($fld) {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_KEY . "_" . $fld];
	}

	function setKey($fld, $v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_KEY . "_" . $fld] = $v;
	}

	// Table level SQL
	function SqlFrom() { // From
		return "(((CCEStudents Inner Join CCEStudentCourses On CCEStudentCourses.CCEStudentID = CCEStudents.CCEStudentID) Inner Join CCECourses On CCEStudentCourses.CCECourseID = CCECourses.CCECourseID) Inner Join CCECourseSchedules On CCEStudentCourses.CCECourseID = CCECourseSchedules.CCECourseScheduleID) Left Join CCEPayments On CCEStudents.CCEStudentID = CCEPayments.StudentID";
	}

	function SqlSelect() { // Select
		return "SELECT Distinct CCECourses.CCECourseID, CCECourses.CCECourseName, CCECourseSchedules.StartDate, CCECourseSchedules.EndDate, Concat_Ws(' ', CCEStudents.FirstName, CCEStudents.Surname) As Delegate, CCEStudents.Organisation, CCEPayments.InvoiceNo, CCEPayments.AmountPaid, CCEPayments.DatePaid, CCEPayments.StudentID, CCEStudents.Telephone, CCEStudents.Cellphone, CCEStudents.EmailAddress, CCEPayments.AmountDue, CCEPayments.CreditNoteNo FROM " . $this->SqlFrom();
	}

	function SqlWhere() { // Where
		$sWhere = "";
		$this->TableFilter = "SchoolCourses.CourseID=".$_GET["CourseID"];
		if ($this->TableFilter <> "") {
			if ($sWhere <> "") $sWhere .= "(" . $sWhere . ") AND (";
			$sWhere .= "(" . $this->TableFilter . ")";
		}
		return $sWhere;
	}

	function SqlGroupBy() { // Group By
		return "";
	}

	function SqlHaving() { // Having
		return "";
	}

	function SqlOrderBy() { // Order By
		return "CCEStudents.Surname, CCEStudents.FirstName";
	}

	// Check if Anonymous User is allowed
	function AllowAnonymousUser() {
		switch (EW_PAGE_ID) {
			case "add":
			case "register":
			case "addopt":
				return FALSE;
			case "edit":
			case "update":
				return FALSE;
			case "delete":
				return FALSE;
			case "view":
				return FALSE;
			case "search":
				return FALSE;
			default:
				return FALSE;
		}
	}

	// Apply User ID filters
	function ApplyUserIDFilters($sFilter) {
		return $sFilter;
	}

	// Get SQL
	function GetSQL($where, $orderby) {
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(),
			$this->SqlGroupBy(), $this->SqlHaving(), $this->SqlOrderBy(),
			$where, $orderby);
	}

	// Table SQL
	function SQL() {
		$sFilter = $this->CurrentFilter;
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(),
			$this->SqlGroupBy(), $this->SqlHaving(), $this->SqlOrderBy(),
			$sFilter, $sSort);
	}

	// Table SQL with List page filter
	function SelectSQL() {
		$sFilter = $this->getSessionWhere();
		if ($this->CurrentFilter <> "") {
			if ($sFilter <> "") $sFilter = "(" . $sFilter . ") AND ";
			$sFilter .= "(" . $this->CurrentFilter . ")";
		}
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(), $this->SqlGroupBy(),
			$this->SqlHaving(), $this->SqlOrderBy(), $sFilter, $sSort);
	}

	// Try to get record count
	function TryGetRecordCount($sSql) {
		global $conn;
		$cnt = -1;
		if ($this->TableType == 'TABLE' || $this->TableType == 'VIEW') {
			$sSql = "SELECT COUNT(*) FROM" . substr($sSql, 13);
		} else {
			$sSql = "SELECT COUNT(*) FROM (" . $sSql . ") EW_COUNT_TABLE";
		}
		if ($rs = $conn->Execute($sSql)) {
			if (!$rs->EOF && $rs->FieldCount() > 0) {
				$cnt = $rs->fields[0];
				$rs->Close();
			}
		}
		return intval($cnt);
	}

	// Get record count based on filter (for detail record count in master table pages)
	function LoadRecordCount($sFilter) {
		$origFilter = $this->CurrentFilter;
		$this->CurrentFilter = $sFilter;
		$this->Recordset_Selecting($this->CurrentFilter);
		$sSql = $this->SQL();
		$cnt = $this->TryGetRecordCount($sSql);
		if ($cnt == -1) {
			if ($rs = $this->LoadRs($this->CurrentFilter)) {
				$cnt = $rs->RecordCount();
				$rs->Close();
			}
		}
		$this->CurrentFilter = $origFilter;
		return intval($cnt);
	}

	// Get record count (for current List page)
	function SelectRecordCount() {
		global $conn;
		$origFilter = $this->CurrentFilter;
		$this->Recordset_Selecting($this->CurrentFilter);
		$sSql = $this->SelectSQL();
		$cnt = $this->TryGetRecordCount($sSql);
		if ($cnt == -1) {
			if ($rs = $conn->Execute($this->SelectSQL())) {
				$cnt = $rs->RecordCount();
				$rs->Close();
			}
		}
		$this->CurrentFilter = $origFilter;
		return intval($cnt);
	}

	// INSERT statement
	function InsertSQL(&$rs) {
		global $conn;
		$names = "";
		$values = "";
		foreach ($rs as $name => $value) {
			$names .= $this->fields[$name]->FldExpression . ",";
			$values .= ew_QuotedValue($value, $this->fields[$name]->FldDataType) . ",";
		}
		if (substr($names, -1) == ",") $names = substr($names, 0, strlen($names)-1);
		if (substr($values, -1) == ",") $values = substr($values, 0, strlen($values)-1);
		return "INSERT INTO (((CCEStudents Inner Join CCEStudentCourses On CCEStudentCourses.CCEStudentID = CCEStudents.CCEStudentID) Inner Join CCECourses On CCEStudentCourses.CCECourseID = CCECourses.CCECourseID) Inner Join CCECourseSchedules On CCEStudentCourses.CCECourseID = CCECourseSchedules.CCECourseScheduleID) Left Join CCEPayments On CCEStudents.CCEStudentID = CCEPayments.StudentID ($names) VALUES ($values)";
	}

	// UPDATE statement
	function UpdateSQL(&$rs) {
		global $conn;
		$SQL = "UPDATE (((CCEStudents Inner Join CCEStudentCourses On CCEStudentCourses.CCEStudentID = CCEStudents.CCEStudentID) Inner Join CCECourses On CCEStudentCourses.CCECourseID = CCECourses.CCECourseID) Inner Join CCECourseSchedules On CCEStudentCourses.CCECourseID = CCECourseSchedules.CCECourseScheduleID) Left Join CCEPayments On CCEStudents.CCEStudentID = CCEPayments.StudentID SET ";
		foreach ($rs as $name => $value) {
			$SQL .= $this->fields[$name]->FldExpression . "=";
			$SQL .= ew_QuotedValue($value, $this->fields[$name]->FldDataType) . ",";
		}
		if (substr($SQL, -1) == ",") $SQL = substr($SQL, 0, strlen($SQL)-1);
		if ($this->CurrentFilter <> "")	$SQL .= " WHERE " . $this->CurrentFilter;
		return $SQL;
	}

	// DELETE statement
	function DeleteSQL(&$rs) {
		$SQL = "DELETE FROM (((CCEStudents Inner Join CCEStudentCourses On CCEStudentCourses.CCEStudentID = CCEStudents.CCEStudentID) Inner Join CCECourses On CCEStudentCourses.CCECourseID = CCECourses.CCECourseID) Inner Join CCECourseSchedules On CCEStudentCourses.CCECourseID = CCECourseSchedules.CCECourseScheduleID) Left Join CCEPayments On CCEStudents.CCEStudentID = CCEPayments.StudentID WHERE ";
		if (substr($SQL, -5) == " AND ") $SQL = substr($SQL, 0, strlen($SQL)-5);
		if ($this->CurrentFilter <> "")	$SQL .= " AND " . $this->CurrentFilter;
		return $SQL;
	}

	// Key filter WHERE clause
	function SqlKeyFilter() {
		return "";
	}

	// Key filter
	function KeyFilter() {
		$sKeyFilter = $this->SqlKeyFilter();
		return $sKeyFilter;
	}

	// Return page URL
	function getReturnUrl() {
		$name = EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL;

		// Get referer URL automatically
		if (ew_ServerVar("HTTP_REFERER") <> "" && ew_ReferPage() <> ew_CurrentPage() && ew_ReferPage() <> "login.php") // Referer not same page or login page
			$_SESSION[$name] = ew_ServerVar("HTTP_REFERER"); // Save to Session
		if (@$_SESSION[$name] <> "") {
			return $_SESSION[$name];
		} else {
			return "cstPaymentslist.php";
		}
	}

	function setReturnUrl($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL] = $v;
	}

	// List URL
	function ListUrl() {
		return "cstPaymentslist.php";
	}

	// View URL
	function ViewUrl() {
		return $this->KeyUrl("cstPaymentsview.php", $this->UrlParm());
	}

	// Add URL
	function AddUrl() {
		$AddUrl = "cstPaymentsadd.php";
		$sUrlParm = $this->UrlParm();
		if ($sUrlParm <> "")
			$AddUrl .= "?" . $sUrlParm;
		return $AddUrl;
	}

	// Edit URL
	function EditUrl() {
		return $this->KeyUrl("cstPaymentsedit.php", $this->UrlParm());
	}

	// Inline edit URL
	function InlineEditUrl() {
		return $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=edit"));
	}

	// Copy URL
	function CopyUrl() {
		return $this->KeyUrl("cstPaymentsadd.php", $this->UrlParm());
	}

	// Inline copy URL
	function InlineCopyUrl() {
		return $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=copy"));
	}

	// Delete URL
	function DeleteUrl() {
		return $this->KeyUrl("cstPaymentsdelete.php", $this->UrlParm());
	}

	// Add key value to URL
	function KeyUrl($url, $parm = "") {
		$sUrl = $url . "?";
		if ($parm <> "") $sUrl .= $parm . "&";
		return $sUrl;
	}

	// Sort URL
	function SortUrl(&$fld) {
		if ($this->CurrentAction <> "" || $this->Export <> "" ||
			in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
				return "";
		} elseif ($fld->Sortable) {
			$sUrlParm = $this->UrlParm("order=" . urlencode($fld->FldName) . "&ordertype=" . $fld->ReverseSort());
			return ew_CurrentPage() . "?" . $sUrlParm;
		} else {
			return "";
		}
	}

	// Add URL parameter
	function UrlParm($parm = "") {
		$UrlParm = ($this->UseTokenInUrl) ? "t=cstPayments" : "";
		if ($parm <> "") {
			if ($UrlParm <> "")
				$UrlParm .= "&";
			$UrlParm .= $parm;
		}
		return $UrlParm;
	}

	// Load rows based on filter
	function &LoadRs($sFilter) {
		global $conn;

		// Set up filter (SQL WHERE clause) and get return SQL
		$this->CurrentFilter = $sFilter;
		$sSql = $this->SQL();
		return $conn->Execute($sSql);
	}

	// Load row values from recordset
	function LoadListRowValues(&$rs) {
		$this->StartDate->setDbValue($rs->fields('StartDate'));
		$this->EndDate->setDbValue($rs->fields('EndDate'));
		$this->Delegate->setDbValue($rs->fields('Delegate'));
		$this->Organisation->setDbValue($rs->fields('Organisation'));
		$this->EmailAddress->setDbValue($rs->fields('EmailAddress'));
		$this->InvoiceNo->setDbValue($rs->fields('InvoiceNo'));
		$this->AmountDue->setDbValue($rs->fields('AmountDue'));
		$this->AmountPaid->setDbValue($rs->fields('AmountPaid'));
		$this->DatePaid->setDbValue($rs->fields('DatePaid'));
		$this->CreditNoteNo->setDbValue($rs->fields('CreditNoteNo'));
		$this->CCECourseID->setDbValue($rs->fields('CCECourseID'));
		$this->CCECourseName->setDbValue($rs->fields('CCECourseName'));
		$this->StudentID->setDbValue($rs->fields('StudentID'));
		$this->Telephone->setDbValue($rs->fields('Telephone'));
		$this->Cellphone->setDbValue($rs->fields('Cellphone'));
	}

	// Render list row values
	function RenderListRow() {
		global $conn, $Security;

		// Call Row Rendering event
		$this->Row_Rendering();

   // Common render codes
		// Delegate

		$this->Delegate->CellCssStyle = ""; $this->Delegate->CellCssClass = "";
		$this->Delegate->CellAttrs = array(); $this->Delegate->ViewAttrs = array(); $this->Delegate->EditAttrs = array();

		// Organisation
		$this->Organisation->CellCssStyle = ""; $this->Organisation->CellCssClass = "";
		$this->Organisation->CellAttrs = array(); $this->Organisation->ViewAttrs = array(); $this->Organisation->EditAttrs = array();

		// EmailAddress
		$this->EmailAddress->CellCssStyle = ""; $this->EmailAddress->CellCssClass = "";
		$this->EmailAddress->CellAttrs = array(); $this->EmailAddress->ViewAttrs = array(); $this->EmailAddress->EditAttrs = array();

		// InvoiceNo
		$this->InvoiceNo->CellCssStyle = ""; $this->InvoiceNo->CellCssClass = "";
		$this->InvoiceNo->CellAttrs = array(); $this->InvoiceNo->ViewAttrs = array(); $this->InvoiceNo->EditAttrs = array();

		// AmountDue
		$this->AmountDue->CellCssStyle = ""; $this->AmountDue->CellCssClass = "";
		$this->AmountDue->CellAttrs = array(); $this->AmountDue->ViewAttrs = array(); $this->AmountDue->EditAttrs = array();

		// AmountPaid
		$this->AmountPaid->CellCssStyle = ""; $this->AmountPaid->CellCssClass = "";
		$this->AmountPaid->CellAttrs = array(); $this->AmountPaid->ViewAttrs = array(); $this->AmountPaid->EditAttrs = array();

		// DatePaid
		$this->DatePaid->CellCssStyle = ""; $this->DatePaid->CellCssClass = "";
		$this->DatePaid->CellAttrs = array(); $this->DatePaid->ViewAttrs = array(); $this->DatePaid->EditAttrs = array();

		// CreditNoteNo
		$this->CreditNoteNo->CellCssStyle = ""; $this->CreditNoteNo->CellCssClass = "";
		$this->CreditNoteNo->CellAttrs = array(); $this->CreditNoteNo->ViewAttrs = array(); $this->CreditNoteNo->EditAttrs = array();

		// CCECourseID
		$this->CCECourseID->CellCssStyle = ""; $this->CCECourseID->CellCssClass = "";
		$this->CCECourseID->CellAttrs = array(); $this->CCECourseID->ViewAttrs = array(); $this->CCECourseID->EditAttrs = array();

		// CCECourseName
		$this->CCECourseName->CellCssStyle = ""; $this->CCECourseName->CellCssClass = "";
		$this->CCECourseName->CellAttrs = array(); $this->CCECourseName->ViewAttrs = array(); $this->CCECourseName->EditAttrs = array();

		// StudentID
		$this->StudentID->CellCssStyle = ""; $this->StudentID->CellCssClass = "";
		$this->StudentID->CellAttrs = array(); $this->StudentID->ViewAttrs = array(); $this->StudentID->EditAttrs = array();

		// Telephone
		$this->Telephone->CellCssStyle = ""; $this->Telephone->CellCssClass = "";
		$this->Telephone->CellAttrs = array(); $this->Telephone->ViewAttrs = array(); $this->Telephone->EditAttrs = array();

		// Cellphone
		$this->Cellphone->CellCssStyle = ""; $this->Cellphone->CellCssClass = "";
		$this->Cellphone->CellAttrs = array(); $this->Cellphone->ViewAttrs = array(); $this->Cellphone->EditAttrs = array();

		// Delegate
		$this->Delegate->ViewValue = $this->Delegate->CurrentValue;
		$this->Delegate->CssStyle = "";
		$this->Delegate->CssClass = "";
		$this->Delegate->ViewCustomAttributes = "";

		// Organisation
		$this->Organisation->ViewValue = $this->Organisation->CurrentValue;
		$this->Organisation->CssStyle = "";
		$this->Organisation->CssClass = "";
		$this->Organisation->ViewCustomAttributes = "";

		// EmailAddress
		$this->EmailAddress->ViewValue = $this->EmailAddress->CurrentValue;
		$this->EmailAddress->CssStyle = "";
		$this->EmailAddress->CssClass = "";
		$this->EmailAddress->ViewCustomAttributes = "";

		// InvoiceNo
		$this->InvoiceNo->ViewValue = $this->InvoiceNo->CurrentValue;
		$this->InvoiceNo->CssStyle = "";
		$this->InvoiceNo->CssClass = "";
		$this->InvoiceNo->ViewCustomAttributes = "";

		// AmountDue
		$this->AmountDue->ViewValue = $this->AmountDue->CurrentValue;
		$this->AmountDue->CssStyle = "";
		$this->AmountDue->CssClass = "";
		$this->AmountDue->ViewCustomAttributes = "";

		// AmountPaid
		$this->AmountPaid->ViewValue = $this->AmountPaid->CurrentValue;
		$this->AmountPaid->CssStyle = "";
		$this->AmountPaid->CssClass = "";
		$this->AmountPaid->ViewCustomAttributes = "";

		// DatePaid
		$this->DatePaid->ViewValue = $this->DatePaid->CurrentValue;
		$this->DatePaid->ViewValue = ew_FormatDateTime($this->DatePaid->ViewValue, 5);
		$this->DatePaid->CssStyle = "";
		$this->DatePaid->CssClass = "";
		$this->DatePaid->ViewCustomAttributes = "";

		// CreditNoteNo
		$this->CreditNoteNo->ViewValue = $this->CreditNoteNo->CurrentValue;
		$this->CreditNoteNo->CssStyle = "";
		$this->CreditNoteNo->CssClass = "";
		$this->CreditNoteNo->ViewCustomAttributes = "";

		// CCECourseID
		$this->CCECourseID->ViewValue = $this->CCECourseID->CurrentValue;
		$this->CCECourseID->CssStyle = "";
		$this->CCECourseID->CssClass = "";
		$this->CCECourseID->ViewCustomAttributes = "";

		// CCECourseName
		$this->CCECourseName->ViewValue = $this->CCECourseName->CurrentValue;
		$this->CCECourseName->CssStyle = "";
		$this->CCECourseName->CssClass = "";
		$this->CCECourseName->ViewCustomAttributes = "";

		// StudentID
		$this->StudentID->ViewValue = $this->StudentID->CurrentValue;
		$this->StudentID->CssStyle = "";
		$this->StudentID->CssClass = "";
		$this->StudentID->ViewCustomAttributes = "";

		// Telephone
		$this->Telephone->ViewValue = $this->Telephone->CurrentValue;
		$this->Telephone->CssStyle = "";
		$this->Telephone->CssClass = "";
		$this->Telephone->ViewCustomAttributes = "";

		// Cellphone
		$this->Cellphone->ViewValue = $this->Cellphone->CurrentValue;
		$this->Cellphone->CssStyle = "";
		$this->Cellphone->CssClass = "";
		$this->Cellphone->ViewCustomAttributes = "";

		// Delegate
		$this->Delegate->HrefValue = "";
		$this->Delegate->TooltipValue = "";

		// Organisation
		$this->Organisation->HrefValue = "";
		$this->Organisation->TooltipValue = "";

		// EmailAddress
		$this->EmailAddress->HrefValue = "";
		$this->EmailAddress->TooltipValue = "";

		// InvoiceNo
		$this->InvoiceNo->HrefValue = "";
		$this->InvoiceNo->TooltipValue = "";

		// AmountDue
		$this->AmountDue->HrefValue = "";
		$this->AmountDue->TooltipValue = "";

		// AmountPaid
		$this->AmountPaid->HrefValue = "";
		$this->AmountPaid->TooltipValue = "";

		// DatePaid
		$this->DatePaid->HrefValue = "";
		$this->DatePaid->TooltipValue = "";

		// CreditNoteNo
		$this->CreditNoteNo->HrefValue = "";
		$this->CreditNoteNo->TooltipValue = "";

		// CCECourseID
		$this->CCECourseID->HrefValue = "";
		$this->CCECourseID->TooltipValue = "";

		// CCECourseName
		$this->CCECourseName->HrefValue = "";
		$this->CCECourseName->TooltipValue = "";

		// StudentID
		$this->StudentID->HrefValue = "";
		$this->StudentID->TooltipValue = "";

		// Telephone
		$this->Telephone->HrefValue = "";
		$this->Telephone->TooltipValue = "";

		// Cellphone
		$this->Cellphone->HrefValue = "";
		$this->Cellphone->TooltipValue = "";

		// Call Row Rendered event
		$this->Row_Rendered();
	}

	// Aggregate list row values
	function AggregateListRowValues() {
	}

	// Aggregate list row (for rendering)
	function AggregateListRow() {
	}

	// Row styles
	function RowStyles() {
		$sAtt = "";
		$sStyle = trim($this->CssStyle);
		if (@$this->RowAttrs["style"] <> "")
			$sStyle .= " " . $this->RowAttrs["style"];
		$sClass = trim($this->CssClass);
		if (@$this->RowAttrs["class"] <> "")
			$sClass .= " " . $this->RowAttrs["class"];
		if (trim($sStyle) <> "")
			$sAtt .= " style=\"" . trim($sStyle) . "\"";
		if (trim($sClass) <> "")
			$sAtt .= " class=\"" . trim($sClass) . "\"";
		return $sAtt;
	}

	// Row attributes
	function RowAttributes() {
		$sAtt = $this->RowStyles();
		if ($this->Export == "") {
			foreach ($this->RowAttrs as $k => $v) {
				if ($k <> "class" && $k <> "style" && trim($v) <> "")
					$sAtt .= " " . $k . "=\"" . trim($v) . "\"";
			}
		}
		return $sAtt;
	}

	// Field object by name
	function fields($fldname) {
		return $this->fields[$fldname];
	}

	// Table level events
	// Recordset Selecting event
	function Recordset_Selecting(&$filter) {

		// Enter your code here	
	}

		// Recordset Selected event
function Recordset_Selected(&$rs) {
    global $cstPayments;
    //echo "Recordset Selected";
    if (empty($_GET["export"])) echo '<p><span class="phpmaker">Master Record: School Events<br><br> 
<a href="SchoolEventslist.php">Back to master page</a></span></p>';

    echo "<table class='ewTable' style='width:550px'>
    <tr><td class='ewTableHeader' width=90><b>Course</b></td><td>".$rs->fields('EventName')."</td></tr>
    <tr><td class='ewTableHeader'><b>Start Date</b></td><td>".$rs->fields('StartDate')."</td></tr>
    <tr><td class='ewTableHeader'><b>End Date</b></td><td>".$rs->fields('EndDate')."</td></tr>
    <tr><td class='ewTableHeader'><b>Code</b></td><td>".$rs->fields('CODE')."</td></tr>
    </table><br>";
}

	// Recordset Search Validated event
	function Recordset_SearchValidated() {

		// Example:
		//$this->MyField1->AdvancedSearch->SearchValue = "your search criteria"; // Search value

	}

	// Recordset Searching event
	function Recordset_Searching(&$filter) {

		// Enter your code here	
	}

	// Row_Selecting event
	function Row_Selecting(&$filter) {

		// Enter your code here	
	}

	// Row Selected event
	function Row_Selected(&$rs) {

		//echo "Row Selected";
	}

	// Row Rendering event
	function Row_Rendering() {

		// Enter your code here	
	}

	// Row Rendered event
	function Row_Rendered() {

		// To view properties of field class, use:
		//var_dump($this-><FieldName>); 

	}

	// Row Inserting event
	function Row_Inserting(&$rs) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Inserted event
	function Row_Inserted(&$rs) {

		//echo "Row Inserted"
	}

	// Row Updating event
	function Row_Updating(&$rsold, &$rsnew) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Updated event
	function Row_Updated(&$rsold, &$rsnew) {

		//echo "Row Updated";
	}

	// Row Update Conflict event
	function Row_UpdateConflict(&$rsold, &$rsnew) {

		// Enter your code here
		// To ignore conflict, set return value to FALSE

		return TRUE;
	}

	// Row Deleting event
	function Row_Deleting(&$rs) {

		// Enter your code here
		// To cancel, set return value to False

		return TRUE;
	}

	// Row Deleted event
	function Row_Deleted(&$rs) {

		//echo "Row Deleted";
	}

	// Email Sending event
	function Email_Sending(&$Email, &$Args) {

		//var_dump($Email); var_dump($Args); exit();
		return TRUE;
	}
}
?>