/**
  * Build records that will be used in rendering the reports
  * @param int $prop_id ID used to identify the property
  * @param string $start Date string specifying start of the period
  * @param sring $end Date string specifyinng end of the period
  * @return array $record_objects An array of record objects
  */
 public static function buildRecords($prop_id, $start, $end)
 {
     $room_count = Room::getNumRoomsForProperty($prop_id);
     $rooms = Room::findByPropertyId($prop_id);
     $record_objects = array();
     $aobj = new Arrears();
     for ($i = 0; $i < $room_count; $i++) {
         $record = new self();
         $rm = $rooms[$i];
         $record->room_label = $rm->getRoomLabel();
         if (!is_null($rm->getTenantId())) {
             $tenant = Tenant::findByRoomId($rm->id);
             $rent_obj = Rent::findByPeriodForTenant($tenant->id, $start, $end);
             $rent_paid = !is_null($rent_obj) ? $rent_obj->getPaymentAmount() : NULL;
             $receipt = !is_null($rent_obj) ? $rent_obj->getReceiptNo() : NULL;
             $remarks = !is_null($rent_obj) ? $rent_obj->getRemarks() : NULL;
             $arrears_paid = ArrearsPaid::calcAmountPaidByTenantDuringPeriod($tenant->id, $start, $end);
             $arrears = $aobj->calcTotalArrearsFromTenant($tenant->id);
             $deposit_obj = Deposit::findByPeriodForTenant($tenant->id, $start, $end);
             $deposit_paid = !is_null($deposit_obj) ? $deposit_obj->getPaymentAmount() : NULL;
             $kplc_obj = DepositKPLC::findByPeriodForTenant($tenant->id, $start, $end);
             $kplc_paid = !is_null($kplc_obj) ? $kplc_obj->getPaymentAmount() : NULL;
             $eldowas_obj = DepositEldowas::findByPeriodForTenant($tenant->id, $start, $end);
             $eldowas_paid = !is_null($eldowas_obj) ? $eldowas_obj->getPaymentAmount() : NULL;
             $totals = $tenant->calcPaymentsMadeDuringPeriod($start, $end);
             $record->tenant = $tenant->getFullName();
             $record->receipt_no = $receipt;
             $record->rent_pm = $rm->getRent();
             $record->rent_paid = $rent_paid;
             $record->arrears_paid = $arrears_paid;
             $record->arrears = $arrears;
             $record->house_deposit = $deposit_paid;
             $record->kplc_deposit = $kplc_paid;
             $record->eldowas_deposit = $eldowas_paid;
             $record->totals = $totals;
             $record->remarks = $remarks;
         } else {
             $record->tenant = "VACANT";
             $record->rent_pm = $rm->getRent();
         }
         $record_objects[] = $record;
     }
     return $record_objects;
 }
 /**
  * Generate the HTML of the receipt print
  */
 public function buildArrearsReceipt()
 {
     global $session;
     $html = '<div id="outerHTML">';
     $html .= '<div id="printArea">';
     $html .= '<h2 align="center">Salesforce</h2>';
     $html .= '<h3 align="center">Official Receipt: Arrears Payment</h3>';
     $html .= '<div id="receipt-header">';
     $html .= '<p align="center">';
     $html .= 'Kenyatta Street, New Muya House<br />';
     $html .= '2<sup>nd</sup> Flr, Room 105.<br />';
     $html .= 'Tel: + 254 721 156 315 &nbsp; / &nbsp; + 254 720 711 115<br />';
     $html .= 'www.salesforce.co.ke &nbsp; Email: info@salesforce.co.ke';
     $html .= '</p></div>';
     $html .= '<hr align="center" />';
     $html .= '<div id="receipt-body">';
     $html .= '<p><strong>Receipt No:</strong> &nbsp;<span style="color:#F00;">';
     $html .= $this->_receipt_no;
     $html .= '</span></p>';
     $html .= '<p><strong>Tenant:</strong> &nbsp;';
     $tenant = Tenant::findById($this->_tid);
     $html .= $tenant->getFullName() . '</p>';
     $html .= '<p><strong>Room No:</strong> &nbsp;';
     $html .= Room::findById(Tenant::findById($this->_tid)->getRoomId())->getRoomLabel();
     $html .= '</p><p><strong>Payment Amount:</strong> &nbsp;';
     //$html .= number_format($session->sessionVar('amount'));
     $html .= number_format($this->_amount);
     if ($tenant->hasArrears()) {
         $arrears = new Arrears();
         $html .= '</p><p><strong>Arrears</strong>&nbsp;';
         $html .= $arrears->calcTotalArrearsFromTenant($this->_tid);
     }
     $html .= '</p><p><strong>Month:</strong>&nbsp;';
     $html .= $this->_getMonthFromDate($this->_start_date);
     $html .= '</p><p><strong>Company Agent:</strong> &nbsp;';
     $html .= $this->_agent . '</p>';
     $html .= '<p><strong>Date:</strong> &nbsp;';
     $html .= $this->_date_paid . " &nbsp;&nbsp;";
     $html .= '</p></div>';
     $html .= '</div></div>';
     print $html;
 }
예제 #3
0
 /**
  * Get the total amount of outstanding rent payments 
  * owed by this tenant
  * @return int
  */
 public function getTotalArrears()
 {
     if ($this->hasArrears()) {
         $arrears = new Arrears();
         return $arrears->calcTotalArrearsFromTenant($this->id);
     }
 }