Your IP : 216.73.217.79


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

<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "cstCourseYearsinfo.php" ?>
<?php include "CCEUsersinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$cstCourseYears_list = new ccstCourseYears_list();
$Page =& $cstCourseYears_list;

// Page init
$cstCourseYears_list->Page_Init();

// Page main
$cstCourseYears_list->Page_Main();
?>
<?php include "header.php" ?>
<?php if ($cstCourseYears->Export == "") { ?>
<script type="text/javascript">
<!--

// Create page object
var cstCourseYears_list = new ew_Page("cstCourseYears_list");

// page properties
cstCourseYears_list.PageID = "list"; // page ID
cstCourseYears_list.FormID = "fcstCourseYearslist"; // form ID
var EW_PAGE_ID = cstCourseYears_list.PageID; // for backward compatibility

// extend page with Form_CustomValidate function
cstCourseYears_list.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
cstCourseYears_list.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
cstCourseYears_list.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<?php } ?>
<?php if ($cstCourseYears->Export == "") { ?>
<?php } ?>
<?php
	$bSelectLimit = EW_SELECT_LIMIT;
	if ($bSelectLimit) {
		$cstCourseYears_list->lTotalRecs = $cstCourseYears->SelectRecordCount();
	} else {
		if ($rs = $cstCourseYears_list->LoadRecordset())
			$cstCourseYears_list->lTotalRecs = $rs->RecordCount();
	}
	$cstCourseYears_list->lStartRec = 1;
	if ($cstCourseYears_list->lDisplayRecs <= 0 || ($cstCourseYears->Export <> "" && $cstCourseYears->ExportAll)) // Display all records
		$cstCourseYears_list->lDisplayRecs = $cstCourseYears_list->lTotalRecs;
	if (!($cstCourseYears->Export <> "" && $cstCourseYears->ExportAll))
		$cstCourseYears_list->SetUpStartRec(); // Set up start record position
	if ($bSelectLimit)
		$rs = $cstCourseYears_list->LoadRecordset($cstCourseYears_list->lStartRec-1, $cstCourseYears_list->lDisplayRecs);
