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