Fixed the customer selection update for receipts, and added a mechanism to automatically update the oustanding charges grid after entering the receipt.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@496 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-06 18:08:21 +00:00
parent 58c4f28956
commit 8f7cf202e5
2 changed files with 28 additions and 11 deletions

View File

@@ -423,8 +423,8 @@ class CustomersController extends AppController {
$this->layout = null; $this->layout = null;
$this->autoLayout = false; $this->autoLayout = false;
$this->autoRender = false; $this->autoRender = false;
//Configure::write('debug', '0'); Configure::write('debug', '0');
//header("Content-type: text/xml;charset=utf-8"); header("Content-type: text/xml;charset=utf-8");
App::import('Helper', 'Xml'); App::import('Helper', 'Xml');
$xml = new XmlHelper(); $xml = new XmlHelper();
@@ -432,16 +432,22 @@ class CustomersController extends AppController {
// Find the unreconciled entries, then manipulate the structure // Find the unreconciled entries, then manipulate the structure
// slightly to accomodate the format necessary for XML Helper. // slightly to accomodate the format necessary for XML Helper.
$unreconciled = $this->Customer->unreconciledCharges($id); $unreconciled = $this->Customer->unreconciledCharges($id);
foreach ($unreconciled['entries'] AS &$entry)
$entry = array_intersect_key($entry['StatementEntry'],
array('id'=>1));
$unreconciled = array('entries' => $unreconciled = array('entries' =>
array_intersect_key($unreconciled['debit'], array('entry' => $unreconciled['entries'],
array('entry'=>1, 'balance'=>1))); 'balance' => $unreconciled['summary']['balance']));
// XML Helper will dump an empty tag if the array is empty // XML Helper will dump an empty tag if the array is empty
if (!count($unreconciled['entries']['entry'])) if (empty($unreconciled['entries']['entry']))
unset($unreconciled['entries']['entry']); unset($unreconciled['entries']['entry']);
//pr($unreconciled); /* pr(compact('unreconciled')); */
//$reconciled = $cust->reconcileNewStatementEntry($cust_id, 'credit', $amount); /* echo htmlspecialchars($xml->serialize($unreconciled)); */
/* $this->render('/fake'); */
$opts = array(); $opts = array();
//$opts['format'] = 'tags'; //$opts['format'] = 'tags';

View File

@@ -70,6 +70,8 @@ function showResponse(responseText, statusText) {
if (statusText == 'success') { if (statusText == 'success') {
// get a clean slate // get a clean slate
//resetForm(); //resetForm();
// REVISIT <AP>: 20090806 Add to resetForm()
updateCharges($("#customer-id").val());
} }
else { else {
alert('not successful??'); alert('not successful??');
@@ -109,8 +111,6 @@ function onRowSelect(grid_id, customer_id) {
$(grid_id).getCell(customer_id, 'Customer-id') + $(grid_id).getCell(customer_id, 'Customer-id') +
'</A>'); '</A>');
$("#receipt-customer-name").html($(grid_id).getCell(customer_id, 'Customer-name')); $("#receipt-customer-name").html($(grid_id).getCell(customer_id, 'Customer-name'));
$("#receipt-balance").html("Calculating...");
$("#receipt-charges-caption").html("Please Wait...");
// Hide the "no customer" message and show the current customer // Hide the "no customer" message and show the current customer
$(".customer-selection-invalid").hide(); $(".customer-selection-invalid").hide();
@@ -227,7 +227,10 @@ function switchPaymentType(paymentid_base, paymentid, radioid) {
function updateChargesGrid(idlist) { function updateChargesGrid(idlist) {
$('#charge-entries-jqGrid').setPostDataItem('idlist', serialize(idlist)); var dynamic_post = new Array();
dynamic_post['idlist'] = idlist;
$('#charge-entries-jqGrid').setPostDataItem('dynamic_post_replace', serialize(dynamic_post));
$('#charge-entries-jqGrid') $('#charge-entries-jqGrid')
.setGridParam({ page: 1 }) .setGridParam({ page: 1 })
.trigger("reloadGrid"); .trigger("reloadGrid");
@@ -239,6 +242,8 @@ function updateCharges(id) {
url += '/'+id; url += '/'+id;
$('#charge-entries-jqGrid').clearGridData(); $('#charge-entries-jqGrid').clearGridData();
$("#receipt-balance").html("Calculating...");
$("#receipt-charges-caption").html("Please Wait...");
$.ajax({ $.ajax({
type: "GET", type: "GET",
@@ -252,7 +257,13 @@ function updateCharges(id) {
$('#receipt-balance').html(fmtCurrency($('entries',xml).attr('balance'))); $('#receipt-balance').html(fmtCurrency($('entries',xml).attr('balance')));
$("#receipt-charges-caption").html("Outstanding Charges"); $("#receipt-charges-caption").html("Outstanding Charges");
updateChargesGrid(ids); updateChargesGrid(ids);
} },
error: function(XMLHttpRequest, textStatus, errorThrown) {
/* alert('ERROR'); */
/* $('#debug').html('<P>request<BR>'+escape(XMLHttpRequest)); */
/* $('#debug').append('<P>status<BR>'+escape(textStatus)); */
/* $('#debug').append('<P>error<BR>'+escape(errorThrown)); */
}
}); });
} }