示例#1
0
文件: AFSEncode.php 项目: armic/erpts
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $AFSDetails = new SoapObject(NCCBIZ . "AFSDetails.php", "urn:Object");
             if (!($xmlStr = $AFSDetails->getAFS($this->formArray["afsID"]))) {
                 echo "xml failed";
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                     $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
                 } else {
                     $afs = new AFS();
                     $afs->parseDomAFS($domDoc);
                     foreach ($afs as $key => $value) {
                         $this->formArray[$key] = $value;
                     }
                     //print_r($afs);
                     //exit();
                     $administrator = $afs->getAdministratorArray();
                     foreach ($administrator as $key => $value) {
                         $this->formArray["lastName"] = $value->getLastName();
                         $this->formArray["firstName"] = $value->getFirstName();
                         $this->formArray["middleName"] = $value->getMiddleName();
                         $this->formArray["number"] = $value->getNumber();
                         $this->formArray["street"] = $value->getStreet();
                         $this->formArray["barangay"] = $value->getBarangay();
                         $this->formArray["district"] = $value->getDistrict();
                         $this->formArray["municipalityCity"] = $value->getMunicipalityCity();
                         $this->formArray["province"] = $value->getProvince();
                         $this->formArray["telephone"] = $value->getTelephone();
                     }
                 }
             }
             break;
         case "save":
             $AFSEncode = new SoapObject(NCCBIZ . "AFSEncode.php", "urn:Object");
             if ($this->formArray["afsID"] != "") {
                 $afs = new AFS();
                 $afs->selectAFS($this->formArray["afsID"]);
                 $afs->setOdID($this->formArray["odID"]);
                 $afs->setPropertyIndexNumber($this->formArray["propertyIndexNumber"]);
                 $afs->setCertificateOfTitleNumber($this->formArray["certificateOfTitleNumber"]);
                 $afs->setCadastralLotNumber($this->formArray["cadastralLotNumber"]);
                 $afs->setNorth($this->formArray["north"]);
                 $afs->setSouth($this->formArray["south"]);
                 $afs->setEast($this->formArray["east"]);
                 $afs->setWest($this->formArray["west"]);
                 $afs->setCreatedBy($this->userID);
                 $afs->setModifiedBy($this->userID);
                 $person = new Person();
                 $person->setPersonID($afs->getAdministrator());
                 $person->setLastName($this->formArray["lastName"]);
                 $person->setFirstName($this->formArray["firstName"]);
                 $person->setMiddleName($this->formArray["middleName"]);
                 $person->setNumber($this->formArray["number"]);
                 $person->setStreet($this->formArray["street"]);
                 $person->setBarangay($this->formArray["barangay"]);
                 $person->setDistrict($this->formArray["district"]);
                 $person->setMunicipalityCity($this->formArray["municipalityCity"]);
                 $person->setProvince($this->formArray["province"]);
                 $person->setTelephone($this->formArray["telephone"]);
                 $person->setDom();
                 $afs->setAdministratorArray($person);
                 $afs->setDomAFS();
                 $doc = $afs->getDomAFS();
                 $xmlStr = $doc->dump_mem();
                 if (!($ret = $AFSEncode->updateAFS($xmlStr))) {
                     echo "error update";
                 }
                 header("location: AFSClose.php" . $this->sess->url("") . $this->sess->add_query(array("odID" => $ret)));
                 exit;
             } else {
                 $afs = new AFS();
                 $afs->setOdID($this->formArray["odID"]);
                 $afs->setPropertyIndexNumber($this->formArray["propertyIndexNumber"]);
                 $afs->setCertificateOfTitleNumber($this->formArray["certificateOfTitleNumber"]);
                 $afs->setCadastralLotNumber($this->formArray["cadastralLotNumber"]);
                 $afs->setNorth($this->formArray["north"]);
                 $afs->setSouth($this->formArray["south"]);
                 $afs->setEast($this->formArray["east"]);
                 $afs->setWest($this->formArray["west"]);
                 $afs->setCreatedBy($this->userID);
                 $afs->setModifiedBy($this->userID);
                 $adminAddress = new Address();
                 $adminAddress->setNumber($this->formArray["number"]);
                 $adminAddress->setStreet($this->formArray["street"]);
                 $adminAddress->setBarangay($this->formArray["barangay"]);
                 $adminAddress->setDistrict($this->formArray["district"]);
                 $adminAddress->setMunicipalityCity($this->formArray["municipalityCity"]);
                 $adminAddress->setProvince($this->formArray["province"]);
                 $adminAddress->setDomDocument();
                 $person = new Person();
                 $person->setLastName($this->formArray["lastName"]);
                 $person->setFirstName($this->formArray["firstName"]);
                 $person->setMiddleName($this->formArray["middleName"]);
                 $person->setTelephone($this->formArray["telephone"]);
                 $person->setDomDocument();
                 $afs->setAdministratorArray($person);
                 $afs->setDomDocument();
                 $doc = $afs->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $AFSEncode->saveAFS($xmlStr))) {
                     echo "ret=" . $ret;
                 }
                 $this->formArray["afsID"] = $ret;
                 header("location: AFSClose.php" . $this->sess->url("") . $this->sess->add_query(array("afsID" => $ret)));
                 exit;
             }
             break;
         case "cancel":
             header("location: AFSList.php");
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "odID", "odIDBlock");
             $this->tpl->set_var("odIDBlock", "");
             $this->tpl->set_block("rptsTemplate", "ACK", "ACKBlock");
             $this->tpl->set_var("ACKBlock", "");
     }
     $this->setForm();
     $this->tpl->set_var("Session", $this->sess->url("") . $this->sess->add_query(array("odID" => $this->formArray["odID"], "ownerID" => $this->formArray["ownerID"])));
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "save":
             $AFSDetails = new SoapObject(NCCBIZ . "AFSDetails.php", "urn:Object");
             if (!($xmlStr = $AFSDetails->getAFS($this->formArray["afsID"]))) {
                 exit("error xml");
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     exit("error domDoc");
                 } else {
                     $AFSEncode = new SoapObject(NCCBIZ . "AFSEncode.php", "urn:Object");
                     $afs = new AFS();
                     $afs->parseDomDocument($domDoc);
                     $afs->setArpNumber($this->formArray["arpNumber"]);
                     $afs->setCadastralLotNumber($this->formArray["cadastralLotNumber"]);
                     // convert $pointsArray to $gisTechnicalDescription string
                     // separate each point with "-" and each pointRecord with ","
                     $pointsArray = $this->formArray["pointsArray"];
                     $pointID = 1;
                     if (is_array($pointsArray)) {
                         for ($pointID = 1; $pointID <= count($pointsArray); $pointID++) {
                             $pointArray = array($pointID, $pointsArray[$pointID]["pointType"], $pointsArray[$pointID]["quadrant"], $pointsArray[$pointID]["bearingDeg"], $pointsArray[$pointID]["bearingMin"], $pointsArray[$pointID]["distance"]);
                             $pointString = implode("-", $pointArray);
                             $gisTechDescArray[$pointID] = $pointString;
                         }
                         $gisTechnicalDescription = implode(",", $gisTechDescArray);
                         $this->formArray["gisTechnicalDescription"] = $gisTechnicalDescription;
                     }
                     $afs->setGISTechnicalDescription($this->formArray["gisTechnicalDescription"]);
                     $afs->setDomDocument();
                     $doc = $afs->getDomDocument();
                     $xmlStr = $doc->dump_mem(true);
                     if (!($ret = $AFSEncode->updateAFS($xmlStr))) {
                         exit("error update");
                     }
                 }
             }
             header("location: GISTechnicalDescriptionClose.php" . $this->sess->url("") . $this->sess->add_query(array("afsID" => $this->formArray["afsID"])));
             exit;
             break;
         case "del":
             // temporarily del points
             $delPointsArray = $this->formArray["pointsArray"];
             $pointID = 1;
             if (is_array($delPointsArray)) {
                 for ($delPointID = 1; $delPointID <= count($delPointsArray); $delPointID++) {
                     if ($delPointID != $this->formArray["delPointID"]) {
                         $pointsArray[$pointID]["pointType"] = $delPointsArray[$delPointID]["pointType"];
                         $pointsArray[$pointID]["quadrant"] = $delPointsArray[$delPointID]["quadrant"];
                         $pointsArray[$pointID]["bearingDeg"] = $delPointsArray[$delPointID]["bearingDeg"];
                         $pointsArray[$pointID]["bearingMin"] = $delPointsArray[$delPointID]["bearingMin"];
                         $pointsArray[$pointID]["distance"] = $delPointsArray[$delPointID]["distance"];
                         $pointID++;
                     }
                 }
                 if (is_array($pointsArray)) {
                     $this->tpl->set_block("rptsTemplate", "PointsList", "PointsListBlock");
                     for ($pointID = 1; $pointID <= count($pointsArray); $pointID++) {
                         $this->tpl->set_var("pointID", $pointID);
                         $this->tpl->set_var("pointType", $pointsArray[$pointID]["pointType"]);
                         $this->tpl->set_var("quadrant", $pointsArray[$pointID]["quadrant"]);
                         $this->tpl->set_var("bearingDeg", $pointsArray[$pointID]["bearingDeg"]);
                         $this->tpl->set_var("bearingMin", $pointsArray[$pointID]["bearingMin"]);
                         $this->tpl->set_var("distance", $pointsArray[$pointID]["distance"]);
                         $this->tpl->parse("PointsListBlock", "PointsList", true);
                     }
                     $this->formArray["pointsExist"] = "true";
                 } else {
                     $this->formArray["pointsExist"] = "false";
                     $this->hideBlock("PointsList");
                 }
             }
             break;
         case "add":
             // temporarily add points
             $pointsArray = $this->formArray["pointsArray"];
             $pointID = 1;
             if (is_array($pointsArray)) {
                 $this->tpl->set_block("rptsTemplate", "PointsList", "PointsListBlock");
                 for ($pointID = 1; $pointID <= count($pointsArray); $pointID++) {
                     $this->tpl->set_var("pointID", $pointID);
                     $this->tpl->set_var("pointType", $pointsArray[$pointID]["pointType"]);
                     $this->tpl->set_var("quadrant", $pointsArray[$pointID]["quadrant"]);
                     $this->tpl->set_var("bearingDeg", $pointsArray[$pointID]["bearingDeg"]);
                     $this->tpl->set_var("bearingMin", $pointsArray[$pointID]["bearingMin"]);
                     $this->tpl->set_var("distance", $pointsArray[$pointID]["distance"]);
                     $this->tpl->parse("PointsListBlock", "PointsList", true);
                 }
                 $pointsArray[$pointID]["pointType"] = $this->formArray["pointType"];
                 $pointsArray[$pointID]["quadrant"] = $this->formArray["quadrant"];
                 $pointsArray[$pointID]["bearingDeg"] = $this->formArray["bearingDeg"];
                 $pointsArray[$pointID]["bearingMin"] = $this->formArray["bearingMin"];
                 $pointsArray[$pointID]["distance"] = $this->formArray["distance"];
                 $this->tpl->set_var("pointID", $pointID);
                 $this->tpl->set_var("pointType", $pointsArray[$pointID]["pointType"]);
                 $this->tpl->set_var("quadrant", $pointsArray[$pointID]["quadrant"]);
                 $this->tpl->set_var("bearingDeg", $pointsArray[$pointID]["bearingDeg"]);
                 $this->tpl->set_var("bearingMin", $pointsArray[$pointID]["bearingMin"]);
                 $this->tpl->set_var("distance", $pointsArray[$pointID]["distance"]);
                 $this->tpl->parse("PointsListBlock", "PointsList", true);
             } else {
                 $pointsArray[$pointID]["pointType"] = $this->formArray["pointType"];
                 $pointsArray[$pointID]["quadrant"] = $this->formArray["quadrant"];
                 $pointsArray[$pointID]["bearingDeg"] = $this->formArray["bearingDeg"];
                 $pointsArray[$pointID]["bearingMin"] = $this->formArray["bearingMin"];
                 $pointsArray[$pointID]["distance"] = $this->formArray["distance"];
                 $this->tpl->set_block("rptsTemplate", "PointsList", "PointsListBlock");
                 $this->tpl->set_var("pointID", $pointID);
                 $this->tpl->set_var("pointType", $pointsArray[$pointID]["pointType"]);
                 $this->tpl->set_var("quadrant", $pointsArray[$pointID]["quadrant"]);
                 $this->tpl->set_var("bearingDeg", $pointsArray[$pointID]["bearingDeg"]);
                 $this->tpl->set_var("bearingMin", $pointsArray[$pointID]["bearingMin"]);
                 $this->tpl->set_var("distance", $pointsArray[$pointID]["distance"]);
                 $this->tpl->parse("PointsListBlock", "PointsList", true);
             }
             $this->formArray["pointsExist"] = "true";
             break;
         default:
             $AFSDetails = new SoapObject(NCCBIZ . "AFSDetails.php", "urn:Object");
             $AFSDetails = new SoapObject(NCCBIZ . "AFSDetails.php", "urn:Object");
             if (!($xmlStr = $AFSDetails->getAFS($this->formArray["afsID"]))) {
                 exit("error xml");
             } else {
                 //echo $xmlStr;
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     exit("error domDoc");
                 } else {
                     $afs = new AFS();
                     $afs->parseDomDocument($domDoc);
                     $this->formArray["afsID"] = $afs->getAfsID();
                     $this->formArray["cadastralLotNumber"] = $afs->getCadastralLotNumber();
                     $this->formArray["gisTechnicalDescription"] = $afs->getGISTechnicalDescription();
                     if ($this->formArray["gisTechnicalDescription"] == "") {
                         $this->formArray["pointsExist"] = "false";
                         $this->hideBlock("PointsList");
                     } else {
                         $this->formArray["pointsExist"] = "true";
                         // parse gisTechnicalDescription into $pointsArray
                         // separate each pointRecord at "," and each point at "-"
                         $gisTechDescArray = explode(",", $this->formArray["gisTechnicalDescription"]);
                         foreach ($gisTechDescArray as $pointString) {
                             $pointArray = explode("-", $pointString);
                             $pointID = $pointArray[0];
                             $pointsArray[$pointID]["pointType"] = $pointArray[1];
                             $pointsArray[$pointID]["quadrant"] = $pointArray[2];
                             $pointsArray[$pointID]["bearingDeg"] = $pointArray[3];
                             $pointsArray[$pointID]["bearingMin"] = $pointArray[4];
                             $pointsArray[$pointID]["distance"] = $pointArray[5];
                         }
                         if (is_array($pointsArray)) {
                             $this->tpl->set_block("rptsTemplate", "PointsList", "PointsListBlock");
                             for ($pointID = 1; $pointID <= count($pointsArray); $pointID++) {
                                 $this->tpl->set_var("pointID", $pointID);
                                 $this->tpl->set_var("pointType", $pointsArray[$pointID]["pointType"]);
                                 $this->tpl->set_var("quadrant", $pointsArray[$pointID]["quadrant"]);
                                 $this->tpl->set_var("bearingDeg", $pointsArray[$pointID]["bearingDeg"]);
                                 $this->tpl->set_var("bearingMin", $pointsArray[$pointID]["bearingMin"]);
                                 $this->tpl->set_var("distance", $pointsArray[$pointID]["distance"]);
                                 $this->tpl->parse("PointsListBlock", "PointsList", true);
                             }
                         }
                     }
                 }
             }
             break;
     }
     $this->setForm();
     $this->tpl->set_var("Session", $this->sess->url("") . $this->sess->add_query(array("afsID" => $this->formArray["afsID"])));
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }