Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/ccmadmin/
Upload File :
Current File : /var/www/cesa.co.za/ccmadmin/CCMNoticeBoardedit.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 "CCMNoticeBoardinfo.php" ?>
<?php include "CCMUsersinfo.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
$CCMNoticeBoard_edit = new cCCMNoticeBoard_edit();
$Page =& $CCMNoticeBoard_edit;

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

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

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

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

// extend page with ValidateForm function
CCMNoticeBoard_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 + "_DocumentFile"];
		if (elm && !ew_CheckFileType(elm.value))
			return ew_OnError(this, elm, ewLanguage.Phrase("WrongFileType"));
		elm = fobj.elements["x" + infix + "_UploadedBy"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCMNoticeBoard->UploadedBy->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_Archived"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCMNoticeBoard->Archived->FldErrMsg()) ?>");

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

// extend page with Form_CustomValidate function
CCMNoticeBoard_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) { ?>
CCMNoticeBoard_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCMNoticeBoard_edit.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("Edit") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCMNoticeBoard->TableCaption() ?><br><br>
<a href="<?php echo $CCMNoticeBoard->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$CCMNoticeBoard_edit->ShowMessage();
?>
<form name="fCCMNoticeBoardedit" id="fCCMNoticeBoardedit" action="<?php echo ew_CurrentPage() ?>" method="post" enctype="multipart/form-data" onsubmit="return CCMNoticeBoard_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="CCMNoticeBoard">
<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">
<?php if ($CCMNoticeBoard->DocumentName->Visible) { // DocumentName ?>
	<tr<?php echo $CCMNoticeBoard->DocumentName->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCMNoticeBoard->DocumentName->FldCaption() ?></td>
		<td<?php echo $CCMNoticeBoard->DocumentName->CellAttributes() ?>><span id="el_DocumentName">
<input type="text" name="x_DocumentName" id="x_DocumentName" title="<?php echo $CCMNoticeBoard->DocumentName->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCMNoticeBoard->DocumentName->EditValue ?>"<?php echo $CCMNoticeBoard->DocumentName->EditAttributes() ?>>
</span><?php echo $CCMNoticeBoard->DocumentName->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCMNoticeBoard->DocumentFile->Visible) { // DocumentFile ?>
	<tr<?php echo $CCMNoticeBoard->DocumentFile->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCMNoticeBoard->DocumentFile->FldCaption() ?></td>
		<td<?php echo $CCMNoticeBoard->DocumentFile->CellAttributes() ?>><span id="el_DocumentFile">
<div id="old_x_DocumentFile">
<?php if ($CCMNoticeBoard->DocumentFile->HrefValue <> "" || $CCMNoticeBoard->DocumentFile->TooltipValue <> "") { ?>
<?php if (!empty($CCMNoticeBoard->DocumentFile->Upload->DbValue)) { ?>
<a href="<?php echo $CCMNoticeBoard->DocumentFile->HrefValue ?>"><?php echo $CCMNoticeBoard->DocumentFile->EditValue ?></a>
<?php } elseif (!in_array($CCMNoticeBoard->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($CCMNoticeBoard->DocumentFile->Upload->DbValue)) { ?>
<?php echo $CCMNoticeBoard->DocumentFile->EditValue ?>
<?php } elseif (!in_array($CCMNoticeBoard->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</div>
<div id="new_x_DocumentFile">
<?php if (!empty($CCMNoticeBoard->DocumentFile->Upload->DbValue)) { ?>
<label><input type="radio" name="a_DocumentFile" id="a_DocumentFile" value="1" checked="checked"><?php echo $Language->Phrase("Keep") ?></label>&nbsp;
<label><input type="radio" name="a_DocumentFile" id="a_DocumentFile" value="2"><?php echo $Language->Phrase("Remove") ?></label>&nbsp;
<label><input type="radio" name="a_DocumentFile" id="a_DocumentFile" value="3"><?php echo $Language->Phrase("Replace") ?><br></label>
<?php $CCMNoticeBoard->DocumentFile->EditAttrs["onchange"] = "this.form.a_DocumentFile[2].checked=true;" . @$CCMNoticeBoard->DocumentFile->EditAttrs["onchange"]; ?>
<?php } else { ?>
<input type="hidden" name="a_DocumentFile" id="a_DocumentFile" value="3">
<?php } ?>
<input type="file" name="x_DocumentFile" id="x_DocumentFile" title="<?php echo $CCMNoticeBoard->DocumentFile->FldTitle() ?>" size="30"<?php echo $CCMNoticeBoard->DocumentFile->EditAttributes() ?>>
</div>
</span><?php echo $CCMNoticeBoard->DocumentFile->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCMNoticeBoard->UploadedBy->Visible) { // UploadedBy ?>
	<tr<?php echo $CCMNoticeBoard->UploadedBy->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCMNoticeBoard->UploadedBy->FldCaption() ?></td>
		<td<?php echo $CCMNoticeBoard->UploadedBy->CellAttributes() ?>><span id="el_UploadedBy">
<input type="text" name="x_UploadedBy" id="x_UploadedBy" title="<?php echo $CCMNoticeBoard->UploadedBy->FldTitle() ?>" size="30" value="<?php echo $CCMNoticeBoard->UploadedBy->EditValue ?>"<?php echo $CCMNoticeBoard->UploadedBy->EditAttributes() ?>>
</span><?php echo $CCMNoticeBoard->UploadedBy->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCMNoticeBoard->DocumentURL->Visible) { // DocumentURL ?>
	<tr<?php echo $CCMNoticeBoard->DocumentURL->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCMNoticeBoard->DocumentURL->FldCaption() ?></td>
		<td<?php echo $CCMNoticeBoard->DocumentURL->CellAttributes() ?>><span id="el_DocumentURL">
<input type="text" name="x_DocumentURL" id="x_DocumentURL" title="<?php echo $CCMNoticeBoard->DocumentURL->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCMNoticeBoard->DocumentURL->EditValue ?>"<?php echo $CCMNoticeBoard->DocumentURL->EditAttributes() ?>>
</span><?php echo $CCMNoticeBoard->DocumentURL->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCMNoticeBoard->Archived->Visible) { // Archived ?>
	<tr<?php echo $CCMNoticeBoard->Archived->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCMNoticeBoard->Archived->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $CCMNoticeBoard->Archived->CellAttributes() ?>><span id="el_Archived">
<input type="text" name="x_Archived" id="x_Archived" title="<?php echo $CCMNoticeBoard->Archived->FldTitle() ?>" size="30" value="<?php echo $CCMNoticeBoard->Archived->EditValue ?>"<?php echo $CCMNoticeBoard->Archived->EditAttributes() ?>>
</span><?php echo $CCMNoticeBoard->Archived->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<input type="hidden" name="x_CCMDocumentID" id="x_CCMDocumentID" value="<?php echo ew_HtmlEncode($CCMNoticeBoard->CCMDocumentID->CurrentValue) ?>">
<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
$CCMNoticeBoard_edit->Page_Terminate();
?>
<?php

//
// Page class
//
class cCCMNoticeBoard_edit {

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

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

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

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

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

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

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

		// Table object (CCMNoticeBoard)
		$GLOBALS["CCMNoticeBoard"] = new cCCMNoticeBoard();

		// Table object (CCMUsers)
		$GLOBALS['CCMUsers'] = new cCCMUsers();

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

		// 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("CCMNoticeBoardlist.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, $CCMNoticeBoard;

		// Load key from QueryString
		if (@$_GET["CCMDocumentID"] <> "")
			$CCMNoticeBoard->CCMDocumentID->setQueryStringValue($_GET["CCMDocumentID"]);
		if (@$_POST["a_edit"] <> "") {
			$CCMNoticeBoard->CurrentAction = $_POST["a_edit"]; // Get action code
			$this->GetUploadFiles(); // Get upload files
			$this->LoadFormValues(); // Get form values

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

		// Check if valid key
		if ($CCMNoticeBoard->CCMDocumentID->CurrentValue == "")
			$this->Page_Terminate("CCMNoticeBoardlist.php"); // Invalid key, return to list
		switch ($CCMNoticeBoard->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("CCMNoticeBoardlist.php"); // No matching record, return to list
				}
				break;
			Case "U": // Update
				$CCMNoticeBoard->SendEmail = TRUE; // Send email on update success
				if ($this->EditRow()) { // Update record based on key
					$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
					$sReturnUrl = $CCMNoticeBoard->getReturnUrl();
					if (ew_GetPageName($sReturnUrl) == "CCMNoticeBoardview.php")
						$sReturnUrl = $CCMNoticeBoard->ViewUrl(); // View paging, return to View page directly
					$this->Page_Terminate($sReturnUrl); // Return to caller
				} else {
					$CCMNoticeBoard->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Restore form values if update failed
				}
		}

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

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

		// Get upload data
			if ($CCMNoticeBoard->DocumentFile->Upload->UploadFile()) {

				// No action required
			} else {
				echo $CCMNoticeBoard->DocumentFile->Upload->Message;
				$this->Page_Terminate();
				exit();
			}
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm, $CCMNoticeBoard;
		$CCMNoticeBoard->DocumentName->setFormValue($objForm->GetValue("x_DocumentName"));
		$CCMNoticeBoard->UploadedBy->setFormValue($objForm->GetValue("x_UploadedBy"));
		$CCMNoticeBoard->DocumentURL->setFormValue($objForm->GetValue("x_DocumentURL"));
		$CCMNoticeBoard->Archived->setFormValue($objForm->GetValue("x_Archived"));
		$CCMNoticeBoard->CCMDocumentID->setFormValue($objForm->GetValue("x_CCMDocumentID"));
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm, $CCMNoticeBoard;
		$CCMNoticeBoard->CCMDocumentID->CurrentValue = $CCMNoticeBoard->CCMDocumentID->FormValue;
		$this->LoadRow();
		$CCMNoticeBoard->DocumentName->CurrentValue = $CCMNoticeBoard->DocumentName->FormValue;
		$CCMNoticeBoard->UploadedBy->CurrentValue = $CCMNoticeBoard->UploadedBy->FormValue;
		$CCMNoticeBoard->DocumentURL->CurrentValue = $CCMNoticeBoard->DocumentURL->FormValue;
		$CCMNoticeBoard->Archived->CurrentValue = $CCMNoticeBoard->Archived->FormValue;
	}

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $CCMNoticeBoard;
		$CCMNoticeBoard->CCMDocumentID->setDbValue($rs->fields('CCMDocumentID'));
		$CCMNoticeBoard->DocumentName->setDbValue($rs->fields('DocumentName'));
		$CCMNoticeBoard->DocumentFile->Upload->DbValue = $rs->fields('DocumentFile');
		$CCMNoticeBoard->UploadedBy->setDbValue($rs->fields('UploadedBy'));
		$CCMNoticeBoard->DocumentURL->setDbValue($rs->fields('DocumentURL'));
		$CCMNoticeBoard->DocumentThumb->setDbValue($rs->fields('DocumentThumb'));
		$CCMNoticeBoard->Archived->setDbValue($rs->fields('Archived'));
	}

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

		// Initialize URLs
		// Call Row_Rendering event

		$CCMNoticeBoard->Row_Rendering();

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

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

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

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

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

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

			// CCMDocumentID
			$CCMNoticeBoard->CCMDocumentID->ViewValue = $CCMNoticeBoard->CCMDocumentID->CurrentValue;
			$CCMNoticeBoard->CCMDocumentID->CssStyle = "";
			$CCMNoticeBoard->CCMDocumentID->CssClass = "";
			$CCMNoticeBoard->CCMDocumentID->ViewCustomAttributes = "";

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

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

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

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

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

			// Archived
			$CCMNoticeBoard->Archived->ViewValue = $CCMNoticeBoard->Archived->CurrentValue;
			$CCMNoticeBoard->Archived->CssStyle = "";
			$CCMNoticeBoard->Archived->CssClass = "";
			$CCMNoticeBoard->Archived->ViewCustomAttributes = "";

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

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

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

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

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

			// DocumentName
			$CCMNoticeBoard->DocumentName->EditCustomAttributes = "";
			$CCMNoticeBoard->DocumentName->EditValue = ew_HtmlEncode($CCMNoticeBoard->DocumentName->CurrentValue);

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

			// UploadedBy
			$CCMNoticeBoard->UploadedBy->EditCustomAttributes = "";
			$CCMNoticeBoard->UploadedBy->EditValue = ew_HtmlEncode($CCMNoticeBoard->UploadedBy->CurrentValue);

			// DocumentURL
			$CCMNoticeBoard->DocumentURL->EditCustomAttributes = "";
			$CCMNoticeBoard->DocumentURL->EditValue = ew_HtmlEncode($CCMNoticeBoard->DocumentURL->CurrentValue);

			// Archived
			$CCMNoticeBoard->Archived->EditCustomAttributes = "";
			$CCMNoticeBoard->Archived->EditValue = ew_HtmlEncode($CCMNoticeBoard->Archived->CurrentValue);

			// Edit refer script
			// DocumentName

			$CCMNoticeBoard->DocumentName->HrefValue = "";

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

			// UploadedBy
			$CCMNoticeBoard->UploadedBy->HrefValue = "";

			// DocumentURL
			$CCMNoticeBoard->DocumentURL->HrefValue = "";

			// Archived
			$CCMNoticeBoard->Archived->HrefValue = "";
		}

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

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

		// Initialize form error message
		$gsFormError = "";
		if (!ew_CheckFileType($CCMNoticeBoard->DocumentFile->Upload->FileName)) {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("WrongFileType");
		}
		if ($CCMNoticeBoard->DocumentFile->Upload->FileSize > 0 && EW_MAX_FILE_SIZE > 0 && $CCMNoticeBoard->DocumentFile->Upload->FileSize > EW_MAX_FILE_SIZE) {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= str_replace("%s", EW_MAX_FILE_SIZE, $Language->Phrase("MaxFileSize"));
		}
		if (in_array($CCMNoticeBoard->DocumentFile->Upload->Error, array(1, 2, 3, 6, 7, 8))) {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("PhpUploadErr" . $CCMNoticeBoard->DocumentFile->Upload->Error);
		}

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!ew_CheckInteger($CCMNoticeBoard->UploadedBy->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCMNoticeBoard->UploadedBy->FldErrMsg();
		}
		if (!ew_CheckInteger($CCMNoticeBoard->Archived->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCMNoticeBoard->Archived->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, $CCMNoticeBoard;
		$sFilter = $CCMNoticeBoard->KeyFilter();
		$CCMNoticeBoard->CurrentFilter = $sFilter;
		$sSql = $CCMNoticeBoard->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();

			// DocumentName
			$CCMNoticeBoard->DocumentName->SetDbValueDef($rsnew, $CCMNoticeBoard->DocumentName->CurrentValue, NULL, FALSE);

			// DocumentFile
			$CCMNoticeBoard->DocumentFile->Upload->SaveToSession(); // Save file value to Session
						if ($CCMNoticeBoard->DocumentFile->Upload->Action == "2" || $CCMNoticeBoard->DocumentFile->Upload->Action == "3") { // Update/Remove
			$CCMNoticeBoard->DocumentFile->Upload->DbValue = $rs->fields('DocumentFile'); // Get original value
			if (is_null($CCMNoticeBoard->DocumentFile->Upload->Value)) {
				$rsnew['DocumentFile'] = NULL;
			} else {
				$rsnew['DocumentFile'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $CCMNoticeBoard->DocumentFile->UploadPath), $CCMNoticeBoard->DocumentFile->Upload->FileName);
			}
			}

			// UploadedBy
			$CCMNoticeBoard->UploadedBy->SetDbValueDef($rsnew, $CCMNoticeBoard->UploadedBy->CurrentValue, NULL, FALSE);

			// DocumentURL
			$CCMNoticeBoard->DocumentURL->SetDbValueDef($rsnew, $CCMNoticeBoard->DocumentURL->CurrentValue, NULL, FALSE);

			// Archived
			$CCMNoticeBoard->Archived->SetDbValueDef($rsnew, $CCMNoticeBoard->Archived->CurrentValue, 0, FALSE);

			// Call Row Updating event
			$bUpdateRow = $CCMNoticeBoard->Row_Updating($rsold, $rsnew);
			if ($bUpdateRow) {
			if (!ew_Empty($CCMNoticeBoard->DocumentFile->Upload->Value)) {
				$CCMNoticeBoard->DocumentFile->Upload->SaveToFile($CCMNoticeBoard->DocumentFile->UploadPath, $rsnew['DocumentFile'], FALSE);
			}
				$conn->raiseErrorFn = 'ew_ErrorFn';
				$EditRow = $conn->Execute($CCMNoticeBoard->UpdateSQL($rsnew));
				$conn->raiseErrorFn = '';
			} else {
				if ($CCMNoticeBoard->CancelMessage <> "") {
					$this->setMessage($CCMNoticeBoard->CancelMessage);
					$CCMNoticeBoard->CancelMessage = "";
				} else {
					$this->setMessage($Language->Phrase("UpdateCancelled"));
				}
				$EditRow = FALSE;
			}
		}

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

		// DocumentFile
		$CCMNoticeBoard->DocumentFile->Upload->RemoveFromSession(); // Remove file value from Session
		return $EditRow;
	}

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