Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/ccmadmin/
Upload File :
Current File : /var/www/cesa.co.za/ccmadmin/cstArchivedStudentslist.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 "cstArchivedStudentsinfo.php" ?>
<?php include "CCMUsersinfo.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
$cstArchivedStudents_list = new ccstArchivedStudents_list();
$Page =& $cstArchivedStudents_list;

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

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

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

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

// extend page with Form_CustomValidate function
cstArchivedStudents_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) { ?>
cstArchivedStudents_list.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
cstArchivedStudents_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 ($cstArchivedStudents->Export == "") { ?>
<?php } ?>
<?php
	$bSelectLimit = EW_SELECT_LIMIT;
	if ($bSelectLimit) {
		$cstArchivedStudents_list->lTotalRecs = $cstArchivedStudents->SelectRecordCount();
	} else {
		if ($rs = $cstArchivedStudents_list->LoadRecordset())
			$cstArchivedStudents_list->lTotalRecs = $rs->RecordCount();
	}
	$cstArchivedStudents_list->lStartRec = 1;
	if ($cstArchivedStudents_list->lDisplayRecs <= 0 || ($cstArchivedStudents->Export <> "" && $cstArchivedStudents->ExportAll)) // Display all records
		$cstArchivedStudents_list->lDisplayRecs = $cstArchivedStudents_list->lTotalRecs;
	if (!($cstArchivedStudents->Export <> "" && $cstArchivedStudents->ExportAll))
		$cstArchivedStudents_list->SetUpStartRec(); // Set up start record position
	if ($bSelectLimit)
		$rs = $cstArchivedStudents_list->LoadRecordset($cstArchivedStudents_list->lStartRec-1, $cstArchivedStudents_list->lDisplayRecs);
?>
<p><span class="phpmaker" style="white-space: nowrap;"><?php echo $Language->Phrase("TblTypeCUSTOMVIEW") ?><?php echo $cstArchivedStudents->TableCaption() ?>
<?php if ($cstArchivedStudents->Export == "" && $cstArchivedStudents->CurrentAction == "") { ?>
&nbsp;&nbsp;<a href="<?php echo $cstArchivedStudents_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 $cstArchivedStudents_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 $cstArchivedStudents_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_cstArchivedStudents" id="emf_cstArchivedStudents" href="javascript:void(0);" onclick="ew_EmailDialogShow({lnk:'emf_cstArchivedStudents',hdr:ewLanguage.Phrase('ExportToEmail'),f:document.fcstArchivedStudentslist,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 ($Security->CanSearch()) { ?>
<?php if ($cstArchivedStudents->Export == "" && $cstArchivedStudents->CurrentAction == "") { ?>
<a href="javascript:ew_ToggleSearchPanel(cstArchivedStudents_list);" style="text-decoration: none;"><img id="cstArchivedStudents_list_SearchImage" src="images/collapse.gif" alt="" width="9" height="9" border="0"></a><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("Search") ?></span><br>
<div id="cstArchivedStudents_list_SearchPanel">
<form name="fcstArchivedStudentslistsrch" id="fcstArchivedStudentslistsrch" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<input type="hidden" id="t" name="t" value="cstArchivedStudents">
<table class="ewBasicSearch">
	<tr>
		<td><span class="phpmaker">
			<input type="text" name="<?php echo EW_TABLE_BASIC_SEARCH ?>" id="<?php echo EW_TABLE_BASIC_SEARCH ?>" size="20" value="<?php echo ew_HtmlEncode($cstArchivedStudents->getSessionBasicSearchKeyword()) ?>">
			<input type="Submit" name="Submit" id="Submit" value="<?php echo ew_BtnCaption($Language->Phrase("QuickSearchBtn")) ?>">&nbsp;
			<a href="<?php echo $cstArchivedStudents_list->PageUrl() ?>cmd=reset"><?php echo $Language->Phrase("ShowAll") ?></a>&nbsp;
		</span></td>
	</tr>
	<tr>
	<td><span class="phpmaker"><label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value=""<?php if ($cstArchivedStudents->getSessionBasicSearchType() == "") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("ExactPhrase") ?></label>&nbsp;&nbsp;<label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="AND"<?php if ($cstArchivedStudents->getSessionBasicSearchType() == "AND") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AllWord") ?></label>&nbsp;&nbsp;<label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="OR"<?php if ($cstArchivedStudents->getSessionBasicSearchType() == "OR") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AnyWord") ?></label></span></td>
	</tr>
</table>
</form>
</div>
<?php } ?>
<?php } ?>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$cstArchivedStudents_list->ShowMessage();
?>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<?php if ($cstArchivedStudents->Export == "") { ?>
<div class="ewGridUpperPanel">
<?php if ($cstArchivedStudents->CurrentAction <> "gridadd" && $cstArchivedStudents->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($cstArchivedStudents_list->Pager)) $cstArchivedStudents_list->Pager = new cPrevNextPager($cstArchivedStudents_list->lStartRec, $cstArchivedStudents_list->lDisplayRecs, $cstArchivedStudents_list->lTotalRecs) ?>
<?php if ($cstArchivedStudents_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 ($cstArchivedStudents_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $cstArchivedStudents_list->PageUrl() ?>start=<?php echo $cstArchivedStudents_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 ($cstArchivedStudents_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $cstArchivedStudents_list->PageUrl() ?>start=<?php echo $cstArchivedStudents_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 $cstArchivedStudents_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($cstArchivedStudents_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $cstArchivedStudents_list->PageUrl() ?>start=<?php echo $cstArchivedStudents_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 ($cstArchivedStudents_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $cstArchivedStudents_list->PageUrl() ?>start=<?php echo $cstArchivedStudents_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 $cstArchivedStudents_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 $cstArchivedStudents_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $cstArchivedStudents_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $cstArchivedStudents_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($cstArchivedStudents_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="fcstArchivedStudentslist" id="fcstArchivedStudentslist" class="ewForm" action="" method="post">
<div id="gmp_cstArchivedStudents" class="ewGridMiddlePanel">
<?php if ($cstArchivedStudents_list->lTotalRecs > 0) { ?>
<table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<?php echo $cstArchivedStudents->TableCustomInnerHtml ?>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<?php

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

// Render list options (header, left)
$cstArchivedStudents_list->ListOptions->Render("header", "left");
?>
<?php if ($cstArchivedStudents->SelectionCategory->Visible) { // SelectionCategory ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->SelectionCategory) == "") { ?>
		<td><?php echo $cstArchivedStudents->SelectionCategory->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->SelectionCategory) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->SelectionCategory->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->SelectionCategory->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->SelectionCategory->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->FirstName->Visible) { // FirstName ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->FirstName) == "") { ?>
		<td><?php echo $cstArchivedStudents->FirstName->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->FirstName) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->FirstName->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->FirstName->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->FirstName->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->Surname->Visible) { // Surname ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->Surname) == "") { ?>
		<td><?php echo $cstArchivedStudents->Surname->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->Surname) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->Surname->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->Surname->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->Surname->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->KnownAs->Visible) { // KnownAs ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->KnownAs) == "") { ?>
		<td><?php echo $cstArchivedStudents->KnownAs->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->KnownAs) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->KnownAs->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->KnownAs->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->KnownAs->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->IDNumber->Visible) { // IDNumber ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->IDNumber) == "") { ?>
		<td><?php echo $cstArchivedStudents->IDNumber->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->IDNumber) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->IDNumber->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->IDNumber->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->IDNumber->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->Telephone->Visible) { // Telephone ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->Telephone) == "") { ?>
		<td><?php echo $cstArchivedStudents->Telephone->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->Telephone) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->Telephone->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->Telephone->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->Telephone->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->Cellphone->Visible) { // Cellphone ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->Cellphone) == "") { ?>
		<td><?php echo $cstArchivedStudents->Cellphone->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->Cellphone) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->Cellphone->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->Cellphone->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->Cellphone->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->EmailAddress->Visible) { // EmailAddress ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->EmailAddress) == "") { ?>
		<td><?php echo $cstArchivedStudents->EmailAddress->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->EmailAddress) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->EmailAddress->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->EmailAddress->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->EmailAddress->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->Organisation->Visible) { // Organisation ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->Organisation) == "") { ?>
		<td><?php echo $cstArchivedStudents->Organisation->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->Organisation) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->Organisation->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->Organisation->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->Organisation->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->Province->Visible) { // Province ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->Province) == "") { ?>
		<td><?php echo $cstArchivedStudents->Province->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->Province) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->Province->FldCaption() ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->Province->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->Province->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->ProfessionalCouncil->Visible) { // ProfessionalCouncil ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->ProfessionalCouncil) == "") { ?>
		<td><?php echo $cstArchivedStudents->ProfessionalCouncil->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->ProfessionalCouncil) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->ProfessionalCouncil->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->ProfessionalCouncil->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->ProfessionalCouncil->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->CategoryReg->Visible) { // CategoryReg ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->CategoryReg) == "") { ?>
		<td><?php echo $cstArchivedStudents->CategoryReg->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->CategoryReg) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->CategoryReg->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->CategoryReg->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->CategoryReg->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($cstArchivedStudents->BelongsTo->Visible) { // BelongsTo ?>
	<?php if ($cstArchivedStudents->SortUrl($cstArchivedStudents->BelongsTo) == "") { ?>
		<td><?php echo $cstArchivedStudents->BelongsTo->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $cstArchivedStudents->SortUrl($cstArchivedStudents->BelongsTo) ?>',2);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $cstArchivedStudents->BelongsTo->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($cstArchivedStudents->BelongsTo->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($cstArchivedStudents->BelongsTo->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)
$cstArchivedStudents_list->ListOptions->Render("header", "right");
?>
	</tr>
</thead>
<?php
if ($cstArchivedStudents->ExportAll && $cstArchivedStudents->Export <> "") {
	$cstArchivedStudents_list->lStopRec = $cstArchivedStudents_list->lTotalRecs;
} else {
	$cstArchivedStudents_list->lStopRec = $cstArchivedStudents_list->lStartRec + $cstArchivedStudents_list->lDisplayRecs - 1; // Set the last record to display
}
$cstArchivedStudents_list->lRecCount = $cstArchivedStudents_list->lStartRec - 1;
if ($rs && !$rs->EOF) {
	$rs->MoveFirst();
	if (!$bSelectLimit && $cstArchivedStudents_list->lStartRec > 1)
		$rs->Move($cstArchivedStudents_list->lStartRec - 1);
}

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

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

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

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

// Render list options (body, left)
$cstArchivedStudents_list->ListOptions->Render("body", "left");
?>
	<?php if ($cstArchivedStudents->SelectionCategory->Visible) { // SelectionCategory ?>
		<td<?php echo $cstArchivedStudents->SelectionCategory->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->SelectionCategory->ViewAttributes() ?>><?php echo $cstArchivedStudents->SelectionCategory->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->FirstName->Visible) { // FirstName ?>
		<td<?php echo $cstArchivedStudents->FirstName->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->FirstName->ViewAttributes() ?>><?php echo $cstArchivedStudents->FirstName->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->Surname->Visible) { // Surname ?>
		<td<?php echo $cstArchivedStudents->Surname->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->Surname->ViewAttributes() ?>><?php echo $cstArchivedStudents->Surname->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->KnownAs->Visible) { // KnownAs ?>
		<td<?php echo $cstArchivedStudents->KnownAs->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->KnownAs->ViewAttributes() ?>><?php echo $cstArchivedStudents->KnownAs->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->IDNumber->Visible) { // IDNumber ?>
		<td<?php echo $cstArchivedStudents->IDNumber->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->IDNumber->ViewAttributes() ?>><?php echo $cstArchivedStudents->IDNumber->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->Telephone->Visible) { // Telephone ?>
		<td<?php echo $cstArchivedStudents->Telephone->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->Telephone->ViewAttributes() ?>><?php echo $cstArchivedStudents->Telephone->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->Cellphone->Visible) { // Cellphone ?>
		<td<?php echo $cstArchivedStudents->Cellphone->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->Cellphone->ViewAttributes() ?>><?php echo $cstArchivedStudents->Cellphone->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->EmailAddress->Visible) { // EmailAddress ?>
		<td<?php echo $cstArchivedStudents->EmailAddress->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->EmailAddress->ViewAttributes() ?>><?php echo $cstArchivedStudents->EmailAddress->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->Organisation->Visible) { // Organisation ?>
		<td<?php echo $cstArchivedStudents->Organisation->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->Organisation->ViewAttributes() ?>><?php echo $cstArchivedStudents->Organisation->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->Province->Visible) { // Province ?>
		<td<?php echo $cstArchivedStudents->Province->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->Province->ViewAttributes() ?>><?php echo $cstArchivedStudents->Province->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->ProfessionalCouncil->Visible) { // ProfessionalCouncil ?>
		<td<?php echo $cstArchivedStudents->ProfessionalCouncil->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->ProfessionalCouncil->ViewAttributes() ?>><?php echo $cstArchivedStudents->ProfessionalCouncil->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->CategoryReg->Visible) { // CategoryReg ?>
		<td<?php echo $cstArchivedStudents->CategoryReg->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->CategoryReg->ViewAttributes() ?>><?php echo $cstArchivedStudents->CategoryReg->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($cstArchivedStudents->BelongsTo->Visible) { // BelongsTo ?>
		<td<?php echo $cstArchivedStudents->BelongsTo->CellAttributes() ?>>
<div<?php echo $cstArchivedStudents->BelongsTo->ViewAttributes() ?>><?php echo $cstArchivedStudents->BelongsTo->ListViewValue() ?></div>
</td>
	<?php } ?>
<?php

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

// Close recordset
if ($rs)
	$rs->Close();
?>
<?php if ($cstArchivedStudents_list->lTotalRecs > 0) { ?>
<?php if ($cstArchivedStudents->Export == "") { ?>
<div class="ewGridLowerPanel">
<?php if ($cstArchivedStudents->CurrentAction <> "gridadd" && $cstArchivedStudents->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($cstArchivedStudents_list->Pager)) $cstArchivedStudents_list->Pager = new cPrevNextPager($cstArchivedStudents_list->lStartRec, $cstArchivedStudents_list->lDisplayRecs, $cstArchivedStudents_list->lTotalRecs) ?>
<?php if ($cstArchivedStudents_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 ($cstArchivedStudents_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $cstArchivedStudents_list->PageUrl() ?>start=<?php echo $cstArchivedStudents_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 ($cstArchivedStudents_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $cstArchivedStudents_list->PageUrl() ?>start=<?php echo $cstArchivedStudents_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 $cstArchivedStudents_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($cstArchivedStudents_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $cstArchivedStudents_list->PageUrl() ?>start=<?php echo $cstArchivedStudents_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 ($cstArchivedStudents_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $cstArchivedStudents_list->PageUrl() ?>start=<?php echo $cstArchivedStudents_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 $cstArchivedStudents_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 $cstArchivedStudents_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $cstArchivedStudents_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $cstArchivedStudents_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($cstArchivedStudents_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 ($cstArchivedStudents_list->lTotalRecs > 0) { ?>
<span class="phpmaker">
</span>
<?php //} ?>
</div>
<?php } ?>
<?php } ?>
</td></tr></table>
<?php if ($cstArchivedStudents->Export == "" && $cstArchivedStudents->CurrentAction == "") { ?>
<?php } ?>
<?php if ($cstArchivedStudents->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
$cstArchivedStudents_list->Page_Terminate();
?>
<?php

//
// Page class
//
class ccstArchivedStudents_list {

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

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

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

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

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $cstArchivedStudents;
		if ($cstArchivedStudents->UseTokenInUrl) $PageUrl .= "t=" . $cstArchivedStudents->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, $cstArchivedStudents;
		if ($cstArchivedStudents->UseTokenInUrl) {
			if ($objForm)
				return ($cstArchivedStudents->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($cstArchivedStudents->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

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

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

		// Table object (cstArchivedStudents)
		$GLOBALS["cstArchivedStudents"] = new ccstArchivedStudents();

		// 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["cstArchivedStudents"]->AddUrl();
		$this->InlineAddUrl = $this->PageUrl() . "a=add";
		$this->GridAddUrl = $this->PageUrl() . "a=gridadd";
		$this->GridEditUrl = $this->PageUrl() . "a=gridedit";
		$this->MultiDeleteUrl = "cstArchivedStudentsdelete.php";
		$this->MultiUpdateUrl = "cstArchivedStudentsupdate.php";

		// Table object (CCMUsers)
		$GLOBALS['CCMUsers'] = new cCCMUsers();

		// 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", 'cstArchivedStudents', 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 $cstArchivedStudents;

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

		// 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();

			// Get basic search values
			$this->LoadBasicSearchValues();

			// Restore search parms from Session
			$this->RestoreSearchParms();

			// Call Recordset SearchValidated event
			$cstArchivedStudents->Recordset_SearchValidated();

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

			// Get basic search criteria
			if ($gsSearchError == "")
				$sSrchBasic = $this->BasicSearchWhere();
		}

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

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

		// Build search criteria
		if ($sSrchAdvanced <> "")
			$this->sSrchWhere = ($this->sSrchWhere <> "") ? "(" . $this->sSrchWhere . ") AND (" . $sSrchAdvanced . ")" : $sSrchAdvanced;
		if ($sSrchBasic <> "")
			$this->sSrchWhere = ($this->sSrchWhere <> "") ? "(" . $this->sSrchWhere . ") AND (" . $sSrchBasic. ")" : $sSrchBasic;

		// Call Recordset_Searching event
		$cstArchivedStudents->Recordset_Searching($this->sSrchWhere);

		// Save search criteria
		if ($this->sSrchWhere <> "") {
			if ($sSrchBasic == "")
				$this->ResetBasicSearchParms();
			$cstArchivedStudents->setSearchWhere($this->sSrchWhere); // Save to Session
			if (!$this->RestoreSearch) {
				$this->lStartRec = 1; // Reset start record counter
				$cstArchivedStudents->setStartRecordNumber($this->lStartRec);
			}
		} else {
			$this->sSrchWhere = $cstArchivedStudents->getSearchWhere();
		}

		// 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
		$cstArchivedStudents->setSessionWhere($sFilter);
		$cstArchivedStudents->CurrentFilter = "";

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

	// Return basic search SQL
	function BasicSearchSQL($Keyword) {
		global $cstArchivedStudents;
		$sKeyword = ew_AdjustSql($Keyword);
		$sWhere = "";
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->SelectionCategory, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Title, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Initials, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->FirstName, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Surname, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->KnownAs, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->IDNumber, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Telephone, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Cellphone, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->EmailAddress, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->WorkAddress, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->PostalAddress, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Department, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Organisation, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->VATNo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->JobTitle, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->PlaceofBirth, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->CountryofBirth, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Province, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->MaleorFemale, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->RaceGroup, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Disability, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->DisabilityNature, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->DisabilityCertificate, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->ProfessionalCouncil, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->CategoryReg, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->CouncilRegNumber, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->LengthCandidateReg, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->YearsToProfReg, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->FirstJobStart, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->VolAssociations, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BelongsTo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->CESA_SABTACO_MemNum, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->AreaDiscipline, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->AreaSubDiscipline, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Salary, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Payslip, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BankAccountName, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BankAccountBank, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BankAccountBranch, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BankAccountNo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BankAccountProof, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Funding, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->CWDTP, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BookedByName, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BookedByDesignation, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BookedByTelNo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BookedByFaxNo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BookedByCellNo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BookedByEmail, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->HRManagerName, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->HRManagerDesignation, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->HRManagerTelNo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->HRManagerCellNo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->HRManagerEmail, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->SupervisorName, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->SupervisorDesig, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->SupervisorProfRegNo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->SupervisorTelNo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->SupervisorCellNo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->SupervisorEmail, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->EducationalInst, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Qualifications, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->DateFinalExam, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->IDFile, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->CVFile, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->QualCertificate1, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->QualCertificate2, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->QualCertificate3, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->MentorUndertaking, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->CandUUndertaking, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->CompanyCandidatePolicy, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->ResidenceProof, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->SignedAppForm, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->Photograph, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->StudentNumber, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->WebUsername, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->WebPassword, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $cstArchivedStudents->BlockAccess, $Keyword);
		return $sWhere;
	}

	// Build basic search SQL
	function BuildBasicSearchSql(&$Where, &$Fld, $Keyword) {
		$sFldExpression = ($Fld->FldVirtualExpression <> "") ? $Fld->FldVirtualExpression : $Fld->FldExpression;
		$lFldDataType = ($Fld->FldIsVirtual) ? EW_DATATYPE_STRING : $Fld->FldDataType;
		if ($lFldDataType == EW_DATATYPE_NUMBER) {
			$sWrk = $sFldExpression . " = " . ew_QuotedValue($Keyword, $lFldDataType);
		} else {
			$sWrk = $sFldExpression . " LIKE " . ew_QuotedValue("%" . $Keyword . "%", $lFldDataType);
		}
		if ($Where <> "") $Where .= " OR ";
		$Where .= $sWrk;
	}

	// Return basic search WHERE clause based on search keyword and type
	function BasicSearchWhere() {
		global $Security, $cstArchivedStudents;
		$sSearchStr = "";
		if (!$Security->CanSearch()) return "";
		$sSearchKeyword = $cstArchivedStudents->BasicSearchKeyword;
		$sSearchType = $cstArchivedStudents->BasicSearchType;
		if ($sSearchKeyword <> "") {
			$sSearch = trim($sSearchKeyword);
			if ($sSearchType <> "") {
				while (strpos($sSearch, "  ") !== FALSE)
					$sSearch = str_replace("  ", " ", $sSearch);
				$arKeyword = explode(" ", trim($sSearch));
				foreach ($arKeyword as $sKeyword) {
					if ($sSearchStr <> "") $sSearchStr .= " " . $sSearchType . " ";
					$sSearchStr .= "(" . $this->BasicSearchSQL($sKeyword) . ")";
				}
			} else {
				$sSearchStr = $this->BasicSearchSQL($sSearch);
			}
		}
		if ($sSearchKeyword <> "") {
			$cstArchivedStudents->setSessionBasicSearchKeyword($sSearchKeyword);
			$cstArchivedStudents->setSessionBasicSearchType($sSearchType);
		}
		return $sSearchStr;
	}

	// Clear all search parameters
	function ResetSearchParms() {
		global $cstArchivedStudents;

		// Clear search WHERE clause
		$this->sSrchWhere = "";
		$cstArchivedStudents->setSearchWhere($this->sSrchWhere);

		// Clear basic search parameters
		$this->ResetBasicSearchParms();
	}

	// Clear all basic search parameters
	function ResetBasicSearchParms() {
		global $cstArchivedStudents;
		$cstArchivedStudents->setSessionBasicSearchKeyword("");
		$cstArchivedStudents->setSessionBasicSearchType("");
	}

	// Restore all search parameters
	function RestoreSearchParms() {
		global $cstArchivedStudents;
		$bRestore = TRUE;
		if (@$_GET[EW_TABLE_BASIC_SEARCH] <> "") $bRestore = FALSE;
		$this->RestoreSearch = $bRestore;
		if ($bRestore) {

			// Restore basic search values
			$cstArchivedStudents->BasicSearchKeyword = $cstArchivedStudents->getSessionBasicSearchKeyword();
			$cstArchivedStudents->BasicSearchType = $cstArchivedStudents->getSessionBasicSearchType();
		}
	}

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

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

		// Check for "order" parameter
		if (@$_GET["order"] <> "") {
			$cstArchivedStudents->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
			$cstArchivedStudents->CurrentOrderType = @$_GET["ordertype"];
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->SelectionCategory, $bCtrl); // SelectionCategory
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->FirstName, $bCtrl); // FirstName
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->Surname, $bCtrl); // Surname
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->KnownAs, $bCtrl); // KnownAs
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->IDNumber, $bCtrl); // IDNumber
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->Telephone, $bCtrl); // Telephone
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->Cellphone, $bCtrl); // Cellphone
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->EmailAddress, $bCtrl); // EmailAddress
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->Organisation, $bCtrl); // Organisation
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->Province, $bCtrl); // Province
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->ProfessionalCouncil, $bCtrl); // ProfessionalCouncil
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->CategoryReg, $bCtrl); // CategoryReg
			$cstArchivedStudents->UpdateSort($cstArchivedStudents->BelongsTo, $bCtrl); // BelongsTo
			$cstArchivedStudents->setStartRecordNumber(1); // Reset start position
		}
	}

	// Load sort order parameters
	function LoadSortOrder() {
		global $cstArchivedStudents;
		$sOrderBy = $cstArchivedStudents->getSessionOrderBy(); // Get ORDER BY from Session
		if ($sOrderBy == "") {
			if ($cstArchivedStudents->SqlOrderBy() <> "") {
				$sOrderBy = $cstArchivedStudents->SqlOrderBy();
				$cstArchivedStudents->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 $cstArchivedStudents;

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

			// Reset search criteria
			if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "resetall")
				$this->ResetSearchParms();

			// Reset sorting order
			if (strtolower($sCmd) == "resetsort") {
				$sOrderBy = "";
				$cstArchivedStudents->setSessionOrderBy($sOrderBy);
				$cstArchivedStudents->SelectionCategory->setSort("");
				$cstArchivedStudents->FirstName->setSort("");
				$cstArchivedStudents->Surname->setSort("");
				$cstArchivedStudents->KnownAs->setSort("");
				$cstArchivedStudents->IDNumber->setSort("");
				$cstArchivedStudents->Telephone->setSort("");
				$cstArchivedStudents->Cellphone->setSort("");
				$cstArchivedStudents->EmailAddress->setSort("");
				$cstArchivedStudents->Organisation->setSort("");
				$cstArchivedStudents->Province->setSort("");
				$cstArchivedStudents->ProfessionalCouncil->setSort("");
				$cstArchivedStudents->CategoryReg->setSort("");
				$cstArchivedStudents->BelongsTo->setSort("");
			}

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

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

		// "view"
		$this->ListOptions->Add("view");
		$item =& $this->ListOptions->Items["view"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->CanView();
		$item->OnLeft = FALSE;

		// "edit"
		$this->ListOptions->Add("edit");
		$item =& $this->ListOptions->Items["edit"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->CanEdit();
		$item->OnLeft = FALSE;

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

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

		// "view"
		$oListOpt =& $this->ListOptions->Items["view"];
		if ($Security->CanView() && $oListOpt->Visible)
			$oListOpt->Body = "<a href=\"" . $this->ViewUrl . "\">" . "<img src=\"images/view.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("ViewLink")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("ViewLink")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>";

		// "edit"
		$oListOpt =& $this->ListOptions->Items["edit"];
		if ($Security->CanEdit() && $oListOpt->Visible) {
			$oListOpt->Body = "<a href=\"" . $this->EditUrl . "\">" . "<img src=\"images/edit.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("EditLink")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("EditLink")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>";
		}
		$this->RenderListOptionsExt();

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

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

	// Set up starting record parameters
	function SetUpStartRec() {
		global $cstArchivedStudents;
		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];
				$cstArchivedStudents->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;
					}
					$cstArchivedStudents->setStartRecordNumber($this->lStartRec);
				}
			}
		}
		$this->lStartRec = $cstArchivedStudents->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
			$cstArchivedStudents->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
			$cstArchivedStudents->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
			$cstArchivedStudents->setStartRecordNumber($this->lStartRec);
		}
	}

	// Load basic search values
	function LoadBasicSearchValues() {
		global $cstArchivedStudents;
		$cstArchivedStudents->BasicSearchKeyword = @$_GET[EW_TABLE_BASIC_SEARCH];
		$cstArchivedStudents->BasicSearchType = @$_GET[EW_TABLE_BASIC_SEARCH_TYPE];
	}

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

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

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

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

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

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $cstArchivedStudents;
		$cstArchivedStudents->Archived->setDbValue($rs->fields('Archived'));
		$cstArchivedStudents->CCMStudentID->setDbValue($rs->fields('CCMStudentID'));
		$cstArchivedStudents->SelectionCategory->setDbValue($rs->fields('SelectionCategory'));
		$cstArchivedStudents->Title->setDbValue($rs->fields('Title'));
		$cstArchivedStudents->Initials->setDbValue($rs->fields('Initials'));
		$cstArchivedStudents->FirstName->setDbValue($rs->fields('FirstName'));
		$cstArchivedStudents->Surname->setDbValue($rs->fields('Surname'));
		$cstArchivedStudents->KnownAs->setDbValue($rs->fields('KnownAs'));
		$cstArchivedStudents->IDNumber->setDbValue($rs->fields('IDNumber'));
		$cstArchivedStudents->Telephone->setDbValue($rs->fields('Telephone'));
		$cstArchivedStudents->Cellphone->setDbValue($rs->fields('Cellphone'));
		$cstArchivedStudents->EmailAddress->setDbValue($rs->fields('EmailAddress'));
		$cstArchivedStudents->WorkAddress->setDbValue($rs->fields('WorkAddress'));
		$cstArchivedStudents->PostalAddress->setDbValue($rs->fields('PostalAddress'));
		$cstArchivedStudents->Department->setDbValue($rs->fields('Department'));
		$cstArchivedStudents->Organisation->setDbValue($rs->fields('Organisation'));
		$cstArchivedStudents->VATNo->setDbValue($rs->fields('VATNo'));
		$cstArchivedStudents->JobTitle->setDbValue($rs->fields('JobTitle'));
		$cstArchivedStudents->DateofBirth->setDbValue($rs->fields('DateofBirth'));
		$cstArchivedStudents->PlaceofBirth->setDbValue($rs->fields('PlaceofBirth'));
		$cstArchivedStudents->CountryofBirth->setDbValue($rs->fields('CountryofBirth'));
		$cstArchivedStudents->Province->setDbValue($rs->fields('Province'));
		$cstArchivedStudents->MaleorFemale->setDbValue($rs->fields('MaleorFemale'));
		$cstArchivedStudents->RaceGroup->setDbValue($rs->fields('RaceGroup'));
		$cstArchivedStudents->Disability->setDbValue($rs->fields('Disability'));
		$cstArchivedStudents->DisabilityNature->setDbValue($rs->fields('DisabilityNature'));
		$cstArchivedStudents->DisabilityCertificate->Upload->DbValue = $rs->fields('DisabilityCertificate');
		$cstArchivedStudents->ProfessionalCouncil->setDbValue($rs->fields('ProfessionalCouncil'));
		$cstArchivedStudents->CategoryReg->setDbValue($rs->fields('CategoryReg'));
		$cstArchivedStudents->CouncilRegNumber->setDbValue($rs->fields('CouncilRegNumber'));
		$cstArchivedStudents->LengthCandidateReg->setDbValue($rs->fields('LengthCandidateReg'));
		$cstArchivedStudents->YearsToProfReg->setDbValue($rs->fields('YearsToProfReg'));
		$cstArchivedStudents->FirstJobStart->setDbValue($rs->fields('FirstJobStart'));
		$cstArchivedStudents->VolAssociations->setDbValue($rs->fields('VolAssociations'));
		$cstArchivedStudents->BelongsTo->setDbValue($rs->fields('BelongsTo'));
		$cstArchivedStudents->CESA_SABTACO_MemNum->setDbValue($rs->fields('CESA_SABTACO_MemNum'));
		$cstArchivedStudents->AreaDiscipline->setDbValue($rs->fields('AreaDiscipline'));
		$cstArchivedStudents->AreaSubDiscipline->setDbValue($rs->fields('AreaSubDiscipline'));
		$cstArchivedStudents->Salary->setDbValue($rs->fields('Salary'));
		$cstArchivedStudents->Payslip->Upload->DbValue = $rs->fields('Payslip');
		$cstArchivedStudents->BankAccountName->setDbValue($rs->fields('BankAccountName'));
		$cstArchivedStudents->BankAccountBank->setDbValue($rs->fields('BankAccountBank'));
		$cstArchivedStudents->BankAccountBranch->setDbValue($rs->fields('BankAccountBranch'));
		$cstArchivedStudents->BankAccountNo->setDbValue($rs->fields('BankAccountNo'));
		$cstArchivedStudents->BankAccountProof->Upload->DbValue = $rs->fields('BankAccountProof');
		$cstArchivedStudents->Funding->setDbValue($rs->fields('Funding'));
		$cstArchivedStudents->CWDTP->setDbValue($rs->fields('CWDTP'));
		$cstArchivedStudents->BookedByName->setDbValue($rs->fields('BookedByName'));
		$cstArchivedStudents->BookedByDesignation->setDbValue($rs->fields('BookedByDesignation'));
		$cstArchivedStudents->BookedByTelNo->setDbValue($rs->fields('BookedByTelNo'));
		$cstArchivedStudents->BookedByFaxNo->setDbValue($rs->fields('BookedByFaxNo'));
		$cstArchivedStudents->BookedByCellNo->setDbValue($rs->fields('BookedByCellNo'));
		$cstArchivedStudents->BookedByEmail->setDbValue($rs->fields('BookedByEmail'));
		$cstArchivedStudents->MentorID->setDbValue($rs->fields('MentorID'));
		$cstArchivedStudents->EmployerID->setDbValue($rs->fields('EmployerID'));
		$cstArchivedStudents->HRManagerName->setDbValue($rs->fields('HRManagerName'));
		$cstArchivedStudents->HRManagerDesignation->setDbValue($rs->fields('HRManagerDesignation'));
		$cstArchivedStudents->HRManagerTelNo->setDbValue($rs->fields('HRManagerTelNo'));
		$cstArchivedStudents->HRManagerCellNo->setDbValue($rs->fields('HRManagerCellNo'));
		$cstArchivedStudents->HRManagerEmail->setDbValue($rs->fields('HRManagerEmail'));
		$cstArchivedStudents->SupervisorName->setDbValue($rs->fields('SupervisorName'));
		$cstArchivedStudents->SupervisorDesig->setDbValue($rs->fields('SupervisorDesig'));
		$cstArchivedStudents->SupervisorProfRegNo->setDbValue($rs->fields('SupervisorProfRegNo'));
		$cstArchivedStudents->SupervisorTelNo->setDbValue($rs->fields('SupervisorTelNo'));
		$cstArchivedStudents->SupervisorCellNo->setDbValue($rs->fields('SupervisorCellNo'));
		$cstArchivedStudents->SupervisorEmail->setDbValue($rs->fields('SupervisorEmail'));
		$cstArchivedStudents->EducationalInst->setDbValue($rs->fields('EducationalInst'));
		$cstArchivedStudents->Qualifications->setDbValue($rs->fields('Qualifications'));
		$cstArchivedStudents->DateFinalExam->setDbValue($rs->fields('DateFinalExam'));
		$cstArchivedStudents->IDFile->Upload->DbValue = $rs->fields('IDFile');
		$cstArchivedStudents->CVFile->Upload->DbValue = $rs->fields('CVFile');
		$cstArchivedStudents->QualCertificate1->Upload->DbValue = $rs->fields('QualCertificate1');
		$cstArchivedStudents->QualCertificate2->Upload->DbValue = $rs->fields('QualCertificate2');
		$cstArchivedStudents->QualCertificate3->Upload->DbValue = $rs->fields('QualCertificate3');
		$cstArchivedStudents->MentorUndertaking->Upload->DbValue = $rs->fields('MentorUndertaking');
		$cstArchivedStudents->CandUUndertaking->Upload->DbValue = $rs->fields('CandUUndertaking');
		$cstArchivedStudents->CompanyCandidatePolicy->Upload->DbValue = $rs->fields('CompanyCandidatePolicy');
		$cstArchivedStudents->ResidenceProof->Upload->DbValue = $rs->fields('ResidenceProof');
		$cstArchivedStudents->SignedAppForm->Upload->DbValue = $rs->fields('SignedAppForm');
		$cstArchivedStudents->Photograph->Upload->DbValue = $rs->fields('Photograph');
		$cstArchivedStudents->StudentNumber->setDbValue($rs->fields('StudentNumber'));
		$cstArchivedStudents->WebUsername->setDbValue($rs->fields('WebUsername'));
		$cstArchivedStudents->WebPassword->setDbValue($rs->fields('WebPassword'));
		$cstArchivedStudents->BlockAccess->setDbValue($rs->fields('BlockAccess'));
		$cstArchivedStudents->SABTACO->setDbValue($rs->fields('SABTACO'));
		$cstArchivedStudents->CESA->setDbValue($rs->fields('CESA'));
	}

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

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

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

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

		$cstArchivedStudents->SelectionCategory->CellCssStyle = ""; $cstArchivedStudents->SelectionCategory->CellCssClass = "";
		$cstArchivedStudents->SelectionCategory->CellAttrs = array(); $cstArchivedStudents->SelectionCategory->ViewAttrs = array(); $cstArchivedStudents->SelectionCategory->EditAttrs = array();

		// FirstName
		$cstArchivedStudents->FirstName->CellCssStyle = ""; $cstArchivedStudents->FirstName->CellCssClass = "";
		$cstArchivedStudents->FirstName->CellAttrs = array(); $cstArchivedStudents->FirstName->ViewAttrs = array(); $cstArchivedStudents->FirstName->EditAttrs = array();

		// Surname
		$cstArchivedStudents->Surname->CellCssStyle = ""; $cstArchivedStudents->Surname->CellCssClass = "";
		$cstArchivedStudents->Surname->CellAttrs = array(); $cstArchivedStudents->Surname->ViewAttrs = array(); $cstArchivedStudents->Surname->EditAttrs = array();

		// KnownAs
		$cstArchivedStudents->KnownAs->CellCssStyle = ""; $cstArchivedStudents->KnownAs->CellCssClass = "";
		$cstArchivedStudents->KnownAs->CellAttrs = array(); $cstArchivedStudents->KnownAs->ViewAttrs = array(); $cstArchivedStudents->KnownAs->EditAttrs = array();

		// IDNumber
		$cstArchivedStudents->IDNumber->CellCssStyle = ""; $cstArchivedStudents->IDNumber->CellCssClass = "";
		$cstArchivedStudents->IDNumber->CellAttrs = array(); $cstArchivedStudents->IDNumber->ViewAttrs = array(); $cstArchivedStudents->IDNumber->EditAttrs = array();

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

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

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

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

		// Province
		$cstArchivedStudents->Province->CellCssStyle = ""; $cstArchivedStudents->Province->CellCssClass = "";
		$cstArchivedStudents->Province->CellAttrs = array(); $cstArchivedStudents->Province->ViewAttrs = array(); $cstArchivedStudents->Province->EditAttrs = array();

		// ProfessionalCouncil
		$cstArchivedStudents->ProfessionalCouncil->CellCssStyle = ""; $cstArchivedStudents->ProfessionalCouncil->CellCssClass = "";
		$cstArchivedStudents->ProfessionalCouncil->CellAttrs = array(); $cstArchivedStudents->ProfessionalCouncil->ViewAttrs = array(); $cstArchivedStudents->ProfessionalCouncil->EditAttrs = array();

		// CategoryReg
		$cstArchivedStudents->CategoryReg->CellCssStyle = ""; $cstArchivedStudents->CategoryReg->CellCssClass = "";
		$cstArchivedStudents->CategoryReg->CellAttrs = array(); $cstArchivedStudents->CategoryReg->ViewAttrs = array(); $cstArchivedStudents->CategoryReg->EditAttrs = array();

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

			// Archived
			if (strval($cstArchivedStudents->Archived->CurrentValue) <> "") {
				switch ($cstArchivedStudents->Archived->CurrentValue) {
					case "1":
						$cstArchivedStudents->Archived->ViewValue = "Yes";
						break;
					case "0":
						$cstArchivedStudents->Archived->ViewValue = "No";
						break;
					default:
						$cstArchivedStudents->Archived->ViewValue = $cstArchivedStudents->Archived->CurrentValue;
				}
			} else {
				$cstArchivedStudents->Archived->ViewValue = NULL;
			}
			$cstArchivedStudents->Archived->CssStyle = "";
			$cstArchivedStudents->Archived->CssClass = "";
			$cstArchivedStudents->Archived->ViewCustomAttributes = "";

			// SelectionCategory
			$cstArchivedStudents->SelectionCategory->ViewValue = $cstArchivedStudents->SelectionCategory->CurrentValue;
			$cstArchivedStudents->SelectionCategory->CssStyle = "";
			$cstArchivedStudents->SelectionCategory->CssClass = "";
			$cstArchivedStudents->SelectionCategory->ViewCustomAttributes = "";

			// Title
			$cstArchivedStudents->Title->ViewValue = $cstArchivedStudents->Title->CurrentValue;
			$cstArchivedStudents->Title->CssStyle = "";
			$cstArchivedStudents->Title->CssClass = "";
			$cstArchivedStudents->Title->ViewCustomAttributes = "";

			// Initials
			$cstArchivedStudents->Initials->ViewValue = $cstArchivedStudents->Initials->CurrentValue;
			$cstArchivedStudents->Initials->CssStyle = "";
			$cstArchivedStudents->Initials->CssClass = "";
			$cstArchivedStudents->Initials->ViewCustomAttributes = "";

			// FirstName
			$cstArchivedStudents->FirstName->ViewValue = $cstArchivedStudents->FirstName->CurrentValue;
			$cstArchivedStudents->FirstName->CssStyle = "";
			$cstArchivedStudents->FirstName->CssClass = "";
			$cstArchivedStudents->FirstName->ViewCustomAttributes = "";

			// Surname
			$cstArchivedStudents->Surname->ViewValue = $cstArchivedStudents->Surname->CurrentValue;
			$cstArchivedStudents->Surname->CssStyle = "";
			$cstArchivedStudents->Surname->CssClass = "";
			$cstArchivedStudents->Surname->ViewCustomAttributes = "";

			// KnownAs
			$cstArchivedStudents->KnownAs->ViewValue = $cstArchivedStudents->KnownAs->CurrentValue;
			$cstArchivedStudents->KnownAs->CssStyle = "";
			$cstArchivedStudents->KnownAs->CssClass = "";
			$cstArchivedStudents->KnownAs->ViewCustomAttributes = "";

			// IDNumber
			$cstArchivedStudents->IDNumber->ViewValue = $cstArchivedStudents->IDNumber->CurrentValue;
			$cstArchivedStudents->IDNumber->CssStyle = "";
			$cstArchivedStudents->IDNumber->CssClass = "";
			$cstArchivedStudents->IDNumber->ViewCustomAttributes = "mso-number-format:General";

			// Telephone
			$cstArchivedStudents->Telephone->ViewValue = $cstArchivedStudents->Telephone->CurrentValue;
			$cstArchivedStudents->Telephone->CssStyle = "";
			$cstArchivedStudents->Telephone->CssClass = "";
			$cstArchivedStudents->Telephone->ViewCustomAttributes = "mso-number-format:General";

			// Cellphone
			$cstArchivedStudents->Cellphone->ViewValue = $cstArchivedStudents->Cellphone->CurrentValue;
			$cstArchivedStudents->Cellphone->CssStyle = "";
			$cstArchivedStudents->Cellphone->CssClass = "";
			$cstArchivedStudents->Cellphone->ViewCustomAttributes = "mso-number-format:General";

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

			// WorkAddress
			$cstArchivedStudents->WorkAddress->ViewValue = $cstArchivedStudents->WorkAddress->CurrentValue;
			$cstArchivedStudents->WorkAddress->CssStyle = "";
			$cstArchivedStudents->WorkAddress->CssClass = "";
			$cstArchivedStudents->WorkAddress->ViewCustomAttributes = "";

			// PostalAddress
			$cstArchivedStudents->PostalAddress->ViewValue = $cstArchivedStudents->PostalAddress->CurrentValue;
			$cstArchivedStudents->PostalAddress->CssStyle = "";
			$cstArchivedStudents->PostalAddress->CssClass = "";
			$cstArchivedStudents->PostalAddress->ViewCustomAttributes = "";

			// Department
			$cstArchivedStudents->Department->ViewValue = $cstArchivedStudents->Department->CurrentValue;
			$cstArchivedStudents->Department->CssStyle = "";
			$cstArchivedStudents->Department->CssClass = "";
			$cstArchivedStudents->Department->ViewCustomAttributes = "";

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

			// VATNo
			$cstArchivedStudents->VATNo->ViewValue = $cstArchivedStudents->VATNo->CurrentValue;
			$cstArchivedStudents->VATNo->CssStyle = "";
			$cstArchivedStudents->VATNo->CssClass = "";
			$cstArchivedStudents->VATNo->ViewCustomAttributes = "";

			// JobTitle
			$cstArchivedStudents->JobTitle->ViewValue = $cstArchivedStudents->JobTitle->CurrentValue;
			$cstArchivedStudents->JobTitle->CssStyle = "";
			$cstArchivedStudents->JobTitle->CssClass = "";
			$cstArchivedStudents->JobTitle->ViewCustomAttributes = "";

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

			// PlaceofBirth
			$cstArchivedStudents->PlaceofBirth->ViewValue = $cstArchivedStudents->PlaceofBirth->CurrentValue;
			$cstArchivedStudents->PlaceofBirth->CssStyle = "";
			$cstArchivedStudents->PlaceofBirth->CssClass = "";
			$cstArchivedStudents->PlaceofBirth->ViewCustomAttributes = "";

			// CountryofBirth
			$cstArchivedStudents->CountryofBirth->ViewValue = $cstArchivedStudents->CountryofBirth->CurrentValue;
			$cstArchivedStudents->CountryofBirth->CssStyle = "";
			$cstArchivedStudents->CountryofBirth->CssClass = "";
			$cstArchivedStudents->CountryofBirth->ViewCustomAttributes = "";

			// Province
			if (strval($cstArchivedStudents->Province->CurrentValue) <> "") {
				$sFilterWrk = "`LookupValue` = '" . ew_AdjustSql($cstArchivedStudents->Province->CurrentValue) . "'";
			$sSqlWrk = "SELECT `LookupValue` FROM `Lookups`";
			$sWhereWrk = "";
			if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
			$sWhereWrk .= "(" . "LookupName='Province'" . ")";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `LookupValue`";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$cstArchivedStudents->Province->ViewValue = $rswrk->fields('LookupValue');
					$rswrk->Close();
				} else {
					$cstArchivedStudents->Province->ViewValue = $cstArchivedStudents->Province->CurrentValue;
				}
			} else {
				$cstArchivedStudents->Province->ViewValue = NULL;
			}
			$cstArchivedStudents->Province->CssStyle = "";
			$cstArchivedStudents->Province->CssClass = "";
			$cstArchivedStudents->Province->ViewCustomAttributes = "";

			// MaleorFemale
			$cstArchivedStudents->MaleorFemale->ViewValue = $cstArchivedStudents->MaleorFemale->CurrentValue;
			$cstArchivedStudents->MaleorFemale->CssStyle = "";
			$cstArchivedStudents->MaleorFemale->CssClass = "";
			$cstArchivedStudents->MaleorFemale->ViewCustomAttributes = "";

			// RaceGroup
			$cstArchivedStudents->RaceGroup->ViewValue = $cstArchivedStudents->RaceGroup->CurrentValue;
			$cstArchivedStudents->RaceGroup->CssStyle = "";
			$cstArchivedStudents->RaceGroup->CssClass = "";
			$cstArchivedStudents->RaceGroup->ViewCustomAttributes = "";

			// Disability
			if (strval($cstArchivedStudents->Disability->CurrentValue) <> "") {
				switch ($cstArchivedStudents->Disability->CurrentValue) {
					case "y":
						$cstArchivedStudents->Disability->ViewValue = "Yes";
						break;
					case "n":
						$cstArchivedStudents->Disability->ViewValue = "No";
						break;
					default:
						$cstArchivedStudents->Disability->ViewValue = $cstArchivedStudents->Disability->CurrentValue;
				}
			} else {
				$cstArchivedStudents->Disability->ViewValue = NULL;
			}
			$cstArchivedStudents->Disability->CssStyle = "";
			$cstArchivedStudents->Disability->CssClass = "";
			$cstArchivedStudents->Disability->ViewCustomAttributes = "";

			// DisabilityNature
			$cstArchivedStudents->DisabilityNature->ViewValue = $cstArchivedStudents->DisabilityNature->CurrentValue;
			$cstArchivedStudents->DisabilityNature->CssStyle = "";
			$cstArchivedStudents->DisabilityNature->CssClass = "";
			$cstArchivedStudents->DisabilityNature->ViewCustomAttributes = "";

			// DisabilityCertificate
			if (!ew_Empty($cstArchivedStudents->DisabilityCertificate->Upload->DbValue)) {
				$cstArchivedStudents->DisabilityCertificate->ViewValue = $cstArchivedStudents->DisabilityCertificate->Upload->DbValue;
			} else {
				$cstArchivedStudents->DisabilityCertificate->ViewValue = "";
			}
			$cstArchivedStudents->DisabilityCertificate->CssStyle = "";
			$cstArchivedStudents->DisabilityCertificate->CssClass = "";
			$cstArchivedStudents->DisabilityCertificate->ViewCustomAttributes = "";

			// ProfessionalCouncil
			$cstArchivedStudents->ProfessionalCouncil->ViewValue = $cstArchivedStudents->ProfessionalCouncil->CurrentValue;
			$cstArchivedStudents->ProfessionalCouncil->CssStyle = "";
			$cstArchivedStudents->ProfessionalCouncil->CssClass = "";
			$cstArchivedStudents->ProfessionalCouncil->ViewCustomAttributes = "";

			// CategoryReg
			$cstArchivedStudents->CategoryReg->ViewValue = $cstArchivedStudents->CategoryReg->CurrentValue;
			$cstArchivedStudents->CategoryReg->CssStyle = "";
			$cstArchivedStudents->CategoryReg->CssClass = "";
			$cstArchivedStudents->CategoryReg->ViewCustomAttributes = "";

			// CouncilRegNumber
			$cstArchivedStudents->CouncilRegNumber->ViewValue = $cstArchivedStudents->CouncilRegNumber->CurrentValue;
			$cstArchivedStudents->CouncilRegNumber->CssStyle = "";
			$cstArchivedStudents->CouncilRegNumber->CssClass = "";
			$cstArchivedStudents->CouncilRegNumber->ViewCustomAttributes = "";

			// LengthCandidateReg
			$cstArchivedStudents->LengthCandidateReg->ViewValue = $cstArchivedStudents->LengthCandidateReg->CurrentValue;
			$cstArchivedStudents->LengthCandidateReg->CssStyle = "";
			$cstArchivedStudents->LengthCandidateReg->CssClass = "";
			$cstArchivedStudents->LengthCandidateReg->ViewCustomAttributes = "";

			// YearsToProfReg
			$cstArchivedStudents->YearsToProfReg->ViewValue = $cstArchivedStudents->YearsToProfReg->CurrentValue;
			$cstArchivedStudents->YearsToProfReg->CssStyle = "";
			$cstArchivedStudents->YearsToProfReg->CssClass = "";
			$cstArchivedStudents->YearsToProfReg->ViewCustomAttributes = "";

			// FirstJobStart
			$cstArchivedStudents->FirstJobStart->ViewValue = $cstArchivedStudents->FirstJobStart->CurrentValue;
			$cstArchivedStudents->FirstJobStart->CssStyle = "";
			$cstArchivedStudents->FirstJobStart->CssClass = "";
			$cstArchivedStudents->FirstJobStart->ViewCustomAttributes = "";

			// VolAssociations
			$cstArchivedStudents->VolAssociations->ViewValue = $cstArchivedStudents->VolAssociations->CurrentValue;
			$cstArchivedStudents->VolAssociations->CssStyle = "";
			$cstArchivedStudents->VolAssociations->CssClass = "";
			$cstArchivedStudents->VolAssociations->ViewCustomAttributes = "";

			// BelongsTo
			$cstArchivedStudents->BelongsTo->ViewValue = $cstArchivedStudents->BelongsTo->CurrentValue;
			$cstArchivedStudents->BelongsTo->CssStyle = "";
			$cstArchivedStudents->BelongsTo->CssClass = "";
			$cstArchivedStudents->BelongsTo->ViewCustomAttributes = "";

			// CESA_SABTACO_MemNum
			$cstArchivedStudents->CESA_SABTACO_MemNum->ViewValue = $cstArchivedStudents->CESA_SABTACO_MemNum->CurrentValue;
			$cstArchivedStudents->CESA_SABTACO_MemNum->CssStyle = "";
			$cstArchivedStudents->CESA_SABTACO_MemNum->CssClass = "";
			$cstArchivedStudents->CESA_SABTACO_MemNum->ViewCustomAttributes = "";

			// AreaDiscipline
			$cstArchivedStudents->AreaDiscipline->ViewValue = $cstArchivedStudents->AreaDiscipline->CurrentValue;
			$cstArchivedStudents->AreaDiscipline->CssStyle = "";
			$cstArchivedStudents->AreaDiscipline->CssClass = "";
			$cstArchivedStudents->AreaDiscipline->ViewCustomAttributes = "";

			// AreaSubDiscipline
			$cstArchivedStudents->AreaSubDiscipline->ViewValue = $cstArchivedStudents->AreaSubDiscipline->CurrentValue;
			$cstArchivedStudents->AreaSubDiscipline->CssStyle = "";
			$cstArchivedStudents->AreaSubDiscipline->CssClass = "";
			$cstArchivedStudents->AreaSubDiscipline->ViewCustomAttributes = "";

			// Salary
			$cstArchivedStudents->Salary->ViewValue = $cstArchivedStudents->Salary->CurrentValue;
			$cstArchivedStudents->Salary->CssStyle = "";
			$cstArchivedStudents->Salary->CssClass = "";
			$cstArchivedStudents->Salary->ViewCustomAttributes = "";

			// Payslip
			if (!ew_Empty($cstArchivedStudents->Payslip->Upload->DbValue)) {
				$cstArchivedStudents->Payslip->ViewValue = $cstArchivedStudents->Payslip->Upload->DbValue;
			} else {
				$cstArchivedStudents->Payslip->ViewValue = "";
			}
			$cstArchivedStudents->Payslip->CssStyle = "";
			$cstArchivedStudents->Payslip->CssClass = "";
			$cstArchivedStudents->Payslip->ViewCustomAttributes = "";

			// BankAccountName
			$cstArchivedStudents->BankAccountName->ViewValue = $cstArchivedStudents->BankAccountName->CurrentValue;
			$cstArchivedStudents->BankAccountName->CssStyle = "";
			$cstArchivedStudents->BankAccountName->CssClass = "";
			$cstArchivedStudents->BankAccountName->ViewCustomAttributes = "";

			// BankAccountBank
			$cstArchivedStudents->BankAccountBank->ViewValue = $cstArchivedStudents->BankAccountBank->CurrentValue;
			$cstArchivedStudents->BankAccountBank->CssStyle = "";
			$cstArchivedStudents->BankAccountBank->CssClass = "";
			$cstArchivedStudents->BankAccountBank->ViewCustomAttributes = "";

			// BankAccountBranch
			$cstArchivedStudents->BankAccountBranch->ViewValue = $cstArchivedStudents->BankAccountBranch->CurrentValue;
			$cstArchivedStudents->BankAccountBranch->CssStyle = "";
			$cstArchivedStudents->BankAccountBranch->CssClass = "";
			$cstArchivedStudents->BankAccountBranch->ViewCustomAttributes = "";

			// BankAccountNo
			$cstArchivedStudents->BankAccountNo->ViewValue = $cstArchivedStudents->BankAccountNo->CurrentValue;
			$cstArchivedStudents->BankAccountNo->CssStyle = "";
			$cstArchivedStudents->BankAccountNo->CssClass = "";
			$cstArchivedStudents->BankAccountNo->ViewCustomAttributes = "";

			// BankAccountProof
			if (!ew_Empty($cstArchivedStudents->BankAccountProof->Upload->DbValue)) {
				$cstArchivedStudents->BankAccountProof->ViewValue = $cstArchivedStudents->BankAccountProof->Upload->DbValue;
			} else {
				$cstArchivedStudents->BankAccountProof->ViewValue = "";
			}
			$cstArchivedStudents->BankAccountProof->CssStyle = "";
			$cstArchivedStudents->BankAccountProof->CssClass = "";
			$cstArchivedStudents->BankAccountProof->ViewCustomAttributes = "";

			// Funding
			$cstArchivedStudents->Funding->ViewValue = $cstArchivedStudents->Funding->CurrentValue;
			$cstArchivedStudents->Funding->CssStyle = "";
			$cstArchivedStudents->Funding->CssClass = "";
			$cstArchivedStudents->Funding->ViewCustomAttributes = "";

			// CWDTP
			$cstArchivedStudents->CWDTP->ViewValue = $cstArchivedStudents->CWDTP->CurrentValue;
			$cstArchivedStudents->CWDTP->CssStyle = "";
			$cstArchivedStudents->CWDTP->CssClass = "";
			$cstArchivedStudents->CWDTP->ViewCustomAttributes = "";

			// BookedByName
			$cstArchivedStudents->BookedByName->ViewValue = $cstArchivedStudents->BookedByName->CurrentValue;
			$cstArchivedStudents->BookedByName->CssStyle = "";
			$cstArchivedStudents->BookedByName->CssClass = "";
			$cstArchivedStudents->BookedByName->ViewCustomAttributes = "";

			// BookedByDesignation
			$cstArchivedStudents->BookedByDesignation->ViewValue = $cstArchivedStudents->BookedByDesignation->CurrentValue;
			$cstArchivedStudents->BookedByDesignation->CssStyle = "";
			$cstArchivedStudents->BookedByDesignation->CssClass = "";
			$cstArchivedStudents->BookedByDesignation->ViewCustomAttributes = "";

			// BookedByTelNo
			$cstArchivedStudents->BookedByTelNo->ViewValue = $cstArchivedStudents->BookedByTelNo->CurrentValue;
			$cstArchivedStudents->BookedByTelNo->CssStyle = "";
			$cstArchivedStudents->BookedByTelNo->CssClass = "";
			$cstArchivedStudents->BookedByTelNo->ViewCustomAttributes = "";

			// BookedByFaxNo
			$cstArchivedStudents->BookedByFaxNo->ViewValue = $cstArchivedStudents->BookedByFaxNo->CurrentValue;
			$cstArchivedStudents->BookedByFaxNo->CssStyle = "";
			$cstArchivedStudents->BookedByFaxNo->CssClass = "";
			$cstArchivedStudents->BookedByFaxNo->ViewCustomAttributes = "";

			// BookedByCellNo
			$cstArchivedStudents->BookedByCellNo->ViewValue = $cstArchivedStudents->BookedByCellNo->CurrentValue;
			$cstArchivedStudents->BookedByCellNo->CssStyle = "";
			$cstArchivedStudents->BookedByCellNo->CssClass = "";
			$cstArchivedStudents->BookedByCellNo->ViewCustomAttributes = "";

			// BookedByEmail
			$cstArchivedStudents->BookedByEmail->ViewValue = $cstArchivedStudents->BookedByEmail->CurrentValue;
			$cstArchivedStudents->BookedByEmail->CssStyle = "";
			$cstArchivedStudents->BookedByEmail->CssClass = "";
			$cstArchivedStudents->BookedByEmail->ViewCustomAttributes = "";

			// MentorID
			if (strval($cstArchivedStudents->MentorID->CurrentValue) <> "") {
				$sFilterWrk = "`CCMMentorID` = " . ew_AdjustSql($cstArchivedStudents->MentorID->CurrentValue) . "";
			$sSqlWrk = "SELECT `Surname`, `FirstName` FROM `CCMMentors`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `FirstName`";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$cstArchivedStudents->MentorID->ViewValue = $rswrk->fields('Surname');
					$cstArchivedStudents->MentorID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('FirstName');
					$rswrk->Close();
				} else {
					$cstArchivedStudents->MentorID->ViewValue = $cstArchivedStudents->MentorID->CurrentValue;
				}
			} else {
				$cstArchivedStudents->MentorID->ViewValue = NULL;
			}
			$cstArchivedStudents->MentorID->CssStyle = "";
			$cstArchivedStudents->MentorID->CssClass = "";
			$cstArchivedStudents->MentorID->ViewCustomAttributes = "";

			// EmployerID
			if (strval($cstArchivedStudents->EmployerID->CurrentValue) <> "") {
				$sFilterWrk = "`CCMEmployerID` = " . ew_AdjustSql($cstArchivedStudents->EmployerID->CurrentValue) . "";
			$sSqlWrk = "SELECT `Organisation`, `Surname` FROM `CCMEmployers`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Organisation`";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$cstArchivedStudents->EmployerID->ViewValue = $rswrk->fields('Organisation');
					$cstArchivedStudents->EmployerID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('Surname');
					$rswrk->Close();
				} else {
					$cstArchivedStudents->EmployerID->ViewValue = $cstArchivedStudents->EmployerID->CurrentValue;
				}
			} else {
				$cstArchivedStudents->EmployerID->ViewValue = NULL;
			}
			$cstArchivedStudents->EmployerID->CssStyle = "";
			$cstArchivedStudents->EmployerID->CssClass = "";
			$cstArchivedStudents->EmployerID->ViewCustomAttributes = "";

			// HRManagerName
			$cstArchivedStudents->HRManagerName->ViewValue = $cstArchivedStudents->HRManagerName->CurrentValue;
			$cstArchivedStudents->HRManagerName->CssStyle = "";
			$cstArchivedStudents->HRManagerName->CssClass = "";
			$cstArchivedStudents->HRManagerName->ViewCustomAttributes = "";

			// HRManagerDesignation
			$cstArchivedStudents->HRManagerDesignation->ViewValue = $cstArchivedStudents->HRManagerDesignation->CurrentValue;
			$cstArchivedStudents->HRManagerDesignation->CssStyle = "";
			$cstArchivedStudents->HRManagerDesignation->CssClass = "";
			$cstArchivedStudents->HRManagerDesignation->ViewCustomAttributes = "";

			// HRManagerTelNo
			$cstArchivedStudents->HRManagerTelNo->ViewValue = $cstArchivedStudents->HRManagerTelNo->CurrentValue;
			$cstArchivedStudents->HRManagerTelNo->CssStyle = "";
			$cstArchivedStudents->HRManagerTelNo->CssClass = "";
			$cstArchivedStudents->HRManagerTelNo->ViewCustomAttributes = "";

			// HRManagerCellNo
			$cstArchivedStudents->HRManagerCellNo->ViewValue = $cstArchivedStudents->HRManagerCellNo->CurrentValue;
			$cstArchivedStudents->HRManagerCellNo->CssStyle = "";
			$cstArchivedStudents->HRManagerCellNo->CssClass = "";
			$cstArchivedStudents->HRManagerCellNo->ViewCustomAttributes = "";

			// HRManagerEmail
			$cstArchivedStudents->HRManagerEmail->ViewValue = $cstArchivedStudents->HRManagerEmail->CurrentValue;
			$cstArchivedStudents->HRManagerEmail->CssStyle = "";
			$cstArchivedStudents->HRManagerEmail->CssClass = "";
			$cstArchivedStudents->HRManagerEmail->ViewCustomAttributes = "";

			// SupervisorName
			$cstArchivedStudents->SupervisorName->ViewValue = $cstArchivedStudents->SupervisorName->CurrentValue;
			$cstArchivedStudents->SupervisorName->CssStyle = "";
			$cstArchivedStudents->SupervisorName->CssClass = "";
			$cstArchivedStudents->SupervisorName->ViewCustomAttributes = "";

			// SupervisorDesig
			$cstArchivedStudents->SupervisorDesig->ViewValue = $cstArchivedStudents->SupervisorDesig->CurrentValue;
			$cstArchivedStudents->SupervisorDesig->CssStyle = "";
			$cstArchivedStudents->SupervisorDesig->CssClass = "";
			$cstArchivedStudents->SupervisorDesig->ViewCustomAttributes = "";

			// SupervisorProfRegNo
			$cstArchivedStudents->SupervisorProfRegNo->ViewValue = $cstArchivedStudents->SupervisorProfRegNo->CurrentValue;
			$cstArchivedStudents->SupervisorProfRegNo->CssStyle = "";
			$cstArchivedStudents->SupervisorProfRegNo->CssClass = "";
			$cstArchivedStudents->SupervisorProfRegNo->ViewCustomAttributes = "";

			// SupervisorTelNo
			$cstArchivedStudents->SupervisorTelNo->ViewValue = $cstArchivedStudents->SupervisorTelNo->CurrentValue;
			$cstArchivedStudents->SupervisorTelNo->CssStyle = "";
			$cstArchivedStudents->SupervisorTelNo->CssClass = "";
			$cstArchivedStudents->SupervisorTelNo->ViewCustomAttributes = "";

			// SupervisorCellNo
			$cstArchivedStudents->SupervisorCellNo->ViewValue = $cstArchivedStudents->SupervisorCellNo->CurrentValue;
			$cstArchivedStudents->SupervisorCellNo->CssStyle = "";
			$cstArchivedStudents->SupervisorCellNo->CssClass = "";
			$cstArchivedStudents->SupervisorCellNo->ViewCustomAttributes = "";

			// SupervisorEmail
			$cstArchivedStudents->SupervisorEmail->ViewValue = $cstArchivedStudents->SupervisorEmail->CurrentValue;
			$cstArchivedStudents->SupervisorEmail->CssStyle = "";
			$cstArchivedStudents->SupervisorEmail->CssClass = "";
			$cstArchivedStudents->SupervisorEmail->ViewCustomAttributes = "";

			// EducationalInst
			$cstArchivedStudents->EducationalInst->ViewValue = $cstArchivedStudents->EducationalInst->CurrentValue;
			$cstArchivedStudents->EducationalInst->CssStyle = "";
			$cstArchivedStudents->EducationalInst->CssClass = "";
			$cstArchivedStudents->EducationalInst->ViewCustomAttributes = "";

			// Qualifications
			$cstArchivedStudents->Qualifications->ViewValue = $cstArchivedStudents->Qualifications->CurrentValue;
			$cstArchivedStudents->Qualifications->CssStyle = "";
			$cstArchivedStudents->Qualifications->CssClass = "";
			$cstArchivedStudents->Qualifications->ViewCustomAttributes = "";

			// DateFinalExam
			$cstArchivedStudents->DateFinalExam->ViewValue = $cstArchivedStudents->DateFinalExam->CurrentValue;
			$cstArchivedStudents->DateFinalExam->CssStyle = "";
			$cstArchivedStudents->DateFinalExam->CssClass = "";
			$cstArchivedStudents->DateFinalExam->ViewCustomAttributes = "";

			// IDFile
			if (!ew_Empty($cstArchivedStudents->IDFile->Upload->DbValue)) {
				$cstArchivedStudents->IDFile->ViewValue = $cstArchivedStudents->IDFile->Upload->DbValue;
			} else {
				$cstArchivedStudents->IDFile->ViewValue = "";
			}
			$cstArchivedStudents->IDFile->CssStyle = "";
			$cstArchivedStudents->IDFile->CssClass = "";
			$cstArchivedStudents->IDFile->ViewCustomAttributes = "";

			// CVFile
			if (!ew_Empty($cstArchivedStudents->CVFile->Upload->DbValue)) {
				$cstArchivedStudents->CVFile->ViewValue = $cstArchivedStudents->CVFile->Upload->DbValue;
			} else {
				$cstArchivedStudents->CVFile->ViewValue = "";
			}
			$cstArchivedStudents->CVFile->CssStyle = "";
			$cstArchivedStudents->CVFile->CssClass = "";
			$cstArchivedStudents->CVFile->ViewCustomAttributes = "";

			// QualCertificate1
			if (!ew_Empty($cstArchivedStudents->QualCertificate1->Upload->DbValue)) {
				$cstArchivedStudents->QualCertificate1->ViewValue = $cstArchivedStudents->QualCertificate1->Upload->DbValue;
			} else {
				$cstArchivedStudents->QualCertificate1->ViewValue = "";
			}
			$cstArchivedStudents->QualCertificate1->CssStyle = "";
			$cstArchivedStudents->QualCertificate1->CssClass = "";
			$cstArchivedStudents->QualCertificate1->ViewCustomAttributes = "";

			// QualCertificate2
			if (!ew_Empty($cstArchivedStudents->QualCertificate2->Upload->DbValue)) {
				$cstArchivedStudents->QualCertificate2->ViewValue = $cstArchivedStudents->QualCertificate2->Upload->DbValue;
			} else {
				$cstArchivedStudents->QualCertificate2->ViewValue = "";
			}
			$cstArchivedStudents->QualCertificate2->CssStyle = "";
			$cstArchivedStudents->QualCertificate2->CssClass = "";
			$cstArchivedStudents->QualCertificate2->ViewCustomAttributes = "";

			// QualCertificate3
			if (!ew_Empty($cstArchivedStudents->QualCertificate3->Upload->DbValue)) {
				$cstArchivedStudents->QualCertificate3->ViewValue = $cstArchivedStudents->QualCertificate3->Upload->DbValue;
			} else {
				$cstArchivedStudents->QualCertificate3->ViewValue = "";
			}
			$cstArchivedStudents->QualCertificate3->CssStyle = "";
			$cstArchivedStudents->QualCertificate3->CssClass = "";
			$cstArchivedStudents->QualCertificate3->ViewCustomAttributes = "";

			// MentorUndertaking
			if (!ew_Empty($cstArchivedStudents->MentorUndertaking->Upload->DbValue)) {
				$cstArchivedStudents->MentorUndertaking->ViewValue = $cstArchivedStudents->MentorUndertaking->Upload->DbValue;
			} else {
				$cstArchivedStudents->MentorUndertaking->ViewValue = "";
			}
			$cstArchivedStudents->MentorUndertaking->CssStyle = "";
			$cstArchivedStudents->MentorUndertaking->CssClass = "";
			$cstArchivedStudents->MentorUndertaking->ViewCustomAttributes = "";

			// CandUUndertaking
			if (!ew_Empty($cstArchivedStudents->CandUUndertaking->Upload->DbValue)) {
				$cstArchivedStudents->CandUUndertaking->ViewValue = $cstArchivedStudents->CandUUndertaking->Upload->DbValue;
			} else {
				$cstArchivedStudents->CandUUndertaking->ViewValue = "";
			}
			$cstArchivedStudents->CandUUndertaking->CssStyle = "";
			$cstArchivedStudents->CandUUndertaking->CssClass = "";
			$cstArchivedStudents->CandUUndertaking->ViewCustomAttributes = "";

			// CompanyCandidatePolicy
			if (!ew_Empty($cstArchivedStudents->CompanyCandidatePolicy->Upload->DbValue)) {
				$cstArchivedStudents->CompanyCandidatePolicy->ViewValue = $cstArchivedStudents->CompanyCandidatePolicy->Upload->DbValue;
			} else {
				$cstArchivedStudents->CompanyCandidatePolicy->ViewValue = "";
			}
			$cstArchivedStudents->CompanyCandidatePolicy->CssStyle = "";
			$cstArchivedStudents->CompanyCandidatePolicy->CssClass = "";
			$cstArchivedStudents->CompanyCandidatePolicy->ViewCustomAttributes = "";

			// ResidenceProof
			if (!ew_Empty($cstArchivedStudents->ResidenceProof->Upload->DbValue)) {
				$cstArchivedStudents->ResidenceProof->ViewValue = $cstArchivedStudents->ResidenceProof->Upload->DbValue;
			} else {
				$cstArchivedStudents->ResidenceProof->ViewValue = "";
			}
			$cstArchivedStudents->ResidenceProof->CssStyle = "";
			$cstArchivedStudents->ResidenceProof->CssClass = "";
			$cstArchivedStudents->ResidenceProof->ViewCustomAttributes = "";

			// SignedAppForm
			if (!ew_Empty($cstArchivedStudents->SignedAppForm->Upload->DbValue)) {
				$cstArchivedStudents->SignedAppForm->ViewValue = $cstArchivedStudents->SignedAppForm->Upload->DbValue;
			} else {
				$cstArchivedStudents->SignedAppForm->ViewValue = "";
			}
			$cstArchivedStudents->SignedAppForm->CssStyle = "";
			$cstArchivedStudents->SignedAppForm->CssClass = "";
			$cstArchivedStudents->SignedAppForm->ViewCustomAttributes = "";

			// Photograph
			if (!ew_Empty($cstArchivedStudents->Photograph->Upload->DbValue)) {
				$cstArchivedStudents->Photograph->ViewValue = $cstArchivedStudents->Photograph->Upload->DbValue;
			} else {
				$cstArchivedStudents->Photograph->ViewValue = "";
			}
			$cstArchivedStudents->Photograph->CssStyle = "";
			$cstArchivedStudents->Photograph->CssClass = "";
			$cstArchivedStudents->Photograph->ViewCustomAttributes = "";

			// StudentNumber
			$cstArchivedStudents->StudentNumber->ViewValue = $cstArchivedStudents->StudentNumber->CurrentValue;
			$cstArchivedStudents->StudentNumber->CssStyle = "";
			$cstArchivedStudents->StudentNumber->CssClass = "";
			$cstArchivedStudents->StudentNumber->ViewCustomAttributes = "";

			// WebUsername
			$cstArchivedStudents->WebUsername->ViewValue = $cstArchivedStudents->WebUsername->CurrentValue;
			$cstArchivedStudents->WebUsername->CssStyle = "";
			$cstArchivedStudents->WebUsername->CssClass = "";
			$cstArchivedStudents->WebUsername->ViewCustomAttributes = "";

			// WebPassword
			$cstArchivedStudents->WebPassword->ViewValue = $cstArchivedStudents->WebPassword->CurrentValue;
			$cstArchivedStudents->WebPassword->CssStyle = "";
			$cstArchivedStudents->WebPassword->CssClass = "";
			$cstArchivedStudents->WebPassword->ViewCustomAttributes = "";

			// BlockAccess
			$cstArchivedStudents->BlockAccess->ViewValue = $cstArchivedStudents->BlockAccess->CurrentValue;
			$cstArchivedStudents->BlockAccess->CssStyle = "";
			$cstArchivedStudents->BlockAccess->CssClass = "";
			$cstArchivedStudents->BlockAccess->ViewCustomAttributes = "";

			// SABTACO
			$cstArchivedStudents->SABTACO->ViewValue = $cstArchivedStudents->SABTACO->CurrentValue;
			$cstArchivedStudents->SABTACO->CssStyle = "";
			$cstArchivedStudents->SABTACO->CssClass = "";
			$cstArchivedStudents->SABTACO->ViewCustomAttributes = "";

			// CESA
			$cstArchivedStudents->CESA->ViewValue = $cstArchivedStudents->CESA->CurrentValue;
			$cstArchivedStudents->CESA->CssStyle = "";
			$cstArchivedStudents->CESA->CssClass = "";
			$cstArchivedStudents->CESA->ViewCustomAttributes = "";

			// SelectionCategory
			$cstArchivedStudents->SelectionCategory->HrefValue = "";
			$cstArchivedStudents->SelectionCategory->TooltipValue = "";

			// FirstName
			$cstArchivedStudents->FirstName->HrefValue = "";
			$cstArchivedStudents->FirstName->TooltipValue = "";

			// Surname
			$cstArchivedStudents->Surname->HrefValue = "";
			$cstArchivedStudents->Surname->TooltipValue = "";

			// KnownAs
			$cstArchivedStudents->KnownAs->HrefValue = "";
			$cstArchivedStudents->KnownAs->TooltipValue = "";

			// IDNumber
			$cstArchivedStudents->IDNumber->HrefValue = "";
			$cstArchivedStudents->IDNumber->TooltipValue = "";

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

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

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

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

			// Province
			$cstArchivedStudents->Province->HrefValue = "";
			$cstArchivedStudents->Province->TooltipValue = "";

			// ProfessionalCouncil
			$cstArchivedStudents->ProfessionalCouncil->HrefValue = "";
			$cstArchivedStudents->ProfessionalCouncil->TooltipValue = "";

			// CategoryReg
			$cstArchivedStudents->CategoryReg->HrefValue = "";
			$cstArchivedStudents->CategoryReg->TooltipValue = "";

			// BelongsTo
			$cstArchivedStudents->BelongsTo->HrefValue = "";
			$cstArchivedStudents->BelongsTo->TooltipValue = "";
		}

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

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

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

		// Export all
		if ($cstArchivedStudents->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 ($cstArchivedStudents->Export == "xml") {
			$XmlDoc = new cXMLDocument(EW_XML_ENCODING);
			$XmlDoc->AddRoot();
		} else {
			$ExportDoc = new cExportDocument($cstArchivedStudents, "h");
			$ExportDoc->ExportHeader();
			if ($ExportDoc->Horizontal) { // Horizontal format, write header
				$ExportDoc->BeginExportRow();
				$ExportDoc->ExportCaption($cstArchivedStudents->Archived);
				$ExportDoc->ExportCaption($cstArchivedStudents->SelectionCategory);
				$ExportDoc->ExportCaption($cstArchivedStudents->Title);
				$ExportDoc->ExportCaption($cstArchivedStudents->Initials);
				$ExportDoc->ExportCaption($cstArchivedStudents->FirstName);
				$ExportDoc->ExportCaption($cstArchivedStudents->Surname);
				$ExportDoc->ExportCaption($cstArchivedStudents->KnownAs);
				$ExportDoc->ExportCaption($cstArchivedStudents->IDNumber);
				$ExportDoc->ExportCaption($cstArchivedStudents->Telephone);
				$ExportDoc->ExportCaption($cstArchivedStudents->Cellphone);
				$ExportDoc->ExportCaption($cstArchivedStudents->EmailAddress);
				$ExportDoc->ExportCaption($cstArchivedStudents->WorkAddress);
				$ExportDoc->ExportCaption($cstArchivedStudents->PostalAddress);
				$ExportDoc->ExportCaption($cstArchivedStudents->Department);
				$ExportDoc->ExportCaption($cstArchivedStudents->Organisation);
				$ExportDoc->ExportCaption($cstArchivedStudents->VATNo);
				$ExportDoc->ExportCaption($cstArchivedStudents->JobTitle);
				$ExportDoc->ExportCaption($cstArchivedStudents->DateofBirth);
				$ExportDoc->ExportCaption($cstArchivedStudents->PlaceofBirth);
				$ExportDoc->ExportCaption($cstArchivedStudents->CountryofBirth);
				$ExportDoc->ExportCaption($cstArchivedStudents->Province);
				$ExportDoc->ExportCaption($cstArchivedStudents->MaleorFemale);
				$ExportDoc->ExportCaption($cstArchivedStudents->RaceGroup);
				$ExportDoc->ExportCaption($cstArchivedStudents->Disability);
				$ExportDoc->ExportCaption($cstArchivedStudents->DisabilityNature);
				$ExportDoc->ExportCaption($cstArchivedStudents->DisabilityCertificate);
				$ExportDoc->ExportCaption($cstArchivedStudents->ProfessionalCouncil);
				$ExportDoc->ExportCaption($cstArchivedStudents->CategoryReg);
				$ExportDoc->ExportCaption($cstArchivedStudents->CouncilRegNumber);
				$ExportDoc->ExportCaption($cstArchivedStudents->LengthCandidateReg);
				$ExportDoc->ExportCaption($cstArchivedStudents->YearsToProfReg);
				$ExportDoc->ExportCaption($cstArchivedStudents->FirstJobStart);
				$ExportDoc->ExportCaption($cstArchivedStudents->VolAssociations);
				$ExportDoc->ExportCaption($cstArchivedStudents->BelongsTo);
				$ExportDoc->ExportCaption($cstArchivedStudents->CESA_SABTACO_MemNum);
				$ExportDoc->ExportCaption($cstArchivedStudents->AreaDiscipline);
				$ExportDoc->ExportCaption($cstArchivedStudents->AreaSubDiscipline);
				$ExportDoc->ExportCaption($cstArchivedStudents->Salary);
				$ExportDoc->ExportCaption($cstArchivedStudents->Payslip);
				$ExportDoc->ExportCaption($cstArchivedStudents->BankAccountName);
				$ExportDoc->ExportCaption($cstArchivedStudents->BankAccountBank);
				$ExportDoc->ExportCaption($cstArchivedStudents->BankAccountBranch);
				$ExportDoc->ExportCaption($cstArchivedStudents->BankAccountNo);
				$ExportDoc->ExportCaption($cstArchivedStudents->BankAccountProof);
				$ExportDoc->ExportCaption($cstArchivedStudents->Funding);
				$ExportDoc->ExportCaption($cstArchivedStudents->CWDTP);
				$ExportDoc->ExportCaption($cstArchivedStudents->BookedByName);
				$ExportDoc->ExportCaption($cstArchivedStudents->BookedByDesignation);
				$ExportDoc->ExportCaption($cstArchivedStudents->BookedByTelNo);
				$ExportDoc->ExportCaption($cstArchivedStudents->BookedByFaxNo);
				$ExportDoc->ExportCaption($cstArchivedStudents->BookedByCellNo);
				$ExportDoc->ExportCaption($cstArchivedStudents->BookedByEmail);
				$ExportDoc->ExportCaption($cstArchivedStudents->MentorID);
				$ExportDoc->ExportCaption($cstArchivedStudents->EmployerID);
				$ExportDoc->ExportCaption($cstArchivedStudents->HRManagerName);
				$ExportDoc->ExportCaption($cstArchivedStudents->HRManagerDesignation);
				$ExportDoc->ExportCaption($cstArchivedStudents->HRManagerTelNo);
				$ExportDoc->ExportCaption($cstArchivedStudents->HRManagerCellNo);
				$ExportDoc->ExportCaption($cstArchivedStudents->HRManagerEmail);
				$ExportDoc->ExportCaption($cstArchivedStudents->SupervisorName);
				$ExportDoc->ExportCaption($cstArchivedStudents->SupervisorDesig);
				$ExportDoc->ExportCaption($cstArchivedStudents->SupervisorProfRegNo);
				$ExportDoc->ExportCaption($cstArchivedStudents->SupervisorTelNo);
				$ExportDoc->ExportCaption($cstArchivedStudents->SupervisorCellNo);
				$ExportDoc->ExportCaption($cstArchivedStudents->SupervisorEmail);
				$ExportDoc->ExportCaption($cstArchivedStudents->EducationalInst);
				$ExportDoc->ExportCaption($cstArchivedStudents->Qualifications);
				$ExportDoc->ExportCaption($cstArchivedStudents->DateFinalExam);
				$ExportDoc->ExportCaption($cstArchivedStudents->IDFile);
				$ExportDoc->ExportCaption($cstArchivedStudents->CVFile);
				$ExportDoc->ExportCaption($cstArchivedStudents->QualCertificate1);
				$ExportDoc->ExportCaption($cstArchivedStudents->QualCertificate2);
				$ExportDoc->ExportCaption($cstArchivedStudents->QualCertificate3);
				$ExportDoc->ExportCaption($cstArchivedStudents->MentorUndertaking);
				$ExportDoc->ExportCaption($cstArchivedStudents->CandUUndertaking);
				$ExportDoc->ExportCaption($cstArchivedStudents->CompanyCandidatePolicy);
				$ExportDoc->ExportCaption($cstArchivedStudents->ResidenceProof);
				$ExportDoc->ExportCaption($cstArchivedStudents->SignedAppForm);
				$ExportDoc->ExportCaption($cstArchivedStudents->Photograph);
				$ExportDoc->ExportCaption($cstArchivedStudents->StudentNumber);
				$ExportDoc->ExportCaption($cstArchivedStudents->WebUsername);
				$ExportDoc->ExportCaption($cstArchivedStudents->WebPassword);
				$ExportDoc->ExportCaption($cstArchivedStudents->BlockAccess);
				$ExportDoc->ExportCaption($cstArchivedStudents->SABTACO);
				$ExportDoc->ExportCaption($cstArchivedStudents->CESA);
				$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
				$cstArchivedStudents->CssClass = "";
				$cstArchivedStudents->CssStyle = "";
				$cstArchivedStudents->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->RenderRow();
				if ($cstArchivedStudents->Export == "xml") {
					$XmlDoc->AddRow();
					$XmlDoc->AddField('Archived', $cstArchivedStudents->Archived->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('SelectionCategory', $cstArchivedStudents->SelectionCategory->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Title', $cstArchivedStudents->Title->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Initials', $cstArchivedStudents->Initials->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('FirstName', $cstArchivedStudents->FirstName->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Surname', $cstArchivedStudents->Surname->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('KnownAs', $cstArchivedStudents->KnownAs->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('IDNumber', $cstArchivedStudents->IDNumber->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Telephone', $cstArchivedStudents->Telephone->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Cellphone', $cstArchivedStudents->Cellphone->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('EmailAddress', $cstArchivedStudents->EmailAddress->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('WorkAddress', $cstArchivedStudents->WorkAddress->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('PostalAddress', $cstArchivedStudents->PostalAddress->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Department', $cstArchivedStudents->Department->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Organisation', $cstArchivedStudents->Organisation->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('VATNo', $cstArchivedStudents->VATNo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('JobTitle', $cstArchivedStudents->JobTitle->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('DateofBirth', $cstArchivedStudents->DateofBirth->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('PlaceofBirth', $cstArchivedStudents->PlaceofBirth->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('CountryofBirth', $cstArchivedStudents->CountryofBirth->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Province', $cstArchivedStudents->Province->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('MaleorFemale', $cstArchivedStudents->MaleorFemale->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('RaceGroup', $cstArchivedStudents->RaceGroup->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Disability', $cstArchivedStudents->Disability->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('DisabilityNature', $cstArchivedStudents->DisabilityNature->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('DisabilityCertificate', $cstArchivedStudents->DisabilityCertificate->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('ProfessionalCouncil', $cstArchivedStudents->ProfessionalCouncil->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('CategoryReg', $cstArchivedStudents->CategoryReg->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('CouncilRegNumber', $cstArchivedStudents->CouncilRegNumber->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('LengthCandidateReg', $cstArchivedStudents->LengthCandidateReg->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('YearsToProfReg', $cstArchivedStudents->YearsToProfReg->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('FirstJobStart', $cstArchivedStudents->FirstJobStart->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('VolAssociations', $cstArchivedStudents->VolAssociations->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BelongsTo', $cstArchivedStudents->BelongsTo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('CESA_SABTACO_MemNum', $cstArchivedStudents->CESA_SABTACO_MemNum->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('AreaDiscipline', $cstArchivedStudents->AreaDiscipline->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('AreaSubDiscipline', $cstArchivedStudents->AreaSubDiscipline->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Salary', $cstArchivedStudents->Salary->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Payslip', $cstArchivedStudents->Payslip->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BankAccountName', $cstArchivedStudents->BankAccountName->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BankAccountBank', $cstArchivedStudents->BankAccountBank->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BankAccountBranch', $cstArchivedStudents->BankAccountBranch->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BankAccountNo', $cstArchivedStudents->BankAccountNo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BankAccountProof', $cstArchivedStudents->BankAccountProof->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Funding', $cstArchivedStudents->Funding->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('CWDTP', $cstArchivedStudents->CWDTP->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BookedByName', $cstArchivedStudents->BookedByName->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BookedByDesignation', $cstArchivedStudents->BookedByDesignation->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BookedByTelNo', $cstArchivedStudents->BookedByTelNo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BookedByFaxNo', $cstArchivedStudents->BookedByFaxNo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BookedByCellNo', $cstArchivedStudents->BookedByCellNo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BookedByEmail', $cstArchivedStudents->BookedByEmail->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('MentorID', $cstArchivedStudents->MentorID->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('EmployerID', $cstArchivedStudents->EmployerID->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('HRManagerName', $cstArchivedStudents->HRManagerName->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('HRManagerDesignation', $cstArchivedStudents->HRManagerDesignation->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('HRManagerTelNo', $cstArchivedStudents->HRManagerTelNo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('HRManagerCellNo', $cstArchivedStudents->HRManagerCellNo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('HRManagerEmail', $cstArchivedStudents->HRManagerEmail->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('SupervisorName', $cstArchivedStudents->SupervisorName->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('SupervisorDesig', $cstArchivedStudents->SupervisorDesig->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('SupervisorProfRegNo', $cstArchivedStudents->SupervisorProfRegNo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('SupervisorTelNo', $cstArchivedStudents->SupervisorTelNo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('SupervisorCellNo', $cstArchivedStudents->SupervisorCellNo->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('SupervisorEmail', $cstArchivedStudents->SupervisorEmail->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('EducationalInst', $cstArchivedStudents->EducationalInst->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Qualifications', $cstArchivedStudents->Qualifications->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('DateFinalExam', $cstArchivedStudents->DateFinalExam->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('IDFile', $cstArchivedStudents->IDFile->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('CVFile', $cstArchivedStudents->CVFile->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('QualCertificate1', $cstArchivedStudents->QualCertificate1->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('QualCertificate2', $cstArchivedStudents->QualCertificate2->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('QualCertificate3', $cstArchivedStudents->QualCertificate3->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('MentorUndertaking', $cstArchivedStudents->MentorUndertaking->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('CandUUndertaking', $cstArchivedStudents->CandUUndertaking->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('CompanyCandidatePolicy', $cstArchivedStudents->CompanyCandidatePolicy->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('ResidenceProof', $cstArchivedStudents->ResidenceProof->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('SignedAppForm', $cstArchivedStudents->SignedAppForm->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('Photograph', $cstArchivedStudents->Photograph->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('StudentNumber', $cstArchivedStudents->StudentNumber->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('WebUsername', $cstArchivedStudents->WebUsername->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('WebPassword', $cstArchivedStudents->WebPassword->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('BlockAccess', $cstArchivedStudents->BlockAccess->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('SABTACO', $cstArchivedStudents->SABTACO->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
					$XmlDoc->AddField('CESA', $cstArchivedStudents->CESA->ExportValue($cstArchivedStudents->Export, $cstArchivedStudents->ExportOriginalValue));
				} else {
					$ExportDoc->BeginExportRow(TRUE); // Allow CSS styles if enabled
					$ExportDoc->ExportField($cstArchivedStudents->Archived);
					$ExportDoc->ExportField($cstArchivedStudents->SelectionCategory);
					$ExportDoc->ExportField($cstArchivedStudents->Title);
					$ExportDoc->ExportField($cstArchivedStudents->Initials);
					$ExportDoc->ExportField($cstArchivedStudents->FirstName);
					$ExportDoc->ExportField($cstArchivedStudents->Surname);
					$ExportDoc->ExportField($cstArchivedStudents->KnownAs);
					$ExportDoc->ExportField($cstArchivedStudents->IDNumber);
					$ExportDoc->ExportField($cstArchivedStudents->Telephone);
					$ExportDoc->ExportField($cstArchivedStudents->Cellphone);
					$ExportDoc->ExportField($cstArchivedStudents->EmailAddress);
					$ExportDoc->ExportField($cstArchivedStudents->WorkAddress);
					$ExportDoc->ExportField($cstArchivedStudents->PostalAddress);
					$ExportDoc->ExportField($cstArchivedStudents->Department);
					$ExportDoc->ExportField($cstArchivedStudents->Organisation);
					$ExportDoc->ExportField($cstArchivedStudents->VATNo);
					$ExportDoc->ExportField($cstArchivedStudents->JobTitle);
					$ExportDoc->ExportField($cstArchivedStudents->DateofBirth);
					$ExportDoc->ExportField($cstArchivedStudents->PlaceofBirth);
					$ExportDoc->ExportField($cstArchivedStudents->CountryofBirth);
					$ExportDoc->ExportField($cstArchivedStudents->Province);
					$ExportDoc->ExportField($cstArchivedStudents->MaleorFemale);
					$ExportDoc->ExportField($cstArchivedStudents->RaceGroup);
					$ExportDoc->ExportField($cstArchivedStudents->Disability);
					$ExportDoc->ExportField($cstArchivedStudents->DisabilityNature);
					$ExportDoc->ExportField($cstArchivedStudents->DisabilityCertificate);
					$ExportDoc->ExportField($cstArchivedStudents->ProfessionalCouncil);
					$ExportDoc->ExportField($cstArchivedStudents->CategoryReg);
					$ExportDoc->ExportField($cstArchivedStudents->CouncilRegNumber);
					$ExportDoc->ExportField($cstArchivedStudents->LengthCandidateReg);
					$ExportDoc->ExportField($cstArchivedStudents->YearsToProfReg);
					$ExportDoc->ExportField($cstArchivedStudents->FirstJobStart);
					$ExportDoc->ExportField($cstArchivedStudents->VolAssociations);
					$ExportDoc->ExportField($cstArchivedStudents->BelongsTo);
					$ExportDoc->ExportField($cstArchivedStudents->CESA_SABTACO_MemNum);
					$ExportDoc->ExportField($cstArchivedStudents->AreaDiscipline);
					$ExportDoc->ExportField($cstArchivedStudents->AreaSubDiscipline);
					$ExportDoc->ExportField($cstArchivedStudents->Salary);
					$ExportDoc->ExportField($cstArchivedStudents->Payslip);
					$ExportDoc->ExportField($cstArchivedStudents->BankAccountName);
					$ExportDoc->ExportField($cstArchivedStudents->BankAccountBank);
					$ExportDoc->ExportField($cstArchivedStudents->BankAccountBranch);
					$ExportDoc->ExportField($cstArchivedStudents->BankAccountNo);
					$ExportDoc->ExportField($cstArchivedStudents->BankAccountProof);
					$ExportDoc->ExportField($cstArchivedStudents->Funding);
					$ExportDoc->ExportField($cstArchivedStudents->CWDTP);
					$ExportDoc->ExportField($cstArchivedStudents->BookedByName);
					$ExportDoc->ExportField($cstArchivedStudents->BookedByDesignation);
					$ExportDoc->ExportField($cstArchivedStudents->BookedByTelNo);
					$ExportDoc->ExportField($cstArchivedStudents->BookedByFaxNo);
					$ExportDoc->ExportField($cstArchivedStudents->BookedByCellNo);
					$ExportDoc->ExportField($cstArchivedStudents->BookedByEmail);
					$ExportDoc->ExportField($cstArchivedStudents->MentorID);
					$ExportDoc->ExportField($cstArchivedStudents->EmployerID);
					$ExportDoc->ExportField($cstArchivedStudents->HRManagerName);
					$ExportDoc->ExportField($cstArchivedStudents->HRManagerDesignation);
					$ExportDoc->ExportField($cstArchivedStudents->HRManagerTelNo);
					$ExportDoc->ExportField($cstArchivedStudents->HRManagerCellNo);
					$ExportDoc->ExportField($cstArchivedStudents->HRManagerEmail);
					$ExportDoc->ExportField($cstArchivedStudents->SupervisorName);
					$ExportDoc->ExportField($cstArchivedStudents->SupervisorDesig);
					$ExportDoc->ExportField($cstArchivedStudents->SupervisorProfRegNo);
					$ExportDoc->ExportField($cstArchivedStudents->SupervisorTelNo);
					$ExportDoc->ExportField($cstArchivedStudents->SupervisorCellNo);
					$ExportDoc->ExportField($cstArchivedStudents->SupervisorEmail);
					$ExportDoc->ExportField($cstArchivedStudents->EducationalInst);
					$ExportDoc->ExportField($cstArchivedStudents->Qualifications);
					$ExportDoc->ExportField($cstArchivedStudents->DateFinalExam);
					$ExportDoc->ExportField($cstArchivedStudents->IDFile);
					$ExportDoc->ExportField($cstArchivedStudents->CVFile);
					$ExportDoc->ExportField($cstArchivedStudents->QualCertificate1);
					$ExportDoc->ExportField($cstArchivedStudents->QualCertificate2);
					$ExportDoc->ExportField($cstArchivedStudents->QualCertificate3);
					$ExportDoc->ExportField($cstArchivedStudents->MentorUndertaking);
					$ExportDoc->ExportField($cstArchivedStudents->CandUUndertaking);
					$ExportDoc->ExportField($cstArchivedStudents->CompanyCandidatePolicy);
					$ExportDoc->ExportField($cstArchivedStudents->ResidenceProof);
					$ExportDoc->ExportField($cstArchivedStudents->SignedAppForm);
					$ExportDoc->ExportField($cstArchivedStudents->Photograph);
					$ExportDoc->ExportField($cstArchivedStudents->StudentNumber);
					$ExportDoc->ExportField($cstArchivedStudents->WebUsername);
					$ExportDoc->ExportField($cstArchivedStudents->WebPassword);
					$ExportDoc->ExportField($cstArchivedStudents->BlockAccess);
					$ExportDoc->ExportField($cstArchivedStudents->SABTACO);
					$ExportDoc->ExportField($cstArchivedStudents->CESA);
					$ExportDoc->EndExportRow();
				}
			}
			$rs->MoveNext();
		}
		if ($cstArchivedStudents->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($cstArchivedStudents->Export, array("email", "xml")))
			echo "\xEF\xBB\xBF";

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

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

	// Export email
	function ExportEmail($EmailContent) {
		global $Language, $cstArchivedStudents;
		$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 ($cstArchivedStudents->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 $cstArchivedStudents;

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

		// Build QueryString for search
		if ($cstArchivedStudents->getSessionBasicSearchKeyword() <> "") {
			$sQry .= "&" . EW_TABLE_BASIC_SEARCH . "=" . $cstArchivedStudents->getSessionBasicSearchKeyword() . "&" . EW_TABLE_BASIC_SEARCH_TYPE . "=" . $cstArchivedStudents->getSessionBasicSearchType();
		}

		// Build QueryString for pager
		$sQry .= "&" . EW_TABLE_REC_PER_PAGE . "=" . $cstArchivedStudents->getRecordsPerPage() . "&" . EW_TABLE_START_REC . "=" . $cstArchivedStudents->getStartRecordNumber();
		return $sQry;
	}

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

	}
}
?>