git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@304 97e9348a-65ac-dc4b-aefc-98561f571b83
115 lines
4.5 KiB
PHP
115 lines
4.5 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['Applied'] = array('index' => "Reconciliation.amount", 'formatter' => 'currency');
|
|
$cols['Sub-Total'] = array('index' => 'subtotal', 'formatter' => 'currency', 'sortable' => false);
|
|
|
|
|
|
// Since group_by_tx is a boolean, let's just get it
|
|
// defined, regardless of whether the caller did so.
|
|
// group_by_tx will cause all entry fields to be
|
|
// invalidated, and will leave only the transaction
|
|
// fields. Yes... the caller should just use the
|
|
// transactions element instead, in theory. However,
|
|
// it hasn't yet been implemented to the level of
|
|
// this element, and additionally, the transactions
|
|
// element will not allow for customer information
|
|
// (rightly so, since it's a ledger_entry field).
|
|
// However, at the current implementation, all ledger
|
|
// entries of a transaction are for the same customer.
|
|
// So... we allow it for now.
|
|
if (!isset($group_by_tx))
|
|
$group_by_tx = false;
|
|
|
|
if (isset($transaction_id) || isset($reconcile_id))
|
|
$grid->invalidFields('Transaction');
|
|
|
|
if ($group_by_tx)
|
|
$grid->invalidFields('Entry');
|
|
|
|
if ($group_by_tx)
|
|
$grid->invalidFields(array('Effective', 'Through'));
|
|
|
|
if (isset($account_ftype) || isset($ledger_id) || isset($account_id) || isset($ar_account))
|
|
$grid->invalidFields(array('Debit Account', 'Credit Account'));
|
|
else
|
|
$grid->invalidFields('Account');
|
|
|
|
if (isset($no_account) || $group_by_tx)
|
|
$grid->invalidFields(array('Account', 'Debit Account', 'Credit Account'));
|
|
|
|
if (isset($ledger_id) || isset($account_id) || isset($ar_account))
|
|
$grid->invalidFields('Amount');
|
|
else
|
|
$grid->invalidFields(array('Debit', 'Credit'));
|
|
|
|
// 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))
|
|
$grid->invalidFields('Applied');
|
|
|
|
if (isset($account_ftype))
|
|
$grid->invalidFields('Sub-Total');
|
|
|
|
|
|
if (!isset($config['rows'])) {
|
|
$config['action'] = 'ledger';
|
|
$grid->limit(50);
|
|
}
|
|
|
|
if (isset($reconcile_id)) {
|
|
$grid->customData(compact('reconcile_id'))->limit(20);
|
|
}
|
|
|
|
// 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',
|
|
'customer_id', 'lease_id', 'transaction_id', 'group_by_tx'));
|
|
|
|
// Render the grid
|
|
$grid
|
|
->columns($cols)
|
|
->sortField('Date')
|
|
->defaultFields(array('Entry', 'Date', 'Amount', 'Credit', 'Debit'))
|
|
->render($this, isset($config) ? $config : null,
|
|
array('Transaction', 'Entry', 'Date', 'Effective',
|
|
'Account', 'Debit Account', 'Credit Account',
|
|
'Customer', 'Unit',
|
|
'Comment',
|
|
'Amount', 'Debit', 'Credit',
|
|
'Applied', 'Sub-Total')
|
|
);
|