pass bills from bill interface to summary display
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 1 Jan 2006 02:31:33 +0000 (02:31 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 1 Jan 2006 02:31:33 +0000 (02:31 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2570 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/patron/bills.js
Open-ILS/xul/staff_client/server/patron/display.js

index 323d2c8..aaf5b97 100644 (file)
@@ -20,13 +20,62 @@ patron.bills.prototype = {
        'current_payments' : [],
 
        'refresh' : function() {
-               location.href = location.href;
+               var obj = this;
+               /*
+               if (window.xulG && typeof window.xulG.display_refresh == 'function') {
+                       try { window.xulG.display_refresh(); } catch(E) { this.error.sdump('D_ERROR',E); }
+               }
+               */
+               obj.bills = obj.network.request(
+                       api.fm_mobts_having_balance.app,
+                       api.fm_mobts_having_balance.method,
+                       [ obj.session, obj.patron_id ]
+               );
+               if (window.xulG && typeof window.xulG.on_bill == 'function') {
+                       try { window.xulG.on_bill(obj.bills); } catch(E) { this.error.sdump('D_ERROR',E); }
+               }
+               //location.href = location.href;
+               var tbs = document.getElementsByTagName('textbox');
+               for (var i = 0; i < tbs.length; i++) {
+                       tbs[i].value = ''; tbs[i].setAttribute('value','');
+               }
+               obj.init();
+               obj.controller.view.bill_payment_amount.focus();
        },
 
        'init' : function( params ) {
+       
+               var obj = this;
+
+               obj.init_controller( params );
+
+               obj.retrieve();
+
+               var total_owed = 0;
+
+               JSAN.use('util.money');
+
+               obj.current_payments = []; obj.list.clear();
+               //FIXME//.bills virtual field
+               for (var i = 0; i < obj.bills.length; i++) {
+                       var rnode = obj.list.append( { 'row' : { 'my' : { 'mobts' : obj.bills[i] } }, 'attributes' : { 'allowevents' : true } } );
+                       var cb = rnode.getElementsByTagName('checkbox')[0];
+                       var tb = rnode.getElementsByTagName('textbox')[0];
+                       var bo = obj.bills[i].balance_owed();
+                       total_owed += util.money.dollars_float_to_cents_integer( bo );
+                       var id = obj.bills[i].id();
+                       obj.current_payments.push( { 'mobts_id' : id, 'balance_owed' : bo, 'checkbox' : cb, 'textbox' : tb, } );
+               }
+               obj.controller.view.bill_total_owed.value = util.money.cents_as_dollars( total_owed );
+               obj.controller.view.bill_total_owed.setAttribute('value',obj.controller.view.bill_total_owed.value);
+       },
+
+       'init_controller' : function( params ) {
 
                var obj = this;
 
+               if (obj._controller_inited) return;
+
                obj.session = obj.session || params['session'];
                obj.patron_id = obj.patron_id || params['patron_id'];
 
@@ -78,9 +127,6 @@ patron.bills.prototype = {
                                                                        'billwizard',
                                                                        'chrome,resizable,modal'
                                                                );
-                                                               if (typeof window.display_refresh == 'function') {
-                                                                       try { window.display_refresh(); } catch(E) { obj.error.sdump('D_ERROR',E); }
-                                                               }
                                                                obj.refresh();
                                                        } catch(E) {
                                                                obj.error.sdump('D_ERROR',E);
@@ -175,27 +221,11 @@ patron.bills.prototype = {
                        }
                );
 
-               obj.retrieve();
-
-               var total_owed = 0;
+               obj._controller_inited = true;
 
-               JSAN.use('util.money');
-
-               obj.current_payments = [];
-               //FIXME//.bills virtual field
-               for (var i = 0; i < obj.bills.length; i++) {
-                       var rnode = obj.list.append( { 'row' : { 'my' : { 'mobts' : obj.bills[i] } }, 'attributes' : { 'allowevents' : true } } );
-                       var cb = rnode.getElementsByTagName('checkbox')[0];
-                       var tb = rnode.getElementsByTagName('textbox')[0];
-                       var bo = obj.bills[i].balance_owed();
-                       total_owed += util.money.dollars_float_to_cents_integer( bo );
-                       var id = obj.bills[i].id();
-                       obj.current_payments.push( { 'mobts_id' : id, 'balance_owed' : bo, 'checkbox' : cb, 'textbox' : tb, } );
-               }
-               obj.controller.view.bill_total_owed.value = util.money.cents_as_dollars( total_owed );
-               obj.controller.view.bill_total_owed.setAttribute('value',obj.controller.view.bill_total_owed.value);
        },
 
+
        /*****************************************************************************************************************************/
 
        'apply_payment' : function() {
@@ -245,6 +275,7 @@ patron.bills.prototype = {
                        if ( obj.pay( payment_blob ) ) {
 
                                obj.refresh();
+                               alert('FIXME: Receipt goes here\n' + js2JSON(payment_blob));
 
                        } else {
 
@@ -525,7 +556,7 @@ patron.bills.prototype = {
                                catch(P){dump('?map_row_to_column: ' + E + '\n');}
                                value = '???';
                        }
-                       dump('map_row_to_column: value = ' + value + '\n');
+                       //dump('map_row_to_column: value = ' + value + '\n');
                        return value;
                };
        },
index 58e1d90..b2a14b3 100644 (file)
@@ -84,11 +84,7 @@ patron.display.prototype = {
                                        'cmd_patron_refresh' : [
                                                ['command'],
                                                function(ev) {
-                                                       obj.controller.view.patron_name.setAttribute(
-                                                               'value','Retrieving...'
-                                                       );
-                                                       try { obj.summary_window.refresh(); } catch(E) { dump(E + '\n'); }
-                                                       try { obj.refresh_deck(); } catch(E) { dump(E + '\n'); }
+                                                       obj.refresh_all();
                                                }
                                        ],
                                        'cmd_patron_checkout' : [
@@ -128,14 +124,25 @@ patron.display.prototype = {
                                        'cmd_patron_bills' : [
                                                ['command'],
                                                function(ev) {
-                                                       obj.right_deck.set_iframe(
+                                                       var f = obj.right_deck.set_iframe(
                                                                urls.remote_patron_bills
                                                                + '?session=' + window.escape( obj.session )
                                                                + '&patron_id=' + window.escape( obj.patron.id() ),
                                                                {},
                                                                {
                                                                        /* FIXME */
-                                                                       'bills' : obj.patron.bills
+                                                                       'bills' : obj.patron.bills,
+                                                                       'display_refresh' : function() {
+                                                                               obj.refresh_all();
+                                                                       },
+                                                                       'on_bill' : function(b) {
+                                                                               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                                                                               f.contentWindow.xulG.bills = b;
+                                                                               /* FIXME */
+                                                                               obj.patron.bills = b;
+                                                                               obj.summary_window.g.summary.patron.bills = b;
+                                                                               obj.summary_window.g.summary.controller.render('patron_bill');
+                                                                       }
                                                                }
                                                        );
                                                        dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
@@ -342,6 +349,15 @@ patron.display.prototype = {
                        }
                }
        },
+       
+       'refresh_all' : function() {
+               var obj = this;
+               obj.controller.view.patron_name.setAttribute(
+                       'value','Retrieving...'
+               );
+               try { obj.summary_window.refresh(); } catch(E) { dump(E + '\n'); }
+               try { obj.refresh_deck(); } catch(E) { dump(E + '\n'); }
+       },
 }
 
 dump('exiting patron/display.js\n');