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