Adds patron and bill columns to the checkin list. Moves the bill fetching call to...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Sep 2009 20:09:34 +0000 (20:09 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Sep 2009 20:09:34 +0000 (20:09 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14235 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/circ/checkin.js
Open-ILS/xul/staff_client/server/circ/util.js

index 54c4159..cc0957c 100644 (file)
@@ -19,7 +19,7 @@ circ.checkin.prototype = {
 
                var obj = this;
 
-               JSAN.use('circ.util');
+               JSAN.use('circ.util'); JSAN.use('patron.util');
                var columns = circ.util.columns( 
                        { 
                                'barcode' : { 'hidden' : false },
@@ -34,13 +34,20 @@ circ.checkin.prototype = {
                        {
                                'except_these' : [ 'uses', 'checkin_time_full' ]
                        }
-               );
+               ).concat(
+            patron.util.columns( {} )
+
+        ).concat(
+            patron.util.mbts_columns( {}, { 'except_these' : [ 'total_paid', 'total_owed', 'xact_start', 'xact_finish', 'xact_type' ] } )
+
+        ).sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
 
                JSAN.use('util.list'); obj.list = new util.list('checkin_list');
                obj.list.init(
                        {
                                'columns' : columns,
                                'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+                'retrieve_row' : obj.gen_list_retrieve_row_func(),
                                'on_select' : function(ev) {
                                        try {
                                                JSAN.use('util.functional');
@@ -279,6 +286,46 @@ circ.checkin.prototype = {
 
        },
 
+    'gen_list_retrieve_row_func' : function() {
+        var obj = this;
+        return function(params) {
+            try {
+                var row = params.row;
+                if (typeof params.on_retrieve == 'function') params.on_retrieve(row);
+
+                if (row.my.circ && ( document.getElementById('no_change_label') || document.getElementById('fine_tally') ) ) {
+                    obj.network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),row.my.circ.id()], function(req) {
+                        JSAN.use('util.money');
+                        var bill = req.getResultObject();
+                        row.my.mbts = bill;
+                        if (typeof params.on_retrieve == 'function') params.on_retrieve(row);
+                        if (Number(bill.balance_owed()) == 0) { return; }
+                        if (document.getElementById('no_change_label')) {
+                            var m = document.getElementById('no_change_label').getAttribute('value');
+                            document.getElementById('no_change_label').setAttribute(
+                                'value', 
+                                m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [row.my.acp.barcode(), util.money.sanitize(bill.balance_owed())]) + '  '
+                            );
+                            document.getElementById('no_change_label').setAttribute('hidden','false');
+                        }
+                        if (document.getElementById('fine_tally')) {
+                            var amount = Number( document.getElementById('fine_tally').getAttribute('amount') ) + Number( bill.balance_owed() );
+                            document.getElementById('fine_tally').setAttribute('amount',amount);
+                            document.getElementById('fine_tally').setAttribute(
+                                'value',
+                                document.getElementById('circStrings').getFormattedString('staff.circ.utils.fine_tally_text', [ util.money.sanitize( amount ) ])
+                            );
+                            document.getElementById('fine_tally').setAttribute('hidden','false');
+                        }
+                    });
+                }
+            } catch(E) {
+                alert('Error in checkin.js, list_retrieve_row(): ' + E);
+            }
+            return row;
+        };
+    },
+
        'test_barcode' : function(bc) {
                var obj = this;
                var x = document.getElementById('strict_barcode');
index 9a8ddf7..3e61ac3 100644 (file)
@@ -1711,7 +1711,7 @@ circ.util.hold_columns = function(modify,params) {
                },
                {
                        'persist' : 'hidden width ordinal',
-                       'id' : 'id',
+                       'id' : 'ahr_id',
                        'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
                        'flex' : 1,
                        'primary' : false,
@@ -2200,31 +2200,6 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che
                        document.getElementById('no_change_label').setAttribute('hidden','true');
                }
 
-               if (check.circ && ( document.getElementById('no_change_label') || document.getElementById('fine_tally') ) ) {
-                       network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),check.circ.id()], function(req) {
-                               JSAN.use('util.money');
-                               var bill = req.getResultObject();
-                               if (Number(bill.balance_owed()) == 0) { return; }
-                               if (document.getElementById('no_change_label')) {
-                                       var m = document.getElementById('no_change_label').getAttribute('value');
-                                       document.getElementById('no_change_label').setAttribute(
-                        'value', 
-                        m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [params.barcode, util.money.sanitize(bill.balance_owed())]) + '  '
-                    );
-                                       document.getElementById('no_change_label').setAttribute('hidden','false');
-                               }
-                               if (document.getElementById('fine_tally')) {
-                                       var amount = Number( document.getElementById('fine_tally').getAttribute('amount') ) + Number( bill.balance_owed() );
-                    document.getElementById('fine_tally').setAttribute('amount',amount);
-                    document.getElementById('fine_tally').setAttribute(
-                        'value',
-                        document.getElementById('circStrings').getFormattedString('staff.circ.utils.fine_tally_text', [ util.money.sanitize( amount ) ])
-                    );
-                                       document.getElementById('fine_tally').setAttribute('hidden','false');
-                }
-                       });
-               }
-
                var msg = '';
         var print_list = [];
         var print_data = {