PageRenderTime 55ms CodeModel.GetById 39ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/companyadd.php

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