Exemplo n.º 1
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $this->tpl->set_var("MessageBlock", "");
             $LandActualUsesDetails = new SoapObject(NCCBIZ . "LandActualUsesDetails.php", "urn:Object");
             if (!($xmlStr = $LandActualUsesDetails->getLandActualUsesDetails($this->formArray["landActualUsesID"]))) {
                 $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 {
                     $landActualUses = new LandActualUses();
                     $landActualUses->parseDomDocument($domDoc);
                     $this->formArray["landActualUsesID"] = $landActualUses->getLandActualUsesID();
                     $this->formArray["code"] = $landActualUses->getCode();
                     $this->formArray["reportCode"] = $landActualUses->getReportCode();
                     $this->formArray["description"] = $landActualUses->getDescription();
                     $this->formArray["value"] = $landActualUses->getValue();
                     $this->formArray["status"] = $landActualUses->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", "");
             }
             $LandActualUsesEncode = new SoapObject(NCCBIZ . "LandActualUsesEncode.php", "urn:Object");
             if ($this->formArray["landActualUsesID"] != "") {
                 $LandActualUsesDetails = new SoapObject(NCCBIZ . "LandActualUsesDetails.php", "urn:Object");
                 if (!($xmlStr = $LandActualUsesDetails->getLandActualUsesDetails($this->formArray["landActualUsesID"]))) {
                     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 {
                         $landActualUses = new LandActualUses();
                         $landActualUses->parseDomDocument($domDoc);
                         $landActualUses->setLandActualUsesID($this->formArray["landActualUsesID"]);
                         $landActualUses->setCode($this->formArray["code"]);
                         $landActualUses->setReportCode($this->formArray["reportCode"]);
                         $landActualUses->setDescription($this->formArray["description"]);
                         $landActualUses->setValue($this->formArray["value"]);
                         $landActualUses->setStatus($this->formArray["status"]);
                         $landActualUses->setDomDocument();
                         $doc = $landActualUses->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $LandActualUsesEncode->updateLandActualUses($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $landActualUses = new LandActualUses();
                 $landActualUses->setLandActualUsesID($this->formArray["landActualUsesID"]);
                 $landActualUses->setCode($this->formArray["code"]);
                 $landActualUses->setReportCode($this->formArray["reportCode"]);
                 $landActualUses->setDescription($this->formArray["description"]);
                 $landActualUses->setValue($this->formArray["value"]);
                 $landActualUses->setStatus($this->formArray["status"]);
                 $landActualUses->setDomDocument();
                 $doc = $landActualUses->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $LandActualUsesEncode->saveLandActualUses($xmlStr))) {
                     exit("error save");
                 }
             }
             $this->formArray["landActualUsesID"] = $ret;
             header("location: LandActualUsesClose.php" . $this->sess->url("") . $this->sess->add_query(array("landActualUsesID" => $ret)));
             //header("location: LandActualUsesEncode.php");
             exit;
             break;
         case "cancel":
             header("location: LandActualUsesClose.php" . $this->sess->url("") . $this->sess->add_query(array("landActualUsesID" => $ret)));
             //header("location: LandActualUsesList.php");
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "LandActualUsesID", "LandActualUsesIDBlock");
             $this->tpl->set_var("LandActualUsesIDBlock", "");
             $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");
 }