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