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