PageRenderTime 51ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/cityadd.php

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