]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/copy_browser.js
column persistence in other interfaces
[Evergreen.git] / Open-ILS / xul / staff_client / server / cat / copy_browser.js
1 dump('entering cat.copy_browser.js\n');
2
3 if (typeof cat == 'undefined') cat = {};
4 cat.copy_browser = function (params) {
5         try {
6                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7                 JSAN.use('util.error'); this.error = new util.error();
8         } catch(E) {
9                 dump('cat.copy_browser: ' + E + '\n');
10         }
11 }
12
13 cat.copy_browser.prototype = {
14
15         'map_tree' : {},
16         'map_acn' : {},
17         'map_acp' : {},
18         'sel_list' : [],
19
20         'init' : function( params ) {
21
22                 try {
23                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
24                         var obj = this;
25
26                         obj.docid = params.docid;
27
28                         JSAN.use('util.network'); obj.network = new util.network();
29                         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
30                         JSAN.use('util.controller'); obj.controller = new util.controller();
31                         obj.controller.init(
32                                 {
33                                         control_map : {
34                                                 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
35                                                 'sel_clip' : [
36                                                         ['command'],
37                                                         function() { obj.list.clipboard(); }
38                                                 ],
39                                                 'cmd_broken' : [
40                                                         ['command'],
41                                                         function() { alert('Not Yet Implemented'); }
42                                                 ],
43                                                 'cmd_show_my_libs' : [
44                                                         ['command'],
45                                                         function() { 
46                                                                 obj.show_my_libs(); 
47                                                         }
48                                                 ],
49                                                 'cmd_show_all_libs' : [
50                                                         ['command'],
51                                                         function() {
52                                                                 obj.show_all_libs();
53                                                         }
54                                                 ],
55                                                 'cmd_show_libs_with_copies' : [
56                                                         ['command'],
57                                                         function() {
58                                                                 obj.show_libs_with_copies();
59                                                         }
60                                                 ],
61                                                 'cmd_clear' : [
62                                                         ['command'],
63                                                         function() {
64                                                                 obj.map_tree = {};
65                                                                 obj.list.clear();
66                                                         }
67                                                 ],
68                                                 'sel_patron' : [
69                                                         ['command'],
70                                                         function() {
71                                                                 JSAN.use('util.functional');
72
73                                                                 var list = util.functional.filter_list(
74                                                                         obj.sel_list,
75                                                                         function (o) {
76                                                                                 return o.split(/_/)[0] == 'acp';
77                                                                         }
78                                                                 );
79
80                                                                 list = util.functional.map_list(
81                                                                         list,
82                                                                         function (o) {
83                                                                                 return { 'copy_id' : o.split(/_/)[1] };
84                                                                         }
85                                                                 );
86                                                                 
87                                                                 JSAN.use('circ.util');
88                                                                 circ.util.show_last_few_circs(list);
89                                                         }
90                                                 ],
91                                                 'sel_copy_details' : [
92                                                         ['command'],
93                                                         function() {
94                                                                 JSAN.use('util.functional');
95
96                                                                 var list = util.functional.filter_list(
97                                                                         obj.sel_list,
98                                                                         function (o) {
99                                                                                 return o.split(/_/)[0] == 'acp';
100                                                                         }
101                                                                 );
102
103                                                                 list = util.functional.map_list(
104                                                                         list,
105                                                                         function (o) {
106                                                                                 return o.split(/_/)[1];
107                                                                         }
108                                                                 );
109         
110                                                                 JSAN.use('circ.util');
111                                                                 for (var i = 0; i < list.length; i++) {
112                                                                         circ.util.show_copy_details( list[i] );
113                                                                 }
114                                                         }
115                                                 ],
116                                                 'cmd_add_items' : [
117                                                         ['command'],
118                                                         function() {
119                                                                 try {
120                                                                         JSAN.use('util.functional');
121                                                                         var list = util.functional.map_list(
122                                                                                 util.functional.filter_list(
123                                                                                         obj.sel_list,
124                                                                                         function (o) {
125                                                                                                 return o.split(/_/)[0] == 'acn';
126                                                                                         }
127                                                                                 ),
128                                                                                 function (o) {
129                                                                                         return o.split(/_/)[1];
130                                                                                 }
131                                                                         );
132                                                                         if (list.length == 0) return;
133
134                                                                         var copy_shortcut = {};
135                                                                         list = util.functional.map_list(
136                                                                                 list,
137                                                                                 function (o) {
138                                                                                         var ou_id = obj.map_acn['acn_' + o].owning_lib();
139                                                                                         var volume_id = o;
140                                                                                         var label = obj.map_acn['acn_' + o].label();
141                                                                                         if (!copy_shortcut[ou_id]) copy_shortcut[ou_id] = {};
142                                                                                         copy_shortcut[ou_id][ label ] = volume_id;
143
144                                                                                         return ou_id;
145                                                                                 }
146                                                                         );
147                                                                         /* quick fix */  /* what was this fixing? */
148                                                                         list = []; for (var i in copy_shortcut) { list.push( i ); }
149
150                                                                         var edit = 0;
151                                                                         try {
152                                                                                 edit = obj.network.request(
153                                                                                         api.PERM_MULTI_ORG_CHECK.app,
154                                                                                         api.PERM_MULTI_ORG_CHECK.method,
155                                                                                         [ 
156                                                                                                 ses(), 
157                                                                                                 obj.data.list.au[0].id(), 
158                                                                                                 list,
159                                                                                                 [ 'CREATE_COPY' ]
160                                                                                         ]
161                                                                                 ).length == 0 ? 1 : 0;
162                                                                         } catch(E) {
163                                                                                 obj.error.sdump('D_ERROR','batch permission check: ' + E);
164                                                                         }
165
166                                                                         if (edit==0) return; // no read-only view for this interface
167
168                                                                         var title = 'Add Item';
169
170                                                                         JSAN.use('util.window'); var win = new util.window();
171                                                                         var w = win.open(
172                                                                                 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR)
173                                                                                         +'?doc_id=' + window.escape(obj.docid)
174                                                                                         +'&ou_ids=' + window.escape( js2JSON(list) )
175                                                                                         +'&copy_shortcut=' + window.escape( js2JSON(copy_shortcut) ),
176                                                                                 title,
177                                                                                 'chrome,modal,resizable'
178                                                                         );
179                                                                         obj.refresh_list();
180                                                                 } catch(E) {
181                                                                         obj.error.standard_unexpected_error_alert('copy browser -> add copies',E);
182                                                                 }
183                                                         }
184                                                 ],
185                                                 'cmd_add_items_to_buckets' : [
186                                                         ['command'],
187                                                         function() {
188                                                                 try {
189                                                                         JSAN.use('util.functional');
190
191                                                                         var list = util.functional.filter_list(
192                                                                                 obj.sel_list,
193                                                                                 function (o) {
194                                                                                         return o.split(/_/)[0] == 'acp';
195                                                                                 }
196                                                                         );
197
198                                                                         list = util.functional.map_list(
199                                                                                 list,
200                                                                                 function (o) {
201                                                                                         return o.split(/_/)[1];
202                                                                                 }
203                                                                         );
204                                                                 
205                                                                         JSAN.use('cat.util');
206                                                                         cat.util.add_copies_to_bucket( list );
207
208                                                                 } catch(E) {
209                                                                         obj.error.standard_unexpected_error_alert('copy browser -> add copies to bucket',E);
210                                                                 }
211                                                         }
212                                                 ],
213                                                 'cmd_edit_items' : [
214                                                         ['command'],
215                                                         function() {
216                                                                 try {
217                                                                         JSAN.use('util.functional');
218
219                                                                         var list = util.functional.filter_list(
220                                                                                 obj.sel_list,
221                                                                                 function (o) {
222                                                                                         return o.split(/_/)[0] == 'acp';
223                                                                                 }
224                                                                         );
225
226                                                                         list = util.functional.map_list(
227                                                                                 list,
228                                                                                 function (o) {
229                                                                                         return o.split(/_/)[1];
230                                                                                 }
231                                                                         );
232
233                                                                         var edit = 0;
234                                                                         try {
235                                                                                 edit = obj.network.request(
236                                                                                         api.PERM_MULTI_ORG_CHECK.app,
237                                                                                         api.PERM_MULTI_ORG_CHECK.method,
238                                                                                         [ 
239                                                                                                 ses(), 
240                                                                                                 obj.data.list.au[0].id(), 
241                                                                                                 util.functional.map_list(
242                                                                                                         list,
243                                                                                                         function (o) {
244                                                                                                                 return obj.map_acn[ 'acn_' + obj.map_acp[ 'acp_' + o ].call_number() ].owning_lib();
245                                                                                                         }
246                                                                                                 ),
247                                                                                                 [ 'UPDATE_COPY', 'UPDATE_BATCH_COPY' ]
248                                                                                         ]
249                                                                                 ).length == 0 ? 1 : 0;
250                                                                         } catch(E) {
251                                                                                 obj.error.sdump('D_ERROR','batch permission check: ' + E);
252                                                                         }
253
254                                                                         JSAN.use('cat.util'); cat.util.spawn_copy_editor(list,edit);
255
256                                                                 } catch(E) {
257                                                                         obj.error.standard_unexpected_error_alert('Copy Browser -> Edit Items',E);
258                                                                 }
259                                                         }
260                                                 ],
261                                                 'cmd_delete_items' : [
262                                                         ['command'],
263                                                         function() {
264                                                                 try {
265                                                                         JSAN.use('util.functional');
266
267                                                                         var list = util.functional.filter_list(
268                                                                                 obj.sel_list,
269                                                                                 function (o) {
270                                                                                         return o.split(/_/)[0] == 'acp';
271                                                                                 }
272                                                                         );
273
274                                                                         list = util.functional.map_list(
275                                                                                 list,
276                                                                                 function (o) {
277                                                                                         return JSON2js( js2JSON( obj.map_acp[ 'acp_' + o.split(/_/)[1] ] ) );
278                                                                                 }
279                                                                         );
280
281                                                                         var r = obj.error.yns_alert('Are you sure you would like to delete ' + (list.length != 1 ? 'these ' + list.length + ' items' : 'this one item') + '?', 'Delete Items?', 'Delete', 'Cancel', null, 'Check here to confirm this action');
282
283                                                                         if (r == 0) {
284                                                                                 var acn_hash = {}; var acn_list = [];
285                                                                                 for (var i = 0; i < list.length; i++) {
286                                                                                         list[i].isdeleted('1');
287                                                                                         var acn_id = list[i].call_number();
288                                                                                         if ( ! acn_hash[ acn_id ] ) {
289                                                                                                 acn_hash[ acn_id ] = obj.map_acn[ 'acn_' + acn_id ];
290                                                                                                 acn_hash[ acn_id ].copies( [] );
291                                                                                         }
292                                                                                         var temp = acn_hash[ acn_id ].copies();
293                                                                                         temp.push( list[i] );
294                                                                                         acn_hash[ acn_id ].copies( temp );
295                                                                                 }
296                                                                                 for (var i in acn_hash) acn_list.push( acn_hash[i] );
297                                                                                 var robj = obj.network.simple_request(
298                                                                                         'FM_ACN_TREE_UPDATE', 
299                                                                                         [ ses(), acn_list, true ],
300                                                                                         null,
301                                                                                         {
302                                                                                                 'title' : 'Override Delete Failure?',
303                                                                                                 'overridable_events' : [
304                                                                                                         1208 /* TITLE_LAST_COPY */
305                                                                                                 ]
306                                                                                         }
307                                                                                 );
308                                                                                 if (robj == null) throw(robj);
309                                                                                 if (typeof robj.ilsevent != 'undefined') {
310                                                                                         if ( (robj.ilsevent != 0) && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */) ) throw(robj);
311                                                                                 }
312                                                                                 obj.refresh_list();
313                                                                         }
314
315                                                                         
316                                                                 } catch(E) {
317                                                                         obj.error.standard_unexpected_error_alert('copy browser -> delete items',E);
318                                                                         obj.refresh_list();
319                                                                 }
320                                                         }
321                                                 ],
322                                                 'cmd_print_spine_labels' : [
323                                                         ['command'],
324                                                         function() {
325                                                                 try {
326                                                                         JSAN.use('util.functional');
327                                                                         
328                                                                         var list = util.functional.filter_list(
329                                                                                 obj.sel_list,
330                                                                                 function (o) {
331                                                                                         return o.split(/_/)[0] == 'acp';
332                                                                                 }
333                                                                         );
334
335                                                                         list = util.functional.map_list(
336                                                                                 list,
337                                                                                 function (o) {
338                                                                                         return obj.map_acp[ o ];
339                                                                                 }
340                                                                         );
341
342                                                                         xulG.new_tab(
343                                                                                 xulG.url_prefix( urls.XUL_SPINE_LABEL ) + '?barcodes=' 
344                                                                                 + js2JSON( 
345                                                                                         util.functional.map_list(
346                                                                                                 list,
347                                                                                                 function(o){return o.barcode();}
348                                                                                         ) 
349                                                                                 ),
350                                                                                 { 'tab_name' : 'Spine Labels' },
351                                                                                 {}
352                                                                         );
353                                                                 } catch(E) {
354                                                                         obj.error.standard_unexpected_error_alert('copy browser -> Spine Labels',E);
355                                                                 }
356                                                         }
357                                                 ],
358                                                 'cmd_add_volumes' : [
359                                                         ['command'],
360                                                         function() {
361                                                                 try {
362                                                                         JSAN.use('util.functional');
363                                                                         var list = util.functional.filter_list(
364                                                                                 obj.sel_list,
365                                                                                 function (o) {
366                                                                                         return o.split(/_/)[0] == 'aou';
367                                                                                 }
368                                                                         );
369                                                                         list = util.functional.map_list(
370                                                                                 list,
371                                                                                 function (o) {
372                                                                                         return o.split(/_/)[1];
373                                                                                 }
374                                                                         );              
375                                                                         var edit = 0;
376                                                                         try {
377                                                                                 edit = obj.network.request(
378                                                                                         api.PERM_MULTI_ORG_CHECK.app,
379                                                                                         api.PERM_MULTI_ORG_CHECK.method,
380                                                                                         [ 
381                                                                                                 ses(), 
382                                                                                                 obj.data.list.au[0].id(), 
383                                                                                                 list,
384                                                                                                 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
385                                                                                         ]
386                                                                                 ).length == 0 ? 1 : 0;
387                                                                         } catch(E) {
388                                                                                 obj.error.sdump('D_ERROR','batch permission check: ' + E);
389                                                                         }
390
391                                                                         if (edit==0) {
392                                                                                 alert("You don't have permission to add volumes to that library.");
393                                                                                 return; // no read-only view for this interface
394                                                                         }
395
396                                                                         var title = 'Add Volume/Item';
397
398                                                                         JSAN.use('util.window'); var win = new util.window();
399                                                                         var w = win.open(
400                                                                                 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR)
401                                                                                         +'?doc_id=' + window.escape(obj.docid)
402                                                                                         +'&ou_ids=' + window.escape( js2JSON(list) ),
403                                                                                 title,
404                                                                                 'chrome,modal,resizable'
405                                                                         );
406
407                                                                         obj.refresh_list();
408                                                                 } catch(E) {
409                                                                         obj.error.standard_unexpected_error_alert('copy browser -> add volumes',E);
410                                                                 }
411                                                         }
412                                                 ],
413                                                 'cmd_edit_volumes' : [
414                                                         ['command'],
415                                                         function() {
416                                                                 try {
417                                                                         JSAN.use('util.functional');
418                                                                         var list = util.functional.map_list(
419                                                                                 util.functional.filter_list(
420                                                                                         obj.sel_list,
421                                                                                         function (o) {
422                                                                                                 return o.split(/_/)[0] == 'acn';
423                                                                                         }
424                                                                                 ),
425                                                                                 function (o) {
426                                                                                         return o.split(/_/)[1];
427                                                                                 }
428                                                                         );
429                                                                         if (list.length == 0) return;
430
431                                                                         var edit = 0;
432                                                                         try {
433                                                                                 edit = obj.network.request(
434                                                                                         api.PERM_MULTI_ORG_CHECK.app,
435                                                                                         api.PERM_MULTI_ORG_CHECK.method,
436                                                                                         [ 
437                                                                                                 ses(), 
438                                                                                                 obj.data.list.au[0].id(), 
439                                                                                                 util.functional.map_list(
440                                                                                                         list,
441                                                                                                         function (o) {
442                                                                                                                 return obj.map_acn[ 'acn_' + o ].owning_lib();
443                                                                                                         }
444                                                                                                 ),
445                                                                                                 [ 'UPDATE_VOLUME' ]
446                                                                                         ]
447                                                                                 ).length == 0 ? 1 : 0;
448                                                                         } catch(E) {
449                                                                                 obj.error.sdump('D_ERROR','batch permission check: ' + E);
450                                                                         }
451
452                                                                         if (edit==0) {
453                                                                                 alert("You don't have permission to edit this volume.");
454                                                                                 return; // no read-only view for this interface
455                                                                         }
456
457                                                                         list = util.functional.map_list(
458                                                                                 list,
459                                                                                 function (o) {
460                                                                                         var my_acn = obj.map_acn['acn_' + o];
461                                                                                         return function(r){return r;}(my_acn);
462                                                                                 }
463                                                                         );
464
465                                                                         var title = list.length == 1 ? 'Volume' : 'Volumes';
466
467                                                                         JSAN.use('util.window'); var win = new util.window();
468                                                                         obj.data.volumes_temp = js2JSON( list );
469                                                                         obj.data.stash('volumes_temp');
470                                                                         var w = win.open(
471                                                                                 window.xulG.url_prefix(urls.XUL_VOLUME_EDITOR),
472                                                                                 title,
473                                                                                 'chrome,modal,resizable'
474                                                                         );
475
476                                                                         /* FIXME -- need to unique the temp space, and not rely on modalness of window */
477                                                                         obj.data.stash_retrieve();
478                                                                         var volumes = JSON2js( obj.data.volumes_temp );
479                                                                         obj.error.sdump('D_CAT','in browse, obj.data.temp =\n' + obj.data.temp);
480                                                                         if (volumes=='') return;
481                                                                 
482                                                                         volumes = util.functional.filter_list(
483                                                                                 volumes,
484                                                                                 function (o) {
485                                                                                         return o.ischanged() == '1';
486                                                                                 }
487                                                                         );
488
489                                                                         volumes = util.functional.map_list(
490                                                                                 volumes,
491                                                                                 function (o) {
492                                                                                         o.record( obj.docid ); // staff client 2 did not do this.  Does it matter?
493                                                                                         return o;
494                                                                                 }
495                                                                         );
496
497                                                                         if (volumes.length == 0) return;
498
499                                                                         try {
500                                                                                 var r = obj.network.request(
501                                                                                         api.FM_ACN_TREE_UPDATE.app,
502                                                                                         api.FM_ACN_TREE_UPDATE.method,
503                                                                                         [ ses(), volumes, true ]
504                                                                                 );
505                                                                                 if (typeof r.ilsevent != 'undefined') throw(r);
506                                                                         } catch(E) {
507                                                                                 obj.error.standard_unexpected_error_alert('volume update error: ',E);
508                                                                         }
509                                                                         obj.refresh_list();
510
511                                                                 } catch(E) {
512                                                                         obj.error.standard_unexpected_error_alert('Copy Browser -> Volume Edit',E);
513                                                                 }
514                                                         }
515                                                 ],
516                                                 'cmd_delete_volumes' : [
517                                                         ['command'],
518                                                         function() {
519                                                                 try {
520                                                                         JSAN.use('util.functional');
521
522                                                                         var list = util.functional.filter_list(
523                                                                                 obj.sel_list,
524                                                                                 function (o) {
525                                                                                         return o.split(/_/)[0] == 'acn';
526                                                                                 }
527                                                                         );
528
529                                                                         list = util.functional.map_list(
530                                                                                 list,
531                                                                                 function (o) {
532                                                                                         return JSON2js( js2JSON( obj.map_acn[ 'acn_' + o.split(/_/)[1] ] ) );
533                                                                                 }
534                                                                         );
535
536                                                                         var r = obj.error.yns_alert('Are you sure you would like to delete ' + (list.length != 1 ? 'these ' + list.length + ' volumes' : 'this one volume') + '?', 'Delete Volumes?', 'Delete', 'Cancel', null, 'Check here to confirm this action');
537
538                                                                         if (r == 0) {
539                                                                                 for (var i = 0; i < list.length; i++) {
540                                                                                         list[i].isdeleted('1');
541                                                                                 }
542                                                                                 var robj = obj.network.simple_request(
543                                                                                         'FM_ACN_TREE_UPDATE', 
544                                                                                         [ ses(), list, true ],
545                                                                                         null,
546                                                                                         {
547                                                                                                 'title' : 'Override Delete Failure?',
548                                                                                                 'overridable_events' : [
549                                                                                                 ]
550                                                                                         }
551                                                                                 );
552                                                                                 if (robj == null) throw(robj);
553                                                                                 if (typeof robj.ilsevent != 'undefined') {
554                                                                                         if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
555                                                                                                 alert('You must delete all the copies on the volume before you may delete the volume itself.');
556                                                                                                 return;
557                                                                                         }
558                                                                                         if (robj.ilsevent != 0) throw(robj);
559                                                                                 }
560                                                                                 obj.refresh_list();
561                                                                         }
562                                                                 } catch(E) {
563                                                                         obj.error.standard_unexpected_error_alert('copy browser -> delete volumes',E);
564                                                                         obj.refresh_list();
565                                                                 }
566
567                                                         }
568                                                 ],
569                                                 'cmd_mark_library' : [
570                                                         ['command'],
571                                                         function() {
572                                                                 try {
573                                                                         var list = util.functional.filter_list(
574                                                                                 obj.sel_list,
575                                                                                 function (o) {
576                                                                                         return o.split(/_/)[0] == 'aou';
577                                                                                 }
578                                                                         );
579
580                                                                         list = util.functional.map_list(
581                                                                                 list,
582                                                                                 function (o) {
583                                                                                         return o.split(/_/)[1];
584                                                                                 }
585                                                                         );
586
587                                                                         if (list.length == 1) {
588                                                                                 obj.data.marked_library = { 'lib' : list[0], 'docid' : obj.docid };
589                                                                                 obj.data.stash('marked_library');
590                                                                                 alert('Library + Record marked as Volume Transfer Destination');
591                                                                         } else {
592                                                                                 obj.error.yns_alert('Choose just one Library to mark as Volume Transfer Destination','Limit Selection','OK',null,null,'Check here to confirm this dialog');
593                                                                         }
594                                                                 } catch(E) {
595                                                                         obj.error.standard_unexpected_error_alert('copy browser -> mark library',E);
596                                                                 }
597                                                         }
598                                                 ],
599
600                                                 'cmd_mark_volume' : [
601                                                         ['command'],
602                                                         function() {
603                                                                 try {
604                                                                         var list = util.functional.filter_list(
605                                                                                 obj.sel_list,
606                                                                                 function (o) {
607                                                                                         return o.split(/_/)[0] == 'acn';
608                                                                                 }
609                                                                         );
610
611                                                                         list = util.functional.map_list(
612                                                                                 list,
613                                                                                 function (o) {
614                                                                                         return o.split(/_/)[1];
615                                                                                 }
616                                                                         );
617
618                                                                         if (list.length == 1) {
619                                                                                 obj.data.marked_volume = list[0];
620                                                                                 obj.data.stash('marked_volume');
621                                                                                 alert('Volume marked as Item Transfer Destination');
622                                                                         } else {
623                                                                                 obj.error.yns_alert('Choose just one Volume to mark as Item Transfer Destination','Limit Selection','OK',null,null,'Check here to confirm this dialog');
624                                                                         }
625                                                                 } catch(E) {
626                                                                         obj.error.standard_unexpected_error_alert('copy browser -> mark volume',E);
627                                                                 }
628                                                         }
629                                                 ],
630                                                 'cmd_refresh_list' : [
631                                                         ['command'],
632                                                         function() {
633                                                                 obj.refresh_list();
634                                                         }
635                                                 ],
636                                                 'cmd_transfer_volume' : [
637                                                         ['command'],
638                                                         function() {
639                                                                 try {
640                                                                         obj.data.stash_retrieve();
641                                                                         if (!obj.data.marked_library) {
642                                                                                 alert('Please mark a library as the destination from within holdings maintenance and then try this again.');
643                                                                                 return;
644                                                                         }
645                                                                         
646                                                                         JSAN.use('util.functional');
647
648                                                                         var list = util.functional.filter_list(
649                                                                                 obj.sel_list,
650                                                                                 function (o) {
651                                                                                         return o.split(/_/)[0] == 'acn';
652                                                                                 }
653                                                                         );
654
655                                                                         list = util.functional.map_list(
656                                                                                 list,
657                                                                                 function (o) {
658                                                                                         return o.split(/_/)[1];
659                                                                                 }
660                                                                         );
661
662                                                                         netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
663                                                                         var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
664                                                                         xml += '<description>Transfer volumes ';
665
666                                                                         xml += util.functional.map_list(
667                                                                                 list,
668                                                                                 function (o) {
669                                                                                         return obj.map_acn[ 'acn_' + o ].label();
670                                                                                 }
671                                                                         ).join(", ");
672
673                                                                         xml += ' to library ' + obj.data.hash.aou[ obj.data.marked_library.lib ].shortname();
674                                                                         xml += ' on the following record?</description>';
675                                                                         xml += '<hbox><button label="Transfer" name="fancy_submit"/>';
676                                                                         xml += '<button label="Cancel" accesskey="C" name="fancy_cancel"/></hbox>';
677                                                                         xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '"/>';
678                                                                         xml += '</vbox>';
679                                                                         obj.data.temp_transfer = xml; obj.data.stash('temp_transfer');
680                                                                         window.open(
681                                                                                 urls.XUL_FANCY_PROMPT
682                                                                                 + '?xml_in_stash=temp_transfer'
683                                                                                 + '&title=' + window.escape('Volume Transfer'),
684                                                                                 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300'
685                                                                         );
686                                                                         JSAN.use('OpenILS.data');
687                                                                         var data = new OpenILS.data(); data.init({'via':'stash'});
688                                                                         if (data.fancy_prompt_data == '') { alert('Transfer Aborted'); return; }
689
690                                                                         var robj = obj.network.simple_request(
691                                                                                 'FM_ACN_TRANSFER', 
692                                                                                 [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'volumes' : list } ],
693                                                                                 null,
694                                                                                 {
695                                                                                         'title' : 'Override Volume Transfer Failure?',
696                                                                                         'overridable_events' : [
697                                                                                                 1208 /* TITLE_LAST_COPY */,
698                                                                                                 1219 /* COPY_REMOTE_CIRC_LIB */,
699                                                                                         ],
700                                                                                 }
701                                                                         );
702
703                                                                         if (typeof robj.ilsevent != 'undefined') {
704                                                                                 if (robj.ilsevent == 1221 /* ORG_CANNOT_HAVE_VOLS */) {
705                                                                                         alert('That destination cannot have volumes.');
706                                                                                 } else {
707                                                                                         throw(robj);
708                                                                                 }
709                                                                         } else {
710                                                                                 alert('Volumes transferred.');
711                                                                         }
712
713                                                                 } catch(E) {
714                                                                         obj.error.standard_unexpected_error_alert('All volumes not likely transferred.',E);
715                                                                 }
716                                                                 obj.refresh_list();
717                                                         }
718                                                 ],
719
720                                                 'cmd_transfer_items' : [
721                                                         ['command'],
722                                                         function() {
723                                                                 try {
724                                                                         obj.data.stash_retrieve();
725                                                                         if (!obj.data.marked_volume) {
726                                                                                 alert('Please mark a volume as the destination from within holdings maintenance and then try this again.');
727                                                                                 return;
728                                                                         }
729                                                                         
730                                                                         JSAN.use('util.functional');
731
732                                                                         var list = util.functional.filter_list(
733                                                                                 obj.sel_list,
734                                                                                 function (o) {
735                                                                                         return o.split(/_/)[0] == 'acp';
736                                                                                 }
737                                                                         );
738
739                                                                         list = util.functional.map_list(
740                                                                                 list,
741                                                                                 function (o) {
742                                                                                         return o.split(/_/)[1];
743                                                                                 }
744                                                                         );
745
746                                                                         var volume = obj.network.simple_request('FM_ACN_RETRIEVE',[ obj.data.marked_volume ]);
747
748                                                                         JSAN.use('cat.util'); cat.util.transfer_copies( { 
749                                                                                 'copy_ids' : list, 
750                                                                                 'docid' : volume.record(),
751                                                                                 'volume_label' : volume.label(),
752                                                                                 'owning_lib' : volume.owning_lib(),
753                                                                         } );
754
755                                                                 } catch(E) {
756                                                                         obj.error.standard_unexpected_error_alert('All copies not likely transferred.',E);
757                                                                 }
758                                                                 obj.refresh_list();
759                                                         }
760                                                 ],
761                                         }
762                                 }
763                         );
764
765                         obj.list_init(params);
766
767                         obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID',[ obj.docid ]);
768
769                         var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
770                         obj.show_libs( org );
771
772                         obj.show_my_libs();
773
774                 } catch(E) {
775                         this.error.sdump('D_ERROR','cat.copy_browser.init: ' + E + '\n');
776                 }
777         },
778
779         'show_my_libs' : function() {
780                 var obj = this;
781                 try {
782                         var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
783                         obj.show_libs( org, true );
784                 
785                         var p_org = obj.data.hash.aou[ org.parent_ou() ];
786                         if (p_org) {
787                                 JSAN.use('util.exec'); var exec = new util.exec();
788                                 var funcs = [];
789                                 for (var i = 0; i < p_org.children().length; i++) {
790                                         funcs.push(
791                                                 function(o) {
792                                                         return function() {
793                                                                 obj.show_libs( o, true );
794                                                         }
795                                                 }( p_org.children()[i] )
796                                         );
797                                 }
798                                 exec.chain( funcs );
799                         }
800                 } catch(E) {
801                         alert(E);
802                 }
803         },
804
805         'show_all_libs' : function() {
806                 var obj = this;
807                 try {
808                         obj.show_my_libs();
809
810                         obj.show_libs( obj.data.tree.aou );
811
812                         JSAN.use('util.exec'); var exec = new util.exec();
813                         var funcs = [];
814                         for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
815                                 funcs.push(
816                                         function(o) {
817                                                 return function() {
818                                                         obj.show_libs( o );
819                                                 }
820                                         }( obj.data.tree.aou.children()[i] )
821                                 );
822                         }
823                         exec.chain( funcs );
824                 } catch(E) {
825                         alert(E);
826                 }
827         },
828
829         'show_libs_with_copies' : function() {
830                 var obj = this;
831                 try {
832                         JSAN.use('util.exec'); var exec = new util.exec();
833                         JSAN.use('util.functional');
834
835                         var orgs = util.functional.map_list(
836                                 obj.org_ids,
837                                 function(id) { return obj.data.hash.aou[id]; }
838                         ).sort(
839                                 function( a, b ) {
840                                         if (a.shortname() < b.shortname()) return -1;
841                                         if (a.shortname() > b.shortname()) return 1;
842                                         return 0;
843                                 }
844                         );
845                         var funcs = [];
846                         for (var i = 0; i < orgs.length; i++) {
847                                 funcs.push(
848                                         function(o) {
849                                                 return function() {
850                                                         obj.show_libs(o,true);
851                                                 }
852                                         }( orgs[i] )
853                                 );
854                         }
855                         exec.chain( funcs );
856                 } catch(E) {
857                         alert(E);
858                 }
859         },
860
861         'show_libs' : function(start_aou,show_open) {
862                 var obj = this;
863                 try {
864                         if (!start_aou) throw('show_libs: Need a start_aou');
865                         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
866                         JSAN.use('util.functional'); JSAN.use('util.exec'); var exec = new util.exec();
867
868                         var funcs = [];
869
870                         var parents = [];
871                         var temp_aou = start_aou;
872                         while ( temp_aou.parent_ou() ) {
873                                 temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
874                                 parents.push( temp_aou );
875                         }
876                         parents.reverse();
877
878                         for (var i = 0; i < parents.length; i++) {
879                                 funcs.push(
880                                         function(o,p) {
881                                                 return function() { 
882                                                         if (show_open) {
883                                                                 obj.append_org(o,p,{'container':'true','open':'true'}); 
884                                                         } else {
885                                                                 obj.append_org(o,p,{'container':'true'}); 
886                                                         }
887                                                 };
888                                         }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
889                                 );
890                         }
891
892                         funcs.push(
893                                 function(o,p) {
894                                         return function() { obj.append_org(o,p); };
895                                 }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
896                         );
897
898                         funcs.push(
899                                 function() {
900                                         if (start_aou.children()) {
901                                                 var x = obj.map_tree[ 'aou_' + start_aou.id() ];
902                                                 x.setAttribute('container','true');
903                                                 if (show_open) x.setAttribute('open','true');
904                                                 for (var i = 0; i < start_aou.children().length; i++) {
905                                                         funcs.push(
906                                                                 function(o,p) {
907                                                                         return function() { obj.append_org(o,p); };
908                                                                 }( start_aou.children()[i], start_aou )
909                                                         );
910                                                 }
911                                         }
912                                 }
913                         );
914
915                         exec.chain( funcs );
916
917                 } catch(E) {
918                         alert(E);
919                 }
920         },
921
922         'on_select' : function(list,twisty) {
923                 var obj = this;
924                 for (var i = 0; i < list.length; i++) {
925                         var node = obj.map_tree[ list[i] ];
926                         //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
927                         var row_type = list[i].split('_')[0];
928                         var id = list[i].split('_')[1];
929                         switch(row_type) {
930                                 case 'aou' : obj.on_select_org(id,twisty); break;
931                                 case 'acn' : obj.on_select_acn(id,twisty); break;
932                                 default: break;
933                         }
934                 }
935         },
936
937         'on_select_acn' : function(acn_id,twisty) {
938                 var obj = this;
939                 try {
940                         var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
941                         var funcs = [];
942                         if (acn_tree.copies()) {
943                                 for (var i = 0; i < acn_tree.copies().length; i++) {
944                                         funcs.push(
945                                                 function(c,a) {
946                                                         return function() {
947                                                                 obj.append_acp(c,a);
948                                                         }
949                                                 }( acn_tree.copies()[i], acn_tree )
950                                         )
951                                 }
952                         }
953                         JSAN.use('util.exec'); var exec = new util.exec();
954                         exec.chain( funcs );
955                 } catch(E) {
956                         alert(E);
957                 }
958         },
959
960         'on_select_org' : function(org_id,twisty) {
961                 var obj = this;
962                 var org = obj.data.hash.aou[ org_id ];
963                 var funcs = [];
964                 if (org.children()) {
965                         for (var i = 0; i < org.children().length; i++) {
966                                 funcs.push(
967                                         function(o,p) {
968                                                 return function() {
969                                                         obj.append_org(o,p)
970                                                 }
971                                         }(org.children()[i],org)
972                                 );
973                         }
974                 } 
975                 if (obj.map_acn[ 'aou_' + org_id ]) {
976                         for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
977                                 funcs.push(
978                                         function(o,a) {
979                                                 return function() {
980                                                         obj.append_acn(o,a);
981                                                 }
982                                         }( org, obj.map_acn[ 'aou_' + org_id ][i] )
983                                 );
984                         }
985                 }
986                 JSAN.use('util.exec'); var exec = new util.exec();
987                 exec.chain( funcs );
988         },
989
990         'append_org' : function (org,parent_org,params) {
991                 var obj = this;
992                 try {
993                         if (obj.map_tree[ 'aou_' + org.id() ]) {
994                                 var x = obj.map_tree[ 'aou_' + org.id() ];
995                                 if (params) {
996                                         for (var i in params) {
997                                                 x.setAttribute(i,params[i]);
998                                         }
999                                 }
1000                                 return x;
1001                         }
1002
1003                         var data = {
1004                                 'row' : {
1005                                         'my' : {
1006                                                 'aou' : org,
1007                                         }
1008                                 },
1009                                 'skip_all_columns_except' : [0,1,2],
1010                                 'retrieve_id' : 'aou_' + org.id(),
1011                         };
1012                 
1013                         var acn_tree_list;
1014                         if ( obj.org_ids.indexOf( org.id() ) == -1 ) {
1015                                 if ( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) {
1016                                         data.row.my.volume_count = '0';
1017                                         data.row.my.copy_count = '<0>';
1018                                 } else {
1019                                         data.row.my.volume_count = '';
1020                                         data.row.my.copy_count = '';
1021                                 }
1022                         } else {
1023                                 var v_count = 0; var c_count = 0;
1024                                 acn_tree_list = obj.network.simple_request(
1025                                         'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS',
1026                                         [ ses(), obj.docid, [ org.id() ] ]
1027                                 );
1028                                 for (var i = 0; i < acn_tree_list.length; i++) {
1029                                         v_count++;
1030                                         obj.map_acn[ 'acn_' + acn_tree_list[i].id() ] = function(r){return r;}(acn_tree_list[i]);
1031                                         var copies = acn_tree_list[i].copies(); if (copies) c_count += copies.length;
1032                                         for (var j = 0; j < copies.length; j++) {
1033                                                 obj.map_acp[ 'acp_' + copies[j].id() ] = function(r){return r;}(copies[j]);
1034                                         }
1035                                 }
1036                                 data.row.my.volume_count = v_count;
1037                                 data.row.my.copy_count = '<' + c_count + '>';
1038                         }
1039                         if (parent_org) {
1040                                 data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
1041                         }
1042
1043                         var node = obj.list.append(data);
1044                         if (params) {
1045                                 for (var i in params) {
1046                                         node.setAttribute(i,params[i]);
1047                                 }
1048                         }
1049                         obj.map_tree[ 'aou_' + org.id() ] = node;
1050
1051                         if (org.children()) {
1052                                 node.setAttribute('container','true');
1053                         }
1054
1055                         if (parent_org) {
1056                                 if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
1057                                         data.node.setAttribute('open','true');
1058                                 }
1059                         } else {
1060                                 obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
1061                         }
1062
1063                         if (acn_tree_list) {
1064                                 obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
1065                                 node.setAttribute('container','true');
1066                         }
1067
1068                 } catch(E) {
1069                         dump(E+'\n');
1070                         alert(E);
1071                 }
1072         },
1073
1074         'append_acn' : function( org, acn_tree, params ) {
1075                 var obj = this;
1076                 try {
1077                         if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
1078                                 var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
1079                                 if (params) {
1080                                         for (var i in params) {
1081                                                 x.setAttribute(i,params[i]);
1082                                         }
1083                                 }
1084                                 return x;
1085                         }
1086
1087                         var parent_node = obj.map_tree[ 'aou_' + org.id() ];
1088                         var data = {
1089                                 'row' : {
1090                                         'my' : {
1091                                                 'aou' : org,
1092                                                 'acn' : acn_tree,
1093                                                 'volume_count' : '',
1094                                                 'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
1095                                         }
1096                                 },
1097                                 'skip_all_columns_except' : [0,1,2],
1098                                 'retrieve_id' : 'acn_' + acn_tree.id(),
1099                                 'node' : parent_node,
1100                         };
1101                         var node = obj.list.append(data);
1102                         obj.map_tree[ 'acn_' + acn_tree.id() ] =  node;
1103                         if (params) {
1104                                 for (var i in params) {
1105                                         node.setAttribute(i,params[i]);
1106                                 }
1107                         }
1108                         if (acn_tree.copies()) {
1109                                 obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
1110                                 node.setAttribute('container','true');
1111                         }
1112
1113                 } catch(E) {
1114                         dump(E+'\n');
1115                         alert(E);
1116                 }
1117         },
1118
1119         'append_acp' : function( acp_item, acn_tree, params ) {
1120                 var obj = this;
1121                 try {
1122                         if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
1123                                 var x = obj.map_tree[ 'acp_' + acp_item.id() ];
1124                                 if (params) {
1125                                         for (var i in params) {
1126                                                 x.setAttribute(i,params[i]);
1127                                         }
1128                                 }
1129                                 return x;
1130                         }
1131
1132                         var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
1133                         var data = {
1134                                 'row' : {
1135                                         'my' : {
1136                                                 'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
1137                                                 'acn' : acn_tree,
1138                                                 'acp' : acp_item,
1139                                                 'volume_count' : '',
1140                                                 'copy_count' : '',
1141                                         }
1142                                 },
1143                                 'retrieve_id' : 'acp_' + acp_item.id(),
1144                                 'node' : parent_node,
1145                         };
1146                         var node = obj.list.append(data);
1147                         obj.map_tree[ 'acp_' + acp_item.id() ] =  node;
1148                         if (params) {
1149                                 for (var i in params) {
1150                                         node.setAttribute(i,params[i]);
1151                                 }
1152                         }
1153
1154                 } catch(E) {
1155                         dump(E+'\n');
1156                         alert(E);
1157                 }
1158         },
1159
1160         'list_init' : function( params ) {
1161
1162                 try {
1163                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1164                         var obj = this;
1165                         
1166                         JSAN.use('circ.util');
1167                         var columns = [
1168                                 {
1169                                         'id' : 'tree_location', 'label' : 'Location/Barcode', 'flex' : 1,
1170                                         'primary' : true, 'hidden' : false, 
1171                                         'render' : 'my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"'
1172                                 },
1173                                 {
1174                                         'id' : 'volume_count', 'label' : 'Volumes', 'flex' : 0,
1175                                         'primary' : false, 'hidden' : false, 
1176                                         'render' : 'my.volume_count'
1177                                 },
1178                                 {
1179                                         'id' : 'copy_count', 'label' : 'Copies', 'flex' : 0,
1180                                         'primary' : false, 'hidden' : false, 
1181                                         'render' : 'my.copy_count'
1182                                 },
1183                         ].concat(
1184                                 circ.util.columns( 
1185                                         { 
1186                                                 'location' : { 'hidden' : false },
1187                                                 'circ_lib' : { 'hidden' : false },
1188                                                 'owning_lib' : { 'hidden' : false },
1189                                                 'call_number' : { 'hidden' : false },
1190                                                 'status' : { 'hidden' : false },
1191                                         },
1192                                         {
1193                                                 'just_these' : [
1194                                                         'owning_lib',
1195                                                         'circ_lib',
1196                                                         'call_number',
1197                                                         'copy_number',
1198                                                         'location',
1199                                                         'barcode',
1200                                                         'loan_duration',
1201                                                         'fine_level',
1202                                                         'circulate',
1203                                                         'holdable',
1204                                                         'opac_visible',
1205                                                         'ref',
1206                                                         'deposit',
1207                                                         'deposit_amount',
1208                                                         'price',
1209                                                         'circ_as_type',
1210                                                         'circ_modifier',
1211                                                         'status',
1212                                                         'alert_message',
1213                                                         'acp_id',
1214                                                 ]
1215                                         }
1216                                 )
1217                         );
1218                         JSAN.use('util.list'); obj.list = new util.list('copy_tree');
1219                         obj.list.init(
1220                                 {
1221                                         'columns' : columns,
1222                                         'map_row_to_column' : circ.util.std_map_row_to_column(' '),
1223                                         'retrieve_row' : function(params) {
1224
1225                                                 var row = params.row;
1226
1227                                                 var funcs = [];
1228                                         /*      
1229                                                 if (!row.my.mvr) funcs.push(
1230                                                         function() {
1231
1232                                                                 row.my.mvr = obj.network.request(
1233                                                                         api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
1234                                                                         api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
1235                                                                         [ row.my.circ.target_copy() ]
1236                                                                 );
1237
1238                                                         }
1239                                                 );
1240                                                 if (!row.my.acp) {
1241                                                         funcs.push(     
1242                                                                 function() {
1243
1244                                                                         row.my.acp = obj.network.request(
1245                                                                                 api.FM_ACP_RETRIEVE.app,
1246                                                                                 api.FM_ACP_RETRIEVE.method,
1247                                                                                 [ row.my.circ.target_copy() ]
1248                                                                         );
1249
1250                                                                         params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1251
1252                                                                 }
1253                                                         );
1254                                                 } else {
1255                                                         params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1256                                                 }
1257                                         */
1258                                                 funcs.push(
1259                                                         function() {
1260
1261                                                                 if (typeof params.on_retrieve == 'function') {
1262                                                                         params.on_retrieve(row);
1263                                                                 }
1264
1265                                                         }
1266                                                 );
1267
1268                                                 JSAN.use('util.exec'); var exec = new util.exec();
1269                                                 exec.on_error = function(E) {
1270                                                         var err = 'items chain: ' + js2JSON(E);
1271                                                         obj.error.sdump('D_ERROR',err);
1272                                                         return true; /* keep going */
1273                                                 }
1274                                                 exec.chain( funcs );
1275
1276                                                 return row;
1277                                         },
1278                                         'on_click' : function(ev) {
1279                                                 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
1280                                                 var row = {}; var col = {}; var nobj = {};
1281                                                 obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj);
1282                                                 if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
1283                                                 var node = obj.list.node.contentView.getItemAtIndex(row.value);
1284                                                 var list = [ node.getAttribute('retrieve_id') ];
1285                                                 if (typeof obj.on_select == 'function') {
1286                                                         obj.on_select(list,true);
1287                                                 }
1288                                                 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1289                                                         window.xulG.on_select(list);
1290                                                 }
1291                                         },
1292                                         'on_select' : function(ev) {
1293                                                 JSAN.use('util.functional');
1294                                                 var sel = obj.list.retrieve_selection();
1295                                                 obj.controller.view.sel_clip.disabled = sel.length < 1;
1296                                                 obj.sel_list = util.functional.map_list(
1297                                                         sel,
1298                                                         function(o) { return o.getAttribute('retrieve_id'); }
1299                                                 );
1300                                                 obj.toggle_actions();
1301                                                 if (typeof obj.on_select == 'function') {
1302                                                         obj.on_select(obj.sel_list);
1303                                                 }
1304                                                 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1305                                                         window.xulG.on_select(obj.sel_list);
1306                                                 }
1307                                         },
1308                                 }
1309                         );
1310
1311                         obj.controller.render();
1312
1313                 } catch(E) {
1314                         this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
1315                         alert(E);
1316                 }
1317         },
1318
1319         'toggle_actions' : function() {
1320                 var obj = this;
1321                 try {
1322                         var found_aou = false; var found_acn = false; var found_acp = false;
1323                         for (var i = 0; i < obj.sel_list.length; i++) {
1324                                 var type = obj.sel_list[i].split(/_/)[0];
1325                                 switch(type) {
1326                                         case 'aou' : found_aou = true; break;
1327                                         case 'acn' : found_acn = true; break;
1328                                         case 'acp' : found_acp = true; break;
1329                                 }
1330                         }
1331                         obj.controller.view.cmd_add_items.setAttribute('disabled','true');
1332                         obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','true');
1333                         obj.controller.view.cmd_edit_items.setAttribute('disabled','true');
1334                         obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
1335                         obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','true');
1336                         obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
1337                         obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
1338                         obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
1339                         obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
1340                         obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
1341                         obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true');
1342                         obj.controller.view.cmd_transfer_items.setAttribute('disabled','true');
1343                         obj.controller.view.sel_copy_details.setAttribute('disabled','true');
1344                         obj.controller.view.sel_patron.setAttribute('disabled','true');
1345                         if (found_aou) {
1346                                 obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
1347                                 obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
1348                         }
1349                         if (found_acn) {
1350                                 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
1351                                 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
1352                                 obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
1353                                 obj.controller.view.cmd_add_items.setAttribute('disabled','false');
1354                                 obj.controller.view.cmd_transfer_volume.setAttribute('disabled','false');
1355                         }
1356                         if (found_acp) {
1357                                 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','false');
1358                                 obj.controller.view.cmd_edit_items.setAttribute('disabled','false');
1359                                 obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
1360                                 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false');
1361                                 obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
1362                                 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
1363                                 obj.controller.view.sel_patron.setAttribute('disabled','false');
1364                         }
1365                 } catch(E) {
1366                         obj.error.standard_unexpected_error_alert('Copy Browser Actions',E);
1367                 }
1368         },
1369
1370         'refresh_list' : function() { 
1371                 try {
1372                         var obj = this;
1373                         obj.list.clear();
1374                         obj.map_tree = {};
1375                         obj.map_acn = {};
1376                         obj.map_acp = {};
1377                         obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID',[ obj.docid ]);
1378                         var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
1379                         obj.show_libs( org );
1380                         obj.show_my_libs();
1381                 } catch(E) {
1382                         this.error.standard_unexpected_error_alert('Problem refreshing the volume/copy tree.',E);
1383                 }
1384         },
1385 }
1386
1387 dump('exiting cat.copy_browser.js\n');