More tweaking with grids that need to be reloaded immediately after page load. Fixed a bug with the statement_entry balance field, as there were two of them.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@534 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -64,7 +64,8 @@ class StatementEntriesController extends AppController {
|
||||
function gridDataTables(&$params, &$model) {
|
||||
$tables = $this->gridDataCountTables($params, $model);
|
||||
|
||||
if (in_array('applied', $params['post']['fields'])) {
|
||||
if (in_array('applied', $params['post']['fields']) ||
|
||||
isset($params['post']['custom']['statement_entry_id'])) {
|
||||
$tables['link']['DisbursementEntry'] = array();
|
||||
$tables['link']['ChargeEntry'] = array();
|
||||
}
|
||||
@@ -80,11 +81,13 @@ class StatementEntriesController extends AppController {
|
||||
" SUM(COALESCE(DisbursementEntry.amount,0))," .
|
||||
" SUM(COALESCE(ChargeEntry.amount,0)))" .
|
||||
" AS 'applied'");
|
||||
}
|
||||
if (in_array('unapplied', $params['post']['fields'])) {
|
||||
$fields[] = ("StatementEntry.amount - (" .
|
||||
"IF(StatementEntry.type = 'CHARGE'," .
|
||||
" SUM(COALESCE(DisbursementEntry.amount,0))," .
|
||||
" SUM(COALESCE(ChargeEntry.amount,0)))" .
|
||||
") AS 'balance'");
|
||||
") AS 'unapplied'");
|
||||
}
|
||||
|
||||
$fields = array_merge($fields,
|
||||
|
||||
@@ -15,7 +15,7 @@ echo '<div class="account collected">' . "\n";
|
||||
|
||||
// Reset the form
|
||||
function resetForm() {
|
||||
<?php /* REVISIT <AP>: 20090810; Hate to do this, but first data is wrong... */ ?>
|
||||
// Kick off the grid
|
||||
updateEntriesGrid();
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ function updateEntriesGrid() {
|
||||
.setGridParam({ page: 1 })
|
||||
.trigger("reloadGrid");
|
||||
|
||||
//$('#debug').html("<PRE>\n"+htmlEncode(dump($('#collected-entries-jqGrid').getGridParam()))+"\n</PRE>")
|
||||
var gridstate = $('#collected-entries-jqGrid').getGridParam('gridstate');
|
||||
if (gridstate == 'hidden')
|
||||
$('#collected-entries .HeaderButton').click();
|
||||
@@ -204,5 +205,3 @@ echo '</div>' . "\n";
|
||||
echo '</div>' . "\n";
|
||||
|
||||
?>
|
||||
|
||||
<a href="#" onClick="$('#debug').html(''); return false;">Clear Debug Output</a>
|
||||
|
||||
@@ -222,6 +222,10 @@ function updateChargesGrid(idlist) {
|
||||
$('#charge-entries-jqGrid')
|
||||
.setGridParam({ page: 1 })
|
||||
.trigger("reloadGrid");
|
||||
|
||||
var gridstate = $('#charge-entries-jqGrid').getGridParam('gridstate');
|
||||
if (gridstate == 'hidden')
|
||||
$('#charge-entries .HeaderButton').click();
|
||||
}
|
||||
|
||||
function updateCharges(id) {
|
||||
@@ -308,10 +312,11 @@ echo $this->element('statement_entries', array
|
||||
(
|
||||
'grid_div_id' => 'charge-entries',
|
||||
'grid_div_class' => 'text-below',
|
||||
'grid_setup' => array('hiddengrid' => true),
|
||||
'caption' => '<SPAN id="receipt-charges-caption"></SPAN>',
|
||||
'action' => 'idlist',
|
||||
'exclude' => array('Customer', 'Unit', 'Type', 'Debit', 'Credit'),
|
||||
'include' => array('Amount', 'Applied', 'Balance'),
|
||||
'include' => array('Applied', 'Balance'),
|
||||
'remap' => array('Applied' => 'Paid'),
|
||||
'limit' => 8,
|
||||
),
|
||||
|
||||
@@ -23,7 +23,9 @@ $cols['Credit'] = array('index' => 'disbursement', 'formatter' =>
|
||||
|
||||
$cols['Amount'] = array('index' => "StatementEntry.amount", 'formatter' => 'currency');
|
||||
$cols['Applied'] = array('index' => "applied", 'formatter' => 'currency');
|
||||
$cols['Balance'] = array('index' => "balance", 'formatter' => 'currency');
|
||||
// 'balance' is already in use as part of charge/disbursement/balance.
|
||||
// 'unapplied' isn't quite the right term, but it's not customer visible.
|
||||
$cols['Balance'] = array('index' => "unapplied", 'formatter' => 'currency');
|
||||
$cols['Sub-Total'] = array('index' => 'subtotal-balance', 'formatter' => 'currency', 'sortable' => false);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user