示例#1
0
 function updateBarangay($xmlStr)
 {
     if (!($domDoc = domxml_open_mem($xmlStr))) {
         return false;
     }
     $barangay = new Barangay();
     $barangay->parseDomDocument($domDoc);
     $ret = $barangay->updateRecord();
     return $ret;
 }
示例#2
0
 function getBarangayDetails($barangayID)
 {
     $barangay = new Barangay();
     $barangay->selectRecord($barangayID);
     if (!($domDoc = $barangay->getDomDocument())) {
         return false;
     } else {
         $xmlStr = $domDoc->dump_mem(true);
         return $xmlStr;
     }
 }
示例#3
0
 function getBarangay()
 {
     $barangay = new Barangay();
     $barangay->selectRecord($this->formArray["barangayID"]);
     $this->formArray["barangay"] = $barangay->getDescription();
 }
示例#4
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         // ajax method
         case "confirmAjax":
             // buildup odID list and print in template as hidden variables
             $this->tpl->set_block("rptsTemplate", "Run", "RunBlock");
             $this->tpl->set_var("RunBlock", "");
             $this->tpl->set_block("rptsTemplate", "Done", "DoneBlock");
             $this->tpl->set_var("DoneBlock", "");
             $this->tpl->set_block("rptsTemplate", "BarangayForm", "BarangayFormBlock");
             $this->tpl->set_var("BarangayFormBlock", "");
             $this->tpl->set_block("rptsTemplate", "AjaxBarangayForm", "AjaxBarangayFormBlock");
             $this->tpl->set_var("AjaxBarangayFormBlock", "");
             $this->tpl->set_block("rptsTemplate", "ConventionalConfirm", "ConventionalConfirmBlock");
             $this->tpl->set_var("ConventionalConfirmBlock", "");
             $barangay = new Barangay();
             $barangay->selectRecord($this->formArray["barangayID"]);
             $this->tpl->set_var("barangayID", $this->formArray["barangayID"]);
             $this->tpl->set_var("barangay", $barangay->getDescription());
             $message = "Run General Revision for this barangay?";
             $this->tpl->set_var("message", $message);
             // get latestActiveRPUs for the barangay
             $latestActiveRPUs = $this->getLatestActiveRPUsByBarangay($this->formArray["barangayID"]);
             $this->tpl->set_var("latestActiveRPUs", number_format($latestActiveRPUs));
             $this->tpl->set_var("countBackDays", $this->formArray["countBackDays"]);
             $this->tpl->set_var("countBackDaysTimeStr", $this->formArray["countBackDaysTimeStr"]);
             $this->tpl->set_var("userID", $this->userID);
             break;
             // old-school method
         // old-school method
         case "run":
             $this->tpl->set_block("rptsTemplate", "Page", "PageBlock");
             $this->tpl->set_var("PageBlock", "");
             $this->formArray["timerStart"] = date("F d, Y h:i:s A", strtotime("now"));
             $this->run($this->formArray["barangayID"]);
             if ($this->formArray["totalCreated"] == 0) {
                 $this->formArray["message"] = "There were no RPUs generated through General Revision for this barangay.";
             } else {
                 $this->formArray["message"] = "General Revision successfully generated for this barangay!";
             }
             $this->tpl->set_var("barangayID", $this->formArray["barangayID"]);
             $this->tpl->set_var("message", $this->formArray["message"]);
             $this->tpl->set_var("totalArchived", $this->formArray["totalArchived"]);
             $this->tpl->set_var("totalCreated", $this->formArray["totalCreated"]);
             $this->tpl->set_var("timerStart", $this->formArray["timerStart"]);
             $this->tpl->set_var("timerEnd", $this->formArray["timerEnd"]);
             $this->tpl->set_var("progressLog", $this->formArray["progressLog"]);
             break;
         case "done":
             $this->tpl->set_block("rptsTemplate", "Run", "RunBlock");
             $this->tpl->set_var("RunBlock", "");
             $this->tpl->set_block("rptsTemplate", "Confirm", "ConfirmBlock");
             $this->tpl->set_var("ConfirmBlock", "");
             $this->tpl->set_block("rptsTemplate", "BarangayForm", "BarangayFormBlock");
             $this->tpl->set_var("BarangayFormBlock", "");
             $this->tpl->set_block("rptsTemplate", "AjaxBarangayForm", "AjaxBarangayFormBlock");
             $this->tpl->set_var("AjaxBarangayFormBlock", "");
             $this->tpl->set_block("rptsTemplate", "AjaxConfirm", "AjaxConfirmBlock");
             $this->tpl->set_var("AjaxConfirmBlock", "");
             $this->tpl->set_var("progressLog", $this->formArray["progressLog"]);
             if ($this->formArray["timerEnd"] == "") {
                 $this->formArray["timerEnd"] = date("F d, Y h:i:s A", strtotime("now"));
             }
             $duration = strtotime($this->formArray["timerEnd"]) - strtotime($this->formArray["timerStart"]);
             $duration_minutes = floor($duration / 60);
             $duration_seconds = $duration % 60;
             $this->tpl->set_var("duration", $duration_minutes . "mins " . $duration_seconds . "s");
             $this->tpl->set_var("timerStart", date("g:i:s a", strtotime($this->formArray["timerStart"])));
             $this->tpl->set_var("timerEnd", date("g:i:s a", strtotime($this->formArray["timerEnd"])));
             $barangay = new Barangay();
             $barangay->selectRecord($this->formArray["barangayID"]);
             $this->tpl->set_var("barangayID", $this->formArray["barangayID"]);
             $this->tpl->set_var("barangay", $barangay->getDescription());
             $this->tpl->set_var("totalArchived", $this->formArray["totalArchived"]);
             $this->tpl->set_var("totalCreated", $this->formArray["totalCreated"]);
             $this->tpl->set_var("message", $this->formArray["message"]);
             break;
         case "confirm":
             $this->tpl->set_block("rptsTemplate", "Run", "RunBlock");
             $this->tpl->set_var("RunBlock", "");
             $this->tpl->set_block("rptsTemplate", "Done", "DoneBlock");
             $this->tpl->set_var("DoneBlock", "");
             $this->tpl->set_block("rptsTemplate", "BarangayForm", "BarangayFormBlock");
             $this->tpl->set_var("BarangayFormBlock", "");
             $this->tpl->set_block("rptsTemplate", "AjaxBarangayForm", "AjaxBarangayFormBlock");
             $this->tpl->set_var("AjaxBarangayFormBlock", "");
             $this->tpl->set_block("rptsTemplate", "AjaxConfirm", "AjaxConfirmBlock");
             $this->tpl->set_var("AjaxConfirmBlock", "");
             $barangay = new Barangay();
             $barangay->selectRecord($this->formArray["barangayID"]);
             $this->tpl->set_var("barangayID", $this->formArray["barangayID"]);
             $this->tpl->set_var("barangay", $barangay->getDescription());
             $message = "Run General Revision for this barangay?";
             $this->tpl->set_var("message", $message);
             // get latestActiveRPUs for the barangay
             $latestActiveRPUs = $this->getLatestActiveRPUsByBarangay($this->formArray["barangayID"]);
             $this->tpl->set_var("latestActiveRPUs", number_format($latestActiveRPUs));
             $this->tpl->set_var("countBackDays", $this->formArray["countBackDays"]);
             $this->tpl->set_var("countBackDaysTimeStr", $this->formArray["countBackDaysTimeStr"]);
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "Run", "RunBlock");
             $this->tpl->set_var("RunBlock", "");
             $this->tpl->set_block("rptsTemplate", "Confirm", "ConfirmBlock");
             $this->tpl->set_var("ConfirmBlock", "");
             $this->tpl->set_block("rptsTemplate", "AjaxConfirm", "AjaxConfirmBlock");
             $this->tpl->set_var("AjaxConfirmBlock", "");
             $this->tpl->set_block("rptsTemplate", "Done", "DoneBlock");
             $this->tpl->set_var("DoneBlock", "");
             // display barangay list
             $this->initBarangayList();
             $message = "Select a Barangay";
             $this->tpl->set_var("message", $message);
             $this->tpl->set_var("countBackDays", $this->countBackDays);
             $this->tpl->set_var("countBackDaysTimeStr", $this->countBackDaysTimeStr);
             break;
     }
     $this->tpl->set_var("Session", $this->sess->url(""));
     $this->tpl->set_var("uname", $this->user["uname"]);
     $this->tpl->set_var("today", date("F j, Y"));
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }
示例#5
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $this->tpl->set_var("MessageBlock", "");
             $BarangayDetails = new SoapObject(NCCBIZ . "BarangayDetails.php", "urn:Object");
             if (!($xmlStr = $BarangayDetails->getBarangayDetails($this->formArray["barangayID"]))) {
                 $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                 $this->tpl->set_var("TableBlock", "record not found");
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                     $this->tpl->set_var("TableBlock", "error xmlDoc");
                 } else {
                     $barangay = new Barangay();
                     $barangay->parseDomDocument($domDoc);
                     $this->formArray["barangayID"] = $barangay->getBarangayID();
                     $this->formArray["code"] = $barangay->getCode();
                     $this->formArray["districtID"] = $barangay->getDistrictID();
                     $this->formArray["description"] = $barangay->getDescription();
                     $this->formArray["status"] = $barangay->getStatus();
                 }
             }
             break;
         case "save":
             if ($this->codeAlreadyExists() == true) {
                 $this->message = "Error. Cannot Save. Code already exists.";
                 $this->tpl->set_var("message", $this->message);
                 $this->tpl->parse("MessageBlock", "Message", true);
                 break;
             } else {
                 $this->tpl->set_var("MessageBlock", "");
             }
             $BarangayEncode = new SoapObject(NCCBIZ . "BarangayEncode.php", "urn:Object");
             if ($this->formArray["barangayID"] != "") {
                 $BarangayDetails = new SoapObject(NCCBIZ . "BarangayDetails.php", "urn:Object");
                 if (!($xmlStr = $BarangayDetails->getBarangayDetails($this->formArray["barangayID"]))) {
                     exit("record not found");
                 } else {
                     if (!($domDoc = domxml_open_mem($xmlStr))) {
                         $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                         $this->tpl->set_var("TableBlock", "error xmlDoc");
                     } else {
                         $barangay = new Barangay();
                         $barangay->parseDomDocument($domDoc);
                         $barangay->setBarangayID($this->formArray["barangayID"]);
                         $barangay->setCode($this->formArray["code"]);
                         $barangay->setDistrictID($this->formArray["districtID"]);
                         $barangay->setDescription($this->formArray["description"]);
                         $barangay->setStatus($this->formArray["status"]);
                         $barangay->setDomDocument();
                         $doc = $barangay->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         //echo htmlentities($xmlStr);
                         //exit;
                         if (!($ret = $BarangayEncode->updateBarangay($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $barangay = new Barangay();
                 $barangay->setBarangayID($this->formArray["barangayID"]);
                 $barangay->setCode($this->formArray["code"]);
                 $barangay->setDistrictID($this->formArray["districtID"]);
                 $barangay->setDescription($this->formArray["description"]);
                 $barangay->setStatus($this->formArray["status"]);
                 $barangay->setDomDocument();
                 $doc = $barangay->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $BarangayEncode->saveBarangay($xmlStr))) {
                     exit("error save");
                 }
             }
             $this->formArray["barangayID"] = $ret;
             header("location: BarangayClose.php" . $this->sess->url("") . $this->sess->add_query(array("barangayID" => $ret)));
             //header("location: BarangayEncode.php?".$this->sess->name."=".$this->sess->id."&barangayID=".$ret.".&formAction=edit");
             exit($ret);
             break;
         case "cancel":
             //header("location: BarangayList.php??".$this->sess->name."=".$this->sess->id."&barangayID=".$ret.".&formAction=edit");
             header("location: BarangayClose.php" . $this->sess->url("") . $this->sess->add_query(array("barangayID" => $ret)));
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "BarangayID", "BarangayIDBlock");
             $this->tpl->set_var("BarangayIDBlock", "");
             $this->tpl->set_block("rptsTemplate", "ACK", "ACKBlock");
             $this->tpl->set_var("ACKBlock", "");
             $this->tpl->set_var("MessageBlock", "");
     }
     $this->setForm();
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }