Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceconvenors/
Upload File :
Current File : /var/www/cesa.co.za/cceconvenors/CCEDocumentssrch.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 "CCEFacilitatorUsersinfo.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_search = new cCCEDocuments_search();
$Page =& $CCEDocuments_search;

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

// Page main
$CCEDocuments_search->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--

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

// page properties
CCEDocuments_search.PageID = "search"; // page ID
CCEDocuments_search.FormID = "fCCEDocumentssearch"; // form ID
var EW_PAGE_ID = CCEDocuments_search.PageID; // for backward compatibility

// extend page with validate function for search
CCEDocuments_search.ValidateSearch = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (this.ValidateRequired) {
		var infix = "";

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj))
			return false;
	}
	for (var i=0; i<fobj.elements.length; i++) {
		var elem = fobj.elements[i];
		if (elem.name.substring(0,2) == "s_" || elem.name.substring(0,3) == "sv_")
			elem.value = "";
	}
	return true;
}

// extend page with Form_CustomValidate function
CCEDocuments_search.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_search.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCEDocuments_search.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>
<p><span class="phpmaker"><?php echo $Language->Phrase("Search") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCEDocuments->TableCaption() ?><br><br>
<a href="<?php echo $CCEDocuments->getReturnUrl() ?>"><?php echo $Language->Phrase("BackToList") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$CCEDocuments_search->ShowMessage();
?>
<form name="fCCEDocumentssearch" id="fCCEDocumentssearch" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return CCEDocuments_search.ValidateSearch(this);">
<p>
<input type="hidden" name="t" id="t" value="CCEDocuments">
<input type="hidden" name="a_search" id="a_search" value="S">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->CCEModuleID->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->CCEModuleID->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_CCEModuleID" id="z_CCEModuleID" value="="></span></td>
		<td<?php echo $CCEDocuments->CCEModuleID->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<select id="x_CCEModuleID" name="x_CCEModuleID" title="<?php echo $CCEDocuments->CCEModuleID->FldTitle() ?>"<?php echo $CCEDocuments->CCEModuleID->EditAttributes() ?>>
<?php
if (is_array($CCEDocuments->CCEModuleID->EditValue)) {
	$arwrk = $CCEDocuments->CCEModuleID->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEDocuments->CCEModuleID->AdvancedSearch->SearchValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
<?php if ($arwrk[$rowcntwrk][2] <> "") { ?>
<?php echo ew_ValueSeparator($rowcntwrk) ?><?php echo $arwrk[$rowcntwrk][2] ?>
<?php } ?>
</option>
<?php
	}
}
?>
</select>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->DocumentCategory->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->DocumentCategory->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_DocumentCategory" id="z_DocumentCategory" value="="></span></td>
		<td<?php echo $CCEDocuments->DocumentCategory->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<select id="x_DocumentCategory" name="x_DocumentCategory" title="<?php echo $CCEDocuments->DocumentCategory->FldTitle() ?>"<?php echo $CCEDocuments->DocumentCategory->EditAttributes() ?>>
