git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@81 97e9348a-65ac-dc4b-aefc-98561f571b83
70 lines
2.0 KiB
PHP
70 lines
2.0 KiB
PHP
<?php /* -*- mode:PHP -*- */
|
|
|
|
if (isset($heading))
|
|
echo $heading;
|
|
elseif (!isset($caption))
|
|
echo '<h2>'.__('Ledger Entries',true).'</h2>';
|
|
|
|
$headers = array('Transaction', 'Entry', 'Date', 'Comment', 'Debit', 'Credit', 'Total');
|
|
$column_class = array();
|
|
foreach (array_intersect($headers, array('Transaction', 'Entry')) AS $k => $v) {
|
|
$column_class[$k] = 'id';
|
|
}
|
|
foreach (array_intersect($headers, array('Debit', 'Credit', 'Total')) AS $k => $v) {
|
|
$column_class[$k] = 'currency';
|
|
}
|
|
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
|
$column_class[$k] = 'slack';
|
|
}
|
|
|
|
|
|
$rows = array();
|
|
$running_total = 0;
|
|
foreach($ledger_entries AS $entry) {
|
|
$credit = $debit = null;
|
|
$running_total += $entry[0]['balance'];
|
|
|
|
if (isset($entry[0]['debit']))
|
|
$debit = $entry[0]['debit'];
|
|
if (isset($entry[0]['credit']))
|
|
$credit = $entry[0]['credit'];
|
|
|
|
// local references to linked tables
|
|
$transaction = $entry['Transaction'];
|
|
|
|
// Now that we've extracted top level 'LedgerEntry' data
|
|
// move our variable to the meat of 'LedgerEntry' for clarity
|
|
if (isset($entry['LedgerEntry']))
|
|
$entry = $entry['LedgerEntry'];
|
|
|
|
$rows[] = array(isset($transaction['id'])
|
|
? $html->link('#'.$transaction['id'],
|
|
array('controller' => 'transactions',
|
|
'action' => 'view',
|
|
$transaction['id']))
|
|
: null,
|
|
|
|
isset($entry['id'])
|
|
? $html->link('#'.$entry['id'],
|
|
array('controller' => 'ledger_entries',
|
|
'action' => 'view',
|
|
$entry['id']))
|
|
: null,
|
|
|
|
FormatHelper::date($transaction['stamp']),
|
|
FormatHelper::comment(array($transaction['comment'], $entry['comment'])),
|
|
FormatHelper::currency($debit),
|
|
FormatHelper::currency($credit),
|
|
FormatHelper::currency($running_total)
|
|
);
|
|
}
|
|
|
|
echo $this->element('table',
|
|
array('class' => 'item ledger-entries list',
|
|
'caption' => isset($caption) ? $caption : null,
|
|
'headers' => $headers,
|
|
'rows' => $rows,
|
|
'column_class' => $column_class));
|
|
|
|
?>
|