diff --git a/app_controller.php b/app_controller.php index b41c9bb..587c9a9 100644 --- a/app_controller.php +++ b/app_controller.php @@ -295,6 +295,8 @@ class AppController extends Controller { foreach ($links AS $table => $fields) { $controller = Inflector::pluralize(Inflector::underscore($table)); $id = 'id'; + if (isset($fields['controller'])) + $controller = $fields['controller']; if (isset($fields['id'])) $id = $fields['id']; foreach ($records AS &$record) { diff --git a/controllers/ledger_entries_controller.php b/controllers/ledger_entries_controller.php index 29da8d8..ec003cb 100644 --- a/controllers/ledger_entries_controller.php +++ b/controllers/ledger_entries_controller.php @@ -30,12 +30,28 @@ class LedgerEntriesController extends AppController { ('link' => array(// Models 'Transaction' => - array('fields' => - array('Transaction.id', 'Transaction.stamp')), + array('fields' => array('id', 'stamp'), + ), + + 'DebitLedger' => + array('fields' => array('id', 'name'), + // Models + 'DebitAccount' => array('class' => 'Account', + 'fields' => array('id', 'name'), + ), + ), + + 'CreditLedger' => + array('fields' => array('id', 'name'), + // Models + 'CreditAccount' => array('class' => 'Account', + 'fields' => array('id', 'name'), + ), + ), 'MonetarySource' => - array('fields' => - array('MonetarySource.id', 'MonetarySource.name')), + array('fields' => array('id', 'name'), + ), ), ); } @@ -53,8 +69,11 @@ class LedgerEntriesController extends AppController { } function jqGridRecordLinks(&$params, &$model, &$records, $links) { - $links['Transaction'] = array('id'); - $links['LedgerEntry'] = array('id'); + $links['Transaction'] = array('id'); + $links['LedgerEntry'] = array('id'); + $links['DebitAccount'] = array('controller' => 'accounts', 'name'); + $links['CreditAccount'] = array('controller' => 'accounts', 'name'); + $links['MonetarySource'] = array('name'); return parent::jqGridRecordLinks($params, $model, $records, $links); } diff --git a/views/elements/ledger_entries.ctp b/views/elements/ledger_entries.ctp index 2e2a2d3..eec37d6 100644 --- a/views/elements/ledger_entries.ctp +++ b/views/elements/ledger_entries.ctp @@ -2,14 +2,15 @@ // Define the table columns $cols = array(); -$cols['Transaction'] = array('index' => 'Transaction.id', 'formatter' => 'id'); -$cols['Entry'] = array('index' => 'LedgerEntry.id', 'formatter' => 'id'); -$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); -$cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name'); -$cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment'); -$cols['Debit'] = array('index' => 'debit', 'formatter' => 'currency'); -$cols['Credit'] = array('index' => 'credit', 'formatter' => 'currency'); -//$cols['Total'] = array('index' => 'balance', 'formatter' => 'currency'); +$cols['Transaction'] = array('index' => 'Transaction.id', 'formatter' => 'id'); +$cols['Entry'] = array('index' => 'LedgerEntry.id', 'formatter' => 'id'); +$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); +$cols['Debit Account'] = array('index' => 'DebitAccount.name', 'formatter' => 'longname'); +$cols['Credit Account'] = array('index' => 'CreditAccount.name', 'formatter' => 'longname'); +$cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name'); +$cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment'); +$cols['Debit'] = array('index' => 'debit', 'formatter' => 'currency'); +$cols['Credit'] = array('index' => 'credit', 'formatter' => 'currency'); $jqGrid_options = array('jqGridColumns' => $cols, 'controller' => 'ledger_entries',