From a2aa612a5eee6ccc0c0c03fadf2209227805524c Mon Sep 17 00:00:00 2001 From: abijah Date: Thu, 6 Aug 2009 18:08:21 +0000 Subject: [PATCH] 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/site@496 97e9348a-65ac-dc4b-aefc-98561f571b83 --- controllers/customers_controller.php | 20 +++++++++++++------- views/customers/receipt.ctp | 19 +++++++++++++++---- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php index 9d5e813..cd6c997 100644 --- a/controllers/customers_controller.php +++ b/controllers/customers_controller.php @@ -423,8 +423,8 @@ class CustomersController extends AppController { $this->layout = null; $this->autoLayout = false; $this->autoRender = false; - //Configure::write('debug', '0'); - //header("Content-type: text/xml;charset=utf-8"); + Configure::write('debug', '0'); + header("Content-type: text/xml;charset=utf-8"); App::import('Helper', 'Xml'); $xml = new XmlHelper(); @@ -432,16 +432,22 @@ class CustomersController extends AppController { // Find the unreconciled entries, then manipulate the structure // slightly to accomodate the format necessary for XML Helper. $unreconciled = $this->Customer->unreconciledCharges($id); + + foreach ($unreconciled['entries'] AS &$entry) + $entry = array_intersect_key($entry['StatementEntry'], + array('id'=>1)); + $unreconciled = array('entries' => - array_intersect_key($unreconciled['debit'], - array('entry'=>1, 'balance'=>1))); + array('entry' => $unreconciled['entries'], + 'balance' => $unreconciled['summary']['balance'])); // 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']); - //pr($unreconciled); - //$reconciled = $cust->reconcileNewStatementEntry($cust_id, 'credit', $amount); +/* pr(compact('unreconciled')); */ +/* echo htmlspecialchars($xml->serialize($unreconciled)); */ +/* $this->render('/fake'); */ $opts = array(); //$opts['format'] = 'tags'; diff --git a/views/customers/receipt.ctp b/views/customers/receipt.ctp index 113995b..9a7e6cf 100644 --- a/views/customers/receipt.ctp +++ b/views/customers/receipt.ctp @@ -70,6 +70,8 @@ function showResponse(responseText, statusText) { if (statusText == 'success') { // get a clean slate //resetForm(); + // REVISIT : 20090806 Add to resetForm() + updateCharges($("#customer-id").val()); } else { alert('not successful??'); @@ -109,8 +111,6 @@ function onRowSelect(grid_id, customer_id) { $(grid_id).getCell(customer_id, 'Customer-id') + ''); $("#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 $(".customer-selection-invalid").hide(); @@ -227,7 +227,10 @@ function switchPaymentType(paymentid_base, paymentid, radioid) { 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') .setGridParam({ page: 1 }) .trigger("reloadGrid"); @@ -239,6 +242,8 @@ function updateCharges(id) { url += '/'+id; $('#charge-entries-jqGrid').clearGridData(); + $("#receipt-balance").html("Calculating..."); + $("#receipt-charges-caption").html("Please Wait..."); $.ajax({ type: "GET", @@ -252,7 +257,13 @@ function updateCharges(id) { $('#receipt-balance').html(fmtCurrency($('entries',xml).attr('balance'))); $("#receipt-charges-caption").html("Outstanding Charges"); updateChargesGrid(ids); - } + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { +/* alert('ERROR'); */ +/* $('#debug').html('

request
'+escape(XMLHttpRequest)); */ +/* $('#debug').append('

status
'+escape(textStatus)); */ +/* $('#debug').append('

error
'+escape(errorThrown)); */ + } }); }