Your IP : 216.73.217.79


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

// Create page object
$CCEMessages_edit = new cCCEMessages_edit();
$Page =& $CCEMessages_edit;

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

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

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

// page properties
CCEMessages_edit.PageID = "edit"; // page ID
CCEMessages_edit.FormID = "fCCEMessagesedit"; // form ID
var EW_PAGE_ID = CCEMessages_edit.PageID; // for backward compatibility

// extend page with ValidateForm function
CCEMessages_edit.ValidateForm = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_SentDateTime"];
		if (elm && !ew_CheckDate(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEMessages->SentDateTime->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_SentByName"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEMessages->SentByName->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_SentByStudentID"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEMessages->SentByStudentID->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_SentByFacilitatorID"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEMessages->SentByFacilitatorID->FldErrMsg()) ?>");

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}

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

//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-cold-1.css" title="win2k-1">
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></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("Edit") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCEMessages->TableCaption() ?><br><br>
<a href="<?php echo $CCEMessages->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$CCEMessages_edit->ShowMessage();
?>
<form name="fCCEMessagesedit" id="fCCEMessagesedit" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return CCEMessages_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="CCEMessages">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<input type="hidden" name="x_CCEMessageID" id="x_CCEMessageID" value="<?php echo ew_HtmlEncode($CCEMessages->CCEMessageID->CurrentValue) ?>">
<?php if ($CCEMessages->CCEModuleID->Visible) { // CCEModuleID ?>
	<tr<?php echo $CCEMessages->CCEModuleID->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEMessages->CCEModuleID->FldCaption() ?></td>
		<td<?php echo $CCEMessages->CCEModuleID->CellAttributes() ?>><span id="el_CCEModuleID">
<?php if ($CCEMessages->CCEModuleID->getSessionValue() <> "") { ?>
<div<?php echo $CCEMessages->CCEModuleID->ViewAttributes() ?>><?php echo $CCEMessages->CCEModuleID->ViewValue ?></div>
<input type="hidden" id="x_CCEModuleID" name="x_CCEModuleID" value="<?php echo ew_HtmlEncode($CCEMessages->CCEModuleID->CurrentValue) ?>">
<?php } else { ?>
<select id="x_CCEModuleID" name="x_CCEModuleID" title="<?php echo $CCEMessages->CCEModuleID->FldTitle() ?>"<?php echo $CCEMessages->CCEModuleID->EditAttributes() ?>>
<?php
if (is_array($CCEMessages->CCEModuleID->EditValue)) {
	$arwrk = $CCEMessages->CCEModuleID->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEMessages->CCEModuleID->CurrentValue) == 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>
<?php } ?>
</span><?php echo $CCEMessages->CCEModuleID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEMessages->SentDateTime->Visible) { // SentDateTime ?>
	<tr<?php echo $CCEMessages->SentDateTime->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEMessages->SentDateTime->FldCaption() ?></td>
		<td<?php echo $CCEMessages->SentDateTime->CellAttributes() ?>><span id="el_SentDateTime">
<input type="text" name="x_SentDateTime" id="x_SentDateTime" title="<?php echo $CCEMessages->SentDateTime->FldTitle() ?>" value="<?php echo $CCEMessages->SentDateTime->EditValue ?>"<?php echo $CCEMessages->SentDateTime->EditAttributes() ?>>
&nbsp;<img src="images/calendar.png" id="cal_x_SentDateTime" name="cal_x_SentDateTime" alt="<?php echo $Language->Phrase("PickDate") ?>" title="<?php echo $Language->Phrase("PickDate") ?>" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup({
	inputField: "x_SentDateTime", // input field id
	showsTime: true, // show time
	ifFormat: "%Y/%m/%d %H:%M:%S", // date format
	button: "cal_x_SentDateTime" // button id
});
</script>
</span><?php echo $CCEMessages->SentDateTime->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEMessages->SentByName->Visible) { // SentByName ?>
	<tr<?php echo $CCEMessages->SentByName->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEMessages->SentByName->FldCaption() ?></td>
		<td<?php echo $CCEMessages->SentByName->CellAttributes() ?>><span id="el_SentByName">
<input type="text" name="x_SentByName" id="x_SentByName" title="<?php echo $CCEMessages->SentByName->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEMessages->SentByName->EditValue ?>"<?php echo $CCEMessages->SentByName->EditAttributes() ?>>
</span><?php echo $CCEMessages->SentByName->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEMessages->SentTo->Visible) { // SentTo ?>
	<tr<?php echo $CCEMessages->SentTo->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEMessages->SentTo->FldCaption() ?></td>
		<td<?php echo $CCEMessages->SentTo->CellAttributes() ?>><span id="el_SentTo">
<textarea name="x_SentTo" id="x_SentTo" title="<?php echo $CCEMessages->SentTo->FldTitle() ?>" cols="35" rows="4"<?php echo $CCEMessages->SentTo->EditAttributes() ?>><?php echo $CCEMessages->SentTo->EditValue ?></textarea>
</span><?php echo $CCEMessages->SentTo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEMessages->MessageSubject->Visible) { // MessageSubject ?>
	<tr<?php echo $CCEMessages->MessageSubject->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEMessages->MessageSubject->FldCaption() ?></td>
		<td<?php echo $CCEMessages->MessageSubject->CellAttributes() ?>><span id="el_MessageSubject">
<input type="text" name="x_MessageSubject" id="x_MessageSubject" title="<?php echo $CCEMessages->MessageSubject->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEMessages->MessageSubject->EditValue ?>"<?php echo $CCEMessages->MessageSubject->EditAttributes() ?>>
</span><?php echo $CCEMessages->MessageSubject->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEMessages->MessageText->Visible) { // MessageText ?>
	<tr<?php echo $CCEMessages->MessageText->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEMessages->MessageText->FldCaption() ?></td>
		<td<?php echo $CCEMessages->MessageText->CellAttributes() ?>><span id="el_MessageText">
<textarea name="x_MessageText" id="x_MessageText" title="<?php echo $CCEMessages->MessageText->FldTitle() ?>" cols="35" rows="4"<?php echo $CCEMessages->MessageText->EditAttributes() ?>><?php echo $CCEMessages->MessageText->EditValue ?></textarea>
</span><?php echo $CCEMessages->MessageText->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEMessages->SentByStudentID->Visible) { // SentByStudentID ?>
	<tr<?php echo $CCEMessages->SentByStudentID->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEMessages->SentByStudentID->FldCaption() ?></td>
		<td<?php echo $CCEMessages->SentByStudentID->CellAttributes() ?>><span id="el_SentByStudentID">
<input type="text" name="x_SentByStudentID" id="x_SentByStudentID" title="<?php echo $CCEMessages->SentByStudentID->FldTitle() ?>" size="30" value="<?php echo $CCEMessages->SentByStudentID->EditValue ?>"<?php echo $CCEMessages->SentByStudentID->EditAttributes() ?>>
</span><?php echo $CCEMessages->SentByStudentID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEMessages->SentByFacilitatorID->Visible) { // SentByFacilitatorID ?>
	<tr<?php echo $CCEMessages->SentByFacilitatorID->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEMessages->SentByFacilitatorID->FldCaption() ?></td>
		<td<?php echo $CCEMessages->SentByFacilitatorID->CellAttributes() ?>><span id="el_SentByFacilitatorID">
<input type="text" name="x_SentByFacilitatorID" id="x_SentByFacilitatorID" title="<?php echo $CCEMessages->SentByFacilitatorID->FldTitle() ?>" size="30" value="<?php echo $CCEMessages->SentByFacilitatorID->EditValue ?>"<?php echo $CCEMessages->SentByFacilitatorID->EditAttributes() ?>>
</span><?php echo $CCEMessages->SentByFacilitatorID->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("EditBtn")) ?>">
</form>
<script language="JavaScript" type="text/javascript">
<!--

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

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

