Beispiel #1
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $this->tpl->set_var("MessageBlock", "");
             $MunicipalityCityDetails = new SoapObject(NCCBIZ . "MunicipalityCityDetails.php", "urn:Object");
             if (!($xmlStr = $MunicipalityCityDetails->getMunicipalityCityDetails($this->formArray["municipalityCityID"]))) {
                 $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 {
                     $municipalityCity = new MunicipalityCity();
                     $municipalityCity->parseDomDocument($domDoc);
                     $this->formArray["municipalityCityID"] = $municipalityCity->getMunicipalityCityID();
                     $this->formArray["code"] = $municipalityCity->getCode();
                     $this->formArray["provinceID"] = $municipalityCity->getProvinceID();
                     $this->formArray["description"] = $municipalityCity->getDescription();
                     $this->formArray["status"] = $municipalityCity->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", "");
             }
             $MunicipalityCityEncode = new SoapObject(NCCBIZ . "MunicipalityCityEncode.php", "urn:Object");
             if ($this->formArray["municipalityCityID"] != "") {
                 $MunicipalityCityDetails = new SoapObject(NCCBIZ . "MunicipalityCityDetails.php", "urn:Object");
                 if (!($xmlStr = $MunicipalityCityDetails->getMunicipalityCityDetails($this->formArray["municipalityCityID"]))) {
                     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 {
                         $municipalityCity = new MunicipalityCity();
                         $municipalityCity->parseDomDocument($domDoc);
                         $municipalityCity->setMunicipalityCityID($this->formArray["municipalityCityID"]);
                         $municipalityCity->setCode($this->formArray["code"]);
                         $municipalityCity->setProvinceID($this->formArray["provinceID"]);
                         $municipalityCity->setDescription($this->formArray["description"]);
                         $municipalityCity->setStatus($this->formArray["status"]);
                         $municipalityCity->setDomDocument();
                         $doc = $municipalityCity->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $MunicipalityCityEncode->updateMunicipalityCity($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $municipalityCity = new MunicipalityCity();
                 $municipalityCity->setMunicipalityCityID($this->formArray["municipalityCityID"]);
                 $municipalityCity->setCode($this->formArray["code"]);
                 $municipalityCity->setProvinceID($this->formArray["provinceID"]);
                 $municipalityCity->setDescription($this->formArray["description"]);
                 $municipalityCity->setStatus($this->formArray["status"]);
                 $municipalityCity->setDomDocument();
                 $doc = $municipalityCity->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $MunicipalityCityEncode->saveMunicipalityCity($xmlStr))) {
                     exit("error save");
                 }
             }
             $this->formArray["municipalityCityID"] = $ret;
             header("location: MunicipalityCityClose.php" . $this->sess->url("") . $this->sess->add_query(array("municipalityCityID" => $ret)));
             //header("location: MunicipalityCityEncode.php?".$this->sess->name."=".$this->sess->id."&municipalityCityID=".$ret.".&formAction=edit");
             exit;
             break;
         case "cancel":
             header("location: MunicipalityCityClose.php" . $this->sess->url("") . $this->sess->add_query(array("municipalityCityID" => $ret)));
             //header("location: MunicipalityCityList.php?".$this->sess->name."=".$this->sess->id."&municipalityCityID=".$ret.".&formAction=edit");
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "MunicipalityCityID", "MunicipalityCityIDBlock");
             $this->tpl->set_var("MunicipalityCityIDBlock", "");
             $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");
 }