function getLandAreaInSquareMeters($code) { $landAreaInSquareMeters = 0; $db = new DB_SelectLGU($this->dbName); $conditionHectares = " AND Land.unit LIKE 'hectares'"; $conditionSquareMeters = " AND Land.unit LIKE 'square meters'"; $sql = "SELECT SUM(Land.area) as area " . " FROM OD, AFS, Land, LandActualUses WHERE " . " OD.odID = AFS.odID AND " . " AFS.afsID = Land.afsID AND " . " Land.actualUse = LandActualUses.landActualUsesID AND " . " OD.archive != 'true' AND " . " LandActualUses.reportCode LIKE '" . $code . "'"; // tally hectares, converting to square meters $db->query($sql . $conditionHectares); while ($db->next_record()) { $landAreaInSquareMeters += hectaresToSquareMeters($db->f("area")); } // tally square meters $db->query($sql . $conditionSquareMeters); while ($db->next_record()) { $landAreaInSquareMeters += $db->f("area"); } return $landAreaInSquareMeters; }
function Main() { switch ($this->formArray["formAction"]) { case "view": ini_set("max_execution_time", "420"); $ODList = new SoapObject(NCCBIZ . "ODList.php", "urn:Object"); $condition = ""; if ($this->formArray["filterByLocation"] == "true") { if ($condition == "") { $condition = " WHERE "; } $condition .= $this->filterLocationAddress(); } else { $this->tpl->set_block("rptsTemplate", "FilterLocationDetails", "FilterLocationDetailsBlock"); $this->tpl->set_var("FilterLocationDetailsBlock", ""); } if ($this->formArray["filterByDate"] == "true") { if ($condition == "") { $condition = " WHERE "; } else { $condition .= " AND "; } $condition .= $this->filterDate(); } else { $this->tpl->set_block("rptsTemplate", "FilterDateDetails", "FilterDateDetailsBlock"); $this->tpl->set_var("FilterDateDetailsBlock", ""); } $countLandAreaCondition = $condition; $condition .= $this->filterArchives(); $odRecords = new ODRecords(); // paging if (!($count = $odRecords->countRecords($condition))) { $this->tpl->set_block("rptsTemplate", "PageNavigationOne", "PageNavigationOneBlock"); $this->tpl->set_var("PageNavigationOneBlock", ""); } else { $numOfPages = ceil($count / PAGE_BY); $this->tpl->set_var("currentPage", $this->formArray["page"]); $this->tpl->set_var("numOfPages", $numOfPages); $this->tpl->set_block("rptsTemplate", "PageListOne", "PageListOneBlock"); for ($p = 1; $p <= $numOfPages; $p++) { $this->tpl->set_var("page", $p); $this->initSelected("page", $p); $this->tpl->parse("PageListOneBlock", "PageListOne", true); } } if ($this->formArray["page"] == $numOfPages) { $this->computeTotalLandArea($countLandAreaCondition); } else { $this->tpl->set_block("rptsTemplate", "TotalLandArea", "TotalLandAreaBlock"); $this->tpl->set_var("TotalLandAreaBlock", ""); } $this->formArray["pageTotalLandArea"] = 0; $this->formArray["transactionNumber"] = $this->formArray["page"] * PAGE_BY - (PAGE_BY - 1); if ($this->formArray["page"] > 0) { $initialLimit = ($this->formArray["page"] - 1) * PAGE_BY; $condition .= " LIMIT " . $initialLimit . "," . PAGE_BY; } // listing if (!$odRecords->selectRecords($condition)) { $this->tpl->set_block("rptsTemplate", "NotFound", "NotFoundBlock"); $this->tpl->set_var("message", "properties not found"); $this->tpl->parse("NotFoundBlock", "NotFound", true); $this->tpl->set_block("rptsTemplate", "Report", "ReportBlock"); $this->tpl->set_var("ReportBlock", ""); } else { $list = $odRecords->getArrayList(); if (count($list)) { $this->tpl->set_block("rptsTemplate", "NotFound", "NotFoundBlock"); $this->tpl->set_var("NotFoundBlock", ""); $this->tpl->set_block("rptsTemplate", "ReportList", "ReportListBlock"); //$this->formArray["totalLandArea"] = 0; foreach ($list as $key => $value) { $this->formArray["odID"] = $value->getOdID(); $this->tpl->set_var("odID", $value->getOdID()); $afs = $this->getAFSDetails($value->getOdID()); if (is_object($afs)) { $this->tpl->set_var("propertyIndexNumber", $afs->getPropertyIndexNumber()); $this->tpl->set_var("arpNumber", $afs->getArpNumber()); $this->tpl->set_var("marketValue", number_format($afs->getTotalMarketValue(), 2, '.', ',')); $this->tpl->set_var("assessedValue", number_format($afs->getTotalAssessedValue(), 2, '.', ',')); $landList = $afs->getLandArray(); $plantsTreesList = $afs->getPlantsTreesArray(); $improvementsBuildingsList = $afs->getImprovementsBuildingsArray(); $machineriesList = $afs->getMachineriesArray(); $this->tpl->set_var("taxability", $afs->getTaxability()); $this->tpl->set_var("effectivity", $afs->getEffectivity()); $kind = ""; $class = ""; $this->tpl->set_var("landArea", ""); if (count($landList)) { $kind = "Land"; $land = $landList[0]; $class = $land->getClassification(); // compute totalLandArea $unit = $land->getUnit(); if ($unit == "square meters") { $unit = "sqm."; $area = $land->getArea(); } else { if ($unit == "hectares") { $unit = "ha."; $area = hectaresToSquareMeters($land->getArea()); } } $this->tpl->set_var("landArea", $land->getArea() . " " . $unit); $this->formArray["pageTotalLandArea"] += $area; $landClasses = new LandClasses(); $landClasses->selectRecord($class); $class = $landClasses->getDescription(); } else { if (count($plantsTreesList)) { $kind = "Land"; $plantsTrees = $plantsTreesList[0]; $class = $plantsTrees->getProductClass(); $plantsTreesClasses = new PlantsTreesClasses(); $plantsTreesClasses->selectRecord($class); $class = $plantsTreesClasses->getDescription(); } else { if (count($improvementsBuildingsList)) { $kind = "Improvements/Buildings"; $improvementsBuildings = $improvementsBuildingsList[0]; $class = $improvementsBuildings->getBuildingClassification(); $improvementsBuildingsClasses = new ImprovementsBuildingsClasses(); $improvementsBuildingsClasses->selectRecord($class); $class = $improvementsBuildingsClasses->getDescription(); } else { if (count($machineriesList)) { $kind = "Machineries"; $machineries = $machineriesList[0]; $class = $machineries->getKind(); } } } } $this->tpl->set_var("kind", $kind); $this->tpl->set_var("classification", $class); $oValue = $value->owner; if (count($oValue->personArray)) { $firstOwner = $oValue->personArray[0]->getLastName(); $firstOwner .= ", "; $firstOwner .= $oValue->personArray[0]->getFirstName(); $firstOwner .= " "; $firstOwner .= substr($oValue->personArray[0]->getMiddleName(), 0, 1) . "."; $pAddress = $oValue->personArray[0]->addressArray ? $oValue->personArray[0]->addressArray[0]->getFullAddress() : "no address"; $firstOwnerAddress = $pAddress; $firstOwnerTelephone = $oValue->personArray[0]->getTelephone(); $this->tpl->set_var("firstOwner", $firstOwner); $this->tpl->set_var("firstOwnerAddress", $firstOwnerAddress); $this->tpl->set_var("firstOwnerTelephone", $firstOwnerTelephone); } if (count($oValue->companyArray)) { if ($firstOwner == "") { $firstOwner = $oValue->companyArray[0]->getCompanyName(); $cAddress = $oValue->companyArray[0]->addressArray ? $oValue->companyArray[0]->addressArray[0]->getFullAddress() : "no address"; $firstOwnerAddress = $cAddress; $firstOwnerTelephone = $oValue->companyArray[0]->getTelephone(); $this->tpl->set_var("firstOwner", $firstOwner); $this->tpl->set_var("firstOwnerAddress", $firstOwnerAddress); $this->tpl->set_var("firstOwnerTelephone", $firstOwnerTelephone); } } if ($firstOwner != "") { $this->tpl->set_var("none", ""); if (count($oValue->personArray) + count($oValue->companyArray) > 1) { $this->tpl->set_var("andOthers", "(and others)"); } else { $this->tpl->set_var("andOthers", ""); } } else { $this->tpl->set_var("none", "none"); $this->tpl->set_var("firstOwner", ""); $this->tpl->set_var("andOthers", ""); $this->tpl->set_var("firstOwnerAddress", ""); $this->tpl->set_var("firstOwnerTelephone", ""); } if ($this->formArray["filterByLocation"] == "true") { $locationAddress = $value->locationAddress->getNumber(); $locationAddress .= " "; $locationAddress .= $value->locationAddress->getStreet(); } else { $locationAddress = $value->locationAddress->getFullAddress(); } $this->tpl->set_var("location", $locationAddress); $this->tpl->set_var("date", date("n/j/Y", $value->getDateCreated())); $this->tpl->set_var("transactionCode", $value->getTransactionCode()); $this->displayPrecedingOD(); //$this->displaySucceedingOD(); $this->tpl->set_var("transactionNumber", $this->formArray["transactionNumber"]); $this->formArray["transactionNumber"]++; $this->tpl->parse("ReportListBlock", "ReportList", true); } } } } break; default: $this->tpl->set_block("rptsTemplate", "NotFound", "NotFoundBlock"); $this->tpl->set_var("message", "select a location to view report"); $this->tpl->parse("NotFoundBlock", "NotFound", true); $this->tpl->set_block("rptsTemplate", "Report", "ReportBlock"); $this->tpl->set_var("ReportBlock", ""); break; } $this->setForm(); $this->tpl->set_var("Session", $this->sess->url("")); $this->tpl->set_var("rpts_Session", $this->sess->id); $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); }