Files
pmgr/views/transactions/view.ctp

103 lines
2.9 KiB
PHP

<?php /* -*- mode:PHP -*- */ ?>
<div class="transaction 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);
}
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Transaction Detail Main Section
*/
$rows = array(array('ID', $transaction['Transaction']['id']),
array('Timestamp', datefmt($transaction['Transaction']['stamp'])),
array('Comment', $transaction['Transaction']['comment']));
echo $this->element('table',
array('class' => 'item transaction detail',
'caption' => 'Transaction Info',
'rows' => $rows,
'column_class' => array('field', 'value')));
/**********************************************************************
* Transaction Info Box
*/
?>
<DIV CLASS="infobox">
<DIV CLASS="summary grand debit">
Debits: <?php echo currency($debitAmount); ?>
</DIV>
<DIV CLASS="summary grand credit">
Credits: <?php echo currency($creditAmount); ?>
</DIV>
</DIV>
<DIV CLASS="detail supporting">
<?php
; // Editor alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Supporting Elements Section
*/
/**********************************************************************
* Entries
*/
$headers = array('Name', 'Debit', 'Credit', 'Comment', 'Amount', 'Total');
$rows = array();
$running_total = 0;
foreach($transaction['LedgerEntry'] AS $entry) {
$amount = $entry['amount'];
$running_total += $amount;
$rows[] = array($entry['name'],
$html->link($entry['DebitLedger']['name'],
array('controller' => 'ledgers',
'action' => 'view',
$entry['DebitLedger']['id'])),
$html->link($entry['CreditLedger']['name'],
array('controller' => 'ledgers',
'action' => 'view',
$entry['CreditLedger']['id'])),
$entry['comment'],
currency($entry['amount']),
currency($running_total)
);
}
echo $this->element('table',
array('class' => 'item entry list',
'caption' => 'Entries in Transaction',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/* End "detail supporting" DIV */ ?>
</DIV>
</div>