Moved the ledger_entries controller/view to jqGrid.
Changed the app controller jqGrid virtual functions for getting the tables for both count and the full query. The ExtraTables bit was too confusing, and was only intended to allow the user to specify a subset for count and augment it for full query. This is easily accomplished by having DataTables just call DataCountTables first... one line solution ends the confusion.
Modified linkable behavior to support a %{MODEL_ALIAS} tag, which is replaced in the relationship conditions at runtime with the actual model alias. This is experimental at best, and certainly will create a problem for any model that ends up using the conditions in 'contain' instead of 'link'.
Broke the LedgerEntry->findInLedgerContext function out into multiple pieces, so those same pieces could be used in the LedgerEntries controller to populate jqGrid.
Changed the ledger_entries element, as a special case, to also allow listing control from ledger_id and account_type, instead of idlist as a mechanism for populating the grid.
Changed the infobox summary css, which will break several pages until I rework them.
Some next steps include fixing the broken infoboxes, and changing the transactions view to use the ledger_entries element. This also means the ledger_entries element will need to add support for idlist, or if we have any credit/debit issues, perhaps another custom transaction_id instead.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@134 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -34,12 +34,12 @@ class AccountsController extends AppController {
|
||||
*/
|
||||
|
||||
function index() { $this->all(); }
|
||||
function asset() { $this->jqGridView('Asset Accounts'); }
|
||||
function liability() { $this->jqGridView('Liability Accounts'); }
|
||||
function equity() { $this->jqGridView('Equity Accounts'); }
|
||||
function income() { $this->jqGridView('Income Accounts'); }
|
||||
function expense() { $this->jqGridView('Expense Accounts'); }
|
||||
function all() { $this->jqGridView('All Accounts', 'all'); }
|
||||
function asset() { $this->jqGridView('Asset Accounts', 'asset'); }
|
||||
function liability() { $this->jqGridView('Liability Accounts', 'liability'); }
|
||||
function equity() { $this->jqGridView('Equity Accounts', 'equity'); }
|
||||
function income() { $this->jqGridView('Income Accounts', 'income'); }
|
||||
function expense() { $this->jqGridView('Expense Accounts', 'expense'); }
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
@@ -57,21 +57,35 @@ class AccountsController extends AppController {
|
||||
$params['action'] = 'all';
|
||||
}
|
||||
|
||||
function jqGridDataExtraTables(&$params, &$model, &$query) {
|
||||
unset($query['contain']);
|
||||
$query['link'] =
|
||||
array(// Models
|
||||
'CurrentLedger' => array
|
||||
(// Models
|
||||
'LedgerEntry' => array
|
||||
('conditions' =>
|
||||
array('OR' =>
|
||||
array('LedgerEntry.debit_ledger_id = CurrentLedger.id',
|
||||
'LedgerEntry.credit_ledger_id = CurrentLedger.id'),
|
||||
),
|
||||
function jqGridDataCountTables(&$params, &$model) {
|
||||
return parent::jqGridDataTables($params, $model);
|
||||
}
|
||||
|
||||
function jqGridDataTables(&$params, &$model) {
|
||||
return array
|
||||
('link' =>
|
||||
array(// Models
|
||||
'CurrentLedger' => array
|
||||
(// Models
|
||||
'LedgerEntry'
|
||||
/* REVISIT <AP> 20090615:
|
||||
* I'll remove this 'conditions' section on a future checkin,
|
||||
* after I've proven out the %{MODEL_ALIAS} feature will be
|
||||
* sticking around.
|
||||
|
||||
=> array
|
||||
('conditions' =>
|
||||
array('OR' =>
|
||||
array('LedgerEntry.debit_ledger_id = CurrentLedger.id',
|
||||
'LedgerEntry.credit_ledger_id = CurrentLedger.id'),
|
||||
),
|
||||
),
|
||||
|
||||
* END REVISIT
|
||||
*/
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
function jqGridDataFields(&$params, &$model) {
|
||||
@@ -142,14 +156,12 @@ class AccountsController extends AppController {
|
||||
$ledger = array_merge($ledger,
|
||||
$this->Account->Ledger->stats($ledger['id']));
|
||||
|
||||
// Obtain the overall account balance
|
||||
$account['Account'] =
|
||||
array_merge($account['Account'],
|
||||
array('stats' => $this->Account->stats($id)));
|
||||
$balance = $account['Account']['stats']['Ledger']['balance'];
|
||||
// Obtain stats across ALL ledgers for the summary infobox
|
||||
$stats = $this->Account->stats($id, true);
|
||||
$stats = $stats['Ledger'];
|
||||
|
||||
// Prepare to render
|
||||
$title = 'Account: ' . $account['Account']['name'];
|
||||
$this->set(compact('account', 'title', 'balance'));
|
||||
$this->set(compact('account', 'title', 'stats'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class LeasesController extends AppController {
|
||||
function index() { $this->all(); }
|
||||
function active() { $this->jqGridView('Active Leases'); }
|
||||
function closed() { $this->jqGridView('Closed Leases'); }
|
||||
function all() { $this->jqGridView('All Leases'); }
|
||||
function all() { $this->jqGridView('All Leases', 'all'); }
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
@@ -16,6 +16,44 @@ class LedgerEntriesController extends AppController {
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* virtuals: jqGridData
|
||||
* - With the application controller handling the jqGridData action,
|
||||
* these virtual functions ensure that the correct data is passed
|
||||
* to jqGrid.
|
||||
*/
|
||||
|
||||
function jqGridDataTables(&$params, &$model) {
|
||||
return array
|
||||
('link' =>
|
||||
array(// Models
|
||||
'Transaction' => array('fields' =>
|
||||
array('Transaction.id', 'Transaction.stamp')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function jqGridDataFields(&$params, &$model) {
|
||||
return $model->ledgerContextFields($params['custom']['ledger_id'],
|
||||
$params['custom']['account_type']);
|
||||
}
|
||||
|
||||
function jqGridDataConditions(&$params, &$model) {
|
||||
$conditions = parent::jqGridDataConditions($params, $model);
|
||||
$conditions[] = $model->ledgerContextConditions($params['custom']['ledger_id'],
|
||||
$params['custom']['account_type']);
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
function jqGridRecordLinks(&$params, &$model, &$records, $links) {
|
||||
$links['Transaction'] = array('id');
|
||||
$links['LedgerEntry'] = array('id');
|
||||
return parent::jqGridRecordLinks($params, $model, $records, $links);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
@@ -49,19 +49,18 @@ class LedgersController extends AppController {
|
||||
$params['action'] = 'all';
|
||||
}
|
||||
|
||||
function jqGridDataExtraTables(&$params, &$model, &$query) {
|
||||
unset($query['contain']);
|
||||
$query['link'] =
|
||||
array(// Models
|
||||
'Account',
|
||||
'LedgerEntry' =>
|
||||
array('conditions' =>
|
||||
array('OR' =>
|
||||
array('LedgerEntry.debit_ledger_id = Ledger.id',
|
||||
'LedgerEntry.credit_ledger_id = Ledger.id'),
|
||||
),
|
||||
),
|
||||
);
|
||||
function jqGridDataCountTables(&$params, &$model) {
|
||||
return array('contain' => false);
|
||||
}
|
||||
|
||||
function jqGridDataTables(&$params, &$model) {
|
||||
return array
|
||||
('link' =>
|
||||
array(// Models
|
||||
'Account',
|
||||
'LedgerEntry',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function jqGridDataFields(&$params, &$model) {
|
||||
@@ -140,18 +139,11 @@ class LedgersController extends AppController {
|
||||
)
|
||||
);
|
||||
|
||||
// Get all ledger entries of this ledger
|
||||
$ledger['LedgerEntry'] = $this->Ledger->findLedgerEntries
|
||||
($id, $ledger['Account']['type']);
|
||||
|
||||
// Summarize the entries, and obtain the ledger balance
|
||||
$ledger['Ledger'] =
|
||||
array_merge($ledger['Ledger'],
|
||||
array('stats' => $this->Ledger->stats($id)));
|
||||
$balance = $ledger['Ledger']['stats']['balance'];
|
||||
// Get ledger stats for our summary box
|
||||
$stats = $this->Ledger->stats($id);
|
||||
|
||||
// OK, set our view variables and render!
|
||||
$title = 'Ledger: ' . $ledger['Ledger']['name'];
|
||||
$this->set(compact('ledger', 'title', 'balance'));
|
||||
$this->set(compact('ledger', 'title', 'stats'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user