Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/CCEExamAnswerssrch.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 "CCEExamAnswersinfo.php" ?>
<?php include "CCEUsersinfo.php" ?>
<?php include "CCEExamQuestionsinfo.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
$CCEExamAnswers_search = new cCCEExamAnswers_search();
$Page =& $CCEExamAnswers_search;

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

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

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

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

// extend page with validate function for search
CCEExamAnswers_search.ValidateSearch = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (this.ValidateRequired) {
		var infix = "";
		elm = fobj.elements["x" + infix + "_Answer_ID"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEExamAnswers->Answer_ID->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_Answer_Score"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEExamAnswers->Answer_Score->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_Display_Order"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEExamAnswers->Display_Order->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_Answer_Text_Len"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEExamAnswers->Answer_Text_Len->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_ParentAnswerID"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEExamAnswers->ParentAnswerID->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
CCEExamAnswers_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) { ?>
CCEExamAnswers_search.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCEExamAnswers_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 $CCEExamAnswers->TableCaption() ?><br><br>
<a href="<?php echo $CCEExamAnswers->getReturnUrl() ?>"><?php echo $Language->Phrase("BackToList") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$CCEExamAnswers_search->ShowMessage();
?>
<form name="fCCEExamAnswerssearch" id="fCCEExamAnswerssearch" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return CCEExamAnswers_search.ValidateSearch(this);">
<p>
<input type="hidden" name="t" id="t" value="CCEExamAnswers">
<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 $CCEExamAnswers->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamAnswers->Answer_ID->FldCaption() ?></td>
		<td<?php echo $CCEExamAnswers->Answer_ID->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_Answer_ID" id="z_Answer_ID" value="="></span></td>
		<td<?php echo $CCEExamAnswers->Answer_ID->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_Answer_ID" id="x_Answer_ID" title="<?php echo $CCEExamAnswers->Answer_ID->FldTitle() ?>" value="<?php echo $CCEExamAnswers->Answer_ID->EditValue ?>"<?php echo $CCEExamAnswers->Answer_ID->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCEExamAnswers->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamAnswers->Question_ID->FldCaption() ?></td>
		<td<?php echo $CCEExamAnswers->Question_ID->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_Question_ID" id="z_Question_ID" value="="></span></td>
		<td<?php echo $CCEExamAnswers->Question_ID->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<select id="x_Question_ID" name="x_Question_ID" title="<?php echo $CCEExamAnswers->Question_ID->FldTitle() ?>"<?php echo $CCEExamAnswers->Question_ID->EditAttributes() ?>>
<?php
if (is_array($CCEExamAnswers->Question_ID->EditValue)) {
	$arwrk = $CCEExamAnswers->Question_ID->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEExamAnswers->Question_ID->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 $CCEExamAnswers->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamAnswers->Answer->FldCaption() ?></td>
		<td<?php echo $CCEExamAnswers->Answer->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_Answer" id="z_Answer" value="LIKE"></span></td>
		<td<?php echo $CCEExamAnswers->Answer->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<textarea name="x_Answer" id="x_Answer" title="<?php echo $CCEExamAnswers->Answer->FldTitle() ?>" cols="35" rows="4"<?php echo $CCEExamAnswers->Answer->EditAttributes() ?>><?php echo $CCEExamAnswers->Answer->EditValue ?></textarea>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCEExamAnswers->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamAnswers->Answer_Score->FldCaption() ?></td>
		<td<?php echo $CCEExamAnswers->Answer_Score->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_Answer_Score" id="z_Answer_Score" value="="></span></td>
		<td<?php echo $CCEExamAnswers->Answer_Score->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_Answer_Score" id="x_Answer_Score" title="<?php echo $CCEExamAnswers->Answer_Score->FldTitle() ?>" size="30" value="<?php echo $CCEExamAnswers->Answer_Score->EditValue ?>"<?php echo $CCEExamAnswers->Answer_Score->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCEExamAnswers->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamAnswers->Display_Order->FldCaption() ?></td>
		<td<?php echo $CCEExamAnswers->Display_Order->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_Display_Order" id="z_Display_Order" value="="></span></td>
		<td<?php echo $CCEExamAnswers->Display_Order->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_Display_Order" id="x_Display_Order" title="<?php echo $CCEExamAnswers->Display_Order->FldTitle() ?>" size="30" value="<?php echo $CCEExamAnswers->Display_Order->EditValue ?>"<?php echo $CCEExamAnswers->Display_Order->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCEExamAnswers->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamAnswers->Answer_Text_Len->FldCaption() ?></td>
		<td<?php echo $CCEExamAnswers->Answer_Text_Len->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_Answer_Text_Len" id="z_Answer_Text_Len" value="="></span></td>
		<td<?php echo $CCEExamAnswers->Answer_Text_Len->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_Answer_Text_Len" id="x_Answer_Text_Len" title="<?php echo $CCEExamAnswers->Answer_Text_Len->FldTitle() ?>" size="30" value="<?php echo $CCEExamAnswers->Answer_Text_Len->EditValue ?>"<?php echo $CCEExamAnswers->Answer_Text_Len->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCEExamAnswers->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamAnswers->TextAfter->FldCaption() ?></td>
		<td<?php echo $CCEExamAnswers->TextAfter->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_TextAfter" id="z_TextAfter" value="LIKE"></span></td>
		<td<?php echo $CCEExamAnswers->TextAfter->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_TextAfter" id="x_TextAfter" title="<?php echo $CCEExamAnswers->TextAfter->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEExamAnswers->TextAfter->EditValue ?>"<?php echo $CCEExamAnswers->TextAfter->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCEExamAnswers->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamAnswers->BarColour->FldCaption() ?></td>
		<td<?php echo $CCEExamAnswers->BarColour->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_BarColour" id="z_BarColour" value="LIKE"></span></td>
		<td<?php echo $CCEExamAnswers->BarColour->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_BarColour" id="x_BarColour" title="<?php echo $CCEExamAnswers->BarColour->FldTitle() ?>" size="30" maxlength="7" value="<?php echo $CCEExamAnswers->BarColour->EditValue ?>"<?php echo $CCEExamAnswers->BarColour->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr<?php echo $CCEExamAnswers->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamAnswers->ParentAnswerID->FldCaption() ?></td>
		<td<?php echo $CCEExamAnswers->ParentAnswerID->CellAttributes() ?>><span class="ewSearchOpr"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_ParentAnswerID" id="z_ParentAnswerID" value="="></span></td>
		<td<?php echo $CCEExamAnswers->ParentAnswerID->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker" style="float: left;">
<input type="text" name="x_ParentAnswerID" id="x_ParentAnswerID" title="<?php echo $CCEExamAnswers->ParentAnswerID->FldTitle() ?>" size="30" value="<?php echo $CCEExamAnswers->ParentAnswerID->EditValue ?>"<?php echo $CCEExamAnswers->ParentAnswerID->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
$CCEExamAnswers_search->Page_Terminate();
?>
<?php

//
// Page class
//
class cCCEExamAnswers_search {

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

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

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

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

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

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

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

		// Table object (CCEExamAnswers)
		$GLOBALS["CCEExamAnswers"] = new cCCEExamAnswers();

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

		// Table object (CCEExamQuestions)
		$GLOBALS['CCEExamQuestions'] = new cCCEExamQuestions();

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

		// 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("CCEExamAnswerslist.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, $CCEExamAnswers;
		if ($this->IsPageRequest()) { // Validate request

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

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

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

// Build advanced search
function BuildAdvancedSearch() {
	global $CCEExamAnswers;
	$sSrchUrl = "";
	$this->BuildSearchUrl($sSrchUrl, $CCEExamAnswers->Answer_ID); // Answer_ID
	$this->BuildSearchUrl($sSrchUrl, $CCEExamAnswers->Question_ID); // Question_ID
	$this->BuildSearchUrl($sSrchUrl, $CCEExamAnswers->Answer); // Answer
	$this->BuildSearchUrl($sSrchUrl, $CCEExamAnswers->Answer_Score); // Answer_Score
	$this->BuildSearchUrl($sSrchUrl, $CCEExamAnswers->Display_Order); // Display_Order
	$this->BuildSearchUrl($sSrchUrl, $CCEExamAnswers->Answer_Text_Len); // Answer_Text_Len
	$this->BuildSearchUrl($sSrchUrl, $CCEExamAnswers->TextAfter); // TextAfter
	$this->BuildSearchUrl($sSrchUrl, $CCEExamAnswers->BarColour); // BarColour
	$this->BuildSearchUrl($sSrchUrl, $CCEExamAnswers->ParentAnswerID); // ParentAnswerID
	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, $CCEExamAnswers;

		// Load search values
		// Answer_ID

		$CCEExamAnswers->Answer_ID->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_Answer_ID"));
		$CCEExamAnswers->Answer_ID->AdvancedSearch->SearchOperator = $objForm->GetValue("z_Answer_ID");

		// Question_ID
		$CCEExamAnswers->Question_ID->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_Question_ID"));
		$CCEExamAnswers->Question_ID->AdvancedSearch->SearchOperator = $objForm->GetValue("z_Question_ID");

		// Answer
		$CCEExamAnswers->Answer->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_Answer"));
		$CCEExamAnswers->Answer->AdvancedSearch->SearchOperator = $objForm->GetValue("z_Answer");

		// Answer_Score
		$CCEExamAnswers->Answer_Score->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_Answer_Score"));
		$CCEExamAnswers->Answer_Score->AdvancedSearch->SearchOperator = $objForm->GetValue("z_Answer_Score");

		// Display_Order
		$CCEExamAnswers->Display_Order->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_Display_Order"));
		$CCEExamAnswers->Display_Order->AdvancedSearch->SearchOperator = $objForm->GetValue("z_Display_Order");

		// Answer_Text_Len
		$CCEExamAnswers->Answer_Text_Len->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_Answer_Text_Len"));
		$CCEExamAnswers->Answer_Text_Len->AdvancedSearch->SearchOperator = $objForm->GetValue("z_Answer_Text_Len");

		// TextAfter
		$CCEExamAnswers->TextAfter->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_TextAfter"));
		$CCEExamAnswers->TextAfter->AdvancedSearch->SearchOperator = $objForm->GetValue("z_TextAfter");

		// BarColour
		$CCEExamAnswers->BarColour->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_BarColour"));
		$CCEExamAnswers->BarColour->AdvancedSearch->SearchOperator = $objForm->GetValue("z_BarColour");

		// ParentAnswerID
		$CCEExamAnswers->ParentAnswerID->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_ParentAnswerID"));
		$CCEExamAnswers->ParentAnswerID->AdvancedSearch->SearchOperator = $objForm->GetValue("z_ParentAnswerID");
	}

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

		// Initialize URLs
		// Call Row_Rendering event

		$CCEExamAnswers->Row_Rendering();

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

		$CCEExamAnswers->Answer_ID->CellCssStyle = ""; $CCEExamAnswers->Answer_ID->CellCssClass = "";
		$CCEExamAnswers->Answer_ID->CellAttrs = array(); $CCEExamAnswers->Answer_ID->ViewAttrs = array(); $CCEExamAnswers->Answer_ID->EditAttrs = array();

		// Question_ID
		$CCEExamAnswers->Question_ID->CellCssStyle = ""; $CCEExamAnswers->Question_ID->CellCssClass = "";
		$CCEExamAnswers->Question_ID->CellAttrs = array(); $CCEExamAnswers->Question_ID->ViewAttrs = array(); $CCEExamAnswers->Question_ID->EditAttrs = array();

		// Answer
		$CCEExamAnswers->Answer->CellCssStyle = ""; $CCEExamAnswers->Answer->CellCssClass = "";
		$CCEExamAnswers->Answer->CellAttrs = array(); $CCEExamAnswers->Answer->ViewAttrs = array(); $CCEExamAnswers->Answer->EditAttrs = array();

		// Answer_Score
		$CCEExamAnswers->Answer_Score->CellCssStyle = ""; $CCEExamAnswers->Answer_Score->CellCssClass = "";
		$CCEExamAnswers->Answer_Score->CellAttrs = array(); $CCEExamAnswers->Answer_Score->ViewAttrs = array(); $CCEExamAnswers->Answer_Score->EditAttrs = array();

		// Display_Order
		$CCEExamAnswers->Display_Order->CellCssStyle = ""; $CCEExamAnswers->Display_Order->CellCssClass = "";
		$CCEExamAnswers->Display_Order->CellAttrs = array(); $CCEExamAnswers->Display_Order->ViewAttrs = array(); $CCEExamAnswers->Display_Order->EditAttrs = array();

		// Answer_Text_Len
		$CCEExamAnswers->Answer_Text_Len->CellCssStyle = ""; $CCEExamAnswers->Answer_Text_Len->CellCssClass = "";
		$CCEExamAnswers->Answer_Text_Len->CellAttrs = array(); $CCEExamAnswers->Answer_Text_Len->ViewAttrs = array(); $CCEExamAnswers->Answer_Text_Len->EditAttrs = array();

		// TextAfter
		$CCEExamAnswers->TextAfter->CellCssStyle = ""; $CCEExamAnswers->TextAfter->CellCssClass = "";
		$CCEExamAnswers->TextAfter->CellAttrs = array(); $CCEExamAnswers->TextAfter->ViewAttrs = array(); $CCEExamAnswers->TextAfter->EditAttrs = array();

		// BarColour
		$CCEExamAnswers->BarColour->CellCssStyle = ""; $CCEExamAnswers->BarColour->CellCssClass = "";
		$CCEExamAnswers->BarColour->CellAttrs = array(); $CCEExamAnswers->BarColour->ViewAttrs = array(); $CCEExamAnswers->BarColour->EditAttrs = array();

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

			// Answer_ID
			$CCEExamAnswers->Answer_ID->ViewValue = $CCEExamAnswers->Answer_ID->CurrentValue;
			$CCEExamAnswers->Answer_ID->CssStyle = "";
			$CCEExamAnswers->Answer_ID->CssClass = "";
			$CCEExamAnswers->Answer_ID->ViewCustomAttributes = "";

			// Question_ID
			if (strval($CCEExamAnswers->Question_ID->CurrentValue) <> "") {
				$sFilterWrk = "`Question_ID` = " . ew_AdjustSql($CCEExamAnswers->Question_ID->CurrentValue) . "";
			$sSqlWrk = "SELECT `QuestionTitle`, `Question` FROM `CCEExamQuestions`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Display_Order` Asc";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEExamAnswers->Question_ID->ViewValue = $rswrk->fields('QuestionTitle');
					$CCEExamAnswers->Question_ID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('Question');
					$rswrk->Close();
				} else {
					$CCEExamAnswers->Question_ID->ViewValue = $CCEExamAnswers->Question_ID->CurrentValue;
				}
			} else {
				$CCEExamAnswers->Question_ID->ViewValue = NULL;
			}
			$CCEExamAnswers->Question_ID->CssStyle = "";
			$CCEExamAnswers->Question_ID->CssClass = "";
			$CCEExamAnswers->Question_ID->ViewCustomAttributes = "";

			// Answer
			$CCEExamAnswers->Answer->ViewValue = $CCEExamAnswers->Answer->CurrentValue;
			$CCEExamAnswers->Answer->CssStyle = "";
			$CCEExamAnswers->Answer->CssClass = "";
			$CCEExamAnswers->Answer->ViewCustomAttributes = "";

			// Answer_Score
			$CCEExamAnswers->Answer_Score->ViewValue = $CCEExamAnswers->Answer_Score->CurrentValue;
			$CCEExamAnswers->Answer_Score->CssStyle = "";
			$CCEExamAnswers->Answer_Score->CssClass = "";
			$CCEExamAnswers->Answer_Score->ViewCustomAttributes = "";

			// Display_Order
			$CCEExamAnswers->Display_Order->ViewValue = $CCEExamAnswers->Display_Order->CurrentValue;
			$CCEExamAnswers->Display_Order->CssStyle = "";
			$CCEExamAnswers->Display_Order->CssClass = "";
			$CCEExamAnswers->Display_Order->ViewCustomAttributes = "";

			// Answer_Text_Len
			$CCEExamAnswers->Answer_Text_Len->ViewValue = $CCEExamAnswers->Answer_Text_Len->CurrentValue;
			$CCEExamAnswers->Answer_Text_Len->CssStyle = "";
			$CCEExamAnswers->Answer_Text_Len->CssClass = "";
			$CCEExamAnswers->Answer_Text_Len->ViewCustomAttributes = "";

			// TextAfter
			$CCEExamAnswers->TextAfter->ViewValue = $CCEExamAnswers->TextAfter->CurrentValue;
			$CCEExamAnswers->TextAfter->CssStyle = "";
			$CCEExamAnswers->TextAfter->CssClass = "";
			$CCEExamAnswers->TextAfter->ViewCustomAttributes = "";

			// BarColour
			$CCEExamAnswers->BarColour->ViewValue = $CCEExamAnswers->BarColour->CurrentValue;
			$CCEExamAnswers->BarColour->CssStyle = "";
			$CCEExamAnswers->BarColour->CssClass = "";
			$CCEExamAnswers->BarColour->ViewCustomAttributes = "";

			// ParentAnswerID
			$CCEExamAnswers->ParentAnswerID->ViewValue = $CCEExamAnswers->ParentAnswerID->CurrentValue;
			$CCEExamAnswers->ParentAnswerID->CssStyle = "";
			$CCEExamAnswers->ParentAnswerID->CssClass = "";
			$CCEExamAnswers->ParentAnswerID->ViewCustomAttributes = "";

			// Answer_ID
			$CCEExamAnswers->Answer_ID->HrefValue = "";
			$CCEExamAnswers->Answer_ID->TooltipValue = "";

			// Question_ID
			$CCEExamAnswers->Question_ID->HrefValue = "";
			$CCEExamAnswers->Question_ID->TooltipValue = "";

			// Answer
			$CCEExamAnswers->Answer->HrefValue = "";
			$CCEExamAnswers->Answer->TooltipValue = "";

			// Answer_Score
			$CCEExamAnswers->Answer_Score->HrefValue = "";
			$CCEExamAnswers->Answer_Score->TooltipValue = "";

			// Display_Order
			$CCEExamAnswers->Display_Order->HrefValue = "";
			$CCEExamAnswers->Display_Order->TooltipValue = "";

			// Answer_Text_Len
			$CCEExamAnswers->Answer_Text_Len->HrefValue = "";
			$CCEExamAnswers->Answer_Text_Len->TooltipValue = "";

			// TextAfter
			$CCEExamAnswers->TextAfter->HrefValue = "";
			$CCEExamAnswers->TextAfter->TooltipValue = "";

			// BarColour
			$CCEExamAnswers->BarColour->HrefValue = "";
			$CCEExamAnswers->BarColour->TooltipValue = "";

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

			// Answer_ID
			$CCEExamAnswers->Answer_ID->EditCustomAttributes = "";
			$CCEExamAnswers->Answer_ID->EditValue = ew_HtmlEncode($CCEExamAnswers->Answer_ID->AdvancedSearch->SearchValue);

			// Question_ID
			$CCEExamAnswers->Question_ID->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `Question_ID`, `QuestionTitle`, `Question`, '' AS SelectFilterFld FROM `CCEExamQuestions`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Display_Order` Asc";
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), ""));
			$CCEExamAnswers->Question_ID->EditValue = $arwrk;

			// Answer
			$CCEExamAnswers->Answer->EditCustomAttributes = "";
			$CCEExamAnswers->Answer->EditValue = ew_HtmlEncode($CCEExamAnswers->Answer->AdvancedSearch->SearchValue);

			// Answer_Score
			$CCEExamAnswers->Answer_Score->EditCustomAttributes = "";
			$CCEExamAnswers->Answer_Score->EditValue = ew_HtmlEncode($CCEExamAnswers->Answer_Score->AdvancedSearch->SearchValue);

			// Display_Order
			$CCEExamAnswers->Display_Order->EditCustomAttributes = "";
			$CCEExamAnswers->Display_Order->EditValue = ew_HtmlEncode($CCEExamAnswers->Display_Order->AdvancedSearch->SearchValue);

			// Answer_Text_Len
			$CCEExamAnswers->Answer_Text_Len->EditCustomAttributes = "";
			$CCEExamAnswers->Answer_Text_Len->EditValue = ew_HtmlEncode($CCEExamAnswers->Answer_Text_Len->AdvancedSearch->SearchValue);

			// TextAfter
			$CCEExamAnswers->TextAfter->EditCustomAttributes = "";
			$CCEExamAnswers->TextAfter->EditValue = ew_HtmlEncode($CCEExamAnswers->TextAfter->AdvancedSearch->SearchValue);

			// BarColour
			$CCEExamAnswers->BarColour->EditCustomAttributes = "";
			$CCEExamAnswers->BarColour->EditValue = ew_HtmlEncode($CCEExamAnswers->BarColour->AdvancedSearch->SearchValue);

			// ParentAnswerID
			$CCEExamAnswers->ParentAnswerID->EditCustomAttributes = "";
			$CCEExamAnswers->ParentAnswerID->EditValue = ew_HtmlEncode($CCEExamAnswers->ParentAnswerID->AdvancedSearch->SearchValue);
		}

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

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

		// Initialize
		$gsSearchError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return TRUE;
		if (!ew_CheckInteger($CCEExamAnswers->Answer_ID->AdvancedSearch->SearchValue)) {
			if ($gsSearchError <> "") $gsSearchError .= "<br>";
			$gsSearchError .= $CCEExamAnswers->Answer_ID->FldErrMsg();
		}
		if (!ew_CheckNumber($CCEExamAnswers->Answer_Score->AdvancedSearch->SearchValue)) {
			if ($gsSearchError <> "") $gsSearchError .= "<br>";
			$gsSearchError .= $CCEExamAnswers->Answer_Score->FldErrMsg();
		}
		if (!ew_CheckInteger($CCEExamAnswers->Display_Order->AdvancedSearch->SearchValue)) {
			if ($gsSearchError <> "") $gsSearchError .= "<br>";
			$gsSearchError .= $CCEExamAnswers->Display_Order->FldErrMsg();
		}
		if (!ew_CheckInteger($CCEExamAnswers->Answer_Text_Len->AdvancedSearch->SearchValue)) {
			if ($gsSearchError <> "") $gsSearchError .= "<br>";
			$gsSearchError .= $CCEExamAnswers->Answer_Text_Len->FldErrMsg();
		}
		if (!ew_CheckInteger($CCEExamAnswers->ParentAnswerID->AdvancedSearch->SearchValue)) {
			if ($gsSearchError <> "") $gsSearchError .= "<br>";
			$gsSearchError .= $CCEExamAnswers->ParentAnswerID->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 $CCEExamAnswers;
		$CCEExamAnswers->Answer_ID->AdvancedSearch->SearchValue = $CCEExamAnswers->getAdvancedSearch("x_Answer_ID");
		$CCEExamAnswers->Question_ID->AdvancedSearch->SearchValue = $CCEExamAnswers->getAdvancedSearch("x_Question_ID");
		$CCEExamAnswers->Answer->AdvancedSearch->SearchValue = $CCEExamAnswers->getAdvancedSearch("x_Answer");
		$CCEExamAnswers->Answer_Score->AdvancedSearch->SearchValue = $CCEExamAnswers->getAdvancedSearch("x_Answer_Score");
		$CCEExamAnswers->Display_Order->AdvancedSearch->SearchValue = $CCEExamAnswers->getAdvancedSearch("x_Display_Order");
		$CCEExamAnswers->Answer_Text_Len->AdvancedSearch->SearchValue = $CCEExamAnswers->getAdvancedSearch("x_Answer_Text_Len");
		$CCEExamAnswers->TextAfter->AdvancedSearch->SearchValue = $CCEExamAnswers->getAdvancedSearch("x_TextAfter");
		$CCEExamAnswers->BarColour->AdvancedSearch->SearchValue = $CCEExamAnswers->getAdvancedSearch("x_BarColour");
		$CCEExamAnswers->ParentAnswerID->AdvancedSearch->SearchValue = $CCEExamAnswers->getAdvancedSearch("x_ParentAnswerID");
	}

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