Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/CCETemplatessrch.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 "CCETemplatesinfo.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
$CCETemplates_search = new cCCETemplates_search();
$Page =& $CCETemplates_search;

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

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

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

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

// extend page with validate function for search
CCETemplates_search.ValidateSearch = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (this.ValidateRequired) {
		var infix = "";
		elm = fobj.elements["x" + infix + "_UploadedBy"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCETemplates->UploadedBy->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_ArchiveYear"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCETemplates->ArchiveYear->FldErrMsg()) ?>");

		// 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
CCETemplates_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) { ?>
CCETemplates_search.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCETemplates_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 $CCETemplates->TableCaption() ?><br><br>
<a href="<?php echo $CCETemplates->getReturnUrl() ?>"><?php echo $Language->Phrase("BackToList") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$CCETemplates_search->ShowMessage();
?>
<form name="fCCETemplatessearch" id="fCCETemplatessearch" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return CCETemplates_search.ValidateSearch(this);">
<p>
<input type="hidden" name="t" id="t" value="CCETemplates">
<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 $CCETemplates->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCETemplates->CCETemplateID->FldCaption() ?></td>
		<td<?php echo $CCETemplates->CCETemplateID->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_CCETemplateID" id="z_CCETemplateID" value="="></span></td>
		<td<?php echo $CCETemplates->CCETemplateID->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_CCETemplateID" id="x_CCETemplateID" title="<?php echo $CCETemplates->CCETemplateID->FldTitle() ?>" value="<?php echo $CCETemplates->CCETemplateID->EditValue ?>"<?php echo $CCETemplates->CCETemplateID->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCETemplates->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCETemplates->TemplateName->FldCaption() ?></td>
		<td<?php echo $CCETemplates->TemplateName->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_TemplateName" id="z_TemplateName" value="LIKE"></span></td>
		<td<?php echo $CCETemplates->TemplateName->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_TemplateName" id="x_TemplateName" title="<?php echo $CCETemplates->TemplateName->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCETemplates->TemplateName->EditValue ?>"<?php echo $CCETemplates->TemplateName->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCETemplates->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCETemplates->RefNum->FldCaption() ?></td>
		<td<?php echo $CCETemplates->RefNum->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_RefNum" id="z_RefNum" value="LIKE"></span></td>
		<td<?php echo $CCETemplates->RefNum->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_RefNum" id="x_RefNum" title="<?php echo $CCETemplates->RefNum->FldTitle() ?>" size="30" maxlength="20" value="<?php echo $CCETemplates->RefNum->EditValue ?>"<?php echo $CCETemplates->RefNum->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCETemplates->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCETemplates->UploadedBy->FldCaption() ?></td>
		<td<?php echo $CCETemplates->UploadedBy->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_UploadedBy" id="z_UploadedBy" value="="></span></td>
		<td<?php echo $CCETemplates->UploadedBy->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_UploadedBy" id="x_UploadedBy" title="<?php echo $CCETemplates->UploadedBy->FldTitle() ?>" size="30" value="<?php echo $CCETemplates->UploadedBy->EditValue ?>"<?php echo $CCETemplates->UploadedBy->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCETemplates->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCETemplates->TemplateThumb->FldCaption() ?></td>
		<td<?php echo $CCETemplates->TemplateThumb->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_TemplateThumb" id="z_TemplateThumb" value="LIKE"></span></td>
		<td<?php echo $CCETemplates->TemplateThumb->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_TemplateThumb" id="x_TemplateThumb" title="<?php echo $CCETemplates->TemplateThumb->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCETemplates->TemplateThumb->EditValue ?>"<?php echo $CCETemplates->TemplateThumb->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCETemplates->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCETemplates->Archived->FldCaption() ?></td>
		<td<?php echo $CCETemplates->Archived->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_Archived" id="z_Archived" value="="></span></td>
		<td<?php echo $CCETemplates->Archived->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<div id="tp_x_Archived" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x_Archived" id="x_Archived" title="<?php echo $CCETemplates->Archived->FldTitle() ?>" value="{value}"<?php echo $CCETemplates->Archived->EditAttributes() ?>></label></div>
<div id="dsl_x_Archived" repeatcolumn="5">
<?php
$arwrk = $CCETemplates->Archived->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCETemplates->Archived->AdvancedSearch->SearchValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x_Archived" id="x_Archived" title="<?php echo $CCETemplates->Archived->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $CCETemplates->Archived->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCETemplates->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCETemplates->ArchiveYear->FldCaption() ?></td>
		<td<?php echo $CCETemplates->ArchiveYear->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_ArchiveYear" id="z_ArchiveYear" value="="></span></td>
		<td<?php echo $CCETemplates->ArchiveYear->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_ArchiveYear" id="x_ArchiveYear" title="<?php echo $CCETemplates->ArchiveYear->FldTitle() ?>" size="30" value="<?php echo $CCETemplates->ArchiveYear->EditValue ?>"<?php echo $CCETemplates->ArchiveYear->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
$CCETemplates_search->Page_Terminate();
?>
<?php

//
// Page class
//
class cCCETemplates_search {

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

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

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

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

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

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

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

		// Table object (CCETemplates)
		$GLOBALS["CCETemplates"] = new cCCETemplates();

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

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

		// 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->CanSearch()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("CCETemplateslist.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, $CCETemplates;
		if ($this->IsPageRequest()) { // Validate request

			// Get action
			$CCETemplates->CurrentAction = $objForm->GetValue("a_search");
			switch ($CCETemplates->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 = $CCETemplates->UrlParm($sSrchStr);
						$this->Page_Terminate("CCETemplateslist.php" . "?" . $sSrchStr); // Go to list page
					}
			}
		}

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

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

// Build advanced search
function BuildAdvancedSearch() {
	global $CCETemplates;
	$sSrchUrl = "";
	$this->BuildSearchUrl($sSrchUrl, $CCETemplates->CCETemplateID); // CCETemplateID
	$this->BuildSearchUrl($sSrchUrl, $CCETemplates->TemplateName); // TemplateName
	$this->BuildSearchUrl($sSrchUrl, $CCETemplates->RefNum); // RefNum
	$this->BuildSearchUrl($sSrchUrl, $CCETemplates->UploadedBy); // UploadedBy
	$this->BuildSearchUrl($sSrchUrl, $CCETemplates->TemplateThumb); // TemplateThumb
	$this->BuildSearchUrl($sSrchUrl, $CCETemplates->Archived); // Archived
	$this->BuildSearchUrl($sSrchUrl, $CCETemplates->ArchiveYear); // ArchiveYear
	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, $CCETemplates;

		// Load search values
		// CCETemplateID

		$CCETemplates->CCETemplateID->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_CCETemplateID"));
		$CCETemplates->CCETemplateID->AdvancedSearch->SearchOperator = $objForm->GetValue("z_CCETemplateID");

		// TemplateName
		$CCETemplates->TemplateName->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_TemplateName"));
		$CCETemplates->TemplateName->AdvancedSearch->SearchOperator = $objForm->GetValue("z_TemplateName");

		// RefNum
		$CCETemplates->RefNum->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_RefNum"));
		$CCETemplates->RefNum->AdvancedSearch->SearchOperator = $objForm->GetValue("z_RefNum");

		// UploadedBy
		$CCETemplates->UploadedBy->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_UploadedBy"));
		$CCETemplates->UploadedBy->AdvancedSearch->SearchOperator = $objForm->GetValue("z_UploadedBy");

		// TemplateThumb
		$CCETemplates->TemplateThumb->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_TemplateThumb"));
		$CCETemplates->TemplateThumb->AdvancedSearch->SearchOperator = $objForm->GetValue("z_TemplateThumb");

		// Archived
		$CCETemplates->Archived->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_Archived"));
		$CCETemplates->Archived->AdvancedSearch->SearchOperator = $objForm->GetValue("z_Archived");

		// ArchiveYear
		$CCETemplates->ArchiveYear->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_ArchiveYear"));
		$CCETemplates->ArchiveYear->AdvancedSearch->SearchOperator = $objForm->GetValue("z_ArchiveYear");
	}

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

		// Initialize URLs
		// Call Row_Rendering event

		$CCETemplates->Row_Rendering();

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

		$CCETemplates->CCETemplateID->CellCssStyle = ""; $CCETemplates->CCETemplateID->CellCssClass = "";
		$CCETemplates->CCETemplateID->CellAttrs = array(); $CCETemplates->CCETemplateID->ViewAttrs = array(); $CCETemplates->CCETemplateID->EditAttrs = array();

		// TemplateName
		$CCETemplates->TemplateName->CellCssStyle = ""; $CCETemplates->TemplateName->CellCssClass = "";
		$CCETemplates->TemplateName->CellAttrs = array(); $CCETemplates->TemplateName->ViewAttrs = array(); $CCETemplates->TemplateName->EditAttrs = array();

		// RefNum
		$CCETemplates->RefNum->CellCssStyle = ""; $CCETemplates->RefNum->CellCssClass = "";
		$CCETemplates->RefNum->CellAttrs = array(); $CCETemplates->RefNum->ViewAttrs = array(); $CCETemplates->RefNum->EditAttrs = array();

		// TemplateFile
		$CCETemplates->TemplateFile->CellCssStyle = ""; $CCETemplates->TemplateFile->CellCssClass = "";
		$CCETemplates->TemplateFile->CellAttrs = array(); $CCETemplates->TemplateFile->ViewAttrs = array(); $CCETemplates->TemplateFile->EditAttrs = array();

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

		// TemplateThumb
		$CCETemplates->TemplateThumb->CellCssStyle = ""; $CCETemplates->TemplateThumb->CellCssClass = "";
		$CCETemplates->TemplateThumb->CellAttrs = array(); $CCETemplates->TemplateThumb->ViewAttrs = array(); $CCETemplates->TemplateThumb->EditAttrs = array();

		// Archived
		$CCETemplates->Archived->CellCssStyle = ""; $CCETemplates->Archived->CellCssClass = "";
		$CCETemplates->Archived->CellAttrs = array(); $CCETemplates->Archived->ViewAttrs = array(); $CCETemplates->Archived->EditAttrs = array();

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

			// CCETemplateID
			$CCETemplates->CCETemplateID->ViewValue = $CCETemplates->CCETemplateID->CurrentValue;
			$CCETemplates->CCETemplateID->CssStyle = "";
			$CCETemplates->CCETemplateID->CssClass = "";
			$CCETemplates->CCETemplateID->ViewCustomAttributes = "";

			// TemplateName
			$CCETemplates->TemplateName->ViewValue = $CCETemplates->TemplateName->CurrentValue;
			$CCETemplates->TemplateName->CssStyle = "";
			$CCETemplates->TemplateName->CssClass = "";
			$CCETemplates->TemplateName->ViewCustomAttributes = "";

			// RefNum
			$CCETemplates->RefNum->ViewValue = $CCETemplates->RefNum->CurrentValue;
			$CCETemplates->RefNum->CssStyle = "";
			$CCETemplates->RefNum->CssClass = "";
			$CCETemplates->RefNum->ViewCustomAttributes = "";

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

			// UploadedBy
			$CCETemplates->UploadedBy->ViewValue = $CCETemplates->UploadedBy->CurrentValue;
			$CCETemplates->UploadedBy->CssStyle = "";
			$CCETemplates->UploadedBy->CssClass = "";
			$CCETemplates->UploadedBy->ViewCustomAttributes = "";

			// TemplateThumb
			$CCETemplates->TemplateThumb->ViewValue = $CCETemplates->TemplateThumb->CurrentValue;
			$CCETemplates->TemplateThumb->CssStyle = "";
			$CCETemplates->TemplateThumb->CssClass = "";
			$CCETemplates->TemplateThumb->ViewCustomAttributes = "";

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

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

			// CCETemplateID
			$CCETemplates->CCETemplateID->HrefValue = "";
			$CCETemplates->CCETemplateID->TooltipValue = "";

			// TemplateName
			$CCETemplates->TemplateName->HrefValue = "";
			$CCETemplates->TemplateName->TooltipValue = "";

			// RefNum
			$CCETemplates->RefNum->HrefValue = "";
			$CCETemplates->RefNum->TooltipValue = "";

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

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

			// TemplateThumb
			$CCETemplates->TemplateThumb->HrefValue = "";
			$CCETemplates->TemplateThumb->TooltipValue = "";

			// Archived
			$CCETemplates->Archived->HrefValue = "";
			$CCETemplates->Archived->TooltipValue = "";

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

			// CCETemplateID
			$CCETemplates->CCETemplateID->EditCustomAttributes = "";
			$CCETemplates->CCETemplateID->EditValue = ew_HtmlEncode($CCETemplates->CCETemplateID->AdvancedSearch->SearchValue);

			// TemplateName
			$CCETemplates->TemplateName->EditCustomAttributes = "";
			$CCETemplates->TemplateName->EditValue = ew_HtmlEncode($CCETemplates->TemplateName->AdvancedSearch->SearchValue);

			// RefNum
			$CCETemplates->RefNum->EditCustomAttributes = "";
			$CCETemplates->RefNum->EditValue = ew_HtmlEncode($CCETemplates->RefNum->AdvancedSearch->SearchValue);

			// TemplateFile
			$CCETemplates->TemplateFile->EditCustomAttributes = "";
			if (!ew_Empty($CCETemplates->TemplateFile->Upload->DbValue)) {
				$CCETemplates->TemplateFile->EditValue = $CCETemplates->TemplateFile->Upload->DbValue;
			} else {
				$CCETemplates->TemplateFile->EditValue = "";
			}

			// UploadedBy
			$CCETemplates->UploadedBy->EditCustomAttributes = "";
			$CCETemplates->UploadedBy->EditValue = ew_HtmlEncode($CCETemplates->UploadedBy->AdvancedSearch->SearchValue);

			// TemplateThumb
			$CCETemplates->TemplateThumb->EditCustomAttributes = "";
			$CCETemplates->TemplateThumb->EditValue = ew_HtmlEncode($CCETemplates->TemplateThumb->AdvancedSearch->SearchValue);

			// Archived
			$CCETemplates->Archived->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("1", "Yes");
			$arwrk[] = array("0", "No");
			$CCETemplates->Archived->EditValue = $arwrk;

			// ArchiveYear
			$CCETemplates->ArchiveYear->EditCustomAttributes = "";
			$CCETemplates->ArchiveYear->EditValue = ew_HtmlEncode($CCETemplates->ArchiveYear->AdvancedSearch->SearchValue);
		}

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

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

		// Initialize
		$gsSearchError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return TRUE;
		if (!ew_CheckInteger($CCETemplates->UploadedBy->AdvancedSearch->SearchValue)) {
			if ($gsSearchError <> "") $gsSearchError .= "<br>";
			$gsSearchError .= $CCETemplates->UploadedBy->FldErrMsg();
		}
		if (!ew_CheckInteger($CCETemplates->ArchiveYear->AdvancedSearch->SearchValue)) {
			if ($gsSearchError <> "") $gsSearchError .= "<br>";
			$gsSearchError .= $CCETemplates->ArchiveYear->FldErrMsg();
		}

		// 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 $CCETemplates;
		$CCETemplates->CCETemplateID->AdvancedSearch->SearchValue = $CCETemplates->getAdvancedSearch("x_CCETemplateID");
		$CCETemplates->TemplateName->AdvancedSearch->SearchValue = $CCETemplates->getAdvancedSearch("x_TemplateName");
		$CCETemplates->RefNum->AdvancedSearch->SearchValue = $CCETemplates->getAdvancedSearch("x_RefNum");
		$CCETemplates->UploadedBy->AdvancedSearch->SearchValue = $CCETemplates->getAdvancedSearch("x_UploadedBy");
		$CCETemplates->TemplateThumb->AdvancedSearch->SearchValue = $CCETemplates->getAdvancedSearch("x_TemplateThumb");
		$CCETemplates->Archived->AdvancedSearch->SearchValue = $CCETemplates->getAdvancedSearch("x_Archived");
		$CCETemplates->ArchiveYear->AdvancedSearch->SearchValue = $CCETemplates->getAdvancedSearch("x_ArchiveYear");
	}

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