?>
<p><span class="phpmaker" style="white-space: nowrap;"><?php echo $Language->Phrase("TblTypeCUSTOMVIEW") ?><?php echo $cstCourseYears->TableCaption() ?>
<?php if ($cstCourseYears->Export == "" && $cstCourseYears->CurrentAction == "") { ?>
&nbsp;&nbsp;<a href="<?php echo $cstCourseYears_list->ExportPrintUrl ?>"><img src="images/print.gif" alt="<?php echo ew_HtmlEncode($Language->Phrase("PrinterFriendly")) ?>" title="<?php echo ew_HtmlEncode($Language->Phrase("PrinterFriendly")) ?>" width="16" height="16" border="0"></a>
&nbsp;&nbsp;<a href="<?php echo $cstCourseYears_list->ExportExcelUrl ?>"><img src='images/exportxls.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToExcel")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToExcel")) ?>' width='16' height='16' border='0'></a>
&nbsp;&nbsp;<a href="<?php echo $cstCourseYears_list->ExportWordUrl ?>"><img src='images/exportdoc.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToWord")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToWord")) ?>' width='16' height='16' border='0'></a>
&nbsp;&nbsp;<a name="emf_cstCourseYears" id="emf_cstCourseYears" href="javascript:void(0);" onclick="ew_EmailDialogShow({lnk:'emf_cstCourseYears',hdr:ewLanguage.Phrase('ExportToEmail'),f:document.fcstCourseYearslist,sel:false});"><img src='images/exportemail.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToEmail")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToEmail")) ?>' width='16' height='16' border='0'></a>
<?php } ?>
</span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$cstCourseYears_list->ShowMessage();
?>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<?php if ($cstCourseYears->Export == "") { ?>
<div class="ewGridUpperPanel">
<?php if ($cstCourseYears->CurrentAction <> "gridadd" && $cstCourseYears->CurrentAction <> "gridedit") { ?>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
	<tr>
		<td nowrap>
<?php if (!isset($cstCourseYears_list->Pager)) $cstCourseYears_list->Pager = new cPrevNextPager($cstCourseYears_list->lStartRec, $cstCourseYears_list->lDisplayRecs, $cstCourseYears_list->lTotalRecs) ?>
<?php if ($cstCourseYears_list->Pager->RecordCount > 0) { ?>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><?php echo $Language->Phrase("Page") ?>&nbsp;</span></td>
<!--first page button-->
	<?php if ($cstCourseYears_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $cstCourseYears_list->PageUrl() ?>start=<?php echo $cstCourseYears_list->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/firstdisab.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--previous page button-->
	<?php if ($cstCourseYears_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $cstCourseYears_list->PageUrl() ?>start=<?php echo $cstCourseYears_list->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/prevdisab.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--current page number-->
	<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $cstCourseYears_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($cstCourseYears_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $cstCourseYears_list->PageUrl() ?>start=<?php echo $cstCourseYears_list->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/nextdisab.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--last page button-->
	<?php if ($cstCourseYears_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $cstCourseYears_list->PageUrl() ?>start=<?php echo $cstCourseYears_list->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/lastdisab.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
	<td><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("of") ?>&nbsp;<?php echo $cstCourseYears_list->Pager->PageCount ?></span></td>
	</tr></table>
	</td>	
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<span class="phpmaker"><?php echo $Language->Phrase("Record") ?>&nbsp;<?php echo $cstCourseYears_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $cstCourseYears_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $cstCourseYears_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($cstCourseYears_list->sSrchWhere == "0=101") { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("EnterSearchCriteria") ?></span>
	<?php } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoRecord") ?></span>
	<?php } ?>
	<?php } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoPermission") ?></span>
	<?php } ?>
<?php } ?>
		</td>
	</tr>
</table>
</form>
<?php } ?>
<span class="phpmaker">
</span>
</div>
<?php } ?>
<form name="fcstCourseYearslist" id="fcstCourseYearslist" class="ewForm" action="" method="post">
<div id="gmp_cstCourseYears" class="ewGridMiddlePanel">
<?php if ($cstCourseYears_list->lTotalRecs > 0) { ?>
<table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<?php echo $cstCourseYears->TableCustomInnerHtml ?>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<?php

// Render list options
$cstCourseYears_list->RenderListOptions();

// Render list options (header, left)
$cstCourseYears_list->ListOptions->Render("header", "left");
?>
<?php if ($cstCourseYears->CourseYear->Visible) { // CourseYear ?>
	<?php if ($cstCourseYears->SortUrl($cstCourseYears->CourseYear) == "") { ?>
		<td><?php echo $cstCourseYears->CourseYear->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstCourseYears->SortUrl($cstCourseYears->CourseYear) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstCourseYears->CourseYear->FldCaption() ?></td><td style="width: 10px;"><?php if ($cstCourseYears->CourseYear->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstCourseYears->CourseYear->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php

// Render list options (header, right)
$cstCourseYears_list->ListOptions->Render("header", "right");
?>
	</tr>
</thead>
<?php
if ($cstCourseYears->ExportAll && $cstCourseYears->Export <> "") {
	$cstCourseYears_list->lStopRec = $cstCourseYears_list->lTotalRecs;
} else {
	$cstCourseYears_list->lStopRec = $cstCourseYears_list->lStartRec + $cstCourseYears_list->lDisplayRecs - 1; // Set the last record to display
}
$cstCourseYears_list->lRecCount = $cstCourseYears_list->lStartRec - 1;
if ($rs && !$rs->EOF) {
	$rs->MoveFirst();
	if (!$bSelectLimit && $cstCourseYears_list->lStartRec > 1)
		$rs->Move($cstCourseYears_list->lStartRec - 1);
}

// Initialize aggregate
$cstCourseYears->RowType = EW_ROWTYPE_AGGREGATEINIT;
$cstCourseYears_list->RenderRow();
$cstCourseYears_list->lRowCnt = 0;
while (($cstCourseYears->CurrentAction == "gridadd" || !$rs->EOF) &&
	$cstCourseYears_list->lRecCount < $cstCourseYears_list->lStopRec) {
	$cstCourseYears_list->lRecCount++;
	if (intval($cstCourseYears_list->lRecCount) >= intval($cstCourseYears_list->lStartRec)) {
		$cstCourseYears_list->lRowCnt++;

	// Init row class and style
	$cstCourseYears->CssClass = "";
	$cstCourseYears->CssStyle = "";
	$cstCourseYears->RowAttrs = array('onmouseover'=>'ew_MouseOver(event, this);', 'onmouseout'=>'ew_MouseOut(event, this);', 'onclick'=>'ew_Click(event, this);');
	if ($cstCourseYears->CurrentAction == "gridadd") {
		$cstCourseYears_list->LoadDefaultValues(); // Load default values
	} else {
		$cstCourseYears_list->LoadRowValues($rs); // Load row values
	}
	$cstCourseYears->RowType = EW_ROWTYPE_VIEW; // Render view

	// Render row
	$cstCourseYears_list->RenderRow();

	// Render list options
	$cstCourseYears_list->RenderListOptions();
?>
	<tr<?php echo $cstCourseYears->RowAttributes() ?>>
<?php

// Render list options (body, left)
$cstCourseYears_list->ListOptions->Render("body", "left");
?>
	<?php if ($cstCourseYears->CourseYear->Visible) { // CourseYear ?>
		<td<?php echo $cstCourseYears->CourseYear->CellAttributes() ?>>
<div<?php echo $cstCourseYears->CourseYear->ViewAttributes() ?>><?php echo $cstCourseYears->CourseYear->ListViewValue() ?></div>
</td>
	<?php } ?>
<?php

// Render list options (body, right)
$cstCourseYears_list->ListOptions->Render("body", "right");
?>
	</tr>
<?php
	}
	if ($cstCourseYears->CurrentAction <> "gridadd")
		$rs->MoveNext();
}
?>
</tbody>
</table>
<?php } ?>
</div>
</form>
<?php

// Close recordset
if ($rs)
	$rs->Close();
?>
<?php if ($cstCourseYears_list->lTotalRecs > 0) { ?>
<?php if ($cstCourseYears->Export == "") { ?>
<div class="ewGridLowerPanel">
<?php if ($cstCourseYears->CurrentAction <> "gridadd" && $cstCourseYears->CurrentAction <> "gridedit") { ?>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
	<tr>
		<td nowrap>
<?php if (!isset($cstCourseYears_list->Pager)) $cstCourseYears_list->Pager = new cPrevNextPager($cstCourseYears_list->lStartRec, $cstCourseYears_list->lDisplayRecs, $cstCourseYears_list->lTotalRecs) ?>
<?php if ($cstCourseYears_list->Pager->RecordCount > 0) { ?>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><?php echo $Language->Phrase("Page") ?>&nbsp;</span></td>
<!--first page button-->
	<?php if ($cstCourseYears_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $cstCourseYears_list->PageUrl() ?>start=<?php echo $cstCourseYears_list->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/firstdisab.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--previous page button-->
	<?php if ($cstCourseYears_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $cstCourseYears_list->PageUrl() ?>start=<?php echo $cstCourseYears_list->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/prevdisab.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--current page number-->
	<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $cstCourseYears_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($cstCourseYears_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $cstCourseYears_list->PageUrl() ?>start=<?php echo $cstCourseYears_list->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/nextdisab.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--last page button-->
	<?php if ($cstCourseYears_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $cstCourseYears_list->PageUrl() ?>start=<?php echo $cstCourseYears_list->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/lastdisab.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
	<td><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("of") ?>&nbsp;<?php echo $cstCourseYears_list->Pager->PageCount ?></span></td>
	</tr></table>
	</td>	
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<span class="phpmaker"><?php echo $Language->Phrase("Record") ?>&nbsp;<?php echo $cstCourseYears_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $cstCourseYears_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $cstCourseYears_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($cstCourseYears_list->sSrchWhere == "0=101") { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("EnterSearchCriteria") ?></span>
	<?php } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoRecord") ?></span>
	<?php } ?>
	<?php } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoPermission") ?></span>
	<?php } ?>
<?php } ?>
		</td>
	</tr>
</table>
</form>
<?php } ?>
<?php //if ($cstCourseYears_list->lTotalRecs > 0) { ?>
<span class="phpmaker">
</span>
<?php //} ?>
</div>
<?php } ?>
<?php } ?>
</td></tr></table>
<?php if ($cstCourseYears->Export == "" && $cstCourseYears->CurrentAction == "") { ?>
<?php } ?>
<?php if ($cstCourseYears->Export == "") { ?>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php } ?>
<?php include "footer.php" ?>
<?php
$cstCourseYears_list->Page_Terminate();
?>
<?php

//
// Page class
//
class ccstCourseYears_list {

	// Page ID
	var $PageID = 'list';

	// Table name
	var $TableName = 'cstCourseYears';

	// Page object name
	var $PageObjName = 'cstCourseYears_list';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $cstCourseYears;
		if ($cstCourseYears->UseTokenInUrl) $PageUrl .= "t=" . $cstCourseYears->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $cstCourseYears;
		if ($cstCourseYears->UseTokenInUrl) {
			if ($objForm)
				return ($cstCourseYears->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($cstCourseYears->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function __construct() {
		global $conn, $Language;

		// Language object
		$Language = new cLanguage();

		// Table object (cstCourseYears)
		$GLOBALS["cstCourseYears"] = new ccstCourseYears();

		// Initialize URLs
		$this->ExportPrintUrl = $this->PageUrl() . "export=print";
		$this->ExportExcelUrl = $this->PageUrl() . "export=excel";
		$this->ExportWordUrl = $this->PageUrl() . "export=word";
		$this->ExportHtmlUrl = $this->PageUrl() . "export=html";
		$this->ExportXmlUrl = $this->PageUrl() . "export=xml";
		$this->ExportCsvUrl = $this->PageUrl() . "export=csv";
		$this->AddUrl = $GLOBALS["cstCourseYears"]->AddUrl();
		$this->InlineAddUrl = $this->PageUrl() . "a=add";
		$this->GridAddUrl = $this->PageUrl() . "a=gridadd";
		$this->GridEditUrl = $this->PageUrl() . "a=gridedit";
		$this->MultiDeleteUrl = "cstCourseYearsdelete.php";
		$this->MultiUpdateUrl = "cstCourseYearsupdate.php";

		// Table object (CCEUsers)
		$GLOBALS['CCEUsers'] = new cCCEUsers();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'list', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'cstCourseYears', TRUE);

		// Start timer
		$GLOBALS["gsTimer"] = new cTimer();

		// Open connection
		$conn = ew_Connect();

		// List options
		$this->ListOptions = new cListOptions();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $cstCourseYears;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		$Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->TableName);
		$Security->TablePermission_Loaded();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		if (!$Security->CanList()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// Get export parameters
		if (@$_GET["export"] <> "") {
			$cstCourseYears->Export = $_GET["export"];
		} elseif (ew_IsHttpPost()) {
			if (@$_POST["exporttype"] <> "")
				$cstCourseYears->Export = $_POST["exporttype"];
		} else {
			$cstCourseYears->setExportReturnUrl(ew_CurrentUrl());
		}
		$gsExport = $cstCourseYears->Export; // Get export parameter, used in header
		$gsExportFile = $cstCourseYears->TableVar; // Get export file, used in header
		if ($cstCourseYears->Export == "excel") {
			header('Content-Type: application/vnd.ms-excel');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
		}
		if ($cstCourseYears->Export == "word") {
			header('Content-Type: application/vnd.ms-word');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
		}

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}

	// Class variables
	var $ListOptions; // List options
	var $lDisplayRecs = 20;
	var $lStartRec;
	var $lStopRec;
	var $lTotalRecs = 0;
	var $lRecRange = 10;
	var $sSrchWhere = ""; // Search WHERE clause
	var $lRecCnt = 0; // Record count
	var $lEditRowCnt;
	var $lRowCnt;
	var $lRowIndex; // Row index
	var $lRecPerRow = 0;
	var $lColCnt = 0;
	var $sDbMasterFilter = ""; // Master filter
	var $sDbDetailFilter = ""; // Detail filter
	var $bMasterRecordExists;	
	var $sMultiSelectKey;
	var $RestoreSearch;

	//
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsSearchError, $Security, $cstCourseYears;

		// Search filters
		$sSrchAdvanced = ""; // Advanced search filter
		$sSrchBasic = ""; // Basic search filter
		$sFilter = "";
		if ($this->IsPageRequest()) { // Validate request

			// Handle reset command
			$this->ResetCmd();

			// Set up list options
			$this->SetupListOptions();

			// Set up sorting order
			$this->SetUpSortOrder();
		}

		// Restore display records
		if ($cstCourseYears->getRecordsPerPage() <> "") {
			$this->lDisplayRecs = $cstCourseYears->getRecordsPerPage(); // Restore from Session
		} else {
			$this->lDisplayRecs = 20; // Load default
		}

		// Load Sorting Order
		$this->LoadSortOrder();

		// Build filter
		$sFilter = "";
		if (!$Security->CanList())
			$sFilter = "(0=1)"; // Filter all records
		if ($this->sDbDetailFilter <> "")
			$sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (" . $this->sDbDetailFilter . ")" : $this->sDbDetailFilter;
		if ($this->sSrchWhere <> "")
			$sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (". $this->sSrchWhere . ")" : $this->sSrchWhere;

		// Set up filter in session
		$cstCourseYears->setSessionWhere($sFilter);
		$cstCourseYears->CurrentFilter = "";

		// Export data only
		if (in_array($cstCourseYears->Export, array("html","word","excel","xml","csv","email"))) {
			$this->ExportData();
			if ($cstCourseYears->Export <> "email")
				$this->Page_Terminate(); // Terminate response
			exit();
		}
	}

	// Set up sort parameters
	function SetUpSortOrder() {
		global $cstCourseYears;

		// Check for Ctrl pressed
		$bCtrl = (@$_GET["ctrl"] <> "");

		// Check for "order" parameter
		if (@$_GET["order"] <> "") {
			$cstCourseYears->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
			$cstCourseYears->CurrentOrderType = @$_GET["ordertype"];
			$cstCourseYears->UpdateSort($cstCourseYears->CourseYear, $bCtrl); // CourseYear
			$cstCourseYears->setStartRecordNumber(1); // Reset start position
		}
	}

	// Load sort order parameters
	function LoadSortOrder() {
		global $cstCourseYears;
		$sOrderBy = $cstCourseYears->getSessionOrderBy(); // Get ORDER BY from Session
		if ($sOrderBy == "") {
			if ($cstCourseYears->SqlOrderBy() <> "") {
				$sOrderBy = $cstCourseYears->SqlOrderBy();
				$cstCourseYears->setSessionOrderBy($sOrderBy);
			}
		}
	}

	// Reset command
	// cmd=reset (Reset search parameters)
	// cmd=resetall (Reset search and master/detail parameters)
	// cmd=resetsort (Reset sort parameters)
	function ResetCmd() {
		global $cstCourseYears;

		// Get reset command
		if (@$_GET["cmd"] <> "") {
			$sCmd = $_GET["cmd"];

			// Reset sorting order
			if (strtolower($sCmd) == "resetsort") {
				$sOrderBy = "";
				$cstCourseYears->setSessionOrderBy($sOrderBy);
				$cstCourseYears->CourseYear->setSort("");
			}

			// Reset start position
			$this->lStartRec = 1;
			$cstCourseYears->setStartRecordNumber($this->lStartRec);
		}
	}

	// Set up list options
	function SetupListOptions() {
		global $Security, $cstCourseYears;

		// Call ListOptions_Load event
		$this->ListOptions_Load();
		if ($cstCourseYears->Export <> "" ||
			$cstCourseYears->CurrentAction == "gridadd" ||
			$cstCourseYears->CurrentAction == "gridedit")
			$this->ListOptions->HideAllOptions();
	}

	// Render list options
	function RenderListOptions() {
		global $Security, $Language, $cstCourseYears;
		$this->ListOptions->LoadDefault();
		$this->RenderListOptionsExt();

		// Call ListOptions_Rendered event
		$this->ListOptions_Rendered();
	}

	function RenderListOptionsExt() {
		global $Security, $Language, $cstCourseYears;
	}

	// Set up starting record parameters
	function SetUpStartRec() {
		global $cstCourseYears;
		if ($this->lDisplayRecs == 0)
			return;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
				$this->lStartRec = $_GET[EW_TABLE_START_REC];
				$cstCourseYears->setStartRecordNumber($this->lStartRec);
			} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
				$this->nPageNo = $_GET[EW_TABLE_PAGE_NO];
				if (is_numeric($this->nPageNo)) {
					$this->lStartRec = ($this->nPageNo-1)*$this->lDisplayRecs+1;
					if ($this->lStartRec <= 0) {
						$this->lStartRec = 1;
					} elseif ($this->lStartRec >= intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1) {
						$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1;
					}
					$cstCourseYears->setStartRecordNumber($this->lStartRec);
				}
			}
		}
		$this->lStartRec = $cstCourseYears->getStartRecordNumber();

		// Check if correct start record counter
		if (!is_numeric($this->lStartRec) || $this->lStartRec == "") { // Avoid invalid start record counter
			$this->lStartRec = 1; // Reset start record counter
			$cstCourseYears->setStartRecordNumber($this->lStartRec);
		} elseif (intval($this->lStartRec) > intval($this->lTotalRecs)) { // Avoid starting record > total records
			$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to last page first record
			$cstCourseYears->setStartRecordNumber($this->lStartRec);
		} elseif (($this->lStartRec-1) % $this->lDisplayRecs <> 0) {
			$this->lStartRec = intval(($this->lStartRec-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to page boundary
			$cstCourseYears->setStartRecordNumber($this->lStartRec);
		}
	}

	// Load recordset
	function LoadRecordset($offset = -1, $rowcnt = -1) {
		global $conn, $cstCourseYears;

		// Call Recordset Selecting event
		$cstCourseYears->Recordset_Selecting($cstCourseYears->CurrentFilter);

		// Load List page SQL
		$sSql = $cstCourseYears->SelectSQL();
		if ($offset > -1 && $rowcnt > -1)
			$sSql .= " LIMIT $offset, $rowcnt";

		// Load recordset
		$rs = ew_LoadRecordset($sSql);

		// Call Recordset Selected event
		$cstCourseYears->Recordset_Selected($rs);
		return $rs;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $cstCourseYears;
		$sFilter = $cstCourseYears->KeyFilter();

		// Call Row Selecting event
		$cstCourseYears->Row_Selecting($sFilter);

		// Load SQL based on filter
		$cstCourseYears->CurrentFilter = $sFilter;
		$sSql = $cstCourseYears->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$cstCourseYears->Row_Selected($rs);
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $cstCourseYears;
		$cstCourseYears->CCECourseScheduleID->setDbValue($rs->fields('CCECourseScheduleID'));
		$cstCourseYears->CourseYear->setDbValue($rs->fields('CourseYear'));
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language, $cstCourseYears;

		// Initialize URLs
		$this->ViewUrl = $cstCourseYears->ViewUrl();
		$this->EditUrl = $cstCourseYears->EditUrl();
		$this->InlineEditUrl = $cstCourseYears->InlineEditUrl();
		$this->CopyUrl = $cstCourseYears->CopyUrl();
		$this->InlineCopyUrl = $cstCourseYears->InlineCopyUrl();
		$this->DeleteUrl = $cstCourseYears->DeleteUrl();

		// Call Row_Rendering event
		$cstCourseYears->Row_Rendering();

		// Common render codes for all row types
		// CourseYear

		$cstCourseYears->CourseYear->CellCssStyle = ""; $cstCourseYears->CourseYear->CellCssClass = "";
		$cstCourseYears->CourseYear->CellAttrs = array(); $cstCourseYears->CourseYear->ViewAttrs = array(); $cstCourseYears->CourseYear->EditAttrs = array();
		if ($cstCourseYears->RowType == EW_ROWTYPE_VIEW) { // View row

			// CCECourseScheduleID
			$cstCourseYears->CCECourseScheduleID->ViewValue = $cstCourseYears->CCECourseScheduleID->CurrentValue;
			$cstCourseYears->CCECourseScheduleID->CssStyle = "";
			$cstCourseYears->CCECourseScheduleID->CssClass = "";
			$cstCourseYears->CCECourseScheduleID->ViewCustomAttributes = "";

			// CourseYear
			$cstCourseYears->CourseYear->ViewValue = $cstCourseYears->CourseYear->CurrentValue;
			$cstCourseYears->CourseYear->CssStyle = "";
			$cstCourseYears->CourseYear->CssClass = "";
			$cstCourseYears->CourseYear->ViewCustomAttributes = "";

			// CourseYear
			$cstCourseYears->CourseYear->HrefValue = "";
			$cstCourseYears->CourseYear->TooltipValue = "";
		}

		// Call Row Rendered event
		if ($cstCourseYears->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$cstCourseYears->Row_Rendered();
	}

	// Export data in HTML/CSV/Word/Excel/XML/Email format
	function ExportData() {
		global $cstCourseYears;
		$utf8 = FALSE;
		$bSelectLimit = EW_SELECT_LIMIT;

		// Load recordset
		if ($bSelectLimit) {
			$this->lTotalRecs = $cstCourseYears->SelectRecordCount();
		} else {
			if ($rs = $this->LoadRecordset())
				$this->lTotalRecs = $rs->RecordCount();
		}
		$this->lStartRec = 1;

		// Export all
		if ($cstCourseYears->ExportAll) {
			$this->lDisplayRecs = $this->lTotalRecs;
			$this->lStopRec = $this->lTotalRecs;
		} else { // Export one page only
			$this->SetUpStartRec(); // Set up start record position

			// Set the last record to display
			if ($this->lDisplayRecs < 0) {
				$this->lStopRec = $this->lTotalRecs;
			} else {
				$this->lStopRec = $this->lStartRec + $this->lDisplayRecs - 1;
			}
		}
		if ($bSelectLimit)
			$rs = $this->LoadRecordset($this->lStartRec-1, $this->lDisplayRecs);
		if (!$rs) {
			header("Content-Type:"); // Remove header
			header("Content-Disposition:");
			$this->ShowMessage();
			return;
		}
		if ($cstCourseYears->Export == "xml") {
			$XmlDoc = new cXMLDocument(EW_XML_ENCODING);
			$XmlDoc->AddRoot();
		} else {
			$ExportDoc = new cExportDocument($cstCourseYears, "h");
			$ExportDoc->ExportHeader();
			if ($ExportDoc->Horizontal) { // Horizontal format, write header
				$ExportDoc->BeginExportRow();
				$ExportDoc->ExportCaption($cstCourseYears->CCECourseScheduleID);
				$ExportDoc->ExportCaption($cstCourseYears->CourseYear);
				$ExportDoc->EndExportRow();
			}
		}

		// Move to first record
		$this->lRecCnt = $this->lStartRec - 1;
		if (!$rs->EOF) {
			$rs->MoveFirst();
			if (!$bSelectLimit && $this->lStartRec > 1)
				$rs->Move($this->lStartRec - 1);
		}
		while (!$rs->EOF && $this->lRecCnt < $this->lStopRec) {
			$this->lRecCnt++;
			if (intval($this->lRecCnt) >= intval($this->lStartRec)) {
				$this->LoadRowValues($rs);

				// Render row
				$cstCourseYears->CssClass = "";
				$cstCourseYears->CssStyle = "";
				$cstCourseYears->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->RenderRow();
				if ($cstCourseYears->Export == "xml") {
					$XmlDoc->AddRow();
					$XmlDoc->AddField('CCECourseScheduleID', $cstCourseYears->CCECourseScheduleID->ExportValue($cstCourseYears->Export, $cstCourseYears->ExportOriginalValue));
					$XmlDoc->AddField('CourseYear', $cstCourseYears->CourseYear->ExportValue($cstCourseYears->Export, $cstCourseYears->ExportOriginalValue));
				} else {
					$ExportDoc->BeginExportRow(TRUE); // Allow CSS styles if enabled
					$ExportDoc->ExportField($cstCourseYears->CCECourseScheduleID);
					$ExportDoc->ExportField($cstCourseYears->CourseYear);
					$ExportDoc->EndExportRow();
				}
			}
			$rs->MoveNext();
		}
		if ($cstCourseYears->Export <> "xml")
			$ExportDoc->ExportFooter();

		// Close recordset
		$rs->Close();

		// Clean output buffer
		if (!EW_DEBUG_ENABLED && ob_get_length())
			ob_end_clean();

		// Write BOM if utf-8
		if ($utf8 && !in_array($cstCourseYears->Export, array("email", "xml")))
			echo "\xEF\xBB\xBF";

		// Write debug message if enabled
		if (EW_DEBUG_ENABLED)
			echo ew_DebugMsg();

		// Output data
		if ($cstCourseYears->Export == "xml") {
			header("Content-Type: text/xml");
			echo $XmlDoc->XML();
		} elseif ($cstCourseYears->Export == "email") {
			$this->ExportEmail($ExportDoc->Text);
			$this->Page_Terminate($cstCourseYears->ExportReturnUrl());
		} else {
			echo $ExportDoc->Text;
		}
	}

	// Export email
	function ExportEmail($EmailContent) {
		global $Language, $cstCourseYears;
		$sSender = @$_GET["sender"];
		$sRecipient = @$_GET["recipient"];
		$sCc = @$_GET["cc"];
		$sBcc = @$_GET["bcc"];
		$sContentType = @$_GET["contenttype"];

		// Subject
		$sSubject = ew_StripSlashes(@$_GET["subject"]);
		$sEmailSubject = $sSubject;

		// Message
		$sContent = ew_StripSlashes(@$_GET["message"]);
		$sEmailMessage = $sContent;

		// Check sender
		if ($sSender == "") {
			$this->setMessage($Language->Phrase("EnterSenderEmail"));
			return;
		}
		if (!ew_CheckEmail($sSender)) {
			$this->setMessage($Language->Phrase("EnterProperSenderEmail"));
			return;
		}

		// Check recipient
		if (!ew_CheckEmailList($sRecipient, EW_MAX_EMAIL_RECIPIENT)) {
			$this->setMessage($Language->Phrase("EnterProperRecipientEmail"));
			return;
		}

		// Check cc
		if (!ew_CheckEmailList($sCc, EW_MAX_EMAIL_RECIPIENT)) {
			$this->setMessage($Language->Phrase("EnterProperCcEmail"));
			return;
		}

		// Check bcc
		if (!ew_CheckEmailList($sBcc, EW_MAX_EMAIL_RECIPIENT)) {
			$this->setMessage($Language->Phrase("EnterProperBccEmail"));
			return;
		}

		// Check email sent count
		if (!isset($_SESSION[EW_EXPORT_EMAIL_COUNTER]))
			$_SESSION[EW_EXPORT_EMAIL_COUNTER] = 0;
		if (intval($_SESSION[EW_EXPORT_EMAIL_COUNTER]) > EW_MAX_EMAIL_SENT_COUNT) {
			$this->setMessage($Language->Phrase("ExceedMaxEmailExport"));
			return;
		}
		if ($sEmailMessage <> "") {
			$sEmailMessage = ew_RemoveXSS($sEmailMessage);
			$sEmailMessage .= ($sContentType == "url") ? "\r\n\r\n" : "<br><br>";
		}
		if ($sContentType == "url") {
			$sUrl = ew_ConvertFullUrl(ew_CurrentPage() . "?" . $this->ExportQueryString());
			$sEmailMessage .= $sUrl; // send URL only
		} else {
			$sEmailMessage .= $EmailContent; // send HTML
		}

		// Send email
		$Email = new cEmail();
		$Email->Sender = $sSender; // Sender
		$Email->Recipient = $sRecipient; // Recipient
		$Email->Cc = $sCc; // Cc
		$Email->Bcc = $sBcc; // Bcc
		$Email->Subject = $sEmailSubject; // Subject
		$Email->Content = $sEmailMessage; // Content
		$Email->Format = ($sContentType == "url") ? "text" : "html";
		$Email->Charset = EW_EMAIL_CHARSET;
		$EventArgs = array();
		$bEmailSent = FALSE;
		if ($cstCourseYears->Email_Sending($Email, $EventArgs))
			$bEmailSent = $Email->Send();

		// Check email sent status
		if ($bEmailSent) {

			// Update email sent count
			$_SESSION[EW_EXPORT_EMAIL_COUNTER]++;

			// Sent email success
			$this->setMessage($Language->Phrase("SendEmailSuccess"));
		} else {

			// Sent email failure
			$this->setMessage($Email->SendErrDescription);
		}
	}

	// Export QueryString
	function ExportQueryString() {
		global $cstCourseYears;

		// Initialize
		$sQry = "export=html";

		// Build QueryString for search
		// Build QueryString for pager

		$sQry .= "&" . EW_TABLE_REC_PER_PAGE . "=" . $cstCourseYears->getRecordsPerPage() . "&" . EW_TABLE_START_REC . "=" . $cstCourseYears->getStartRecordNumber();
		return $sQry;
	}

	// Add search QueryString
	function AddSearchQueryString(&$Qry, &$Fld) {
		global $cstCourseYears;
		$FldParm = substr($Fld->FldVar, 2);
		$FldSearchValue = $cstCourseYears->GetAdvancedSearch("x_" . $FldParm);
		if (strval($FldSearchValue) <> "") {
			$Qry .= "&x_" . $FldParm . "=" . FldSearchValue .
				"&z_" . $FldParm . "=" . $cstCourseYears->GetAdvancedSearch("z_" . $FldParm);
		}
		$FldSearchValue2 = $cstCourseYears->GetAdvancedSearch("y_" . $FldParm);
		if (strval($FldSearchValue2) <> "") {
			$Qry .= "&v_" . $FldParm . "=" . $cstCourseYears->GetAdvancedSearch("v_" . $FldParm) .
				"&y_" . $FldParm . "=" . $FldSearchValue2 .
				"&w_" . $FldParm . "=" . $cstCourseYears->GetAdvancedSearch("w_" . $FldParm);
		}
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	function Message_Showing(&$msg) {

		// Example:
		//$msg = "your new message";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}

	// ListOptions Load event
	function ListOptions_Load() {

		// Example: 
		//$this->ListOptions->Add("new");
		//$this->ListOptions->Items["new"]->OnLeft = TRUE; // Link on left
		//$this->ListOptions->MoveItem("new", 0); // Move to first column

	}

	// ListOptions Rendered event
	function ListOptions_Rendered() {

		// Example: 
		//$this->ListOptions->Items["new"]->Body = "xxx";

	}
}
?>