Beispiel #1
0
 function Main()
 {
     $this->formArray['currentDate'] = date("F d, Y");
     $MunicipalityCityDetails = new SoapObject(NCCBIZ . "MunicipalityCityDetails.php", "urn:Object");
     #test values
     //$this->formArray['municipalityCityID']=1;
     if (!($xmlStr = $MunicipalityCityDetails->getMunicipalityCityDetails($this->formArray['municipalityCityID']))) {
         #echo($xmlStr);
         exit("xml failed for municipality");
         //header("Location: ".$this->sess->url("ViewSOA.php")."&status=2");
     } else {
         if (!($domDoc = domxml_open_mem($xmlStr))) {
             echo "error xmlDoc";
         } else {
             $MunicipalityCity = new MunicipalityCity();
             $MunicipalityCity->parseDomDocument($domDoc);
             $this->formArray['municipality'] = $MunicipalityCity->getDescription();
         }
     }
     if ($this->formArray['personID'] != "") {
         $person = new Person();
         $person->selectRecord($this->formArray['personID']);
         $this->tpl->set_var(ownerName, $person->getFullName());
         $this->tpl->set_var(ownerNo, $person->getTin());
         $address = $person->addressArray[0];
         if (is_object($address)) {
             $this->tpl->set_var(ownerAddress, $address->getNumber() . " " . $address->getStreet() . " " . $address->getBarangay() . " " . $address->getDistrict() . " " . $address->getMunicipalitycity() . " " . $address->getProvince());
         } else {
             $this->tpl->set_var(ownerAddress, "");
         }
         $db = new DB_RPTS();
         $sql = "SELECT rptopID FROM Owner inner join OwnerPerson on Owner.ownerID=OwnerPerson.ownerID WHERE Owner.rptopID <> '' AND OwnerPerson.personID=" . $this->formArray['personID'];
         $db->query($sql);
     } else {
         $company = new Company();
         $company->selectRecord($this->formArray['companyID']);
         $this->tpl->set_var(ownerName, $company->getCompanyName());
         $this->tpl->set_var(ownerNo, $company->getCompanyID());
         $address = $company->addressArray[0];
         $this->tpl->set_var(ownerAddress, $address->getNumber() . " " . $address->getStreet() . " " . $address->getBarangay() . " " . $address->getDistrict() . " " . $address->getMunicipalitycity() . " " . $address->getProvince());
         $db = new DB_RPTS();
         $sql = "SELECT rptopID FROM Owner inner join OwnerPerson on Owner.ownerID=OwnerPerson.ownerID WHERE Owner.rptopID <> '' AND OwnerPerson.personID=" . $this->formArray['companyID'];
         $db->query($sql);
     }
     $ypos = 325;
     $this->tpl->set_block("rptsTemplate", "ROW", "RowBlk");
     for ($i = 0; $db->next_record(); $i++) {
         $rptopID = $db->f("rptopID");
         $RPTOPDetails = new SoapObject(NCCBIZ . "RPTOPDetails.php", "urn:Object");
         if (!($xmlStr = $RPTOPDetails->getRPTOP($rptopID))) {
             //	exit("xml failed for RPTOP");
             header("Location: " . $this->sess->url("ViewSOA.php") . "&status=1");
         } 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();
                 $td = new TD();
                 $rptop->parseDomDocument($domDoc);
                 foreach ($rptop as $key => $value) {
                     $this->formArray['payableYear'] = $rptop->getTaxableYear();
                     $rptopID = $rptop->getRptopID();
                     if ($key == "tdArray") {
                         $tdCtr = 0;
                         if (count($value)) {
                             foreach ($value as $tkey => $tvalue) {
                                 $td->selectRecord($tvalue->getTdID());
                                 $assessedValue = number_format($td->getAssessedValue(), 2, ".", "");
                                 $propertyType = $td->getPropertyType();
                                 $TaxDeclarationNumber = $td->getTaxDeclarationNumber();
                                 $afsID = $td->getAfsID();
                                 $afs = new AFS();
                                 $afs->selectRecord($afsID);
                                 $od = new OD();
                                 $od->selectRecord($afs->getOdID());
                                 $addr = $od->getLocationAddress();
                                 if (count($addr)) {
                                     $location = strtoupper($addr->getNumber() . " " . substr($addr->getBarangay(), 0, 4) . " " . substr($addr->getMunicipalityCity(), 0, 3) . " " . substr($addr->getProvince(), 0, 3));
                                     $munCityID = $addr->getMunicipalityCityID();
                                 }
                                 if (count($afs->landArray)) {
                                     foreach ($afs->landArray as $afsKey => $afsValue) {
                                         $actualUse = $afsValue->getActualUse();
                                         $landActualUses = new LandActualUses();
                                         $landActualUses->selectRecord($actualUse);
                                         $Code = $landActualUses->getCode();
                                     }
                                 }
                                 if (count($afs->improvementsBuildingsArray)) {
                                     foreach ($afs->improvementsBuildingsArray as $afsKey => $afsValue) {
                                         $actualUse = $afsValue->getActualUse();
                                         $improvementsBuildingsActualUses = new improvementsBuildingsActualUses();
                                         $improvementsBuildingsActualUses->selectRecord($actualUse);
                                         $Code = $improvementsBuildingsActualUses->getCode();
                                     }
                                 }
                                 if ($munCityID == $this->formArray['municipalityCityID']) {
                                     $this->tpl->set_var(location, $location);
                                     $this->tpl->set_var("class", $Code);
                                     $this->tpl->set_var(kind, strtoupper(substr($propertyType, 0, 4)));
                                     $this->tpl->set_var(currentTDNo, $TaxDeclarationNumber);
                                     $this->tpl->set_var(municipality, $addr->getMunicipalityCity());
                                     //$dues = new Dues();
                                     //$dues->create($td->getTdID(),"2003");
                                     //$totTaxDue += $dues->getSEF()+$dues->getBasic();
                                     $dues = new Dues($tvalue->getTdID(), $rptop->getTaxableYear(), $assessedValue);
                                     $paymentPeriod = $dues->getPaymentMode();
                                     $totalTaxDue = $dues->getPaidBasic($paymentPeriod) + $dues->getPaidSEF($paymentPeriod) + $dues->getPaidIdle($paymentPeriod);
                                     if ($dues->getAmnesty()) {
                                         $dues->setPctPenalty(0.0);
                                     } else {
                                         $totalTaxDue += $dues->getPenalty($paymentPeriod);
                                     }
                                     if ($dues->getIsDiscount()) {
                                         $taxDue->setDiscount($totalTaxDue);
                                         $totalTaxDue -= $dues->getDiscount();
                                     }
                                     $interest = $dues->getPctPenalty();
                                     if ($interest > 0 && $paymentPeriod != "Annual") {
                                         $paymentPeriod = "Annual";
                                     }
                                     $basic = number_format($dues->getPaidBasic(), "2", ".", "");
                                     $this->tpl->set_var(basic, $basic);
                                     $totBasic += $basic;
                                     $sef = number_format($dues->getPaidSEF(), "2", ".", "");
                                     $this->tpl->set_var(sef, $sef);
                                     $totSEF += number_format($sef, "2", ".", "");
                                     $this->tpl->set_var(total, number_format($sef + $basic, "2", ".", ""));
                                     $this->tpl->set_var(marketValue, number_format($afs->getTotalMarketValue(), 2));
                                     $totMarketValue += $afs->getTotalMarketValue();
                                     $this->tpl->set_var(assessedValue, number_format($afs->getTotalAssessedValue(), 2));
                                     $totAssessedValue += $afs->getTotalAssessedValue();
                                     $pIndexNo = $afs->getPropertyIndexNumber();
                                     if ($pIndexNo == "") {
                                         $pIndexNo = "No value specified";
                                     }
                                     $ypos = $ypos - 10;
                                     $this->tpl->set_var(ypos, $ypos);
                                     $this->tpl->set_var(pin, $pIndexNo);
                                     $this->tpl->parse("RowBlk", "ROW", true);
                                 }
                             }
                             #end foreach($value)
                         }
                         #end if coun value
                         $this->tpl->set_var(totalMarketValue, number_format($totMarketValue, 2));
                         $this->tpl->set_var(totalAssessedValue, number_format($totAssessedValue, 2));
                         $this->tpl->set_var(totalBasic, number_format($totBasic, 2));
                         $this->tpl->set_var(totalSEF, number_format($totSEF, 2));
                         $this->tpl->set_var(totalTaxDue, number_format($totalTaxDue, 2));
                     }
                 }
             }
         }
     }
     $this->setForm();
     $this->tpl->set_var("Session", $this->sess->url(""));
     /*		$this->tpl->parse("templatePage", "rptsTemplate");
     		$this->tpl->finish("templatePage");
     		$this->tpl->p("templatePage");
     */
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $rptrpdf = new PDFWriter();
     $rptrpdf->setOutputXML($this->tpl->get('templatePage'), "string");
     $rptrpdf->writePDF("viewSOA.pdf");
 }
