'Transaction.id', 'formatter' => 'id'); $cols['StatementEntry'] = array('index' => 'StatementEntry.id', 'formatter' => 'id'); $cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); $cols['Effective'] = array('index' => 'StatementEntry.effective_date', 'formatter' => 'date'); $cols['Through'] = array('index' => 'StatementEntry.through_date', 'formatter' => 'date'); $cols['Account'] = array('index' => 'Account.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['Comment'] = array('index' => 'StatementEntry.comment', 'formatter' => 'comment', 'width'=>150); $cols['Charge'] = array('index' => 'charge', 'formatter' => 'currency'); $cols['Payment'] = array('index' => 'payment', 'formatter' => 'currency'); $cols['Last Payment'] = array('index' => 'last_paid', 'formatter' => 'date'); $cols['Applied'] = array('index' => "applied", 'formatter' => 'currency'); $cols['Sub-Total'] = array('index' => 'subtotal-StatementEntry.amount', 'formatter' => 'currency', 'sortable' => false); if (isset($transaction_id)) $grid->invalidFields('Transaction'); if (!isset($collected_account_id)) $grid->invalidFields('Last Payment'); if (isset($ledger_id) || isset($account_id)) $grid->invalidFields(array('Account')); if (isset($lease_id) || isset($customer_id)) $grid->invalidFields(array('Customer')); if (isset($lease_id)) $grid->invalidFields(array('Lease', 'Unit')); if (!isset($statement_entry_id)) $grid->invalidFields('Applied'); else $cols['Sub-Total']['index'] = 'subtotal-applied'; $grid->invalidFields('Sub-Total'); $grid->invalidFields('Applied'); // Now that columns are defined, establish basic grid parameters $grid ->columns($cols) ->sortField('Date') ->defaultFields(array('Entry', 'Date', 'Amount', 'Credit', 'Debit')); /* // Set up search fields if requested by caller */ /* if (isset($searchfields)) */ /* $grid->searchFields(array('Customer', 'Unit')); */ // Include custom data $grid->customData(compact('transaction_id', 'account_id', 'customer_id', 'lease_id', 'statement_entry_id', 'from_date', 'through_date', 'payment_accounts', 'charge_accounts')); // Render the grid $grid ->render($this, isset($config) ? $config : null, array('Transaction', 'StatementEntry', 'Date', 'Effective', 'Last Payment', 'Account', 'Customer', 'Unit', 'Comment', 'Charge', 'Payment', 'Amount', 'Applied', 'Sub-Total') );