From d9cfd7b8201759dd4ca08b0a9edf66b3ea4805bb Mon Sep 17 00:00:00 2001 From: phasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Fri, 11 Dec 2009 18:48:46 +0000 Subject: [PATCH] tally amounts for selected payments in payment history interface git-svn-id: svn://svn.open-ils.org/ILS/trunk@15144 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/server/patron/bill_history.js | 29 +++++++++++++++++++--- .../staff_client/server/patron/bill_history.xul | 6 +++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/patron/bill_history.js b/Open-ILS/xul/staff_client/server/patron/bill_history.js index 97bc2d6b84..3f4837a246 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_history.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_history.js @@ -19,13 +19,34 @@ function tally_selected() { selected_billed += to; selected_paid += tp; } - $('billed_tally').setAttribute('value', '$' + util.money.cents_as_dollars( selected_billed ) ); - $('paid_tally').setAttribute('value', '$' + util.money.cents_as_dollars( selected_paid ) ); + $('billed_tally').setAttribute('value', util.money.cents_as_dollars( selected_billed ) ); + $('paid_tally').setAttribute('value', util.money.cents_as_dollars( selected_paid ) ); } catch(E) { alert('Error in bill_history.js, tally_selected(): ' + E); } } +function payments_tally_selected() { + try { + JSAN.use('util.money'); + var selected_paid = 0; + + for (var i = 0; i < g.payments_list_selection.length; i++) { + var payment = g.payments_map[g.payments_list_selection[i].id]; + if (!payment) { + $('payments_paid_tally').setAttribute('value', '???'); + return; + } + var amount = util.money.dollars_float_to_cents_integer( payment.amount() ); + selected_paid += amount; + } + $('payments_paid_tally').setAttribute('value', util.money.cents_as_dollars( selected_paid ) ); + } catch(E) { + alert('Error in bill_history.js, payments_tally_selected(): ' + E); + } +} + + function retrieve_mbts_for_list() { //var method = 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_CHARGE'; var method = 'FM_MBTS_IDS_RETRIEVE_FOR_HISTORY.authoritative'; @@ -178,6 +199,7 @@ function init_payments_list() { g.payments_list.retrieve_selection(), function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } ); + payments_tally_selected(); $('payments_details').disabled = g.payments_list_selection.length == 0; }, 'retrieve_row' : function(params) { @@ -219,7 +241,7 @@ function my_init() { document.title = $("patronStrings").getString('staff.patron.bill_history.my_init.bill_history'); } - g.funcs = []; g.bill_map = {}; + g.funcs = []; g.bill_map = {}; g.payments_map = {}; g.patron_id = xul_param('patron_id'); @@ -383,6 +405,7 @@ function retrieve_payments() { } } ); + g.payments_map[ result.mp.id() ] = result.mp; } else { throw( js2JSON(result) ); } diff --git a/Open-ILS/xul/staff_client/server/patron/bill_history.xul b/Open-ILS/xul/staff_client/server/patron/bill_history.xul index e374e36b6b..9ab7d9a29f 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_history.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill_history.xul @@ -96,6 +96,12 @@ <hbox> <toolbox flex="1"> <toolbar> + <toolbaritem pack="center"> + <hbox> + <label value='&staff.patron.bill_history.selected_paid.label;' style='font-weight: bold;'/> + <label id="payments_paid_tally" /> + </hbox> + </toolbaritem> <toolbarspring/> <toolbaritem> <progressmeter id="payments_meter" flex="1" hidden="true" mode="undetermined"/> -- 2.11.0