$session->message($mesg);
            redirect_to("tenant_deposit.php?tid={$tenant_id}");
        }
    }
}
/////////////////////////////////////////////////////////////////
///////////////////////// PROCESS SUBMIT ////////////////////////
/////////////////////////////////////////////////////////////////
if (isset($_POST['submit'])) {
    $date_paid = $_POST['paid'];
    $amount = $_POST['amount'];
    if (empty($date_paid) || empty($amount)) {
        $err = "Form fields marked with an asterix are required";
    } else {
        $tenant_id = (int) $_GET['tid'];
        $dpt = new DepositEldowas();
        $dpt->setTenantId($tenant_id);
        $dpt->setRoomId($tenant_id);
        $dpt->setTenantName($tenant_id);
        $dpt->setPaymentAmount($amount);
        $dpt->generateReceiptNo();
        $dpt->setAgent();
        $dpt->setDatePaid($date_paid);
        /**echo "<tt><pre>".var_export($dpt, true)."</pre></tt>";
        			echo "Last Receipt No: ";
        			echo $dpt->_lastReceiptNo().'<br />';*/
        /**echo "Tenant ID: ";
        			echo $tenant_id;*/
        if ($dpt->save()) {
            Logger::getInstance()->logAction("ELDOWAS DEPOSIT", $amount, "Eldowas Deposit of {$tenant->getFullName()}");
            $mesg = "Payment posted";
        $session->message($mesg);
        redirect_to('tenants.php');
    } elseif (!valid_deposit($type)) {
        $mesg = "Deposit edit failed. An invalid value was sent through the URL";
        $session->message($mesg);
        redirect_to('tenants.php');
    } else {
        switch ($type) {
            case "house":
                $deposit = Deposit::findByTenantId($tenant_id);
                break;
            case "kplc":
                $deposit = DepositKPLC::findByTenantId($tenant_id);
                break;
            case "eldowas":
                $deposit = DepositEldowas::findByTenantId($tenant_id);
                break;
        }
    }
} else {
    $mesg = "Deposit edit failed. An invalid value was sent through the URL";
    $session->message($mesg);
    redirect_to("tenants.php");
}
/////////////////////////////////////////////////////////////////////////
//////////////////////////// PROCESS SUBMIT /////////////////////////////
/////////////////////////////////////////////////////////////////////////
if (isset($_POST['submit'])) {
    $amount = $_POST['amount'];
    $date_paid = $_POST['date_paid'];
    if (empty($amount) || empty($date_paid)) {
Esempio n. 3
0
        $session->message($mesg);
        redirect_to("tenants.php");
    } elseif (!valid_receipt($type)) {
        $mesg = "Receipt for the transaction could not be generated. An invalid value was sent through the URL";
        $session->message($mesg);
        redirect_to("tenants.php");
    } else {
        switch ($type) {
            case "deposit":
                $deposit = Deposit::findByTenantId($tenant_id);
                break;
            case "deposit_kplc":
                $dpt_kplc = DepositKPLC::findByTenantId($tenant_id);
                break;
            case "deposit_eldowas":
                $dpt_eldowas = DepositEldowas::findByTenantId($tenant_id);
                break;
            case "rent":
                $rent = Rent::findById($id);
                break;
            case "arrears":
                $ap = ArrearsPaid::findById($id);
                break;
        }
        //echo var_dump($deposit);
    }
} else {
    $mesg = "Operation Not Supported";
    $session->message($mesg);
    redirect_to("tenants.php");
}
Esempio n. 4
0
    } elseif (empty($prop_id)) {
        $err = "Please select property from which to show deposits";
    } else {
        $property = Property::findById($prop_id);
        switch ($type) {
            case 1:
                $deposits = Deposit::findByPropertyId($prop_id);
                $total_deposits = Deposit::calcDepositsForProperty($prop_id);
                break;
            case 2:
                $deposits = DepositKPLC::findByPropertyId($prop_id);
                $total_deposits = DepositKPLC::calcDepositsForProperty($prop_id);
                break;
            case 3:
                $deposits = DepositEldowas::findByPropertyId($prop_id);
                $total_deposits = DepositEldowas::calcDepositsForProperty($prop_id);
                break;
        }
    }
}
include_layout_template('admin_header.php');
?>

	<div id="container">
    <h3>Actions</h3>
    <div id="side-bar">
	<?php 