//
// Page class
//
class cCCEMessages_edit {

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

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

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

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

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

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

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

		// Table object (CCEMessages)
		$GLOBALS["CCEMessages"] = new cCCEMessages();

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

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

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

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'CCEMessages', 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 $CCEMessages;

		// 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->CanEdit()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("CCEMessageslist.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();
	}
	var $sDbMasterFilter;
	var $sDbDetailFilter;

	// 
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError, $CCEMessages;

		// Load key from QueryString
		if (@$_GET["CCEMessageID"] <> "")
			$CCEMessages->CCEMessageID->setQueryStringValue($_GET["CCEMessageID"]);

		// Set up master detail parameters
		$this->SetUpMasterDetail();
		if (@$_POST["a_edit"] <> "") {
			$CCEMessages->CurrentAction = $_POST["a_edit"]; // Get action code
			$this->LoadFormValues(); // Get form values

			// Validate form
			if (!$this->ValidateForm()) {
				$CCEMessages->CurrentAction = ""; // Form error, reset action
				$this->setMessage($gsFormError);
				$CCEMessages->EventCancelled = TRUE; // Event cancelled
				$this->RestoreFormValues();
			}
		} else {
			$CCEMessages->CurrentAction = "I"; // Default action is display
		}

		// Check if valid key
		if ($CCEMessages->CCEMessageID->CurrentValue == "")
			$this->Page_Terminate("CCEMessageslist.php"); // Invalid key, return to list
		switch ($CCEMessages->CurrentAction) {
			case "I": // Get a record to display
				if (!$this->LoadRow()) { // Load record based on key
					$this->setMessage($Language->Phrase("NoRecord")); // No record found
					$this->Page_Terminate("CCEMessageslist.php"); // No matching record, return to list
				}
				break;
			Case "U": // Update
				$CCEMessages->SendEmail = TRUE; // Send email on update success
				if ($this->EditRow()) { // Update record based on key
					$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
					$sReturnUrl = $CCEMessages->getReturnUrl();
					if (ew_GetPageName($sReturnUrl) == "CCEMessagesview.php")
						$sReturnUrl = $CCEMessages->ViewUrl(); // View paging, return to View page directly
					$this->Page_Terminate($sReturnUrl); // Return to caller
				} else {
					$CCEMessages->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Restore form values if update failed
				}
		}

		// Render the record
		$CCEMessages->RowType = EW_ROWTYPE_EDIT; // Render as Edit
		$this->RenderRow();
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm, $CCEMessages;

		// Get upload data
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm, $CCEMessages;
		$CCEMessages->CCEMessageID->setFormValue($objForm->GetValue("x_CCEMessageID"));
		$CCEMessages->CCEModuleID->setFormValue($objForm->GetValue("x_CCEModuleID"));
		$CCEMessages->SentDateTime->setFormValue($objForm->GetValue("x_SentDateTime"));
		$CCEMessages->SentDateTime->CurrentValue = ew_UnFormatDateTime($CCEMessages->SentDateTime->CurrentValue, 9);
		$CCEMessages->SentByName->setFormValue($objForm->GetValue("x_SentByName"));
		$CCEMessages->SentTo->setFormValue($objForm->GetValue("x_SentTo"));
		$CCEMessages->MessageSubject->setFormValue($objForm->GetValue("x_MessageSubject"));
		$CCEMessages->MessageText->setFormValue($objForm->GetValue("x_MessageText"));
		$CCEMessages->SentByStudentID->setFormValue($objForm->GetValue("x_SentByStudentID"));
		$CCEMessages->SentByFacilitatorID->setFormValue($objForm->GetValue("x_SentByFacilitatorID"));
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm, $CCEMessages;
		$this->LoadRow();
		$CCEMessages->CCEMessageID->CurrentValue = $CCEMessages->CCEMessageID->FormValue;
		$CCEMessages->CCEModuleID->CurrentValue = $CCEMessages->CCEModuleID->FormValue;
		$CCEMessages->SentDateTime->CurrentValue = $CCEMessages->SentDateTime->FormValue;
		$CCEMessages->SentDateTime->CurrentValue = ew_UnFormatDateTime($CCEMessages->SentDateTime->CurrentValue, 9);
		$CCEMessages->SentByName->CurrentValue = $CCEMessages->SentByName->FormValue;
		$CCEMessages->SentTo->CurrentValue = $CCEMessages->SentTo->FormValue;
		$CCEMessages->MessageSubject->CurrentValue = $CCEMessages->MessageSubject->FormValue;
		$CCEMessages->MessageText->CurrentValue = $CCEMessages->MessageText->FormValue;
		$CCEMessages->SentByStudentID->CurrentValue = $CCEMessages->SentByStudentID->FormValue;
		$CCEMessages->SentByFacilitatorID->CurrentValue = $CCEMessages->SentByFacilitatorID->FormValue;
	}

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $CCEMessages;
		$CCEMessages->CCEMessageID->setDbValue($rs->fields('CCEMessageID'));
		$CCEMessages->CCEModuleID->setDbValue($rs->fields('CCEModuleID'));
		$CCEMessages->SentDateTime->setDbValue($rs->fields('SentDateTime'));
		$CCEMessages->SentByName->setDbValue($rs->fields('SentByName'));
		$CCEMessages->SentTo->setDbValue($rs->fields('SentTo'));
		$CCEMessages->MessageSubject->setDbValue($rs->fields('MessageSubject'));
		$CCEMessages->MessageText->setDbValue($rs->fields('MessageText'));
		$CCEMessages->SentByStudentID->setDbValue($rs->fields('SentByStudentID'));
		$CCEMessages->SentByFacilitatorID->setDbValue($rs->fields('SentByFacilitatorID'));
	}

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

		// Initialize URLs
		// Call Row_Rendering event

		$CCEMessages->Row_Rendering();

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

		$CCEMessages->CCEMessageID->CellCssStyle = ""; $CCEMessages->CCEMessageID->CellCssClass = "";
		$CCEMessages->CCEMessageID->CellAttrs = array(); $CCEMessages->CCEMessageID->ViewAttrs = array(); $CCEMessages->CCEMessageID->EditAttrs = array();

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

		// SentDateTime
		$CCEMessages->SentDateTime->CellCssStyle = ""; $CCEMessages->SentDateTime->CellCssClass = "";
		$CCEMessages->SentDateTime->CellAttrs = array(); $CCEMessages->SentDateTime->ViewAttrs = array(); $CCEMessages->SentDateTime->EditAttrs = array();

		// SentByName
		$CCEMessages->SentByName->CellCssStyle = ""; $CCEMessages->SentByName->CellCssClass = "";
		$CCEMessages->SentByName->CellAttrs = array(); $CCEMessages->SentByName->ViewAttrs = array(); $CCEMessages->SentByName->EditAttrs = array();

		// SentTo
		$CCEMessages->SentTo->CellCssStyle = ""; $CCEMessages->SentTo->CellCssClass = "";
		$CCEMessages->SentTo->CellAttrs = array(); $CCEMessages->SentTo->ViewAttrs = array(); $CCEMessages->SentTo->EditAttrs = array();

		// MessageSubject
		$CCEMessages->MessageSubject->CellCssStyle = ""; $CCEMessages->MessageSubject->CellCssClass = "";
		$CCEMessages->MessageSubject->CellAttrs = array(); $CCEMessages->MessageSubject->ViewAttrs = array(); $CCEMessages->MessageSubject->EditAttrs = array();

		// MessageText
		$CCEMessages->MessageText->CellCssStyle = ""; $CCEMessages->MessageText->CellCssClass = "";
		$CCEMessages->MessageText->CellAttrs = array(); $CCEMessages->MessageText->ViewAttrs = array(); $CCEMessages->MessageText->EditAttrs = array();

		// SentByStudentID
		$CCEMessages->SentByStudentID->CellCssStyle = ""; $CCEMessages->SentByStudentID->CellCssClass = "";
		$CCEMessages->SentByStudentID->CellAttrs = array(); $CCEMessages->SentByStudentID->ViewAttrs = array(); $CCEMessages->SentByStudentID->EditAttrs = array();

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

			// CCEMessageID
			$CCEMessages->CCEMessageID->ViewValue = $CCEMessages->CCEMessageID->CurrentValue;
			$CCEMessages->CCEMessageID->CssStyle = "";
			$CCEMessages->CCEMessageID->CssClass = "";
			$CCEMessages->CCEMessageID->ViewCustomAttributes = "";

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

			// SentDateTime
			$CCEMessages->SentDateTime->ViewValue = $CCEMessages->SentDateTime->CurrentValue;
			$CCEMessages->SentDateTime->ViewValue = ew_FormatDateTime($CCEMessages->SentDateTime->ViewValue, 9);
			$CCEMessages->SentDateTime->CssStyle = "";
			$CCEMessages->SentDateTime->CssClass = "";
			$CCEMessages->SentDateTime->ViewCustomAttributes = "";

			// SentByName
			$CCEMessages->SentByName->ViewValue = $CCEMessages->SentByName->CurrentValue;
			$CCEMessages->SentByName->CssStyle = "";
			$CCEMessages->SentByName->CssClass = "";
			$CCEMessages->SentByName->ViewCustomAttributes = "";

			// SentTo
			$CCEMessages->SentTo->ViewValue = $CCEMessages->SentTo->CurrentValue;
			$CCEMessages->SentTo->CssStyle = "";
			$CCEMessages->SentTo->CssClass = "";
			$CCEMessages->SentTo->ViewCustomAttributes = "";

			// MessageSubject
			$CCEMessages->MessageSubject->ViewValue = $CCEMessages->MessageSubject->CurrentValue;
			$CCEMessages->MessageSubject->CssStyle = "";
			$CCEMessages->MessageSubject->CssClass = "";
			$CCEMessages->MessageSubject->ViewCustomAttributes = "";

			// MessageText
			$CCEMessages->MessageText->ViewValue = $CCEMessages->MessageText->CurrentValue;
			$CCEMessages->MessageText->CssStyle = "";
			$CCEMessages->MessageText->CssClass = "";
			$CCEMessages->MessageText->ViewCustomAttributes = "";

			// SentByStudentID
			$CCEMessages->SentByStudentID->ViewValue = $CCEMessages->SentByStudentID->CurrentValue;
			$CCEMessages->SentByStudentID->CssStyle = "";
			$CCEMessages->SentByStudentID->CssClass = "";
			$CCEMessages->SentByStudentID->ViewCustomAttributes = "";

			// SentByFacilitatorID
			$CCEMessages->SentByFacilitatorID->ViewValue = $CCEMessages->SentByFacilitatorID->CurrentValue;
			$CCEMessages->SentByFacilitatorID->CssStyle = "";
			$CCEMessages->SentByFacilitatorID->CssClass = "";
			$CCEMessages->SentByFacilitatorID->ViewCustomAttributes = "";

			// CCEMessageID
			$CCEMessages->CCEMessageID->HrefValue = "";
			$CCEMessages->CCEMessageID->TooltipValue = "";

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

			// SentDateTime
			$CCEMessages->SentDateTime->HrefValue = "";
			$CCEMessages->SentDateTime->TooltipValue = "";

			// SentByName
			$CCEMessages->SentByName->HrefValue = "";
			$CCEMessages->SentByName->TooltipValue = "";

			// SentTo
			$CCEMessages->SentTo->HrefValue = "";
			$CCEMessages->SentTo->TooltipValue = "";

			// MessageSubject
			$CCEMessages->MessageSubject->HrefValue = "";
			$CCEMessages->MessageSubject->TooltipValue = "";

			// MessageText
			$CCEMessages->MessageText->HrefValue = "";
			$CCEMessages->MessageText->TooltipValue = "";

			// SentByStudentID
			$CCEMessages->SentByStudentID->HrefValue = "";
			$CCEMessages->SentByStudentID->TooltipValue = "";

			// SentByFacilitatorID
			$CCEMessages->SentByFacilitatorID->HrefValue = "";
			$CCEMessages->SentByFacilitatorID->TooltipValue = "";
		} elseif ($CCEMessages->RowType == EW_ROWTYPE_EDIT) { // Edit row

			// CCEMessageID
			$CCEMessages->CCEMessageID->EditCustomAttributes = "";

			// CCEModuleID
			$CCEMessages->CCEModuleID->EditCustomAttributes = "";
			if ($CCEMessages->CCEModuleID->getSessionValue() <> "") {
				$CCEMessages->CCEModuleID->CurrentValue = $CCEMessages->CCEModuleID->getSessionValue();
			if (strval($CCEMessages->CCEModuleID->CurrentValue) <> "") {
				$sFilterWrk = "`CCEModuleID` = " . ew_AdjustSql($CCEMessages->CCEModuleID->CurrentValue) . "";
			$sSqlWrk = "SELECT `ModuleName` FROM `CCEModules`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `ModuleName`";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEMessages->CCEModuleID->ViewValue = $rswrk->fields('ModuleName');
					$rswrk->Close();
				} else {
					$CCEMessages->CCEModuleID->ViewValue = $CCEMessages->CCEModuleID->CurrentValue;
				}
			} else {
				$CCEMessages->CCEModuleID->ViewValue = NULL;
			}
			$CCEMessages->CCEModuleID->CssStyle = "";
			$CCEMessages->CCEModuleID->CssClass = "";
			$CCEMessages->CCEModuleID->ViewCustomAttributes = "";
			} else {
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `CCEModuleID`, `ModuleName`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `CCEModules`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `ModuleName`";
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$CCEMessages->CCEModuleID->EditValue = $arwrk;
			}

			// SentDateTime
			$CCEMessages->SentDateTime->EditCustomAttributes = "";
			$CCEMessages->SentDateTime->EditValue = ew_HtmlEncode(ew_FormatDateTime($CCEMessages->SentDateTime->CurrentValue, 9));

			// SentByName
			$CCEMessages->SentByName->EditCustomAttributes = "";
			$CCEMessages->SentByName->EditValue = ew_HtmlEncode($CCEMessages->SentByName->CurrentValue);

			// SentTo
			$CCEMessages->SentTo->EditCustomAttributes = "";
			$CCEMessages->SentTo->EditValue = ew_HtmlEncode($CCEMessages->SentTo->CurrentValue);

			// MessageSubject
			$CCEMessages->MessageSubject->EditCustomAttributes = "";
			$CCEMessages->MessageSubject->EditValue = ew_HtmlEncode($CCEMessages->MessageSubject->CurrentValue);

			// MessageText
			$CCEMessages->MessageText->EditCustomAttributes = "";
			$CCEMessages->MessageText->EditValue = ew_HtmlEncode($CCEMessages->MessageText->CurrentValue);

			// SentByStudentID
			$CCEMessages->SentByStudentID->EditCustomAttributes = "";
			$CCEMessages->SentByStudentID->EditValue = ew_HtmlEncode($CCEMessages->SentByStudentID->CurrentValue);

			// SentByFacilitatorID
			$CCEMessages->SentByFacilitatorID->EditCustomAttributes = "";
			$CCEMessages->SentByFacilitatorID->EditValue = ew_HtmlEncode($CCEMessages->SentByFacilitatorID->CurrentValue);

			// Edit refer script
			// CCEMessageID

			$CCEMessages->CCEMessageID->HrefValue = "";

			// CCEModuleID
			$CCEMessages->CCEModuleID->HrefValue = "";

			// SentDateTime
			$CCEMessages->SentDateTime->HrefValue = "";

			// SentByName
			$CCEMessages->SentByName->HrefValue = "";

			// SentTo
			$CCEMessages->SentTo->HrefValue = "";

			// MessageSubject
			$CCEMessages->MessageSubject->HrefValue = "";

			// MessageText
			$CCEMessages->MessageText->HrefValue = "";

			// SentByStudentID
			$CCEMessages->SentByStudentID->HrefValue = "";

			// SentByFacilitatorID
			$CCEMessages->SentByFacilitatorID->HrefValue = "";
		}

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

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError, $CCEMessages;

		// Initialize form error message
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!ew_CheckDate($CCEMessages->SentDateTime->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEMessages->SentDateTime->FldErrMsg();
		}
		if (!ew_CheckInteger($CCEMessages->SentByName->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEMessages->SentByName->FldErrMsg();
		}
		if (!ew_CheckInteger($CCEMessages->SentByStudentID->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEMessages->SentByStudentID->FldErrMsg();
		}
		if (!ew_CheckInteger($CCEMessages->SentByFacilitatorID->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEMessages->SentByFacilitatorID->FldErrMsg();
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $sFormCustomError;
		}
		return $ValidateForm;
	}

	// Update record based on key values
	function EditRow() {
		global $conn, $Security, $Language, $CCEMessages;
		$sFilter = $CCEMessages->KeyFilter();
		$CCEMessages->CurrentFilter = $sFilter;
		$sSql = $CCEMessages->SQL();
		$conn->raiseErrorFn = 'ew_ErrorFn';
		$rs = $conn->Execute($sSql);
		$conn->raiseErrorFn = '';
		if ($rs === FALSE)
			return FALSE;
		if ($rs->EOF) {
			$EditRow = FALSE; // Update Failed
		} else {

			// Save old values
			$rsold =& $rs->fields;
			$rsnew = array();

			// CCEModuleID
			$CCEMessages->CCEModuleID->SetDbValueDef($rsnew, $CCEMessages->CCEModuleID->CurrentValue, NULL, FALSE);

			// SentDateTime
			$CCEMessages->SentDateTime->SetDbValueDef($rsnew, ew_UnFormatDateTime($CCEMessages->SentDateTime->CurrentValue, 9, FALSE), NULL);

			// SentByName
			$CCEMessages->SentByName->SetDbValueDef($rsnew, $CCEMessages->SentByName->CurrentValue, NULL, FALSE);

			// SentTo
			$CCEMessages->SentTo->SetDbValueDef($rsnew, $CCEMessages->SentTo->CurrentValue, NULL, FALSE);

			// MessageSubject
			$CCEMessages->MessageSubject->SetDbValueDef($rsnew, $CCEMessages->MessageSubject->CurrentValue, NULL, FALSE);

			// MessageText
			$CCEMessages->MessageText->SetDbValueDef($rsnew, $CCEMessages->MessageText->CurrentValue, NULL, FALSE);

			// SentByStudentID
			$CCEMessages->SentByStudentID->SetDbValueDef($rsnew, $CCEMessages->SentByStudentID->CurrentValue, NULL, FALSE);

			// SentByFacilitatorID
			$CCEMessages->SentByFacilitatorID->SetDbValueDef($rsnew, $CCEMessages->SentByFacilitatorID->CurrentValue, NULL, FALSE);

			// Call Row Updating event
			$bUpdateRow = $CCEMessages->Row_Updating($rsold, $rsnew);
			if ($bUpdateRow) {
				$conn->raiseErrorFn = 'ew_ErrorFn';
				$EditRow = $conn->Execute($CCEMessages->UpdateSQL($rsnew));
				$conn->raiseErrorFn = '';
			} else {
				if ($CCEMessages->CancelMessage <> "") {
					$this->setMessage($CCEMessages->CancelMessage);
					$CCEMessages->CancelMessage = "";
				} else {
					$this->setMessage($Language->Phrase("UpdateCancelled"));
				}
				$EditRow = FALSE;
			}
		}

		// Call Row_Updated event
		if ($EditRow)
			$CCEMessages->Row_Updated($rsold, $rsnew);
		$rs->Close();
		return $EditRow;
	}

	// Set up master/detail based on QueryString
	function SetUpMasterDetail() {
		global $CCEMessages;
		$bValidMaster = FALSE;

		// Get the keys for master table
		if (@$_GET[EW_TABLE_SHOW_MASTER] <> "") {
			$sMasterTblVar = $_GET[EW_TABLE_SHOW_MASTER];
			if ($sMasterTblVar == "") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = "";
				$this->sDbDetailFilter = "";
			}
			if ($sMasterTblVar == "CCEModules") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $CCEMessages->SqlMasterFilter_CCEModules();
				$this->sDbDetailFilter = $CCEMessages->SqlDetailFilter_CCEModules();
				if (@$_GET["CCEModuleID"] <> "") {
					$GLOBALS["CCEModules"]->CCEModuleID->setQueryStringValue($_GET["CCEModuleID"]);
					$CCEMessages->CCEModuleID->setQueryStringValue($GLOBALS["CCEModules"]->CCEModuleID->QueryStringValue);
					$CCEMessages->CCEModuleID->setSessionValue($CCEMessages->CCEModuleID->QueryStringValue);
					if (!is_numeric($GLOBALS["CCEModules"]->CCEModuleID->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@CCEModuleID@", ew_AdjustSql($GLOBALS["CCEModules"]->CCEModuleID->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@CCEModuleID@", ew_AdjustSql($GLOBALS["CCEModules"]->CCEModuleID->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
		}
		if ($bValidMaster) {

			// Save current master table
			$CCEMessages->setCurrentMasterTable($sMasterTblVar);

			// Reset start record counter (new master key)
			$this->lStartRec = 1;
			$CCEMessages->setStartRecordNumber($this->lStartRec);
			$CCEMessages->setMasterFilter($this->sDbMasterFilter); // Set up master filter
			$CCEMessages->setDetailFilter($this->sDbDetailFilter); // Set up detail filter

			// Clear previous master key from Session
			if ($sMasterTblVar <> "CCEModules") {
				if ($CCEMessages->CCEModuleID->QueryStringValue == "") $CCEMessages->CCEModuleID->setSessionValue("");
			}
		} else {
			$this->sDbMasterFilter = $CCEMessages->getMasterFilter(); //  Restore master filter
			$this->sDbDetailFilter = $CCEMessages->getDetailFilter(); // Restore detail filter
		}
	}

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