Added the charges controller and views. Fixed a couple minor bugs found with receipts.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@62 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-01 08:05:53 +00:00
parent cdd274adf7
commit f473a91870
6 changed files with 301 additions and 2 deletions

3
views/charges/index.ctp Normal file
View File

@@ -0,0 +1,3 @@
<div class="charges index">
<?php echo $this->element('charges', array('heading' => '<h2>'.$heading.'</h2>')) ?>
</div>

84
views/charges/view.ctp Normal file
View File

@@ -0,0 +1,84 @@
<?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');
$rows = array();
$running_total = 0;
foreach($charge['Receipt'] AS $receipt) {
$amount = $receipt['ChargesReceipt']['amount'];
$running_total += $amount;
$rows[] = array('#'.$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>