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