git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@64 97e9348a-65ac-dc4b-aefc-98561f571b83
88 lines
2.4 KiB
PHP
88 lines
2.4 KiB
PHP
<?php /* -*- mode:PHP -*- */ ?>
|
|
|
|
<div class="charges 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);
|
|
}
|
|
|
|
/**********************************************************************
|
|
* Charge Info
|
|
*/
|
|
|
|
$rows = array(array('ID', $charge['Charge']['id']),
|
|
array('Date', datefmt($charge['Charge']['charge_date'])),
|
|
array('Through', datefmt($charge['Charge']['charge_to_date'])),
|
|
array('Due', datefmt($charge['Charge']['due_date'])),
|
|
array('Type', $charge['ChargeType']['name']),
|
|
array('Lease', '#'.$charge['Lease']['number']),
|
|
array('Amount', currency($charge['Charge']['amount'])),
|
|
array('Tax', currency($charge['Charge']['tax'])),
|
|
array('Total', currency($charge['Charge']['total'])),
|
|
array('Comment', $charge['Charge']['comment']));
|
|
|
|
echo $this->element('table',
|
|
array('class' => 'item charge detail',
|
|
'caption' => 'Charge Info',
|
|
'rows' => $rows,
|
|
'column_class' => array('field', 'value')));
|
|
|
|
|
|
?>
|
|
<DIV CLASS="infobox charge">
|
|
<DIV CLASS="summary grand payment">
|
|
Amount Received: <?php echo currency($paymentAmount); ?>
|
|
</DIV>
|
|
<DIV CLASS="summary grand balance">
|
|
Amount Owing: <?php echo currency($balanceAmount); ?>
|
|
</DIV>
|
|
</DIV>
|
|
<?php
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
* Receipts
|
|
*/
|
|
|
|
$headers = array('ID', 'Timestamp', 'Comment', 'Applied', 'Balance');
|
|
$rows = array();
|
|
$running_total = $charge['Charge']['total'];
|
|
foreach($charge['Receipt'] AS $receipt) {
|
|
$amount = $receipt['ChargesReceipt']['amount'];
|
|
$running_total -= $amount;
|
|
$rows[] = array($html->link('#'.$receipt['id'],
|
|
array('controller' => 'receipts',
|
|
'action' => 'view',
|
|
$receipt['id'])),
|
|
datefmt($receipt['stamp']),
|
|
$receipt['comment'],
|
|
currency($receipt['ChargesReceipt']['amount']),
|
|
currency($running_total)
|
|
);
|
|
}
|
|
|
|
echo $this->element('table',
|
|
array('class' => 'item receipt list',
|
|
'caption' => 'Receipts towards Charge',
|
|
'headers' => $headers,
|
|
'rows' => $rows,
|
|
'column_class' => $headers));
|
|
|
|
|
|
?>
|
|
|
|
</div>
|