<?php
if (is_array($CCEDocuments->DocumentCategory->EditValue)) {
	$arwrk = $CCEDocuments->DocumentCategory->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEDocuments->DocumentCategory->AdvancedSearch->SearchValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCEDocuments->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEDocuments->DocumentName->FldCaption() ?></td>
		<td<?php echo $CCEDocuments->DocumentName->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_DocumentName" id="z_DocumentName" value="LIKE"></span></td>
		<td<?php echo $CCEDocuments->DocumentName->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_DocumentName" id="x_DocumentName" title="<?php echo $CCEDocuments->DocumentName->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEDocuments->DocumentName->EditValue ?>"<?php echo $CCEDocuments->DocumentName->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="Action" id="Action" value="<?php echo ew_BtnCaption($Language->Phrase("Search")) ?>">
<input type="button" name="Reset" id="Reset" value="<?php echo ew_BtnCaption($Language->Phrase("Reset")) ?>" onclick="ew_ClearForm(this.form);">
</form>
<script language="JavaScript" type="text/javascript">
<!--

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

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

//
// Page class
//
class cCCEDocuments_search {

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

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

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

	// 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 (CCEFacilitatorUsers)
		$GLOBALS['CCEFacilitatorUsers'] = new cCCEFacilitatorUsers();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'search', 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");
		}

		// Create form object
		$objForm = new cFormObj();

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

	//
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsSearchError, $CCEDocuments;
		if ($this->IsPageRequest()) { // Validate request

			// Get action
			$CCEDocuments->CurrentAction = $objForm->GetValue("a_search");
			switch ($CCEDocuments->CurrentAction) {
				case "S": // Get search criteria

					// Build search string for advanced search, remove blank field
					$this->LoadSearchValues(); // Get search values
					if ($this->ValidateSearch()) {
						$sSrchStr = $this->BuildAdvancedSearch();
					} else {
						$sSrchStr = "";
						$this->setMessage($gsSearchError);
					}
					if ($sSrchStr <> "") {
						$sSrchStr = $CCEDocuments->UrlParm($sSrchStr);
						$this->Page_Terminate("CCEDocumentslist.php" . "?" . $sSrchStr); // Go to list page
					}
			}
		}

		// Restore search settings from Session
		if ($gsSearchError == "")
			$this->LoadAdvancedSearch();

		// Render row for search
		$CCEDocuments->RowType = EW_ROWTYPE_SEARCH;
		$this->RenderRow();
	}

// Build advanced search
function BuildAdvancedSearch() {
	global $CCEDocuments;
	$sSrchUrl = "";
	$this->BuildSearchUrl($sSrchUrl, $CCEDocuments->CCEModuleID); // CCEModuleID
	$this->BuildSearchUrl($sSrchUrl, $CCEDocuments->DocumentCategory); // DocumentCategory
	$this->BuildSearchUrl($sSrchUrl, $CCEDocuments->DocumentName); // DocumentName
	return $sSrchUrl;
}

// Build search URL
function BuildSearchUrl(&$Url, &$Fld) {
	global $objForm;
	$sWrk = "";
	$FldParm = substr($Fld->FldVar, 2);
	$FldVal = $objForm->GetValue("x_$FldParm");
	$FldOpr = $objForm->GetValue("z_$FldParm");
	$FldCond = $objForm->GetValue("v_$FldParm");
	$FldVal2 = $objForm->GetValue("y_$FldParm");
	$FldOpr2 = $objForm->GetValue("w_$FldParm");
	$FldVal = ew_StripSlashes($FldVal);
	if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
	$FldVal2 = ew_StripSlashes($FldVal2);
	if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
	$FldOpr = strtoupper(trim($FldOpr));
	$lFldDataType = ($Fld->FldIsVirtual) ? EW_DATATYPE_STRING : $Fld->FldDataType;
	if ($FldOpr == "BETWEEN") {
		$IsValidValue = ($lFldDataType <> EW_DATATYPE_NUMBER) ||
			($lFldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal) && is_numeric($FldVal2));
		if ($FldVal <> "" && $FldVal2 <> "" && $IsValidValue) {
			$sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
				"&y_" . $FldParm . "=" . urlencode($FldVal2) .
				"&z_" . $FldParm . "=" . urlencode($FldOpr);
		}
	} elseif ($FldOpr == "IS NULL" || $FldOpr == "IS NOT NULL") {
		$sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
			"&z_" . $FldParm . "=" . urlencode($FldOpr);
	} else {
		$IsValidValue = ($lFldDataType <> EW_DATATYPE_NUMBER) ||
			($lFldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal));
		if ($FldVal <> "" && $IsValidValue && ew_IsValidOpr($FldOpr, $lFldDataType)) {

			//$FldVal = $this->ConvertSearchValue($Fld, $FldVal);
			$sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
				"&z_" . $FldParm . "=" . urlencode($FldOpr);
		}
		$IsValidValue = ($lFldDataType <> EW_DATATYPE_NUMBER) ||
			($lFldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal2));
		if ($FldVal2 <> "" && $IsValidValue && ew_IsValidOpr($FldOpr2, $lFldDataType)) {

			//$FldVal2 = $this->ConvertSearchValue($Fld, $FldVal2);
			if ($sWrk <> "") $sWrk .= "&v_" . $FldParm . "=" . urlencode($FldCond) . "&";
			$sWrk .= "&y_" . $FldParm . "=" . urlencode($FldVal2) .
				"&w_" . $FldParm . "=" . urlencode($FldOpr2);
		}
	}
	if ($sWrk <> "") {
		if ($Url <> "") $Url .= "&";
		$Url .= $sWrk;
	}
}

