Added accounts to the ledger entry grids, since it's tough to figure out what's going on without them. This exposed a problem with the controller name automatically being determined in the Links function, so it now looks for an optional controller parameter.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@141 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -295,6 +295,8 @@ class AppController extends Controller {
|
|||||||
foreach ($links AS $table => $fields) {
|
foreach ($links AS $table => $fields) {
|
||||||
$controller = Inflector::pluralize(Inflector::underscore($table));
|
$controller = Inflector::pluralize(Inflector::underscore($table));
|
||||||
$id = 'id';
|
$id = 'id';
|
||||||
|
if (isset($fields['controller']))
|
||||||
|
$controller = $fields['controller'];
|
||||||
if (isset($fields['id']))
|
if (isset($fields['id']))
|
||||||
$id = $fields['id'];
|
$id = $fields['id'];
|
||||||
foreach ($records AS &$record) {
|
foreach ($records AS &$record) {
|
||||||
|
|||||||
@@ -30,12 +30,28 @@ class LedgerEntriesController extends AppController {
|
|||||||
('link' =>
|
('link' =>
|
||||||
array(// Models
|
array(// Models
|
||||||
'Transaction' =>
|
'Transaction' =>
|
||||||
array('fields' =>
|
array('fields' => array('id', 'stamp'),
|
||||||
array('Transaction.id', 'Transaction.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' =>
|
'MonetarySource' =>
|
||||||
array('fields' =>
|
array('fields' => array('id', 'name'),
|
||||||
array('MonetarySource.id', 'MonetarySource.name')),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -53,8 +69,11 @@ class LedgerEntriesController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function jqGridRecordLinks(&$params, &$model, &$records, $links) {
|
function jqGridRecordLinks(&$params, &$model, &$records, $links) {
|
||||||
$links['Transaction'] = array('id');
|
$links['Transaction'] = array('id');
|
||||||
$links['LedgerEntry'] = 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);
|
return parent::jqGridRecordLinks($params, $model, $records, $links);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
|
|
||||||
// Define the table columns
|
// Define the table columns
|
||||||
$cols = array();
|
$cols = array();
|
||||||
$cols['Transaction'] = array('index' => 'Transaction.id', 'formatter' => 'id');
|
$cols['Transaction'] = array('index' => 'Transaction.id', 'formatter' => 'id');
|
||||||
$cols['Entry'] = array('index' => 'LedgerEntry.id', 'formatter' => 'id');
|
$cols['Entry'] = array('index' => 'LedgerEntry.id', 'formatter' => 'id');
|
||||||
$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
|
$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
|
||||||
$cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name');
|
$cols['Debit Account'] = array('index' => 'DebitAccount.name', 'formatter' => 'longname');
|
||||||
$cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment');
|
$cols['Credit Account'] = array('index' => 'CreditAccount.name', 'formatter' => 'longname');
|
||||||
$cols['Debit'] = array('index' => 'debit', 'formatter' => 'currency');
|
$cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name');
|
||||||
$cols['Credit'] = array('index' => 'credit', 'formatter' => 'currency');
|
$cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment');
|
||||||
//$cols['Total'] = array('index' => 'balance', 'formatter' => 'currency');
|
$cols['Debit'] = array('index' => 'debit', 'formatter' => 'currency');
|
||||||
|
$cols['Credit'] = array('index' => 'credit', 'formatter' => 'currency');
|
||||||
|
|
||||||
$jqGrid_options = array('jqGridColumns' => $cols,
|
$jqGrid_options = array('jqGridColumns' => $cols,
|
||||||
'controller' => 'ledger_entries',
|
'controller' => 'ledger_entries',
|
||||||
|
|||||||
Reference in New Issue
Block a user