Significant changes to work with the new account/ledger structure. Removed much of the auto-generated model association code. Added helper functions into the models to perform model related work, such as model 'stats' (a bad name for a function to return a summary of pertinent financial information from a given model instance). There is a ton of cleanup to do, but first I want to get it all captured.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@81 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -5,12 +5,15 @@ if (isset($heading))
|
||||
elseif (!isset($caption))
|
||||
echo '<h2>'.__('Ledgers',true).'</h2>';
|
||||
|
||||
$headers = array_merge(array('Name'),
|
||||
$headers = array_merge(array('Sequence'), //array('Name'),
|
||||
(isset($ledgers[0]['Account'])
|
||||
? array('Account')
|
||||
: array()),
|
||||
array('Entries', 'Debits', 'Credits', 'Balance', 'Closed', 'Comment'));
|
||||
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';
|
||||
}
|
||||
foreach (array_intersect($headers, array('Debits', 'Credits', 'Balance')) AS $k => $v) {
|
||||
$column_class[$k] = 'currency';
|
||||
}
|
||||
@@ -22,7 +25,7 @@ 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('name')),
|
||||
$headers = array_merge(array($paginator->sort('sequence')), //array($paginator->sort('name')),
|
||||
(isset($ledgers[0]['Account'])
|
||||
? array($paginator->sort('Account', 'Account.name'))
|
||||
: array()),
|
||||
@@ -30,35 +33,40 @@ if (isset($paginator)) {
|
||||
$paginator->sort('debits'),
|
||||
$paginator->sort('credits'),
|
||||
$paginator->sort('balance'),
|
||||
$paginator->sort('closed'),
|
||||
$paginator->sort('Close Date', 'close_stamp'),
|
||||
$paginator->sort('comment')));
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
foreach ($ledgers as $ledger) {
|
||||
$account = null;
|
||||
$stats = null;
|
||||
|
||||
if (isset($ledger[0]))
|
||||
$ledger = array_merge($ledger[0], array_diff_key($ledger, array(0=>1)));
|
||||
if (isset($ledger['Ledger']))
|
||||
$ledger = array_merge($ledger['Ledger'], array_diff_key($ledger, array('Ledger'=>1)));
|
||||
$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['name'],
|
||||
$rows[] = array_merge(array($html->link('#'.$ledger['sequence'],//$ledger['name'],
|
||||
array('controller' => 'ledgers',
|
||||
'action' => 'view',
|
||||
$ledger['id']))),
|
||||
(isset($ledger['Account'])
|
||||
(isset($account)
|
||||
? array($html->link($account['name'],
|
||||
array('controller' => 'accounts',
|
||||
'action' => 'view',
|
||||
$account['id'])))
|
||||
: array()),
|
||||
array($ledger['entries'],
|
||||
FormatHelper::currency($ledger['debits']),
|
||||
FormatHelper::currency($ledger['credits']),
|
||||
FormatHelper::currency($ledger['balance']),
|
||||
$ledger['closed'] ? 'Closed' : 'Open',
|
||||
array($stats['entries'],
|
||||
FormatHelper::currency($stats['debits']),
|
||||
FormatHelper::currency($stats['credits']),
|
||||
FormatHelper::currency($stats['balance']),
|
||||
FormatHelper::datetime($ledger['close_stamp']),
|
||||
$ledger['comment']));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user