fix clear hold shelf with 25 or more holds
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / patron / holds.js
1 dump('entering patron.holds.js\n');
2
3 function $(id) { return document.getElementById(id); }
4
5 if (typeof patron == 'undefined') patron = {};
6 patron.holds = function (params) {
7
8     JSAN.use('util.error'); this.error = new util.error();
9     JSAN.use('util.network'); this.network = new util.network();
10     JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
11 }
12
13 patron.holds.prototype = {
14
15     'hold_interface_type' : null,
16
17     'pull_from_shelf_interface' : {
18         '_default' : { 'limit' : 100, 'offset' : 0 },
19         'current' : { 'limit' : 100, 'offset' : 0 }
20     },
21
22     'filter_lib' : null,
23
24     'hold_subscription_map' : {},
25     'hold_part_map' : {},
26
27     'expired' : false,
28     'post_clear_shelf_hold_action_map' : {},
29
30     'retrieve_ids' : [],
31
32     'holds_map' : {},
33
34     'flatten_copy' : function(hold) {
35         try { if ( hold.current_copy() && typeof hold.current_copy() == 'object') hold.current_copy( hold.current_copy().id() ); } catch(E) { alert('FIXME: Error flattening hold before hold update: ' + E); }
36         return hold;
37     },
38
39     'init' : function( params ) {
40
41         var obj = this;
42
43         dojo.require("openils.Util");
44         obj.event_listeners = new EventListenerList();
45
46         obj.patron_id = params['patron_id'];
47         obj.patron_barcode = params['patron_barcode'];
48         obj.docid = params['docid'];
49         obj.shelf = params['shelf'];
50         obj.tree_id = params['tree_id'];
51
52         obj.determine_hold_interface_type();
53
54         var progressmeter = document.getElementById('progress');
55
56         JSAN.use('circ.util');
57         var columns = circ.util.hold_columns(
58             {
59                 'title' : { 'hidden' : false, 'flex' : '3' },
60                 'request_time' : { 'hidden' : false },
61                 'pickup_lib_shortname' : { 'hidden' : false },
62                 'hold_type' : { 'hidden' : false },
63                 'current_copy' : { 'hidden' : false },
64                 'capture_time' : { 'hidden' : false },
65                 'notify_time' : { 'hidden' : false },
66                 'notify_count' : { 'hidden' : false },
67                 'cancel_cause' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
68                 'cancel_note' : { 'hidden' :  ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
69                 'cancel_time' : { 'hidden' :  ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
70                 'post_clear_shelf_action' : { 'hidden' : obj.shelf ? false : true }
71             }
72         );
73
74         JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
75         obj.list.init(
76             {
77                 'columns_saved_under' : 'holds_' + obj.hold_interface_type,
78                 'columns' : columns.concat(
79                     obj.list.fm_columns('acp', {
80                         '*' : { 'expanded_label' : true, 'hidden' : true },
81                         // example of unhiding some columns by default
82                         // 'acp_circ_modifier' : { 'hidden' : false }
83                     })
84                 ),
85                 'retrieve_row' : function(params) {
86                     var row = params.row;
87                     try {
88                         obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
89                             function(blob_req) {
90                                 try {
91                                     var blob = blob_req.getResultObject();
92                                     if (typeof blob.ilsevent != 'undefined') throw(blob);
93                                     row.my.ahr = blob.hold;
94                                     row.my.status = blob.status;
95                                     row.my.ahr.status( blob.status );
96                                     row.my.acp = blob.copy;
97                                     row.my.acn = blob.volume;
98                                     row.my.mvr = blob.mvr;
99                                     row.my.part = blob.part;
100                                     if (blob.part) {
101                                         obj.hold_part_map[ row.my.hold_id ] = row.my.part;
102                                     }
103                                     row.my.issuance = blob.issuance;
104                                     if (blob.issuance) {
105                                         row.my.subscription = blob.issuance.subscription();
106                                         obj.hold_subscription_map[ row.my.hold_id ] = row.my.subscription;
107                                     }
108                                     row.my.patron_family_name = blob.patron_last;
109                                     row.my.patron_first_given_name = blob.patron_first;
110                                     row.my.patron_barcode = blob.patron_barcode;
111                                     row.my.patron_alias = blob.patron_alias;
112                                     row.my.total_holds = blob.total_holds;
113                                     row.my.queue_position = blob.queue_position;
114                                     row.my.potential_copies = blob.potential_copies;
115                                     row.my.estimated_wait = blob.estimated_wait;
116                                     row.my.ahrn_count = blob.hold.notes().length;
117
118                                     var copy_id = row.my.ahr.current_copy();
119                                     if (typeof copy_id == 'object') {
120                                         if (copy_id == null) {
121                                             if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
122                                         } else {
123                                             copy_id = copy_id.id();
124                                         }
125                                     } else {
126                                         copy_id = row.my.acp.id();
127                                     }
128
129                                     obj.holds_map[ row.my.ahr.id() ] = blob;
130                                     params.treeitem_node.setAttribute('retrieve_id',
131                                         js2JSON({
132                                             'copy_id':copy_id,
133                                             'barcode':row.my.acp ? row.my.acp.barcode() : null,
134                                             'id':row.my.ahr.id(),
135                                             'type':row.my.ahr.hold_type(),
136                                             'target':row.my.ahr.target(),
137                                             'usr':row.my.ahr.usr()
138                                         })
139                                     );
140                                     if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
141
142                                 } catch(E) {
143                                     obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
144                                 }
145                             }
146                         );
147                     } catch(E) {
148                         obj.error.sdump('D_ERROR','retrieve_row: ' + E );
149                     }
150                     return row;
151                 },
152                 'on_select' : function(ev) {
153                     JSAN.use('util.functional');
154                     var sel = obj.list.retrieve_selection();
155                     obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
156                     obj.retrieve_ids = util.functional.map_list(
157                         sel,
158                         function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
159                     );
160                     if (obj.retrieve_ids.length > 0) {
161                         obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
162                         obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
163                         obj.controller.view.sel_copy_details.setAttribute('disabled','false');
164                         obj.controller.view.sel_patron.setAttribute('disabled','false');
165                         obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
166                         obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
167                         obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
168                         obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
169                         obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
170                         obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
171                         obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
172                         obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
173                         obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
174                         obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
175                         obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
176                         obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
177                         obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','false');
178                         if (obj.controller.view.cmd_alt_view.getAttribute('ready')=='true') {
179                             obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
180                         }
181                         obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
182                         obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
183                         obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
184                         obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
185                         obj.controller.view.cmd_show_catalog_holds.setAttribute('disabled','false');
186                     } else {
187                         obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
188                         obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
189                         obj.controller.view.sel_copy_details.setAttribute('disabled','true');
190                         obj.controller.view.sel_patron.setAttribute('disabled','true');
191                         obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
192                         obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
193                         obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
194                         obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
195                         obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
196                         obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
197                         obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
198                         obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
199                         obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
200                         obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
201                         obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
202                         obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
203                         obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
204                         obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','true');
205                         obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
206                         obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
207                         obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
208                         obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
209                         obj.controller.view.cmd_show_catalog_holds.setAttribute('disabled','true');
210                     }
211                 }
212             }
213         );
214
215         JSAN.use('util.controller'); obj.controller = new util.controller();
216         obj.controller.init(
217             {
218                 'control_map' : {
219                     'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
220                     'sel_clip' : [
221                         ['command'],
222                         function() { obj.list.clipboard(); }
223                     ],
224                     'cmd_broken' : [
225                         ['command'],
226                         function() { alert($("commonStrings").getString('common.unimplemented')); }
227                     ],
228                     'sel_patron' : [
229                         ['command'],
230                         function() {
231                             JSAN.use('circ.util');
232                             circ.util.show_last_few_circs(obj.retrieve_ids);
233                         }
234                     ],
235                     'alt_view_btn' : [
236                         ['render'],
237                         function(e) {
238                             return function() {
239                                 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
240                                 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
241                             };
242                         }
243                     ],
244                     'cmd_alt_view' : [
245                         ['command'],
246                         function(ev) {
247                             try {
248                                 var n = obj.controller.view.alt_view_btn;
249                                 if (n.getAttribute('toggle') == '1') {
250                                     document.getElementById('deck').selectedIndex = 0;
251                                     n.setAttribute('toggle','0');
252                                     n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
253                                     n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
254                                     obj.controller.view.save_columns.setAttribute('disabled','false');
255                                 } else {
256                                     document.getElementById('deck').selectedIndex = 1;
257                                     n.setAttribute('toggle','1');
258                                     n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
259                                     n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
260                                     if (obj.retrieve_ids.length == 0) return;
261                                     var f = obj.browser.get_content();
262                                     xulG.ahr_id = obj.retrieve_ids[0].id;
263                                     xulG.blob = obj.holds_map[ xulG.ahr_id ];
264                                     xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
265                                     xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
266                                     f.xulG = xulG;
267                                     f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
268                                     f.fetch_and_render_all(true);
269                                     obj.controller.view.save_columns.setAttribute('disabled','true');
270                                 }
271                             } catch(E) {
272                                 alert('Error in holds.js, cmd_alt_view handler: ' + E);
273                             }
274                         },
275                     ],
276                     'cmd_cancelled_holds_view' : [
277                         ['command'],
278                         function(ev) {
279                             document.getElementById('show_cancelled_deck').selectedIndex = 1;
280                             /* For some reason attribute propogation on the <command> element isn't working with hidden */
281                             document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
282                             document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
283                             document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
284                             document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
285                             obj.clear_and_retrieve();
286                         }
287                     ],
288                     'cmd_uncancelled_holds_view' : [
289                         ['command'],
290                         function(ev) {
291                             document.getElementById('show_cancelled_deck').selectedIndex = 0;
292                             /* For some reason attribute propogation on the <command> element isn't working with hidden */
293                             document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
294                             document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
295                             document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
296                             document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
297                             obj.clear_and_retrieve();
298                         }
299                     ],
300                     'sel_mark_items_damaged' : [
301                         ['command'],
302                         function() {
303                             JSAN.use('cat.util'); JSAN.use('util.functional');
304                             cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
305                         }
306                     ],
307                     'sel_mark_items_missing' : [
308                         ['command'],
309                         function() {
310                             JSAN.use('cat.util'); JSAN.use('util.functional');
311                             cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
312                         }
313                     ],
314                     'sel_copy_details' : [
315                         ['command'],
316                         function() {
317                             JSAN.use('circ.util');
318                             circ.util.item_details_new(
319                                 util.functional.map_list(
320                                     obj.retrieve_ids,
321                                     function(o) { return o.barcode; }
322                                 )
323                             );
324                         }
325                     ],
326                     'cmd_holds_print_full' : [
327                         ['command'],
328                         function() {
329                             var x_print_full_pull_list = document.getElementById('print_full_btn');
330                             try {
331                                 if (progressmeter) {
332                                     progressmeter.mode = 'undetermined';
333                                     progressmeter.hidden = false;
334                                     x_print_full_pull_list.disabled = true;
335                                 }
336                                 JSAN.use('util.print');
337                                 var print = new util.print('default');
338                                 var robj = fieldmapper.standardRequest(
339                                     [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
340                                     {   async: false,
341                                         timeout: 180,
342                                         params: [ses()],
343                                     }
344                                 );
345                                 if (robj != null) {
346                                     if (typeof robj.ilsevent != 'undefined') { throw(robj); }
347                                     print.simple( robj.template_output().data() );
348                                 }
349                             } catch(E) {
350                                 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
351                             }
352                             if (progressmeter) {
353                                 progressmeter.mode = 'determined';
354                                 progressmeter.hidden = true;
355                                 x_print_full_pull_list.disabled = false;
356                             }
357                         }
358                     ],
359                     'cmd_holds_print_alt' : [
360                         ['command'],
361                         function() {
362                             try {
363                                 var content_params = {
364                                     "session": ses(),
365                                     "authtime": ses("authtime"),
366                                     "no_xulG": false,
367                                     "show_nav_buttons": true,
368                                     "show_print_button": true
369                                 };
370                                 ["url_prefix", "new_tab", "set_tab",
371                                     "close_tab", "new_patron_tab",
372                                     "set_patron_tab", "volume_item_creator",
373                                     "get_new_session",
374                                     "holdings_maintenance_tab", "set_tab_name",
375                                     "open_chrome_window", "url_prefix",
376                                     "network_meter", "page_meter",
377                                     "set_statusbar", "set_help_context"
378                                 ].forEach(function(k) {
379                                     content_params[k] = xulG[k];
380                                 });
381
382                                 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
383                                     xulG.url_prefix("ALT_HOLDS_PRINT")
384                                 );
385                                 xulG.new_tab(
386                                     loc, {
387                                         "tab_name": "Printable Pull List", /* XXX i18n */
388                                         "browser": false
389                                     }, content_params
390                                 );
391                             } catch (E) {
392                                 g.error.sdump("D_ERROR", E);
393                             }
394                         }
395                     ],
396                     'cmd_simplified_pull_list' : [
397                         ['command'],
398                         function() {
399                             try {
400                                 var content_params = {
401                                     "session": ses(),
402                                     "authtime": ses("authtime"),
403                                     "no_xulG": false,
404                                     "show_nav_buttons": true,
405                                     "show_print_button": false
406                                 };
407                                 ["url_prefix", "new_tab", "set_tab",
408                                     "close_tab", "new_patron_tab",
409                                     "set_patron_tab", "volume_item_creator",
410                                     "get_new_session",
411                                     "holdings_maintenance_tab", "set_tab_name",
412                                     "open_chrome_window", "url_prefix",
413                                     "network_meter", "page_meter",
414                                     "set_statusbar", "set_help_context"
415                                 ].forEach(function(k) {
416                                     content_params[k] = xulG[k];
417                                 });
418
419                                 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
420                                     xulG.url_prefix("/eg/circ/hold_pull_list").replace("http:","https:")
421                                 );
422                                 xulG.new_tab(
423                                     loc, {
424                                         "tab_name": "Simplified Pull List", /* XXX i18n */
425                                         "browser": false,
426                                         "show_print_button": false
427                                     }, content_params
428                                 );
429                             } catch (E) {
430                                 g.error.sdump("D_ERROR", E);
431                             }
432                         }
433                     ],
434                     'cmd_holds_print' : [
435                         ['command'],
436                         function() {
437                             try {
438                                 JSAN.use('patron.util');
439                                 var params = {
440                                     'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id)
441                                 };
442                                 switch(obj.hold_interface_type) {
443                                     case 'patron':
444                                         params.template = 'holds_for_patron';
445                                     break;
446                                     case 'record':
447                                         params.template = 'holds_on_bib';
448                                     break;
449                                     case 'shelf':
450                                         params.template = 'holds_shelf';
451                                     break;
452                                     case 'pull':
453                                     default:
454                                         params.template = 'holds_pull_list';
455                                     break;
456                                 }
457                                 obj.list.print(params);
458                             } catch(E) {
459                                 obj.error.standard_unexpected_error_alert('print 1',E);
460                             }
461                         }
462                     ],
463                     'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
464                     'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
465                     'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
466
467                     'cmd_holds_edit_selection_depth' : [
468                         ['command'],
469                         function() {
470                             try {
471                                 JSAN.use('util.widgets'); JSAN.use('util.functional');
472                                 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
473                                 var list = util.functional.map_list(
474                                     util.functional.filter_list(
475                                         obj.data.list.aout,
476                                         function(o) {
477                                             if (o.depth() > ws_type.depth()) return false;
478                                             if (o.depth() < ws_type.depth()) return true;
479                                             return (o.id() == ws_type.id());
480                                         }
481                                     ),
482                                     function(o) {
483                                         return [
484                                             o.opac_label(),
485                                             o.id(),
486                                             false,
487                                             ( o.depth() * 2),
488                                         ];
489                                     }
490                                 );
491                                 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
492                                 ml.setAttribute('id','selection');
493                                 ml.setAttribute('name','fancy_data');
494                                 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
495                                 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
496                                 xml += util.widgets.serialize_node(ml);
497                                 xml += '</vbox>';
498                                 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
499                                 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
500                                 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
501                                 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
502                                 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
503                                 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
504                                 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
505                                 JSAN.use('util.window'); var win = new util.window();
506                                 var fancy_prompt_data = win.open(
507                                     urls.XUL_FANCY_PROMPT,
508                                     //+ '?xml_in_stash=temp_mid'
509                                     //+ '&bottom_xml_in_stash=temp_bot'
510                                     //+ '&title=' + window.escape('Choose a Pick Up Library'),
511                                     'fancy_prompt', 'chrome,resizable,modal',
512                                     { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
513                                 );
514                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
515                                 var selection = fancy_prompt_data.selection;
516
517                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
518                                 var msg = '';
519                                 if(obj.retrieve_ids.length > 1) {
520                                     msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
521                                 } else {
522                                     msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
523                                 }
524
525                                 var r = obj.error.yns_alert(msg,
526                                         $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
527                                         $("commonStrings").getString('common.yes'),
528                                         $("commonStrings").getString('common.no'),
529                                         null,
530                                         $("commonStrings").getString('common.check_to_confirm')
531                                 );
532                                 if (r == 0) {
533                                     circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
534                                 }
535                             } catch(E) {
536                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
537                             }
538                         }
539                     ],
540
541                     'cmd_holds_edit_pickup_lib' : [
542                         ['command'],
543                         function() {
544                             try {
545                                 JSAN.use('util.widgets'); JSAN.use('util.functional');
546
547                                 var list = util.functional.map_list(
548                                     obj.data.list.aou,
549                                     function(o) {
550                                         var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
551                                         return [
552                                             o.name() ? sname + ' ' + o.name() : o.shortname(),
553                                             o.id(),
554                                             ( !isTrue(obj.data.hash.aout[ o.ou_type() ].can_have_users()) ),
555                                             ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
556                                         ];
557                                     }
558                                 );
559                                 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
560                                 ml.setAttribute('id','lib');
561                                 ml.setAttribute('name','fancy_data');
562                                 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
563                                 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
564                                 xml += util.widgets.serialize_node(ml);
565                                 xml += '</vbox>';
566                                 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
567                                 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
568                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
569                                 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
570                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
571                                 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
572                                 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
573                                 JSAN.use('util.window'); var win = new util.window();
574                                 var fancy_prompt_data = win.open(
575                                     urls.XUL_FANCY_PROMPT,
576                                     //+ '?xml_in_stash=temp_mid'
577                                     //+ '&bottom_xml_in_stash=temp_bot'
578                                     //+ '&title=' + window.escape('Choose a Pick Up Library'),
579                                     'fancy_prompt', 'chrome,resizable,modal',
580                                     { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
581                                 );
582                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
583                                 var pickup_lib = fancy_prompt_data.lib;
584
585                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
586                                 var msg = '';
587                                 if(obj.retrieve_ids.length > 1) {
588                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.plural',[hold_list.join(', '), obj.data.hash.aou[pickup_lib].shortname()]);
589                                 } else {
590                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.singular',[hold_list.join(', '), obj.data.hash.aou[pickup_lib].shortname()]);
591                                 }
592                                 var r = obj.error.yns_alert(msg,
593                                         $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
594                                         $("commonStrings").getString('common.yes'),
595                                         $("commonStrings").getString('common.no'),
596                                         null,
597                                         $("commonStrings").getString('common.check_to_confirm')
598                                 );
599                                 if (r == 0) {
600                                     circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
601                                 }
602                             } catch(E) {
603                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
604                             }
605                         }
606                     ],
607                     'cmd_holds_edit_phone_notify' : [
608                         ['command'],
609                         function() {
610                             try {
611                                 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
612                                 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
613                                 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
614                                 xml += '</vbox>';
615                                 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
616                                 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
617                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
618                                 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
619                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
620                                 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
621                                 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
622                                 JSAN.use('util.window'); var win = new util.window();
623                                 var fancy_prompt_data = win.open(
624                                     urls.XUL_FANCY_PROMPT,
625                                     //+ '?xml_in_stash=temp_mid'
626                                     //+ '&bottom_xml_in_stash=temp_bot'
627                                     //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
628                                     //+ '&focus=phone',
629                                     'fancy_prompt', 'chrome,resizable,modal',
630                                     { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
631                                 );
632                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
633                                 var phone = fancy_prompt_data.phone;
634
635                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
636                                 var msg = '';
637                                 if(obj.retrieve_ids.length > 1) {
638                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
639                                 } else {
640                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
641                                 }
642                                 var r = obj.error.yns_alert(msg,
643                                         $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
644                                         $("commonStrings").getString('common.yes'),
645                                         $("commonStrings").getString('common.no'),
646                                         null,
647                                         $("commonStrings").getString('common.check_to_confirm')
648                                 );
649                                 if (r == 0) {
650                                     circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
651                                 }
652                             } catch(E) {
653                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
654                             }
655                         }
656                     ],
657
658                     'cmd_holds_edit_sms_notify' : [
659                         ['command'],
660                         function() {
661                             try {
662                                 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
663                                 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.new_phone_number')+'</description>';
664                                 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
665                                 xml += '</vbox>';
666                                 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
667                                 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_done.label')+'"';
668                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
669                                 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_cancel.label')+'"';
670                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
671                                 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
672                                 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
673                                 JSAN.use('util.window'); var win = new util.window();
674                                 var fancy_prompt_data = win.open(
675                                     urls.XUL_FANCY_PROMPT,
676                                     //+ '?xml_in_stash=temp_mid'
677                                     //+ '&bottom_xml_in_stash=temp_bot'
678                                     //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
679                                     //+ '&focus=phone',
680                                     'fancy_prompt', 'chrome,resizable,modal',
681                                     { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.choose_phone_number'), 'focus' : 'phone' }
682                                 );
683                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
684                                 var phone = fancy_prompt_data.phone;
685
686                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
687                                 var msg = '';
688                                 if(obj.retrieve_ids.length > 1) {
689                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
690                                 } else {
691                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
692                                 }
693                                 var r = obj.error.yns_alert(msg,
694                                         $("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.modifying_holds_title'),
695                                         $("commonStrings").getString('common.yes'),
696                                         $("commonStrings").getString('common.no'),
697                                         null,
698                                         $("commonStrings").getString('common.check_to_confirm')
699                                 );
700                                 if (r == 0) {
701                                     var hparams = {
702                                         'sms_notify' : phone == '' ? null : phone 
703                                     }
704                                     if (phone == '') {
705                                         hparams.sms_carrier = null;
706                                     }
707                                     circ.util.batch_hold_update(hold_list, hparams, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
708                                 }
709                             } catch(E) {
710                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
711                             }
712                         }
713                     ],
714
715                     'cmd_holds_edit_sms_carrier' : [
716                         ['command'],
717                         function() {
718                             try {
719                                 JSAN.use('util.widgets'); JSAN.use('util.functional');
720
721                                 var list = util.functional.map_list(
722                                     obj.data.list.csc,
723                                     function(o) {
724                                         return [
725                                             o.name() + ' (' + o.region() + ')',
726                                             o.id(),
727                                             ( !isTrue(o.active()) ),
728                                             0
729                                         ];
730                                     }
731                                 );
732                                 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
733                                 ml.setAttribute('id','carrier');
734                                 ml.setAttribute('name','fancy_data');
735                                 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
736                                 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.new_carrier')+'</description>';
737                                 xml += util.widgets.serialize_node(ml);
738                                 xml += '</vbox>';
739                                 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
740                                 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_done.label') +'"';
741                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_done.accesskey')+'" name="fancy_submit"/>';
742                                 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_cancel.label')+'"';
743                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
744                                 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
745                                 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
746                                 JSAN.use('util.window'); var win = new util.window();
747                                 var fancy_prompt_data = win.open(
748                                     urls.XUL_FANCY_PROMPT,
749                                     //+ '?xml_in_stash=temp_mid'
750                                     //+ '&bottom_xml_in_stash=temp_bot'
751                                     //+ '&title=' + window.escape('Choose a Pick Up Library'),
752                                     'fancy_prompt', 'chrome,resizable,modal',
753                                     { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.choose_carrier') }
754                                 );
755                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
756                                 var sms_carrier = fancy_prompt_data.carrier;
757
758                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
759                                 var msg = '';
760
761                                 if(obj.retrieve_ids.length > 1) {
762                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_carrier.confirm_carrier_change.plural',[hold_list.join(', '), obj.data.hash.csc[sms_carrier].name()]);
763                                 } else {
764                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_carrier.confirm_carrier_change.singular',[hold_list.join(', '), obj.data.hash.csc[sms_carrier].name()]);
765                                 }
766                                 var r = obj.error.yns_alert(msg,
767                                         $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.modifying_holds_title'),
768                                         $("commonStrings").getString('common.yes'),
769                                         $("commonStrings").getString('common.no'),
770                                         null,
771                                         $("commonStrings").getString('common.check_to_confirm')
772                                 );
773                                 if (r == 0) {
774                                     circ.util.batch_hold_update(hold_list, { 'sms_carrier' : sms_carrier }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
775                                 }
776                             } catch(E) {
777                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
778                             }
779                         }
780                     ],
781
782                     'cmd_holds_edit_email_notify' : [
783                         ['command'],
784                         function() {
785                             try {
786                                 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
787                                 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
788                                 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
789                                 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
790                                 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
791                                 xml += '  accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
792                                 xml += '</vbox>';
793                                 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
794                                 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
795                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
796                                 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
797                                 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
798                                 JSAN.use('util.window'); var win = new util.window();
799                                 var fancy_prompt_data = win.open(
800                                     urls.XUL_FANCY_PROMPT,
801                                     //+ '?xml_in_stash=temp_mid'
802                                     //+ '&bottom_xml_in_stash=temp_bot'
803                                     //+ '&title=' + window.escape('Set Email Notification for Holds'),
804                                     'fancy_prompt', 'chrome,resizable,modal',
805                                     { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
806                                 );
807                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
808                                 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
809
810                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
811                                 var msg = '';
812                                 if(get_bool(email)) {
813                                     if(obj.retrieve_ids.length > 1) {
814                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
815                                     } else {
816                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
817                                     }
818                                 } else {
819                                     if(obj.retrieve_ids.length > 1) {
820                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
821                                     } else {
822                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
823                                     }
824                                 }
825
826                                 var r = obj.error.yns_alert(msg,
827                                         $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
828                                         $("commonStrings").getString('common.yes'),
829                                         $("commonStrings").getString('common.no'),
830                                         null,
831                                         $("commonStrings").getString('common.check_to_confirm')
832                                 );
833                                 if (r == 0) {
834                                     circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
835                                 }
836                             } catch(E) {
837                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
838                             }
839                         }
840                     ],
841                     'cmd_holds_cut_in_line' : [
842                         ['command'],
843                         function() {
844                             try {
845                                 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
846                                 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
847                                 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
848                                 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
849                                 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
850                                 xml += '  accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
851                                 xml += '</vbox>';
852                                 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
853                                 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
854                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
855                                 JSAN.use('util.window'); var win = new util.window();
856                                 var fancy_prompt_data = win.open(
857                                     urls.XUL_FANCY_PROMPT,
858                                     'fancy_prompt', 'chrome,resizable,modal',
859                                     { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
860                                 );
861                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
862                                 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
863
864                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
865                                 var msg = '';
866                                 if(get_bool(cut)) {
867                                     if(obj.retrieve_ids.length > 1) {
868                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
869                                     } else {
870                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
871                                     }
872                                 } else {
873                                     if(obj.retrieve_ids.length > 1) {
874                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
875                                     } else {
876                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
877                                     }
878                                 }
879
880                                 var r = obj.error.yns_alert(msg,
881                                         $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
882                                         $("commonStrings").getString('common.yes'),
883                                         $("commonStrings").getString('common.no'),
884                                         null,
885                                         $("commonStrings").getString('common.check_to_confirm')
886                                 );
887                                 if (r == 0) {
888                                     circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
889                                 }
890                             } catch(E) {
891                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
892                             }
893                         }
894                     ],
895                     'cmd_holds_edit_desire_mint_condition' : [
896                         ['command'],
897                         function() {
898                             try {
899                                 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
900                                 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
901                                 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
902                                 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
903                                 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
904                                 xml += '  accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
905                                 xml += '</vbox>';
906                                 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
907                                 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
908                                 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
909                                 JSAN.use('util.window'); var win = new util.window();
910                                 var fancy_prompt_data = win.open(
911                                     urls.XUL_FANCY_PROMPT,
912                                     'fancy_prompt', 'chrome,resizable,modal',
913                                     { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
914                                 );
915                                 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
916                                 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
917
918                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
919                                 var msg = '';
920                                 if(get_bool(good)) {
921                                     if(obj.retrieve_ids.length > 1) {
922                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
923                                     } else {
924                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
925                                     }
926                                 } else {
927                                     if(obj.retrieve_ids.length > 1) {
928                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
929                                     } else {
930                                         msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
931                                     }
932                                 }
933
934                                 var r = obj.error.yns_alert(msg,
935                                         $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
936                                         $("commonStrings").getString('common.yes'),
937                                         $("commonStrings").getString('common.no'),
938                                         null,
939                                         $("commonStrings").getString('common.check_to_confirm')
940                                 );
941                                 if (r == 0) {
942                                     circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } });
943                                 }
944                             } catch(E) {
945                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
946                             }
947                         }
948                     ],
949
950
951                     'cmd_holds_suspend' : [
952                         ['command'],
953                         function() {
954                             try {
955                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
956                                 var r = obj.error.yns_alert(
957                                     obj.retrieve_ids.length > 1 ?
958                                     document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
959                                     document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
960                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
961                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
962                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
963                                     null,
964                                     document.getElementById('commonStrings').getString('common.confirm')
965                                 );
966                                 if (r == 0) {
967                                     var already_suspended = []; var filtered_hold_list = [];
968                                     for (var i = 0; i < obj.retrieve_ids.length; i++) {
969                                         var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
970                                         if ( get_bool( hold.frozen() ) ) {
971                                             already_suspended.push( hold.id() );
972                                             continue;
973                                         }
974                                         filtered_hold_list.push( hold.id() );
975                                     }
976                                     circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { 
977                                         if (already_suspended.length == 1) {
978                                             alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
979                                         } else if (already_suspended.length > 1) {
980                                             alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
981                                         }
982                                         obj.clear_and_retrieve(true); 
983                                     } });
984                                 }
985                             } catch(E) {
986                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
987                             }
988                         }
989                     ],
990                     'cmd_holds_activate' : [
991                         ['command'],
992                         function() {
993                             try {
994                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
995                                 var r = obj.error.yns_alert(
996                                     obj.retrieve_ids.length > 1 ?
997                                     document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
998                                     document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
999                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
1000                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
1001                                     document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
1002                                     null,
1003                                     document.getElementById('commonStrings').getString('common.confirm')
1004                                 );
1005                                 if (r == 0) {
1006                                     var already_activated = []; var filtered_hold_list = [];
1007                                     for (var i = 0; i < obj.retrieve_ids.length; i++) {
1008                                         var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
1009                                         if ( ! get_bool( hold.frozen() ) ) {
1010                                             already_activated.push( hold.id() );
1011                                             continue;
1012                                         }
1013                                         filtered_hold_list.push( hold.id() );
1014                                     }
1015                                     circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' :  function() { 
1016                                         if (already_activated.length == 1) {
1017                                             alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
1018                                         } else if (already_activated.length > 1) {
1019                                             alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
1020                                         }
1021                                         obj.clear_and_retrieve(true); 
1022                                     } });
1023                                 }
1024                             } catch(E) {
1025                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
1026                             }
1027                         }
1028                     ],
1029                     'cmd_holds_edit_thaw_date' : [
1030                         ['command'],
1031                         function() {
1032                             try {
1033                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1034                                 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
1035                                 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
1036                                 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1037                                 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1038                                 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
1039
1040                                 JSAN.use('util.window'); var win = new util.window();
1041                                 var my_xulG = win.open( 
1042                                     urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal', 
1043                                     { 
1044                                         'title' : title, 
1045                                         'description' : desc, 
1046                                         'msg' : msg, 
1047                                         'allow_unset' : true,
1048                                         'disallow_future_dates' : false,
1049                                         'disallow_past_dates' : true,
1050                                         'disallow_today' : true,
1051                                         'default_time' : '00:00:00',
1052                                         'time_readonly' : false
1053                                     }
1054                                 );
1055                                 if (my_xulG.complete) {
1056                                     circ.util.batch_hold_update(
1057                                         hold_list, 
1058                                         { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp }, 
1059                                         { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } }
1060                                     );
1061                                 }
1062                             } catch(E) {
1063                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1064                             }
1065                         }
1066                     ],
1067                     'cmd_holds_edit_expire_time' : [
1068                         ['command'],
1069                         function() {
1070                             try {
1071                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1072                                 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
1073                                 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
1074                                 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1075                                 var value = 'YYYY-MM-DD';
1076                                 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1077                                 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
1078
1079                                 JSAN.use('util.window'); var win = new util.window();
1080                                 var my_xulG = win.open( 
1081                                     urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal', 
1082                                     { 
1083                                         'title' : title, 
1084                                         'description' : desc, 
1085                                         'msg' : msg, 
1086                                         'allow_unset' : true,
1087                                         'disallow_future_dates' : false,
1088                                         'disallow_past_dates' : true,
1089                                         'disallow_today' : true,
1090                                         'default_time' : '00:00:00',
1091                                         'time_readonly' : false
1092                                     }
1093                                 );
1094                                 if (my_xulG.complete) {
1095                                     circ.util.batch_hold_update(
1096                                         hold_list, 
1097                                         { 'expire_time' : my_xulG.timestamp }, 
1098                                         { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } }
1099                                     );
1100                                 }
1101                             } catch(E) {
1102                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1103                             }
1104                         }
1105                     ],
1106                     'cmd_holds_edit_shelf_expire_time' : [
1107                         ['command'],
1108                         function() {
1109                             try {
1110                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1111                                 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
1112                                 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
1113                                 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1114                                 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1115                                 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
1116
1117                                 JSAN.use('util.window'); var win = new util.window();
1118                                 var my_xulG = win.open( 
1119                                     urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal', 
1120                                     { 
1121                                         'title' : title, 
1122                                         'description' : desc, 
1123                                         'msg' : msg, 
1124                                         'allow_unset' : false,
1125                                         'disallow_future_dates' : false,
1126                                         'disallow_past_dates' : false,
1127                                         'disallow_today' : false
1128                                     }
1129                                 );
1130                                 if (my_xulG.complete) {
1131                                     circ.util.batch_hold_update(
1132                                         hold_list, 
1133                                         { 'shelf_expire_time' : my_xulG.timestamp }, 
1134                                         { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } }
1135                                     );
1136                                 }
1137                             } catch(E) {
1138                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1139                             }
1140                         }
1141                     ],
1142                     'cmd_holds_edit_request_date' : [
1143                         ['command'],
1144                         function() {
1145                             try {
1146                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1147                                 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
1148                                 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
1149                                 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1150                                 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1151                                 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
1152
1153                                 JSAN.use('util.window'); var win = new util.window();
1154                                 var my_xulG = win.open( 
1155                                     urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal', 
1156                                     { 
1157                                         'title' : title, 
1158                                         'description' : desc, 
1159                                         'msg' : msg, 
1160                                         'allow_unset' : false,
1161                                         'disallow_future_dates' : true,
1162                                         'disallow_past_dates' : false,
1163                                         'disallow_today' : false
1164                                     }
1165                                 );
1166                                 if (my_xulG.complete) {
1167                                     circ.util.batch_hold_update(
1168                                         hold_list, 
1169                                         { 'request_time' : my_xulG.timestamp }, 
1170                                         { 'progressmeter' : progressmeter, 'oncomplete' :  function() { obj.clear_and_retrieve(true); } }
1171                                     );
1172                                 }
1173                             } catch(E) {
1174                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1175                             }
1176                         }
1177                     ],
1178                     'cmd_holds_retarget' : [
1179                         ['command'],
1180                         function() {
1181                             try {
1182                                 JSAN.use('util.functional');
1183
1184                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1185                                 var msg = '';
1186                                 if(obj.retrieve_ids.length > 1) {
1187                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
1188                                 } else {
1189                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
1190                                 }
1191                                 var r = obj.error.yns_alert(msg,
1192                                         $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
1193                                         $("commonStrings").getString('common.yes'),
1194                                         $("commonStrings").getString('common.no'),
1195                                         null,
1196                                         $("commonStrings").getString('common.check_to_confirm')
1197                                 );
1198                                 if (r == 0) {
1199                                     for (var i = 0; i < obj.retrieve_ids.length; i++) {
1200                                         var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
1201                                         if (typeof robj.ilsevent != 'undefined') throw(robj);
1202                                     }
1203                                     obj.clear_and_retrieve();
1204                                 }
1205                             } catch(E) {
1206                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
1207                             }
1208
1209                         }
1210                     ],
1211
1212                     'cmd_holds_cancel' : [
1213                         ['command'],
1214                         function() {
1215                             try {
1216                                 JSAN.use('util.functional');
1217
1218                                 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1219                                 var msg = '';
1220                                 if(obj.retrieve_ids.length > 1 ) {
1221                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
1222                                 } else {
1223                                     msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
1224                                 }
1225
1226                                 JSAN.use('util.window');
1227                                 var win = new util.window();
1228                                 var my_xulG = win.open(
1229                                     urls.XUL_HOLD_CANCEL,
1230                                     'hold_cancel',
1231                                     'chrome,resizable,modal',
1232                                     {}
1233                                 );
1234                                 /*var r = obj.error.yns_alert(msg,
1235                                         $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1236                                         $("commonStrings").getString('common.yes'),
1237                                         $("commonStrings").getString('common.no'),
1238                                         null,
1239                                         $("commonStrings").getString('common.check_to_confirm')
1240                                 );*/
1241
1242                                 if (my_xulG.proceed) { 
1243                                     var transits = [];
1244                                     for (var i = 0; i < obj.retrieve_ids.length; i++) {
1245                                         var transit = obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit();
1246                                         if (transit && ! transit.dest_recv_time() ) {
1247                                             transits.push( obj.retrieve_ids[i].barcode );
1248                                         }
1249                                         var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1250                                         if (typeof robj.ilsevent != 'undefined') throw(robj);
1251                                     }
1252                                     if (transits.length > 0) {
1253                                         var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1254                                         var r2 = obj.error.yns_alert(msg2,
1255                                             $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1256                                             $("commonStrings").getString('common.yes'),
1257                                             $("commonStrings").getString('common.no'),
1258                                             null,
1259                                             $("commonStrings").getString('common.check_to_confirm'));
1260                                         if (r2 == 0) {
1261                                             try {
1262                                                 for (var i = 0; i < transits.length; i++) {
1263                                                     var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1264                                                     if (typeof robj.ilsevent != 'undefined') {
1265                                                         switch(Number(robj.ilsevent)) {
1266                                                             case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1267                                                                 alert(robj.desc);
1268                                                             break;
1269                                                             case 5000 /* PERM_FAILURE */ :
1270                                                             break;
1271                                                             default:
1272                                                                 throw(robj);
1273                                                             break;
1274                                                         }
1275                                                     }
1276                                                 }
1277                                             } catch(E) {
1278                                                obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1279                                             }
1280                                         }
1281                                     }
1282                                     obj.clear_and_retrieve();
1283                                 }
1284                             } catch(E) {
1285                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1286                             }
1287                         }
1288                     ],
1289                     'cmd_holds_uncancel' : [
1290                         ['command'],
1291                         function() {
1292                             try {
1293                                 JSAN.use('util.functional');
1294                                 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1295                                     var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1296                                     if (typeof robj.ilsevent != 'undefined') throw(robj);
1297                                 }
1298                                 obj.clear_and_retrieve();
1299                             } catch(E) {
1300                                 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1301                             }
1302                         }
1303                     ],
1304
1305                     'cmd_retrieve_patron' : [
1306                         ['command'],
1307                         function() {
1308                             try {
1309                                 var seen = {};
1310                                 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1311                                     var patron_id = obj.retrieve_ids[i].usr;
1312                                     if (seen[patron_id]) continue; seen[patron_id] = true;
1313                                     xulG.new_patron_tab(
1314                                         {},
1315                                         { 'id' : patron_id }
1316                                     );
1317                                 }
1318                             } catch(E) {
1319                                 obj.error.standard_unexpected_error_alert('',E);
1320                             }
1321                         }
1322                     ],
1323                     'cmd_show_catalog' : [
1324                         ['command'],
1325                         function() {
1326                             obj.show_catalog_impl();
1327                         }
1328                     ],
1329                     'cmd_show_catalog_holds' : [
1330                         ['command'],
1331                         function() {
1332                             obj.show_catalog_impl('hold_browser');
1333                         }
1334                     ],
1335                     'cmd_holds_title_transfer' : [
1336                         ['command'],
1337                         function() {
1338                             try {
1339                                 var hids = [];
1340                                 var unique_targets = [];
1341                                 var seen_target = {};
1342                                 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1343                                     var hid = obj.retrieve_ids[i].id;
1344                                     var htarget = obj.retrieve_ids[i].id;
1345                                     var htype = obj.retrieve_ids[i].type;
1346                                     switch(htype) {
1347                                         case 'M' :
1348                                             continue; // not supported
1349                                         break;
1350                                         case 'T' :
1351                                             hids.push( hid );
1352                                             if (! seen_target[htarget]) {
1353                                                 unique_targets.push( htarget );
1354                                                 seen_target[htarget] = 1;
1355                                             }
1356                                         break;
1357                                         case 'V' :
1358                                             continue; // not supported
1359                                         break;
1360                                         case 'C' :
1361                                             continue; // not supported
1362                                         break;
1363                                         default:
1364                                             continue; // not supported
1365                                         break;
1366                                     }
1367                                 }
1368                                 JSAN.use('cat.util');
1369                                 cat.util.transfer_specific_title_holds(hids,unique_targets);
1370                                 obj.clear_and_retrieve();
1371                             } catch(E) {
1372                                 obj.error.standard_unexpected_error_alert('',E);
1373                             }
1374                         }
1375                     ],
1376
1377                     'fetch_more' : [
1378                         ['command'],
1379                         function() {
1380                             obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1381                             obj.retrieve(true);
1382                         }
1383                     ],
1384                     'lib_filter_checkbox' : [
1385                         ['command'],
1386                         function(ev) {
1387                             var x_lib_type_menu = document.getElementById('lib_type_menu');
1388                             if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1389                             if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1390                             obj.clear_and_retrieve();
1391                             ev.target.setAttribute('checked',ev.target.checked);
1392                         }
1393                     ],
1394                     'cmd_view_expired_onshelf_holds' : [
1395                         ['command'],
1396                         function(ev) {
1397                             var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1398                             obj.expired = x.checked;
1399                             obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1400                             obj.clear_and_retrieve();
1401                         }
1402                     ],
1403                     'cmd_clear_expired_onshelf_holds' : [
1404                         ['command'],
1405                         function(ev) {
1406                             obj.cmd_clear_expired_onshelf_holds();
1407                         }
1408                     ],
1409                     'cmd_search_opac' : [
1410                         ['command'],
1411                         function(ev) {
1412                             try {
1413                                 var content_params = {
1414                                     'show_nav_buttons' : true,
1415                                     'show_print_button' : true,
1416                                     'passthru_content_params' : {
1417                                         'authtoken' : ses(),
1418                                         'authtime' : ses('authtime'),
1419                                         'window_open' : function(a,b,c) {
1420                                             try {
1421                                                 return window.open(a,b,c);
1422                                             } catch(E) {
1423                                                 obj.error.standard_unexpected_error_alert('window_open',E);
1424                                             }
1425                                         },
1426                                         'opac_hold_placed' : function(hold) {
1427                                             try {
1428                                                 var hold_id = typeof hold == 'object' ? hold.id() : hold;
1429                                                 obj.list.append(
1430                                                     {
1431                                                         'row' : {
1432                                                             'my' : {
1433                                                                 'hold_id' : hold_id
1434                                                             }
1435                                                         }
1436                                                     }
1437                                                 );
1438                                                 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1439                                                     window.xulG.on_list_change(); 
1440                                                 }
1441                                                 obj.list.wrap_in_full_retrieve(
1442                                                     function() {
1443                                                         try {
1444                                                             obj.error.work_log(
1445                                                                 $('offlineStrings').getFormattedString(
1446                                                                     'staff.circ.work_log_hold_placed.message',
1447                                                                     [
1448                                                                         ses('staff_usrname'),
1449                                                                         obj.holds_map[ hold_id ].patron_last,
1450                                                                         obj.holds_map[ hold_id ].patron_barcode,
1451                                                                         hold_id,
1452                                                                         obj.holds_map[ hold_id ].hold.hold_type()
1453                                                                     ]
1454                                                                 ), {
1455                                                                     'au_id' : obj.holds_map[ hold_id ].hold.usr(),
1456                                                                     'au_family_name' : obj.holds_map[ hold_id ].patron_family_name,
1457                                                                     'au_barcode' : obj.holds_map[ hold_id ].patron_barcode
1458                                                                 }
1459                                                             );
1460                                                         } catch(F) {
1461                                                             obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(), work_log: ',F);
1462                                                         }
1463                                                     }
1464                                                 );
1465                                             } catch(E) {
1466                                                 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1467                                             }
1468                                         },
1469                                         'get_barcode' : xulG.get_barcode,
1470                                         'get_barcode_and_settings' : xulG.get_barcode_and_settings,
1471                                         'patron_barcode' : obj.patron_barcode
1472                                     },
1473                                     'url_prefix' : xulG.url_prefix,
1474                                     'url' : xulG.url_prefix('browser')
1475                                 };
1476                                 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1477                             } catch(E) {
1478                                 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1479                             }
1480
1481                         }
1482                     ]
1483                 }
1484             }
1485         );
1486
1487         obj.determine_hold_interface_type();
1488         var x_fetch_more = document.getElementById('fetch_more');
1489         var x_lib_type_menu = document.getElementById('lib_type_menu');
1490         var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1491         var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1492         var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1493         var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1494         var x_expired_checkbox = document.getElementById('expired_checkbox');
1495         var x_print_full_pull_list = document.getElementById('print_full_btn');
1496         var x_print_full_pull_list_alt = document.getElementById('print_alt_btn');
1497         var x_simplified_pull_list = document.getElementById('simplified_pull_list_btn');
1498         switch(obj.hold_interface_type) {
1499             case 'shelf':
1500                 obj.render_lib_menus({'pickup_lib':true});
1501                 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1502                 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1503                 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1504                 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1505                 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1506                 if (x_simplified_pull_list) x_simplified_pull_list.hidden = true;
1507             break;
1508             case 'pull' :
1509                 if (x_fetch_more) x_fetch_more.hidden = false;
1510                 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1511                 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = false;
1512                 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1513                 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1514                 if (x_simplified_pull_list) x_simplified_pull_list.hidden = false;
1515             break;
1516             case 'record' :
1517                 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1518                 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1519                 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1520                 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1521                 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1522                 if (x_simplified_pull_list) x_simplified_pull_list.hidden = true;
1523             break;
1524             default:
1525                 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1526                 if (x_fetch_more) x_fetch_more.hidden = true;
1527                 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1528                 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1529                 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1530                 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1531                 if (x_simplified_pull_list) x_simplified_pull_list.hidden = true;
1532             break;
1533         }
1534         setTimeout( // We do this because render_lib_menus above creates and appends a DOM node, but until this thread exits, it doesn't really happen
1535             function() {
1536                 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1537                     if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1538                     if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1539                 }
1540                 obj.controller.render();
1541                 if (params['clear']) {
1542                     JSAN.use('util.widgets');
1543                     var x = document.getElementById('expired_checkbox');
1544                     x.checked = true;
1545                     obj.expired = true;
1546                     util.widgets.dispatch('command','cmd_clear_expired_onshelf_holds');
1547                 } else {
1548                     obj.retrieve(true);
1549                 }
1550
1551                 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1552                 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1553                 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1554                 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1555                 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1556                 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1557                 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1558                 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1559                 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1560                 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1561                 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1562                 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1563                 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1564                 obj.controller.view.cmd_show_catalog_holds.setAttribute('disabled','true');
1565             }, 0
1566         );
1567
1568         $('cmd_alt_view').setAttribute('disabled','true');
1569         xulG.when_done = function() {
1570             $('cmd_alt_view').setAttribute('ready','true');
1571             if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1572                 $('cmd_alt_view').setAttribute('disabled','false');
1573             }
1574             dump('hold details UI ready\n');
1575         }
1576         JSAN.use('util.browser');
1577         obj.browser = new util.browser();
1578         obj.browser.init(
1579             {
1580                 'url' : urls.XUL_HOLD_DETAILS,
1581                 'push_xulG' : true,
1582                 'alt_print' : false,
1583                 'browser_id' : 'hold_detail_frame',
1584                 'passthru_content_params' : xulG
1585             }
1586         );
1587
1588     },
1589
1590     'cleanup' : function() {
1591         var obj = this;
1592         obj.controller.cleanup();
1593         obj.list.cleanup();
1594         obj.list.clear();
1595         obj.event_listeners.removeAll();
1596     },
1597
1598     'determine_hold_interface_type' : function() {
1599         var obj = this;
1600         if (obj.patron_id) { /*************************************************** PATRON ******************************/
1601             obj.hold_interface_type = 'patron';
1602         } else if (obj.docid) { /*************************************************** RECORD ******************************/
1603             obj.hold_interface_type = 'record';
1604         } else if (obj.pull) { /*************************************************** PULL ******************************/
1605             obj.hold_interface_type = 'pull';
1606         } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1607             obj.hold_interface_type = 'shelf';
1608         } else { /*************************************************** PULL ******************************/
1609             obj.hold_interface_type = 'pull';
1610         }
1611         if(obj.hold_interface_type != 'patron') {
1612             var disableItems = document.getElementsByAttribute('command','cmd_show_catalog_holds');
1613             for(var i = 0; i < disableItems.length; i++)
1614                 disableItems.item(i).style.display='none';
1615         }
1616     },
1617
1618     'show_catalog_impl' : function(default_view) {
1619         var obj = this;
1620         try {
1621             for (var i = 0; i < obj.retrieve_ids.length; i++) {
1622                 var htarget = obj.retrieve_ids[i].target;
1623                 var htype = obj.retrieve_ids[i].type;
1624                 var opac_url;
1625                 switch(htype) {
1626                     case 'M' :
1627                         opac_url = xulG.url_prefix('opac_rresult_metarecord') + htarget;
1628                     break;
1629                     case 'T' :
1630                         opac_url = xulG.url_prefix('opac_rdetail') + htarget;
1631                     break;
1632                     case 'P' :
1633                         opac_url = xulG.url_prefix('opac_rdetail')
1634                         + obj.hold_part_map[ obj.retrieve_ids[i].id ].record();
1635                     break;
1636                     case 'I' :
1637                         opac_url = xulG.url_prefix('opac_rdetail')
1638                         + obj.hold_subscription_map[ obj.retrieve_ids[i].id ].record_entry();
1639                     break;
1640                     case 'V' :
1641                         var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1642                         opac_url = xulG.url_prefix('opac_rdetail') + my_acn.record();
1643                     break;
1644                     case 'C' :
1645                     case 'R' :
1646                     case 'F' :
1647                         var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1648                         var my_acn;
1649                         if (typeof my_acp.call_number() == 'object') {
1650                             my_acn = my.acp.call_number();
1651                         } else {
1652                             my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1653                                 [ my_acp.call_number() ]);
1654                         }
1655                         opac_url = xulG.url_prefix('opac_rdetail') + my_acn.record();
1656                     break;
1657                     default:
1658                         obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1659                         continue;
1660                     break;
1661                 }
1662                 var content_params = {
1663                     'session' : ses(),
1664                     'authtime' : ses('authtime'),
1665                     'opac_url' : opac_url
1666                 };
1667                 if(default_view)
1668                     content_params['default_view'] = default_view;
1669                 xulG.new_tab(
1670                     xulG.url_prefix('XUL_OPAC_WRAPPER'),
1671                     {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1672                     content_params
1673                 );
1674             }
1675         } catch(E) {
1676             obj.error.standard_unexpected_error_alert('',E);
1677         }
1678     },
1679
1680     'clear_and_retrieve' : function() {
1681         try {
1682             this.list.clear();
1683             this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1684             this.retrieve();
1685             if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1686                 window.xulG.on_list_change(); 
1687             }
1688         } catch(E) {
1689             this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1690         }
1691     },
1692
1693     'retrieve' : function() {
1694         var obj = this; var holds = [];
1695         if (window.xulG && window.xulG.holds) {
1696             holds = window.xulG.holds;
1697         } else {
1698             var method; var params = [ ses() ];
1699             switch(obj.hold_interface_type) {
1700                 case 'patron' :
1701                     if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1702                         method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1703                     } else {
1704                         method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1705                     }
1706                     params.push( obj.patron_id );
1707                     obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1708                 break;
1709                 case 'record' :
1710                     method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1711                     params.push( obj.docid );
1712                     var x_lib_filter = document.getElementById('lib_filter_checkbox');
1713                     var x_lib_type_menu = document.getElementById('lib_type_menu');
1714                     if (x_lib_filter) {
1715                         if (x_lib_filter.checked) {
1716                             if (x_lib_type_menu && obj.controller.view.lib_menu) {
1717                                 var x = {};
1718                                 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1719                                 params.push( x );
1720                             }
1721                         }
1722                     }
1723                     obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1724                 break;
1725                 case 'shelf' :
1726                     if (obj.expired) {
1727                         method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1728                     } else {
1729                         method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1730                     }
1731                     params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1732                     obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1733                 break;
1734                 case 'pull' :
1735                 default:
1736                     method = 'FM_AHR_ID_LIST_PULL_LIST';
1737                     params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1738                     var x = document.getElementById('hold_count');
1739                     if (x) {
1740                         obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1741                             var count = req.getResultObject();
1742                             if (typeof count.ilsevent == 'undefined' && count != null) {
1743                                 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1744                                     'staff.patron.holds.total_count',
1745                                     [ count ]
1746                                 ));
1747                                 x.hidden = false;
1748                             }
1749                         });
1750                     }
1751                 break;
1752             }
1753             var robj = obj.network.simple_request( method, params );
1754             if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1755             if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1756                 holds = [];
1757                 if (robj != null) {
1758                     holds = holds.concat( robj.copy_holds );
1759                     holds = holds.concat( robj.recall_holds );
1760                     holds = holds.concat( robj.force_holds );
1761                     holds = holds.concat( robj.volume_holds );
1762                     holds = holds.concat( robj.title_holds );
1763                     holds = holds.concat( robj.part_holds );
1764                     holds = holds.concat( robj.issuance_holds );
1765                     holds = holds.concat( robj.metarecord_holds );
1766                     holds = holds.sort();
1767                 }
1768             } else {
1769                 if (robj == null ) {
1770                     holds = [];
1771                 } else {
1772                     if (typeof robj.length == 'undefined') {
1773                         holds = [ robj ];
1774                     } else {
1775                         holds = robj;
1776                     }
1777                 }
1778             }
1779             holds.reverse();
1780             //alert('method = ' + method + ' params = ' + js2JSON(params));
1781         }
1782
1783         var x_fetch_more = document.getElementById('fetch_more');
1784         if (holds.length == 0) {
1785             if (x_fetch_more) x_fetch_more.disabled = true;
1786         } else {
1787             if (x_fetch_more) x_fetch_more.disabled = false;
1788             obj.render(holds);
1789         }
1790
1791     },
1792
1793     'render' : function(holds) {
1794         try {
1795             var obj = this;
1796
1797             function list_append(hold_id) {
1798                 obj.list.append(
1799                     {
1800                         'row' : {
1801                             'my' : {
1802                                 'hold_id' : hold_id,
1803                                 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1804                             }
1805                         },
1806                         'to_bottom' : true
1807                     }
1808                 );
1809             }
1810
1811             function gen_list_append(hold) {
1812                 return function() {
1813                     if (typeof obj.controller.view.lib_menu == 'undefined') {
1814                         list_append(typeof hold == 'object' ? hold.id() : hold);
1815                     } else {
1816                         list_append(typeof hold == 'object' ? hold.id() : hold);
1817                     }
1818                 };
1819             }
1820
1821             //obj.list.clear();
1822
1823             JSAN.use('util.exec'); var exec = new util.exec(2);
1824             var rows = [];
1825             for (var i in holds) {
1826                 rows.push( gen_list_append(holds[i]) );
1827             }
1828             exec.chain( rows );
1829
1830         } catch(E) {
1831             this.error.standard_unexpected_error_alert('holds.js, render():',E);
1832         }
1833     },
1834
1835     'render_lib_menus' : function(types) {
1836         try {
1837             var obj = this;
1838             JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1839
1840             var x = document.getElementById('lib_type_menu');
1841             if (types) {
1842                 var nodes = x.firstChild.childNodes;
1843                 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1844                 for (var i in types) document.getElementById(i).hidden = false;
1845             }
1846             x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1847
1848             x = document.getElementById('lib_menu_placeholder');
1849             util.widgets.remove_children( x );
1850
1851             JSAN.use('util.file');
1852             var file = new util.file('offline_ou_list');
1853             if (file._file.exists()) {
1854                 var list_data = file.get_object(); file.close();
1855                 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1856                 ml.setAttribute('id','lib_menu');
1857                 x.appendChild( ml );
1858                 obj.event_listeners.add(ml, 
1859                     'command',
1860                     function(ev) {
1861                         obj.filter_lib = ev.target.value;
1862                         obj.clear_and_retrieve();
1863                     },
1864                     false
1865                 );
1866                 obj.controller.view.lib_menu = ml;
1867             } else {
1868                 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1869             }
1870
1871         } catch(E) {
1872             this.error.standard_unexpected_error_alert('rendering lib menu',E);
1873         }
1874     },
1875
1876     'cmd_clear_expired_onshelf_holds' : function() {
1877         var obj = this;
1878         try {
1879             // Disable anything such as filters that can have us accidentally
1880             // lose these non-repeatable results.  Well, now that they're cached
1881             // it's less of an issue.
1882             if ($('lib_filter_checkbox')) {
1883                 $('lib_filter_checkbox').checked = false;
1884             }
1885             if ($('lib_type_menu')) {
1886                 $('lib_type_menu').disabled = true;
1887             }
1888             if ($('lib_menu_placeholder')) {
1889                 $('lib_menu_placeholder').firstChild.disabled = true;
1890             }
1891             obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute(
1892                 'disabled', 'true');
1893             obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute(
1894                 'disabled', 'true');
1895
1896             // I could put this with the "retrieval" methods, but since it has
1897             // side effects, seems cleaner to invoke it here
1898             var robj = obj.network.simple_request(
1899                 'CLEAR_HOLD_SHELF',
1900                 [
1901                     ses(),
1902                     obj.filter_lib || obj.data.list.au[0].ws_ou()
1903                 ]
1904             );
1905             if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1906
1907             var cache_key;
1908             if (typeof robj.cache_key != 'undefined') {
1909                 cache_key = robj.cache_key;
1910             } else {
1911                 if (robj.constructor == Array) {
1912                     for (var i = 0; i < robj.length; i++) {
1913                         if (typeof robj[i].cache_key != 'undefined') {
1914                             cache_key = robj[i].cache_key;
1915                         }
1916                     }
1917                 }
1918             }
1919
1920             if (!cache_key) { throw(robj); }
1921
1922             // id's in xulG.holds will prevent the normal retrieval method from
1923             // firing.  Let's put our affected hold.id's in here:
1924             xulG.holds = [];
1925
1926             // Start the progress meter
1927             $('progress').value = 0;
1928             $('progress').hidden = false;
1929
1930             // Fetch the affected holds
1931             fieldmapper.standardRequest(
1932                 [ 'open-ils.circ', 'open-ils.circ.hold.clear_shelf.get_cache' ],
1933                 {
1934                     'async' : true,
1935                     'params' : [ ses(), cache_key ],
1936                     'onresponse' : function(r) {
1937                         dojo.forEach(
1938                             openils.Util.readResponse(r),
1939                             function(resp) {
1940                                 if (resp.maximum) {
1941                                     $('progress').value = Number(resp.progress)
1942                                         * 100/resp.maximum;
1943                                     return;
1944                                 }
1945                                 obj.post_clear_shelf_hold_action_map[
1946                                     resp.hold_details.id
1947                                 ] = resp.action;
1948                                 xulG.holds.push( resp.hold_details.id );
1949                             }
1950                         )
1951                     },
1952                     'oncomplete' : function() {
1953                         obj.clear_and_retrieve();
1954                         $('progress').hidden = true;
1955                     }
1956                 }
1957             );
1958
1959         } catch(E) {
1960             if (E.ilsevent == 5000 /* PERM_FAILURE */ ) {
1961                 return; /* handled by network.js */
1962             }
1963             obj.error.standard_unexpected_error_alert(
1964                 'Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1965         }
1966     }
1967 }
1968
1969 dump('exiting patron.holds.js\n');