rough-cut of a payment-history interface
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 9 Dec 2009 13:36:50 +0000 (13:36 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 9 Dec 2009 13:36:50 +0000 (13:36 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15114 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/patron/bill_history.js
Open-ILS/xul/staff_client/server/patron/bill_history.xul

index 7c8bf63..3284d8b 100644 (file)
 <!ENTITY staff.patron.bill_history.print.accesskey "P">
 <!ENTITY staff.patron.bill_history.selected_billed.label "Selected Billed:">
 <!ENTITY staff.patron.bill_history.selected_paid.label "Selected Paid:">
+<!ENTITY staff.patron.bill_history.tab.transactions.label "Transactions">
+<!ENTITY staff.patron.bill_history.tab.transactions.accesskey "T">
+<!ENTITY staff.patron.bill_history.tab.payments.label "Payments">
+<!ENTITY staff.patron.bill_history.tab.payments.accesskey "y">
 
 <!ENTITY staff.patron.bill_interface.total_owed "Total Owed:">
 <!ENTITY staff.patron.bill_interface.total_checked "Total Checked:">
index 1d22a87..cd11be8 100644 (file)
@@ -228,6 +228,7 @@ const api = {
     'FM_MBTS_IDS_RETRIEVE_FOR_HISTORY.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_bill.ids.authoritative' },
     'FM_MP_RETRIEVE_VIA_MBTS_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.retrieve.all' },
     'FM_MP_RETRIEVE_VIA_MBTS_ID.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.retrieve.all.authoritative' },
+    'FM_MP_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.payments.retrieve' },
     'FM_MP_NOTE_EDIT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.note.edit' },
     'FM_MG_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.grocery.create' },
     'FM_MG_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.grocery.retrieve' },
index f7648f0..e96d489 100644 (file)
@@ -1,4 +1,5 @@
 function $(id) { return document.getElementById(id); }
