Ejemplo n.º 1
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $this->tpl->set_var("MessageBlock", "");
             $LandClassesDetails = new SoapObject(NCCBIZ . "LandClassesDetails.php", "urn:Object");
             if (!($xmlStr = $LandClassesDetails->getLandClassesDetails($this->formArray["landClassesID"]))) {
                 $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 {
                     $landClasses = new LandClasses();
                     $landClasses->parseDomDocument($domDoc);
                     $this->formArray["landClassesID"] = $landClasses->getLandClassesID();
                     $this->formArray["code"] = $landClasses->getCode();
                     $this->formArray["description"] = $landClasses->getDescription();
                     $this->formArray["value"] = $landClasses->getValue();
                     $this->formArray["status"] = $landClasses->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", "");
             }
             $LandClassesEncode = new SoapObject(NCCBIZ . "LandClassesEncode.php", "urn:Object");
             if ($this->formArray["landClassesID"] != "") {
                 $LandClassesDetails = new SoapObject(NCCBIZ . "LandClassesDetails.php", "urn:Object");
                 if (!($xmlStr = $LandClassesDetails->getLandClassesDetails($this->formArray["landClassesID"]))) {
                     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 {
                         $landClasses = new LandClasses();
                         $landClasses->parseDomDocument($domDoc);
                         $landClasses->setLandClassesID($this->formArray["landClassesID"]);
                         $landClasses->setCode($this->formArray["code"]);
                         $landClasses->setDescription($this->formArray["description"]);
                         $landClasses->setValue($this->formArray["value"]);
                         $landClasses->setStatus($this->formArray["status"]);
                         $landClasses->setDomDocument();
                         $doc = $landClasses->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $LandClassesEncode->updateLandClasses($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $landClasses = new LandClasses();
                 $landClasses->setLandClassesID($this->formArray["landClassesID"]);
                 $landClasses->setCode($this->formArray["code"]);
                 $landClasses->setDescription($this->formArray["description"]);
                 $landClasses->setValue($this->formArray["value"]);
                 $landClasses->setStatus($this->formArray["status"]);
                 $landClasses->setDomDocument();
                 $doc = $landClasses->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $LandClassesEncode->saveLandClasses($xmlStr))) {
                     exit("error save");
                 }
             }
             $this->formArray["landClassesID"] = $ret;
             header("location: LandClassesClose.php" . $this->sess->url("") . $this->sess->add_query(array("landClassesID" => $ret)));
             // header("location: LandClassesEncode.php");
             exit;
             break;
         case "cancel":
             header("location: LandClassesClose.php" . $this->sess->url("") . $this->sess->add_query(array("landClassesID" => $ret)));
             //header("location: LandClassesList.php");
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "LandClassesID", "LandClassesIDBlock");
             $this->tpl->set_var("LandClassesIDBlock", "");
             $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");
 }