From c8b781804a482bbc78066d7caf97412dc8efb171 Mon Sep 17 00:00:00 2001 From: abijah Date: Thu, 18 Jun 2009 04:07:52 +0000 Subject: [PATCH] Modified Transaction view to use jqGrid for entries. Also fixed a bug in the ledger entries element, since there is no way for credit/debit to be populated without a ledger_id, it makes sense to base the column displays on the presence of ledger_id. git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@167 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/views/elements/ledger_entries.ctp | 8 ++-- site/views/transactions/view.ctp | 59 ++------------------------ 2 files changed, 8 insertions(+), 59 deletions(-) diff --git a/site/views/elements/ledger_entries.ctp b/site/views/elements/ledger_entries.ctp index 2fee5c3..70e8c1f 100644 --- a/site/views/elements/ledger_entries.ctp +++ b/site/views/elements/ledger_entries.ctp @@ -14,13 +14,13 @@ else { } $cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name'); $cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment', 'width'=>150); -if (isset($account_ftype)) { - $cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency'); -} -else { +if (isset($ledger_id)) { $cols['Debit'] = array('index' => 'debit', 'formatter' => 'currency'); $cols['Credit'] = array('index' => 'credit', 'formatter' => 'currency'); } +else { + $cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency'); +} if (isset($reconcile_id)) { $cols['Applied'] = array('index' => "Reconciliation.amount", 'formatter' => 'currency'); } diff --git a/site/views/transactions/view.ctp b/site/views/transactions/view.ctp index 973edbf..67e77cd 100644 --- a/site/views/transactions/view.ctp +++ b/site/views/transactions/view.ctp @@ -52,61 +52,10 @@ echo '
' . "\n"; * Entries */ -$headers = array('Entry', 'Debit', 'Credit', 'Amount', 'Comment',/* 'Total'*/); -$column_class = array(); -foreach (array_intersect($headers, array('Entry')) AS $k => $v) { - $column_class[$k] = 'id'; -} -foreach (array_intersect($headers, array('Amount', '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($transaction['LedgerEntry'] AS $entry) { - $amount = $entry['amount']; - $running_total += $amount; - $rows[] = array($html->link('#'.$entry['id'], - array('controller' => 'ledger_entries', - 'action' => 'view', - $entry['id'])), - ($html->link($entry['DebitLedger']['Account']['name'], - array('controller' => 'accounts', - 'action' => 'view', - $entry['DebitLedger']['Account']['id'])) - . ' (' - . $html->link('#' . $entry['DebitLedger']['Account']['id'] - . '-' . $entry['DebitLedger']['sequence'], - array('controller' => 'ledgers', - 'action' => 'view', - $entry['DebitLedger']['id'])) - . ')'), - ($html->link($entry['CreditLedger']['Account']['name'], - array('controller' => 'accounts', - 'action' => 'view', - $entry['CreditLedger']['Account']['id'])) - . ' (' - . $html->link('#' . $entry['CreditLedger']['Account']['id'] - . '-' . $entry['CreditLedger']['sequence'], - array('controller' => 'ledgers', - 'action' => 'view', - $entry['CreditLedger']['id'])) - . ')'), - FormatHelper::currency($entry['amount']), - $entry['comment'], - //FormatHelper::currency($running_total), - ); -} - -echo $this->element('table', - array('class' => 'item entry list', - 'caption' => 'Entries in Transaction', - 'headers' => $headers, - 'rows' => $rows, - 'column_class' => $column_class)); +echo $this->element('ledger_entries', + array('caption' => 'Entries in Transaction', + 'ledger_entries' => $transaction['LedgerEntry'], + )); /* End "detail supporting" div */