]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/copy_buckets.js
shared buckets
[Evergreen.git] / Open-ILS / xul / staff_client / server / cat / copy_buckets.js
1 dump('entering cat.copy_buckets.js\n');
2
3 if (typeof cat == 'undefined') cat = {};
4 cat.copy_buckets = function (params) {
5
6         JSAN.use('util.error'); this.error = new util.error();
7         JSAN.use('util.network'); this.network = new util.network();
8         JSAN.use('util.date');
9         JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
10         this.first_pause = true;
11 }
12
13 cat.copy_buckets.prototype = {
14         'selection_list1' : [],
15         'selection_list2' : [],
16         'bucket_id_name_map' : {},
17
18         'render_pending_copies' : function() {
19                 if (this.first_pause) {
20                         this.first_pause = false;
21                 } else {
22                         alert("Pausing for replicated databases... press Enter or Spacebar when ready.");
23                 }
24                 var obj = this;
25                 obj.list1.clear();
26                 for (var i = 0; i < obj.copy_ids.length; i++) {
27                         var item = obj.flesh_item_for_list( obj.copy_ids[i] );
28                         if (item) obj.list1.append( item );
29                 }
30         },
31
32         'init' : function( params ) {
33
34                 var obj = this;
35
36                 obj.copy_ids = params['copy_ids'] || [];
37
38                 JSAN.use('circ.util');
39                 var columns = circ.util.columns( 
40                         { 
41                                 'barcode' : { 'hidden' : false },
42                                 'title' : { 'hidden' : false },
43                                 'location' : { 'hidden' : false },
44                                 'call_number' : { 'hidden' : false },
45                                 'status' : { 'hidden' : false },
46                                 'deleted' : { 'hidden' : false },
47                         } 
48                 );
49
50                 JSAN.use('util.list'); 
51
52                 obj.list1 = new util.list('pending_copies_list');
53                 obj.list1.init(
54                         {
55                                 'columns' : columns,
56                                 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
57                                 'on_select' : function(ev) {
58                                         try {
59                                                 JSAN.use('util.functional');
60                                                 var sel = obj.list1.retrieve_selection();
61                                                 obj.selection_list1 = util.functional.map_list(
62                                                         sel,
63                                                         function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
64                                                 );
65                                                 obj.error.sdump('D_TRACE','circ/copy_buckets: selection list 1 = ' + js2JSON(obj.selection_list1) );
66                                                 if (obj.selection_list1.length == 0) {
67                                                         obj.controller.view.copy_buckets_sel_add.disabled = true;
68                                                 } else {
69                                                         obj.controller.view.copy_buckets_sel_add.disabled = false;
70                                                 }
71                                         } catch(E) {
72                                                 alert('FIXME: ' + E);
73                                         }
74                                 },
75
76                         }
77                 );
78
79                 obj.render_pending_copies();
80         
81                 obj.list2 = new util.list('copies_in_bucket_list');
82                 obj.list2.init(
83                         {
84                                 'columns' : columns,
85                                 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
86                                 'on_select' : function(ev) {
87                                         try {
88                                                 JSAN.use('util.functional');
89                                                 var sel = obj.list2.retrieve_selection();
90                                                 document.getElementById('clip_button').disabled = sel.length < 1;
91                                                 obj.selection_list2 = util.functional.map_list(
92                                                         sel,
93                                                         function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
94                                                 );
95                                                 obj.error.sdump('D_TRACE','circ/copy_buckets: selection list 2 = ' + js2JSON(obj.selection_list2) );
96                                                 if (obj.selection_list2.length == 0) {
97                                                         obj.controller.view.copy_buckets_delete_item.disabled = true;
98                                                         obj.controller.view.copy_buckets_delete_item.setAttribute('disabled','true');
99                                                         obj.controller.view.copy_buckets_export.disabled = true;
100                                                         obj.controller.view.copy_buckets_export.setAttribute('disabled','true');
101                                                 } else {
102                                                         obj.controller.view.copy_buckets_delete_item.disabled = false;
103                                                         obj.controller.view.copy_buckets_delete_item.setAttribute('disabled','false');
104                                                         obj.controller.view.copy_buckets_export.disabled = false;
105                                                         obj.controller.view.copy_buckets_export.setAttribute('disabled','false');
106                                                 }
107                                         } catch(E) {
108                                                 alert('FIXME: ' + E);
109                                         }
110                                 },
111                         }
112                 );
113                 
114                 JSAN.use('util.controller'); obj.controller = new util.controller();
115                 obj.controller.init(
116                         {
117                                 'control_map' : {
118                                         'sel_clip' : [
119                                                 ['command'],
120                                                 function() { obj.list2.clipboard(); }
121                                         ],
122                                         'copy_buckets_menulist_placeholder' : [
123                                                 ['render'],
124                                                 function(e) {
125                                                         return function() {
126                                                                 JSAN.use('util.widgets'); JSAN.use('util.functional');
127                                                                 var items = [ ['Choose a bucket...',''], ['Retrieve shared bucket...',-1] ].concat(
128                                                                         util.functional.map_list(
129                                                                                 obj.network.simple_request(
130                                                                                         'BUCKET_RETRIEVE_VIA_USER',
131                                                                                         [ ses(), obj.data.list.au[0].id() ]
132                                                                                 ).copy,
133                                                                                 function(o) {
134                                                                                         obj.bucket_id_name_map[ o.id() ] = o.name();
135                                                                                         return [ o.name(), o.id() ];
136                                                                                 }
137                                                                         )
138                                                                 );
139                                                                 obj.error.sdump('D_TRACE','items = ' + js2JSON(items));
140                                                                 util.widgets.remove_children( e );
141                                                                 var ml = util.widgets.make_menulist(
142                                                                         items
143                                                                 );
144                                                                 e.appendChild( ml );
145                                                                 ml.setAttribute('id','bucket_menulist');
146                                                                 ml.setAttribute('accesskey','');
147
148                                                                 function change_bucket(ev) {
149                                                                         var bucket_id = ev.target.value;
150                                                                         if (bucket_id < 0 ) {
151                                                                                 bucket_id = window.prompt('Enter bucket number:');
152                                                                                 ev.target.value = bucket_id;
153                                                                                 ev.target.setAttribute('value',bucket_id);
154                                                                         }
155                                                                         if (!bucket_id) return;
156                                                                         var bucket = obj.network.simple_request(
157                                                                                 'BUCKET_FLESH',
158                                                                                 [ ses(), 'copy', bucket_id ]
159                                                                         );
160                                                                         if (typeof bucket.ilsevent != 'undefined') {
161                                                                                 if (bucket.ilsevent == 1506 /* CONTAINER_NOT_FOUND */) {
162                                                                                         alert('Could not find a bucket with ID = ' + bucket_id);
163                                                                                 } else {
164                                                                                         obj.error.standard_unexpected_error_alert('Error retrieving bucket.  Did you use a valid bucket id?',bucket);
165                                                                                 }
166                                                                                 return;
167                                                                         }
168                                                                         try {
169                                                                                 var x = document.getElementById('info_box');
170                                                                                 x.setAttribute('hidden','false');
171                                                                                 x = document.getElementById('bucket_number');
172                                                                                 x.setAttribute('value',bucket.id());
173                                                                                 x = document.getElementById('bucket_name');
174                                                                                 x.setAttribute('value',bucket.name());
175                                                                                 x = document.getElementById('bucket_owner');
176                                                                                 var s = bucket.owner(); JSAN.use('patron.util');
177                                                                                 if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s); 
178                                                                                 x.setAttribute('value',s.card().barcode() + " @ " + obj.data.hash.aou[ s.home_ou() ].shortname());
179
180                                                                         } catch(E) {
181                                                                                 alert(E);
182                                                                         }
183                                                                         var items = bucket.items() || [];
184                                                                         obj.list2.clear();
185                                                                         for (var i = 0; i < items.length; i++) {
186                                                                                 var item = obj.flesh_item_for_list( 
187                                                                                         items[i].target_copy(),
188                                                                                         items[i].id()
189                                                                                 );
190                                                                                 if (item) obj.list2.append( item );
191                                                                         }
192                                                                 }
193
194                                                                 ml.addEventListener( 'change_bucket', change_bucket , false);
195                                                                 ml.addEventListener( 'command', function() {
196                                                                         JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
197                                                                 }, false);
198                                                                 obj.controller.view.bucket_menulist = ml;
199                                                                 JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
200                                                                 document.getElementById('refresh').addEventListener( 'command', function() {
201                                                                         JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
202                                                                 }, false);
203                                                         };
204                                                 },
205                                         ],
206
207                                         'copy_buckets_add' : [
208                                                 ['command'],
209                                                 function() {
210                                                         var bucket_id = obj.controller.view.bucket_menulist.value;
211                                                         if (!bucket_id) return;
212                                                         for (var i = 0; i < obj.copy_ids.length; i++) {
213                                                                 var bucket_item = new ccbi();
214                                                                 bucket_item.isnew('1');
215                                                                 bucket_item.bucket(bucket_id);
216                                                                 bucket_item.target_copy( obj.copy_ids[i] );
217                                                                 try {
218                                                                         var robj = obj.network.simple_request('BUCKET_ITEM_CREATE',
219                                                                                 [ ses(), 'copy', bucket_item ]);
220
221                                                                         if (typeof robj == 'object') throw robj;
222
223                                                                         var item = obj.flesh_item_for_list( obj.copy_ids[i], robj );
224                                                                         if (!item) continue;
225
226                                                                         obj.list2.append( item );
227                                                                 } catch(E) {
228                                                                         obj.error.standard_unexpected_error_alert('Addition likely failed.',E);
229                                                                 }
230                                                         }
231                                                 }
232                                         ],
233                                         'copy_buckets_sel_add' : [
234                                                 ['command'],
235                                                 function() {                                                        
236                                                         var bucket_id = obj.controller.view.bucket_menulist.value;
237                                                         if (!bucket_id) return;
238                                                         for (var i = 0; i < obj.selection_list1.length; i++) {
239                                                                 var acp_id = obj.selection_list1[i][0];
240                                                                 //var barcode = obj.selection_list1[i][1];
241                                                                 var bucket_item = new ccbi();
242                                                                 bucket_item.isnew('1');
243                                                                 bucket_item.bucket(bucket_id);
244                                                                 bucket_item.target_copy( acp_id );
245                                                                 try {
246                                                                         var robj = obj.network.simple_request('BUCKET_ITEM_CREATE',
247                                                                                 [ ses(), 'copy', bucket_item ]);
248
249                                                                         if (typeof robj == 'object') throw robj;
250
251                                                                         var item = obj.flesh_item_for_list( acp_id, robj );
252                                                                         if (!item) continue;
253
254                                                                         obj.list2.append( item );
255                                                                 } catch(E) {
256                                                                         obj.error.standard_unexpected_error_alert('Deletion likely failed.',E);
257                                                                 }
258                                                         }
259
260                                                 }
261                                         ],
262                                         'copy_buckets_export' : [
263                                                 ['command'],
264                                                 function() {                                                        
265                                                         for (var i = 0; i < obj.selection_list2.length; i++) {
266                                                                 var acp_id = obj.selection_list2[i][0];
267                                                                 //var barcode = obj.selection_list1[i][1];
268                                                                 //var bucket_item_id = obj.selection_list1[i][2];
269                                                                 var item = obj.flesh_item_for_list( acp_id );
270                                                                 if (item) {
271                                                                         obj.list1.append( item );
272                                                                         obj.copy_ids.push( acp_id );
273                                                                 }
274                                                         }
275                                                 }
276                                         ],
277
278                                         'copy_buckets_delete_item' : [
279                                                 ['command'],
280                                                 function() {
281                                                         for (var i = 0; i < obj.selection_list2.length; i++) {
282                                                                 try {
283                                                                         //var acp_id = obj.selection_list2[i][0];
284                                                                         //var barcode = obj.selection_list2[i][1];
285                                                                         var bucket_item_id = obj.selection_list2[i][2];
286                                                                         var robj = obj.network.simple_request('BUCKET_ITEM_DELETE',
287                                                                                 [ ses(), 'copy', bucket_item_id ]);
288                                                                         if (typeof robj == 'object') throw robj;
289                                                                 } catch(E) {
290                                                                         obj.error.standard_unexpected_error_alert('Deletion likely failed.',E);
291                                                                 }
292                                                         }
293                                                         alert("Pausing for replicated databases... press Enter or Spacebar when ready.");
294                                                         setTimeout(
295                                                                 function() {
296                                                                         JSAN.use('util.widgets'); 
297                                                                         util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
298                                                                 }, 0
299                                                         );
300                                                 }
301                                         ],
302                                         'copy_buckets_delete_bucket' : [
303                                                 ['command'],
304                                                 function() {
305                                                         try {
306                                                                 var bucket = obj.controller.view.bucket_menulist.value;
307                                                                 var name = obj.bucket_id_name_map[ bucket ];
308                                                                 var conf = window.confirm('Delete the bucket named ' + name + '?');
309                                                                 if (!conf) return;
310                                                                 obj.list2.clear();
311                                                                 var robj = obj.network.simple_request('BUCKET_DELETE',[ses(),'copy',bucket]);
312                                                                 if (typeof robj == 'object') throw robj;
313                                                                 alert("Pausing for replicated databases... press Enter or Spacebar when ready.");
314                                                                 obj.controller.render('copy_buckets_menulist_placeholder');
315                                                         } catch(E) {
316                                                                 obj.error.standard_unexpected_error_alert('Bucket deletion likely failed.',E);
317                                                         }
318                                                 }
319                                         ],
320                                         'copy_buckets_new_bucket' : [
321                                                 ['command'],
322                                                 function() {
323                                                         try {
324                                                                 var name = prompt('What would you like to name the bucket?','','Bucket Creation');
325
326                                                                 if (name) {
327                                                                         var bucket = new ccb();
328                                                                         bucket.btype('staff_client');
329                                                                         bucket.owner( obj.data.list.au[0].id() );
330                                                                         bucket.name( name );
331
332                                                                         var robj = obj.network.simple_request('BUCKET_CREATE',[ses(),'copy',bucket]);
333
334                                                                         if (typeof robj == 'object') throw robj;
335
336                                                                         alert('Bucket "' + name + '" created.');
337
338                                                                         obj.controller.render('copy_buckets_menulist_placeholder');
339                                                                         obj.controller.view.bucket_menulist.value = robj;
340                                                                         setTimeout(
341                                                                                 function() {
342                                                                                         JSAN.use('util.widgets'); 
343                                                                                         util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
344                                                                                 }, 0
345                                                                         );
346                                                                 }
347                                                         } catch(E) {
348                                                                 obj.error.standard_unexpected_error_alert('Bucket creation failed.',E);
349                                                         }
350                                                 }
351                                         ],
352                                         'copy_buckets_batch_copy_edit' : [
353                                                 ['command'],
354                                                 function() {
355                                                         try {
356
357                                                                 obj.list2.select_all();
358                                                         
359                                                                 JSAN.use('util.widgets'); JSAN.use('util.functional');
360
361                                                                 var list = util.functional.map_list(
362                                                                         obj.list2.dump_retrieve_ids(),
363                                                                         function (o) {
364                                                                                 return JSON2js(o)[0]; // acp_id
365                                                                         }
366                                                                 );
367
368                                                                 var copies = util.functional.map_list(
369                                                                         list,
370                                                                         function (acp_id) {
371                                                                                 return obj.network.simple_request('FM_ACP_RETRIEVE',[acp_id]);
372                                                                         }
373                                                                 );
374
375                                                                 var edit = 0;
376                                                                 try {
377                                                                         edit = obj.network.request(
378                                                                                 api.PERM_MULTI_ORG_CHECK.app,
379                                                                                 api.PERM_MULTI_ORG_CHECK.method,
380                                                                                 [ 
381                                                                                         ses(), 
382                                                                                         obj.data.list.au[0].id(), 
383                                                                                         util.functional.map_list(
384                                                                                                 copies,
385                                                                                                 function (o) {
386                                                                                                         return o.call_number() == -1 ? o.circ_lib() : obj.network.simple_request('FM_ACN_RETRIEVE',[o.call_number()]).owning_lib();
387                                                                                                 }
388                                                                                         ),
389                                                                                         copies.length == 1 ? [ 'UPDATE_COPY' ] : [ 'UPDATE_COPY', 'UPDATE_BATCH_COPY' ]
390                                                                                 ]
391                                                                         ).length == 0 ? 1 : 0;
392                                                                 } catch(E) {
393                                                                         obj.error.sdump('D_ERROR','batch permission check: ' + E);
394                                                                 }
395
396                                                                 JSAN.use('cat.util'); cat.util.spawn_copy_editor(list,edit);
397
398                                                                 obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
399                                                                 setTimeout(
400                                                                         function() {
401                                                                                 JSAN.use('util.widgets'); 
402                                                                                 util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
403                                                                         }, 0
404                                                                 );
405                                                         } catch(E) {
406                                                                 alert( js2JSON(E) );
407                                                         }
408                                                 }
409                                         ],
410                                         'copy_buckets_batch_copy_delete' : [
411                                                 ['command'],
412                                                 function() {
413                                                         try {
414                                                         
415                                                                 obj.list2.select_all();
416
417                                                                 JSAN.use('util.widgets'); JSAN.use('util.functional');
418
419                                                                 var list = util.functional.map_list(
420                                                                         obj.list2.dump_retrieve_ids(),
421                                                                         function (o) {
422                                                                                 return JSON2js(o)[0]; // acp_id
423                                                                         }
424                                                                 );
425
426                                                                 var copies = util.functional.map_list(
427                                                                         list,
428                                                                         function (acp_id) {
429                                                                                 return obj.network.simple_request('FM_ACP_RETRIEVE',[acp_id]);
430                                                                         }
431                                                                 );
432
433                                                                 for (var i = 0; i < copies.length; i++) {
434                                                                         copies[i].ischanged(1);
435                                                                         copies[i].isdeleted(1);
436                                                                 }
437
438                                                                 var robj = obj.network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE',[ ses(), copies, true]);
439                                                                 if (typeof robj.ilsevent != 'undefined') obj.error.standard_unexpected_error_alert('Batch Item Deletion',robj);
440
441                                                                 obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
442                                                                 setTimeout(
443                                                                         function() {
444                                                                                 JSAN.use('util.widgets'); 
445                                                                                 util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
446                                                                         }, 0
447                                                                 );
448                                                         } catch(E) {
449                                                                 alert( js2JSON(E) );
450                                                         }
451                                                 }
452                                         ],
453
454                                         'copy_buckets_transfer_to_volume' : [
455                                                 ['command'],
456                                                 function() {
457                                                         try {
458                                                                 obj.list2.select_all();
459
460                                                                 obj.data.stash_retrieve();
461                                                                 if (!obj.data.marked_volume) {
462                                                                         alert('Please mark a volume as the destination from within the copy browser and then try this again.');
463                                                                         return;
464                                                                 }
465
466                                                                 var copy_ids = util.functional.map_list(
467                                                                         obj.list2.dump_retrieve_ids(),
468                                                                         function (o) {
469                                                                                 return JSON2js(o)[0]; // acp_id
470                                                                         }
471                                                                 )
472
473                                                                 var volume = obj.network.simple_request('FM_ACN_RETRIEVE',[ obj.data.marked_volume ]);
474
475                                                                 var msg = 'Transfer the items in bucket "';
476                                                                 msg += obj.controller.view.bucket_menulist.getAttribute('label') + '" ';
477                                                                 msg += 'from their original volumes to ';
478                                                                 msg += obj.data.hash.aou[ volume.owning_lib() ].shortname() + "'s volume labelled ";
479                                                                 msg += '"' + volume.label() + '" on the following record?';
480
481                                                                 JSAN.use('cat.util'); cat.util.transfer_copies( { 
482                                                                         'copy_ids' : copy_ids, 
483                                                                         'message' : msg, 
484                                                                         'docid' : volume.record(),
485                                                                         'volume_label' : volume.label(),
486                                                                         'owning_lib' : volume.owning_lib(),
487                                                                 } );
488
489                                                                 obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
490                                                                 setTimeout(
491                                                                         function() {
492                                                                                 JSAN.use('util.widgets'); 
493                                                                                 util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
494                                                                         }, 0
495                                                                 );
496                                                                 
497                                                         } catch(E) {
498                                                                 obj.error.standard_unexpected_error_alert('Items not likely transferred.',E);
499                                                         }
500                                                 }
501                                         ],
502                                         'cmd_broken' : [
503                                                 ['command'],
504                                                 function() { alert('Not Yet Implemented'); }
505                                         ],
506                                         'cmd_copy_buckets_print' : [
507                                                 ['command'],
508                                                 function() {
509                                                         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
510                                                         obj.list2.on_all_fleshed = function() {
511                                                                 try {
512                                                                         dump( js2JSON( obj.list2.dump_with_keys() ) + '\n' );
513                                                                         data.stash_retrieve();
514                                                                         var lib = data.hash.aou[ data.list.au[0].ws_ou() ];
515                                                                         lib.children(null);
516                                                                         var p = { 
517                                                                                 'lib' : lib,
518                                                                                 'staff' : data.list.au[0],
519                                                                                 'header' : data.print_list_templates.item_status.header,
520                                                                                 'line_item' : data.print_list_templates.item_status.line_item,
521                                                                                 'footer' : data.print_list_templates.item_status.footer,
522                                                                                 'type' : data.print_list_templates.item_status.type,
523                                                                                 'list' : obj.list2.dump_with_keys(),
524                                                                         };
525                                                                         JSAN.use('util.print'); var print = new util.print();
526                                                                         print.tree_list( p );
527                                                                         setTimeout(function(){obj.list2.on_all_fleshed = null;},0);
528                                                                 } catch(E) {
529                                                                         alert(E); 
530                                                                 }
531                                                         }
532                                                         obj.list2.full_retrieve();
533                                                 }
534                                         ],
535                                         'cmd_copy_buckets_reprint' : [
536                                                 ['command'],
537                                                 function() {
538                                                 }
539                                         ],
540                                         'cmd_copy_buckets_done' : [
541                                                 ['command'],
542                                                 function() {
543                                                         window.close();
544                                                 }
545                                         ],
546                                         'cmd_export_to_copy_status' : [
547                                                 ['command'],
548                                                 function() {
549                                                         try {
550                                                                 obj.list2.select_all();
551                                                                 JSAN.use('util.functional');
552                                                                 var barcodes = util.functional.map_list(
553                                                                         obj.list2.dump_retrieve_ids(),
554                                                                         function(o) { return JSON2js(o)[1]; }
555                                                                 );
556                                                                 var url = urls.XUL_COPY_STATUS + '?barcodes=' + window.escape( js2JSON(barcodes) );
557                                                                 xulG.new_tab( url, {}, {});
558                                                         } catch(E) {
559                                                                 obj.error.standard_unexpected_error_alert('Copy Status from Copy Buckets',E);
560                                                         }
561                                                 }
562                                         ],
563                                 }
564                         }
565                 );
566                 this.controller.render();
567
568                 if (typeof xulG == 'undefined') {
569                         obj.controller.view.cmd_export_to_copy_status.disabled = true;
570                         obj.controller.view.cmd_export_to_copy_status.setAttribute('disabled',true);
571                 } else {
572                         obj.controller.view.cmd_copy_buckets_done.disabled = true;
573                         obj.controller.view.cmd_copy_buckets_done.setAttribute('disabled',true);
574                 }
575         
576         },
577
578         'flesh_item_for_list' : function(acp_id,bucket_item_id) {
579                 var obj = this;
580                 try {
581                         var copy = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ acp_id ]);
582                         if (copy == null || typeof copy.ilsevent != 'undefined') {
583                                 throw(copy);
584                         } else {
585                                 var item = {
586                                         'retrieve_id' : js2JSON( [ copy.id(), copy.barcode(), bucket_item_id ] ),
587                                         'row' : {
588                                                 'my' : {
589                                                         'mvr' : obj.network.simple_request('MODS_SLIM_RECORD_RETRIEVE_VIA_COPY', [ copy.id() ]),
590                                                         'acp' : copy,
591                                                 }
592                                         }
593                                 };
594                                 return item;
595                         }
596                 } catch(E) {
597                         obj.error.standard_unexpected_error_alert('List building failed.',E);
598                         return null;
599                 }
600
601         },
602         
603 }
604
605 dump('exiting cat.copy_buckets.js\n');