function Main() { switch ($this->formArray["formAction"]) { case "edit": $CompanyDetails = new SoapObject(NCCBIZ . "CompanyDetails.php", "urn:Object"); if (!($xmlStr = $CompanyDetails->getCompanyDetails($this->formArray["companyID"]))) { $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 { $company = new Company(); $company->parseDomDocument($domDoc); $this->formArray["companyID"] = $company->getCompanyID(); $this->formArray["companyName"] = $company->getCompanyName(); $this->formArray["tin"] = $company->getTin(); $this->formArray["telephone"] = $company->getTelephone(); $this->formArray["fax"] = $company->getFax(); $address = $company->addressArray[0]; if (is_a($address, Address)) { $this->formArray["addressID"] = $address->getAddressID(); $this->formArray["number"] = $address->getNumber(); $this->formArray["street"] = $address->getStreet(); $this->formArray["barangay"] = $address->getBarangay(); $this->formArray["district"] = $address->getDistrict(); $this->formArray["municipalityCity"] = $address->getMunicipalitycity(); $this->formArray["province"] = $address->getProvince(); } $this->formArray["email"] = $company->getEmail(); $this->formArray["website"] = $company->getWebsite(); } } break; case "save": $CompanyEncode = new SoapObject(NCCBIZ . "CompanyEncode.php", "urn:Object"); if ($this->formArray["companyID"] != "") { $CompanyDetails = new SoapObject(NCCBIZ . "CompanyDetails.php", "urn:Object"); if (!($xmlStr = $CompanyDetails->getCompanyDetails($this->formArray["companyID"]))) { $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 { $company = new Company(); $company->parseDomDocument($domDoc); $address = $company->addressArray[0]; if (is_a($address, Address)) { $address->setAddressID($this->formArray["addressID"]); $address->setNumber($this->formArray["number"]); $address->setStreet($this->formArray["street"]); $address->setBarangay($this->formArray["barangay"]); $address->setDistrict($this->formArray["district"]); $address->setMunicipalityCity($this->formArray["municipalityCity"]); $address->setProvince($this->formArray["province"]); $address->setDomDocument(); } //$company->selectRecord($this->formArray["companyID"]); $company->setCompanyID($this->formArray["companyID"]); $company->setCompanyName($this->formArray["companyName"]); $company->setTin($this->formArray["tin"]); $company->setTelephone($this->formArray["telephone"]); $company->setFax($this->formArray["fax"]); $company->setAddressArray($address); $company->setEmail($this->formArray["email"]); $company->setWebsite($this->formArray["website"]); $company->setDomDocument(); $doc = $company->getDomDocument(); $xmlStr = $doc->dump_mem(true); if (!($ret = $CompanyEncode->updateCompany($xmlStr))) { exit("error update"); } } } } else { $address = new Address(); $address->setNumber($this->formArray["number"]); $address->setStreet($this->formArray["street"]); $address->setBarangay($this->formArray["barangay"]); $address->setDistrict($this->formArray["district"]); $address->setMunicipalityCity($this->formArray["municipalityCity"]); $address->setProvince($this->formArray["province"]); $address->setDomDocument(); $company = new Company(); $company->setCompanyID($this->formArray["companyID"]); $company->setCompanyName($this->formArray["companyName"]); $company->setTelephone($this->formArray["telephone"]); $company->setFax($this->formArray["fax"]); $company->setTin($this->formArray["tin"]); $company->setAddressArray($address); $company->setEmail($this->formArray["email"]); $company->setWebsite($this->formArray["website"]); $company->setDomDocument(); $doc = $company->getDomDocument(); $xmlStr = $doc->dump_mem(true); if (!($ret = $CompanyEncode->saveCompany($xmlStr, $this->formArray["ownerID"]))) { exit("error save"); } } $this->formArray["companyID"] = $ret; //echo $ret; //} header("location: CompanyClose.php?parentURL=" . urlencode($this->formArray["parentURL"])); exit; //*/ //else echo "tumpak!"; break; case "cancel": header("location: CompanyList.php"); exit; break; default: if ($this->formArray["locID"]) { $ODDetails = new SoapObject(NCCBIZ . "ODDetails.php", "urn:Object"); if (!($xmlStr = $ODDetails->getLocation($this->formArray["locID"]))) { exit("xml failed"); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { } else { $loc = new LocationAddress(); $loc->parseDomDocument($domDoc); foreach ($loc as $key => $value) { $this->formArray[$key] = $value; } } } } $this->tpl->set_block("rptsTemplate", "companyID", "companyIDBlock"); $this->tpl->set_var("companyIDBlock", ""); $this->tpl->set_block("rptsTemplate", "ACK", "ACKBlock"); $this->tpl->set_var("ACKBlock", ""); } //*/ $this->setForm(); $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); }
function parseDomDocument($domDoc) { //echo "<br>parsing<br>"; $ret = true; if (is_object($domDoc)) { $baseNode = $domDoc->document_element(); if ($baseNode->has_child_nodes()) { $child = $baseNode->first_child(); while ($child) { //echo "parse->".$child->tagname."<br>"; switch ($child->tagname) { case "ownerArray": //echo "owner<br>"; $ownerNode = $child->first_child(); while ($ownerNode) { //if ($ownerNode->tagname=="Owner") { if ($ownerNode->tagname) { $tempXmlStr = $domDoc->dump_node($ownerNode); $tempDomDoc = domxml_open_mem($tempXmlStr); $owner = new Owner(); $ret = $owner->parseDomDocument($tempDomDoc); $this->owner = $owner; } $ownerNode = $ownerNode->next_sibling(); } break; case "locationAddressArray": //echo "locationAddress<br>"; $locationAddressNode = $child->first_child(); while ($locationAddressNode) { //if ($locationAddressNode->tagname=="locationAddress") { if ($locationAddressNode->tagname) { $tempXmlStr = $domDoc->dump_node($locationAddressNode); $tempDomDoc = domxml_open_mem($tempXmlStr); $locationAddress = new LocationAddress(); $ret = $locationAddress->parseDomDocument($tempDomDoc); $this->locationAddress = $locationAddress; } $locationAddressNode = $locationAddressNode->next_sibling(); } break; case "oldODArray": $oldODNode = $child->first_child(); while ($oldODNode) { if ($oldODNode->tagname) { $this->oldODArray[] = html_entity_decode($oldODNode->get_content()); } $oldODNode = $oldODNode->next_sibling(); } break; default: //eval("\$this->".$child->tagname."= \"".$child->get_content()."\";"); // test varvars $varvar = $child->tagname; $trans = array_flip(get_html_translation_table(HTML_ENTITIES)); $childContent = strtr(html_entity_decode($child->get_content()), $trans); $this->{$varvar} = html_entity_decode($childContent); //$this->$varvar = html_entity_decode($child->get_content()); } $child = $child->next_sibling(); } } $this->setDomDocument(); $ret = true; } else { $ret = false; } return $ret; }
function Main() { switch ($this->formArray["formAction"]) { case "edit": $PersonDetails = new SoapObject(NCCBIZ . "PersonDetails.php", "urn:Object"); if (!($xmlStr = $PersonDetails->getPersonDetails($this->formArray["personID"]))) { $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 { $person = new Person(); $person->parseDomDocument($domDoc); list($dateArr["year"], $dateArr["month"], $dateArr["day"]) = explode("-", $person->getBirthday()); $this->formArray["personID"] = $person->getPersonID(); $this->formArray["lastName"] = $person->getLastName(); $this->formArray["firstName"] = $person->getFirstName(); $this->formArray["middleName"] = $person->getMiddleName(); $this->formArray["gender"] = $person->getGender(); $this->formArray["birth_year"] = removePreZero($dateArr["year"]); $this->formArray["birth_month"] = removePreZero($dateArr["month"]); $this->formArray["birth_day"] = removePreZero($dateArr["day"]); $this->formArray["maritalStatus"] = $person->getMaritalStatus(); $this->formArray["tin"] = $person->getTin(); $address = $person->addressArray[0]; if (is_a($address, Address)) { $this->formArray["addressID"] = $address->getAddressID(); $this->formArray["number"] = $address->getNumber(); $this->formArray["street"] = $address->getStreet(); $this->formArray["barangay"] = $address->getBarangay(); $this->formArray["district"] = $address->getDistrict(); $this->formArray["municipalityCity"] = $address->getMunicipalitycity(); $this->formArray["province"] = $address->getProvince(); } $this->formArray["telephone"] = $person->getTelephone(); $this->formArray["mobileNumber"] = $person->getMobileNumber(); $this->formArray["email"] = $person->getEmail(); } } break; case "save": $PersonEncode = new SoapObject(NCCBIZ . "PersonEncode.php", "urn:Object"); if ($this->formArray["personID"] != "") { $PersonDetails = new SoapObject(NCCBIZ . "PersonDetails.php", "urn:Object"); if (!($xmlStr = $PersonDetails->getPersonDetails($this->formArray["personID"]))) { $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 { $person = new Person(); $person->parseDomDocument($domDoc); $address = $person->addressArray[0]; if (is_a($address, Address)) { $address->setAddressID($this->formArray["addressID"]); $address->setNumber($this->formArray["number"]); $address->setStreet($this->formArray["street"]); $address->setBarangay($this->formArray["barangay"]); $address->setDistrict($this->formArray["district"]); $address->setMunicipalityCity($this->formArray["municipalityCity"]); $address->setProvince($this->formArray["province"]); $address->setDomDocument(); } $person->setPersonID($this->formArray["personID"]); $person->setLastName($this->formArray["lastName"]); $person->setFirstName($this->formArray["firstName"]); $person->setMiddleName($this->formArray["middleName"]); $person->setGender($this->formArray["gender"]); $person->setBirthday($this->birthdate); $person->setMaritalStatus($this->formArray["maritalStatus"]); $person->setTin($this->formArray["tin"]); $person->setAddressArray($address); $person->setTelephone($this->formArray["telephone"]); $person->setMobileNumber($this->formArray["mobileNumber"]); $person->setEmail($this->formArray["email"]); $person->setDomDocument(); $doc = $person->getDomDocument(); $xmlStr = $doc->dump_mem(true); if (!($ret = $PersonEncode->updatePerson($xmlStr))) { exit("error update"); } } } } else { $address = new Address(); $address->setNumber($this->formArray["number"]); $address->setStreet($this->formArray["street"]); $address->setBarangay($this->formArray["barangay"]); $address->setDistrict($this->formArray["district"]); $address->setMunicipalityCity($this->formArray["municipalityCity"]); $address->setProvince($this->formArray["province"]); $address->setDomDocument(); $person = new Person(); $person->setPersonID($this->formArray["personID"]); $person->setLastName($this->formArray["lastName"]); $person->setFirstName($this->formArray["firstName"]); $person->setMiddleName($this->formArray["middleName"]); $person->setGender($this->formArray["gender"]); $person->setBirthday($this->birthdate); $person->setMaritalStatus($this->formArray["maritalStatus"]); $person->setTin($this->formArray["tin"]); $person->setAddressArray($address); $person->setTelephone($this->formArray["telephone"]); $person->setMobileNumber($this->formArray["mobileNumber"]); $person->setEmail($this->formArray["email"]); $person->setDomDocument(); $doc = $person->getDomDocument(); $xmlStr = $doc->dump_mem(true); //echo $this->formArray["ownerID"].$xmlStr; if (!($ret = $PersonEncode->savePerson($xmlStr, $this->formArray["ownerID"]))) { exit("error save"); } } $this->formArray["personID"] = $ret; header("location: ChangeOfOwnershipPropertyInfoClose.php" . $this->sess->url("") . $this->sess->add_query(array("odID" => $this->formArray["odID"], "personID" => $ret, "formAction" => "view"))); exit; break; case "cancel": header("location: PersonList.php"); exit; break; default: if ($this->formArray["locID"]) { $ODDetails = new SoapObject(NCCBIZ . "ODDetails.php", "urn:Object"); if (!($xmlStr = $ODDetails->getLocation($this->formArray["locID"]))) { exit("xml failed"); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { } else { $loc = new LocationAddress(); $loc->parseDomDocument($domDoc); foreach ($loc as $key => $value) { $this->formArray[$key] = $value; } } } } $this->tpl->set_block("rptsTemplate", "personID", "personIDBlock"); $this->tpl->set_var("personIDBlock", ""); $this->tpl->set_block("rptsTemplate", "ACK", "ACKBlock"); $this->tpl->set_var("ACKBlock", ""); } $this->setForm(); $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); }