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