Beispiel #2
0
 function recordReceipt($varValues)
 {
     # create receipt object
     $collections = new Collections();
     # set the details of the receipt
     $collections->setOldReceiptNum($varValues['prevORNum']);
     $collections->setRPTOPNum($varValues['rptopNum']);
     $tdID = $varValues['tdID'];
     $amountPaid = $varValues['amountPaid'];
     $isAmnesty = isset($varValues['amnesty']) ? "Yes" : "No";
     $proceed = true;
     // insert backtaxTD record as a payment
     // and FLAG backtaxTD as PAID!!! ;)
     if ($_POST["backtaxTDCheckbox"]) {
         $backtaxTDID = $_POST['backtaxTDCheckbox'];
         $backtaxTD = new BacktaxTD();
         $backtaxTD->selectRecord("", $backtaxTDID);
         $assessedValue = $backtaxTD->getTotalAssessedValue();
         $paymentPeriod = $_POST['paymentPeriod'];
         $application = $paymentPeriod;
         $penalty = $backtaxTD->getTotalPenalties();
         $totalTaxDue = $backtaxTD->getTotalTaxDue();
         $totalTaxes = $backtaxTD->getTotalTaxes();
         $amountPaid = str_replace(",", "", $amountPaid);
         if ($totalTaxDue > $amountPaid) {
             // payment is partial
             $totalPaid = $backtaxTD->getTotalPaid() + $amountPaid;
             $backtaxTD->setTotalPaid($totalPaid);
             $backtaxTD->updateRecord();
             // FLAG paidStatus as "" (NOT YET FULLY PAID) for backtaxTDRecord
             $backtaxTD->updatePaidStatus("");
             $amountPaid = 0;
         } else {
             if ($totalTaxDue <= $amountPaid) {
                 // payment is full or exceeding full to payoff successive TD's
                 // FLAG paidStatus as PAID for backtaxTDRecord
                 $backtaxTD->updatePaidStatus("PAID");
                 $backtaxTD->setTotalPaid($totalTaxes);
                 $backtaxTD->updateRecord();
                 $amountPaid = $amountPaid - $totalTaxDue;
             }
         }
         //Partial payment handler??
         $basic = $backtaxTD->getTotalBasicTax();
         $sef = $backtaxTD->getTotalSEFTax();
         $idle = $backtaxTD->getTotalIdleTax();
         $discount = 0;
         # record the payments for each receipt
         # recomputed instead of getting values from $_POST
         # used createRecord
         $payments[0] = new Payment("sef");
         $payments[0]->setApplication($application);
         $payments[0]->createRecord("000");
         $payments[0]->setAmount($sef);
         $payments[0]->setDiscount("0");
         $payments[0]->setPenalty("0");
         $payments[0]->setDueID("000");
         $payments[0]->setDueType("backtaxTDID-sef,backtaxTDID=" . $backtaxTD->getBacktaxTDID());
         $payments[0]->setReceiptNum($varValues['receiptNo']);
         $payments[0]->storeRecord();
         $collections->addPayment($payments[0]);
         $payments[1] = new Payment("basic");
         $payments[1]->setApplication($application);
         $payments[1]->createRecord("000");
         $payments[1]->setAmount($basic);
         $payments[1]->setDiscount("0");
         $payments[1]->setPenalty("0");
         $payments[1]->setDueID("000");
         $payments[1]->setDueType("backtaxTD-basic,backtaxTDID=" . $backtaxTD->getBacktaxTDID());
         $payments[1]->setReceiptNum($varValues['receiptNo']);
         $payments[1]->storeRecord();
         $collections->addPayment($payments[1]);
         $payments[2] = new Payment("idle");
         $payments[2]->setApplication($application);
         $payments[2]->createRecord("000");
         $payments[2]->setAmount($idle);
         $payments[2]->setDiscount("0");
         $payments[2]->setPenalty("0");
         $payments[2]->setDueID("000");
         $payments[2]->setDueType("backtaxTD-idle,backtaxTDID=" . $backtaxTD->getBacktaxTDID());
         $payments[2]->setReceiptNum($varValues['receiptNo']);
         $payments[2]->storeRecord();
         $collections->addPayment($payments[2]);
         $payments[3] = new Payment("penalty");
         $payments[3]->setApplication($application);
         $payments[3]->createRecord("0");
         $payments[3]->setAmount($penalty);
         $payments[3]->setDiscount("0");
         $payments[3]->setPenalty("0");
         $payments[3]->setDueID("000");
         $payments[3]->setDueType("backtaxTD-penalty,backtaxTDID=" . $backtaxTD->getBacktaxTDID());
         $payments[3]->setReceiptNum($varValues['receiptNo']);
         $payments[3]->storeRecord();
         $collections->addPayment($payments[3]);
         $payments[4] = new Payment("pd1185");
         $payments[4]->setApplication($application);
         $payments[4]->createRecord("000");
         $payments[4]->setAmount("0");
         $payments[4]->setDiscount("0");
         $payments[4]->setPenalty("0");
         $payments[4]->setDueID("000");
         $payments[4]->setDueType("backtaxTD-pd1185,backtaxTDID=" . $backtaxTD->getBacktaxTDID());
         $payments[4]->setReceiptNum($varValues['receiptNo']);
         $payments[4]->storeRecord();
         $collections->addPayment($payments[4]);
         //$taxDue->reapplyPayments();
         //$taxDue->store();
         //print_r($payments);
         if (!$proceed) {
             break;
         }
     }
     if (is_array($tdID)) {
         foreach ($tdID as $key => $id) {
             $td = new TD();
             $td->selectRecord($id);
             # get assessed value and use it to compute taxes -- 07 Aug 2003
             $propertyType = $td->getPropertyType();
             $propertyID = $td->getPropertyID();
             $assessedValue = number_format($td->getAssessedValue(), 2, ".", "");
             $tdNum = $td->getTaxDeclarationNumber();
             $collections->setTDNum($tdNum);
             # get the specific due by using the tdNum and the date on the RPTOP
             $rptop = new RPTOP();
             # changed to taxableYear & selected record using rptopID instead of rptopNum
             if ($rptop->selectRecord($varValues['rptopID'])) {
                 $dueDate = $rptop->getTaxableYear();
             } else {
                 # did not find due date in POST
                 // if there is no valid RPTOP provided, then just use the dueDate
                 $dueDate = $varValues['dueDate'];
             }
             $dueDate = $td->getTaxBeginsWithTheYear();
             $taxDue = new Dues($id, $dueDate);
             /*$taxDue = new Dues();*/
             if (!$taxDue->create($id, $dueDate)) {
                 $taxDue->setBasic($assessedValue);
                 $taxDue->setSEF($assessedValue);
                 # check if land is idle, if yes, set assessed value
                 if ($taxDue->getIdleStatus() == 1) {
                     $taxDue->setIdle($assessedValue);
                     $idleStatus = 1;
                 } else {
                     $taxDue->setIdle(0);
                     $idleStatus = 0;
                 }
             }
             $paymentPeriod = $taxDue->getPaymentMode();
             if ($taxDue->getPctPenalty() > 0 && $paymentPeriod != "Annual") {
                 $paymentPeriod = "Annual";
             }
             $application = $paymentPeriod;
             if ($application == "Quarter") {
                 $application = "Q" . ceil(date("n") / 3);
                 $taxDue->setPaidQuarters(ceil(date("n") / 3));
             }
             #echo("b=$basic<br>s=$sef<br>i=$idle");
             # if amnesty declared, no interest on late payments, set penalty to 0
             if (isset($varValues['amnesty']) || $taxDue->getIsDiscount()) {
                 $taxDue->setAmnesty("Yes");
                 $taxDue->resetPenalty();
                 $interest = 0;
             } else {
                 $taxDue->setAmnesty("No");
                 $interest = $taxDue->getPctPenalty();
             }
             $penalty = $taxDue->getBalancePenalty($paymentPeriod);
             $totalTaxDue = $taxDue->getTotalDue($paymentPeriod);
             //Partial payment handler
             $basic = $taxDue->getBalanceBasic($paymentPeriod);
             $sef = $taxDue->getBalanceSEF($paymentPeriod);
             $idle = $taxDue->getBalanceIdle($paymentPeriod);
             $discount = $taxDue->getDiscount();
             $discountSEF = $taxDue->getIsDiscount() ? $sef * $taxDue->getDiscountPercentage() / 100 : 0;
             $discountBasic = $taxDue->getIsDiscount() ? $basic * $taxDue->getDiscountPercentage() / 100 : 0;
             if (str_replace(",", "", $amountPaid) < $totalTaxDue) {
                 $basic = round(str_replace(",", "", $amountPaid) * (($basic - $discountBasic) / $totalTaxDue), 2);
                 $sef = round(str_replace(",", "", $amountPaid) * (($sef - $discountSEF) / $totalTaxDue), 2);
                 $idle = round(str_replace(",", "", $amountPaid) * ($idle / $totalTaxDue), 2);
                 $penalty = round(str_replace(",", "", $amountPaid) * ($penalty / $totalTaxDue), 2);
                 $proceed = false;
             }
             # record the payments for each receipt
             # recomputed instead of getting values from $_POST
             # used createRecord
             $payments[0] = new Payment("sef");
             $payments[0]->setApplication($application);
             $payments[0]->createRecord($taxDue->getDueID());
             $payments[0]->setAmount($sef);
             $payments[0]->setDiscount($discountSEF);
             $payments[0]->setPenalty($sef * $interest);
             $payments[0]->setDueID($taxDue->getDueID());
             $payments[0]->setDueType("sef");
             $payments[0]->setReceiptNum($varValues['receiptNo']);
             $payments[0]->storeRecord();
             $collections->addPayment($payments[0]);
             # $gfTotal = ($basic*0.7)*(1+interest);
             # $ibTotal = ($basic*0.15)*(1+interest);
             # $cbTotal = ($basic*0.15)*(1+interest);
             $payments[1] = new Payment("basic");
             $payments[1]->setApplication($application);
             $payments[1]->createRecord($taxDue->getDueID());
             $payments[1]->setAmount($basic);
             $payments[1]->setDiscount($discountBasic);
             $payments[1]->setPenalty($basic * $interest);
             $payments[1]->setDueID($taxDue->getDueID());
             $payments[1]->setDueType("basic");
             $payments[1]->setReceiptNum($varValues['receiptNo']);
             $payments[1]->storeRecord();
             $collections->addPayment($payments[1]);
             $payments[2] = new Payment("idle");
             $payments[2]->setApplication($application);
             $payments[2]->createRecord($taxDue->getDueID());
             $payments[2]->setAmount($idle);
             $payments[2]->setDiscount(0);
             $payments[2]->setPenalty($idle * $interest);
             $payments[2]->setDueID($taxDue->getDueID());
             $payments[2]->setDueType("idle");
             $payments[2]->setReceiptNum($varValues['receiptNo']);
             $payments[2]->storeRecord();
             $collections->addPayment($payments[2]);
             $payments[3] = new Payment("penalty");
             $payments[3]->setApplication($application);
             $payments[3]->createRecord($taxDue->getDueID());
             $payments[3]->setAmount($penalty);
             $payments[3]->setDiscount(0);
             $payments[3]->setPenalty(0);
             $payments[3]->setDueID($taxDue->getDueID());
             $payments[3]->setDueType("penalty");
             $payments[3]->setReceiptNum($varValues['receiptNo']);
             $payments[3]->storeRecord();
             $collections->addPayment($payments[3]);
             $payments[4] = new Payment("pd1185");
             $payments[4]->setApplication($application);
             $payments[4]->createRecord($taxDue->getDueID());
             $payments[4]->setAmount(round(0, 2));
             $payments[4]->setDiscount(0);
             $payments[4]->setPenalty(0);
             $payments[4]->setDueID($taxDue->getDueID());
             $payments[4]->setDueType("pd1185");
             $payments[4]->setReceiptNum($varValues['receiptNo']);
             #				print_r($payments);
             $payments[4]->storeRecord();
             $collections->addPayment($payments[4]);
             $taxDue->reapplyPayments();
             $taxDue->store();
             if (!$proceed) {
                 break;
             }
         }
     }
     # end foreach
     //*
     // get parent TD
     //$tdID = $backtaxTD->getTDID();
     //*/
     # set collection details and save to db; no receipt number yet
     # format date to db date YYYY-MM-DD
     list($month, $day, $year) = explode("-", $varValues['checkDate']);
     list($oldReceiptMonth, $oldReceiptDay, $oldReceiptYear) = explode("-", $varValues['prevORDate']);
     $collections->setCollectionDate(date("Y-m-d"));
     $collections->setCollectionSum($varValues['collectionSum']);
     $collections->setReceivedFrom($varValues['receivedFrom']);
     $collections->setKindOfPayment($varValues['kindOfPayment']);
     $collections->setCheckNum($varValues['checkNum']);
     $collections->setCheckDate($year . "-" . $month . "-" . $day);
     $collections->setOldReceiptNum($varValues['prevORNum']);
     $collections->setOldReceiptDate($oldReceiptYear . "-" . $oldReceiptMonth . "-" . $oldReceiptDay);
     $collections->setMunicipality($varValues['municipalityCityID']);
     $collections->setAmnesty($isAmnesty);
     $collections->createRecord();
     $collections->storeRecord();
     # get collection id and use it to close receipt
     $collectionID = $collections->getCollectionID();
     $_POST['collectionID'] = $collectionID;
 }