function Main() { switch ($this->formArray["formAction"]) { case "edit": $ODDetails = new SoapObject(NCCBIZ . "ODDetails.php", "urn:Object"); if (!($xmlStr = $ODDetails->getOD($this->formArray["odID"]))) { exit("xml failed"); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock"); $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc"); } else { $od = new OD(); $od->parseDomDocument($domDoc); foreach ($od as $key => $value) { if ($key == "locationAddress" && is_object($value)) { foreach ($value as $lkey => $lvalue) { $this->formArray[$lkey] = $lvalue; } } else { $this->formArray[$key] = $value; } } $ODEncode = new SoapObject(NCCBIZ . "ODEncode.php", "urn:Object"); $this->formArray["ownerID"] = $ODEncode->getOwnerID($this->formArray["odID"]); $OwnerList = new SoapObject(NCCBIZ . "OwnerList.php", "urn:Object"); if (!($xmlStr = $OwnerList->getOwnerList($this->formArray["ownerID"]))) { //exit(print_r($OwnerList)); $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock"); $this->tpl->set_var("OwnerListTableBlock", ""); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock"); $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc"); } else { } } } } break; case "save": $PropertyInfoEncode = new SoapObject(NCCBIZ . "PropertyInfoEncode.php", "urn:Object"); if ($this->formArray["odID"] != "") { if (!($xmlStr = $PropertyInfoEncode->getPropertyInfoDetails($this->formArray["odID"]))) { $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 { $od = new OD(); $od->parseDomDocument($domDoc); $locationAddress = $od->locationAddress; if (is_a($locationAddress, LocationAddress)) { $locationAddress->setLocationAddressID($this->formArray["locationAddressID"]); $locationAddress->setNumber($this->formArray["number"]); $locationAddress->setStreet($this->formArray["street"]); $locationAddress->setBarangay($this->formArray["barangay"]); $locationAddress->setDistrict($this->formArray["district"]); $locationAddress->setMunicipalityCity($this->formArray["municipalityCity"]); $locationAddress->setProvince($this->formArray["province"]); $locationAddress->setDomDocument(); } $od->setOdID($this->formArray["odID"]); $od->setlocationAddress($locationAddress); $od->setHouseTagNumber($this->formArray["houseTagNumber"]); $od->setLandArea($this->formArray["landArea"]); $od->setLotNumber($this->formArray["lotNumber"]); $od->setZoneNumber($this->formArray["zoneNumber"]); $od->setBlockNumber($this->formArray["blockNumber"]); $od->setPsd13($this->formArray["psd13"]); $od->setAffidavitOfOwnership($this->formArray["affidavitOfOwnership"]); $od->setBarangayCertificate($this->formArray["barangayCertificate"]); $od->setLandTagging($this->formArray["landTagging"]); $od->setCreatedBy($this->userID); $od->setModifiedBy($this->userID); $od->setDomDocument(); $doc = $od->getDomDocument(); $xmlStr = $doc->dump_mem(true); if (!($ret = $PropertyInfoEncode->updatePropertyInfo($xmlStr))) { echo "error update"; } header("location: PropertyInfoClose.php" . $this->sess->url("") . $this->sess->add_query(array("odID" => $ret))); exit; } } } else { $locationAddress = new LocationAddress(); $locationAddress->setNumber($this->formArray["number"]); $locationAddress->setStreet($this->formArray["street"]); $locationAddress->setBarangay($this->formArray["barangay"]); $locationAddress->setDistrict($this->formArray["district"]); $locationAddress->setMunicipalityCity($this->formArray["municipalityCity"]); $locationAddress->setProvince($this->formArray["province"]); $locationAddress->setDomDocument(); $od = new OD(); $od->setlocationAddress($locationAddress); $od->setHouseTagNumber($this->formArray["houseTagNumber"]); $od->setLandArea($this->formArray["landArea"]); $od->setLotNumber($this->formArray["lotNumber"]); $od->setZoneNumber($this->formArray["zoneNumber"]); $od->setBlockNumber($this->formArray["blockNumber"]); $od->setPsd13($this->formArray["psd13"]); $od->setAffidavitOfOwnership($this->formArray["affidavitOfOwnership"]); $od->setBarangayCertificate($this->formArray["barangayCertificate"]); $od->setLandTagging($this->formArray["landTagging"]); $od->setCreatedBy($this->userID); $od->setModifiedBy($this->userID); $od->setTransactionCode($this->formArray["transactionCode"]); $od->setDomDocument(); //echo hello; $doc = $od->getDomDocument(); $xmlStr = $doc->dump_mem(true); if (!($ret = $PropertyInfoEncode->savePropertyInfo($xmlStr))) { //echo("ret=".$ret); } $this->formArray["odID"] = $ret; header("location: PropertyInfoClose.php" . $this->sess->url("") . $this->sess->add_query(array("odID" => $ret))); //echo $PropertyInfoEncode->getPropertyInfoDetails($ret); exit($ret); } break; case "cancel": header("location: PropertyInfoList.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 CreateNewRPU_AFS_TD($odID, $userID = "", $transactionCode = "", $copyOwner = true, $copyAFS = true, $copyTD = false) { $od = new OD(); $od->selectRecord($odID); unset($od->oldODArray); $od->setTransactionCode($transactionCode); $od->setOldODArray($odID); // create new OD $ownerID = $od->owner->getOwnerID(); $newOdID = $od->insertRecord(); $newOwnerID = $od->newOwnerID; $od->setDomDocument(); // associate existing Owner to new OD $owner = new Owner(); $owner->selectRecord($ownerID); if (count($owner->personArray)) { foreach ($owner->personArray as $personKey => $personValue) { if ($copyOwner) { $owner->insertOwnerPerson($newOwnerID, $personValue->getPersonID()); } } } if (count($owner->companyArray)) { foreach ($owner->companyArray as $companyKey => $companyValue) { if ($copyOwner) { $owner->insertOwnerCompany($newOwnerID, $companyValue->getCompanyID()); } } } // create new AFS and associate existing properties to new AFS $afs = new AFS(); $afsID = $afs->checkAfsID($odID); $afs->selectRecord($afsID); $afs->setOdID($newOdID); $afs->effectivity = date("Y") + 1; // new arpNumber is blank $afs->arpNumber = ""; // retain PIN except for Consolidation and Subdivision if ($transactionCode == "SD" || $transactionCode == "CS") { $afs->propertyIndexNumber = ""; } $afs->setDomDocument(); if ($copyAFS) { $newAfsID = $afs->insertRecord(); if (count($afs->landArray)) { foreach ($afs->landArray as $landKey => $landValue) { $landValue->setPropertyID(""); $landValue->setAfsID($newAfsID); if (is_object($landValue->propertyAdministrator)) { $landValue->propertyAdministrator->setPersonID(""); } else { $landValue->propertyAdministrator = new Person(); $landValue->propertyAdministrator->setPersonID(""); } // set unitValue from SubClass $landSubclasses = new LandSubclasses(); $landSubclasses->selectRecord(intVal($landValue->subClass)); $landValue->setUnitValue($landSubclasses->getValue()); // set assessmentLevel from ActualUse $landActualUses = new LandActualUses(); $landActualUses->selectRecord(intVal($landValue->actualUse)); $landValue->setAssessmentLevel($landActualUses->getValue()); $landValue->calculateMarketValue(); $landValue->calculateValueAdjustment(); $landValue->calculateAdjustedMarketValue(); $landValue->calculateAssessedValue(); $newP = $landValue->insertRecord(); } } if (count($afs->plantsTreesArray)) { foreach ($afs->plantsTreesArray as $plantsTreesKey => $plantsTreesValue) { $plantsTreesValue->setPropertyID(""); $plantsTreesValue->setAfsID($newAfsID); if (is_object($plantsTreesValue->propertyAdministrator)) { $plantsTreesValue->propertyAdministrator->setPersonID(""); } else { $plantsTreesValue->propertyAdministrator = new Person(); $plantsTreesValue->propertyAdministrator->setPersonID(""); } // set unitPrice from ProductClass $plantsTreesClasses = new PlantsTreesClasses(); $plantsTreesClasses->selectRecord(intVal($plantsTreesValue->productClass)); $plantsTreesValue->setUnitPrice($plantsTreesClasses->getValue()); // set assessmentLevel from ActualUse $plantsTreesActualUses = new PlantsTreesActualUses(); $plantsTreesActualUses->selectRecord(intVal($plantsTreesValue->actualUse)); $plantsTreesValue->setAssessmentLevel($plantsTreesActualUses->getValue()); $plantsTreesValue->calculateMarketValue(); $plantsTreesValue->calculateValueAdjustment(); $plantsTreesValue->calculateAdjustedMarketValue(); $plantsTreesValue->calculateAssessedValue(); $newP = $plantsTreesValue->insertRecord(); } } if (count($afs->improvementsBuildingsArray)) { foreach ($afs->improvementsBuildingsArray as $improvementsBuildingsKey => $improvementsBuildingsValue) { $improvementsBuildingsValue->setPropertyID(""); $improvementsBuildingsValue->setAfsID($newAfsID); if (is_object($improvementsBuildingsValue->propertyAdministrator)) { $improvementsBuildingsValue->propertyAdministrator->setPersonID(""); } else { $improvementsBuildingsValue->propertyAdministrator = new Person(); $improvementsBuildingsValue->propertyAdministrator->setPersonID(""); } // set unitValue from BuildingClassification $improvementsBuildingsClasses = new ImprovementsBuildingsClasses(); $improvementsBuildingsClasses->selectRecord(intVal($improvementsBuildingsValue->buildingClassification)); $improvementsBuildingsValue->setUnitValue($improvementsBuildingsClasses->getValue()); // this if() line added : November 05 2004: // if master table unit value is not 0, update this unit value with the master table unit value // otherwise, retain this unit value as it is the old one. if ($improvementsBuildingsClasses->getValue() != 0) { $improvementsBuildingsValue->setUnitValue($improvementsBuildingsClasses->getValue()); } // set assessmentLevel from ActualUse $improvementsBuildingsActualUses = new ImprovementsBuildingsActualUses(); $improvementsBuildingsActualUses->selectRecord(intVal($improvementsBuildingsValue->actualUse)); $improvementsBuildingsValue->setAssessmentLevel($improvementsBuildingsActualUses->getValue()); $improvementsBuildingsValue->calculateMarketValue(); $improvementsBuildingsValue->calculateAccumulatedDepreciation(); $improvementsBuildingsValue->calculatedDepreciatedMarketValue(); $improvementsBuildingsValue->calculateAdjustedMarketValue(); $improvementsBuildingsValue->calculateAssessedValue(); $newP = $improvementsBuildingsValue->insertRecord(); } } if (count($afs->machineriesArray)) { foreach ($afs->machineriesArray as $machineriesKey => $machineriesValue) { $machineriesValue->setPropertyID(""); $machineriesValue->setAfsID($newAfsID); if (is_object($machineriesValue->propertyAdministrator)) { $machineriesValue->propertyAdministrator->setPersonID(""); } else { $machineriesValue->propertyAdministrator = new Person(); $machineriesValue->propertyAdministrator->setPersonID(""); } // set assessmentLevel from ActualUse $machineriesActualUses = new MachineriesActualUses(); $machineriesActualUses->selectRecord(intVal($machineriesValue->actualUse)); $machineriesValue->setAssessmentLevel($machineriesActualUses->getValue()); $machineriesValue->calculateMarketValue(); $machineriesValue->calculateDepreciatedMarketValue(); $machineriesValue->calculateAdjustedMarketValue(); $machineriesValue->calculateAssessedValue(); $newP = $machineriesValue->insertRecord(); } } } return $newOdID; }
function CreateNewRPU_AFS_TDGenRevBrgy($odID, $userID = "", $transactionCode = "", $copyOwner = true, $copyAFS = true, $copyTD = true) { $link = mysql_connect(MYSQLDBHOST, MYSQLDBUSER, MYSQLDBPWD); mysql_select_db(MYSQLDBNAME, $link); $sql = "select Person.firstName, Person.lastName from Person, Owner, OwnerPerson " . "where Person.personID = OwnerPerson.personID and OwnerPerson.ownerID = Owner.ownerID and Owner.odID = " . $odID; $rs = mysql_query($sql, $link); $prevowners = ''; while ($row = mysql_fetch_assoc($rs)) { $prevowners .= $row['firstName'] . ' ' . $row['lastName'] . ', '; } $prevowners = substr($prevowners, 0, strlen($prevowners) - 2); $sql = "select AFS.totalAssessedValue from AFS where AFS.odID = " . $odID; $rs = mysql_query($sql, $link); $prevassdval = 0; if ($row = mysql_fetch_assoc($rs)) { $prevassdval = $row['totalAssessedValue']; } $od = new OD(); $od->selectRecord($odID); unset($od->oldODArray); $od->setTransactionCode($transactionCode); $od->setOldODArray($odID); // create new OD $ownerID = $od->owner->getOwnerID(); $newOdID = $od->insertRecord(); $newOwnerID = $od->newOwnerID; $od->setDomDocument(); // associate existing Owner to new OD $owner = new Owner(); $owner->selectRecord($ownerID); if (count($owner->personArray)) { foreach ($owner->personArray as $personKey => $personValue) { if ($copyOwner) { $owner->insertOwnerPerson($newOwnerID, $personValue->getPersonID()); } } } if (count($owner->companyArray)) { foreach ($owner->companyArray as $companyKey => $companyValue) { if ($copyOwner) { $owner->insertOwnerCompany($newOwnerID, $companyValue->getCompanyID()); } } } // create new AFS and associate existing properties to new AFS $afs = new AFS(); $afsID = $afs->checkAfsID($odID); $afs->selectRecord($afsID); $afs->setOdID($newOdID); $afs->effectivity = date("Y") + 1; // new arpNumber is blank //$afs->arpNumber = ""; // retain PIN except for Consolidation and Subdivision //if($transactionCode=="SD" || $transactionCode=="CS"){ $afs->propertyIndexNumber = ""; //} $afs->setDomDocument(); $newAFSID = $afs->insertRecord(); $afs->arpNumber = '(' . $newAFSID . ')'; $afs->updateRecord(); if ($copyAFS) { if ($copyTD) { $td = new TD(); $td->taxDeclarationNumber = $afs->arpNumber; $td->afsID = $newAFSID; $td->previousOwner = $prevowners; $td->previousAssessedValue = $prevassdval; $td->setDomDocument(); $newTDID = $td->insertRecord(); } if (count($afs->landArray)) { foreach ($afs->landArray as $landKey => $landValue) { $landValue->setPropertyID(""); $landValue->setAfsID($newAFSID); $landValue->propertyAdministrator->setPersonID(""); // set unitValue from SubClass $landSubclasses = new LandSubclasses(); $landSubclasses->selectRecord(intVal($landValue->subClass)); $landValue->setUnitValue($landSubclasses->getValue()); // set assessmentLevel from ActualUse $landActualUses = new LandActualUses(); $landActualUses->selectRecord(intVal($landValue->actualUse)); $landValue->setAssessmentLevel($landActualUses->getValue()); $landValue->calculateMarketValue(); $landValue->calculateValueAdjustment(); $landValue->calculateAdjustedMarketValue(); $landValue->calculateAssessedValue(); $landValue->memoranda = GENERALREVISION_DEFAULT_MEMORANDA; $landValue->appraisedByDate = ""; $landValue->recommendingApprovalDate = ""; $landValue->approvedByDate = ""; $newP = $landValue->insertRecord(); } } if (count($afs->plantsTreesArray)) { foreach ($afs->plantsTreesArray as $plantsTreesKey => $plantsTreesValue) { $plantsTreesValue->setPropertyID(""); $plantsTreesValue->setAfsID($newAFSID); $plantsTreesValue->propertyAdministrator->setPersonID(""); // set unitPrice from ProductClass $plantsTreesClasses = new PlantsTreesClasses(); $plantsTreesClasses->selectRecord(intVal($plantsTreesValue->productClass)); $plantsTreesValue->setUnitPrice($plantsTreesClasses->getValue()); // set assessmentLevel from ActualUse $plantsTreesActualUses = new PlantsTreesActualUses(); $plantsTreesActualUses->selectRecord(intVal($plantsTreesValue->actualUse)); $plantsTreesValue->setAssessmentLevel($plantsTreesActualUses->getValue()); $plantsTreesValue->calculateMarketValue(); $plantsTreesValue->calculateValueAdjustment(); $plantsTreesValue->calculateAdjustedMarketValue(); $plantsTreesValue->calculateAssessedValue(); $plantsTreesValue->memoranda = GENERALREVISION_DEFAULT_MEMORANDA; $plantsTreesValue->appraisedByDate = ""; $plantsTreesValue->recommendingApprovalDate = ""; $plantsTreesValue->approvedByDate = ""; $newP = $plantsTreesValue->insertRecord(); } } if (count($afs->improvementsBuildingsArray)) { foreach ($afs->improvementsBuildingsArray as $improvementsBuildingsKey => $improvementsBuildingsValue) { $improvementsBuildingsValue->setPropertyID(""); $improvementsBuildingsValue->setAfsID($newAFSID); $improvementsBuildingsValue->propertyAdministrator->setPersonID(""); // set unitValue from BuildingClassification $improvementsBuildingsClasses = new ImprovementsBuildingsClasses(); $improvementsBuildingsClasses->selectRecord(intVal($improvementsBuildingsValue->buildingClassification)); $improvementsBuildingsValue->setUnitValue($improvementsBuildingsClasses->getValue()); // set assessmentLevel from ActualUse $improvementsBuildingsActualUses = new ImprovementsBuildingsActualUses(); $improvementsBuildingsActualUses->selectRecord(intVal($improvementsBuildingsValue->actualUse)); $improvementsBuildingsValue->setAssessmentLevel($improvementsBuildingsActualUses->getValue()); $improvementsBuildingsValue->calculateMarketValue(); $improvementsBuildingsValue->calculateAccumulatedDepreciation(); $improvementsBuildingsValue->calculatedDepreciatedMarketValue(); $improvementsBuildingsValue->calculateAdjustedMarketValue(); $improvementsBuildingsValue->calculateAssessedValue(); $improvementsBuildingsValue->memoranda = GENERALREVISION_DEFAULT_MEMORANDA; $improvementsBuildingsValue->appraisedByDate = ""; $improvementsBuildingsValue->recommendingApprovalDate = ""; $improvementsBuildingsValue->approvedByDate = ""; $newP = $improvementsBuildingsValue->insertRecord(); } } if (count($afs->machineriesArray)) { foreach ($afs->machineriesArray as $machineriesKey => $machineriesValue) { $machineriesValue->setPropertyID(""); $machineriesValue->setAfsID($newAFSID); $machineriesValue->propertyAdministrator->setPersonID(""); // set assessmentLevel from ActualUse $machineriesActualUses = new MachineriesActualUses(); $machineriesActualUses->selectRecord(intVal($machineriesValue->actualUse)); $machineriesValue->setAssessmentLevel($machineriesActualUses->getValue()); $machineriesValue->calculateMarketValue(); $machineriesValue->calculateDepreciatedMarketValue(); $machineriesValue->calculateAdjustedMarketValue(); $machineriesValue->calculateAssessedValue(); $machineriesValue->memoranda = GENERALREVISION_DEFAULT_MEMORANDA; $machineriesValue->appraisedByDate = ""; $machineriesValue->recommendingApprovalDate = ""; $machineriesValue->approvedByDate = ""; $newP = $machineriesValue->insertRecord(); } } } $sql = "update AFS set archive = 'true' where AFS.odID = " . $odID; mysql_query($sql, $link); $sql = "update OD set archive = 'true' where OD.odID = " . $odID; mysql_query($sql, $link); $sql = "update TD set archive = 'true' where TD.afsID = " . $afsID; mysql_query($sql, $link); mysql_close($link); return $newOdID; echo "OD - " . $odID . "->" . $newOdID . "<br>"; echo "Owner - " . $ownerID . "->" . $newOwnerID . "<br>"; echo "AFS - " . $afsID . "->" . $newAFSID . "<br>" . $newP; }