Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/CCEDocumentsview.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 "CCEDocumentsinfo.php" ?>
<?php include "CCEModulesinfo.php" ?>
<?php include "CCEUsersinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$CCEDocuments_view = new cCCEDocuments_view();
$Page =& $CCEDocuments_view;

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

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

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

// page properties
CCEDocuments_view.PageID = "view"; // page ID
CCEDocuments_view.FormID = "fCCEDocumentsview"; // form ID
var EW_PAGE_ID = CCEDocuments_view.PageID; // for backward compatibility

// extend page with Form_CustomValidate function
CCEDocuments_view.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) { ?>
CCEDocuments_view.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCEDocuments_view.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</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 } ?>
<p><span class="phpmaker"><?php echo $Language->Phrase("View") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCEDocuments->TableCaption() ?>
<?php if ($CCEDocuments->Export == "") { ?>
&nbsp;&nbsp;<a href="<?php echo $CCEDocuments_view->ExportPrintUrl ?>"><?php echo $Language->Phrase("PrinterFriendly") ?></a>
&nbsp;&nbsp;<a href="<?php echo $CCEDocuments_view->ExportExcelUrl ?>"><?php echo $Language->Phrase("ExportToExcel") ?></a>
&nbsp;&nbsp;<a href="<?php echo $CCEDocuments_view->ExportWordUrl ?>"><?php echo $Language->Phrase("ExportToWord") ?></a>
&nbsp;&nbsp;<a name="emf_CCEDocuments" id="emf_CCEDocuments" href="javascript:void(0);" onclick="ew_EmailDialogShow({lnk:'emf_CCEDocuments',hdr:ewLanguage.Phrase('ExportToEmail'),key:<?php echo ew_ArrayToJsonAttr($CCEDocuments_view->arRecKey) ?>,sel:false});"><?php echo $Language->Phrase("ExportToEmail") ?></a>
<?php } ?>
<br><br>
<?php if ($CCEDocuments->Export == "") { ?>
<a href="<?php echo $CCEDocuments_view->ListUrl ?>"><?php echo $Language->Phrase("BackToList") ?></a>&nbsp;
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $CCEDocuments_view->AddUrl ?>"><?php echo $Language->Phrase("ViewPageAddLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->CanEdit()) { ?>
<a href="<?php echo $CCEDocuments_view->EditUrl ?>"><?php echo $Language->Phrase("ViewPageEditLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->CanDelete()) { ?>
<a href="<?php echo $CCEDocuments_view->DeleteUrl ?>"><?php echo $Language->Phrase("ViewPageDeleteLink") ?></a>&nbsp;
<?php } ?>
<?php } ?>
</span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$CCEDocuments_view->ShowMessage();
?>
<p>
<?php if ($CCEDocuments->Export == "") { ?>
<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($CCEDocuments_view->Pager)) $CCEDocuments_view->Pager = new cPrevNextPager($CCEDocuments_view->lStartRec, $CCEDocuments_view->lDisplayRecs, $CCEDocuments_view->lTotalRecs) ?>
<?php if ($CCEDocuments_view->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 ($CCEDocuments_view->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $CCEDocuments_view->PageUrl() ?>start=<?php echo $CCEDocuments_view->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 ($CCEDocuments_view->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $CCEDocuments_view->PageUrl() ?>start=<?php echo $CCEDocuments_view->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 $CCEDocuments_view->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($CCEDocuments_view->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $CCEDocuments_view->PageUrl() ?>start=<?php echo $CCEDocuments_view->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 ($CCEDocuments_view->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $CCEDocuments_view->PageUrl() ?>start=<?php echo $CCEDocuments_view->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 $CCEDocuments_view->Pager->PageCount ?></span></td>
	</tr></table>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($CCEDocuments_view->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>
<br>
<?php } ?>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($CCEDocuments->CCEModuleID->Visible) { // CCEModuleID ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->CCEModuleID->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->CCEModuleID->CellAttributes() ?>>
<div<?php echo $CCEDocuments->CCEModuleID->ViewAttributes() ?>><?php echo $CCEDocuments->CCEModuleID->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->DocumentCode->Visible) { // DocumentCode ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->DocumentCode->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->DocumentCode->CellAttributes() ?>>
<div<?php echo $CCEDocuments->DocumentCode->ViewAttributes() ?>><?php echo $CCEDocuments->DocumentCode->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->DocumentCategory->Visible) { // DocumentCategory ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->DocumentCategory->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->DocumentCategory->CellAttributes() ?>>
<div<?php echo $CCEDocuments->DocumentCategory->ViewAttributes() ?>><?php echo $CCEDocuments->DocumentCategory->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->DocumentName->Visible) { // DocumentName ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->DocumentName->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->DocumentName->CellAttributes() ?>>
<div<?php echo $CCEDocuments->DocumentName->ViewAttributes() ?>><?php echo $CCEDocuments->DocumentName->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->DocumentFile->Visible) { // DocumentFile ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->DocumentFile->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->DocumentFile->CellAttributes() ?>>
<?php if ($CCEDocuments->DocumentFile->HrefValue <> "" || $CCEDocuments->DocumentFile->TooltipValue <> "") { ?>
<?php if (!empty($CCEDocuments->DocumentFile->Upload->DbValue)) { ?>
<a href="<?php echo $CCEDocuments->DocumentFile->HrefValue ?>"><?php echo $CCEDocuments->DocumentFile->ViewValue ?></a>
<?php } elseif (!in_array($CCEDocuments->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($CCEDocuments->DocumentFile->Upload->DbValue)) { ?>
<?php echo $CCEDocuments->DocumentFile->ViewValue ?>
<?php } elseif (!in_array($CCEDocuments->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->DocumentURL->Visible) { // DocumentURL ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->DocumentURL->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->DocumentURL->CellAttributes() ?>>
<div<?php echo $CCEDocuments->DocumentURL->ViewAttributes() ?>><?php echo $CCEDocuments->DocumentURL->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->UploadedBy->Visible) { // UploadedBy ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->UploadedBy->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->UploadedBy->CellAttributes() ?>>
<div<?php echo $CCEDocuments->UploadedBy->ViewAttributes() ?>><?php echo $CCEDocuments->UploadedBy->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->AppliesToDate->Visible) { // AppliesToDate ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->AppliesToDate->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->AppliesToDate->CellAttributes() ?>>
<div<?php echo $CCEDocuments->AppliesToDate->ViewAttributes() ?>><?php echo $CCEDocuments->AppliesToDate->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->PresenterName->Visible) { // PresenterName ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->PresenterName->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->PresenterName->CellAttributes() ?>>
<div<?php echo $CCEDocuments->PresenterName->ViewAttributes() ?>><?php echo $CCEDocuments->PresenterName->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->ReleaseDate->Visible) { // ReleaseDate ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->ReleaseDate->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->ReleaseDate->CellAttributes() ?>>
<div<?php echo $CCEDocuments->ReleaseDate->ViewAttributes() ?>><?php echo $CCEDocuments->ReleaseDate->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->ReleaseTime->Visible) { // ReleaseTime ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->ReleaseTime->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->ReleaseTime->CellAttributes() ?>>
<div<?php echo $CCEDocuments->ReleaseTime->ViewAttributes() ?>><?php echo $CCEDocuments->ReleaseTime->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->Students->Visible) { // Students ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->Students->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->Students->CellAttributes() ?>>
<div<?php echo $CCEDocuments->Students->ViewAttributes() ?>><?php echo $CCEDocuments->Students->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->DateCreated->Visible) { // DateCreated ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->DateCreated->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->DateCreated->CellAttributes() ?>>
<div<?php echo $CCEDocuments->DateCreated->ViewAttributes() ?>><?php echo $CCEDocuments->DateCreated->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->Description->Visible) { // Description ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->Description->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->Description->CellAttributes() ?>>
<div<?php echo $CCEDocuments->Description->ViewAttributes() ?>><?php echo $CCEDocuments->Description->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->KeyWords->Visible) { // KeyWords ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->KeyWords->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->KeyWords->CellAttributes() ?>>
<div<?php echo $CCEDocuments->KeyWords->ViewAttributes() ?>><?php echo $CCEDocuments->KeyWords->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($CCEDocuments->DisplayInline->Visible) { // DisplayInline ?>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->DisplayInline->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->DisplayInline->CellAttributes() ?>>
<div<?php echo $CCEDocuments->DisplayInline->ViewAttributes() ?>><?php echo $CCEDocuments->DisplayInline->ViewValue ?></div></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<?php if ($CCEDocuments->Export == "") { ?>
<br>
<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($CCEDocuments_view->Pager)) $CCEDocuments_view->Pager = new cPrevNextPager($CCEDocuments_view->lStartRec, $CCEDocuments_view->lDisplayRecs, $CCEDocuments_view->lTotalRecs) ?>
<?php if ($CCEDocuments_view->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 ($CCEDocuments_view->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $CCEDocuments_view->PageUrl() ?>start=<?php echo $CCEDocuments_view->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 ($CCEDocuments_view->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $CCEDocuments_view->PageUrl() ?>start=<?php echo $CCEDocuments_view->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 $CCEDocuments_view->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($CCEDocuments_view->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $CCEDocuments_view->PageUrl() ?>start=<?php echo $CCEDocuments_view->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 ($CCEDocuments_view->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $CCEDocuments_view->PageUrl() ?>start=<?php echo $CCEDocuments_view->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 $CCEDocuments_view->Pager->PageCount ?></span></td>
	</tr></table>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($CCEDocuments_view->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 } ?>
<p>
<?php if ($CCEDocuments->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
$CCEDocuments_view->Page_Terminate();
?>
<?php

//
// Page class
//
class cCCEDocuments_view {

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

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

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

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

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

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

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

		// Table object (CCEDocuments)
		$GLOBALS["CCEDocuments"] = new cCCEDocuments();

		// Table object (CCEModules)
		$GLOBALS['CCEModules'] = new cCCEModules();

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

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

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

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

		// Open connection
		$conn = ew_Connect();
	}

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

		// 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->CanView()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("CCEDocumentslist.php");
		}

		// Get export parameters
		if (@$_GET["export"] <> "") {
			$CCEDocuments->Export = $_GET["export"];
		} elseif (ew_IsHttpPost()) {
			if (@$_POST["exporttype"] <> "")
				$CCEDocuments->Export = $_POST["exporttype"];
		} else {
			$CCEDocuments->setExportReturnUrl(ew_CurrentUrl());
		}
		$gsExport = $CCEDocuments->Export; // Get export parameter, used in header
		$gsExportFile = $CCEDocuments->TableVar; // Get export file, used in header
		if (@$_GET["CCEDocumentID"] <> "") {
			if ($gsExportFile <> "") $gsExportFile .= "_";
			$gsExportFile .= ew_StripSlashes($_GET["CCEDocumentID"]);
		}
		if ($CCEDocuments->Export == "excel") {
			header('Content-Type: application/vnd.ms-excel');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
		}
		if ($CCEDocuments->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();
	}
	var $lDisplayRecs = 1;
	var $lStartRec;
	var $lStopRec;
	var $lTotalRecs = 0;
	var $lRecRange = 10;
	var $lRecCnt;
	var $arRecKey = array();

	//
	// Page main
	//
	function Page_Main() {
		global $Language, $CCEDocuments;

		// Load current record
		$bLoadCurrentRecord = FALSE;
		$sReturnUrl = "";
		$bMatchRecord = FALSE;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET["CCEDocumentID"] <> "") {
				$CCEDocuments->CCEDocumentID->setQueryStringValue($_GET["CCEDocumentID"]);
				$this->arRecKey["CCEDocumentID"] = $CCEDocuments->CCEDocumentID->QueryStringValue;
			} else {
				$bLoadCurrentRecord = TRUE;
			}

			// Get action
			$CCEDocuments->CurrentAction = "I"; // Display form
			switch ($CCEDocuments->CurrentAction) {
				case "I": // Get a record to display
					$this->lStartRec = 1; // Initialize start position
					if ($rs = $this->LoadRecordset()) // Load records
						$this->lTotalRecs = $rs->RecordCount(); // Get record count
					if ($this->lTotalRecs <= 0) { // No record found
						$this->setMessage($Language->Phrase("NoRecord")); // Set no record message
						$this->Page_Terminate("CCEDocumentslist.php"); // Return to list page
					} elseif ($bLoadCurrentRecord) { // Load current record position
						$this->SetUpStartRec(); // Set up start record position

						// Point to current record
						if (intval($this->lStartRec) <= intval($this->lTotalRecs)) {
							$bMatchRecord = TRUE;
							$rs->Move($this->lStartRec-1);
						}
					} else { // Match key values
						while (!$rs->EOF) {
							if (strval($CCEDocuments->CCEDocumentID->CurrentValue) == strval($rs->fields('CCEDocumentID'))) {
								$CCEDocuments->setStartRecordNumber($this->lStartRec); // Save record position
								$bMatchRecord = TRUE;
								break;
							} else {
								$this->lStartRec++;
								$rs->MoveNext();
							}
						}
					}
					if (!$bMatchRecord) {
						$this->setMessage($Language->Phrase("NoRecord")); // Set no record message
						$sReturnUrl = "CCEDocumentslist.php"; // No matching record, return to list
					} else {
						$this->LoadRowValues($rs); // Load row values
					}
			}

			// Export data only
			if (in_array($CCEDocuments->Export, array("html","word","excel","xml","csv","email"))) {
				$this->ExportData();
				if ($CCEDocuments->Export <> "email")
					$this->Page_Terminate(); // Terminate response
				exit();
			}
		} else {
			$sReturnUrl = "CCEDocumentslist.php"; // Not page request, return to list
		}
		if ($sReturnUrl <> "")
			$this->Page_Terminate($sReturnUrl);

		// Render row
		$CCEDocuments->RowType = EW_ROWTYPE_VIEW;
		$this->RenderRow();
	}

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

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

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

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

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

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

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $CCEDocuments;
		$CCEDocuments->CCEDocumentID->setDbValue($rs->fields('CCEDocumentID'));
		$CCEDocuments->CCEModuleID->setDbValue($rs->fields('CCEModuleID'));
		$CCEDocuments->DocumentCode->setDbValue($rs->fields('DocumentCode'));
		$CCEDocuments->DocumentCategory->setDbValue($rs->fields('DocumentCategory'));
		$CCEDocuments->DocumentName->setDbValue($rs->fields('DocumentName'));
		$CCEDocuments->DocumentFile->Upload->DbValue = $rs->fields('DocumentFile');
		$CCEDocuments->DocumentURL->setDbValue($rs->fields('DocumentURL'));
		$CCEDocuments->DocumentThumb->setDbValue($rs->fields('DocumentThumb'));
		$CCEDocuments->UploadedBy->setDbValue($rs->fields('UploadedBy'));
		$CCEDocuments->AppliesToDate->setDbValue($rs->fields('AppliesToDate'));
		$CCEDocuments->CCEWeeklySessionID->setDbValue($rs->fields('CCEWeeklySessionID'));
		$CCEDocuments->PresenterName->setDbValue($rs->fields('PresenterName'));
		$CCEDocuments->PresentationTime->setDbValue($rs->fields('PresentationTime'));
		$CCEDocuments->ReleaseDate->setDbValue($rs->fields('ReleaseDate'));
		$CCEDocuments->ReleaseTime->setDbValue($rs->fields('ReleaseTime'));
		$CCEDocuments->Students->setDbValue($rs->fields('Students'));
		$CCEDocuments->Archived->setDbValue($rs->fields('Archived'));
		$CCEDocuments->ArchiveYear->setDbValue($rs->fields('ArchiveYear'));
		$CCEDocuments->DateCreated->setDbValue($rs->fields('DateCreated'));
		$CCEDocuments->Description->setDbValue($rs->fields('Description'));
		$CCEDocuments->KeyWords->setDbValue($rs->fields('KeyWords'));
		$CCEDocuments->DisplayInline->setDbValue($rs->fields('DisplayInline'));
	}

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

		// Initialize URLs
		$this->ExportPrintUrl = $this->PageUrl() . "export=print&" . "CCEDocumentID=" . urlencode($CCEDocuments->CCEDocumentID->CurrentValue);
		$this->ExportHtmlUrl = $this->PageUrl() . "export=html&" . "CCEDocumentID=" . urlencode($CCEDocuments->CCEDocumentID->CurrentValue);
		$this->ExportExcelUrl = $this->PageUrl() . "export=excel&" . "CCEDocumentID=" . urlencode($CCEDocuments->CCEDocumentID->CurrentValue);
		$this->ExportWordUrl = $this->PageUrl() . "export=word&" . "CCEDocumentID=" . urlencode($CCEDocuments->CCEDocumentID->CurrentValue);
		$this->ExportXmlUrl = $this->PageUrl() . "export=xml&" . "CCEDocumentID=" . urlencode($CCEDocuments->CCEDocumentID->CurrentValue);
		$this->ExportCsvUrl = $this->PageUrl() . "export=csv&" . "CCEDocumentID=" . urlencode($CCEDocuments->CCEDocumentID->CurrentValue);
		$this->AddUrl = $CCEDocuments->AddUrl();
		$this->EditUrl = $CCEDocuments->EditUrl();
		$this->CopyUrl = $CCEDocuments->CopyUrl();
		$this->DeleteUrl = $CCEDocuments->DeleteUrl();
		$this->ListUrl = $CCEDocuments->ListUrl();

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

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

		$CCEDocuments->CCEModuleID->CellCssStyle = ""; $CCEDocuments->CCEModuleID->CellCssClass = "";
		$CCEDocuments->CCEModuleID->CellAttrs = array(); $CCEDocuments->CCEModuleID->ViewAttrs = array(); $CCEDocuments->CCEModuleID->EditAttrs = array();

		// DocumentCode
		$CCEDocuments->DocumentCode->CellCssStyle = ""; $CCEDocuments->DocumentCode->CellCssClass = "";
		$CCEDocuments->DocumentCode->CellAttrs = array(); $CCEDocuments->DocumentCode->ViewAttrs = array(); $CCEDocuments->DocumentCode->EditAttrs = array();

		// DocumentCategory
		$CCEDocuments->DocumentCategory->CellCssStyle = ""; $CCEDocuments->DocumentCategory->CellCssClass = "";
		$CCEDocuments->DocumentCategory->CellAttrs = array(); $CCEDocuments->DocumentCategory->ViewAttrs = array(); $CCEDocuments->DocumentCategory->EditAttrs = array();

		// DocumentName
		$CCEDocuments->DocumentName->CellCssStyle = ""; $CCEDocuments->DocumentName->CellCssClass = "";
		$CCEDocuments->DocumentName->CellAttrs = array(); $CCEDocuments->DocumentName->ViewAttrs = array(); $CCEDocuments->DocumentName->EditAttrs = array();

		// DocumentFile
		$CCEDocuments->DocumentFile->CellCssStyle = ""; $CCEDocuments->DocumentFile->CellCssClass = "";
		$CCEDocuments->DocumentFile->CellAttrs = array(); $CCEDocuments->DocumentFile->ViewAttrs = array(); $CCEDocuments->DocumentFile->EditAttrs = array();

		// DocumentURL
		$CCEDocuments->DocumentURL->CellCssStyle = ""; $CCEDocuments->DocumentURL->CellCssClass = "";
		$CCEDocuments->DocumentURL->CellAttrs = array(); $CCEDocuments->DocumentURL->ViewAttrs = array(); $CCEDocuments->DocumentURL->EditAttrs = array();

		// UploadedBy
		$CCEDocuments->UploadedBy->CellCssStyle = ""; $CCEDocuments->UploadedBy->CellCssClass = "";
		$CCEDocuments->UploadedBy->CellAttrs = array(); $CCEDocuments->UploadedBy->ViewAttrs = array(); $CCEDocuments->UploadedBy->EditAttrs = array();

		// AppliesToDate
		$CCEDocuments->AppliesToDate->CellCssStyle = ""; $CCEDocuments->AppliesToDate->CellCssClass = "";
		$CCEDocuments->AppliesToDate->CellAttrs = array(); $CCEDocuments->AppliesToDate->ViewAttrs = array(); $CCEDocuments->AppliesToDate->EditAttrs = array();

		// PresenterName
		$CCEDocuments->PresenterName->CellCssStyle = ""; $CCEDocuments->PresenterName->CellCssClass = "";
		$CCEDocuments->PresenterName->CellAttrs = array(); $CCEDocuments->PresenterName->ViewAttrs = array(); $CCEDocuments->PresenterName->EditAttrs = array();

		// ReleaseDate
		$CCEDocuments->ReleaseDate->CellCssStyle = ""; $CCEDocuments->ReleaseDate->CellCssClass = "";
		$CCEDocuments->ReleaseDate->CellAttrs = array(); $CCEDocuments->ReleaseDate->ViewAttrs = array(); $CCEDocuments->ReleaseDate->EditAttrs = array();

		// ReleaseTime
		$CCEDocuments->ReleaseTime->CellCssStyle = ""; $CCEDocuments->ReleaseTime->CellCssClass = "";
		$CCEDocuments->ReleaseTime->CellAttrs = array(); $CCEDocuments->ReleaseTime->ViewAttrs = array(); $CCEDocuments->ReleaseTime->EditAttrs = array();

		// Students
		$CCEDocuments->Students->CellCssStyle = ""; $CCEDocuments->Students->CellCssClass = "";
		$CCEDocuments->Students->CellAttrs = array(); $CCEDocuments->Students->ViewAttrs = array(); $CCEDocuments->Students->EditAttrs = array();

		// DateCreated
		$CCEDocuments->DateCreated->CellCssStyle = ""; $CCEDocuments->DateCreated->CellCssClass = "";
		$CCEDocuments->DateCreated->CellAttrs = array(); $CCEDocuments->DateCreated->ViewAttrs = array(); $CCEDocuments->DateCreated->EditAttrs = array();

		// Description
		$CCEDocuments->Description->CellCssStyle = ""; $CCEDocuments->Description->CellCssClass = "";
		$CCEDocuments->Description->CellAttrs = array(); $CCEDocuments->Description->ViewAttrs = array(); $CCEDocuments->Description->EditAttrs = array();

		// KeyWords
		$CCEDocuments->KeyWords->CellCssStyle = ""; $CCEDocuments->KeyWords->CellCssClass = "";
		$CCEDocuments->KeyWords->CellAttrs = array(); $CCEDocuments->KeyWords->ViewAttrs = array(); $CCEDocuments->KeyWords->EditAttrs = array();

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

			// CCEDocumentID
			$CCEDocuments->CCEDocumentID->ViewValue = $CCEDocuments->CCEDocumentID->CurrentValue;
			$CCEDocuments->CCEDocumentID->CssStyle = "";
			$CCEDocuments->CCEDocumentID->CssClass = "";
			$CCEDocuments->CCEDocumentID->ViewCustomAttributes = "";

			// CCEModuleID
			if (strval($CCEDocuments->CCEModuleID->CurrentValue) <> "") {
				$sFilterWrk = "CCEModules.CCEModuleID = " . ew_AdjustSql($CCEDocuments->CCEModuleID->CurrentValue) . "";
			$sSqlWrk = "SELECT CCEModules.ModuleNum AS `ModuleNum`, CCEModules.ModuleName AS `ModuleName` FROM CCECourses Inner Join CCEModules On CCECourses.CCECourseID = CCEModules.CCECourseID";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY CCECourses.CCECourseID, CCEModules.ModuleNum";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEDocuments->CCEModuleID->ViewValue = $rswrk->fields('ModuleNum');
					$CCEDocuments->CCEModuleID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('ModuleName');
					$rswrk->Close();
				} else {
					$CCEDocuments->CCEModuleID->ViewValue = $CCEDocuments->CCEModuleID->CurrentValue;
				}
			} else {
				$CCEDocuments->CCEModuleID->ViewValue = NULL;
			}
			$CCEDocuments->CCEModuleID->CssStyle = "";
			$CCEDocuments->CCEModuleID->CssClass = "";
			$CCEDocuments->CCEModuleID->ViewCustomAttributes = "";

			// DocumentCode
			$CCEDocuments->DocumentCode->ViewValue = $CCEDocuments->DocumentCode->CurrentValue;
			$CCEDocuments->DocumentCode->CssStyle = "";
			$CCEDocuments->DocumentCode->CssClass = "";
			$CCEDocuments->DocumentCode->ViewCustomAttributes = "";

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

			// DocumentName
			$CCEDocuments->DocumentName->ViewValue = $CCEDocuments->DocumentName->CurrentValue;
			$CCEDocuments->DocumentName->CssStyle = "";
			$CCEDocuments->DocumentName->CssClass = "";
			$CCEDocuments->DocumentName->ViewCustomAttributes = "";

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

			// DocumentURL
			$CCEDocuments->DocumentURL->ViewValue = $CCEDocuments->DocumentURL->CurrentValue;
			$CCEDocuments->DocumentURL->CssStyle = "";
			$CCEDocuments->DocumentURL->CssClass = "";
			$CCEDocuments->DocumentURL->ViewCustomAttributes = "";

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

			// AppliesToDate
			if (strval($CCEDocuments->AppliesToDate->CurrentValue) <> "") {
				$sFilterWrk = "`SessionDate` = '" . ew_AdjustSql($CCEDocuments->AppliesToDate->CurrentValue) . "'";
			$sSqlWrk = "SELECT DISTINCT `SessionDate` FROM `CCEWeeklySessions`";
			$sWhereWrk = "";
			if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
			$sWhereWrk .= "(" . "YEAR(SessionDate)=YEAR(NOW())" . ")";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `SessionDate`";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEDocuments->AppliesToDate->ViewValue = $rswrk->fields('SessionDate');
					$rswrk->Close();
				} else {
					$CCEDocuments->AppliesToDate->ViewValue = $CCEDocuments->AppliesToDate->CurrentValue;
				}
			} else {
				$CCEDocuments->AppliesToDate->ViewValue = NULL;
			}
			$CCEDocuments->AppliesToDate->ViewValue = ew_FormatDateTime($CCEDocuments->AppliesToDate->ViewValue, 5);
			$CCEDocuments->AppliesToDate->CssStyle = "";
			$CCEDocuments->AppliesToDate->CssClass = "";
			$CCEDocuments->AppliesToDate->ViewCustomAttributes = "";

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

			// PresentationTime
			$CCEDocuments->PresentationTime->ViewValue = $CCEDocuments->PresentationTime->CurrentValue;
			$CCEDocuments->PresentationTime->CssStyle = "";
			$CCEDocuments->PresentationTime->CssClass = "";
			$CCEDocuments->PresentationTime->ViewCustomAttributes = "";

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

			// ReleaseTime
			$CCEDocuments->ReleaseTime->ViewValue = $CCEDocuments->ReleaseTime->CurrentValue;
			$CCEDocuments->ReleaseTime->ViewValue = ew_FormatDateTime($CCEDocuments->ReleaseTime->ViewValue, 4);
			$CCEDocuments->ReleaseTime->CssStyle = "";
			$CCEDocuments->ReleaseTime->CssClass = "";
			$CCEDocuments->ReleaseTime->ViewCustomAttributes = "";

			// Students
			if (strval($CCEDocuments->Students->CurrentValue) <> "") {
				$arwrk = explode(",", $CCEDocuments->Students->CurrentValue);
				$sFilterWrk = "";
				foreach ($arwrk as $wrk) {
					if ($sFilterWrk <> "") $sFilterWrk .= " OR ";
					$sFilterWrk .= "`CCEStudentID` = " . ew_AdjustSql(trim($wrk)) . "";
				}	
			$sSqlWrk = "SELECT `Surname`, `FirstName` FROM `CCEStudents`";
			$sWhereWrk = "";
			if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
			$sWhereWrk .= "(" . "Archived=0 AND CCEStudentID in (select CCEStudentID from CCEStudentCourses, CCESetup WHERE CCECourseScheduleID=CurrentScheduleID)" . ")";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Surname`";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEDocuments->Students->ViewValue = "";
					$ari = 0;
					while (!$rswrk->EOF) {
						$CCEDocuments->Students->ViewValue .= $rswrk->fields('Surname');
						$CCEDocuments->Students->ViewValue .= ew_ValueSeparator($ari) . $rswrk->fields('FirstName');
						$rswrk->MoveNext();
						if (!$rswrk->EOF) $CCEDocuments->Students->ViewValue .= ew_ViewOptionSeparator($ari); // Separate Options
						$ari++;
					}
					$rswrk->Close();
				} else {
					$CCEDocuments->Students->ViewValue = $CCEDocuments->Students->CurrentValue;
				}
			} else {
				$CCEDocuments->Students->ViewValue = NULL;
			}
			$CCEDocuments->Students->CssStyle = "";
			$CCEDocuments->Students->CssClass = "";
			$CCEDocuments->Students->ViewCustomAttributes = "";

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

			// ArchiveYear
			$CCEDocuments->ArchiveYear->ViewValue = $CCEDocuments->ArchiveYear->CurrentValue;
			$CCEDocuments->ArchiveYear->CssStyle = "";
			$CCEDocuments->ArchiveYear->CssClass = "";
			$CCEDocuments->ArchiveYear->ViewCustomAttributes = "";

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

			// Description
			$CCEDocuments->Description->ViewValue = $CCEDocuments->Description->CurrentValue;
			$CCEDocuments->Description->CssStyle = "";
			$CCEDocuments->Description->CssClass = "";
			$CCEDocuments->Description->ViewCustomAttributes = "";

			// KeyWords
			$CCEDocuments->KeyWords->ViewValue = $CCEDocuments->KeyWords->CurrentValue;
			$CCEDocuments->KeyWords->CssStyle = "";
			$CCEDocuments->KeyWords->CssClass = "";
			$CCEDocuments->KeyWords->ViewCustomAttributes = "";

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

			// CCEModuleID
			$CCEDocuments->CCEModuleID->HrefValue = "";
			$CCEDocuments->CCEModuleID->TooltipValue = "";

			// DocumentCode
			$CCEDocuments->DocumentCode->HrefValue = "";
			$CCEDocuments->DocumentCode->TooltipValue = "";

			// DocumentCategory
			$CCEDocuments->DocumentCategory->HrefValue = "";
			$CCEDocuments->DocumentCategory->TooltipValue = "";

			// DocumentName
			$CCEDocuments->DocumentName->HrefValue = "";
			$CCEDocuments->DocumentName->TooltipValue = "";

			// DocumentFile
			if (!ew_Empty($CCEDocuments->DocumentFile->Upload->DbValue)) {
				$CCEDocuments->DocumentFile->HrefValue = ew_UploadPathEx(FALSE, $CCEDocuments->DocumentFile->UploadPath) . ((!empty($CCEDocuments->DocumentFile->ViewValue)) ? $CCEDocuments->DocumentFile->ViewValue : $CCEDocuments->DocumentFile->CurrentValue);
				if ($CCEDocuments->Export <> "") $CCEDocuments->DocumentFile->HrefValue = ew_ConvertFullUrl($CCEDocuments->DocumentFile->HrefValue);
			} else {
				$CCEDocuments->DocumentFile->HrefValue = "";
			}
			$CCEDocuments->DocumentFile->TooltipValue = "";

			// DocumentURL
			$CCEDocuments->DocumentURL->HrefValue = "";
			$CCEDocuments->DocumentURL->TooltipValue = "";

			// UploadedBy
			$CCEDocuments->UploadedBy->HrefValue = "";
			$CCEDocuments->UploadedBy->TooltipValue = "";

			// AppliesToDate
			$CCEDocuments->AppliesToDate->HrefValue = "";
			$CCEDocuments->AppliesToDate->TooltipValue = "";

			// PresenterName
			$CCEDocuments->PresenterName->HrefValue = "";
			$CCEDocuments->PresenterName->TooltipValue = "";

			// ReleaseDate
			$CCEDocuments->ReleaseDate->HrefValue = "";
			$CCEDocuments->ReleaseDate->TooltipValue = "";

			// ReleaseTime
			$CCEDocuments->ReleaseTime->HrefValue = "";
			$CCEDocuments->ReleaseTime->TooltipValue = "";

			// Students
			$CCEDocuments->Students->HrefValue = "";
			$CCEDocuments->Students->TooltipValue = "";

			// DateCreated
			$CCEDocuments->DateCreated->HrefValue = "";
			$CCEDocuments->DateCreated->TooltipValue = "";

			// Description
			$CCEDocuments->Description->HrefValue = "";
			$CCEDocuments->Description->TooltipValue = "";

			// KeyWords
			$CCEDocuments->KeyWords->HrefValue = "";
			$CCEDocuments->KeyWords->TooltipValue = "";

			// DisplayInline
			$CCEDocuments->DisplayInline->HrefValue = "";
			$CCEDocuments->DisplayInline->TooltipValue = "";
		}

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

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

		// Load recordset
		if ($bSelectLimit) {
			$this->lTotalRecs = $CCEDocuments->SelectRecordCount();
		} else {
			if ($rs = $this->LoadRecordset())
				$this->lTotalRecs = $rs->RecordCount();
		}
		$this->lStartRec = 1;
		$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 (!$rs) {
			header("Content-Type:"); // Remove header
			header("Content-Disposition:");
			$this->ShowMessage();
			return;
		}
		if ($CCEDocuments->Export == "xml") {
			$XmlDoc = new cXMLDocument(EW_XML_ENCODING);
			$XmlDoc->AddRoot();
		} else {
			$ExportDoc = new cExportDocument($CCEDocuments, "v");
			$ExportDoc->ExportHeader();
			if ($ExportDoc->Horizontal) { // Horizontal format, write header
				$ExportDoc->BeginExportRow();
				$ExportDoc->ExportCaption($CCEDocuments->CCEDocumentID);
				$ExportDoc->ExportCaption($CCEDocuments->CCEModuleID);
				$ExportDoc->ExportCaption($CCEDocuments->DocumentCode);
				$ExportDoc->ExportCaption($CCEDocuments->DocumentCategory);
				$ExportDoc->ExportCaption($CCEDocuments->DocumentName);
				$ExportDoc->ExportCaption($CCEDocuments->DocumentFile);
				$ExportDoc->ExportCaption($CCEDocuments->DocumentURL);
				$ExportDoc->ExportCaption($CCEDocuments->UploadedBy);
				$ExportDoc->ExportCaption($CCEDocuments->AppliesToDate);
				$ExportDoc->ExportCaption($CCEDocuments->PresenterName);
				$ExportDoc->ExportCaption($CCEDocuments->PresentationTime);
				$ExportDoc->ExportCaption($CCEDocuments->ReleaseDate);
				$ExportDoc->ExportCaption($CCEDocuments->ReleaseTime);
				$ExportDoc->ExportCaption($CCEDocuments->Archived);
				$ExportDoc->ExportCaption($CCEDocuments->ArchiveYear);
				$ExportDoc->ExportCaption($CCEDocuments->DateCreated);
				$ExportDoc->ExportCaption($CCEDocuments->Description);
				$ExportDoc->ExportCaption($CCEDocuments->KeyWords);
				$ExportDoc->ExportCaption($CCEDocuments->DisplayInline);
				$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
				$CCEDocuments->CssClass = "";
				$CCEDocuments->CssStyle = "";
				$CCEDocuments->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->RenderRow();
				if ($CCEDocuments->Export == "xml") {
					$XmlDoc->AddRow();
					$XmlDoc->AddField('CCEDocumentID', $CCEDocuments->CCEDocumentID->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('CCEModuleID', $CCEDocuments->CCEModuleID->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('DocumentCode', $CCEDocuments->DocumentCode->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('DocumentCategory', $CCEDocuments->DocumentCategory->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('DocumentName', $CCEDocuments->DocumentName->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('DocumentFile', $CCEDocuments->DocumentFile->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('DocumentURL', $CCEDocuments->DocumentURL->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('UploadedBy', $CCEDocuments->UploadedBy->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('AppliesToDate', $CCEDocuments->AppliesToDate->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('PresenterName', $CCEDocuments->PresenterName->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('PresentationTime', $CCEDocuments->PresentationTime->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('ReleaseDate', $CCEDocuments->ReleaseDate->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('ReleaseTime', $CCEDocuments->ReleaseTime->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('Archived', $CCEDocuments->Archived->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('ArchiveYear', $CCEDocuments->ArchiveYear->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('DateCreated', $CCEDocuments->DateCreated->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('Description', $CCEDocuments->Description->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('KeyWords', $CCEDocuments->KeyWords->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
					$XmlDoc->AddField('DisplayInline', $CCEDocuments->DisplayInline->ExportValue($CCEDocuments->Export, $CCEDocuments->ExportOriginalValue));
				} else {
					$ExportDoc->BeginExportRow(TRUE); // Allow CSS styles if enabled
					$ExportDoc->ExportField($CCEDocuments->CCEDocumentID);
					$ExportDoc->ExportField($CCEDocuments->CCEModuleID);
					$ExportDoc->ExportField($CCEDocuments->DocumentCode);
					$ExportDoc->ExportField($CCEDocuments->DocumentCategory);
					$ExportDoc->ExportField($CCEDocuments->DocumentName);
					$ExportDoc->ExportField($CCEDocuments->DocumentFile);
					$ExportDoc->ExportField($CCEDocuments->DocumentURL);
					$ExportDoc->ExportField($CCEDocuments->UploadedBy);
					$ExportDoc->ExportField($CCEDocuments->AppliesToDate);
					$ExportDoc->ExportField($CCEDocuments->PresenterName);
					$ExportDoc->ExportField($CCEDocuments->PresentationTime);
					$ExportDoc->ExportField($CCEDocuments->ReleaseDate);
					$ExportDoc->ExportField($CCEDocuments->ReleaseTime);
					$ExportDoc->ExportField($CCEDocuments->Archived);
					$ExportDoc->ExportField($CCEDocuments->ArchiveYear);
					$ExportDoc->ExportField($CCEDocuments->DateCreated);
					$ExportDoc->ExportField($CCEDocuments->Description);
					$ExportDoc->ExportField($CCEDocuments->KeyWords);
					$ExportDoc->ExportField($CCEDocuments->DisplayInline);
					$ExportDoc->EndExportRow();
				}
			}
			$rs->MoveNext();
		}
		if ($CCEDocuments->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($CCEDocuments->Export, array("email", "xml")))
			echo "\xEF\xBB\xBF";

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

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

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

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

		// Add record key QueryString
		$sQry .= "&" . substr($CCEDocuments->KeyUrl("", ""), 1);
		return $sQry;
	}

	// 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";

	}
}
?>