retrieve foreign non-cat types as needed..and make sure only the non-foreign ones...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Aug 2006 16:20:47 +0000 (16:20 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Aug 2006 16:20:47 +0000 (16:20 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5297 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/util/fm_utils.js
Open-ILS/xul/staff_client/server/circ/checkout.js
Open-ILS/xul/staff_client/server/patron/items.js

index ee1f7eb..d988772 100644 (file)
@@ -3,7 +3,7 @@ dump('entering util/fm_utils.js\n');
 if (typeof util == 'undefined') var util = {};
 util.fm_utils = {};
 
-util.fm_utils.EXPORT_OK        = [ 'flatten_ou_branch', 'find_ou' ];
+util.fm_utils.EXPORT_OK        = [ 'flatten_ou_branch', 'find_ou', 'compare_aou_a_is_b_or_ancestor' ];
 util.fm_utils.EXPORT_TAGS      = { ':all' : util.fm_utils.EXPORT_OK };
 
 util.fm_utils.flatten_ou_branch = function(branch) {
@@ -34,3 +34,14 @@ util.fm_utils.find_ou = function(tree,id) {
        return null;
 }
 
+util.fm_utils.compare_aou_a_is_b_or_ancestor = function(a,b) {
+       JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+       if (typeof a != 'object') a = data.hash.aou[ a ];
+       if (typeof b != 'object') b = data.hash.aou[ b ];
+       var node = b;
+       while ( node != null ) {
+               if (a.id() == node.id()) return true;
+               node = typeof node.parent_ou() == 'object' ? node.parent_ou() : data.hash.aou[ node.parent_ou() ];
+       }
+       return false;
+}
index a24b8a0..c57006a 100644 (file)
@@ -42,10 +42,15 @@ circ.checkout.prototype = {
                                                ['render'],
                                                function(e) {
                                                        return function() {
-                                                               JSAN.use('util.widgets'); JSAN.use('util.functional');
+                                                               JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
                                                                var items = [ [ 'Barcode:' , 'barcode' ] ].concat(
                                                                        util.functional.map_list(
-                                                                               obj.data.list.cnct,
+                                                                               util.functional.filter_list(
+                                                                                       obj.data.list.cnct,
+                                                                                       function(o) {
+                                                                                               return util.fm_utils.compare_aou_a_is_b_or_ancestor(o.owning_lib(), obj.data.list.au[0].ws_ou());
+                                                                                       }
+                                                                               ),
                                                                                function(o) {
                                                                                        return [ o.name(), o.id() ];
                                                                                }
index a3995a3..c5c2658 100644 (file)
@@ -75,8 +75,6 @@ patron.items.prototype = {
                                        fake_circ.circ_lib( nc_circ.circ_lib() );
                                        fake_circ.circ_staff( nc_circ.staff() );
                                        fake_circ.usr( nc_circ.patron() );
-                                       fake_circ.circ_staff( nc_circ.staff() );
-                                       fake_circ.circ_lib( nc_circ.circ_lib() );
                                        fake_circ.xact_start( nc_circ.circ_time() );
                                        fake_circ.renewal_remaining(0);
                                        fake_circ.stop_fines('Non-Cataloged');
@@ -85,6 +83,19 @@ patron.items.prototype = {
                                        var c = nc_circ.circ_time();
                                        var d = c == "now" ? new Date() : util.date.db_date2Date( c );
                                        var t = obj.data.hash.cnct[ nc_circ.item_type() ];
+                                       if (!t) {
+                                               var robj2 = obj.network.simple_request('FM_CNCT_RETRIEVE',[ nc_circ.circ_lib() ]);
+                                               if (typeof robj2.ilsevent != 'undefined') throw(robj);
+                                               obj.data.stash_retrieve();
+                                               for (var j = 0; j < robj2.length; j++) {
+                                                       if (! obj.data.hash.cnct[ robj2[j].id() ] ) {
+                                                               obj.data.hash.cnct[ robj2[j].id() ] = robj2[j];
+                                                               obj.data.list.cnct.push( robj2[j] );
+                                                       }
+                                               }
+                                               obj.data.stash('hash','list');
+                                               t = obj.data.hash.cnct[ nc_circ.item_type() ];
+                                       }
                                        var cd = t.circ_duration() || "14 days";
                                        var i = util.date.interval_to_seconds( cd ) * 1000;
                                        d.setTime( Date.parse(d) + i );
@@ -95,11 +106,12 @@ patron.items.prototype = {
        
                                        var fake_copy = new acp();
                                        fake_copy.barcode( '' );
+                                       fake_copy.circ_lib( nc_circ.circ_lib() );
 
                                        obj.list.append( { 'row' : { 'my' : { 'circ' : fake_circ, 'mvr' : fake_record, 'acp' : fake_copy } }, } );
 
                                } catch(F) {
-                                       obj.error.standard_unexpected_error_alert('Error showing NonCat #' + robj[ii],F);
+                                       obj.error.standard_unexpected_error_alert('Error showing NonCat #' + robj[ii].id(),F);
                                }
                        }
 
@@ -417,6 +429,7 @@ patron.items.prototype = {
                var columns = circ.util.columns( 
                        { 
                                'barcode' : { 'hidden' : false },
+                               'circ_lib' : { 'hidden' : false },
                                'title' : { 'hidden' : false, 'flex' : '3' },
                                'due_date' : { 'hidden' : false },
                                'renewal_remaining' : { 'hidden' : false },
@@ -426,6 +439,7 @@ patron.items.prototype = {
                var columns2 = circ.util.columns( 
                        { 
                                'barcode' : { 'hidden' : false },
+                               'circ_lib' : { 'hidden' : false },
                                'title' : { 'hidden' : false, 'flex' : '3' },
                                'checkin_time' : { 'hidden' : false },
                                'stop_fines' : { 'hidden' : false },