PageRenderTime 33ms CodeModel.GetById 19ms app.highlight 7ms RepoModel.GetById 0ms app.codeStats 1ms

/provinceedit.php

https://bitbucket.org/joemarmatulac/ebutton
PHP | 1159 lines | 778 code | 162 blank | 219 comment | 170 complexity | 3bf7b85f401c61bc7c1f46b452b2c6a3 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 "provinceinfo.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$province_edit = new cprovince_edit();
  16$Page =& $province_edit;
  17
  18// Page init
  19$province_edit->Page_Init();
  20
  21// Page main
  22$province_edit->Page_Main();
  23?>
  24<?php include_once "header.php" ?>
  25<script type="text/javascript">
  26<!--
  27
  28// Create page object
  29var province_edit = new ew_Page("province_edit");
  30
  31// page properties
  32province_edit.PageID = "edit"; // page ID
  33province_edit.FormID = "fprovinceedit"; // form ID
  34var EW_PAGE_ID = province_edit.PageID; // for backward compatibility
  35
  36// extend page with ValidateForm function
  37province_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($province->id->FldErrMsg()) ?>");
  50		elm = fobj.elements["x" + infix + "_province_1"];
  51		if (elm && !ew_HasValue(elm))
  52			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($province->province_1->FldCaption()) ?>");
  53		/*elm = fobj.elements["x" + infix + "_provcontact"];
  54		if (elm && !ew_HasValue(elm))
  55			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($province->provcontact->FldCaption()) ?>");
  56		elm = fobj.elements["x" + infix + "_provhalladdress"];
  57		if (elm && !ew_HasValue(elm))
  58			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($province->provhalladdress->FldCaption()) ?>");
  59		elm = fobj.elements["x" + infix + "_provtelno"];
  60		if (elm && !ew_HasValue(elm))
  61			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($province->provtelno->FldCaption()) ?>");
  62		elm = fobj.elements["x" + infix + "_provlatitude"];
  63		if (elm && !ew_HasValue(elm))
  64			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($province->provlatitude->FldCaption()) ?>");
  65		elm = fobj.elements["x" + infix + "_provlatitude"];
  66		if (elm && !ew_CheckNumber(elm.value))
  67			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($province->provlatitude->FldErrMsg()) ?>");
  68		elm = fobj.elements["x" + infix + "_provlongitude"];
  69		if (elm && !ew_HasValue(elm))
  70			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($province->provlongitude->FldCaption()) ?>");
  71		elm = fobj.elements["x" + infix + "_provlongitude"];
  72		if (elm && !ew_CheckNumber(elm.value))
  73			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($province->provlongitude->FldErrMsg()) ?>");
  74		elm = fobj.elements["x" + infix + "_provaltitude"];
  75		if (elm && !ew_HasValue(elm))
  76			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($province->provaltitude->FldCaption()) ?>");
  77		elm = fobj.elements["x" + infix + "_provaltitude"];
  78		if (elm && !ew_CheckNumber(elm.value))
  79			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($province->provaltitude->FldErrMsg()) ?>");
  80		elm = fobj.elements["x" + infix + "_countryid"];
  81		if (elm && !ew_HasValue(elm))
  82			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($province->countryid->FldCaption()) ?>");
  83		elm = fobj.elements["x" + infix + "_provincecode"];
  84		if (elm && !ew_HasValue(elm))
  85			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($province->provincecode->FldCaption()) ?>");
  86		elm = fobj.elements["x" + infix + "_provincecode"];
  87		if (elm && !ew_CheckInteger(elm.value))
  88			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($province->provincecode->FldErrMsg()) ?>");
  89		*/
  90		// Set up row object
  91		var row = {};
  92		row["index"] = infix;
  93		for (var j = 0; j < fobj.elements.length; j++) {
  94			var el = fobj.elements[j];
  95			var len = infix.length + 2;
  96			if (el.name.substr(0, len) == "x" + infix + "_") {
  97				var elname = "x_" + el.name.substr(len);
  98				if (ewLang.isObject(row[elname])) { // already exists
  99					if (ewLang.isArray(row[elname])) {
 100						row[elname][row[elname].length] = el; // add to array
 101					} else {
 102						row[elname] = [row[elname], el]; // convert to array
 103					}
 104				} else {
 105					row[elname] = el;
 106				}
 107			}
 108		}
 109		fobj.row = row;
 110
 111		// Call Form Custom Validate event
 112		if (!this.Form_CustomValidate(fobj)) return false;
 113	}
 114
 115	// Process detail page
 116	var detailpage = (fobj.detailpage) ? fobj.detailpage.value : "";
 117	if (detailpage != "") {
 118		return eval(detailpage+".ValidateForm(fobj)");
 119	}
 120	return true;
 121}
 122
 123// extend page with Form_CustomValidate function
 124province_edit.Form_CustomValidate =  
 125 function(fobj) { // DO NOT CHANGE THIS LINE!
 126
 127 	// Your custom validation code here, return false if invalid. 
 128 	return true;
 129 }
 130<?php if (EW_CLIENT_VALIDATE) { ?>
 131province_edit.ValidateRequired = true; // uses JavaScript validation
 132<?php } else { ?>
 133province_edit.ValidateRequired = false; // no JavaScript validation
 134<?php } ?>
 135
 136//-->
 137</script>
 138<script language="JavaScript" type="text/javascript">
 139<!--
 140
 141// Write your client script here, no need to add script tags.
 142//-->
 143
 144</script>
 145<p class="phpmaker ewTitle"><?php echo $Language->Phrase("Edit") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $province->TableCaption() ?></p>
 146<p class="phpmaker"><a href="<?php echo $province->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></p>
 147<?php $province_edit->ShowPageHeader(); ?>
 148<?php
 149$province_edit->ShowMessage();
 150?>
 151<form name="fprovinceedit" id="fprovinceedit" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return province_edit.ValidateForm(this);">
 152<p>
 153<input type="hidden" name="a_table" id="a_table" value="province">
 154<input type="hidden" name="a_edit" id="a_edit" value="U">
 155<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
 156<div class="ewGridMiddlePanel">
 157<table cellspacing="0" class="ewTable">
 158<?php if ($province->id->Visible) { // id ?>
 159	<tr id="r_id"<?php echo $province->RowAttributes() ?>>
 160		<td class="ewTableHeader"><?php echo $province->id->FldCaption() ?></td>
 161		<td<?php echo $province->id->CellAttributes() ?>><span id="el_id">
 162<div<?php echo $province->id->ViewAttributes() ?>><?php echo $province->id->EditValue ?></div>
 163<input type="hidden" name="x_id" id="x_id" value="<?php echo ew_HtmlEncode($province->id->CurrentValue) ?>">
 164</span><?php echo $province->id->CustomMsg ?></td>
 165	</tr>
 166<?php } ?>
 167<?php if ($province->province_1->Visible) { // province ?>
 168	<tr id="r_province_1"<?php echo $province->RowAttributes() ?>>
 169		<td class="ewTableHeader"><?php echo $province->province_1->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
 170		<td<?php echo $province->province_1->CellAttributes() ?>><span id="el_province_1">
 171<input type="text" name="x_province_1" id="x_province_1" size="30" maxlength="60" value="<?php echo $province->province_1->EditValue ?>"<?php echo $province->province_1->EditAttributes() ?>>
 172</span><?php echo $province->province_1->CustomMsg ?></td>
 173	</tr>
 174<?php } ?>
 175<?php if ($province->provcontact->Visible) { // provcontact ?>
 176	<tr id="r_provcontact"<?php echo $province->RowAttributes() ?>>
 177		<td class="ewTableHeader"><?php echo $province->provcontact->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 178		<td<?php echo $province->provcontact->CellAttributes() ?>><span id="el_provcontact">
 179<input type="text" name="x_provcontact" id="x_provcontact" size="30" maxlength="60" value="<?php echo $province->provcontact->EditValue ?>"<?php echo $province->provcontact->EditAttributes() ?>>
 180</span><?php echo $province->provcontact->CustomMsg ?></td>
 181	</tr>
 182<?php } ?>
 183<?php if ($province->provhalladdress->Visible) { // provhalladdress ?>
 184	<tr id="r_provhalladdress"<?php echo $province->RowAttributes() ?>>
 185		<td class="ewTableHeader"><?php echo $province->provhalladdress->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 186		<td<?php echo $province->provhalladdress->CellAttributes() ?>><span id="el_provhalladdress">
 187<textarea name="x_provhalladdress" id="x_provhalladdress" cols="35" rows="4"<?php echo $province->provhalladdress->EditAttributes() ?>><?php echo $province->provhalladdress->EditValue ?></textarea>
 188</span><?php echo $province->provhalladdress->CustomMsg ?></td>
 189	</tr>
 190<?php } ?>
 191<?php if ($province->provtelno->Visible) { // provtelno ?>
 192	<tr id="r_provtelno"<?php echo $province->RowAttributes() ?>>
 193		<td class="ewTableHeader"><?php echo $province->provtelno->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 194		<td<?php echo $province->provtelno->CellAttributes() ?>><span id="el_provtelno">
 195<input type="text" name="x_provtelno" id="x_provtelno" size="30" maxlength="20" value="<?php echo $province->provtelno->EditValue ?>"<?php echo $province->provtelno->EditAttributes() ?>>
 196</span><?php echo $province->provtelno->CustomMsg ?></td>
 197	</tr>
 198<?php } ?>
 199<?php if ($province->provlatitude->Visible) { // provlatitude ?>
 200	<tr id="r_provlatitude"<?php echo $province->RowAttributes() ?>>
 201		<td class="ewTableHeader"><?php echo $province->provlatitude->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 202		<td<?php echo $province->provlatitude->CellAttributes() ?>><span id="el_provlatitude">
 203<input type="text" name="x_provlatitude" id="x_provlatitude" size="30" value="<?php echo $province->provlatitude->EditValue ?>"<?php echo $province->provlatitude->EditAttributes() ?>>
 204</span><?php echo $province->provlatitude->CustomMsg ?></td>
 205	</tr>
 206<?php } ?>
 207<?php if ($province->provlongitude->Visible) { // provlongitude ?>
 208	<tr id="r_provlongitude"<?php echo $province->RowAttributes() ?>>
 209		<td class="ewTableHeader"><?php echo $province->provlongitude->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 210		<td<?php echo $province->provlongitude->CellAttributes() ?>><span id="el_provlongitude">
 211<input type="text" name="x_provlongitude" id="x_provlongitude" size="30" value="<?php echo $province->provlongitude->EditValue ?>"<?php echo $province->provlongitude->EditAttributes() ?>>
 212</span><?php echo $province->provlongitude->CustomMsg ?></td>
 213	</tr>
 214<?php } ?>
 215<?php if ($province->provaltitude->Visible) { // provaltitude ?>
 216	<tr id="r_provaltitude"<?php echo $province->RowAttributes() ?>>
 217		<td class="ewTableHeader"><?php echo $province->provaltitude->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 218		<td<?php echo $province->provaltitude->CellAttributes() ?>><span id="el_provaltitude">
 219<input type="text" name="x_provaltitude" id="x_provaltitude" size="30" value="<?php echo $province->provaltitude->EditValue ?>"<?php echo $province->provaltitude->EditAttributes() ?>>
 220</span><?php echo $province->provaltitude->CustomMsg ?></td>
 221	</tr>
 222<?php } ?>
 223<?php if ($province->countryid->Visible) { // countryid ?>
 224	<tr id="r_countryid"<?php echo $province->RowAttributes() ?>>
 225		<td class="ewTableHeader"><?php echo $province->countryid->FldCaption() ?><!-- Removed Required Field Indicator--></td>
 226		<td<?php echo $province->countryid->CellAttributes() ?>><span id="el_countryid">
 227<select id="x_countryid" name="x_countryid"<?php echo $province->countryid->EditAttributes() ?>>
 228<?php
 229if (is_array($province->countryid->EditValue)) {
 230	$arwrk = $province->countryid->EditValue;
 231	$rowswrk = count($arwrk);
 232	$emptywrk = TRUE;
 233	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
 234		$selwrk = (strval($province->countryid->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
 235		if ($selwrk <> "") $emptywrk = FALSE;
 236?>
 237<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
 238<?php echo $arwrk[$rowcntwrk][1] ?>
 239</option>
 240<?php
 241	}
 242}
 243?>
 244</select>
 245</span><?php echo $province->countryid->CustomMsg ?></td>
 246	</tr>
 247<?php } ?>
 248
 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("EditBtn")) ?>">
 254</form>
 255<?php
 256$province_edit->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$province_edit->Page_Terminate();
 271?>
 272<?php
 273
 274//
 275// Page class
 276//
 277class cprovince_edit {
 278
 279	// Page ID
 280	var $PageID = 'edit';
 281
 282	// Table name
 283	var $TableName = 'province';
 284
 285	// Page object name
 286	var $PageObjName = 'province_edit';
 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 $province;
 297		if ($province->UseTokenInUrl) $PageUrl .= "t=" . $province->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, $province;
 375		if ($province->UseTokenInUrl) {
 376			if ($objForm)
 377				return ($province->TableVar == $objForm->GetValue("t"));
 378			if (@$_GET["t"] <> "")
 379				return ($province->TableVar == $_GET["t"]);
 380		} else {
 381			return TRUE;
 382		}
 383	}
 384
 385	//
 386	// Page class constructor
 387	//
 388	function cprovince_edit() {
 389		global $conn, $Language;
 390
 391		// Language object
 392		if (!isset($Language)) $Language = new cLanguage();
 393
 394		// Table object (province)
 395		if (!isset($GLOBALS["province"])) {
 396			$GLOBALS["province"] = new cprovince();
 397			$GLOBALS["Table"] =& $GLOBALS["province"];
 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", 'edit', TRUE);
 406
 407		// Table name (for backward compatibility)
 408		if (!defined("EW_TABLE_NAME"))
 409			define("EW_TABLE_NAME", 'province', 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 $province;
 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->CanEdit()) {
 440			$Security->SaveLastUrl();
 441			$this->Page_Terminate("provincelist.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
 481	// 
 482	// Page main
 483	//
 484	function Page_Main() {
 485		global $objForm, $Language, $gsFormError, $province;
 486
 487		// Load key from QueryString
 488		if (@$_GET["id"] <> "")
 489			$province->id->setQueryStringValue($_GET["id"]);
 490		if (@$_POST["a_edit"] <> "") {
 491			$province->CurrentAction = $_POST["a_edit"]; // Get action code
 492			$this->LoadFormValues(); // Get form values
 493
 494			// Validate form
 495			if (!$this->ValidateForm()) {
 496				$province->CurrentAction = ""; // Form error, reset action
 497				$this->setFailureMessage($gsFormError);
 498				$province->EventCancelled = TRUE; // Event cancelled
 499				$this->RestoreFormValues();
 500			}
 501		} else {
 502			$province->CurrentAction = "I"; // Default action is display
 503		}
 504
 505		// Check if valid key
 506		if ($province->id->CurrentValue == "")
 507			$this->Page_Terminate("provincelist.php"); // Invalid key, return to list
 508		switch ($province->CurrentAction) {
 509			case "I": // Get a record to display
 510				if (!$this->LoadRow()) { // Load record based on key
 511					$this->setFailureMessage($Language->Phrase("NoRecord")); // No record found
 512					$this->Page_Terminate("provincelist.php"); // No matching record, return to list
 513				}
 514				break;
 515			Case "U": // Update
 516				$province->SendEmail = TRUE; // Send email on update success
 517				if ($this->EditRow()) { // Update record based on key
 518					$this->setSuccessMessage($Language->Phrase("UpdateSuccess")); // Update success
 519					$sReturnUrl = $province->getReturnUrl();
 520					if (ew_GetPageName($sReturnUrl) == "provinceview.php")
 521						$sReturnUrl = $province->ViewUrl(); // View paging, return to View page directly
 522					$this->Page_Terminate($sReturnUrl); // Return to caller
 523				} else {
 524					$province->EventCancelled = TRUE; // Event cancelled
 525					$this->RestoreFormValues(); // Restore form values if update failed
 526				}
 527		}
 528
 529		// Render the record
 530		$province->RowType = EW_ROWTYPE_EDIT; // Render as Edit
 531		$province->ResetAttrs();
 532		$this->RenderRow();
 533	}
 534
 535	// Get upload files
 536	function GetUploadFiles() {
 537		global $objForm, $province;
 538
 539		// Get upload data
 540		$index = $objForm->Index; // Save form index
 541		$objForm->Index = 0;
 542		$confirmPage = (strval($objForm->GetValue("a_confirm")) <> "");
 543		$objForm->Index = $index; // Restore form index
 544	}
 545
 546	// Load form values
 547	function LoadFormValues() {
 548
 549		// Load from form
 550		global $objForm, $province;
 551		if (!$province->id->FldIsDetailKey)
 552			$province->id->setFormValue($objForm->GetValue("x_id"));
 553		if (!$province->province_1->FldIsDetailKey) {
 554			$province->province_1->setFormValue($objForm->GetValue("x_province_1"));
 555		}
 556		if (!$province->provcontact->FldIsDetailKey) {
 557			$province->provcontact->setFormValue($objForm->GetValue("x_provcontact"));
 558		}
 559		if (!$province->provhalladdress->FldIsDetailKey) {
 560			$province->provhalladdress->setFormValue($objForm->GetValue("x_provhalladdress"));
 561		}
 562		if (!$province->provtelno->FldIsDetailKey) {
 563			$province->provtelno->setFormValue($objForm->GetValue("x_provtelno"));
 564		}
 565		if (!$province->provlatitude->FldIsDetailKey) {
 566			$province->provlatitude->setFormValue($objForm->GetValue("x_provlatitude"));
 567		}
 568		if (!$province->provlongitude->FldIsDetailKey) {
 569			$province->provlongitude->setFormValue($objForm->GetValue("x_provlongitude"));
 570		}
 571		if (!$province->provaltitude->FldIsDetailKey) {
 572			$province->provaltitude->setFormValue($objForm->GetValue("x_provaltitude"));
 573		}
 574		if (!$province->countryid->FldIsDetailKey) {
 575			$province->countryid->setFormValue($objForm->GetValue("x_countryid"));
 576		}
 577		if (!$province->zuserid->FldIsDetailKey) {
 578			$province->zuserid->setFormValue($objForm->GetValue("x_zuserid"));
 579		}
 580		if (!$province->timestamp->FldIsDetailKey) {
 581			$province->timestamp->setFormValue($objForm->GetValue("x_timestamp"));
 582			$province->timestamp->CurrentValue = ew_UnFormatDateTime($province->timestamp->CurrentValue, 5);
 583		}
 584		if (!$province->provincecode->FldIsDetailKey) {
 585			$province->provincecode->setFormValue($objForm->GetValue("x_provincecode"));
 586		}
 587	}
 588
 589	// Restore form values
 590	function RestoreFormValues() {
 591		global $objForm, $province;
 592		$this->LoadRow();
 593		$province->id->CurrentValue = $province->id->FormValue;
 594		$province->province_1->CurrentValue = $province->province_1->FormValue;
 595		$province->provcontact->CurrentValue = $province->provcontact->FormValue;
 596		$province->provhalladdress->CurrentValue = $province->provhalladdress->FormValue;
 597		$province->provtelno->CurrentValue = $province->provtelno->FormValue;
 598		$province->provlatitude->CurrentValue = $province->provlatitude->FormValue;
 599		$province->provlongitude->CurrentValue = $province->provlongitude->FormValue;
 600		$province->provaltitude->CurrentValue = $province->provaltitude->FormValue;
 601		$province->countryid->CurrentValue = $province->countryid->FormValue;
 602		$province->zuserid->CurrentValue = $province->zuserid->FormValue;
 603		$province->timestamp->CurrentValue = $province->timestamp->FormValue;
 604		$province->timestamp->CurrentValue = ew_UnFormatDateTime($province->timestamp->CurrentValue, 5);
 605		$province->provincecode->CurrentValue = $province->provincecode->FormValue;
 606	}
 607
 608	// Load row based on key values
 609	function LoadRow() {
 610		global $conn, $Security, $province;
 611		$sFilter = $province->KeyFilter();
 612
 613		// Call Row Selecting event
 614		$province->Row_Selecting($sFilter);
 615
 616		// Load SQL based on filter
 617		$province->CurrentFilter = $sFilter;
 618		$sSql = $province->SQL();
 619		$res = FALSE;
 620		$rs = ew_LoadRecordset($sSql);
 621		if ($rs && !$rs->EOF) {
 622			$res = TRUE;
 623			$this->LoadRowValues($rs); // Load row values
 624			$rs->Close();
 625		}
 626		return $res;
 627	}
 628
 629	// Load row values from recordset
 630	function LoadRowValues(&$rs) {
 631		global $conn, $province;
 632		if (!$rs || $rs->EOF) return;
 633
 634		// Call Row Selected event
 635		$row =& $rs->fields;
 636		$province->Row_Selected($row);
 637		$province->id->setDbValue($rs->fields('id'));
 638		$province->province_1->setDbValue($rs->fields('province'));
 639		$province->provcontact->setDbValue($rs->fields('provcontact'));
 640		$province->provhalladdress->setDbValue($rs->fields('provhalladdress'));
 641		$province->provtelno->setDbValue($rs->fields('provtelno'));
 642		$province->provlatitude->setDbValue($rs->fields('provlatitude'));
 643		$province->provlongitude->setDbValue($rs->fields('provlongitude'));
 644		$province->provaltitude->setDbValue($rs->fields('provaltitude'));
 645		$province->countryid->setDbValue($rs->fields('countryid'));
 646		$province->zuserid->setDbValue($rs->fields('userid'));
 647		$province->timestamp->setDbValue($rs->fields('timestamp'));
 648		$province->provincecode->setDbValue($rs->fields('provincecode'));
 649	}
 650
 651	// Render row values based on field settings
 652	function RenderRow() {
 653		global $conn, $Security, $Language, $province;
 654
 655		// Initialize URLs
 656		// Call Row_Rendering event
 657
 658		$province->Row_Rendering();
 659
 660		// Common render codes for all row types
 661		// id
 662		// province
 663		// provcontact
 664		// provhalladdress
 665		// provtelno
 666		// provlatitude
 667		// provlongitude
 668		// provaltitude
 669		// countryid
 670		// userid
 671		// timestamp
 672		// provincecode
 673
 674		if ($province->RowType == EW_ROWTYPE_VIEW) { // View row
 675
 676			// id
 677			$province->id->ViewValue = $province->id->CurrentValue;
 678			$province->id->ViewCustomAttributes = "";
 679
 680			// province
 681			$province->province_1->ViewValue = $province->province_1->CurrentValue;
 682			$province->province_1->ViewCustomAttributes = "";
 683
 684			// provcontact
 685			$province->provcontact->ViewValue = $province->provcontact->CurrentValue;
 686			$province->provcontact->ViewCustomAttributes = "";
 687
 688			// provhalladdress
 689			$province->provhalladdress->ViewValue = $province->provhalladdress->CurrentValue;
 690			$province->provhalladdress->ViewCustomAttributes = "";
 691
 692			// provtelno
 693			$province->provtelno->ViewValue = $province->provtelno->CurrentValue;
 694			$province->provtelno->ViewCustomAttributes = "";
 695
 696			// provlatitude
 697			$province->provlatitude->ViewValue = $province->provlatitude->CurrentValue;
 698			$province->provlatitude->ViewCustomAttributes = "";
 699
 700			// provlongitude
 701			$province->provlongitude->ViewValue = $province->provlongitude->CurrentValue;
 702			$province->provlongitude->ViewCustomAttributes = "";
 703
 704			// provaltitude
 705			$province->provaltitude->ViewValue = $province->provaltitude->CurrentValue;
 706			$province->provaltitude->ViewCustomAttributes = "";
 707
 708			// countryid
 709			if (strval($province->countryid->CurrentValue) <> "") {
 710				$sFilterWrk = "`id` = " . ew_AdjustSql($province->countryid->CurrentValue) . "";
 711			$sSqlWrk = "SELECT `country` FROM `country`";
 712			$sWhereWrk = "";
 713			if ($sFilterWrk <> "") {
 714				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
 715				$sWhereWrk .= "(" . $sFilterWrk . ")";
 716			}
 717			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
 718				$rswrk = $conn->Execute($sSqlWrk);
 719				if ($rswrk && !$rswrk->EOF) { // Lookup values found
 720					$province->countryid->ViewValue = $rswrk->fields('country');
 721					$rswrk->Close();
 722				} else {
 723					$province->countryid->ViewValue = $province->countryid->CurrentValue;
 724				}
 725			} else {
 726				$province->countryid->ViewValue = NULL;
 727			}
 728			$province->countryid->ViewCustomAttributes = "";
 729
 730			// userid
 731			$province->zuserid->ViewValue = $province->zuserid->CurrentValue;
 732			$province->zuserid->ViewCustomAttributes = "";
 733
 734			// timestamp
 735			$province->timestamp->ViewValue = $province->timestamp->CurrentValue;
 736			$province->timestamp->ViewValue = ew_FormatDateTime($province->timestamp->ViewValue, 9);
 737			$province->timestamp->ViewCustomAttributes = "";
 738
 739			// provincecode
 740			$province->provincecode->ViewValue = $province->provincecode->CurrentValue;
 741			$province->provincecode->ViewCustomAttributes = "";
 742
 743			// id
 744			$province->id->LinkCustomAttributes = "";
 745			$province->id->HrefValue = "";
 746			$province->id->TooltipValue = "";
 747
 748			// province
 749			$province->province_1->LinkCustomAttributes = "";
 750			$province->province_1->HrefValue = "";
 751			$province->province_1->TooltipValue = "";
 752
 753			// provcontact
 754			$province->provcontact->LinkCustomAttributes = "";
 755			$province->provcontact->HrefValue = "";
 756			$province->provcontact->TooltipValue = "";
 757
 758			// provhalladdress
 759			$province->provhalladdress->LinkCustomAttributes = "";
 760			$province->provhalladdress->HrefValue = "";
 761			$province->provhalladdress->TooltipValue = "";
 762
 763			// provtelno
 764			$province->provtelno->LinkCustomAttributes = "";
 765			$province->provtelno->HrefValue = "";
 766			$province->provtelno->TooltipValue = "";
 767
 768			// provlatitude
 769			$province->provlatitude->LinkCustomAttributes = "";
 770			$province->provlatitude->HrefValue = "";
 771			$province->provlatitude->TooltipValue = "";
 772
 773			// provlongitude
 774			$province->provlongitude->LinkCustomAttributes = "";
 775			$province->provlongitude->HrefValue = "";
 776			$province->provlongitude->TooltipValue = "";
 777
 778			// provaltitude
 779			$province->provaltitude->LinkCustomAttributes = "";
 780			$province->provaltitude->HrefValue = "";
 781			$province->provaltitude->TooltipValue = "";
 782
 783			// countryid
 784			$province->countryid->LinkCustomAttributes = "";
 785			$province->countryid->HrefValue = "";
 786			$province->countryid->TooltipValue = "";
 787
 788			// userid
 789			$province->zuserid->LinkCustomAttributes = "";
 790			$province->zuserid->HrefValue = "";
 791			$province->zuserid->TooltipValue = "";
 792
 793			// timestamp
 794			$province->timestamp->LinkCustomAttributes = "";
 795			$province->timestamp->HrefValue = "";
 796			$province->timestamp->TooltipValue = "";
 797
 798			// provincecode
 799			$province->provincecode->LinkCustomAttributes = "";
 800			$province->provincecode->HrefValue = "";
 801			$province->provincecode->TooltipValue = "";
 802		} elseif ($province->RowType == EW_ROWTYPE_EDIT) { // Edit row
 803
 804			// id
 805			$province->id->EditCustomAttributes = "";
 806			$province->id->EditValue = $province->id->CurrentValue;
 807			$province->id->ViewCustomAttributes = "";
 808
 809			// province
 810			$province->province_1->EditCustomAttributes = "";
 811			$province->province_1->EditValue = ew_HtmlEncode($province->province_1->CurrentValue);
 812
 813			// provcontact
 814			$province->provcontact->EditCustomAttributes = "";
 815			$province->provcontact->EditValue = ew_HtmlEncode($province->provcontact->CurrentValue);
 816
 817			// provhalladdress
 818			$province->provhalladdress->EditCustomAttributes = "";
 819			$province->provhalladdress->EditValue = ew_HtmlEncode($province->provhalladdress->CurrentValue);
 820
 821			// provtelno
 822			$province->provtelno->EditCustomAttributes = "";
 823			$province->provtelno->EditValue = ew_HtmlEncode($province->provtelno->CurrentValue);
 824
 825			// provlatitude
 826			$province->provlatitude->EditCustomAttributes = "";
 827			$province->provlatitude->EditValue = ew_HtmlEncode($province->provlatitude->CurrentValue);
 828
 829			// provlongitude
 830			$province->provlongitude->EditCustomAttributes = "";
 831			$province->provlongitude->EditValue = ew_HtmlEncode($province->provlongitude->CurrentValue);
 832
 833			// provaltitude
 834			$province->provaltitude->EditCustomAttributes = "";
 835			$province->provaltitude->EditValue = ew_HtmlEncode($province->provaltitude->CurrentValue);
 836
 837			// countryid
 838			$province->countryid->EditCustomAttributes = "";
 839				$sFilterWrk = "";
 840			$sSqlWrk = "SELECT `id`, `country` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld` FROM `country`";
 841			$sWhereWrk = "";
 842			if ($sFilterWrk <> "") {
 843				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
 844				$sWhereWrk .= "(" . $sFilterWrk . ")";
 845			}
 846			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
 847			$rswrk = $conn->Execute($sSqlWrk);
 848			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
 849			if ($rswrk) $rswrk->Close();
 850			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
 851			$province->countryid->EditValue = $arwrk;
 852
 853			// userid
 854			// timestamp
 855			// provincecode
 856
 857			$province->provincecode->EditCustomAttributes = "";
 858			$province->provincecode->EditValue = ew_HtmlEncode($province->provincecode->CurrentValue);
 859
 860			// Edit refer script
 861			// id
 862
 863			$province->id->HrefValue = "";
 864
 865			// province
 866			$province->province_1->HrefValue = "";
 867
 868			// provcontact
 869			$province->provcontact->HrefValue = "";
 870
 871			// provhalladdress
 872			$province->provhalladdress->HrefValue = "";
 873
 874			// provtelno
 875			$province->provtelno->HrefValue = "";
 876
 877			// provlatitude
 878			$province->provlatitude->HrefValue = "";
 879
 880			// provlongitude
 881			$province->provlongitude->HrefValue = "";
 882
 883			// provaltitude
 884			$province->provaltitude->HrefValue = "";
 885
 886			// countryid
 887			$province->countryid->HrefValue = "";
 888
 889			// userid
 890			$province->zuserid->HrefValue = "";
 891
 892			// timestamp
 893			$province->timestamp->HrefValue = "";
 894
 895			// provincecode
 896			$province->provincecode->HrefValue = "";
 897		}
 898		if ($province->RowType == EW_ROWTYPE_ADD ||
 899			$province->RowType == EW_ROWTYPE_EDIT ||
 900			$province->RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
 901			$province->SetupFieldTitles();
 902		}
 903
 904		// Call Row Rendered event
 905		if ($province->RowType <> EW_ROWTYPE_AGGREGATEINIT)
 906			$province->Row_Rendered();
 907	}
 908
 909	// Validate form
 910	function ValidateForm() {
 911		global $Language, $gsFormError, $province;
 912
 913		// Initialize form error message
 914		$gsFormError = "";
 915
 916		// Check if validation required
 917		if (!EW_SERVER_VALIDATE)
 918			return ($gsFormError == "");
 919		if (!ew_CheckInteger($province->id->FormValue)) {
 920			ew_AddMessage($gsFormError, $province->id->FldErrMsg());
 921		}
 922		if (!is_null($province->province_1->FormValue) && $province->province_1->FormValue == "") {
 923			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $province->province_1->FldCaption());
 924		}
 925		if (!is_null($province->provcontact->FormValue) && $province->provcontact->FormValue == "") {
 926			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $province->provcontact->FldCaption());
 927		}
 928		if (!is_null($province->provhalladdress->FormValue) && $province->provhalladdress->FormValue == "") {
 929			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $province->provhalladdress->FldCaption());
 930		}
 931		if (!is_null($province->provtelno->FormValue) && $province->provtelno->FormValue == "") {
 932			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $province->provtelno->FldCaption());
 933		}
 934		if (!is_null($province->provlatitude->FormValue) && $province->provlatitude->FormValue == "") {
 935			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $province->provlatitude->FldCaption());
 936		}
 937		if (!ew_CheckNumber($province->provlatitude->FormValue)) {
 938			ew_AddMessage($gsFormError, $province->provlatitude->FldErrMsg());
 939		}
 940		if (!is_null($province->provlongitude->FormValue) && $province->provlongitude->FormValue == "") {
 941			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $province->provlongitude->FldCaption());
 942		}
 943		if (!ew_CheckNumber($province->provlongitude->FormValue)) {
 944			ew_AddMessage($gsFormError, $province->provlongitude->FldErrMsg());
 945		}
 946		if (!is_null($province->provaltitude->FormValue) && $province->provaltitude->FormValue == "") {
 947			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $province->provaltitude->FldCaption());
 948		}
 949		if (!ew_CheckNumber($province->provaltitude->FormValue)) {
 950			ew_AddMessage($gsFormError, $province->provaltitude->FldErrMsg());
 951		}
 952		if (!is_null($province->countryid->FormValue) && $province->countryid->FormValue == "") {
 953			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $province->countryid->FldCaption());
 954		}
 955		if (!is_null($province->provincecode->FormValue) && $province->provincecode->FormValue == "") {
 956			ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $province->provincecode->FldCaption());
 957		}
 958		if (!ew_CheckInteger($province->provincecode->FormValue)) {
 959			ew_AddMessage($gsFormError, $province->provincecode->FldErrMsg());
 960		}
 961
 962		// Return validate result
 963		$ValidateForm = ($gsFormError == "");
 964
 965		// Call Form_CustomValidate event
 966		$sFormCustomError = "";
 967		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
 968		if ($sFormCustomError <> "") {
 969			ew_AddMessage($gsFormError, $sFormCustomError);
 970		}
 971		return $ValidateForm;
 972	}
 973
 974	// Update record based on key values
 975	function EditRow() {
 976		global $conn, $Security, $Language, $province;
 977		$sFilter = $province->KeyFilter();
 978		$province->CurrentFilter = $sFilter;
 979		$sSql = $province->SQL();
 980		$conn->raiseErrorFn = 'ew_ErrorFn';
 981		$rs = $conn->Execute($sSql);
 982		$conn->raiseErrorFn = '';
 983		if ($rs === FALSE)
 984			return FALSE;
 985		if ($rs->EOF) {
 986			$EditRow = FALSE; // Update Failed
 987		} else {
 988
 989			// Save old values
 990			$rsold =& $rs->fields;
 991			$rsnew = array();
 992
 993			// province
 994			$province->province_1->SetDbValueDef($rsnew, $province->province_1->CurrentValue, "", $province->province_1->ReadOnly);
 995
 996			// provcontact
 997			$province->provcontact->SetDbValueDef($rsnew, $province->provcontact->CurrentValue, "", $province->provcontact->ReadOnly);
 998
 999			// provhalladdress
1000			$province->provhalladdress->SetDbValueDef($rsnew, $province->provhalladdress->CurrentValue, "", $province->provhalladdress->ReadOnly);
1001
1002			// provtelno
1003			$province->provtelno->SetDbValueDef($rsnew, $province->provtelno->CurrentValue, "", $province->provtelno->ReadOnly);
1004
1005			// provlatitude
1006			$province->provlatitude->SetDbValueDef($rsnew, $province->provlatitude->CurrentValue, 0, $province->provlatitude->ReadOnly);
1007
1008			// provlongitude
1009			$province->provlongitude->SetDbValueDef($rsnew, $province->provlongitude->CurrentValue, 0, $province->provlongitude->ReadOnly);
1010
1011			// provaltitude
1012			$province->provaltitude->SetDbValueDef($rsnew, $province->provaltitude->CurrentValue, 0, $province->provaltitude->ReadOnly);
1013
1014			// countryid
1015			$province->countryid->SetDbValueDef($rsnew, $province->countryid->CurrentValue, 0, $province->countryid->ReadOnly);
1016
1017			// userid
1018			$province->zuserid->SetDbValueDef($rsnew, CurrentUserID(), 0);
1019			$rsnew['userid'] =& $province->zuserid->DbValue;
1020
1021			// timestamp
1022			$province->timestamp->SetDbValueDef($rsnew, ew_CurrentDateTime(), ew_CurrentDate());
1023			$rsnew['timestamp'] =& $province->timestamp->DbValue;
1024
1025			// provincecode
1026			$province->provincecode->SetDbValueDef($rsnew, $province->provincecode->CurrentValue, 0, $province->provincecode->ReadOnly);
1027
1028			// Call Row Updating event
1029			$bUpdateRow = $province->Row_Updating($rsold, $rsnew);
1030			if ($bUpdateRow) {
1031				$conn->raiseErrorFn = 'ew_ErrorFn';
1032				if (count($rsnew) > 0)
1033					$EditRow = $conn->Execute($province->UpdateSQL($rsnew));
1034				else
1035					$EditRow = TRUE; // No field to update
1036				$conn->raiseErrorFn = '';
1037			} else {
1038				if ($province->CancelMessage <> "") {
1039					$this->setFailureMessage($province->CancelMessage);
1040					$province->CancelMessage = "";
1041				} else {
1042					$this->setFailureMessage($Language->Phrase("UpdateCancelled"));
1043				}
1044				$EditRow = FALSE;
1045			}
1046		}
1047
1048		// Call Row_Updated event
1049		if ($EditRow)
1050			$province->Row_Updated($rsold, $rsnew);
1051		if ($EditRow) {
1052			$this->WriteAuditTrailOnEdit($rsold, $rsnew);
1053		}
1054		$rs->Close();
1055		return $EditRow;
1056	}
1057// Write Audit Trail start/end for grid update
1058	function WriteAuditTrailDummy($typ) {
1059		$table = 'province';
1060	  $usr = CurrentUserName();
1061		ew_WriteAuditTrail("log", ew_StdCurrentDateTime(), ew_ScriptName(), $usr, $typ, $table, "", "", "", "");
1062	}
1063
1064	// Write Audit Trail (edit page)
1065	function WriteAuditTrailOnEdit(&$rsold, &$rsnew) {
1066		global $province;
1067		$table = 'province';
1068
1069		// Get key value
1070		$key = "";
1071		if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
1072		$key .= $rsold['id'];
1073
1074		// Write Audit Trail
1075		$dt = ew_StdCurrentDateTime();
1076		$id = ew_ScriptName();
1077	  $usr = CurrentUserName();
1078		foreach (array_keys($rsnew) as $fldname) {
1079			if ($province->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore BLOB fields
1080				if ($province->fields[$fldname]->FldDataType == EW_DATATYPE_DATE) { // DateTime field
1081					$modified = (ew_FormatDateTime($rsold[$fldname], 0) <> ew_FormatDateTime($rsnew[$fldname], 0));
1082				} else {
1083					$modified = !ew_CompareValue($rsold[$fldname], $rsnew[$fldname]);
1084				}
1085				if ($modified) {
1086					if ($province->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // Memo field
1087						if (EW_AUDIT_TRAIL_TO_DATABASE) {
1088							$oldvalue = $rsold[$fldname];
1089							$newvalue = $rsnew[$fldname];
1090						} else {
1091							$oldvalue = "[MEMO]";
1092							$newvalue = "[MEMO]";
1093						}
1094					} elseif ($province->fields[$fldname]->FldDataType == EW_DATATYPE_XML) { // XML field
1095						$oldvalue = "[XML]";
1096						$newvalue = "[XML]";
1097					} else {
1098						$oldvalue = $rsold[$fldname];
1099						$newvalue = $rsnew[$fldname];
1100					}
1101					ew_WriteAuditTrail("log", $dt, $id, $usr, "U", $table, $fldname, $key, $oldvalue, $newvalue);
1102				}
1103			}
1104		}
1105	}
1106
1107	// Page Load event
1108	function Page_Load() {
1109
1110		//echo "Page Load";
1111	}
1112
1113	// Page Unload event
1114	function Page_Unload() {
1115
1116		//echo "Page Unload";
1117	}
1118
1119	// Page Redirecting event
1120	function Page_Redirecting(&$url) {
1121
1122		// Example:
1123		//$url = "your URL";
1124
1125	}
1126
1127	// Message Showing event
1128	// $type = ''|'success'|'failure'
1129	function Message_Showing(&$msg, $type) {
1130
1131		// Example:
1132		//if ($type == 'success') $msg = "your success message";
1133
1134	}
1135
1136	// Page Data Rendering event
1137	function Page_DataRendering(&$header) {
1138
1139		// Example:
1140		//$header = "your header";
1141
1142	}
1143
1144	// Page Data Rendered event
1145	function Page_DataRendered(&$footer) {
1146
1147		// Example:
1148		//$footer = "your footer";
1149
1150	}
1151
1152	// Form Custom Validate event
1153	function Form_CustomValidate(&$CustomError) {
1154
1155		// Return error message in CustomError
1156		return TRUE;
1157	}
1158}
1159?>