PageRenderTime 57ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/cityedit.php

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