Moved ledgers over the jqGrid. Working reasonably well at the moment.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@131 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -1,88 +1,29 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
if (isset($heading))
|
||||
echo $heading;
|
||||
elseif (!isset($caption))
|
||||
echo '<h2>'.__('Ledgers',true).'</h2>';
|
||||
// Define the table columns
|
||||
$cols = array();
|
||||
$cols['ID'] = array('index' => 'id_sequence', 'formatter' => 'id');
|
||||
$cols['Account'] = array('index' => 'Account.name', 'formatter' => 'name', 'width' => '250');
|
||||
$cols['Entries'] = array('index' => 'entries', 'width' => '60', 'align' => 'right');
|
||||
$cols['Debits'] = array('index' => 'debits', 'formatter' => 'currency');
|
||||
$cols['Credits'] = array('index' => 'credits', 'formatter' => 'currency');
|
||||
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
|
||||
$cols['Close Date'] = array('index' => 'Ledger.close_stamp', 'formatter' => 'date');
|
||||
$cols['Comment'] = array('index' => 'Ledger.comment', 'formatter' => 'comment');
|
||||
|
||||
$headers = array_merge(array('Sequence'), //array('Name'),
|
||||
(isset($ledgers[0]['Account'])
|
||||
? array('Account')
|
||||
: array()),
|
||||
array('Entries', 'Debits', 'Credits', 'Balance', 'Close Date', 'Comment'));
|
||||
$column_class = array();
|
||||
foreach (array_intersect($headers, array('ID', 'Sequence')) AS $k => $v) {
|
||||
$column_class[$k] = 'id';
|
||||
$jqGrid_options = array('jqGridColumns' => $cols,
|
||||
'controller' => 'ledgers',
|
||||
'caption' => isset($caption) ? $caption : null);
|
||||
|
||||
if (isset($ledgers)) {
|
||||
$jqGrid_options += array('custom_ids' =>
|
||||
array_map(create_function('$data',
|
||||
'return $data["id"];'),
|
||||
$ledgers),
|
||||
'limit' => 5);
|
||||
}
|
||||
foreach (array_intersect($headers, array('Debits', 'Credits', 'Balance')) AS $k => $v) {
|
||||
$column_class[$k] = 'currency';
|
||||
}
|
||||
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||
$column_class[$k] = 'slack';
|
||||
else {
|
||||
$jqGrid_options += array('search_fields' => array('Account'));
|
||||
}
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
|
||||
$headers = array_merge(array($paginator->sort('sequence')), //array($paginator->sort('name')),
|
||||
(isset($ledgers[0]['Account'])
|
||||
? array($paginator->sort('Account', 'Account.name'))
|
||||
: array()),
|
||||
array($paginator->sort('entries'),
|
||||
$paginator->sort('debits'),
|
||||
$paginator->sort('credits'),
|
||||
$paginator->sort('balance'),
|
||||
$paginator->sort('Close Date', 'close_stamp'),
|
||||
$paginator->sort('comment')));
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
foreach ($ledgers as $ledger) {
|
||||
$account = null;
|
||||
$stats = null;
|
||||
|
||||
if (isset($ledger[0]))
|
||||
$stats = $ledger[0];
|
||||
else
|
||||
$stats = $ledger;
|
||||
|
||||
if (isset($ledger['Account']))
|
||||
$account = $ledger['Account'];
|
||||
if (isset($ledger['Ledger']))
|
||||
$ledger = $ledger['Ledger'];
|
||||
|
||||
$rows[] = array_merge(array($html->link('#'.$ledger['account_id'].'-'.$ledger['sequence'],
|
||||
array('controller' => 'ledgers',
|
||||
'action' => 'view',
|
||||
$ledger['id']))),
|
||||
(isset($account)
|
||||
? array($html->link($account['name'],
|
||||
array('controller' => 'accounts',
|
||||
'action' => 'view',
|
||||
$account['id'])))
|
||||
: array()),
|
||||
array($stats['entries'],
|
||||
FormatHelper::currency($stats['debits']),
|
||||
FormatHelper::currency($stats['credits']),
|
||||
FormatHelper::currency($stats['balance']),
|
||||
FormatHelper::datetime($ledger['close_stamp']),
|
||||
$ledger['comment']));
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item ledger list',
|
||||
'caption' => isset($caption) ? $caption : null,
|
||||
'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");
|
||||
}
|
||||
echo $this->element('jqGrid', $jqGrid_options);
|
||||
|
||||
Reference in New Issue
Block a user