Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/ccmadmin/
Upload File :
Current File : /var/www/cesa.co.za/ccmadmin/CCMNoticeBoardadd.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_add = new cCCMNoticeBoard_add();
$Page =& $CCMNoticeBoard_add;

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

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

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

// page properties
CCMNoticeBoard_add.PageID = "add"; // page ID
CCMNoticeBoard_add.FormID = "fCCMNoticeBoardadd"; // form ID
var EW_PAGE_ID = CCMNoticeBoard_add.PageID; // for backward compatibility

// extend page with ValidateForm function
CCMNoticeBoard_add.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_add.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_add.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCMNoticeBoard_add.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("Add") ?>&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_add->ShowMessage();
?>
<form name="fCCMNoticeBoardadd" id="fCCMNoticeBoardadd" action="<?php echo ew_CurrentPage() ?>" method="post" enctype="multipart/form-data" onsubmit="return CCMNoticeBoard_add.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="CCMNoticeBoard">
<input type="hidden" name="a_add" id="a_add" value="A">
<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">
<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>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("AddBtn")) ?>">
</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_add->Page_Terminate();
?>
<?php

//
// Page class
//
class cCCMNoticeBoard_add {

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

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

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

	// 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_add() {
		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", 'add', 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->CanAdd()) {
			$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 = "";
	var $lPriv = 0;

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

		// Load key values from QueryString
		$bCopy = TRUE;
		if (@$_GET["CCMDocumentID"] != "") {
		  $CCMNoticeBoard->CCMDocumentID->setQueryStringValue($_GET["CCMDocumentID"]);
		} else {
		  $bCopy = FALSE;
		}

		// Process form if post back
		if (@$_POST["a_add"] <> "") {
		   $CCMNoticeBoard->CurrentAction = $_POST["a_add"]; // Get form action
		  $this->GetUploadFiles(); // Get upload files
		  $this->LoadFormValues(); // Load form values

			// Validate form
			if (!$this->ValidateForm()) {
				$CCMNoticeBoard->CurrentAction = "I"; // Form error, reset action
				$this->setMessage($gsFormError);
			}
		} else { // Not post back
		  if ($bCopy) {
		    $CCMNoticeBoard->CurrentAction = "C"; // Copy record
		  } else {
		    $CCMNoticeBoard->CurrentAction = "I"; // Display blank record
		    $this->LoadDefaultValues(); // Load default values
		  }
		}

		// Perform action based on action code
		switch ($CCMNoticeBoard->CurrentAction) {
		  case "I": // Blank record, no action required
				break;
		  case "C": // Copy an existing record
		   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 "A": // ' Add new record
				$CCMNoticeBoard->SendEmail = TRUE; // Send email on add success
		    if ($this->AddRow()) { // Add successful
		      $this->setMessage($Language->Phrase("AddSuccess")); // Set up success message
					$sReturnUrl = $CCMNoticeBoard->getReturnUrl();
					if (ew_GetPageName($sReturnUrl) == "CCMNoticeBoardview.php")
						$sReturnUrl = $CCMNoticeBoard->ViewUrl(); // View paging, return to view page with keyurl directly
					$this->Page_Terminate($sReturnUrl); // Clean up and return
		    } else {
		      $this->RestoreFormValues(); // Add failed, restore form values
		    }
		}

		// Render row based on row type
		$CCMNoticeBoard->RowType = EW_ROWTYPE_ADD;  // Render add type

		// Render row
		$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 default values
	function LoadDefaultValues() {
		global $CCMNoticeBoard;
		$CCMNoticeBoard->DocumentFile->CurrentValue = NULL; // Clear file related field
		$CCMNoticeBoard->Archived->CurrentValue = 0;
	}

	// 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;
		$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_ADD) { // Add 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);
		}

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

	// Add record
	function AddRow() {
		global $conn, $Language, $Security, $CCMNoticeBoard;
		$rsnew = array();

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

		// DocumentFile
		$CCMNoticeBoard->DocumentFile->Upload->SaveToSession(); // Save file value to Session
		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, TRUE);

		// Call Row Inserting event
		$bInsertRow = $CCMNoticeBoard->Row_Inserting($rsnew);
		if ($bInsertRow) {
			if (!ew_Empty($CCMNoticeBoard->DocumentFile->Upload->Value)) {
				$CCMNoticeBoard->DocumentFile->Upload->SaveToFile($CCMNoticeBoard->DocumentFile->UploadPath, $rsnew['DocumentFile'], FALSE);
			}
			$conn->raiseErrorFn = 'ew_ErrorFn';
			$AddRow = $conn->Execute($CCMNoticeBoard->InsertSQL($rsnew));
			$conn->raiseErrorFn = '';
		} else {
			if ($CCMNoticeBoard->CancelMessage <> "") {
				$this->setMessage($CCMNoticeBoard->CancelMessage);
				$CCMNoticeBoard->CancelMessage = "";
			} else {
				$this->setMessage($Language->Phrase("InsertCancelled"));
			}
			$AddRow = FALSE;
		}
		if ($AddRow) {
			$CCMNoticeBoard->CCMDocumentID->setDbValue($conn->Insert_ID());
			$rsnew['CCMDocumentID'] = $CCMNoticeBoard->CCMDocumentID->DbValue;

			// Call Row Inserted event
			$CCMNoticeBoard->Row_Inserted($rsnew);
		}

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

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