Files
pmgr/site/views/elements/ledger.ctp

81 lines
2.7 KiB
PHP

<?php /* -*- mode:PHP -*- */
$headers = array('Transaction', 'Entry', 'Date', 'Customer', 'Comment', 'Debit', 'Credit', 'Total');
$column_class = $headers;
foreach (array_intersect($column_class, array('Transaction', 'Entry')) AS $k => $v) {
$column_class[$k] = array($column_class[$k], 'id');
}
foreach (array_intersect($column_class, array('Debits', 'Credits', 'Total')) AS $k => $v) {
$column_class[$k] = array($column_class[$k], 'currency');
}
/* if (isset($paginator)) { */
/* echo $paginator->counter(array( */
/* 'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true))); */
/* $headers = array($paginator->sort('Transaction', 'transaction_id'), */
/* $paginator->sort('entry_id'), */
/* $paginator->sort('Date', 'stamp'), */
/* $paginator->sort('customer_id'), */
/* $paginator->sort('comment'), */
/* $paginator->sort('debit'), */
/* $paginator->sort('credit'), */
/* $paginator->sort('total')); */
/* } */
$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'])),
datefmt($transaction['stamp']),
$html->link($customer['name'],
array('controller' => 'customers',
'action' => 'view',
$customer['id'])),
comment(array($transaction['comment'], $entry['comment'])),
currency($debit),
currency($credit),
currency($running_total)
);
}
echo $this->element('table',
array('class' => 'item account ledger list',
'caption' => $caption,
'headers' => $headers,
'rows' => $rows,
'column_class' => $column_class));
/* if (isset($paginator)) { */
/* echo('<div class="paging">' . "\n"); */
/* echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled')); */
/* echo(' | '); */
/* echo $paginator->numbers(); */
/* echo(' | '); */
/* echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled')); */
/* echo('</div>' . "\n"); */
/* } */
?>