acpl lookup
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Aug 2006 05:26:08 +0000 (05:26 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Aug 2006 05:26:08 +0000 (05:26 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5276 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/copy_editor.js
Open-ILS/xul/staff_client/server/circ/util.js

index dfd93a7..5c95604 100644 (file)
@@ -369,6 +369,54 @@ g.populate_alert_message_input = function(tb) {
 }
 
 /******************************************************************************************************/
+/* This returns a list of acpl's appropriate for the copies being edited */
+
+g.get_acpl_list = function() {
+       try {
+
+               function get(lib_id) {
+                       g.data.stash_retrieve();
+                       var label = 'acpl_list_for_lib_'+lib_id;
+                       if (typeof g.data[label] == 'undefined') {
+                               var robj = g.network.simple_request('FM_ACPL_RETRIEVE', [ lib_id ]);
+                               if (typeof robj.ilsevent != 'undefined') throw(robj);
+                               var temp_list = [];
+                               for (var j = 0; j < robj.length; j++) {
+                                       var my_acpl = robj[j];
+                                       if (typeof g.data.hash.acpl[ my_acpl.id() ] == 'undefined') {
+                                               g.data.hash.acpl[ my_acpl.id() ] = my_acpl;
+                                               g.data.list.acpl.push( my_acpl );
+                                       }
+                                       temp_list.push( my_acpl );
+                               }
+                               g.data[label] = temp_list; g.data.stash(label,'hash','list');
+                       }
+                       return g.data[label];
+               }
+
+               var seen = {}; seen[ g.data.list.au[0].ws_ou() ] = true;
+               var list = get( g.data.list.au[0].ws_ou() ); //g.data.list.acpl;
+               for (var i = 0; i < g.copies.length; i++) {
+                       var cn_id = g.copies[i].call_number();
+                       if (cn_id > 0) {
+                               var my_acn = g.network.simple_request('FM_ACN_RETRIEVE',[ cn_id ]);
+                               var lib = my_acn.owning_lib();
+                               if ( typeof seen[lib] == 'undefined' ) {
+                                       seen[lib] = true;
+                                       var r = get(my_acn.owning_lib());
+                                       list = list.concat( r );
+                               }
+                       } 
+               }
+               return list;
+       } catch(E) {
+               g.error.standard_unexpected_error_alert('get_acpl_list',E);
+               return list;
+       }
+}
+
+
+/******************************************************************************************************/
 /* This keeps track of what fields have been edited for styling purposes */
 
 g.changed = {};
@@ -489,8 +537,8 @@ g.panes_and_field_names = {
        [
                "Shelving Location",
                { 
-                       render: 'typeof fm.location() == "object" ? fm.location().name() : g.data.hash.acpl[ fm.location() ].name()', 
-                       input: 'c = function(v){ g.apply("location",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.acpl, function(obj) { return [ obj.name(), obj.id() ]; }).sort()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+                       render: 'typeof fm.location() == "object" ? fm.location().name() : g.data.lookup("acpl",fm.location()).name()', 
+                       input: 'c = function(v){ g.apply("location",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.get_acpl_list(), function(obj) { return [ g.data.hash.aou[ obj.owning_lib() ].shortname() + " : " + obj.name(), obj.id() ]; }).sort()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
 
                }
        ],
index 174162a..9eb279b 100644 (file)
@@ -350,7 +350,7 @@ circ.util.columns = function(modify,params) {
                },
                {
                        'id' : 'location', 'label' : getString('staff.acp_label_location'), 'flex' : 1,
-                       'primary' : false, 'hidden' : true, 'render' : 'if (Number(my.acp.location())>=0) obj.data.hash.acpl[ my.acp.location() ].name(); else my.acp.location().name();', 'persist' : 'hidden width',
+                       'primary' : false, 'hidden' : true, 'render' : 'if (Number(my.acp.location())>=0) obj.data.lookup("acpl", my.acp.location() ).name(); else my.acp.location().name();', 'persist' : 'hidden width',
                },
                {
                        'id' : 'loan_duration', 'label' : getString('staff.acp_label_loan_duration'), 'flex' : 1,
@@ -700,7 +700,7 @@ circ.util.checkin_via_barcode = function(session,barcode,backdate,auto_print) {
 
                /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
                if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
-                       try { check.route_to = data.hash.acpl[ check.copy.location() ].name(); } catch(E) { msg += 'FIXME: ' + E + '\n'; }
+                       try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); } catch(E) { msg += 'FIXME: ' + E + '\n'; }
                        var msg = '';
                        if (check.ilsevent == 3) msg = 'This item is already checked in.\n';
                        if (check.ilsevent == 1202 && check.copy.status() != 11) {