PageRenderTime 27ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/companyedit.php

https://bitbucket.org/joemarmatulac/ebutton
PHP | 1152 lines | 799 code | 154 blank | 199 comment | 181 complexity | cecd8868252a4272d9bad49bd9c572e9 MD5 | raw file
   1<?php
   2if (session_id() == "") session_start(); // Initialize Session data
   3ob_start(); // Turn on output buffering
   4?>
   5<?php include_once "ewcfg8.php" ?>
   6<?php include_once "ewmysql8.php" ?>
   7<?php include_once "phpfn8.php" ?>
   8<?php include_once "companyinfo.php" ?>
   9<?php include_once "userinfo.php" ?>
  10<?php include_once "userfn8.php" ?>
  11<?php ew_Header(FALSE) ?>
  12<?php
  13
  14// Create page object
  15$company_edit = new ccompany_edit();
  16$Page =& $company_edit;
  17
  18// Page init
  19$company_edit->Page_Init();
  20
  21// Page main
  22$company_edit->Page_Main();
  23?>
  24<?php include_once "header.php" ?>
  25<script type="text/javascript">
  26<!--
  27
  28// Create page object
  29var company_edit = new ew_Page("company_edit");
  30
  31// page properties
  32company_edit.PageID = "edit"; // page ID
  33company_edit.FormID = "fcompanyedit"; // form ID
  34var EW_PAGE_ID = company_edit.PageID; // for backward compatibility
  35
  36// extend page with ValidateForm function
  37company_edit.ValidateForm = function(fobj) {
  38	ew_PostAutoSuggest(fobj);
  39	if (!this.ValidateRequired)
  40		return true; // ignore validation
  41	if (fobj.a_confirm && fobj.a_confirm.value == "F")
  42		return true;
  43	var i, elm, aelm, infix;
  44	var rowcnt = 1;
  45	for (i=0; i<rowcnt; i++) {
  46		infix = "";
  47		elm = fobj.elements["x" + infix + "_id"];
  48		if (elm && !ew_CheckInteger(elm.value))
  49			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($company->id->FldErrMsg()) ?>");
  50		elm = fobj.elements["x" + infix + "_name"];
  51		if (elm && !ew_HasValue(elm))
  52			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($company->name->FldCaption()) ?>");
  53		/*elm = fobj.elements["x" + infix + "_address"];
  54		if (elm && !ew_HasValue(elm))
  55			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($company->address->FldCaption()) ?>");
  56		elm = fobj.elements["x" + infix + "_mobileno"];
  57		if (elm && !ew_HasValue(elm))
  58			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($company->mobileno->FldCaption()) ?>");
  59		elm = fobj.elements["x" + infix + "_city"];
  60		if (elm && !ew_HasValue(elm))
  61			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($company->city->FldCaption()) ?>");
  62		elm = fobj.elements["x" + infix + "_province"];
  63		if (elm && !ew_HasValue(elm))
  64			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($company->province->FldCaption()) ?>");
  65		elm = fobj.elements["x" + infix + "_telno"];
  66		if (elm && !ew_HasValue(elm))
  67			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($company->telno->FldCaption()) ?>");
  68		elm = fobj.elements["x" + infix + "_faxno"];
  69		if (elm && !ew_HasValue(elm))
  70			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($company->faxno->FldCaption()) ?>");
  71		elm = fobj.elements["x" + infix + "_zemail"];
  72		if (elm && !ew_HasValue(elm))
  73			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($company->zemail->FldCaption()) ?>");
  74		elm = fobj.elements["x" + infix + "_contact"];
  75		if (elm && !ew_HasValue(elm))
  76			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($company->contact->FldCaption()) ?>");
  77		*/
  78		// Set up row object
  79		var row = {};
  80		row["index"] = infix;
  81		for (var j = 0; j < fobj.elements.length; j++) {
  82			var el = fobj.elements[j];
  83			var len = infix.length + 2;
  84			if (el.name.substr(0, len) == "x" + infix + "_") {
  85				var elname = "x_" + el.name.substr(len);
  86				if (ewLang.isObject(row[elname])) { // already exists
  87					if (ewLang.isArray(row[elname])) {
  88						row[elname][row[elname].length] = el; // add to array
  89					} else {
  90						row[elname] = [row[elname], el]; // convert to array
  91					}
  92				} else {
  93					row[elname] = el;
  94				}
  95			}
  96		}
  97		fobj.row = row;
  98
  99		// Call Form Custom Validate event
 100		if (!this.Form_CustomValidate(fobj)) return false;
 101	}
 102
 103	// Process detail page
 104	var detailpage = (fobj.detailpage) ? fobj.detailpage.value : "";
 105	if (detailpage != "") {
 106		return eval(detailpage+".ValidateForm(fobj)");
 107	}
 108	return true;
 109}
 110
 111// extend page with Form_CustomValidate function
 112company_edit.Form_CustomValidate =  
 113 function(fobj) { // DO NOT CHANGE THIS LINE!
 114
 115 	// Your custom validation code here, return false if invalid. 
 116 	return true;
 117 }
 118<?php if (EW_CLIENT_VALIDATE) { ?>
 119company_edit.ValidateRequired = true; // uses JavaScript validation
 120<?php } else { ?>
 121company_edit.ValidateRequired = false; // no JavaScript validation
 122<?php } ?>
 123
 124//-->
 125</script>
 126<script language="JavaScript" type="text/javascript">
 127<!--
 128
 129// Write your client script here, no need to add script tags.
 130//-->
 131
 132</script>
 133<p class="phpmaker ewTitle"><?php echo $Language->Phrase("Edit") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $company->TableCaption() ?></p>
 134<p class="phpmaker"><a href="<?php echo $company->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></p>
 135<?php $company_edit->ShowPageHeader(); ?>
 136<?php
 137$company_edit->ShowMessage();
 138?>
 139<form name="fcompanyedit" id="fcompanyedit" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return company_edit.ValidateForm(this);">
 140<p>
 141<input type="hidden" name="a_table" id="a_table" value="company">
 142<input type="hidden" name="a_edit" id="a_edit" value="U">
 143<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
 144<div class="ewGridMiddlePanel">
 145<table cellspacing="0" class="ewTable">
 146<?php if ($company->id->Visible) { // id ?>
 147	<tr id="r_id"<?php echo $company->RowAttributes() ?>>
 148		<td class="ewTableHeader"><?php echo $company->id->FldCaption() ?></td>
 149		<td<?php echo $company->id->CellAttributes() ?>><span id="el_id">
 150<div<?php echo $company->id->ViewAttributes() ?>><?php echo $company->id->EditValue ?></div>
 151<input type="hidden" name="x_id" id="x_id" value="<?php echo ew_HtmlEncode($company->id->CurrentValue) ?>">
 152</span><?php echo $company->id->CustomMsg ?></td>
 153	</tr>
 154<?php } ?>
 155<?php if ($company->name->Visible) { // name ?>
 156	<tr id="r_name"<?php echo $company->RowAttributes() ?>>
 157		<td class="ewTableHeader"><?php echo $company->name->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
 158		<td<?php echo $company->name->CellAttributes() ?>><span id="el_name">
 159<input type="text" name="x_name" id="x_name" size="30" maxlength="60" value="<?php echo $company->name->EditValue ?>"<?php echo $company->name->EditAttributes() ?>>
 160</span><?php echo $company->name->CustomMsg ?></td>
 161	</tr>
 162<?php } ?>
 163<?php if ($company->address->Visible) { // address ?>
 164	<tr id="r_address"<?php echo $company->RowAttributes() ?>>
 165		<td class="ewTableHeader"><?php echo $company->address->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 166		<td<?php echo $company->address->CellAttributes() ?>><span id="el_address">
 167<textarea name="x_address" id="x_address" cols="35" rows="4"<?php echo $company->address->EditAttributes() ?>><?php echo $company->address->EditValue ?></textarea>
 168</span><?php echo $company->address->CustomMsg ?></td>
 169	</tr>
 170<?php } ?>
 171<?php if ($company->city->Visible) { // city ?>
 172	<tr id="r_city"<?php echo $company->RowAttributes() ?>>
 173		<td class="ewTableHeader"><?php echo $company->city->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 174		<td<?php echo $company->city->CellAttributes() ?>><span id="el_city">
 175<select id="x_city" name="x_city"<?php echo $company->city->EditAttributes() ?>>
 176<?php
 177if (is_array($company->city->EditValue)) {
 178	$arwrk = $company->city->EditValue;
 179	$rowswrk = count($arwrk);
 180	$emptywrk = TRUE;
 181	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
 182		$selwrk = (strval($company->city->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
 183		if ($selwrk <> "") $emptywrk = FALSE;
 184?>
 185<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
 186<?php echo $arwrk[$rowcntwrk][1] ?>
 187</option>
 188<?php
 189	}
 190}
 191?>
 192</select>
 193</span><?php echo $company->city->CustomMsg ?></td>
 194	</tr>
 195<?php } ?>
 196<?php if ($company->province->Visible) { // province ?>
 197	<tr id="r_province"<?php echo $company->RowAttributes() ?>>
 198		<td class="ewTableHeader"><?php echo $company->province->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 199		<td<?php echo $company->province->CellAttributes() ?>><span id="el_province">
 200<select id="x_province" name="x_province"<?php echo $company->province->EditAttributes() ?>>
 201<?php
 202if (is_array($company->province->EditValue)) {
 203	$arwrk = $company->province->EditValue;
 204	$rowswrk = count($arwrk);
 205	$emptywrk = TRUE;
 206	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
 207		$selwrk = (strval($company->province->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
 208		if ($selwrk <> "") $emptywrk = FALSE;
 209?>
 210<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
 211<?php echo $arwrk[$rowcntwrk][1] ?>
 212</option>
 213<?php
 214	}
 215}
 216?>
 217</select>
 218</span><?php echo $company->province->CustomMsg ?></td>
 219	</tr>
 220<?php } ?>
 221<?php if ($company->telno->Visible) { // telno ?>
 222	<tr id="r_telno"<?php echo $company->RowAttributes() ?>>
 223		<td class="ewTableHeader"><?php echo $company->telno->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 224		<td<?php echo $company->telno->CellAttributes() ?>><span id="el_telno">
 225<input type="text" name="x_telno" id="x_telno" size="30" maxlength="20" value="<?php echo $company->telno->EditValue ?>"<?php echo $company->telno->EditAttributes() ?>>
 226</span><?php echo $company->telno->CustomMsg ?></td>
 227	</tr>
 228<?php } ?>
 229<?php if ($company->mobileno->Visible) { // mobileno ?>
 230	<tr id="r_mobileno"<?php echo $company->RowAttributes() ?>>
 231		<td class="ewTableHeader"><?php echo $company->mobileno->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 232		<td<?php echo $company->mobileno->CellAttributes() ?>><span id="el_mobileno">
 233<input type="text" name="x_mobileno" id="x_mobileno" size="30" maxlength="20" value="<?php echo $company->mobileno->EditValue ?>"<?php echo $company->mobileno->EditAttributes() ?>>
 234</span><?php echo $company->mobileno->CustomMsg ?></td>
 235	</tr>
 236<?php } ?>
 237<?php if ($company->faxno->Visible) { // faxno ?>
 238	<tr id="r_faxno"<?php echo $company->RowAttributes() ?>>
 239		<td class="ewTableHeader"><?php echo $company->faxno->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 240		<td<?php echo $company->faxno->CellAttributes() ?>><span id="el_faxno">
 241<input type="text" name="x_faxno" id="x_faxno" size="30" maxlength="20" value="<?php echo $company->faxno->EditValue ?>"<?php echo $company->faxno->EditAttributes() ?>>
 242</span><?php echo $company->faxno->CustomMsg ?></td>
 243	</tr>
 244<?php } ?>
 245<?php if ($company->zemail->Visible) { // email ?>
 246	<tr id="r_zemail"<?php echo $company->RowAttributes() ?>>
 247		<td class="ewTableHeader"><?php echo $company->zemail->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 248		<td<?php echo $company->zemail->CellAttributes() ?>><span id="el_zemail">
 249<input type="text" name="x_zemail" id="x_zemail" size="30" maxlength="60" value="<?php echo $company->zemail->EditValue ?>"<?php echo $company->zemail->EditAttributes() ?>>
 250</span><?php echo $company->zemail->CustomMsg ?></td>
 251	</tr>
 252<?php } ?>
 253<?php if ($company->contact->Visible) { // contact ?>
 254	<tr id="r_contact"<?php echo $company->RowAttributes() ?>>
 255		<td class="ewTableHeader"><?php echo $company->contact->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 256		<td<?php echo $company->contact->CellAttributes() ?>><span id="el_contact">
 257<input type="text" name="x_contact" id="x_contact" size="30" maxlength="60" value="<?php echo $company->contact->EditValue ?>"<?php echo $company->contact->EditAttributes() ?>>
 258</span><?php echo $company->contact->CustomMsg ?></td>
 259	</tr>
 260<?php } ?>
 261</table>
 262</div>
 263</td></tr></table>
 264<p>
 265<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("EditBtn")) ?>">
 266</form>
 267<?php
 268$company_edit->ShowPageFooter();
 269if (EW_DEBUG_ENABLED)
 270	echo ew_DebugMsg();
 271?>
 272<script language="JavaScript" type="text/javascript">
 273<!--
 274
 275// Write your table-specific startup script here
 276// document.write("page loaded");
 277//-->
 278
 279</script>
 280<?php include_once "footer.php" ?>
 281<?php
 282$company_edit->Page_Terminate();
 283?>
 284<?php
 285
 286//
 287// Page class
 288//
 289class ccompany_edit {
 290
 291	// Page ID
 292	var $PageID = 'edit';
 293
 294	// Table name
 295	var $TableName = 'company';
 296
 297	// Page object name
 298	var $PageObjName = 'company_edit';
 299
 300	// Page name
 301	function PageName() {
 302		return ew_CurrentPage();
 303	}
 304
 305	// Page URL
 306	function PageUrl() {
 307		$PageUrl = ew_CurrentPage() . "?";
 308		global $company;
 309		if ($company->UseTokenInUrl) $PageUrl .= "t=" . $company->TableVar . "&"; // Add page token
 310		return $PageUrl;
 311	}
 312
 313	// Message
 314	function getMessage() {
 315		return @$_SESSION[EW_SESSION_MESSAGE];
 316	}
 317
 318	function setMessage($v) {
 319		ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v);
 320	}
 321
 322	function getFailureMessage() {
 323		return @$_SESSION[EW_SESSION_FAILURE_MESSAGE];
 324	}
 325
 326	function setFailureMessage($v) {
 327		ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v);
 328	}
 329
 330	function getSuccessMessage() {
 331		return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE];
 332	}
 333
 334	function setSuccessMessage($v) {
 335		ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v);
 336	}
 337
 338	// Show message
 339	function ShowMessage() {
 340		$sMessage = $this->getMessage();
 341		$this->Message_Showing($sMessage, "");
 342		if ($sMessage <> "") { // Message in Session, display
 343			echo "<p class=\"ewMessage\">" . $sMessage . "</p>";
 344			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
 345		}
 346
 347		// Success message
 348		$sSuccessMessage = $this->getSuccessMessage();
 349		$this->Message_Showing($sSuccessMessage, "success");
 350		if ($sSuccessMessage <> "") { // Message in Session, display
 351			echo "<p class=\"ewSuccessMessage\">" . $sSuccessMessage . "</p>";
 352			$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
 353		}
 354
 355		// Failure message
 356		$sErrorMessage = $this->getFailureMessage();
 357		$this->Message_Showing($sErrorMessage, "failure");
 358		if ($sErrorMessage <> "") { // Message in Session, display
 359			echo "<p class=\"ewErrorMessage\">" . $sErrorMessage . "</p>";
 360			$_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
 361		}
 362	}
 363	var $PageHeader;
 364	var $PageFooter;
 365
 366	// Show Page Header
 367	function ShowPageHeader() {
 368		$sHeader = $this->PageHeader;
 369		$this->Page_DataRendering($sHeader);
 370		if ($sHeader <> "") { // Header exists, display
 371			echo "<p class=\"phpmaker\">" . $sHeader . "</p>";
 372		}
 373	}
 374
 375	// Show Page Footer
 376	function ShowPageFooter() {
 377		$sFooter = $this->PageFooter;
 378		$this->Page_DataRendered($sFooter);
 379		if ($sFooter <> "") { // Fotoer exists, display
 380			echo "<p class=\"phpmaker\">" . $sFooter . "</p>";
 381		}
 382	}
 383
 384	// Validate page request
 385	function IsPageRequest() {
 386		global $objForm, $company;
 387		if ($company->UseTokenInUrl) {
 388			if ($objForm)
 389				return ($company->TableVar == $objForm->GetValue("t"));
 390			if (@$_GET["t"] <> "")
 391				return ($company->TableVar == $_GET["t"]);
 392		} else {
 393			return TRUE;
 394		}
 395	}
 396
 397	//
 398	// Page class constructor
 399	//
 400	function ccompany_edit() {
 401		global $conn, $Language;
 402
 403		// Language object
 404		if (!isset($Language)) $Language = new cLanguage();
 405
 406		// Table object (company)
 407		if (!isset($GLOBALS["company"])) {
 408			$GLOBALS["company"] = new ccompany();
 409			$GLOBALS["Table"] =& $GLOBALS["company"];
 410		}
 411
 412		// Table object (user)
 413		if (!isset($GLOBALS['user'])) $GLOBALS['user'] = new cuser();
 414
 415		// Page ID
 416		if (!defined("EW_PAGE_ID"))
 417			define("EW_PAGE_ID", 'edit', TRUE);
 418
 419		// Table name (for backward compatibility)
 420		if (!defined("EW_TABLE_NAME"))
 421			define("EW_TABLE_NAME", 'company', TRUE);
 422
 423		// Start timer
 424		if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer();
 425
 426		// Open connection
 427		if (!isset($conn)) $conn = ew_Connect();
 428	}
 429
 430	// 
 431	//  Page_Init
 432	//
 433	function Page_Init() {
 434		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
 435		global $company;
 436
 437		// Security
 438		$Security = new cAdvancedSecurity();
 439		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
 440		if (!$Security->IsLoggedIn()) {
 441			$Security->SaveLastUrl();
 442			$this->Page_Terminate("login.php");
 443		}
 444		$Security->TablePermission_Loading();
 445		$Security->LoadCurrentUserLevel($this->TableName);
 446		$Security->TablePermission_Loaded();
 447		if (!$Security->IsLoggedIn()) {
 448			$Security->SaveLastUrl();
 449			$this->Page_Terminate("login.php");
 450		}
 451		if (!$Security->CanEdit()) {
 452			$Security->SaveLastUrl();
 453			$this->Page_Terminate("companylist.php");
 454		}
 455
 456		// Create form object
 457		$objForm = new cFormObj();
 458
 459		// Global Page Loading event (in userfn*.php)
 460		Page_Loading();
 461
 462		// Page Load event
 463		$this->Page_Load();
 464	}
 465
 466	//
 467	// Page_Terminate
 468	//
 469	function Page_Terminate($url = "") {
 470		global $conn;
 471
 472		// Page Unload event
 473		$this->Page_Unload();
 474
 475		// Global Page Unloaded event (in userfn*.php)
 476		Page_Unloaded();
 477		$this->Page_Redirecting($url);
 478
 479		 // Close connection
 480		$conn->Close();
 481
 482		// Go to URL if specified
 483		if ($url <> "") {
 484			if (!EW_DEBUG_ENABLED && ob_get_length())
 485				ob_end_clean();
 486			header("Location: " . $url);
 487		}
 488		exit();
 489	}
 490	var $DbMasterFilter;
 491	var $DbDetailFilter;
 492
 493	// 
 494	// Page main
 495	//
 496	function Page_Main() {
 497		global $objForm, $Language, $gsFormError, $company;
 498
 499		// Load key from QueryString
 500		if (@$_GET["id"] <> "")
 501			$company->id->setQueryStringValue($_GET["id"]);
 502		if (@$_POST["a_edit"] <> "") {
 503			$company->CurrentAction = $_POST["a_edit"]; // Get action code
 504			$this->LoadFormValues(); // Get form values
 505
 506			// Validate form
 507			if (!$this->ValidateForm()) {
 508				$company->CurrentAction = ""; // Form error, reset action
 509				$this->setFailureMessage($gsFormError);
 510				$company->EventCancelled = TRUE; // Event cancelled
 511				$this->RestoreFormValues();
 512			}
 513		} else {
 514			$company->CurrentAction = "I"; // Default action is display
 515		}
 516
 517		// Check if valid key
 518		if ($company->id->CurrentValue == "")
 519			$this->Page_Terminate("companylist.php"); // Invalid key, return to list
 520		switch ($company->CurrentAction) {
 521			case "I": // Get a record to display
 522				if (!$this->LoadRow()) { // Load record based on key
 523					$this->setFailureMessage($Language->Phrase("NoRecord")); // No record found
 524					$this->Page_Terminate("companylist.php"); // No matching record, return to list
 525				}
 526				break;
 527			Case "U": // Update
 528				$company->SendEmail = TRUE; // Send email on update success
 529				if ($this->EditRow()) { // Update record based on key
 530					$this->setSuccessMessage($Language->Phrase("UpdateSuccess")); // Update success
 531					$sReturnUrl = $company->getReturnUrl();
 532					if (ew_GetPageName($sReturnUrl) == "companyview.php")
 533						$sReturnUrl = $company->ViewUrl(); // View paging, return to View page directly
 534					$this->Page_Terminate($sReturnUrl); // Return to caller
 535				} else {
 536					$company->EventCancelled = TRUE; // Event cancelled
 537					$this->RestoreFormValues(); // Restore form values if update failed
 538				}
 539		}
 540
 541		// Render the record
 542		$company->RowType = EW_ROWTYPE_EDIT; // Render as Edit
 543		$company->ResetAttrs();
 544		$this->RenderRow();
 545	}
 546
 547	// Get upload files
 548	function GetUploadFiles() {
 549		global $objForm, $company;
 550
 551		// Get upload data
 552		$index = $objForm->Index; // Save form index
 553		$objForm->Index = 0;
 554		$confirmPage = (strval($objForm->GetValue("a_confirm")) <> "");
 555		$objForm->Index = $index; // Restore form index
 556	}
 557
 558	// Load form values
 559	function LoadFormValues() {
 560
 561		// Load from form
 562		global $objForm, $company;
 563		if (!$company->id->FldIsDetailKey)
 564			$company->id->setFormValue($objForm->GetValue("x_id"));
 565		if (!$company->name->FldIsDetailKey) {
 566			$company->name->setFormValue($objForm->GetValue("x_name"));
 567		}
 568		if (!$company->address->FldIsDetailKey) {
 569			$company->address->setFormValue($objForm->GetValue("x_address"));
 570		}
 571		if (!$company->city->FldIsDetailKey) {
 572			$company->city->setFormValue($objForm->GetValue("x_city"));
 573		}
 574		if (!$company->province->FldIsDetailKey) {
 575			$company->province->setFormValue($objForm->GetValue("x_province"));
 576		}
 577		if (!$company->telno->FldIsDetailKey) {
 578			$company->telno->setFormValue($objForm->GetValue("x_telno"));
 579		}
 580		if (!$company->mobileno->FldIsDetailKey) {
 581			$company->mobileno->setFormValue($objForm->GetValue("x_mobileno"));
 582		}
 583		if (!$company->faxno->FldIsDetailKey) {
 584			$company->faxno->setFormValue($objForm->GetValue("x_faxno"));
 585		}
 586		if (!$company->zemail->FldIsDetailKey) {
 587			$company->zemail->setFormValue($objForm->GetValue("x_zemail"));
 588		}
 589		if (!$company->contact->FldIsDetailKey) {
 590			$company->contact->setFormValue($objForm->GetValue("x_contact"));
 591		}
 592	}
 593
 594	// Restore form values
 595	function RestoreFormValues() {
 596		global $objForm, $company;
 597		$this->LoadRow();
 598		$company->id->CurrentValue = $company->id->FormValue;
 599		$company->name->CurrentValue = $company->name->FormValue;
 600		$company->address->CurrentValue = $company->address->FormValue;
 601		$company->city->CurrentValue = $company->city->FormValue;
 602		$company->province->CurrentValue = $company->province->FormValue;
 603		$company->telno->CurrentValue = $company->telno->FormValue;
 604		$company->mobileno->CurrentValue = $company->mobileno->FormValue;
 605		$company->faxno->CurrentValue = $company->faxno->FormValue;
 606		$company->zemail->CurrentValue = $company->zemail->FormValue;
 607		$company->contact->CurrentValue = $company->contact->FormValue;
 608	}
 609
 610	// Load row based on key values
 611	function LoadRow() {
 612		global $conn, $Security, $company;
 613		$sFilter = $company->KeyFilter();
 614
 615		// Call Row Selecting event
 616		$company->Row_Selecting($sFilter);
 617
 618		// Load SQL based on filter
 619		$company->CurrentFilter = $sFilter;
 620		$sSql = $company->SQL();
 621		$res = FALSE;
 622		$rs = ew_LoadRecordset($sSql);
 623		if ($rs && !$rs->EOF) {
 624			$res = TRUE;
 625			$this->LoadRowValues($rs); // Load row values
 626			$rs->Close();
 627		}
 628		return $res;
 629	}
 630
 631	// Load row values from recordset
 632	function LoadRowValues(&$rs) {
 633		global $conn, $company;
 634		if (!$rs || $rs->EOF) return;
 635
 636		// Call Row Selected event
 637		$row =& $rs->fields;
 638		$company->Row_Selected($row);
 639		$company->id->setDbValue($rs->fields('id'));
 640		$company->name->setDbValue($rs->fields('name'));
 641		$company->address->setDbValue($rs->fields('address'));
 642		$company->city->setDbValue($rs->fields('city'));
 643		$company->province->setDbValue($rs->fields('province'));
 644		$company->telno->setDbValue($rs->fields('telno'));
 645		$company->mobileno->setDbValue($rs->fields('mobileno'));
 646		$company->faxno->setDbValue($rs->fields('faxno'));
 647		$company->zemail->setDbValue($rs->fields('email'));
 648		$company->contact->setDbValue($rs->fields('contact'));
 649		$company->zuserid->setDbValue($rs->fields('userid'));
 650		$company->timestamp->setDbValue($rs->fields('timestamp'));
 651	}
 652
 653	// Render row values based on field settings
 654	function RenderRow() {
 655		global $conn, $Security, $Language, $company;
 656
 657		// Initialize URLs
 658		// Call Row_Rendering event
 659
 660		$company->Row_Rendering();
 661
 662		// Common render codes for all row types
 663		// id
 664		// name
 665		// address
 666		// city
 667		// province
 668		// telno
 669		// mobileno
 670		// faxno
 671		// email
 672		// contact
 673		// userid
 674		// timestamp
 675
 676		if ($company->RowType == EW_ROWTYPE_VIEW) { // View row
 677
 678			// id
 679			$company->id->ViewValue = $company->id->CurrentValue;
 680			$company->id->ViewCustomAttributes = "";
 681
 682			// name
 683			$company->name->ViewValue = $company->name->CurrentValue;
 684			$company->name->ViewCustomAttributes = "";
 685
 686			// address
 687			$company->address->ViewValue = $company->address->CurrentValue;
 688			$company->address->ViewCustomAttributes = "";
 689
 690			// city
 691			if (strval($company->city->CurrentValue) <> "") {
 692				$sFilterWrk = "`id` = " . ew_AdjustSql($company->city->CurrentValue) . "";
 693			$sSqlWrk = "SELECT `city` FROM `city`";
 694			$sWhereWrk = "";
 695			if ($sFilterWrk <> "") {
 696				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
 697				$sWhereWrk .= "(" . $sFilterWrk . ")";
 698			}
 699			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
 700				$rswrk = $conn->Execute($sSqlWrk);
 701				if ($rswrk && !$rswrk->EOF) { // Lookup values found
 702					$company->city->ViewValue = $rswrk->fields('city');
 703					$rswrk->Close();
 704				} else {
 705					$company->city->ViewValue = $company->city->CurrentValue;
 706				}
 707			} else {
 708				$company->city->ViewValue = NULL;
 709			}
 710			$company->city->ViewCustomAttributes = "";
 711
 712			// province
 713			if (strval($company->province->CurrentValue) <> "") {
 714				$sFilterWrk = "`id` = " . ew_AdjustSql($company->province->CurrentValue) . "";
 715			$sSqlWrk = "SELECT `province` FROM `province`";
 716			$sWhereWrk = "";
 717			if ($sFilterWrk <> "") {
 718				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
 719				$sWhereWrk .= "(" . $sFilterWrk . ")";
 720			}
 721			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
 722				$rswrk = $conn->Execute($sSqlWrk);
 723				if ($rswrk && !$rswrk->EOF) { // Lookup values found
 724					$company->province->ViewValue = $rswrk->fields('province');
 725					$rswrk->Close();
 726				} else {
 727					$company->province->ViewValue = $company->province->CurrentValue;
 728				}
 729			} else {
 730				$company->province->ViewValue = NULL;
 731			}
 732			$company->province->ViewCustomAttributes = "";
 733
 734			// telno
 735			$company->telno->ViewValue = $company->telno->CurrentValue;
 736			$company->telno->ViewCustomAttributes = "";
 737
 738			// mobileno
 739			$company->mobileno->ViewValue = $company->mobileno->CurrentValue;
 740			$company->mobileno->ViewCustomAttributes = "";
 741
 742			// faxno
 743			$company->faxno->ViewValue = $company->faxno->CurrentValue;
 744			$company->faxno->ViewCustomAttributes = "";
 745
 746			// email
 747			$company->zemail->ViewValue = $company->zemail->CurrentValue;
 748			$company->zemail->ViewCustomAttributes = "";
 749
 750			// contact
 751			$company->contact->ViewValue = $company->contact->CurrentValue;
 752			$company->contact->ViewCustomAttributes = "";
 753
 754			// userid
 755			$company->zuserid->ViewValue = $company->zuserid->CurrentValue;
 756			$company->zuserid->ViewCustomAttributes = "";
 757
 758			// timestamp
 759			$company->timestamp->ViewValue = $company->timestamp->CurrentValue;
 760			$company->timestamp->ViewValue = ew_FormatDateTime($company->timestamp->ViewValue, 9);
 761			$company->timestamp->ViewCustomAttributes = "";
 762
 763			// id
 764			$company->id->LinkCustomAttributes = "";
 765			$company->id->HrefValue = "";
 766			$company->id->TooltipValue = "";
 767
 768			// name
 769			$company->name->LinkCustomAttributes = "";
 770			$company->name->HrefValue = "";
 771			$company->name->TooltipValue = "";
 772
 773			// address
 774			$company->address->LinkCustomAttributes = "";
 775			$company->address->HrefValue = "";
 776			$company->address->TooltipValue = "";
 777
 778			// city
 779			$company->city->LinkCustomAttributes = "";
 780			$company->city->HrefValue = "";
 781			$company->city->TooltipValue = "";
 782
 783			// province
 784			$company->province->LinkCustomAttributes = "";
 785			$company->province->HrefValue = "";
 786			$company->province->TooltipValue = "";
 787
 788			// telno
 789			$company->telno->LinkCustomAttributes = "";
 790			$company->telno->HrefValue = "";
 791			$company->telno->TooltipValue = "";
 792
 793			// mobileno
 794			$company->mobileno->LinkCustomAttributes = "";
 795			$company->mobileno->HrefValue = "";
 796			$company->mobileno->TooltipValue = "";
 797
 798			// faxno
 799			$company->faxno->LinkCustomAttributes = "";
 800			$company->faxno->HrefValue = "";
 801			$company->faxno->TooltipValue = "";
 802
 803			// email
 804			$company->zemail->LinkCustomAttributes = "";
 805			$company->zemail->HrefValue = "";
 806			$company->zemail->TooltipValue = "";
 807
 808			// contact
 809			$company->contact->LinkCustomAttributes = "";
 810			$company->contact->HrefValue = "";
 811			$company->contact->TooltipValue = "";
 812		} elseif ($company->RowType == EW_ROWTYPE_EDIT) { // Edit row
 813
 814			// id
 815			$company->id->EditCustomAttributes = "";
 816			$company->id->EditValue = $company->id->CurrentValue;
 817			$company->id->ViewCustomAttributes = "";
 818
 819			// name
 820			$company->name->EditCustomAttributes = "";
 821			$company->name->EditValue = ew_HtmlEncode($company->name->CurrentValue);
 822
 823			// address
 824			$company->address->EditCustomAttributes = "";
 825			$company->address->EditValue = ew_HtmlEncode($company->address->CurrentValue);
 826
 827			// city
 828			$company->city->EditCustomAttributes = "";
 829				$sFilterWrk = "";
 830			$sSqlWrk = "SELECT `id`, `city` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld` FROM `city`";
 831			$sWhereWrk = "";
 832			if ($sFilterWrk <> "") {
 833				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
 834				$sWhereWrk .= "(" . $sFilterWrk . ")";
 835			}
 836			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
 837			$rswrk = $conn->Execute($sSqlWrk);
 838			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
 839			if ($rswrk) $rswrk->Close();
 840			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
 841			$company->city->EditValue = $arwrk;
 842
 843			// province
 844			$company->province->EditCustomAttributes = "";
 845				$sFilterWrk = "";
 846			$sSqlWrk = "SELECT `id`, `province` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld` FROM `province`";
 847			$sWhereWrk = "";
 848			if ($sFilterWrk <> "") {
 849				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
 850				$sWhereWrk .= "(" . $sFilterWrk . ")";
 851			}
 852			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
 853			$rswrk = $conn->Execute($sSqlWrk);
 854			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
 855			if ($rswrk) $rswrk->Close();
 856			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
 857			$company->province->EditValue = $arwrk;
 858
 859			// telno
 860			$company->telno->EditCustomAttributes = "";
 861			$company->telno->EditValue = ew_HtmlEncode($company->telno->CurrentValue);
 862
 863			// mobileno
 864			$company->mobileno->EditCustomAttributes = "";
 865			$company->mobileno->EditValue = ew_HtmlEncode($company->mobileno->CurrentValue);
 866
 867			// faxno
 868			$company->faxno->EditCustomAttributes = "";
 869			$company->faxno->EditValue = ew_HtmlEncode($company->faxno->CurrentValue);
 870
 871			// email
 872			$company->zemail->EditCustomAttributes = "";
 873			$company->zemail->EditValue = ew_HtmlEncode($company->zemail->CurrentValue);
 874
 875			// contact
 876			$company->contact->EditCustomAttributes = "";
 877			$company->contact->EditValue = ew_HtmlEncode($company->contact->CurrentValue);
 878
 879			// Edit refer script
 880			// id
 881
 882			$company->id->HrefValue = "";
 883
 884			// name
 885			$company->name->HrefValue = "";
 886
 887			// address
 888			$company->address->HrefValue = "";
 889
 890			// city
 891			$company->city->HrefValue = "";
 892
 893			// province
 894			$company->province->HrefValue = "";
 895
 896			// telno
 897			$company->telno->HrefValue = "";
 898
 899			// mobileno
 900			$company->mobileno->HrefValue = "";
 901
 902			// faxno
 903			$company->faxno->HrefValue = "";
 904
 905			// email
 906			$company->zemail->HrefValue = "";
 907
 908			// contact
 909			$company->contact->HrefValue = "";
 910		}
 911		if ($company->RowType == EW_ROWTYPE_ADD ||
 912			$company->RowType == EW_ROWTYPE_EDIT ||
 913			$company->RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
 914			$company->SetupFieldTitles();
 915		}
 916
 917		// Call Row Rendered event
 918		if ($company->RowType <> EW_ROWTYPE_AGGREGATEINIT)
 919			$company->Row_Rendered();
 920	}
 921
 922	// Validate form
 923	function ValidateForm() {
 924		global $Language, $gsFormError, $company;
 925
 926		// Initialize form error message
 927		$gsFormError = "";
 928
 929		// Check if validation required
 930		if (!EW_SERVER_VALIDATE)
 931			return ($gsFormError == "");
 932		if (!ew_CheckInteger($company->id->FormValue)) {
 933			ew_AddMessage($gsFormError, $company->id->FldErrMsg());
 934		}
 935		if (!is_null($company->name->FormValue) && $company->name->FormValue == "") {
 936			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $company->name->FldCaption());
 937		}
 938		if (!is_null($company->address->FormValue) && $company->address->FormValue == "") {
 939			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $company->address->FldCaption());
 940		}
 941		if (!is_null($company->city->FormValue) && $company->city->FormValue == "") {
 942			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $company->city->FldCaption());
 943		}
 944		if (!is_null($company->province->FormValue) && $company->province->FormValue == "") {
 945			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $company->province->FldCaption());
 946		}
 947		if (!is_null($company->telno->FormValue) && $company->telno->FormValue == "") {
 948			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $company->telno->FldCaption());
 949		}
 950		if (!is_null($company->mobileno->FormValue) && $company->mobileno->FormValue == "") {
 951			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $company->mobileno->FldCaption());
 952		}
 953		if (!is_null($company->faxno->FormValue) && $company->faxno->FormValue == "") {
 954			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $company->faxno->FldCaption());
 955		}
 956		if (!is_null($company->zemail->FormValue) && $company->zemail->FormValue == "") {
 957			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $company->zemail->FldCaption());
 958		}
 959		if (!is_null($company->contact->FormValue) && $company->contact->FormValue == "") {
 960			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $company->contact->FldCaption());
 961		}
 962
 963		// Return validate result
 964		$ValidateForm = ($gsFormError == "");
 965
 966		// Call Form_CustomValidate event
 967		$sFormCustomError = "";
 968		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
 969		if ($sFormCustomError <> "") {
 970			ew_AddMessage($gsFormError, $sFormCustomError);
 971		}
 972		return $ValidateForm;
 973	}
 974
 975	// Update record based on key values
 976	function EditRow() {
 977		global $conn, $Security, $Language, $company;
 978		$sFilter = $company->KeyFilter();
 979		$company->CurrentFilter = $sFilter;
 980		$sSql = $company->SQL();
 981		$conn->raiseErrorFn = 'ew_ErrorFn';
 982		$rs = $conn->Execute($sSql);
 983		$conn->raiseErrorFn = '';
 984		if ($rs === FALSE)
 985			return FALSE;
 986		if ($rs->EOF) {
 987			$EditRow = FALSE; // Update Failed
 988		} else {
 989
 990			// Save old values
 991			$rsold =& $rs->fields;
 992			$rsnew = array();
 993
 994			// name
 995			$company->name->SetDbValueDef($rsnew, $company->name->CurrentValue, "", $company->name->ReadOnly);
 996
 997			// address
 998			$company->address->SetDbValueDef($rsnew, $company->address->CurrentValue, "", $company->address->ReadOnly);
 999
1000			// city
1001			$company->city->SetDbValueDef($rsnew, $company->city->CurrentValue, 0, $company->city->ReadOnly);
1002
1003			// province
1004			$company->province->SetDbValueDef($rsnew, $company->province->CurrentValue, 0, $company->province->ReadOnly);
1005
1006			// telno
1007			$company->telno->SetDbValueDef($rsnew, $company->telno->CurrentValue, "", $company->telno->ReadOnly);
1008
1009			// mobileno
1010			$company->mobileno->SetDbValueDef($rsnew, $company->mobileno->CurrentValue, "", $company->mobileno->ReadOnly);
1011
1012			// faxno
1013			$company->faxno->SetDbValueDef($rsnew, $company->faxno->CurrentValue, "", $company->faxno->ReadOnly);
1014
1015			// email
1016			$company->zemail->SetDbValueDef($rsnew, $company->zemail->CurrentValue, "", $company->zemail->ReadOnly);
1017
1018			// contact
1019			$company->contact->SetDbValueDef($rsnew, $company->contact->CurrentValue, "", $company->contact->ReadOnly);
1020
1021			// Call Row Updating event
1022			$bUpdateRow = $company->Row_Updating($rsold, $rsnew);
1023			if ($bUpdateRow) {
1024				$conn->raiseErrorFn = 'ew_ErrorFn';
1025				if (count($rsnew) > 0)
1026					$EditRow = $conn->Execute($company->UpdateSQL($rsnew));
1027				else
1028					$EditRow = TRUE; // No field to update
1029				$conn->raiseErrorFn = '';
1030			} else {
1031				if ($company->CancelMessage <> "") {
1032					$this->setFailureMessage($company->CancelMessage);
1033					$company->CancelMessage = "";
1034				} else {
1035					$this->setFailureMessage($Language->Phrase("UpdateCancelled"));
1036				}
1037				$EditRow = FALSE;
1038			}
1039		}
1040
1041		// Call Row_Updated event
1042		if ($EditRow)
1043			$company->Row_Updated($rsold, $rsnew);
1044					if ($EditRow) {
1045			$this->WriteAuditTrailOnEdit($rsold, $rsnew);
1046		}
1047		$rs->Close();
1048		return $EditRow;
1049	}
1050// Write Audit Trail start/end for grid update
1051	function WriteAuditTrailDummy($typ) {
1052		$table = 'company';
1053	  $usr = CurrentUserName();
1054		ew_WriteAuditTrail("log", ew_StdCurrentDateTime(), ew_ScriptName(), $usr, $typ, $table, "", "", "", "");
1055	}
1056
1057	// Write Audit Trail (edit page)
1058	function WriteAuditTrailOnEdit(&$rsold, &$rsnew) {
1059		global $company;
1060		$table = 'company';
1061
1062		// Get key value
1063		$key = "";
1064		if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
1065		$key .= $rsold['id'];
1066
1067		// Write Audit Trail
1068		$dt = ew_StdCurrentDateTime();
1069		$id = ew_ScriptName();
1070	  $usr = CurrentUserName();
1071		foreach (array_keys($rsnew) as $fldname) {
1072			if ($company->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore BLOB fields
1073				if ($company->fields[$fldname]->FldDataType == EW_DATATYPE_DATE) { // DateTime field
1074					$modified = (ew_FormatDateTime($rsold[$fldname], 0) <> ew_FormatDateTime($rsnew[$fldname], 0));
1075				} else {
1076					$modified = !ew_CompareValue($rsold[$fldname], $rsnew[$fldname]);
1077				}
1078				if ($modified) {
1079					if ($company->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // Memo field
1080						if (EW_AUDIT_TRAIL_TO_DATABASE) {
1081							$oldvalue = $rsold[$fldname];
1082							$newvalue = $rsnew[$fldname];
1083						} else {
1084							$oldvalue = "[MEMO]";
1085							$newvalue = "[MEMO]";
1086						}
1087					} elseif ($company->fields[$fldname]->FldDataType == EW_DATATYPE_XML) { // XML field
1088						$oldvalue = "[XML]";
1089						$newvalue = "[XML]";
1090					} else {
1091						$oldvalue = $rsold[$fldname];
1092						$newvalue = $rsnew[$fldname];
1093					}
1094					ew_WriteAuditTrail("log", $dt, $id, $usr, "U", $table, $fldname, $key, $oldvalue, $newvalue);
1095				}
1096			}
1097		}
1098	}
1099
1100	// Page Load event
1101	function Page_Load() {
1102
1103		//echo "Page Load";
1104	}
1105
1106	// Page Unload event
1107	function Page_Unload() {
1108
1109		//echo "Page Unload";
1110	}
1111
1112	// Page Redirecting event
1113	function Page_Redirecting(&$url) {
1114
1115		// Example:
1116		//$url = "your URL";
1117
1118	}
1119
1120	// Message Showing event
1121	// $type = ''|'success'|'failure'
1122	function Message_Showing(&$msg, $type) {
1123
1124		// Example:
1125		//if ($type == 'success') $msg = "your success message";
1126
1127	}
1128
1129	// Page Data Rendering event
1130	function Page_DataRendering(&$header) {
1131
1132		// Example:
1133		//$header = "your header";
1134
1135	}
1136
1137	// Page Data Rendered event
1138	function Page_DataRendered(&$footer) {
1139
1140		// Example:
1141		//$footer = "your footer";
1142
1143	}
1144
1145	// Form Custom Validate event
1146	function Form_CustomValidate(&$CustomError) {
1147
1148		// Return error message in CustomError
1149		return TRUE;
1150	}
1151}
1152?>