Ejemplo n.º 1
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $this->tpl->set_var("MessageBlock", "");
             $ProvinceDetails = new SoapObject(NCCBIZ . "ProvinceDetails.php", "urn:Object");
             if (!($xmlStr = $ProvinceDetails->getProvinceDetails($this->formArray["provinceID"]))) {
                 $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 {
                     $province = new Province();
                     $province->parseDomDocument($domDoc);
                     $this->formArray["provinceID"] = $province->getProvinceID();
                     $this->formArray["code"] = $province->getCode();
                     $this->formArray["description"] = $province->getDescription();
                     $this->formArray["status"] = $province->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", "");
             }
             $ProvinceEncode = new SoapObject(NCCBIZ . "ProvinceEncode.php", "urn:Object");
             if ($this->formArray["provinceID"] != "") {
                 $ProvinceDetails = new SoapObject(NCCBIZ . "ProvinceDetails.php", "urn:Object");
                 if (!($xmlStr = $ProvinceDetails->getProvinceDetails($this->formArray["provinceID"]))) {
                     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 {
                         $province = new Province();
                         $province->parseDomDocument($domDoc);
                         $province->setProvinceID($this->formArray["provinceID"]);
                         $province->setCode($this->formArray["code"]);
                         $province->setDescription($this->formArray["description"]);
                         $province->setStatus($this->formArray["status"]);
                         $province->setDomDocument();
                         $doc = $province->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $ProvinceEncode->updateProvince($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $province = new Province();
                 $province->setProvinceID($this->formArray["provinceID"]);
                 $province->setCode($this->formArray["code"]);
                 $province->setDescription($this->formArray["description"]);
                 $province->setStatus($this->formArray["status"]);
                 $province->setDomDocument();
                 $doc = $province->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $ProvinceEncode->saveProvince($xmlStr))) {
                     exit("error save");
                 }
             }
             $this->formArray["provinceID"] = $ret;
             header("location: ProvinceClose.php" . $this->sess->url("") . $this->sess->add_query(array("provinceID" => $ret)));
             //header("location: ProvinceEncode.php");
             exit;
             break;
         case "cancel":
             header("location: ProvinceClose.php" . $this->sess->url("") . $this->sess->add_query(array("provinceID" => $ret)));
             //header("location: ProvinceList.php");
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "ProvinceID", "ProvinceIDBlock");
             $this->tpl->set_var("ProvinceIDBlock", "");
             $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");
 }