Files
pmgr/views/units/view.ctp
abijah fc71c058fb Added links everywhere for charge/payment/receipt. Also, minor tweaking to the views in a couple places.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@64 97e9348a-65ac-dc4b-aefc-98561f571b83
2009-06-01 08:39:33 +00:00

126 lines
3.6 KiB
PHP

<?php /* -*- mode:PHP -*- */ ?>
<div class="units view">
<?php
function currency($number) {
if ($number < 0)
return "($ " . number_format(-1*$number, 2) . ")";
else
return "$ " . number_format($number, 2);
}
function datefmt($date) {
$date_fmt = 'm/d/Y';
return ($date
? date_format(date_create($date), $date_fmt)
: null);
}
/**********************************************************************
* Unit Info
*/
$rows = array(array('Name', $unit['Unit']['name']),
array('Status', $unit['Unit']['status']),
array('Comment', $unit['Unit']['comment']));
echo $this->element('table',
array('class' => 'item unit detail',
'caption' => 'Unit Info',
'rows' => $rows,
'column_class' => array('field', 'value')));
?>
<DIV CLASS="infobox unit">
<DIV CLASS="summary grand deposit">
Security Deposit: <?php echo currency($outstandingDeposit); ?>
</DIV>
<DIV CLASS="summary grand balance">
Balance: <?php echo currency($outstandingBalance); ?>
</DIV>
</DIV>
<?php
/**********************************************************************
* Lease History
*/
$headers = array('Lease', 'Tenant', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
$rows = array();
foreach($unit['Lease'] AS $lease) {
$rows[] = array('#'.$lease['number'],
$html->link($lease['Contact'][0]['display_name'],
array('controller' => 'contacts',
'action' => 'view',
$lease['Contact'][0]['id'])),
datefmt($lease['lease_date']),
datefmt($lease['movein_date']),
datefmt($lease['moveout_date']),
$lease['amount'],
$lease['deposit'],
$lease['comment']);
}
echo $this->element('table',
array('class' => 'item lease list',
'caption' => 'Lease History',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/**********************************************************************
* Ledger History
*/
foreach($unit['Lease'] AS $lease) {
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
$rows = array();
$running_total = 0;
$odd = 0;
foreach($lease['Charge'] AS $charge) {
$amount = $charge['total'];
$running_total += $amount;
$rows[] = array($html->link('#'.$charge['id'],
array('controller' => 'charges',
'action' => 'view',
$charge['id'])),
datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
$charge['ChargeType']['name'],
$charge['comment'],
currency($amount),
currency($running_total));
$row_class[] = array('charge', (++$odd % 2) ? 'oddrow' : 'evnrow');
foreach ($charge['Receipt'] AS $receipt) {
$amount = -1 * $receipt['ChargesReceipt']['amount'];
$running_total += $amount;
$rows[] = array($html->link('#'.$receipt['id'],
array('controller' => 'receipts',
'action' => 'view',
$receipt['id'])),
' -- ' . datefmt($receipt['stamp']),
'Payment Applied',
$receipt['comment'],
currency($amount),
currency($running_total));
$row_class[] = array('receipt', ($odd % 2) ? 'oddrow' : 'evnrow');
}
}
echo $this->element('table',
array('class' => 'item ledger list',
'caption' => 'Lease #'.$lease['number'].' (Tenant: '.$lease['Contact'][0]['display_name'].')',
'suppress_alternate_rows' => true,
'headers' => $headers,
'rows' => $rows,
'row_class' => $row_class,
'column_class' => $headers));
}
?>
</div>