]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/copy_browser.js
Improve Firefox/XULRunner Support
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / cat / copy_browser.js
1 dump('entering cat.copy_browser.js\n');
2 // vim:noet:sw=4:ts=4:
3
4 if (typeof cat == 'undefined') cat = {};
5 cat.copy_browser = function (params) {
6     try {
7         JSAN.use('util.error'); this.error = new util.error();
8     } catch(E) {
9         dump('cat.copy_browser: ' + E + '\n');
10     }
11 }
12
13 cat.copy_browser.prototype = {
14
15     'map_tree' : {},
16     'map_acn' : {},
17     'map_acp' : {},
18     'sel_list' : [],
19     'funcs' : [],
20
21     'init' : function( params ) {
22
23         try {
24             var obj = this;
25
26             obj.docid = params.docid;
27
28             JSAN.use('util.network'); obj.network = new util.network();
29             JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
30
31             obj.controller_init(params);
32
33             obj.list_init(params);
34
35             obj.source_init();
36
37             obj.controller.render();
38
39             obj.default_depth = obj.depth_menu_init();
40             obj.default_lib = obj.data.hash.aou[ obj.library_menu_init() ];
41
42             document.getElementById('show_acns').addEventListener(
43                 'command',
44                 function(ev) {
45                     JSAN.use('util.file');
46                     var file = new util.file(
47                         'copy_browser_prefs.'+obj.data.server_unadorned);
48                     util.widgets.save_attributes(file, {
49                         'lib_menu' : [ 'value' ],
50                         'depth_menu' : [ 'value' ],
51                         'show_acns' : [ 'checked' ],
52                         'show_acps' : [ 'checked' ],
53                         'hide_aous' : [ 'checked' ] });
54                 },
55                 false
56             );
57
58             document.getElementById('show_acps').addEventListener(
59                 'command',
60                 function(ev) {
61                     JSAN.use('util.file');
62                     var file = new util.file(
63                         'copy_browser_prefs.'+obj.data.server_unadorned);
64                     util.widgets.save_attributes(file, {
65                         'lib_menu' : [ 'value' ],
66                         'depth_menu' : [ 'value' ],
67                         'show_acns' : [ 'checked' ],
68                         'show_acps' : [ 'checked' ],
69                         'hide_aous' : [ 'checked' ] });
70                 },
71                 false
72             );
73
74             document.getElementById('hide_aous').addEventListener(
75                 'command',
76                 function(ev) {
77                     JSAN.use('util.file');
78                     var file = new util.file(
79                         'copy_browser_prefs.'+obj.data.server_unadorned);
80                     util.widgets.save_attributes(file, {
81                         'lib_menu' : [ 'value' ],
82                         'depth_menu' : [ 'value' ],
83                         'show_acns' : [ 'checked' ],
84                         'show_acps' : [ 'checked' ],
85                         'hide_aous' : [ 'checked' ] });
86                 },
87                 false
88             );
89
90             obj.show_my_libs( obj.default_lib.id() );
91
92             JSAN.use('util.exec'); var exec = new util.exec(20); exec.timer(obj.funcs,100);
93
94             obj.show_consortial_count();
95
96         } catch(E) {
97             this.error.standard_unexpected_error_alert('cat.copy_browser.init: ',E);
98         }
99     },
100
101     'controller_init' : function(params) {
102         var obj = this;
103         try {
104             JSAN.use('util.controller'); obj.controller = new util.controller();
105             obj.controller.init(
106                 {
107                     control_map : {
108                         'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
109                         'sel_clip' : [
110                             ['command'],
111                             function() { obj.list.clipboard(); }
112                         ],
113                         'cmd_broken' : [
114                             ['command'],
115                             function() { 
116                                 alert(document.getElementById('commonStrings').getString('common.unimplemented'));
117                             }
118                         ],
119                         'cmd_show_my_libs' : [
120                             ['command'],
121                             function() { 
122                                 obj.show_my_libs(); 
123                             }
124                         ],
125                         'cmd_show_all_libs' : [
126                             ['command'],
127                             function() {
128                                 obj.show_all_libs();
129                             }
130                         ],
131                         'cmd_show_libs_with_copies' : [
132                             ['command'],
133                             function() {
134                                 obj.show_libs_with_copies();
135                             }
136                         ],
137                         'cmd_clear' : [
138                             ['command'],
139                             function() {
140                                 obj.map_tree = {};
141                                 obj.list.clear();
142                             }
143                         ],
144                         'cmd_request_items' : [
145                             ['command'],
146                             function() {
147                                 JSAN.use('cat.util'); JSAN.use('util.functional');
148
149                                 var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
150
151                                 list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
152
153                                 cat.util.request_items( list );
154                             }
155                         ],
156                         'sel_mark_items_damaged' : [
157                             ['command'],
158                             function() {
159                                 JSAN.use('cat.util'); JSAN.use('util.functional');
160
161                                 var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
162
163                                 list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
164
165                                 cat.util.mark_item_damaged( list );
166
167                                 obj.refresh_list();
168                             }
169                         ],
170                         'sel_mark_items_missing' : [
171                             ['command'],
172                             function() {
173                                 JSAN.use('cat.util'); JSAN.use('util.functional');
174
175                                 var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
176
177                                 list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
178
179                                 cat.util.mark_item_missing( list );
180
181                                 obj.refresh_list();
182                             }
183                         ],
184                         'sel_patron' : [
185                             ['command'],
186                             function() {
187                                 JSAN.use('util.functional');
188
189                                 var list = util.functional.filter_list(
190                                     obj.sel_list,
191                                     function (o) {
192                                         return o.split(/_/)[0] == 'acp';
193                                     }
194                                 );
195
196                                 list = util.functional.map_list(
197                                     list,
198                                     function (o) {
199                                         return { 'copy_id' : o.split(/_/)[1] };
200                                     }
201                                 );
202                                 
203                                 JSAN.use('circ.util');
204                                 circ.util.show_last_few_circs(list);
205                             }
206                         ],
207                         'sel_copy_details' : [
208                             ['command'],
209                             function() {
210                                 JSAN.use('util.functional');
211
212                                 var list = util.functional.filter_list(
213                                     obj.sel_list,
214                                     function (o) {
215                                         return o.split(/_/)[0] == 'acp';
216                                     }
217                                 );
218
219                                 JSAN.use('circ.util');
220                                 circ.util.item_details_new(
221                                     util.functional.map_list(
222                                         list, function (o) {
223                                             return obj.map_acp[o].barcode();
224                                         }
225                                     )
226                                 );
227                             }
228                         ],
229                         'cmd_create_brt' : [
230                             ['command'],
231                             function() {
232                                 JSAN.use("cat.util");
233                                 JSAN.use("util.functional");
234
235                                 /* Filter selected rows that aren"t copies. */
236                                 var list = util.functional.filter_list(
237                                     obj.sel_list,
238                                     function (o) {
239                                         return o.split(/_/)[0] == "acp";
240                                     }
241                                 );
242                                 var results = cat.util.make_bookable(
243                                     util.functional.map_list(
244                                         list, function (o) {
245                                             return obj.map_acp[o].id();
246                                         }
247                                     )
248                                 );
249                                 if (results && results["brsrc"]) {
250                                     cat.util.edit_new_brsrc(results["brsrc"]);
251                                 }
252                             }
253                         ],
254                         'cmd_book_item_now' : [
255                             ['command'],
256                             function() {
257                                 JSAN.use("cat.util");
258                                 JSAN.use("util.functional");
259
260                                 /* Filter selected rows that aren"t copies. */
261                                 var list = util.functional.filter_list(
262                                     obj.sel_list,
263                                     function (o) {
264                                         return o.split(/_/)[0] == "acp";
265                                     }
266                                 );
267                                 var results = cat.util.make_bookable(
268                                     util.functional.map_list(
269                                         list, function (o) {
270                                             return obj.map_acp[o].id();
271                                         }
272                                     )
273                                 );
274                                 if (results) {
275                                     cat.util.edit_new_bresv(results);
276                                 }
277                             }
278                         ],
279                         'cmd_add_items' : [
280                             ['command'],
281                             function() {
282                                 try {
283                                     JSAN.use('util.functional');
284                                     var list = util.functional.map_list(
285                                         util.functional.filter_list(
286                                             obj.sel_list,
287                                             function (o) {
288                                                 return o.split(/_/)[0] == 'acn';
289                                             }
290                                         ),
291                                         function (o) {
292                                             return o.split(/_/)[1];
293                                         }
294                                     );
295                                     if (list.length == 0) return;
296
297                                     var copy_shortcut = {};
298                                     list = util.functional.map_list(
299                                         list,
300                                         function (o) {
301                                             var call_number = obj.map_acn['acn_'+o];
302                                             var ou_id = call_number.owning_lib();
303                                             var volume_id = o;
304                                             var label = call_number.label();
305                                             var acnc_id = typeof call_number.label_class() == 'object'
306                                                 ? call_number.label_class().id()
307                                                 : call_number.label_class();
308                                             var acnp_id = typeof call_number.prefix() == 'object'
309                                                 ? call_number.prefix().id()
310                                                 : call_number.prefix();
311                                             var acns_id = typeof call_number.suffix() == 'object'
312                                                 ? call_number.suffix().id()
313                                                 : call_number.suffix();
314                                             if (!copy_shortcut[ou_id]) copy_shortcut[ou_id] = {};
315                                             var callnumber_composite_key = acnc_id + ':' + acnp_id + ':' + label + ':' + acns_id;
316                                             copy_shortcut[ou_id][ callnumber_composite_key ] = volume_id;
317
318                                             return ou_id;
319                                         }
320                                     );
321                                     /* quick fix */  /* what was this fixing? */
322                                     list = []; for (var i in copy_shortcut) { list.push( i ); }
323
324                                     var edit = 0;
325                                     try {
326                                         edit = obj.network.request(
327                                             api.PERM_MULTI_ORG_CHECK.app,
328                                             api.PERM_MULTI_ORG_CHECK.method,
329                                             [ 
330                                                 ses(), 
331                                                 obj.data.list.au[0].id(), 
332                                                 list,
333                                                 [ 'CREATE_COPY' ]
334                                             ]
335                                         ).length == 0 ? 1 : 0;
336                                     } catch(E) {
337                                         obj.error.sdump('D_ERROR','batch permission check: ' + E);
338                                     }
339
340                                     if (edit==0) return; // no read-only view for this interface
341
342                                     if (!obj.can_have_copies) {
343                                         alert(document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.can_have_copies.false', obj.source));
344                                         return;
345                                     }
346
347                                     var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.title');
348
349                                     var url;
350                                     var unified_interface = String( obj.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
351                                     if (unified_interface) {
352                                         var horizontal_interface = String( obj.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
353                                         url = xulG.url_prefix( horizontal_interface ? 'XUL_VOLUME_COPY_CREATOR_HORIZONTAL' : 'XUL_VOLUME_COPY_CREATOR' );
354                                     } else {
355                                         url = xulG.url_prefix('XUL_VOLUME_COPY_CREATOR_ORIGINAL');
356                                     }
357
358                                     var w = xulG.new_tab(
359                                         url,
360                                         { 'tab_name' : title },
361                                         {
362                                             'doc_id' : obj.docid, 
363                                             'ou_ids' : list, 
364                                             'copy_shortcut' : copy_shortcut,
365                                             'onrefresh' : function() { obj.refresh_list(); }
366                                         }
367                                     );
368                                 } catch(E) {
369                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.error'),E);
370                                 }
371                             }
372                         ],
373                         'cmd_add_items_to_buckets' : [
374                             ['command'],
375                             function() {
376                                 try {
377                                     JSAN.use('util.functional');
378
379                                     var list = util.functional.filter_list(
380                                         obj.sel_list,
381                                         function (o) {
382                                             return o.split(/_/)[0] == 'acp';
383                                         }
384                                     );
385
386                                     list = util.functional.map_list(
387                                         list,
388                                         function (o) {
389                                             return o.split(/_/)[1];
390                                         }
391                                     );
392                                 
393                                     JSAN.use('cat.util');
394                                     cat.util.add_copies_to_bucket( list );
395
396                                 } catch(E) {
397                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_items_bucket.error'),E);
398                                 }
399                             }
400                         ],
401                         'cmd_edit_items' : [
402                             ['command'],
403                             function() {
404                                 try {
405                                     var unified_interface = String( obj.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
406                                     if (!unified_interface) {
407                                         obj.controller.control_map['old_cmd_edit_items'][1]();
408                                         return;
409                                     }
410
411                                     JSAN.use('util.functional');
412
413                                     var list = util.functional.filter_list(
414                                         obj.sel_list,
415                                         function (o) {
416                                             return o.split(/_/)[0] == 'acp';
417                                         }
418                                     );
419
420                                     list = util.functional.map_list(
421                                         list,
422                                         function (o) {
423                                             var cloned_copy_obj = JSON2js( js2JSON( obj.map_acp[ o ] ) );
424                                             cloned_copy_obj.call_number( obj.map_acn[ 'acn_' + cloned_copy_obj.call_number() ] );
425                                             return cloned_copy_obj;
426                                         }
427                                     );
428
429                                     if (list.length > 0) {
430                                         xulG.volume_item_creator( {'existing_copies':list, 'onrefresh' : function() { obj.refresh_list(); } } );
431                                     }
432
433                                 } catch(E) {
434                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_items.error'),E);
435                                     obj.refresh_list();
436                                 }
437                             }
438                         ],
439                         'cmd_replace_barcode' : [
440                             ['command'],
441                             function() {
442                                 try {
443                                     JSAN.use('util.functional');
444
445                                     var list = util.functional.filter_list(
446                                         obj.sel_list,
447                                         function (o) {
448                                             return o.split(/_/)[0] == 'acp';
449                                         }
450                                     );
451
452                                     list = util.functional.map_list(
453                                         list,
454                                         function (o) {
455                                             var cloned_copy_obj = JSON2js( js2JSON( obj.map_acp[ o ] ) );
456                                             cloned_copy_obj.call_number( obj.map_acn[ 'acn_' + cloned_copy_obj.call_number() ] );
457                                             return cloned_copy_obj;
458                                         }
459                                     );
460
461                                     xulG.volume_item_creator( {'existing_copies':list, 'onrefresh' : function() { obj.refresh_list(); } } );
462
463                                 } catch(E) {
464                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_items.error'),E);
465                                     obj.refresh_list();
466                                 }
467                             }
468                         ],
469
470                         'old_cmd_edit_items' : [
471                             ['command'],
472                             function() {
473                                 try {
474                                     JSAN.use('util.functional');
475
476                                     var list = util.functional.filter_list(
477                                         obj.sel_list,
478                                         function (o) {
479                                             return o.split(/_/)[0] == 'acp';
480                                         }
481                                     );
482
483                                     list = util.functional.map_list(
484                                         list,
485                                         function (o) {
486                                             return o.split(/_/)[1];
487                                         }
488                                     );
489
490                                     JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
491                                     obj.refresh_list();
492
493                                 } catch(E) {
494                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_items.error'),E);
495                                 }
496                             }
497                         ],
498                         'cmd_delete_items' : [
499                             ['command'],
500                             function() {
501                                 try {
502                                     JSAN.use('util.functional');
503
504                                     var list = util.functional.filter_list(
505                                         obj.sel_list,
506                                         function (o) {
507                                             return o.split(/_/)[0] == 'acp';
508                                         }
509                                     );
510
511                                     list = util.functional.map_list(
512                                         list,
513                                         function (o) {
514                                             return JSON2js( js2JSON( obj.map_acp[ 'acp_' + o.split(/_/)[1] ] ) );
515                                         }
516                                     );
517
518                                     var delete_msg;
519                                     if (list.length != 1) {
520                                         delete_msg = document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.delete_items.confirm.plural', [list.length]);
521                                     } else {
522                                         delete_msg = document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.confirm');
523                                     }
524                                     var r = obj.error.yns_alert(
525                                             delete_msg,
526                                             document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.title'),
527                                             document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.delete'),
528                                             document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.cancel'),
529                                             null,
530                                             document.getElementById('commonStrings').getString('common.confirm')
531                                     );
532
533                                     if (r == 0) {
534                                         var acn_hash = {}; var acn_list = [];
535                                         for (var i = 0; i < list.length; i++) {
536                                             list[i].isdeleted('1');
537                                             var acn_id = list[i].call_number();
538                                             if ( ! acn_hash[ acn_id ] ) {
539                                                 acn_hash[ acn_id ] = obj.map_acn[ 'acn_' + acn_id ];
540                                                 acn_hash[ acn_id ].copies( [] );
541                                             }
542                                             var temp = acn_hash[ acn_id ].copies();
543                                             temp.push( list[i] );
544                                             acn_hash[ acn_id ].copies( temp );
545                                         }
546                                         for (var i in acn_hash) acn_list.push( acn_hash[i] );
547                                         var robj = obj.network.simple_request(
548                                             'FM_ACN_TREE_UPDATE', 
549                                             [ ses(), acn_list, true ],
550                                             null,
551                                             {
552                                                 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.override'),
553                                                 'overridable_events' : [
554                                                     1208 /* TITLE_LAST_COPY */,
555                                                     1227 /* COPY_DELETE_WARNING */,
556                                                 ]
557                                             }
558                                         );
559                                         if (robj == null) throw(robj);
560                                         if (typeof robj.ilsevent != 'undefined') {
561                                             if (
562                                                 (robj.ilsevent != 0)
563                                                 && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */)
564                                                 && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */)
565                                                 && (robj.ilsevent != 5000 /* PERM_DENIED */)
566                                             ) {
567                                                 throw(robj);
568                                             }
569                                         }
570                                         obj.refresh_list();
571                                     }
572
573                                     
574                                 } catch(E) {
575                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.error'),E);
576                                     obj.refresh_list();
577                                 }
578                             }
579                         ],
580                         'cmd_print_spine_labels' : [
581                             ['command'],
582                             function() {
583                                 try {
584                                     JSAN.use('util.functional');
585                                     
586                                     var list = util.functional.filter_list(
587                                         obj.sel_list,
588                                         function (o) {
589                                             return o.split(/_/)[0] == 'acp';
590                                         }
591                                     );
592
593                                     list = util.functional.map_list(
594                                         list,
595                                         function (o) {
596                                             return obj.map_acp[ o ];
597                                         }
598                                     );
599
600                                     xulG.new_tab(
601                                         xulG.url_prefix('XUL_SPINE_LABEL'),
602                                         { 'tab_name' : document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.tab') },
603                                         {
604                                             'barcodes' : util.functional.map_list( list, function(o){return o.barcode();})
605                                         }
606                                     );
607                                 } catch(E) {
608                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.error'),E);
609                                 }
610                             }
611                         ],
612                         'cmd_add_volumes' : [
613                             ['command'],
614                             function() {
615                                 try {
616                                     JSAN.use('util.functional');
617                                     var list = util.functional.filter_list(
618                                         obj.sel_list,
619                                         function (o) {
620                                             return o.split(/_/)[0] == 'aou';
621                                         }
622                                     );
623                                     list = util.functional.map_list(
624                                         list,
625                                         function (o) {
626                                             return o.split(/_/)[1];
627                                         }
628                                     );        
629                                     var edit = 0;
630                                     try {
631                                         edit = obj.network.request(
632                                             api.PERM_MULTI_ORG_CHECK.app,
633                                             api.PERM_MULTI_ORG_CHECK.method,
634                                             [ 
635                                                 ses(), 
636                                                 obj.data.list.au[0].id(), 
637                                                 list,
638                                                 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
639                                             ]
640                                         ).length == 0 ? 1 : 0;
641                                     } catch(E) {
642                                         obj.error.sdump('D_ERROR','batch permission check: ' + E);
643                                     }
644
645                                     if (edit==0) {
646                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.permission_error'));
647                                         return; // no read-only view for this interface
648                                     }
649
650                                     if (!obj.can_have_copies) {
651                                         alert(document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.can_have_copies.false', obj.source));
652                                         return;
653                                     }
654
655                                     var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.title');
656
657                                     var url;
658                                     var unified_interface = String( obj.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
659                                     if (unified_interface) {
660                                         var horizontal_interface = String( obj.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
661                                         url = xulG.url_prefix( horizontal_interface ? 'XUL_VOLUME_COPY_CREATOR_HORIZONTAL' : 'XUL_VOLUME_COPY_CREATOR' );
662                                     } else {
663                                         url = xulG.url_prefix('XUL_VOLUME_COPY_CREATOR_ORIGINAL');
664                                     }
665
666                                     var w = xulG.new_tab(
667                                         url,
668                                         { 'tab_name' : title },
669                                         { 'doc_id' : obj.docid, 'ou_ids' : list, 'onrefresh' : function() { obj.refresh_list(); } }
670                                     );
671
672                                 } catch(E) {
673                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.error'),E);
674                                 }
675                             }
676                         ],
677                         'cmd_edit_volumes' : [
678                             ['command'],
679                             function() {
680                                 try {
681                                     JSAN.use('util.functional');
682                                     var volumes = util.functional.map_list(
683                                         util.functional.filter_list(
684                                             obj.sel_list,
685                                             function (o) {
686                                                 return o.split(/_/)[0] == 'acn';
687                                             }
688                                         ),
689                                         function (o) {
690                                             return o.split(/_/)[1];
691                                         }
692                                     );
693                                     volumes = util.functional.map_list(
694                                         volumes,
695                                         function (o) {
696                                             var my_acn = obj.map_acn['acn_' + o];
697                                             return function(r){return r;}(my_acn);
698                                         }
699                                     );
700
701                                     JSAN.use('cat.util'); 
702                                     if ( cat.util.batch_edit_volumes( volumes ) ) {
703                                         obj.refresh_list();
704                                     }
705
706                                 } catch(E) {
707                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.exception'),E);
708                                 }
709                             }
710                         ],
711                         'cmd_delete_volumes' : [
712                             ['command'],
713                             function() {
714                                 try {
715                                     JSAN.use('util.functional');
716
717                                     var list = util.functional.filter_list(
718                                         obj.sel_list,
719                                         function (o) {
720                                             return o.split(/_/)[0] == 'acn';
721                                         }
722                                     );
723
724                                     list = util.functional.map_list(
725                                         list,
726                                         function (o) {
727                                             return JSON2js( js2JSON( obj.map_acn[ 'acn_' + o.split(/_/)[1] ] ) );
728                                         }
729                                     );
730
731                                     var del_prompt;
732                                     if (list.length == 1) {
733                                         del_prompt = document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.prompt');
734                                     } else {
735                                         del_prompt = document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.delete_volume.prompt.plural', [list.length]);
736                                     }
737
738                                     var r = obj.error.yns_alert(
739                                             del_prompt,
740                                             document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.title'),
741                                             document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.delete'),
742                                             document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.cancel'),
743                                             null,
744                                             document.getElementById('commonStrings').getString('common.confirm')
745                                     );
746
747                                     if (r == 0) { // delete vols
748                                         for (var i = 0; i < list.length; i++) {
749                                             list[i].isdeleted('1');
750                                         }
751                                         var params = {};
752                                         loop: while(true) {
753                                             var robj = obj.network.simple_request(
754                                                 'FM_ACN_TREE_UPDATE', 
755                                                 [ ses(), list, true, params ],
756                                                 null,
757                                                 {
758                                                     'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.override'),
759                                                     'overridable_events' : [
760                                                         1208 /* TITLE_LAST_COPY */,
761                                                         1227 /* COPY_DELETE_WARNING */
762                                                     ]
763                                                 }
764                                             );
765                                             if (robj == null) throw(robj);
766                                             if (typeof robj.ilsevent != 'undefined') {
767                                                 if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
768                                                     var r2 = obj.error.yns_alert(
769                                                         document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain'),
770                                                         document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.title'),
771                                                         document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain.confirm'),
772                                                         document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain.cancel'),
773                                                         null,
774                                                         document.getElementById('commonStrings').getString('common.confirm')
775                                                     );
776                                                     if (r2 == 0) { // delete vols and copies
777                                                         params.force_delete_copies = true;
778                                                         continue loop;
779                                                     }
780                                                 } else {
781                                                     if (typeof robj.ilsevent != 'undefined') {
782                                                         if (
783                                                             (robj.ilsevent != 0)
784                                                             && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */)
785                                                             && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */)
786                                                             && (robj.ilsevent != 5000 /* PERM_DENIED */)
787                                                         ) {
788                                                             throw(robj);
789                                                         }
790                                                     }
791                                                 }
792                                             }
793                                             break loop;
794                                         }
795                                         obj.refresh_list();
796                                     }
797                                 } catch(E) {
798                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.exception'),E);
799                                     obj.refresh_list();
800                                 }
801
802                             }
803                         ],
804                         'cmd_mark_library' : [
805                             ['command'],
806                             function() {
807                                 try {
808                                     var list = util.functional.filter_list(
809                                         obj.sel_list,
810                                         function (o) {
811                                             return o.split(/_/)[0] == 'aou';
812                                         }
813                                     );
814
815                                     list = util.functional.map_list(
816                                         list,
817                                         function (o) {
818                                             return o.split(/_/)[1];
819                                         }
820                                     );
821
822                                     if (list.length == 1) {
823                                         obj.data.marked_library = { 'lib' : list[0], 'docid' : obj.docid };
824                                         obj.data.stash('marked_library');
825                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.alert'));
826                                     } else {
827                                         obj.error.yns_alert(
828                                                 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.prompt'),
829                                                 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.title'),
830                                                 document.getElementById('commonStrings').getString('common.ok'),
831                                                 null,
832                                                 null,
833                                                 document.getElementById('commonStrings').getString('common.confirm')
834                                                 );
835                                     }
836                                 } catch(E) {
837                                     obj.error.standard_unexpected_error_alert('copy browser -> mark library',E);
838                                 }
839                             }
840                         ],
841
842                         'cmd_mark_volume' : [
843                             ['command'],
844                             function() {
845                                 try {
846                                     var list = util.functional.filter_list(
847                                         obj.sel_list,
848                                         function (o) {
849                                             return o.split(/_/)[0] == 'acn';
850                                         }
851                                     );
852
853                                     list = util.functional.map_list(
854                                         list,
855                                         function (o) {
856                                             return o.split(/_/)[1];
857                                         }
858                                     );
859
860                                     if (list.length == 1) {
861                                         obj.data.marked_volume = list[0];
862                                         obj.data.stash('marked_volume');
863                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.alert'));
864                                     } else {
865                                         obj.error.yns_alert(
866                                                 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.prompt'),
867                                                 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.title'),
868                                                 document.getElementById('commonStrings').getString('common.ok'),
869                                                 null,
870                                                 null,
871                                                 document.getElementById('commonStrings').getString('common.confirm')
872                                                 );
873                                     }
874                                 } catch(E) {
875                                     obj.error.standard_unexpected_error_alert('copy browser -> mark volume',E);
876                                 }
877                             }
878                         ],
879                         'cmd_refresh_list' : [
880                             ['command'],
881                             function() {
882                                 obj.refresh_list();
883                             }
884                         ],
885                         'cmd_transfer_volume' : [
886                             ['command'],
887                             function() {
888                                 try {
889                                     obj.data.stash_retrieve();
890                                     if (!obj.data.marked_library) {
891                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_volume.alert'));
892                                         return;
893                                     }
894                                     
895                                     JSAN.use('util.functional');
896
897                                     var list = util.functional.filter_list(
898                                         obj.sel_list,
899                                         function (o) {
900                                             return o.split(/_/)[0] == 'acn';
901                                         }
902                                     );
903
904                                     list = util.functional.map_list(
905                                         list,
906                                         function (o) {
907                                             return o.split(/_/)[1];
908                                         }
909                                     );
910
911                                     var acn_list = util.functional.map_list(
912                                         list,
913                                         function (o) {
914                                             return obj.map_acn[ 'acn_' + o ].label();
915                                         }
916                                     ).join(document.getElementById('commonStrings').getString('common.grouping_string'));
917
918                                     var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
919                                     xml += '<description>';
920                                     xml += document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.transfer.prompt', [acn_list, obj.data.hash.aou[ obj.data.marked_library.lib ].shortname()]);
921                                     xml += '</description>';
922                                     xml += '<hbox><button label="' + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.submit.label') + '" name="fancy_submit"/>';
923                                     xml += '<button label="' 
924                                         + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.label') 
925                                         + '" accesskey="' 
926                                         + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.accesskey') 
927                                         + '" name="fancy_cancel"/></hbox>';
928                                     xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '" oils_force_external="true"/>';
929                                     xml += '</vbox>';
930                                     JSAN.use('OpenILS.data');
931                                     var data = new OpenILS.data(); data.init({'via':'stash'});
932                                     //data.temp_transfer = xml; data.stash('temp_transfer');
933                                     JSAN.use('util.window'); var win = new util.window();
934                                     var fancy_prompt_data = win.open(
935                                         urls.XUL_FANCY_PROMPT,
936                                         //+ '?xml_in_stash=temp_transfer'
937                                         //+ '&title=' + window.escape('Volume Transfer'),
938                                         'fancy_prompt', 'chrome,resizable,modal,width=500,height=300',
939                                         {
940                                             'xml' : xml,
941                                             'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.title')
942                                         }
943                                     );
944
945                                     if (fancy_prompt_data.fancy_status == 'incomplete') {
946                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.incomplete'));
947                                         return;
948                                     }
949
950                                     var robj = obj.network.simple_request(
951                                         'FM_ACN_TRANSFER', 
952                                         [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'volumes' : list } ],
953                                         null,
954                                         {
955                                             'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.override.failure'),
956                                             'overridable_events' : [
957                                                 1208 /* TITLE_LAST_COPY */,
958                                                 1219 /* COPY_REMOTE_CIRC_LIB */,
959                                             ],
960                                         }
961                                     );
962
963                                     if (typeof robj.ilsevent != 'undefined') {
964                                         if (robj.ilsevent == 1221 /* ORG_CANNOT_HAVE_VOLS */) {
965                                             alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.ineligible_destination'));
966                                         } else {
967                                             throw(robj);
968                                         }
969                                     } else {
970                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.success'));
971                                     }
972
973                                 } catch(E) {
974                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.unexpected_error'),E);
975                                 }
976                                 obj.refresh_list();
977                             }
978                         ],
979
980                         'cmd_transfer_items' : [
981                             ['command'],
982                             function() {
983                                 try {
984                                     obj.data.stash_retrieve();
985                                     if (!obj.data.marked_volume) {
986                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.missing_volume'));
987                                         return;
988                                     }
989                                     
990                                     JSAN.use('util.functional');
991
992                                     var list = util.functional.filter_list(
993                                         obj.sel_list,
994                                         function (o) {
995                                             return o.split(/_/)[0] == 'acp';
996                                         }
997                                     );
998
999                                     list = util.functional.map_list(
1000                                         list,
1001                                         function (o) {
1002                                             return o.split(/_/)[1];
1003                                         }
1004                                     );
1005
1006                                     var volume = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_volume ]);
1007
1008                                     JSAN.use('cat.util'); cat.util.transfer_copies( { 
1009                                         'copy_ids' : list, 
1010                                         'docid' : volume.record(),
1011                                         'volume_label' : volume.label(),
1012                                         'owning_lib' : volume.owning_lib(),
1013                                     } );
1014
1015                                 } catch(E) {
1016                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.unexpected_error'),E);
1017                                 }
1018                                 obj.refresh_list();
1019                             }
1020                         ],
1021
1022                         'cmd_link_as_multi_bib' : [
1023                             ['command'],
1024                             function() {
1025                                 try {
1026                                     obj.data.stash_retrieve();
1027                                     if (!obj.data.marked_multi_home_record) {
1028                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.link_as_multi_bib.missing_bib'));
1029                                         return;
1030                                     }
1031
1032                                     JSAN.use('util.functional');
1033
1034                                     var list = util.functional.filter_list(
1035                                         obj.sel_list,
1036                                         function (o) {
1037                                             return o.split(/_/)[0] == 'acp';
1038                                         }
1039                                     );
1040
1041                                     list = util.functional.map_list(
1042                                         list,
1043                                         function (o) {
1044                                             return obj.map_acp[ o ].barcode();
1045                                         }
1046                                     );
1047
1048                                     xulG.new_tab(
1049                                         window.xulG.url_prefix('MANAGE_MULTI_HOME_ITEMS'),
1050                                         {},
1051                                         { 'docid' : obj.data.marked_multi_home_record, 'barcodes' : list }
1052                                     );
1053
1054                                 } catch(E) {
1055                                     alert('Error in copy_browser.js, cmd_link_as_multi_bib: ' + E);
1056                                 }
1057                                 obj.refresh_list();
1058                             }
1059                         ],
1060
1061                         'cmd_print_tree' : [
1062                             ['command'],
1063                             function() {
1064                                 try {
1065                                     var p = {
1066                                         'template' : 'holdings_maintenance',
1067                                         'mvr_id' : obj.docid,
1068                                         'print_data' : {}
1069                                     };
1070                                     bib_brief_overlay(p);
1071                                     p.data = p.print_data;
1072                                     obj.list.print(p);
1073                                 } catch(E) {
1074                                     alert('Error in copy_browser.js, cmd_print_tree: ' + E);
1075                                 }
1076                             }
1077                         ]
1078                     }
1079                 }
1080             );
1081
1082         } catch(E) {
1083             this.error.standard_unexpected_error_alert('cat.copy_browser.controller_init(): ',E);
1084         }
1085     },
1086
1087     'depth_menu_init' : function(params) {
1088         var obj = this;
1089         try {
1090             var list = [];
1091             var max_depth = 0;
1092             for (var i = 0; i < obj.data.list.aout.length; i++) {
1093                 var type = obj.data.list.aout[i];
1094                 var depth = type.depth();
1095                 if ( depth > max_depth) { max_depth = depth; }
1096                 if (typeof list[depth] == 'undefined') {
1097                     list[depth] = [
1098                         type.opac_label(),
1099                         type.depth(),
1100                         false,
1101                         ( type.depth() * 2)
1102                     ];
1103                 } else {
1104                     list[depth][0] += ' / ' + type.opac_label();
1105                 }
1106             }
1107             ml = util.widgets.make_menulist( list, max_depth );
1108             ml.setAttribute('id','depth_menu'); document.getElementById('x_depth_menu').appendChild(ml);
1109             ml.addEventListener(
1110                 'command',
1111                 function(ev) {
1112                     obj.default_depth = ev.target.value;
1113                     if (document.getElementById('refresh_button')) document.getElementById('refresh_button').focus(); 
1114                     JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
1115                     util.widgets.save_attributes(file, { 
1116                         'lib_menu' : [ 'value' ],
1117                         'depth_menu' : [ 'value' ],
1118                         'show_acns' : [ 'checked' ],
1119                         'show_acps' : [ 'checked' ],
1120                         'hide_aous' : [ 'checked' ]
1121                     });
1122                 },
1123                 false
1124             );
1125
1126             file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
1127             util.widgets.load_attributes(file);
1128             ml.value = ml.getAttribute('value');
1129             if (! ml.value) {
1130                 ml.value = max_depth;
1131                 ml.setAttribute('value',ml.value);
1132             }
1133
1134             return ml.value;
1135         } catch(E) {
1136             alert('Error in copy_browser.js, depth_menu_init(): ' + E);
1137         }
1138     },
1139
1140     'library_menu_init' : function(params) {
1141         var obj = this;
1142         try {
1143
1144             obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
1145             if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
1146             JSAN.use('util.functional'); 
1147             obj.org_ids = util.functional.map_list( obj.org_ids, function (o) { return Number(o); });
1148
1149             var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
1150
1151             JSAN.use('util.file'); JSAN.use('util.widgets');
1152
1153             var file; var list_data; var ml; 
1154
1155             file = new util.file('offline_ou_list'); 
1156             if (file._file.exists()) {
1157                 list_data = file.get_object(); file.close();
1158                 for (var i = 0; i < list_data[0].length; i++) { // make sure all entries are enabled
1159                     list_data[0][i][2] = false;
1160                 }
1161                 ml = util.widgets.make_menulist( list_data[0], list_data[1] );
1162                 ml.setAttribute('id','lib_menu'); document.getElementById('x_lib_menu').appendChild(ml);
1163                 for (var i = 0; i < obj.org_ids.length; i++) {
1164                     ml.getElementsByAttribute('value',obj.org_ids[i])[0].setAttribute('class','has_copies');
1165                 }
1166                 ml.firstChild.addEventListener(
1167                     'popupshowing',
1168                     function(ev) {
1169                         document.getElementById('legend').setAttribute('hidden','false');
1170                     },
1171                     false
1172                 );
1173                 ml.firstChild.addEventListener(
1174                     'popuphidden',
1175                     function(ev) {
1176                         document.getElementById('legend').setAttribute('hidden','true');
1177                     },
1178                     false
1179                 );
1180                 ml.addEventListener(
1181                     'command',
1182                     function(ev) {
1183                         obj.default_lib = obj.data.hash.aou[ ev.target.value ];
1184                         if (document.getElementById('refresh_button')) document.getElementById('refresh_button').focus(); 
1185                         JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
1186                         util.widgets.save_attributes(file, { 
1187                             'lib_menu' : [ 'value' ],
1188                             'depth_menu' : [ 'value' ],
1189                             'show_acns' : [ 'checked' ],
1190                             'show_acps' : [ 'checked' ],
1191                             'hide_aous' : [ 'checked' ]
1192                         });
1193                         obj.refresh_list();
1194                     },
1195                     false
1196                 );
1197             } else {
1198                 throw(document.getElementById('catStrings').getString('staff.cat.copy_browser.missing_library') + '\n');
1199             }
1200
1201             file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
1202             util.widgets.load_attributes(file);
1203             ml.value = ml.getAttribute('value');
1204             if (! ml.value) {
1205                 ml.value = org.id();
1206                 ml.setAttribute('value',ml.value);
1207             }
1208
1209             return ml.value;
1210
1211         } catch(E) {
1212             this.error.standard_unexpected_error_alert('cat.copy_browser.library_menu_init(): ',E);
1213         }
1214     },
1215
1216     'show_consortial_count' : function() {
1217         var obj = this;
1218         try {
1219             obj.network.simple_request('FM_ACP_COUNT.authoritative',[ obj.data.tree.aou.id(), obj.docid ],function(req){ 
1220                 try {
1221                     var robj = req.getResultObject();
1222                     var x = document.getElementById('consortial_total');
1223                     if (x) x.setAttribute('value',robj[0].count);
1224                     x = document.getElementById('consortial_available');
1225                     if (x) x.setAttribute('value',robj[0].available);
1226                 } catch(E) {
1227                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.consortial_copy_count.error'),E);
1228                 }
1229             });
1230         } catch(E) {
1231             this.error.standard_unexpected_error_alert('cat.copy_browser.show_consortial_count: ',E);
1232         }
1233     },
1234
1235     'show_my_libs' : function(org) {
1236         var obj = this;
1237         try {
1238             if (!org) {
1239                 org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
1240             } else {
1241                 if (typeof org != 'object') org = obj.data.hash.aou[ org ];
1242             }
1243             obj.show_libs( org, false );
1244 /*        
1245             var p_org = obj.data.hash.aou[ org.parent_ou() ];
1246             if (p_org) {
1247                 obj.funcs.push( function() { 
1248                     document.getElementById('cmd_refresh_list').setAttribute('disabled','true'); 
1249                     document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true'); 
1250                     document.getElementById('lib_menu').setAttribute('disabled','true'); 
1251                 } );
1252                 for (var i = 0; i < p_org.children().length; i++) {
1253                     obj.funcs.push(
1254                         function(o) {
1255                             return function() {
1256                                 obj.show_libs( o, false );
1257                             }
1258                         }( p_org.children()[i] )
1259                     );
1260                 }
1261                 obj.funcs.push( function() { 
1262                     document.getElementById('cmd_refresh_list').setAttribute('disabled','false'); 
1263                     document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false'); 
1264                     document.getElementById('lib_menu').setAttribute('disabled','false'); 
1265                 } );
1266             }
1267 */
1268         } catch(E) {
1269             alert(E);
1270         }
1271     },
1272
1273     'show_all_libs' : function() {
1274         var obj = this;
1275         try {
1276             obj.show_my_libs();
1277
1278             obj.show_libs( obj.data.tree.aou );
1279
1280             obj.funcs.push( function() { 
1281                 document.getElementById('cmd_refresh_list').setAttribute('disabled','true'); 
1282                 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true'); 
1283                 document.getElementById('lib_menu').setAttribute('disabled','true'); 
1284             } );
1285
1286             for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
1287                 var child = obj.data.tree.aou.children()[i];
1288                 if (obj.data.hash.aout[child.ou_type()].depth() <= obj.default_depth
1289                 && orgIsMine(obj.default_lib,child,obj.default_depth)) {
1290                     obj.funcs.push(
1291                         function(o) {
1292                             return function() {
1293                                 obj.show_libs( o );
1294                             }
1295                         }( child )
1296                     );
1297                 }
1298             }
1299             obj.funcs.push( function() { 
1300                 document.getElementById('cmd_refresh_list').setAttribute('disabled','false'); 
1301                 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false'); 
1302                 document.getElementById('lib_menu').setAttribute('disabled','false'); 
1303             } );
1304
1305         } catch(E) {
1306             alert(E);
1307         }
1308     },
1309
1310     'show_libs_with_copies' : function() {
1311         var obj = this;
1312         try {
1313             JSAN.use('util.functional');
1314
1315             var orgs = util.functional.map_list(
1316                 obj.org_ids,
1317                 function(id) { return obj.data.hash.aou[id]; }
1318             ).sort(
1319                 function( a, b ) {
1320                     if (a.shortname() < b.shortname()) return -1;
1321                     if (a.shortname() > b.shortname()) return 1;
1322                     return 0;
1323                 }
1324             );
1325             obj.funcs.push( function() { 
1326                 document.getElementById('cmd_refresh_list').setAttribute('disabled','true'); 
1327                 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true'); 
1328                 document.getElementById('lib_menu').setAttribute('disabled','true'); 
1329             } );
1330
1331             for (var i = 0; i < orgs.length; i++) {
1332                 obj.funcs.push(
1333                     function(o) {
1334                         return function() {
1335                             obj.show_libs(o,false);
1336                         }
1337                     }( orgs[i] )
1338                 );
1339             }
1340             obj.funcs.push( function() { 
1341                 document.getElementById('cmd_refresh_list').setAttribute('disabled','false'); 
1342                 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false'); 
1343                 document.getElementById('lib_menu').setAttribute('disabled','false'); 
1344             } );
1345
1346         } catch(E) {
1347             alert(E);
1348         }
1349     },
1350
1351     'show_libs' : function(start_aou,show_open) {
1352         var obj = this;
1353         try {
1354             if (!start_aou) throw('show_libs: Need a start_aou');
1355             JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1356             JSAN.use('util.functional'); 
1357
1358             var parents = [];
1359             var temp_aou = start_aou;
1360             while ( temp_aou.parent_ou() ) {
1361                 temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
1362                 parents.push( temp_aou );
1363             }
1364             parents.reverse();
1365
1366             for (var i = 0; i < parents.length; i++) {
1367                 obj.funcs.push(
1368                     function(o,p) {
1369                         return function() { 
1370                             obj.append_org(o,p,{'container':'true','open':'true'}); 
1371                         };
1372                     }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
1373                 );
1374             }
1375
1376             obj.funcs.push(
1377                 function(o,p) {
1378                     return function() { obj.append_org(o,p); };
1379                 }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
1380             );
1381
1382             obj.funcs.push(
1383                 function() {
1384                     if (start_aou.children()) {
1385                         var x = obj.map_tree[ 'aou_' + start_aou.id() ];
1386                         x.setAttribute('container','true');
1387                         if (show_open) x.setAttribute('open','true');
1388                         for (var i = 0; i < start_aou.children().length; i++) {
1389                             var child = start_aou.children()[i];
1390                             if (obj.data.hash.aout[child.ou_type()].depth() <= obj.default_depth
1391                             && orgIsMine(obj.default_lib,child,obj.default_depth)) {
1392                                 obj.funcs.push(
1393                                     function(o,p) {
1394                                         return function() { obj.append_org(o,p); };
1395                                     }( child, start_aou )
1396                                 );
1397                             }
1398                         }
1399                     }
1400                 }
1401             );
1402
1403         } catch(E) {
1404             alert(E);
1405         }
1406     },
1407
1408     'on_select' : function(list,twisty) {
1409         var obj = this;
1410         for (var i = 0; i < list.length; i++) {
1411             var node = obj.map_tree[ list[i] ];
1412             //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
1413             var row_type = list[i].split('_')[0];
1414             var id = list[i].split('_')[1];
1415             switch(row_type) {
1416                 case 'aou' : obj.on_select_org(id,twisty); break;
1417                 case 'acn' : obj.on_select_acn(id,twisty); break;
1418                 default: break;
1419             }
1420         }
1421     },
1422
1423     'on_select_acn' : function(acn_id,twisty) {
1424         var obj = this;
1425         try {
1426             var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
1427             obj.funcs.push( function() { 
1428                 document.getElementById('cmd_refresh_list').setAttribute('disabled','true'); 
1429                 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true'); 
1430                 document.getElementById('lib_menu').setAttribute('disabled','true'); 
1431             } );
1432             if (acn_tree.copies()) {
1433                 for (var i = 0; i < acn_tree.copies().length; i++) {
1434                     obj.funcs.push(
1435                         function(c,a) {
1436                             return function() {
1437                                 obj.append_acp(c,a);
1438                             }
1439                         }( acn_tree.copies()[i], acn_tree )
1440                     )
1441                 }
1442             }
1443             obj.funcs.push( function() { 
1444                 document.getElementById('cmd_refresh_list').setAttribute('disabled','false'); 
1445                 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false'); 
1446                 document.getElementById('lib_menu').setAttribute('disabled','false'); 
1447             } );
1448         } catch(E) {
1449             alert(E);
1450         }
1451     },
1452
1453     'on_select_org' : function(org_id,twisty) {
1454         var obj = this;
1455         try {
1456             var org = obj.data.hash.aou[ org_id ];
1457             obj.funcs.push( function() { 
1458                 document.getElementById('cmd_refresh_list').setAttribute('disabled','true'); 
1459                 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true'); 
1460                 document.getElementById('lib_menu').setAttribute('disabled','true'); 
1461             } );
1462             if (org.children()) {
1463                 for (var i = 0; i < org.children().length; i++) {
1464                     var child = org.children()[i];
1465                     if (obj.data.hash.aout[child.ou_type()].depth() <= obj.default_depth
1466                     && orgIsMine(obj.default_lib,child,obj.default_depth)) {
1467                         obj.funcs.push(
1468                             function(o,p) {
1469                                 return function() {
1470                                     obj.append_org(o,p)
1471                                 }
1472                             }(child,org)
1473                         );
1474                     }
1475                 }
1476             } 
1477             if (obj.map_acn[ 'aou_' + org_id ]) {
1478                 for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
1479                     obj.funcs.push(
1480                         function(o,a) {
1481                             return function() {
1482                                 obj.append_acn(o,a);
1483                             }
1484                         }( org, obj.map_acn[ 'aou_' + org_id ][i] )
1485                     );
1486                 }
1487             }
1488             obj.funcs.push( function() { 
1489                 document.getElementById('cmd_refresh_list').setAttribute('disabled','false'); 
1490                 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false'); 
1491                 document.getElementById('lib_menu').setAttribute('disabled','false'); 
1492             } );
1493         } catch(E) {
1494             alert('Error in copy_browser.js, on_select_org(): ' + E);
1495         }
1496     },
1497
1498     'append_org' : function (org,parent_org,params) {
1499         var obj = this;
1500         obj.error.consoleService.logStringMessage('append_org: org = ' + org.shortname() + ' parent_org = ' + (parent_org ? parent_org.shortname() : '') + ' params = ' + js2JSON(params) + '\n');
1501         try {
1502             if (obj.map_tree[ 'aou_' + org.id() ]) {
1503                 var x = obj.map_tree[ 'aou_' + org.id() ];
1504                 if (params) {
1505                     for (var i in params) {
1506                         x.setAttribute(i,params[i]);
1507                     }
1508                 }
1509                 return x;
1510             }
1511
1512             var data = {
1513                 'row' : {
1514                     'my' : {
1515                         'aou' : org,
1516                     }
1517                 },
1518                 'skip_all_columns_except' : [0,1,2],
1519                 'retrieve_id' : 'aou_' + org.id(),
1520                 'to_bottom' : true,
1521                 'no_auto_select' : true,
1522             };
1523         
1524             var acn_tree_list;
1525             if ( obj.org_ids.indexOf( Number( org.id() ) ) == -1 ) {
1526                 if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) {
1527                     data.row.my.volume_count = '0';
1528                     data.row.my.copy_count = '<0>';
1529                 } else {
1530                     data.row.my.volume_count = '';
1531                     data.row.my.copy_count = '';
1532                 }
1533             } else {
1534                 var v_count = 0; var c_count = 0;
1535                 acn_tree_list = obj.network.simple_request(
1536                     'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS.authoritative',
1537                     [ ses(), obj.docid, [ org.id() ] ]
1538                 );
1539                 for (var i = 0; i < acn_tree_list.length; i++) {
1540                     v_count++;
1541                     obj.map_acn[ 'acn_' + acn_tree_list[i].id() ] = function(r){return r;}(acn_tree_list[i]);
1542                     var copies = acn_tree_list[i].copies(); if (copies) c_count += copies.length;
1543                     for (var j = 0; j < copies.length; j++) {
1544                         obj.map_acp[ 'acp_' + copies[j].id() ] = function(r){return r;}(copies[j]);
1545                     }
1546                 }
1547                 data.row.my.volume_count = String(v_count);
1548                 data.row.my.copy_count = '<' + c_count + '>';
1549             }
1550             if (document.getElementById('hide_aous').checked) {
1551                 if (org.children().length == 0
1552                         && data.row.my.volume_count == '0') {
1553                     if (!params) {
1554                         params = { 'hidden' : true };
1555                     } else {
1556                         params['hidden'] = true;
1557                     }
1558                     dump('hiding org.id() = ' + org.id() + '\n');
1559                 }
1560             }
1561             if (parent_org) {
1562                 data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
1563             }
1564             var nparams = obj.list.append(data);
1565             obj.list.refresh_ordinals();
1566             var node = nparams.treeitem_node;
1567             if (params) {
1568                 for (var i in params) {
1569                     node.setAttribute(i,params[i]);
1570                 }
1571             }
1572             obj.map_tree[ 'aou_' + org.id() ] = node;
1573
1574             if (org.children()) {
1575                 node.setAttribute('container','true');
1576             }
1577
1578             if (parent_org) {
1579                 if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
1580                     data.node.setAttribute('open','true');
1581                 }
1582             } else {
1583                 obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
1584             }
1585
1586             if (acn_tree_list) {
1587                 obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
1588                 node.setAttribute('container','true');
1589             }
1590
1591             if (document.getElementById('show_acns').checked) {
1592                 node.setAttribute('open','true');
1593                 obj.funcs.push( function() { obj.on_select_org( org.id() ); } );
1594             }
1595
1596         } catch(E) {
1597             dump(E+'\n');
1598             alert(E);
1599         }
1600     },
1601
1602     'append_acn' : function( org, acn_tree, params ) {
1603         var obj = this;
1604         try {
1605             if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
1606                 var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
1607                 if (params) {
1608                     for (var i in params) {
1609                         x.setAttribute(i,params[i]);
1610                     }
1611                 }
1612                 return x;
1613             }
1614
1615             var parent_node = obj.map_tree[ 'aou_' + org.id() ];
1616             var data = {
1617                 'row' : {
1618                     'my' : {
1619                         'aou' : org,
1620                         'acn' : acn_tree,
1621                         'volume_count' : '',
1622                         'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
1623                     }
1624                 },
1625                 'skip_all_columns_except' : [0,1,2],
1626                 'retrieve_id' : 'acn_' + acn_tree.id(),
1627                 'node' : parent_node,
1628                 'to_bottom' : true,
1629                 'no_auto_select' : true,
1630             };
1631             var nparams = obj.list.append(data);
1632             obj.list.refresh_ordinals();
1633             var node = nparams.treeitem_node;
1634             obj.map_tree[ 'acn_' + acn_tree.id() ] =  node;
1635             if (params) {
1636                 for (var i in params) {
1637                     node.setAttribute(i,params[i]);
1638                 }
1639             }
1640             if (acn_tree.copies()) {
1641                 obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
1642                 node.setAttribute('container','true');
1643             }
1644             if (document.getElementById('show_acps').checked) {
1645                 node.setAttribute('open','true');
1646                 obj.funcs.push( function() { obj.on_select_acn( acn_tree.id() ); } );
1647             }
1648
1649         } catch(E) {
1650             dump(E+'\n');
1651             alert(E);
1652         }
1653     },
1654
1655     'append_acp' : function( acp_item, acn_tree, params ) {
1656         var obj = this;
1657         try {
1658             if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
1659                 var x = obj.map_tree[ 'acp_' + acp_item.id() ];
1660                 if (params) {
1661                     for (var i in params) {
1662                         x.setAttribute(i,params[i]);
1663                     }
1664                 }
1665                 return x;
1666             }
1667
1668             var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
1669             var data = {
1670                 'row' : {
1671                     'my' : {
1672                         'doc_id' : obj.docid,
1673                         'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
1674                         'acn' : acn_tree,
1675                         'acp' : acp_item,
1676                         'circ' :
1677                             acp_item.circulations() 
1678                             ? (
1679                                 acp_item.circulations().length > 0
1680                                 ? acp_item.circulations()[0]
1681                                 : null
1682                             ) 
1683                             : null,
1684                         'volume_count' : '',
1685                         'copy_count' : '',
1686                     }
1687                 },
1688                 'retrieve_id' : 'acp_' + acp_item.id(),
1689                 'node' : parent_node,
1690                 'to_bottom' : true,
1691                 'no_auto_select' : true,
1692             };
1693             var nparams = obj.list.append(data);
1694             obj.list.refresh_ordinals();
1695             var node = nparams.treeitem_node;
1696             obj.map_tree[ 'acp_' + acp_item.id() ] =  node;
1697             if (params) {
1698                 for (var i in params) {
1699                     node.setAttribute(i,params[i]);
1700                 }
1701             }
1702
1703         } catch(E) {
1704             dump(E+'\n');
1705             alert(E);
1706         }
1707     },
1708
1709     'list_init' : function( params ) {
1710
1711         try {
1712             var obj = this;
1713             
1714             JSAN.use('circ.util');
1715             var columns = [
1716                 {
1717                     'id' : 'tree_location',
1718                     'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.tree_location'),
1719                     'flex' : 1, 'primary' : true, 'hidden' : false, 
1720                     'render' : function(my) { return my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"; },
1721                 },
1722                 {
1723                     'id' : 'volume_count',
1724                     'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.volume_count'),
1725                     'flex' : 0, 'primary' : false, 'hidden' : false, 
1726                     'render' : function(my) { return my.volume_count; },
1727                 },
1728                 {
1729                     'id' : 'copy_count',
1730                     'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.copy_count'),
1731                     'flex' : 0,
1732                     'primary' : false, 'hidden' : false, 
1733                     'render' : function(my) { return my.copy_count; },
1734                 },
1735             ].concat(
1736                 circ.util.columns( 
1737                     { 
1738                         'location' : { 'hidden' : false },
1739                         'circ_lib' : { 'hidden' : false },
1740                         'owning_lib' : { 'hidden' : false },
1741                         'call_number' : { 'hidden' : false },
1742                         'parts' : { 'hidden' : false },
1743                         'due_date' : { 'hidden' : false },
1744                         'acp_status' : { 'hidden' : false },
1745                     },
1746                     {
1747                         'just_these' : [
1748                             'due_date',
1749                             'owning_lib',
1750                             'circ_lib',
1751                             'label_class',
1752                             'prefix',
1753                             'call_number',
1754                             'suffix',
1755                             'copy_number',
1756                             'parts',
1757                             'location',
1758                             'barcode',
1759                             'loan_duration',
1760                             'fine_level',
1761                             'circulate',
1762                             'holdable',
1763                             'opac_visible',
1764                             'ref',
1765                             'deposit',
1766                             'deposit_amount',
1767                             'price',
1768                             'circ_as_type',
1769                             'circ_modifier',
1770                             'acp_status',
1771                             'alert_message',
1772                             'acp_mint_condition',
1773                             'acp_id'
1774                         ]
1775                     }
1776                 )
1777             );
1778             JSAN.use('util.list'); obj.list = new util.list('copy_tree');
1779             obj.list.init(
1780                 {
1781                     'no_auto_select' : true,
1782                     'columns' : columns,
1783                     'retrieve_row' : function(params) {
1784
1785                         var row = params.row;
1786
1787                     /*    
1788                         if (!row.my.mvr) obj.funcs.push(
1789                             function() {
1790
1791                                 row.my.mvr = obj.network.request(
1792                                     api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
1793                                     api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
1794                                     [ row.my.circ.target_copy() ]
1795                                 );
1796
1797                             }
1798                         );
1799                         if (!row.my.acp) {
1800                             obj.funcs.push(    
1801                                 function() {
1802
1803                                     row.my.acp = obj.network.request(
1804                                         api.FM_ACP_RETRIEVE.app,
1805                                         api.FM_ACP_RETRIEVE.method,
1806                                         [ row.my.circ.target_copy() ]
1807                                     );
1808
1809                                     params.treeitem_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1810
1811                                 }
1812                             );
1813                         } else {
1814                             params.treeitem_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1815                         }
1816                     */
1817                         obj.funcs.push(
1818                             function() {
1819
1820                                 if (typeof params.on_retrieve == 'function') {
1821                                     params.on_retrieve(row);
1822                                 }
1823                                 obj.list.refresh_ordinals();
1824
1825                             }
1826                         );
1827
1828                         return row;
1829                     },
1830                     'on_click' : function(ev) {
1831                         var row = {}; var col = {}; var nobj = {};
1832                         obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj); 
1833                         if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
1834                         var node = obj.list.node.contentView.getItemAtIndex(row.value);
1835                         var list = [ node.getAttribute('retrieve_id') ];
1836                         if (typeof obj.on_select == 'function') {
1837                             obj.on_select(list,true);
1838                         }
1839                         if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1840                             window.xulG.on_select(list);
1841                         }
1842                         obj.list.refresh_ordinals();
1843                     },
1844                     'on_dblclick' : function(ev) {
1845                         JSAN.use('util.functional');
1846                         JSAN.use('util.widgets');
1847                         var sel = obj.list.retrieve_selection();
1848                         obj.controller.view.sel_clip.disabled = sel.length < 1;
1849                         obj.sel_list = util.functional.map_list(
1850                             sel,
1851                             function(o) { return o.getAttribute('retrieve_id'); }
1852                         );
1853                         obj.toggle_actions();
1854                         util.widgets.dispatch('command','cmd_edit_items');
1855                         obj.list.refresh_ordinals();
1856                     },
1857                     'on_select' : function(ev) {
1858                         JSAN.use('util.functional');
1859                         var sel = obj.list.retrieve_selection();
1860                         obj.controller.view.sel_clip.disabled = sel.length < 1;
1861                         obj.sel_list = util.functional.map_list(
1862                             sel,
1863                             function(o) { return o.getAttribute('retrieve_id'); }
1864                         );
1865                         obj.toggle_actions();
1866                         if (typeof obj.on_select == 'function') {
1867                             obj.on_select(obj.sel_list);
1868                         }
1869                         if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1870                             window.xulG.on_select(obj.sel_list);
1871                         }
1872                         obj.list.refresh_ordinals();
1873                     },
1874                 }
1875             );
1876
1877             $('list_actions').appendChild( obj.list.render_list_actions() );
1878             obj.list.set_list_actions();
1879
1880         } catch(E) {
1881             this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
1882             alert(E);
1883         }
1884     },
1885
1886     // Sets can_have_copies and source member variables.
1887     'source_init' : function() {
1888         var obj = this;
1889         try {
1890             JSAN.use('cat.util');
1891             var cbsObj = cat.util.get_cbs_for_bre_id(obj.docid);
1892             if(cbsObj) {
1893                 obj.can_have_copies = (cbsObj.can_have_copies() == get_db_true());
1894                 obj.source = cbsObj.source();
1895             } else {
1896                 obj.can_have_copies = true;
1897             }
1898         } catch(E) {
1899             obj.error.sdump('D_ERROR','can have copies check: ' + E);
1900             alert(E);
1901         }
1902     },
1903
1904     'toggle_actions' : function() {
1905         var obj = this;
1906         try {
1907             var found_aou = false; var found_acn = false; var found_acp = false;
1908             var found_aou_with_can_have_vols = false;
1909             var sel_copy_libs = {};
1910             for (var i = 0; i < obj.sel_list.length; i++) {
1911                 var type = obj.sel_list[i].split(/_/)[0];
1912                 switch(type) {
1913                     case 'aou' : 
1914                         found_aou = true; 
1915                         var org = obj.data.hash.aou[ obj.sel_list[i].split(/_/)[1] ];
1916                         if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) found_aou_with_can_have_vols = true;
1917                     break;
1918                     case 'acn' : found_acn = true; break;
1919                     case 'acp' :
1920                         found_acp = true;
1921                         sel_copy_libs[
1922                             obj.map_acn[
1923                                 "acn_" +
1924                                 obj.map_acp[obj.sel_list[i]].call_number()
1925                             ].owning_lib()
1926                         ] = true;
1927                         break;
1928                 }
1929             }
1930             obj.controller.view.cmd_add_items.setAttribute('disabled','true');
1931             obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','true');
1932             obj.controller.view.cmd_edit_items.setAttribute('disabled','true');
1933             obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
1934             obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
1935             obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','true');
1936             obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
1937             obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
1938             obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
1939             obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
1940             obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
1941             obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true');
1942             obj.controller.view.cmd_transfer_items.setAttribute('disabled','true');
1943             obj.controller.view.sel_copy_details.setAttribute('disabled','true');
1944             obj.controller.view.cmd_create_brt.setAttribute('disabled','true');
1945             obj.controller.view.cmd_book_item_now.setAttribute('disabled','true');
1946             obj.controller.view.sel_patron.setAttribute('disabled','true');
1947             obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
1948             obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
1949             if (found_aou && found_aou_with_can_have_vols) {
1950                 obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
1951                 obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
1952             }
1953             if (found_acn) {
1954                 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
1955                 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
1956                 obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
1957                 obj.controller.view.cmd_add_items.setAttribute('disabled','false');
1958                 obj.controller.view.cmd_transfer_volume.setAttribute('disabled','false');
1959             }
1960             if (found_acp) {
1961                 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
1962                 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
1963                 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','false');
1964                 obj.controller.view.cmd_edit_items.setAttribute('disabled','false');
1965                 obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
1966                 obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
1967                 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false');
1968                 obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
1969                 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
1970                 obj.controller.view.cmd_create_brt.setAttribute('disabled','false');
1971                 obj.controller.view.sel_patron.setAttribute('disabled','false');
1972
1973                 var L = 0; for (var k in sel_copy_libs) L++;
1974                 if (L < 2) {
1975                     obj.controller.view.cmd_book_item_now.setAttribute('disabled','false');
1976                 }
1977             }
1978         } catch(E) {
1979             obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.actions.error'),E);
1980         }
1981     },
1982
1983     'refresh_list' : function() { 
1984         try {
1985             var obj = this;
1986             obj.list.clear();
1987             obj.map_tree = {};
1988             obj.map_acn = {};
1989             obj.map_acp = {};
1990             obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
1991             if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
1992             JSAN.use('util.functional'); 
1993             obj.org_ids = util.functional.map_list( obj.org_ids, function (o) { return Number(o); });
1994             obj.show_my_libs( obj.default_lib.id() );
1995             // FIXME - we get a null from the copy_count call if we call it too quickly here
1996             setTimeout(
1997                 function() {
1998                     obj.show_consortial_count();
1999                     if (typeof xulG.reload_opac == 'function') {
2000                         xulG.reload_opac();
2001                     }
2002                 }, 2000
2003             );
2004         } catch(E) {
2005             this.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.refresh_list.error'),E);
2006         }
2007     },
2008 }
2009
2010 dump('exiting cat.copy_browser.js\n');