/barangayedit.php
PHP | 1180 lines | 807 code | 156 blank | 217 comment | 185 complexity | 1ae7388b77a12939f7db1ca88bb887de MD5 | raw file
Possible License(s): LGPL-2.1
- <?php
- if (session_id() == "") session_start(); // Initialize Session data
- ob_start(); // Turn on output buffering
- ?>
- <?php include_once "ewcfg8.php" ?>
- <?php include_once "ewmysql8.php" ?>
- <?php include_once "phpfn8.php" ?>
- <?php include_once "barangayinfo.php" ?>
- <?php include_once "userinfo.php" ?>
- <?php include_once "userfn8.php" ?>
- <?php ew_Header(FALSE) ?>
- <?php
-
- // Create page object
- $barangay_edit = new cbarangay_edit();
- $Page =& $barangay_edit;
-
- // Page init
- $barangay_edit->Page_Init();
-
- // Page main
- $barangay_edit->Page_Main();
- ?>
- <?php include_once "header.php" ?>
- <script type="text/javascript">
- <!--
-
- // Create page object
- var barangay_edit = new ew_Page("barangay_edit");
-
- // page properties
- barangay_edit.PageID = "edit"; // page ID
- barangay_edit.FormID = "fbarangayedit"; // form ID
- var EW_PAGE_ID = barangay_edit.PageID; // for backward compatibility
-
- // extend page with ValidateForm function
- barangay_edit.ValidateForm = function(fobj) {
- ew_PostAutoSuggest(fobj);
- if (!this.ValidateRequired)
- return true; // ignore validation
- if (fobj.a_confirm && fobj.a_confirm.value == "F")
- return true;
- var i, elm, aelm, infix;
- var rowcnt = 1;
- for (i=0; i<rowcnt; i++) {
- infix = "";
- elm = fobj.elements["x" + infix + "_baranggay"];
- if (elm && !ew_HasValue(elm))
- return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($barangay->baranggay->FldCaption()) ?>");
- /*elm = fobj.elements["x" + infix + "_brgyaddress"];
- if (elm && !ew_HasValue(elm))
- return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($barangay->brgyaddress->FldCaption()) ?>");
- elm = fobj.elements["x" + infix + "_brgytelno"];
- if (elm && !ew_HasValue(elm))
- return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($barangay->brgytelno->FldCaption()) ?>");
- elm = fobj.elements["x" + infix + "_brgycontact"];
- if (elm && !ew_HasValue(elm))
- return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($barangay->brgycontact->FldCaption()) ?>");
- elm = fobj.elements["x" + infix + "_cityid"];
- if (elm && !ew_HasValue(elm))
- return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($barangay->cityid->FldCaption()) ?>");
- elm = fobj.elements["x" + infix + "_districtid"];
- if (elm && !ew_HasValue(elm))
- return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($barangay->districtid->FldCaption()) ?>");
- elm = fobj.elements["x" + infix + "_brgylatitude"];
- if (elm && !ew_HasValue(elm))
- return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($barangay->brgylatitude->FldCaption()) ?>");
- elm = fobj.elements["x" + infix + "_brgylatitude"];
- if (elm && !ew_CheckNumber(elm.value))
- return ew_OnError(this, elm, "<?php echo ew_JsEncode2($barangay->brgylatitude->FldErrMsg()) ?>");
- elm = fobj.elements["x" + infix + "_brgylongtitude"];
- if (elm && !ew_HasValue(elm))
- return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($barangay->brgylongtitude->FldCaption()) ?>");
- elm = fobj.elements["x" + infix + "_brgylongtitude"];
- if (elm && !ew_CheckNumber(elm.value))
- return ew_OnError(this, elm, "<?php echo ew_JsEncode2($barangay->brgylongtitude->FldErrMsg()) ?>");
- elm = fobj.elements["x" + infix + "_brgyaltitude"];
- if (elm && !ew_HasValue(elm))
- return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($barangay->brgyaltitude->FldCaption()) ?>");
- elm = fobj.elements["x" + infix + "_brgyaltitude"];
- if (elm && !ew_CheckNumber(elm.value))
- return ew_OnError(this, elm, "<?php echo ew_JsEncode2($barangay->brgyaltitude->FldErrMsg()) ?>");
- elm = fobj.elements["x" + infix + "_brgycode"];
- if (elm && !ew_HasValue(elm))
- return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($barangay->brgycode->FldCaption()) ?>");
- elm = fobj.elements["x" + infix + "_brgycode"];
- if (elm && !ew_CheckInteger(elm.value))
- return ew_OnError(this, elm, "<?php echo ew_JsEncode2($barangay->brgycode->FldErrMsg()) ?>");
- */
- // Set up row object
- var row = {};
- row["index"] = infix;
- for (var j = 0; j < fobj.elements.length; j++) {
- var el = fobj.elements[j];
- var len = infix.length + 2;
- if (el.name.substr(0, len) == "x" + infix + "_") {
- var elname = "x_" + el.name.substr(len);
- if (ewLang.isObject(row[elname])) { // already exists
- if (ewLang.isArray(row[elname])) {
- row[elname][row[elname].length] = el; // add to array
- } else {
- row[elname] = [row[elname], el]; // convert to array
- }
- } else {
- row[elname] = el;
- }
- }
- }
- fobj.row = row;
-
- // Call Form Custom Validate event
- if (!this.Form_CustomValidate(fobj)) return false;
- }
-
- // Process detail page
- var detailpage = (fobj.detailpage) ? fobj.detailpage.value : "";
- if (detailpage != "") {
- return eval(detailpage+".ValidateForm(fobj)");
- }
- return true;
- }
-
- // extend page with Form_CustomValidate function
- barangay_edit.Form_CustomValidate =
- function(fobj) { // DO NOT CHANGE THIS LINE!
-
- // Your custom validation code here, return false if invalid.
- return true;
- }
- <?php if (EW_CLIENT_VALIDATE) { ?>
- barangay_edit.ValidateRequired = true; // uses JavaScript validation
- <?php } else { ?>
- barangay_edit.ValidateRequired = false; // no JavaScript validation
- <?php } ?>
-
- //-->
- </script>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your client script here, no need to add script tags.
- //-->
-
- </script>
- <p class="phpmaker ewTitle"><?php echo $Language->Phrase("Edit") ?> <?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $barangay->TableCaption() ?></p>
- <p class="phpmaker"><a href="<?php echo $barangay->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></p>
- <?php $barangay_edit->ShowPageHeader(); ?>
- <?php
- $barangay_edit->ShowMessage();
- ?>
- <form name="fbarangayedit" id="fbarangayedit" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return barangay_edit.ValidateForm(this);">
- <p>
- <input type="hidden" name="a_table" id="a_table" value="barangay">
- <input type="hidden" name="a_edit" id="a_edit" value="U">
- <table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
- <div class="ewGridMiddlePanel">
- <table cellspacing="0" class="ewTable">
- <?php if ($barangay->baranggay->Visible) { // baranggay ?>
- <tr id="r_baranggay"<?php echo $barangay->RowAttributes() ?>>
- <td class="ewTableHeader"><?php echo $barangay->baranggay->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
- <td<?php echo $barangay->baranggay->CellAttributes() ?>><span id="el_baranggay">
- <input type="text" name="x_baranggay" id="x_baranggay" size="30" maxlength="20" value="<?php echo $barangay->baranggay->EditValue ?>"<?php echo $barangay->baranggay->EditAttributes() ?>>
- </span><?php echo $barangay->baranggay->CustomMsg ?></td>
- </tr>
- <?php } ?>
- <?php if ($barangay->brgyaddress->Visible) { // brgyaddress ?>
- <tr id="r_brgyaddress"<?php echo $barangay->RowAttributes() ?>>
- <td class="ewTableHeader"><?php echo $barangay->brgyaddress->FldCaption() ?><!-- Removed Required Field Indicator--></td>
- <td<?php echo $barangay->brgyaddress->CellAttributes() ?>><span id="el_brgyaddress">
- <textarea name="x_brgyaddress" id="x_brgyaddress" cols="35" rows="4"<?php echo $barangay->brgyaddress->EditAttributes() ?>><?php echo $barangay->brgyaddress->EditValue ?></textarea>
- </span><?php echo $barangay->brgyaddress->CustomMsg ?></td>
- </tr>
- <?php } ?>
- <?php if ($barangay->brgytelno->Visible) { // brgytelno ?>
- <tr id="r_brgytelno"<?php echo $barangay->RowAttributes() ?>>
- <td class="ewTableHeader"><?php echo $barangay->brgytelno->FldCaption() ?><!-- Removed Required Field Indicator--></td>
- <td<?php echo $barangay->brgytelno->CellAttributes() ?>><span id="el_brgytelno">
- <input type="text" name="x_brgytelno" id="x_brgytelno" size="30" maxlength="20" value="<?php echo $barangay->brgytelno->EditValue ?>"<?php echo $barangay->brgytelno->EditAttributes() ?>>
- </span><?php echo $barangay->brgytelno->CustomMsg ?></td>
- </tr>
- <?php } ?>
- <?php if ($barangay->brgycontact->Visible) { // brgycontact ?>
- <tr id="r_brgycontact"<?php echo $barangay->RowAttributes() ?>>
- <td class="ewTableHeader"><?php echo $barangay->brgycontact->FldCaption() ?><!-- Removed Required Field Indicator--></td>
- <td<?php echo $barangay->brgycontact->CellAttributes() ?>><span id="el_brgycontact">
- <input type="text" name="x_brgycontact" id="x_brgycontact" size="30" maxlength="20" value="<?php echo $barangay->brgycontact->EditValue ?>"<?php echo $barangay->brgycontact->EditAttributes() ?>>
- </span><?php echo $barangay->brgycontact->CustomMsg ?></td>
- </tr>
- <?php } ?>
- <?php if ($barangay->cityid->Visible) { // cityid ?>
- <tr id="r_cityid"<?php echo $barangay->RowAttributes() ?>>
- <td class="ewTableHeader"><?php echo $barangay->cityid->FldCaption() ?><!-- Removed Required Field Indicator--></td>
- <td<?php echo $barangay->cityid->CellAttributes() ?>><span id="el_cityid">
- <select id="x_cityid" name="x_cityid"<?php echo $barangay->cityid->EditAttributes() ?>>
- <?php
- if (is_array($barangay->cityid->EditValue)) {
- $arwrk = $barangay->cityid->EditValue;
- $rowswrk = count($arwrk);
- $emptywrk = TRUE;
- for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
- $selwrk = (strval($barangay->cityid->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
- if ($selwrk <> "") $emptywrk = FALSE;
- ?>
- <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
- <?php echo $arwrk[$rowcntwrk][1] ?>
- </option>
- <?php
- }
- }
- ?>
- </select>
- </span><?php echo $barangay->cityid->CustomMsg ?></td>
- </tr>
- <?php } ?>
- <?php if ($barangay->districtid->Visible) { // districtid ?>
- <tr id="r_districtid"<?php echo $barangay->RowAttributes() ?>>
- <td class="ewTableHeader"><?php echo $barangay->districtid->FldCaption() ?><!-- Removed Required Field Indicator--></td>
- <td<?php echo $barangay->districtid->CellAttributes() ?>><span id="el_districtid">
- <select id="x_districtid" name="x_districtid"<?php echo $barangay->districtid->EditAttributes() ?>>
- <?php
- if (is_array($barangay->districtid->EditValue)) {
- $arwrk = $barangay->districtid->EditValue;
- $rowswrk = count($arwrk);
- $emptywrk = TRUE;
- for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
- $selwrk = (strval($barangay->districtid->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
- if ($selwrk <> "") $emptywrk = FALSE;
- ?>
- <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
- <?php echo $arwrk[$rowcntwrk][1] ?>
- </option>
- <?php
- }
- }
- ?>
- </select>
- </span><?php echo $barangay->districtid->CustomMsg ?></td>
- </tr>
- <?php } ?>
- <?php if ($barangay->brgylatitude->Visible) { // brgylatitude ?>
- <tr id="r_brgylatitude"<?php echo $barangay->RowAttributes() ?>>
- <td class="ewTableHeader"><?php echo $barangay->brgylatitude->FldCaption() ?><!-- Removed Required Field Indicator--></td>
- <td<?php echo $barangay->brgylatitude->CellAttributes() ?>><span id="el_brgylatitude">
- <input type="text" name="x_brgylatitude" id="x_brgylatitude" size="30" value="<?php echo $barangay->brgylatitude->EditValue ?>"<?php echo $barangay->brgylatitude->EditAttributes() ?>>
- </span><?php echo $barangay->brgylatitude->CustomMsg ?></td>
- </tr>
- <?php } ?>
- <?php if ($barangay->brgylongtitude->Visible) { // brgylongtitude ?>
- <tr id="r_brgylongtitude"<?php echo $barangay->RowAttributes() ?>>
- <td class="ewTableHeader"><?php echo $barangay->brgylongtitude->FldCaption() ?><!-- Removed Required Field Indicator--></td>
- <td<?php echo $barangay->brgylongtitude->CellAttributes() ?>><span id="el_brgylongtitude">
- <input type="text" name="x_brgylongtitude" id="x_brgylongtitude" size="30" value="<?php echo $barangay->brgylongtitude->EditValue ?>"<?php echo $barangay->brgylongtitude->EditAttributes() ?>>
- </span><?php echo $barangay->brgylongtitude->CustomMsg ?></td>
- </tr>
- <?php } ?>
- <?php if ($barangay->brgyaltitude->Visible) { // brgyaltitude ?>
- <tr id="r_brgyaltitude"<?php echo $barangay->RowAttributes() ?>>
- <td class="ewTableHeader"><?php echo $barangay->brgyaltitude->FldCaption() ?><!-- Removed Required Field Indicator--></td>
- <td<?php echo $barangay->brgyaltitude->CellAttributes() ?>><span id="el_brgyaltitude">
- <input type="text" name="x_brgyaltitude" id="x_brgyaltitude" size="30" value="<?php echo $barangay->brgyaltitude->EditValue ?>"<?php echo $barangay->brgyaltitude->EditAttributes() ?>>
- </span><?php echo $barangay->brgyaltitude->CustomMsg ?></td>
- </tr>
- <?php } ?>
-
- </table>
- </div>
- </td></tr></table>
- <input type="hidden" name="x_id" id="x_id" value="<?php echo ew_HtmlEncode($barangay->id->CurrentValue) ?>">
- <p>
- <input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("EditBtn")) ?>">
- </form>
- <?php
- $barangay_edit->ShowPageFooter();
- if (EW_DEBUG_ENABLED)
- echo ew_DebugMsg();
- ?>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your table-specific startup script here
- // document.write("page loaded");
- //-->
-
- </script>
- <?php include_once "footer.php" ?>
- <?php
- $barangay_edit->Page_Terminate();
- ?>
- <?php
-
- //
- // Page class
- //
- class cbarangay_edit {
-
- // Page ID
- var $PageID = 'edit';
-
- // Table name
- var $TableName = 'barangay';
-
- // Page object name
- var $PageObjName = 'barangay_edit';
-
- // Page name
- function PageName() {
- return ew_CurrentPage();
- }
-
- // Page URL
- function PageUrl() {
- $PageUrl = ew_CurrentPage() . "?";
- global $barangay;
- if ($barangay->UseTokenInUrl) $PageUrl .= "t=" . $barangay->TableVar . "&"; // Add page token
- return $PageUrl;
- }
-
- // Message
- function getMessage() {
- return @$_SESSION[EW_SESSION_MESSAGE];
- }
-
- function setMessage($v) {
- ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v);
- }
-
- function getFailureMessage() {
- return @$_SESSION[EW_SESSION_FAILURE_MESSAGE];
- }
-
- function setFailureMessage($v) {
- ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v);
- }
-
- function getSuccessMessage() {
- return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE];
- }
-
- function setSuccessMessage($v) {
- ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v);
- }
-
- // Show message
- function ShowMessage() {
- $sMessage = $this->getMessage();
- $this->Message_Showing($sMessage, "");
- if ($sMessage <> "") { // Message in Session, display
- echo "<p class=\"ewMessage\">" . $sMessage . "</p>";
- $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
- }
-
- // Success message
- $sSuccessMessage = $this->getSuccessMessage();
- $this->Message_Showing($sSuccessMessage, "success");
- if ($sSuccessMessage <> "") { // Message in Session, display
- echo "<p class=\"ewSuccessMessage\">" . $sSuccessMessage . "</p>";
- $_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
- }
-
- // Failure message
- $sErrorMessage = $this->getFailureMessage();
- $this->Message_Showing($sErrorMessage, "failure");
- if ($sErrorMessage <> "") { // Message in Session, display
- echo "<p class=\"ewErrorMessage\">" . $sErrorMessage . "</p>";
- $_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
- }
- }
- var $PageHeader;
- var $PageFooter;
-
- // Show Page Header
- function ShowPageHeader() {
- $sHeader = $this->PageHeader;
- $this->Page_DataRendering($sHeader);
- if ($sHeader <> "") { // Header exists, display
- echo "<p class=\"phpmaker\">" . $sHeader . "</p>";
- }
- }
-
- // Show Page Footer
- function ShowPageFooter() {
- $sFooter = $this->PageFooter;
- $this->Page_DataRendered($sFooter);
- if ($sFooter <> "") { // Fotoer exists, display
- echo "<p class=\"phpmaker\">" . $sFooter . "</p>";
- }
- }
-
- // Validate page request
- function IsPageRequest() {
- global $objForm, $barangay;
- if ($barangay->UseTokenInUrl) {
- if ($objForm)
- return ($barangay->TableVar == $objForm->GetValue("t"));
- if (@$_GET["t"] <> "")
- return ($barangay->TableVar == $_GET["t"]);
- } else {
- return TRUE;
- }
- }
-
- //
- // Page class constructor
- //
- function cbarangay_edit() {
- global $conn, $Language;
-
- // Language object
- if (!isset($Language)) $Language = new cLanguage();
-
- // Table object (barangay)
- if (!isset($GLOBALS["barangay"])) {
- $GLOBALS["barangay"] = new cbarangay();
- $GLOBALS["Table"] =& $GLOBALS["barangay"];
- }
-
- // Table object (user)
- if (!isset($GLOBALS['user'])) $GLOBALS['user'] = new cuser();
-
- // Page ID
- if (!defined("EW_PAGE_ID"))
- define("EW_PAGE_ID", 'edit', TRUE);
-
- // Table name (for backward compatibility)
- if (!defined("EW_TABLE_NAME"))
- define("EW_TABLE_NAME", 'barangay', TRUE);
-
- // Start timer
- if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer();
-
- // Open connection
- if (!isset($conn)) $conn = ew_Connect();
- }
-
- //
- // Page_Init
- //
- function Page_Init() {
- global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
- global $barangay;
-
- // Security
- $Security = new cAdvancedSecurity();
- if (!$Security->IsLoggedIn()) $Security->AutoLogin();
- if (!$Security->IsLoggedIn()) {
- $Security->SaveLastUrl();
- $this->Page_Terminate("login.php");
- }
- $Security->TablePermission_Loading();
- $Security->LoadCurrentUserLevel($this->TableName);
- $Security->TablePermission_Loaded();
- if (!$Security->IsLoggedIn()) {
- $Security->SaveLastUrl();
- $this->Page_Terminate("login.php");
- }
- if (!$Security->CanEdit()) {
- $Security->SaveLastUrl();
- $this->Page_Terminate("barangaylist.php");
- }
-
- // Create form object
- $objForm = new cFormObj();
-
- // Global Page Loading event (in userfn*.php)
- Page_Loading();
-
- // Page Load event
- $this->Page_Load();
- }
-
- //
- // Page_Terminate
- //
- function Page_Terminate($url = "") {
- global $conn;
-
- // Page Unload event
- $this->Page_Unload();
-
- // Global Page Unloaded event (in userfn*.php)
- Page_Unloaded();
- $this->Page_Redirecting($url);
-
- // Close connection
- $conn->Close();
-
- // Go to URL if specified
- if ($url <> "") {
- if (!EW_DEBUG_ENABLED && ob_get_length())
- ob_end_clean();
- header("Location: " . $url);
- }
- exit();
- }
- var $DbMasterFilter;
- var $DbDetailFilter;
-
- //
- // Page main
- //
- function Page_Main() {
- global $objForm, $Language, $gsFormError, $barangay;
-
- // Load key from QueryString
- if (@$_GET["id"] <> "")
- $barangay->id->setQueryStringValue($_GET["id"]);
- if (@$_POST["a_edit"] <> "") {
- $barangay->CurrentAction = $_POST["a_edit"]; // Get action code
- $this->LoadFormValues(); // Get form values
-
- // Validate form
- if (!$this->ValidateForm()) {
- $barangay->CurrentAction = ""; // Form error, reset action
- $this->setFailureMessage($gsFormError);
- $barangay->EventCancelled = TRUE; // Event cancelled
- $this->RestoreFormValues();
- }
- } else {
- $barangay->CurrentAction = "I"; // Default action is display
- }
-
- // Check if valid key
- if ($barangay->id->CurrentValue == "")
- $this->Page_Terminate("barangaylist.php"); // Invalid key, return to list
- switch ($barangay->CurrentAction) {
- case "I": // Get a record to display
- if (!$this->LoadRow()) { // Load record based on key
- $this->setFailureMessage($Language->Phrase("NoRecord")); // No record found
- $this->Page_Terminate("barangaylist.php"); // No matching record, return to list
- }
- break;
- Case "U": // Update
- $barangay->SendEmail = TRUE; // Send email on update success
- if ($this->EditRow()) { // Update record based on key
- $this->setSuccessMessage($Language->Phrase("UpdateSuccess")); // Update success
- $sReturnUrl = $barangay->getReturnUrl();
- if (ew_GetPageName($sReturnUrl) == "barangayview.php")
- $sReturnUrl = $barangay->ViewUrl(); // View paging, return to View page directly
- $this->Page_Terminate($sReturnUrl); // Return to caller
- } else {
- $barangay->EventCancelled = TRUE; // Event cancelled
- $this->RestoreFormValues(); // Restore form values if update failed
- }
- }
-
- // Render the record
- $barangay->RowType = EW_ROWTYPE_EDIT; // Render as Edit
- $barangay->ResetAttrs();
- $this->RenderRow();
- }
-
- // Get upload files
- function GetUploadFiles() {
- global $objForm, $barangay;
-
- // Get upload data
- $index = $objForm->Index; // Save form index
- $objForm->Index = 0;
- $confirmPage = (strval($objForm->GetValue("a_confirm")) <> "");
- $objForm->Index = $index; // Restore form index
- }
-
- // Load form values
- function LoadFormValues() {
-
- // Load from form
- global $objForm, $barangay;
- if (!$barangay->baranggay->FldIsDetailKey) {
- $barangay->baranggay->setFormValue($objForm->GetValue("x_baranggay"));
- }
- if (!$barangay->brgyaddress->FldIsDetailKey) {
- $barangay->brgyaddress->setFormValue($objForm->GetValue("x_brgyaddress"));
- }
- if (!$barangay->brgytelno->FldIsDetailKey) {
- $barangay->brgytelno->setFormValue($objForm->GetValue("x_brgytelno"));
- }
- if (!$barangay->brgycontact->FldIsDetailKey) {
- $barangay->brgycontact->setFormValue($objForm->GetValue("x_brgycontact"));
- }
- if (!$barangay->cityid->FldIsDetailKey) {
- $barangay->cityid->setFormValue($objForm->GetValue("x_cityid"));
- }
- if (!$barangay->districtid->FldIsDetailKey) {
- $barangay->districtid->setFormValue($objForm->GetValue("x_districtid"));
- }
- if (!$barangay->brgylatitude->FldIsDetailKey) {
- $barangay->brgylatitude->setFormValue($objForm->GetValue("x_brgylatitude"));
- }
- if (!$barangay->brgylongtitude->FldIsDetailKey) {
- $barangay->brgylongtitude->setFormValue($objForm->GetValue("x_brgylongtitude"));
- }
- if (!$barangay->brgyaltitude->FldIsDetailKey) {
- $barangay->brgyaltitude->setFormValue($objForm->GetValue("x_brgyaltitude"));
- }
- if (!$barangay->brgycode->FldIsDetailKey) {
- $barangay->brgycode->setFormValue($objForm->GetValue("x_brgycode"));
- }
- if (!$barangay->id->FldIsDetailKey)
- $barangay->id->setFormValue($objForm->GetValue("x_id"));
- }
-
- // Restore form values
- function RestoreFormValues() {
- global $objForm, $barangay;
- $this->LoadRow();
- $barangay->id->CurrentValue = $barangay->id->FormValue;
- $barangay->baranggay->CurrentValue = $barangay->baranggay->FormValue;
- $barangay->brgyaddress->CurrentValue = $barangay->brgyaddress->FormValue;
- $barangay->brgytelno->CurrentValue = $barangay->brgytelno->FormValue;
- $barangay->brgycontact->CurrentValue = $barangay->brgycontact->FormValue;
- $barangay->cityid->CurrentValue = $barangay->cityid->FormValue;
- $barangay->districtid->CurrentValue = $barangay->districtid->FormValue;
- $barangay->brgylatitude->CurrentValue = $barangay->brgylatitude->FormValue;
- $barangay->brgylongtitude->CurrentValue = $barangay->brgylongtitude->FormValue;
- $barangay->brgyaltitude->CurrentValue = $barangay->brgyaltitude->FormValue;
- $barangay->brgycode->CurrentValue = $barangay->brgycode->FormValue;
- }
-
- // Load row based on key values
- function LoadRow() {
- global $conn, $Security, $barangay;
- $sFilter = $barangay->KeyFilter();
-
- // Call Row Selecting event
- $barangay->Row_Selecting($sFilter);
-
- // Load SQL based on filter
- $barangay->CurrentFilter = $sFilter;
- $sSql = $barangay->SQL();
- $res = FALSE;
- $rs = ew_LoadRecordset($sSql);
- if ($rs && !$rs->EOF) {
- $res = TRUE;
- $this->LoadRowValues($rs); // Load row values
- $rs->Close();
- }
- return $res;
- }
-
- // Load row values from recordset
- function LoadRowValues(&$rs) {
- global $conn, $barangay;
- if (!$rs || $rs->EOF) return;
-
- // Call Row Selected event
- $row =& $rs->fields;
- $barangay->Row_Selected($row);
- $barangay->id->setDbValue($rs->fields('id'));
- $barangay->baranggay->setDbValue($rs->fields('baranggay'));
- $barangay->brgyaddress->setDbValue($rs->fields('brgyaddress'));
- $barangay->brgytelno->setDbValue($rs->fields('brgytelno'));
- $barangay->brgycontact->setDbValue($rs->fields('brgycontact'));
- $barangay->cityid->setDbValue($rs->fields('cityid'));
- $barangay->districtid->setDbValue($rs->fields('districtid'));
- $barangay->brgylatitude->setDbValue($rs->fields('brgylatitude'));
- $barangay->brgylongtitude->setDbValue($rs->fields('brgylongtitude'));
- $barangay->brgyaltitude->setDbValue($rs->fields('brgyaltitude'));
- $barangay->zuserid->setDbValue($rs->fields('userid'));
- $barangay->timestamp->setDbValue($rs->fields('timestamp'));
- $barangay->brgycode->setDbValue($rs->fields('brgycode'));
- }
-
- // Render row values based on field settings
- function RenderRow() {
- global $conn, $Security, $Language, $barangay;
-
- // Initialize URLs
- // Call Row_Rendering event
-
- $barangay->Row_Rendering();
-
- // Common render codes for all row types
- // id
- // baranggay
- // brgyaddress
- // brgytelno
- // brgycontact
- // cityid
- // districtid
- // brgylatitude
- // brgylongtitude
- // brgyaltitude
- // userid
- // timestamp
- // brgycode
-
- if ($barangay->RowType == EW_ROWTYPE_VIEW) { // View row
-
- // id
- $barangay->id->ViewValue = $barangay->id->CurrentValue;
- $barangay->id->ViewCustomAttributes = "";
-
- // baranggay
- $barangay->baranggay->ViewValue = $barangay->baranggay->CurrentValue;
- $barangay->baranggay->ViewCustomAttributes = "";
-
- // brgyaddress
- $barangay->brgyaddress->ViewValue = $barangay->brgyaddress->CurrentValue;
- $barangay->brgyaddress->ViewCustomAttributes = "";
-
- // brgytelno
- $barangay->brgytelno->ViewValue = $barangay->brgytelno->CurrentValue;
- $barangay->brgytelno->ViewCustomAttributes = "";
-
- // brgycontact
- $barangay->brgycontact->ViewValue = $barangay->brgycontact->CurrentValue;
- $barangay->brgycontact->ViewCustomAttributes = "";
-
- // cityid
- if (strval($barangay->cityid->CurrentValue) <> "") {
- $sFilterWrk = "`id` = " . ew_AdjustSql($barangay->cityid->CurrentValue) . "";
- $sSqlWrk = "SELECT `city` FROM `city`";
- $sWhereWrk = "";
- if ($sFilterWrk <> "") {
- if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
- $sWhereWrk .= "(" . $sFilterWrk . ")";
- }
- if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
- $rswrk = $conn->Execute($sSqlWrk);
- if ($rswrk && !$rswrk->EOF) { // Lookup values found
- $barangay->cityid->ViewValue = $rswrk->fields('city');
- $rswrk->Close();
- } else {
- $barangay->cityid->ViewValue = $barangay->cityid->CurrentValue;
- }
- } else {
- $barangay->cityid->ViewValue = NULL;
- }
- $barangay->cityid->ViewCustomAttributes = "";
-
- // districtid
- if (strval($barangay->districtid->CurrentValue) <> "") {
- $sFilterWrk = "`id` = " . ew_AdjustSql($barangay->districtid->CurrentValue) . "";
- $sSqlWrk = "SELECT `district` FROM `district`";
- $sWhereWrk = "";
- if ($sFilterWrk <> "") {
- if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
- $sWhereWrk .= "(" . $sFilterWrk . ")";
- }
- if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
- $rswrk = $conn->Execute($sSqlWrk);
- if ($rswrk && !$rswrk->EOF) { // Lookup values found
- $barangay->districtid->ViewValue = $rswrk->fields('district');
- $rswrk->Close();
- } else {
- $barangay->districtid->ViewValue = $barangay->districtid->CurrentValue;
- }
- } else {
- $barangay->districtid->ViewValue = NULL;
- }
- $barangay->districtid->ViewCustomAttributes = "";
-
- // brgylatitude
- $barangay->brgylatitude->ViewValue = $barangay->brgylatitude->CurrentValue;
- $barangay->brgylatitude->ViewCustomAttributes = "";
-
- // brgylongtitude
- $barangay->brgylongtitude->ViewValue = $barangay->brgylongtitude->CurrentValue;
- $barangay->brgylongtitude->ViewCustomAttributes = "";
-
- // brgyaltitude
- $barangay->brgyaltitude->ViewValue = $barangay->brgyaltitude->CurrentValue;
- $barangay->brgyaltitude->ViewCustomAttributes = "";
-
- // userid
- $barangay->zuserid->ViewValue = $barangay->zuserid->CurrentValue;
- $barangay->zuserid->ViewCustomAttributes = "";
-
- // timestamp
- $barangay->timestamp->ViewValue = $barangay->timestamp->CurrentValue;
- $barangay->timestamp->ViewValue = ew_FormatDateTime($barangay->timestamp->ViewValue, 9);
- $barangay->timestamp->ViewCustomAttributes = "";
-
- // brgycode
- $barangay->brgycode->ViewValue = $barangay->brgycode->CurrentValue;
- $barangay->brgycode->ViewCustomAttributes = "";
-
- // baranggay
- $barangay->baranggay->LinkCustomAttributes = "";
- $barangay->baranggay->HrefValue = "";
- $barangay->baranggay->TooltipValue = "";
-
- // brgyaddress
- $barangay->brgyaddress->LinkCustomAttributes = "";
- $barangay->brgyaddress->HrefValue = "";
- $barangay->brgyaddress->TooltipValue = "";
-
- // brgytelno
- $barangay->brgytelno->LinkCustomAttributes = "";
- $barangay->brgytelno->HrefValue = "";
- $barangay->brgytelno->TooltipValue = "";
-
- // brgycontact
- $barangay->brgycontact->LinkCustomAttributes = "";
- $barangay->brgycontact->HrefValue = "";
- $barangay->brgycontact->TooltipValue = "";
-
- // cityid
- $barangay->cityid->LinkCustomAttributes = "";
- $barangay->cityid->HrefValue = "";
- $barangay->cityid->TooltipValue = "";
-
- // districtid
- $barangay->districtid->LinkCustomAttributes = "";
- $barangay->districtid->HrefValue = "";
- $barangay->districtid->TooltipValue = "";
-
- // brgylatitude
- $barangay->brgylatitude->LinkCustomAttributes = "";
- $barangay->brgylatitude->HrefValue = "";
- $barangay->brgylatitude->TooltipValue = "";
-
- // brgylongtitude
- $barangay->brgylongtitude->LinkCustomAttributes = "";
- $barangay->brgylongtitude->HrefValue = "";
- $barangay->brgylongtitude->TooltipValue = "";
-
- // brgyaltitude
- $barangay->brgyaltitude->LinkCustomAttributes = "";
- $barangay->brgyaltitude->HrefValue = "";
- $barangay->brgyaltitude->TooltipValue = "";
-
- // brgycode
- $barangay->brgycode->LinkCustomAttributes = "";
- $barangay->brgycode->HrefValue = "";
- $barangay->brgycode->TooltipValue = "";
- } elseif ($barangay->RowType == EW_ROWTYPE_EDIT) { // Edit row
-
- // baranggay
- $barangay->baranggay->EditCustomAttributes = "";
- $barangay->baranggay->EditValue = ew_HtmlEncode($barangay->baranggay->CurrentValue);
-
- // brgyaddress
- $barangay->brgyaddress->EditCustomAttributes = "";
- $barangay->brgyaddress->EditValue = ew_HtmlEncode($barangay->brgyaddress->CurrentValue);
-
- // brgytelno
- $barangay->brgytelno->EditCustomAttributes = "";
- $barangay->brgytelno->EditValue = ew_HtmlEncode($barangay->brgytelno->CurrentValue);
-
- // brgycontact
- $barangay->brgycontact->EditCustomAttributes = "";
- $barangay->brgycontact->EditValue = ew_HtmlEncode($barangay->brgycontact->CurrentValue);
-
- // cityid
- $barangay->cityid->EditCustomAttributes = "";
- $sFilterWrk = "";
- $sSqlWrk = "SELECT `id`, `city` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld` FROM `city`";
- $sWhereWrk = "";
- if ($sFilterWrk <> "") {
- if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
- $sWhereWrk .= "(" . $sFilterWrk . ")";
- }
- if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
- $rswrk = $conn->Execute($sSqlWrk);
- $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
- if ($rswrk) $rswrk->Close();
- array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
- $barangay->cityid->EditValue = $arwrk;
-
- // districtid
- $barangay->districtid->EditCustomAttributes = "";
- $sFilterWrk = "";
- $sSqlWrk = "SELECT `id`, `district` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld` FROM `district`";
- $sWhereWrk = "";
- if ($sFilterWrk <> "") {
- if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
- $sWhereWrk .= "(" . $sFilterWrk . ")";
- }
- if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
- $rswrk = $conn->Execute($sSqlWrk);
- $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
- if ($rswrk) $rswrk->Close();
- array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
- $barangay->districtid->EditValue = $arwrk;
-
- // brgylatitude
- $barangay->brgylatitude->EditCustomAttributes = "";
- $barangay->brgylatitude->EditValue = ew_HtmlEncode($barangay->brgylatitude->CurrentValue);
-
- // brgylongtitude
- $barangay->brgylongtitude->EditCustomAttributes = "";
- $barangay->brgylongtitude->EditValue = ew_HtmlEncode($barangay->brgylongtitude->CurrentValue);
-
- // brgyaltitude
- $barangay->brgyaltitude->EditCustomAttributes = "";
- $barangay->brgyaltitude->EditValue = ew_HtmlEncode($barangay->brgyaltitude->CurrentValue);
-
- // brgycode
- $barangay->brgycode->EditCustomAttributes = "";
- $barangay->brgycode->EditValue = ew_HtmlEncode($barangay->brgycode->CurrentValue);
-
- // Edit refer script
- // baranggay
-
- $barangay->baranggay->HrefValue = "";
-
- // brgyaddress
- $barangay->brgyaddress->HrefValue = "";
-
- // brgytelno
- $barangay->brgytelno->HrefValue = "";
-
- // brgycontact
- $barangay->brgycontact->HrefValue = "";
-
- // cityid
- $barangay->cityid->HrefValue = "";
-
- // districtid
- $barangay->districtid->HrefValue = "";
-
- // brgylatitude
- $barangay->brgylatitude->HrefValue = "";
-
- // brgylongtitude
- $barangay->brgylongtitude->HrefValue = "";
-
- // brgyaltitude
- $barangay->brgyaltitude->HrefValue = "";
-
- // brgycode
- $barangay->brgycode->HrefValue = "";
- }
- if ($barangay->RowType == EW_ROWTYPE_ADD ||
- $barangay->RowType == EW_ROWTYPE_EDIT ||
- $barangay->RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
- $barangay->SetupFieldTitles();
- }
-
- // Call Row Rendered event
- if ($barangay->RowType <> EW_ROWTYPE_AGGREGATEINIT)
- $barangay->Row_Rendered();
- }
-
- // Validate form
- function ValidateForm() {
- global $Language, $gsFormError, $barangay;
-
- // Initialize form error message
- $gsFormError = "";
-
- // Check if validation required
- if (!EW_SERVER_VALIDATE)
- return ($gsFormError == "");
- if (!is_null($barangay->baranggay->FormValue) && $barangay->baranggay->FormValue == "") {
- ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $barangay->baranggay->FldCaption());
- }
- if (!is_null($barangay->brgyaddress->FormValue) && $barangay->brgyaddress->FormValue == "") {
- ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $barangay->brgyaddress->FldCaption());
- }
- if (!is_null($barangay->brgytelno->FormValue) && $barangay->brgytelno->FormValue == "") {
- ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $barangay->brgytelno->FldCaption());
- }
- if (!is_null($barangay->brgycontact->FormValue) && $barangay->brgycontact->FormValue == "") {
- ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $barangay->brgycontact->FldCaption());
- }
- if (!is_null($barangay->cityid->FormValue) && $barangay->cityid->FormValue == "") {
- ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $barangay->cityid->FldCaption());
- }
- if (!is_null($barangay->districtid->FormValue) && $barangay->districtid->FormValue == "") {
- ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $barangay->districtid->FldCaption());
- }
- if (!is_null($barangay->brgylatitude->FormValue) && $barangay->brgylatitude->FormValue == "") {
- ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $barangay->brgylatitude->FldCaption());
- }
- if (!ew_CheckNumber($barangay->brgylatitude->FormValue)) {
- ew_AddMessage($gsFormError, $barangay->brgylatitude->FldErrMsg());
- }
- if (!is_null($barangay->brgylongtitude->FormValue) && $barangay->brgylongtitude->FormValue == "") {
- ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $barangay->brgylongtitude->FldCaption());
- }
- if (!ew_CheckNumber($barangay->brgylongtitude->FormValue)) {
- ew_AddMessage($gsFormError, $barangay->brgylongtitude->FldErrMsg());
- }
- if (!is_null($barangay->brgyaltitude->FormValue) && $barangay->brgyaltitude->FormValue == "") {
- ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $barangay->brgyaltitude->FldCaption());
- }
- if (!ew_CheckNumber($barangay->brgyaltitude->FormValue)) {
- ew_AddMessage($gsFormError, $barangay->brgyaltitude->FldErrMsg());
- }
- if (!is_null($barangay->brgycode->FormValue) && $barangay->brgycode->FormValue == "") {
- ew_AddMessage($gsFormError, $Language->Phrase("EnterRequiredField") . " - " . $barangay->brgycode->FldCaption());
- }
- if (!ew_CheckInteger($barangay->brgycode->FormValue)) {
- ew_AddMessage($gsFormError, $barangay->brgycode->FldErrMsg());
- }
-
- // Return validate result
- $ValidateForm = ($gsFormError == "");
-
- // Call Form_CustomValidate event
- $sFormCustomError = "";
- $ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
- if ($sFormCustomError <> "") {
- ew_AddMessage($gsFormError, $sFormCustomError);
- }
- return $ValidateForm;
- }
-
- // Update record based on key values
- function EditRow() {
- global $conn, $Security, $Language, $barangay;
- $sFilter = $barangay->KeyFilter();
- $barangay->CurrentFilter = $sFilter;
- $sSql = $barangay->SQL();
- $conn->raiseErrorFn = 'ew_ErrorFn';
- $rs = $conn->Execute($sSql);
- $conn->raiseErrorFn = '';
- if ($rs === FALSE)
- return FALSE;
- if ($rs->EOF) {
- $EditRow = FALSE; // Update Failed
- } else {
-
- // Save old values
- $rsold =& $rs->fields;
- $rsnew = array();
-
- // baranggay
- $barangay->baranggay->SetDbValueDef($rsnew, $barangay->baranggay->CurrentValue, "", $barangay->baranggay->ReadOnly);
-
- // brgyaddress
- $barangay->brgyaddress->SetDbValueDef($rsnew, $barangay->brgyaddress->CurrentValue, "", $barangay->brgyaddress->ReadOnly);
-
- // brgytelno
- $barangay->brgytelno->SetDbValueDef($rsnew, $barangay->brgytelno->CurrentValue, "", $barangay->brgytelno->ReadOnly);
-
- // brgycontact
- $barangay->brgycontact->SetDbValueDef($rsnew, $barangay->brgycontact->CurrentValue, "", $barangay->brgycontact->ReadOnly);
-
- // cityid
- $barangay->cityid->SetDbValueDef($rsnew, $barangay->cityid->CurrentValue, 0, $barangay->cityid->ReadOnly);
-
- // districtid
- $barangay->districtid->SetDbValueDef($rsnew, $barangay->districtid->CurrentValue, 0, $barangay->districtid->ReadOnly);
-
- // brgylatitude
- $barangay->brgylatitude->SetDbValueDef($rsnew, $barangay->brgylatitude->CurrentValue, 0, $barangay->brgylatitude->ReadOnly);
-
- // brgylongtitude
- $barangay->brgylongtitude->SetDbValueDef($rsnew, $barangay->brgylongtitude->CurrentValue, 0, $barangay->brgylongtitude->ReadOnly);
-
- // brgyaltitude
- $barangay->brgyaltitude->SetDbValueDef($rsnew, $barangay->brgyaltitude->CurrentValue, 0, $barangay->brgyaltitude->ReadOnly);
-
- // brgycode
- $barangay->brgycode->SetDbValueDef($rsnew, $barangay->brgycode->CurrentValue, 0, $barangay->brgycode->ReadOnly);
-
- // Call Row Updating event
- $bUpdateRow = $barangay->Row_Updating($rsold, $rsnew);
- if ($bUpdateRow) {
- $conn->raiseErrorFn = 'ew_ErrorFn';
- if (count($rsnew) > 0)
- $EditRow = $conn->Execute($barangay->UpdateSQL($rsnew));
- else
- $EditRow = TRUE; // No field to update
- $conn->raiseErrorFn = '';
- } else {
- if ($barangay->CancelMessage <> "") {
- $this->setFailureMessage($barangay->CancelMessage);
- $barangay->CancelMessage = "";
- } else {
- $this->setFailureMessage($Language->Phrase("UpdateCancelled"));
- }
- $EditRow = FALSE;
- }
- }
-
- // Call Row_Updated event
- if ($EditRow)
- $barangay->Row_Updated($rsold, $rsnew);
- if ($EditRow) {
- $this->WriteAuditTrailOnEdit($rsold, $rsnew);
- }
- $rs->Close();
- return $EditRow;
- }
- // Write Audit Trail start/end for grid update
- function WriteAuditTrailDummy($typ) {
- $table = 'barangay';
- $usr = CurrentUserName();
- ew_WriteAuditTrail("log", ew_StdCurrentDateTime(), ew_ScriptName(), $usr, $typ, $table, "", "", "", "");
- }
-
- // Write Audit Trail (edit page)
- function WriteAuditTrailOnEdit(&$rsold, &$rsnew) {
- global $barangay;
- $table = 'barangay';
-
- // Get key value
- $key = "";
- if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
- $key .= $rsold['id'];
-
- // Write Audit Trail
- $dt = ew_StdCurrentDateTime();
- $id = ew_ScriptName();
- $usr = CurrentUserName();
- foreach (array_keys($rsnew) as $fldname) {
- if ($barangay->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore BLOB fields
- if ($barangay->fields[$fldname]->FldDataType == EW_DATATYPE_DATE) { // DateTime field
- $modified = (ew_FormatDateTime($rsold[$fldname], 0) <> ew_FormatDateTime($rsnew[$fldname], 0));
- } else {
- $modified = !ew_CompareValue($rsold[$fldname], $rsnew[$fldname]);
- }
- if ($modified) {
- if ($barangay->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // Memo field
- if (EW_AUDIT_TRAIL_TO_DATABASE) {
- $oldvalue = $rsold[$fldname];
- $newvalue = $rsnew[$fldname];
- } else {
- $oldvalue = "[MEMO]";
- $newvalue = "[MEMO]";
- }
- } elseif ($barangay->fields[$fldname]->FldDataType == EW_DATATYPE_XML) { // XML field
- $oldvalue = "[XML]";
- $newvalue = "[XML]";
- } else {
- $oldvalue = $rsold[$fldname];
- $newvalue = $rsnew[$fldname];
- }
- ew_WriteAuditTrail("log", $dt, $id, $usr, "U", $table, $fldname, $key, $oldvalue, $newvalue);
- }
- }
- }
- }
- // Page Load event
- function Page_Load() {
-
- //echo "Page Load";
- }
-
- // Page Unload event
- function Page_Unload() {
-
- //echo "Page Unload";
- }
-
- // Page Redirecting event
- function Page_Redirecting(&$url) {
-
- // Example:
- //$url = "your URL";
-
- }
-
- // Message Showing event
- // $type = ''|'success'|'failure'
- function Message_Showing(&$msg, $type) {
-
- // Example:
- //if ($type == 'success') $msg = "your success message";
-
- }
-
- // Page Data Rendering event
- function Page_DataRendering(&$header) {
-
- // Example:
- //$header = "your header";
-
- }
-
- // Page Data Rendered event
- function Page_DataRendered(&$footer) {
-
- // Example:
- //$footer = "your footer";
-
- }
-
- // Form Custom Validate event
- function Form_CustomValidate(&$CustomError) {
-
- // Return error message in CustomError
- return TRUE;
- }
- }
- ?>