function setDetails() { global $sess; $this->tpl->set_var($_GET); $this->tpl->set_var($_POST); # set the RPTOP to get the owner's object and information # get it from POST if possible, otherwise from GET $rptopID = isset($_POST['rptopID']) ? $_POST['rptopID'] : $_GET['rptopID']; $rptop = new RPTOP(); $rptop->selectRecord($rptopID); $dateDue = $rptop->getTaxableYear() . "-01-01"; # must be a usable format $formValues['taxableYear'] = $rptop->getTaxableYear(); $formValues['rptopNum'] = $rptop->getRptopNumber(); # set the specific TD (although this is in the RPTOP), hard to search for it. # get the tdID from POST or GET to initialize the TD $tdID = isset($_POST['tdID']) ? $_POST['tdID'] : $_GET['tdID']; $td = new TD(); $td->selectRecord($tdID); $tdNum = $td->getTaxDeclarationNumber(); $formValues['tdNum'] = $tdNum; # we define the property from the TD $propertyType = $td->getPropertyType(); $propertyID = $td->getPropertyID(); switch ($propertyType) { case "Land": $property = new Land(); break; case "PlantsTrees": $property = new PlantsTrees(); break; case "ImprovementsBuildings": $property = new ImprovementsBuildings(); break; case "Machineries": $property = new Machineries(); break; default: echo "cannot be! {$propertyType}"; break; } if (is_object($property)) { $property->selectRecord($propertyID); $assessedValue = number_format($property->getAssessedValue(), 2, ".", ""); $formValues['assessedValue'] = number_format($property->getAssessedValue(), 2); } $formValues['propertyType'] = $propertyType; # set the owner's List # we define the owner from the RPTOP $this->tpl->set_block('step3', 'Owner', 'Owners'); $owner = $rptop->getOwner(); $personArray = $owner->getPersonArray(); if (is_array($personArray)) { foreach ($personArray as $person) { $ownerValues['ownerName'] = $person->getLastName() . ", " . $person->getFirstName() . " " . $person->getMiddleName(); $addressArray = $person->getAddressArray(); $address = $addressArray[0]; $ownerValues['ownerAddress'] = $address->getNumber() . " " . $address->getStreet() . "<br>" . $address->getBarangay() . ", " . $address->getMunicipalityCity() . "<br>" . $address->getProvince(); $this->tpl->set_var($ownerValues); $this->tpl->parse('Owners', 'Owner', 'true'); } } $companyArray = $owner->getCompanyArray(); if (is_array($companyArray)) { foreach ($companyArray as $company) { $ownerValues['ownerName'] = $company->getCompanyName(); $addressArray = $company->getAddressArray(); $address = $addressArray[0]; $ownerValues['ownerAddress'] = $address->getNumber() . " " . $address->getStreet() . "<br>" . $address->getBarangay() . ", " . $address->getMunicipalityCity() . "<br> " . $address->getProvince(); $this->tpl->set_var($ownerValues); $this->tpl->parse('Owners', 'Owner', 'true'); } } # tax dues are defined from TDNumber and taxableYear # compute for taxes $taxDue = new Dues(); if ($taxDue->create($tdNum, $dateDue) == false) { $taxDue->setBasic($assessedValue); $taxDue->setSEF($assessedValue); $taxDue->setDueDate($dateDue); $taxDue->setUpdateDate(); } $paymentPeriod = "Annual"; if (isset($_POST['paymentPeriod'])) { $paymentPeriod = $_POST['paymentPeriod']; } switch ($paymentPeriod) { case 'Annual': $this->tpl->set_var("checkedAnnual", "checked"); break; case 'Q1': $this->tpl->set_var("checkedQ1", "checked"); break; case 'Q2': $this->tpl->set_var("checkedQ2", "checked"); break; case 'Q3': $this->tpl->set_var("checkedQ3", "checked"); break; case 'Q4': $this->tpl->set_var("checkedQ4", "checked"); break; default: break; } $this->tpl->set_var($formValues); ## Compute taxes and set the page values $basic = $taxDue->getBalanceBasic($paymentPeriod); $sef = $taxDue->getBalanceSEF($paymentPeriod); $interest = $taxDue->computePenalty($paymentPeriod); $taxValues['basic'] = number_format($basic, 2); $taxValues['sef'] = number_format($sef, 2); $taxValues['pd1185'] = number_format(0.0, 2); $taxValues['subTotal'] = number_format($basic + $sef, 2); $taxValues['periodTotal'] = number_format($basic + $sef, 2); $taxValues['discount'] = "0.0%"; $taxValues['interest'] = number_format($interest * 100.0, 1) . "%"; $taxValues['totBasic'] = number_format($basic * (1 + $interest), 2); $taxValues['totSEF'] = number_format($sef * (1 + $interest), 2); $taxValues['totPD1185'] = number_format(0, 2); $taxValues['totSubTotal'] = number_format(($basic + $sef) * (1 + $interest), 2); $taxValues['grandTotal'] = number_format(($basic + $sef) * (1 + $interest), 2); # further breakdown of basic tax for RPT Receipt $taxValues['gf'] = number_format($basic * 0.7, 2); // 70% of basic $taxValues['ib'] = number_format($basic * 0.15, 2); // 15% of basic $taxValues['cb'] = number_format($basic * 0.15, 2); // 15% of basic for a total if 100% $taxValues['totGF'] = number_format($basic * 0.7 * (1 + $interest), 2); $taxValues['totIB'] = number_format($basic * 0.15 * (1 + $interest), 2); $taxValues['totCB'] = number_format($basic * 0.15 * (1 + $interest), 2); $this->tpl->set_var($taxValues); if (!isset($_POST['printReceipt_x'])) { $this->tpl->set_var("Session", $sess->url("")); } }
function Main() { global $sess; $RPTOPDetails = new SoapObject(NCCBIZ . "RPTOPDetails.php", "urn:Object"); if (!($xmlStr = $RPTOPDetails->getRPTOP($this->formArray["rptopID"]))) { exit("xml failed"); } else { //echo $xmlStr; if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock"); $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc"); } else { $rptop = new RPTOP(); $rptop->parseDomDocument($domDoc); foreach ($rptop as $key => $value) { switch ($key) { case "owner": //$RPTOPEncode = new SoapObject(NCCBIZ."RPTOPEncode.php", "urn:Object"); if (is_a($value, "Owner")) { $this->formArray["ownerID"] = $rptop->owner->getOwnerID(); $xmlStr = $rptop->owner->domDocument->dump_mem(true); if (!$xmlStr) { $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 { $this->displayOwnerList($domDoc); } } } else { $this->tpl->set_block("rptsTemplate", "PersonList", "PersonListBlock"); $this->tpl->set_var("PersonListBlock", ""); $this->tpl->set_block("rptsTemplate", "CompanyList", "CompanyListBlock"); $this->tpl->set_var("CompanyListBlock", ""); } break; case "taxableYear": $this->tpl->set_var("taxableYear", $value); $dueDate = $value; break; case "tdArray": $this->tpl->set_block("rptsTemplate", "TDList", "TDListBlock"); $this->tpl->set_block("rptsTemplate", "JSTDList", "JSTDListBlock"); $this->tpl->set_block("rptsTemplate", "BacktaxTDTable", "BacktaxTDTableBlock"); $this->unpaidTDCount = 0; if (count($value)) { $this->tpl->set_block("rptsTemplate", "TDDBEmpty", "TDDBEmptyBlock"); $this->tpl->set_var("TDDBEmptyBlock", ""); foreach ($value as $tkey => $tvalue) { $propertyType = $tvalue->getPropertyType(); $propertyID = $tvalue->getPropertyID(); $afsID = $tvalue->getAfsID(); $afs = new AFS(); $afs->selectRecord($afsID); $listValues['propertyIndexNumber'] = $afs->getPropertyIndexNumber(); $assessedValue = $tvalue->getAssessedValue(); #echo("assessedValue=$assessedValue<br7>"); $listValues['taxBeginsWithTheYear'] = $tvalue->getTaxBeginsWithTheYear(); $listValues['tdNum'] = $tvalue->getTaxDeclarationNumber(); $tdID = $tvalue->getTdID(); $listValues['tdID'] = $tdID; #echo("tdID=$tdID, dueDate=$dueDate<br>"); $dues = new Dues($tdID, $dueDate); if (!$dues->create($tdID, $dueDate, $assessedValue)) { $dues->setBasic($assessedValue); $dues->setSEF($assessedValue); # check if land is idle, if yes, set assessed value # getIdleStatus -- temporary function if ($dues->getIdleStatus() == 1) { #echo("idle<br>"); $dues->setIdle($assessedValue); } } // Refresh for amnesty and paymentPeriod if ($this->formArray["formAction"] == "refresh") { $amnesty = $this->formArray[amnesty]; $dues->setAmnesty($amnesty); $paymentPeriod = $this->formArray[paymentPeriod]; $dues->setPaymentMode($paymentPeriod); } if ($dues->getAmnesty() == "Yes") { $dues->resetPenalty(); $dues->computePenalty($paymentPeriod, "now"); } $paymentPeriod = $dues->getPaymentMode(); $amnesty = $dues->getAmnesty(); $dues->store(); switch ($paymentPeriod) { case 'Quarter': $this->tpl->set_var("selectedQuarter", "selected"); $this->tpl->set_var("paymentPeriod", $paymentPeriod); $this->tpl->set_var("installmentNumber", ceil(date("n") / 3)); $this->tpl->set_var("netDueFullAmount", number_format($dues->getTotalDue("Annual"), 2)); break; default: #Annual $this->tpl->set_block("rptsTemplate", "QuarterNetDue", "QuarterNetDueBlock"); $this->tpl->set_var("QuarterNetDueBlock", ""); $this->tpl->set_var("selectedAnnual", "selected"); $this->tpl->set_var("paymentPeriod", $paymentPeriod); break; } //$totalDue = $dues->getTotalDue($paymentPeriod); $totalDue = $dues->getTotalDue($paymentPeriod); $basic = $dues->getBasic($paymentPeriod); $sef = $dues->getSEF($paymentPeriod); $penalty = $dues->getPenalty($paymentPeriod); $discount = $dues->getDiscount(); $totalPaid = $dues->getPaidBasic($paymentPeriod) + $dues->getPaidPenalty($paymentPeriod) + $dues->getPaidSEF($paymentPeriod); $listValues['taxDue'] = $totalDue; $listValues['basic'] = number_format($basic, 2); $listValues['sef'] = number_format($sef, 2); $listValues['penalty'] = number_format($penalty, 2); $listValues['discount'] = number_format($discount, 2); $listValues['totalPaid'] = number_format($totalPaid, 2); $listValues['strTaxDue'] = number_format($totalDue, 2); //$basic = $dues->getBasic($paymentPeriod); #echo("basic=$basic<br>"); //$sef = $dues->getSEF($paymentPeriod); #echo("sef=$sef<br>"); if (!$this->isPriorTDPaid($tdID)) { $backtaxes = true; $paidStatus = "<input type=\"checkbox\" name=\"tdID[" . $tdID . "]\" value=\"" . $tdID . "\" onclick=\"javascript: toggle(this, '" . $tdID . "'); updateTotalTaxDue(this," . $tdID . ");\" disabled>"; } else { $backtaxes = false; $paidStatus = $totalDue <= 0 ? $basic <= 0 ? "N.A." : "PAID" : "<input type=\"checkbox\" name=\"tdID[" . $tdID . "]\" value=\"" . $tdID . "\" onclick=\"javascript: toggle(this, '" . $tdID . "'); updateTotalTaxDue(this," . $tdID . ");\">"; } $listValues['paidStatus'] = $paidStatus; $listValues['tdBgcolor'] = '#f6f6f6'; $this->tpl->set_var($listValues); $this->tpl->parse("TDListBlock", "TDList", true); if ($backtaxes) { $oldestUnpaidTD = $this->unpaidTDArray[count($this->unpaidTDArray) - 1]; $this->displayBacktaxTD($oldestUnpaidTD->getTdID()); $this->displayPriorTDs($tdID); unset($this->unpaidTDArray); } else { $this->displayBacktaxTD($tdID); $this->tpl->set_var("JSTDListBlock", ""); } //$this->tpl->parse("BacktaxTDTableBlock", "BacktaxTDTable", true); } } else { $this->tpl->set_block("rptsTemplate", "CheckAll", "CheckAllBlock"); $this->tpl->set_var("CheckAllBlock", ""); $this->tpl->set_var("TDListBlock", ""); } $this->tpl->set_var("rptopID", $rptopID); break; default: $this->formArray[$key] = $value; } } } } $this->setForm(); $this->tpl->set_var("uname", $this->user["uname"]); $this->tpl->set_var("today", date("F j, Y")); $this->setPageDetailPerms(); $this->tpl->set_var(amnestyChecked, $amnesty == "Yes" ? " checked" : ""); $this->tpl->set_var("Session", $sess->url("") . $sess->add_query(array("rptopID" => $this->formArray["rptopID"], "ownerID" => $this->formArray["ownerID"]))); $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); }