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