git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@368 97e9348a-65ac-dc4b-aefc-98561f571b83
117 lines
4.6 KiB
PHP
117 lines
4.6 KiB
PHP
<?php /* -*- mode:PHP -*- */
|
|
|
|
// 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['Effective'] = array('index' => 'LedgerEntry.effective_date', 'formatter' => 'date');
|
|
$cols['Through'] = array('index' => 'LedgerEntry.through_date', 'formatter' => 'date');
|
|
|
|
$cols['Account'] = array('index' => 'Account.name', 'formatter' => 'name');
|
|
$cols['Debit Account'] = array('index' => 'DebitAccount.name', 'formatter' => 'name');
|
|
$cols['Credit Account'] = array('index' => 'CreditAccount.name', 'formatter' => 'name');
|
|
|
|
$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
|
|
$cols['Lease'] = array('index' => 'Lease.number', 'formatter' => 'id');
|
|
$cols['Unit'] = array('index' => 'Unit.name', 'formatter' => 'name');
|
|
|
|
$cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name');
|
|
$cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment', 'width'=>150);
|
|
|
|
$cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency');
|
|
$cols['Debit'] = array('index' => 'debit', 'formatter' => 'currency');
|
|
$cols['Credit'] = array('index' => 'credit', 'formatter' => 'currency');
|
|
|
|
$cols['Last Payment'] = array('index' => 'last_paid', 'formatter' => 'date');
|
|
$cols['Applied'] = array('index' => "applied", 'formatter' => 'currency');
|
|
$cols['Sub-Total'] = array('index' => 'subtotal-LedgerEntry.amount', 'formatter' => 'currency', 'sortable' => false);
|
|
|
|
|
|
if (isset($transaction_id) || isset($reconcile_id))
|
|
$grid->invalidFields('Transaction');
|
|
|
|
if (!isset($collected_account_id))
|
|
$grid->invalidFields('Last Payment');
|
|
|
|
if (isset($account_ftype) || isset($ledger_id) || isset($account_id) || isset($ar_account) || isset($customer_id))
|
|
$grid->invalidFields(array('Debit Account', 'Credit Account'));
|
|
else
|
|
$grid->invalidFields('Account');
|
|
|
|
if (isset($no_account) || $group_by_tx || isset($collected_account_id))
|
|
$grid->invalidFields(array('Account', 'Debit Account', 'Credit Account'));
|
|
|
|
if (isset($ledger_id) || isset($account_id) || isset($ar_account) || isset($customer_id)) {
|
|
$grid->invalidFields('Amount');
|
|
$cols['Sub-Total']['index'] = 'subtotal-balance';
|
|
} else {
|
|
$grid->invalidFields(array('Debit', 'Credit'));
|
|
$cols['Sub-Total']['index'] = 'subtotal-LedgerEntry.amount';
|
|
}
|
|
|
|
// group_by_tx SHOULD wipe out Customer, but the reality
|
|
// is that it works good at the present, so we'll leave it.
|
|
if (isset($lease_id) || isset($customer_id))
|
|
$grid->invalidFields(array('Customer'));
|
|
|
|
if (isset($lease_id) || $group_by_tx)
|
|
$grid->invalidFields(array('Lease', 'Unit'));
|
|
|
|
if (!isset($reconcile_id) && !isset($collected_account_id))
|
|
$grid->invalidFields('Applied');
|
|
else
|
|
$cols['Sub-Total']['index'] = 'subtotal-applied';
|
|
|
|
if (isset($account_ftype) || isset($collected_account_id))
|
|
$grid->invalidFields('Sub-Total');
|
|
|
|
|
|
// Now that columns are defined, establish basic grid parameters
|
|
$grid
|
|
->columns($cols)
|
|
->sortField('Date')
|
|
->defaultFields(array('Entry', 'Date', 'Amount', 'Credit', 'Debit'));
|
|
|
|
|
|
if (!isset($config['rows']) && !isset($collected_account_id)) {
|
|
$config['action'] = 'ledger';
|
|
$grid->limit(50);
|
|
}
|
|
|
|
if (isset($reconcile_id)) {
|
|
$config['action'] = 'reconcile';
|
|
$grid->customData(compact('reconcile_id'))->limit(20);
|
|
}
|
|
|
|
if (isset($collected_account_id)) {
|
|
$config['action'] = 'collected';
|
|
$account_id = $collected_account_id;
|
|
$grid->limit(50);
|
|
$grid->sortField('Last Payment');
|
|
}
|
|
|
|
if (isset($entry_ids))
|
|
$grid->id_list($entry_ids);
|
|
|
|
// Set up search fields if requested by caller
|
|
if (isset($searchfields))
|
|
$grid->searchFields(array('Customer', 'Unit'));
|
|
|
|
// Include custom data
|
|
$grid->customData(compact('ledger_id', 'account_id', 'ar_account',
|
|
'account_type', 'account_ftype', 'monetary_source_id',
|
|
'customer_id', 'lease_id', 'transaction_id', 'group_by_tx'));
|
|
|
|
// Render the grid
|
|
$grid
|
|
->render($this, isset($config) ? $config : null,
|
|
array('Transaction', 'Entry', 'Date', 'Effective', 'Last Payment',
|
|
'Account', 'Debit Account', 'Credit Account',
|
|
'Customer', 'Unit',
|
|
'Comment',
|
|
'Amount', 'Debit', 'Credit',
|
|
'Applied', 'Sub-Total')
|
|
);
|