// Convert search value for date
function ConvertSearchValue(&$Fld, $FldVal) {
	$Value = $FldVal;
	if ($Fld->FldDataType == EW_DATATYPE_DATE && $FldVal <> "")
		$Value = ew_UnFormatDateTime($FldVal, $Fld->FldDateTimeFormat);
	return $Value;
}

	//  Load search values for validation
	function LoadSearchValues() {
		global $objForm, $CCEDocuments;

		// Load search values
		// CCEModuleID

		$CCEDocuments->CCEModuleID->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_CCEModuleID"));
		$CCEDocuments->CCEModuleID->AdvancedSearch->SearchOperator = $objForm->GetValue("z_CCEModuleID");

		// DocumentCategory
		$CCEDocuments->DocumentCategory->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_DocumentCategory"));
		$CCEDocuments->DocumentCategory->AdvancedSearch->SearchOperator = $objForm->GetValue("z_DocumentCategory");

		// DocumentName
		$CCEDocuments->DocumentName->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_DocumentName"));
		$CCEDocuments->DocumentName->AdvancedSearch->SearchOperator = $objForm->GetValue("z_DocumentName");
	}

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

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

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

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

			// Archived
			$CCEDocuments->Archived->ViewValue = $CCEDocuments->Archived->CurrentValue;
			$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 = "";

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

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

			// DocumentName
			$CCEDocuments->DocumentName->HrefValue = "";
			$CCEDocuments->DocumentName->TooltipValue = "";
		} elseif ($CCEDocuments->RowType == EW_ROWTYPE_SEARCH) { // Search row

			// CCEModuleID
			$CCEDocuments->CCEModuleID->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT CCEModules.CCEModuleID, CCEModules.ModuleNum, CCEModules.ModuleName, '' AS SelectFilterFld 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);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), ""));
			$CCEDocuments->CCEModuleID->EditValue = $arwrk;

			// DocumentCategory
			$CCEDocuments->DocumentCategory->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `CCEDocCategoryID`, `CategoryName`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `CCEDocCategories`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `CategoryName`";
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$CCEDocuments->DocumentCategory->EditValue = $arwrk;

			// DocumentName
			$CCEDocuments->DocumentName->EditCustomAttributes = "";
			$CCEDocuments->DocumentName->EditValue = ew_HtmlEncode($CCEDocuments->DocumentName->AdvancedSearch->SearchValue);
		}

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

	// Validate search
	function ValidateSearch() {
		global $gsSearchError, $CCEDocuments;

		// Initialize
		$gsSearchError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return TRUE;

		// Return validate result
		$ValidateSearch = ($gsSearchError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateSearch = $ValidateSearch && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			if ($gsSearchError <> "") $gsSearchError .= "<br>";
			$gsSearchError .= $sFormCustomError;
		}
		return $ValidateSearch;
	}

	// Load advanced search
	function LoadAdvancedSearch() {
		global $CCEDocuments;
		$CCEDocuments->CCEModuleID->AdvancedSearch->SearchValue = $CCEDocuments->getAdvancedSearch("x_CCEModuleID");
		$CCEDocuments->DocumentCategory->AdvancedSearch->SearchValue = $CCEDocuments->getAdvancedSearch("x_DocumentCategory");
		$CCEDocuments->DocumentName->AdvancedSearch->SearchValue = $CCEDocuments->getAdvancedSearch("x_DocumentName");
	}

	// 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;
	}
}
?>