$actions = array("status" => "Payment Status", "tenant_search" => "Search Tenant", "property_arrears" => "Arrears");
echo create_action_links($actions);
?>
    </div>
 /**
  * Calculate the sum total of all deductions made on a property during
  * a specified period of time
  * @param int $prop_id ID used to identify the property
  * @param string $start Date string specifying start of the period
  * @param srting $end Date string specifying end of period
  * @return int $total_deductions
  */
 public static function calcTotalDeductionsForPeriod($prop_id, $start, $end)
 {
     $total_deductions = 0;
     $commission = self::calcCommissionOnCollection($prop_id, $start, $end);
     $commission = (int) str_replace(',', '', $commission);
     $expenses = Expense::calcTotalExpenses($prop_id, $start, $end);
     $expenses = (int) str_replace(',', '', $expenses);
     $house_dep_refunds = Deposit::calcRefundsForPeriodByProperty($prop_id, $start, $end);
     $house_dep_refunds = (int) str_replace(',', '', $house_dep_refunds);
     $kplc_refunds = DepositKPLC::calcRefundsForPeriodByProperty($prop_id, $start, $end);
     $kplc_refunds = (int) str_replace(',', '', $kplc_refunds);
     $eldowas_refunds = DepositEldowas::calcRefundsForPeriodByProperty($prop_id, $start, $end);
     $eldowas_refunds = (int) str_replace(',', '', $eldowas_refunds);
     $deductions = array($commission, $expenses, $house_dep_refunds, $kplc_refunds, $eldowas_refunds);
     $total_deductions = array_sum($deductions);
     return number_format($total_deductions);
 }
    if (empty($start_date) || empty($end_date)) {
        $err = "Choose a month from which to display rent payments from";
    } elseif (!valid_date_range($start_date, $end_date)) {
        $err = "Reports can only be specified monthly";
    } else {
        // continue with processing
        //echo var_dump($prop_id);
        $payments = Rent::getPaymentsFromProperty($prop_id, $start_date, $end_date);
        //echo var_dump($payments);
        $arrears_paid = ArrearsPaid::getPaidArrearsForProperty($prop_id, $start_date, $end_date);
        $arrears = Arrears::getOutstandingArrearsForProperty($prop_id, $start_date, $end_date);
        $expenses = Expense::findByPeriodForProperty($prop_id, $start_date, $end_date);
        $deposits = Deposit::findPaymentsForPeriodByProperty($prop_id, $start_date, $end_date);
        $refunds = Deposit::findRefundsForPeriodByProperty($prop_id, $start_date, $end_date);
        $refunds_kplc = DepositKPLC::findRefundsForPeriodByProperty($prop_id, $start_date, $end_date);
        $refunds_eldowas = DepositEldowas::findRefundsForPeriodByProperty($prop_id, $start_date, $end_date);
        $records = CollectionReport::buildRecords($prop_id, $start_date, $end_date);
        $deductions = CollectionReport::calcTotalDeductionsForPeriod($prop_id, $start_date, $end_date);
        //echo var_dump($records);
        //echo var_dump($arrears_paid);
    }
} elseif (isset($_POST['report'])) {
    // Generate PDF report
    $start_date = $_POST['start_date'];
    $end_date = $_POST['end_date'];
    if (empty($start_date) || empty($end_date)) {
        $err = "Choose a period to use in generating report";
    } else {
        // continue with processing
        //echo var_dump($prop_id);
        //Rent::generatePdfReport($prop_id, $start_date, $end_date);
 /**
  * Calculate the sum of all payments made by a tenant during a specifed
  * period of time. This includes monthly rent, rent arrears paid, house 
  * deposit, KPLC deposit and ELDOWAS deposit
  * @param string $start Date string specifying start of the period
  * @param string $end Date string specifying end of the period
  * @return int $total_payments
  */
 public function calcPaymentsMadeDuringPeriod($start, $end)
 {
     $total_amount = 0;
     $rent = Rent::findByPeriodForTenant($this->id, $start, $end);
     $arrers_paid = ArrearsPaid::calcAmountPaidByTenantDuringPeriod($this->id, $start, $end);
     $arrers_paid = $this->_formatCurrencyString($arrers_paid);
     $deposit = Deposit::findByPeriodForTenant($this->id, $start, $end);
     $kplc = DepositKPLC::findByPeriodForTenant($this->id, $start, $end);
     $eldowas = DepositEldowas::findByPeriodForTenant($this->id, $start, $end);
     $rent_amount = !is_null($rent) ? $this->_formatCurrencyString($rent->getPaymentAmount()) : 0;
     $deposit_amount = !is_null($deposit) ? $this->_formatCurrencyString($deposit->getPaymentAmount()) : 0;
     $kplc_amount = !is_null($kplc) ? $this->_formatCurrencyString($kplc->getPaymentAmount()) : 0;
     $eldowas_amount = !is_null($eldowas_amount) ? $this->_formatCurrencyString($eldowas->getPaymentAmount()) : 0;
     $total_amount = $rent_amount + $deposit_amount + $arrers_paid + $kplc_amount + $eldowas_amount;
     return number_format($total_amount);
 }