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