+var payment_history_fetched = false;
 
 function tally_selected() {
     try {
@@ -76,6 +77,11 @@ function retrieve_mbts_for_list() {
 function init_lists() {
     JSAN.use('util.list'); JSAN.use('circ.util'); 
 
+    init_main_list();
+    init_payments_list();
+}
+
+function init_main_list() {
     g.bill_list_selection = [];
 
     g.bill_list = new util.list('bill_tree');
@@ -130,6 +136,34 @@ function init_lists() {
     g.bill_list.set_list_actions();
 }
 
+function init_payments_list() {
+    g.payments_list_selection = [];
+
+    g.payments_list = new util.list('payments_tree');
+
+    g.payments_list.init( {
+        'columns' : g.payments_list.fm_columns('mp'),
+        'on_select' : function(ev) {
+            JSAN.use('util.functional');
+            g.payments_list_selection = util.functional.map_list(
+                g.payments_list.retrieve_selection(),
+                function(o) { return o.getAttribute('retrieve_id'); }
+            );
+        },
+        'retrieve_row' : function(params) {
+            var id = params.retrieve_id;
+            var row = params.row;
+            if (typeof params.on_retrieve == 'function') {
+                params.on_retrieve(row);
+            };
+            return row;
+        },
+    } );
+
+    $('payments_list_actions').appendChild( g.payments_list.render_list_actions() );
+    g.payments_list.set_list_actions();
+}
+
 function my_init() {
     try {
         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
@@ -247,4 +281,51 @@ function print_bills() {
     }
 }
 
+function payment_history_init() {
+    try {
+        if (payment_history_fetched) { return; } else { payment_history_fetched = true; }
+
+        g.payments_list.clear();
+
+        $('payments_meter').hidden = false;
 
+        fieldmapper.standardRequest(
+            [ api.FM_MP_RETRIEVE_VIA_USER.app, api.FM_MP_RETRIEVE_VIA_USER.method ],
+            {   async: true,
+                params: [ses(), g.patron_id],
+                onresponse: function(r) {
+                    try {
+                        var result = r.recv().content();
+
+                        if (result && typeof result.ilsevent == 'undefined') {
+                            g.payments_list.append( 
+                                { 
+                                    'retrieve_id' : result.id(), 
+                                    'row' : { 
+                                        'my' : { 
+                                            'mp' : result 
+                                        } 
+                                    } 
+                                } 
+                            );
+                        } else {
+                            throw( js2JSON(result) );
+                        }
+                    } catch(E) {
+                        alert('Error retrieving payment in bill_history.js, onresponse: ' + E);                        
+                    }
+                },
+                oncomplete: function() {
+                    $('payments_meter').hidden = true;
+                },
+                onerror: function(r) {
+                    var result = r.recv().content();
+                    alert('Error retrieving payment in bill_history.js, onerror: ' + js2JSON(result));                        
+                }
+            }
+        );
+
+    } catch(E) {
+        alert('Error in bill_history.js, payment_history_init(): ' + E);
+    }
+}
index 613e9bd..53e7c79 100644 (file)
@@ -26,8 +26,8 @@
 
     <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
     <!-- BEHAVIOR -->
-        <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
-        <scripts id="openils_util_scripts"/>
+    <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
+    <scripts id="openils_util_scripts"/>
 
     <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
     <script type="text/javascript" src="bill_history.js"/>
     <vbox flex="1" class="my_overflow">
         <groupbox orient="vertical" flex="1">
             <caption id="caption" label="&staff.patron.bill_history.caption.label;"/>
-            <hbox>
-                <label value='&staff.patron.bill_history.selected_billed.label;' style='font-weight: bold;'/>
-                <label id="billed_tally" />
-                <label value='&staff.patron.bill_history.selected_paid.label;' style='font-weight: bold;'/>
-                <label id="paid_tally" />
-            </hbox>
-            <tree id="bill_tree" flex="1" enableColumnDrag="true" seltype="multiple"/>
-            <hbox>
-                <hbox id="bill_list_actions" />
-                <spacer flex="1"/>
-                <button id="opac" label="&staff.patron.bill_history.show_in_catalog.label;" accesskey="&staff.patron.bill_history.show_in_catalog.accesskey;" hidden="true" oncommand="alert('Not Yet Implemented');"/>
-                <button id="print" label="&staff.patron.bill_history.print.label;" accesskey="&staff.patron.bill_history.print.accesskey;" hidden="false" oncommand="print_bills();"/>
-                <button id="add" label="&staff.patron.bill_history.add_billing.label;" disabled="true"/>
-                <button id="details" label="&staff.patron.bill_history.full_details.label;" disabled="true" accesskey="&staff.patron.bill_history.full_details.accesskey;"/>
-            </hbox>
+            <tabbox flex="1">
+                <tabs>
+                    <tab label="&staff.patron.bill_history.tab.transactions.label;" accesskey="&staff.patron.bill_history.tab.transactions.accesskey;"/>
+                    <tab label="&staff.patron.bill_history.tab.payments.label;" accesskey="&staff.patron.bill_history.tab.payments.accesskey;" oncommand="payment_history_init();"/>
+                </tabs>
+                <tabpanels flex="1">
+                    <tabpanel orient="vertical">
+                        <hbox>
+                            <label value='&staff.patron.bill_history.selected_billed.label;' style='font-weight: bold;'/>
+                            <label id="billed_tally" />
+                            <label value='&staff.patron.bill_history.selected_paid.label;' style='font-weight: bold;'/>
+                            <label id="paid_tally" />
+                        </hbox>
+                        <tree id="bill_tree" flex="1" enableColumnDrag="true" seltype="multiple"/>
+                        <hbox>
+                            <hbox id="bill_list_actions" />
+                            <spacer flex="1"/>
+                            <button id="opac" label="&staff.patron.bill_history.show_in_catalog.label;" accesskey="&staff.patron.bill_history.show_in_catalog.accesskey;" hidden="true" oncommand="alert('Not Yet Implemented');"/>
+                            <button id="print" label="&staff.patron.bill_history.print.label;" accesskey="&staff.patron.bill_history.print.accesskey;" hidden="false" oncommand="print_bills();"/>
+                            <button id="add" label="&staff.patron.bill_history.add_billing.label;" disabled="true"/>
+                            <button id="details" label="&staff.patron.bill_history.full_details.label;" disabled="true" accesskey="&staff.patron.bill_history.full_details.accesskey;"/>
+                        </hbox>
+                    </tabpanel>
+                    <tabpanel orient="vertical">
+                        <hbox>
+                            <spacer flex="1"/>
+                            <progressmeter id ="payments_meter" mode="undetermined" hidden="true"/>
+                            <spacer flex="1"/>
+                        </hbox>
+                        <tree id="payments_tree" flex="1" enableColumnDrag="true" seltype="multiple"/>
+                        <hbox>
+                            <hbox id="payments_list_actions" />
+                        </hbox>
+                    </tabpanel>
+                </tabpanels>
+            </tabbox>
         </groupbox>
     </vbox>