Added Lease History and security deposit tracking.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@19 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-05-28 07:05:05 +00:00
parent 0021eb1768
commit ffe04ed6fd

View File

@@ -5,7 +5,6 @@
<?php
$date_fmt = 'm/d/Y';
function currency($number) {
if ($number < 0)
return "($ " . number_format(-1*$number, 2) . ")";
@@ -23,6 +22,13 @@ function phone($phone) {
return $phone;
}
function datefmt($date) {
$date_fmt = 'm/d/Y';
return ($date
? date_format(date_create($date), $date_fmt)
: null);
}
/**********************************************************************
* Tenant Info
*/
@@ -113,9 +119,33 @@ if (count($rows)) {
}
/**********************************************************************
* Lease History
*/
$headers = array('Lease', 'Unit', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
$rows = array();
foreach($tenant['Lease'] AS $lease) {
$rows[] = array('#'.$lease['id'],
$lease['Unit']['name'],
datefmt($lease['lease_date']),
datefmt($lease['movein_date']),
datefmt($lease['moveout_date']),
$lease['amount'],
$lease['deposit'],
$lease['comment']);
}
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Lease History</CAPTION>' . "\n");
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('</table>' . "\n");
/**********************************************************************
* Ledger History
*/
$security_deposit = 0;
$grand_total = 0;
foreach($tenant['Lease'] AS $lease) {
$headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
@@ -125,8 +155,7 @@ foreach($tenant['Lease'] AS $lease) {
foreach($lease['Charge'] AS $charge) {
$amount = $charge['total'];
$running_total += $amount;
$rows[] = array(date_format(date_create($charge['charge_date']), $date_fmt) . ' - ' .
date_format(date_create($charge['charge_to_date']), $date_fmt),
$rows[] = array(datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
'#'.$charge['id'],
$charge['ChargeType']['name'],
$charge['comment'],
@@ -136,8 +165,11 @@ foreach($tenant['Lease'] AS $lease) {
foreach ($charge['Receipt'] AS $receipt) {
$amount = -1 * $receipt['ChargesReceipt']['amount'];
$running_total += $amount;
$rows[] = array(' -- ' .date_format(date_create($receipt['stamp']), $date_fmt),
//null,
// REVISIT <AP> 20090527:
// Using hardcoded value for security deposit... can't be good!
if ($charge['charge_type_id'] == 1)
$security_deposit += $receipt['ChargesReceipt']['amount'];
$rows[] = array(' -- ' . datefmt($receipt['stamp']),
'#'.$receipt['id'],
'Payment/Receipt',
$receipt['comment'],
@@ -148,7 +180,7 @@ foreach($tenant['Lease'] AS $lease) {
$grand_total += $running_total;
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Lease #'.$lease['number'].' (Unit '.$lease['Unit']['name'].')</CAPTION>' . "\n");
echo(' <CAPTION>Lease #'.$lease['number'].' ('.$lease['Unit']['name'].')</CAPTION>' . "\n");
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('</table>' . "\n");
@@ -156,5 +188,6 @@ foreach($tenant['Lease'] AS $lease) {
}
?>
<DIV ALIGN=RIGHT><H3>Total Security Deposit: <?php echo currency($security_deposit); ?></H3></DIV>
<DIV ALIGN=RIGHT><H3>Outstanding Balance: <?php echo currency($grand_total); ?></H3></DIV>
</div>