1 dump('entering patron.holds.js\n');
3 function $(id) { return document.getElementById(id); }
5 if (typeof patron == 'undefined') patron = {};
6 patron.holds = function (params) {
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'});
13 patron.holds.prototype = {
15 'hold_interface_type' : null,
17 'pull_from_shelf_interface' : {
18 '_default' : { 'limit' : 100, 'offset' : 0 },
19 'current' : { 'limit' : 100, 'offset' : 0 }
25 'post_clear_shelf_hold_action_map' : {},
31 'flatten_copy' : function(hold) {
32 try { if ( hold.current_copy() && typeof hold.current_copy() == 'object') hold.current_copy( hold.current_copy().id() ); } catch(E) { alert('FIXME: Error flattening hold before hold update: ' + E); }
36 'init' : function( params ) {
40 obj.patron_id = params['patron_id'];
41 obj.patron_barcode = params['patron_barcode'];
42 obj.docid = params['docid'];
43 obj.shelf = params['shelf'];
44 obj.tree_id = params['tree_id'];
46 var progressmeter = document.getElementById('progress');
48 JSAN.use('circ.util');
49 var columns = circ.util.hold_columns(
51 'title' : { 'hidden' : false, 'flex' : '3' },
52 'request_time' : { 'hidden' : false },
53 'pickup_lib_shortname' : { 'hidden' : false },
54 'hold_type' : { 'hidden' : false },
55 'current_copy' : { 'hidden' : false },
56 'capture_time' : { 'hidden' : false },
57 'notify_time' : { 'hidden' : false },
58 'notify_count' : { 'hidden' : false },
59 'cancel_cause' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
60 'cancel_note' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
61 'cancel_time' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
62 'post_clear_shelf_action' : { 'hidden' : obj.shelf ? false : true }
66 JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
70 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
71 'retrieve_row' : function(params) {
74 obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
77 var blob = blob_req.getResultObject();
78 if (typeof blob.ilsevent != 'undefined') throw(blob);
79 row.my.ahr = blob.hold;
80 row.my.status = blob.status;
81 row.my.ahr.status( blob.status );
82 row.my.acp = blob.copy;
83 row.my.acn = blob.volume;
84 row.my.mvr = blob.mvr;
85 row.my.patron_family_name = blob.patron_last;
86 row.my.patron_first_given_name = blob.patron_first;
87 row.my.patron_barcode = blob.patron_barcode;
88 row.my.total_holds = blob.total_holds;
89 row.my.queue_position = blob.queue_position;
90 row.my.potential_copies = blob.potential_copies;
91 row.my.estimated_wait = blob.estimated_wait;
92 row.my.ahrn_count = blob.hold.notes().length;
94 var copy_id = row.my.ahr.current_copy();
95 if (typeof copy_id == 'object') {
96 if (copy_id == null) {
97 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
99 copy_id = copy_id.id();
102 copy_id = row.my.acp.id();
105 obj.holds_map[ row.my.ahr.id() ] = blob;
106 params.row_node.setAttribute('retrieve_id',
109 'barcode':row.my.acp ? row.my.acp.barcode() : null,
110 'id':row.my.ahr.id(),
111 'type':row.my.ahr.hold_type(),
112 'target':row.my.ahr.target(),
113 'usr':row.my.ahr.usr()
116 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
119 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
124 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
128 'on_select' : function(ev) {
129 JSAN.use('util.functional');
130 var sel = obj.list.retrieve_selection();
131 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
132 obj.retrieve_ids = util.functional.map_list(
134 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
136 if (obj.retrieve_ids.length > 0) {
137 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
138 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
139 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
140 obj.controller.view.sel_patron.setAttribute('disabled','false');
141 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
142 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
143 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
144 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
145 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
146 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
147 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
148 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
149 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
150 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
151 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
152 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
153 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
154 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
155 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
156 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
157 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
159 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
160 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
161 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
162 obj.controller.view.sel_patron.setAttribute('disabled','true');
163 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
164 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
165 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
166 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
167 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
168 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
169 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
170 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
171 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
172 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
173 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
174 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
175 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
176 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
177 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
178 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
179 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
185 JSAN.use('util.controller'); obj.controller = new util.controller();
189 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
192 function() { obj.list.clipboard(); }
196 function() { alert($("commonStrings").getString('common.unimplemented')); }
201 JSAN.use('circ.util');
202 circ.util.show_last_few_circs(obj.retrieve_ids);
208 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
209 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
216 var n = obj.controller.view.alt_view_btn;
217 if (n.getAttribute('toggle') == '1') {
218 document.getElementById('deck').selectedIndex = 0;
219 n.setAttribute('toggle','0');
220 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
221 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
223 document.getElementById('deck').selectedIndex = 1;
224 n.setAttribute('toggle','1');
225 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
226 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
227 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
228 if (obj.retrieve_ids.length == 0) return;
229 var f = obj.browser.get_content();
230 xulG.ahr_id = obj.retrieve_ids[0].id;
231 xulG.blob = obj.holds_map[ xulG.ahr_id ];
232 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
233 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
235 f.fetch_and_render_all();
238 alert('Error in holds.js, cmd_alt_view handler: ' + E);
242 'cmd_cancelled_holds_view' : [
245 document.getElementById('show_cancelled_deck').selectedIndex = 1;
246 /* For some reason attribute propogation on the <command> element isn't working with hidden */
247 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
248 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
249 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
250 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
251 obj.clear_and_retrieve();
254 'cmd_uncancelled_holds_view' : [
257 document.getElementById('show_cancelled_deck').selectedIndex = 0;
258 /* For some reason attribute propogation on the <command> element isn't working with hidden */
259 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
260 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
261 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
262 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
263 obj.clear_and_retrieve();
266 'sel_mark_items_damaged' : [
269 JSAN.use('cat.util'); JSAN.use('util.functional');
270 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
273 'sel_mark_items_missing' : [
276 JSAN.use('cat.util'); JSAN.use('util.functional');
277 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
280 'sel_copy_details' : [
283 JSAN.use('circ.util');
284 circ.util.item_details_new(
285 util.functional.map_list(
287 function(o) { return o.barcode; }
292 'cmd_holds_print_full' : [
295 var x_print_full_pull_list = document.getElementById('print_full_btn');
298 progressmeter.mode = 'undetermined';
299 progressmeter.hidden = false;
300 x_print_full_pull_list.disabled = true;
302 JSAN.use('util.print');
303 var print = new util.print('default');
304 var robj = obj.network.simple_request('HTML_HOLD_PULL_LIST',[ses()]);
305 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
306 print.simple( robj.template_output().data() );
308 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
311 progressmeter.mode = 'determined';
312 progressmeter.hidden = true;
313 x_print_full_pull_list.disabled = false;
317 'cmd_holds_print' : [
321 JSAN.use('patron.util');
323 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
326 obj.list.print(params);
328 obj.error.standard_unexpected_error_alert('print 1',E);
332 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
333 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
334 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
336 'cmd_holds_edit_selection_depth' : [
340 JSAN.use('util.widgets'); JSAN.use('util.functional');
341 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
342 var list = util.functional.map_list(
343 util.functional.filter_list(
346 if (o.depth() > ws_type.depth()) return false;
347 if (o.depth() < ws_type.depth()) return true;
348 return (o.id() == ws_type.id());
360 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
361 ml.setAttribute('id','selection');
362 ml.setAttribute('name','fancy_data');
363 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
364 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
365 xml += util.widgets.serialize_node(ml);
367 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
368 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
369 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
370 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
371 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
372 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
373 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
374 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
375 JSAN.use('util.window'); var win = new util.window();
376 var fancy_prompt_data = win.open(
377 urls.XUL_FANCY_PROMPT,
378 //+ '?xml_in_stash=temp_mid'
379 //+ '&bottom_xml_in_stash=temp_bot'
380 //+ '&title=' + window.escape('Choose a Pick Up Library'),
381 'fancy_prompt', 'chrome,resizable,modal',
382 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
384 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
385 var selection = fancy_prompt_data.selection;
387 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
389 if(obj.retrieve_ids.length > 1) {
390 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
392 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
395 var r = obj.error.yns_alert(msg,
396 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
397 $("commonStrings").getString('common.yes'),
398 $("commonStrings").getString('common.no'),
400 $("commonStrings").getString('common.check_to_confirm')
403 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
406 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
411 'cmd_holds_edit_pickup_lib' : [
415 JSAN.use('util.widgets'); JSAN.use('util.functional');
417 var list = util.functional.map_list(
420 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
422 o.name() ? sname + ' ' + o.name() : o.shortname(),
424 ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
425 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
429 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
430 ml.setAttribute('id','lib');
431 ml.setAttribute('name','fancy_data');
432 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
433 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
434 xml += util.widgets.serialize_node(ml);
436 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
437 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
438 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
439 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
440 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
441 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
442 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
443 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
444 JSAN.use('util.window'); var win = new util.window();
445 var fancy_prompt_data = win.open(
446 urls.XUL_FANCY_PROMPT,
447 //+ '?xml_in_stash=temp_mid'
448 //+ '&bottom_xml_in_stash=temp_bot'
449 //+ '&title=' + window.escape('Choose a Pick Up Library'),
450 'fancy_prompt', 'chrome,resizable,modal',
451 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
453 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
454 var pickup_lib = fancy_prompt_data.lib;
456 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
458 if(obj.retrieve_ids.length > 1) {
459 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()]);
461 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()]);
463 var r = obj.error.yns_alert(msg,
464 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
465 $("commonStrings").getString('common.yes'),
466 $("commonStrings").getString('common.no'),
468 $("commonStrings").getString('common.check_to_confirm')
471 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
474 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
478 'cmd_holds_edit_phone_notify' : [
482 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
483 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
484 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
486 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
487 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
488 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
489 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
490 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
491 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
492 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
493 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
494 JSAN.use('util.window'); var win = new util.window();
495 var fancy_prompt_data = win.open(
496 urls.XUL_FANCY_PROMPT,
497 //+ '?xml_in_stash=temp_mid'
498 //+ '&bottom_xml_in_stash=temp_bot'
499 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
501 'fancy_prompt', 'chrome,resizable,modal',
502 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
504 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
505 var phone = fancy_prompt_data.phone;
507 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
509 if(obj.retrieve_ids.length > 1) {
510 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
512 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
514 var r = obj.error.yns_alert(msg,
515 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
516 $("commonStrings").getString('common.yes'),
517 $("commonStrings").getString('common.no'),
519 $("commonStrings").getString('common.check_to_confirm')
522 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
525 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
529 'cmd_holds_edit_email_notify' : [
533 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
534 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
535 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
536 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
537 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
538 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
540 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
541 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
542 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
543 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
544 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
545 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
546 JSAN.use('util.window'); var win = new util.window();
547 var fancy_prompt_data = win.open(
548 urls.XUL_FANCY_PROMPT,
549 //+ '?xml_in_stash=temp_mid'
550 //+ '&bottom_xml_in_stash=temp_bot'
551 //+ '&title=' + window.escape('Set Email Notification for Holds'),
552 'fancy_prompt', 'chrome,resizable,modal',
553 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
555 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
556 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
558 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
560 if(get_bool(email)) {
561 if(obj.retrieve_ids.length > 1) {
562 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
564 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
567 if(obj.retrieve_ids.length > 1) {
568 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
570 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
574 var r = obj.error.yns_alert(msg,
575 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
576 $("commonStrings").getString('common.yes'),
577 $("commonStrings").getString('common.no'),
579 $("commonStrings").getString('common.check_to_confirm')
582 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
585 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
589 'cmd_holds_cut_in_line' : [
593 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
594 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
595 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
596 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
597 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
598 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
600 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
601 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
602 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
603 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
604 JSAN.use('util.window'); var win = new util.window();
605 var fancy_prompt_data = win.open(
606 urls.XUL_FANCY_PROMPT,
607 'fancy_prompt', 'chrome,resizable,modal',
608 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
610 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
611 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
613 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
616 if(obj.retrieve_ids.length > 1) {
617 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
619 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
622 if(obj.retrieve_ids.length > 1) {
623 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
625 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
629 var r = obj.error.yns_alert(msg,
630 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
631 $("commonStrings").getString('common.yes'),
632 $("commonStrings").getString('common.no'),
634 $("commonStrings").getString('common.check_to_confirm')
637 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
640 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
644 'cmd_holds_edit_desire_mint_condition' : [
648 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
649 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
650 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
651 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
652 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
653 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
655 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
656 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
657 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
658 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
659 JSAN.use('util.window'); var win = new util.window();
660 var fancy_prompt_data = win.open(
661 urls.XUL_FANCY_PROMPT,
662 'fancy_prompt', 'chrome,resizable,modal',
663 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
665 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
666 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
668 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
671 if(obj.retrieve_ids.length > 1) {
672 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
674 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
677 if(obj.retrieve_ids.length > 1) {
678 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
680 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
684 var r = obj.error.yns_alert(msg,
685 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
686 $("commonStrings").getString('common.yes'),
687 $("commonStrings").getString('common.no'),
689 $("commonStrings").getString('common.check_to_confirm')
692 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
695 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
701 'cmd_holds_suspend' : [
705 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
706 var r = obj.error.yns_alert(
707 obj.retrieve_ids.length > 1 ?
708 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
709 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
710 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
711 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
712 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
714 document.getElementById('commonStrings').getString('common.confirm')
717 var already_suspended = []; var filtered_hold_list = [];
718 for (var i = 0; i < obj.retrieve_ids.length; i++) {
719 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
720 if ( get_bool( hold.frozen() ) ) {
721 already_suspended.push( hold.id() );
724 filtered_hold_list.push( hold.id() );
726 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
727 if (already_suspended.length == 1) {
728 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
729 } else if (already_suspended.length > 1) {
730 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
732 obj.clear_and_retrieve(true);
736 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
740 'cmd_holds_activate' : [
744 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
745 var r = obj.error.yns_alert(
746 obj.retrieve_ids.length > 1 ?
747 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
748 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
749 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
750 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
751 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
753 document.getElementById('commonStrings').getString('common.confirm')
756 var already_activated = []; var filtered_hold_list = [];
757 for (var i = 0; i < obj.retrieve_ids.length; i++) {
758 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
759 if ( ! get_bool( hold.frozen() ) ) {
760 already_activated.push( hold.id() );
763 filtered_hold_list.push( hold.id() );
765 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
766 if (already_activated.length == 1) {
767 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
768 } else if (already_activated.length > 1) {
769 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
771 obj.clear_and_retrieve(true);
775 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
779 'cmd_holds_edit_thaw_date' : [
783 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
784 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
785 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
786 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
787 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
788 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
790 JSAN.use('util.window'); var win = new util.window();
791 var my_xulG = win.open(
792 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
795 'description' : desc,
797 'allow_unset' : true,
798 'disallow_future_dates' : false,
799 'disallow_past_dates' : true,
800 'disallow_today' : true,
801 'default_time' : '00:00:00',
802 'time_readonly' : false
805 if (my_xulG.complete) {
806 circ.util.batch_hold_update(
808 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
809 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
813 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
817 'cmd_holds_edit_expire_time' : [
821 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
822 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
823 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
824 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
825 var value = 'YYYY-MM-DD';
826 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
827 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
829 JSAN.use('util.window'); var win = new util.window();
830 var my_xulG = win.open(
831 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
834 'description' : desc,
836 'allow_unset' : true,
837 'disallow_future_dates' : false,
838 'disallow_past_dates' : true,
839 'disallow_today' : true,
840 'default_time' : '00:00:00',
841 'time_readonly' : false
844 if (my_xulG.complete) {
845 circ.util.batch_hold_update(
847 { 'expire_time' : my_xulG.timestamp },
848 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
852 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
856 'cmd_holds_edit_shelf_expire_time' : [
860 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
861 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
862 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
863 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
864 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
865 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
867 JSAN.use('util.window'); var win = new util.window();
868 var my_xulG = win.open(
869 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
872 'description' : desc,
874 'allow_unset' : false,
875 'disallow_future_dates' : false,
876 'disallow_past_dates' : false,
877 'disallow_today' : false
880 if (my_xulG.complete) {
881 circ.util.batch_hold_update(
883 { 'shelf_expire_time' : my_xulG.timestamp },
884 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
888 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
892 'cmd_holds_edit_request_date' : [
896 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
897 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
898 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
899 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
900 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
901 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
903 JSAN.use('util.window'); var win = new util.window();
904 var my_xulG = win.open(
905 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
908 'description' : desc,
910 'allow_unset' : false,
911 'disallow_future_dates' : true,
912 'disallow_past_dates' : false,
913 'disallow_today' : false
916 if (my_xulG.complete) {
917 circ.util.batch_hold_update(
919 { 'request_time' : my_xulG.timestamp },
920 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
924 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
928 'cmd_holds_retarget' : [
932 JSAN.use('util.functional');
934 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
936 if(obj.retrieve_ids.length > 1) {
937 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
939 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
941 var r = obj.error.yns_alert(msg,
942 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
943 $("commonStrings").getString('common.yes'),
944 $("commonStrings").getString('common.no'),
946 $("commonStrings").getString('common.check_to_confirm')
949 for (var i = 0; i < obj.retrieve_ids.length; i++) {
950 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
951 if (typeof robj.ilsevent != 'undefined') throw(robj);
953 obj.clear_and_retrieve();
956 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
962 'cmd_holds_cancel' : [
966 JSAN.use('util.functional');
968 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
970 if(obj.retrieve_ids.length > 1 ) {
971 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
973 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
976 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
977 JSAN.use('util.window');
978 var win = new util.window();
979 var my_xulG = win.open(
980 urls.XUL_HOLD_CANCEL,
982 'chrome,resizable,modal',
985 /*var r = obj.error.yns_alert(msg,
986 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
987 $("commonStrings").getString('common.yes'),
988 $("commonStrings").getString('common.no'),
990 $("commonStrings").getString('common.check_to_confirm')
993 if (my_xulG.proceed) {
995 for (var i = 0; i < obj.retrieve_ids.length; i++) {
996 if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
997 transits.push( obj.retrieve_ids[i].barcode );
999 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1000 if (typeof robj.ilsevent != 'undefined') throw(robj);
1002 if (transits.length > 0) {
1003 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1004 var r2 = obj.error.yns_alert(msg2,
1005 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1006 $("commonStrings").getString('common.yes'),
1007 $("commonStrings").getString('common.no'),
1009 $("commonStrings").getString('common.check_to_confirm'));
1012 for (var i = 0; i < transits.length; i++) {
1013 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1014 if (typeof robj.ilsevent != 'undefined') {
1015 switch(Number(robj.ilsevent)) {
1016 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1019 case 5000 /* PERM_FAILURE */ :
1028 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1032 obj.clear_and_retrieve();
1035 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1039 'cmd_holds_uncancel' : [
1043 JSAN.use('util.functional');
1044 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1045 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1046 if (typeof robj.ilsevent != 'undefined') throw(robj);
1048 obj.clear_and_retrieve();
1050 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1055 'cmd_retrieve_patron' : [
1060 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1061 var patron_id = obj.retrieve_ids[i].usr;
1062 if (seen[patron_id]) continue; seen[patron_id] = true;
1063 xulG.new_patron_tab(
1065 { 'id' : patron_id }
1069 obj.error.standard_unexpected_error_alert('',E);
1073 'cmd_show_catalog' : [
1077 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1078 var htarget = obj.retrieve_ids[i].target;
1079 var htype = obj.retrieve_ids[i].type;
1083 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1086 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1089 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1090 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1093 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1095 if (typeof my_acp.call_number() == 'object') {
1096 my_acn = my.acp.call_number();
1098 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1099 [ my_acp.call_number() ]);
1101 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1104 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1108 var content_params = {
1110 'authtime' : ses('authtime'),
1111 'opac_url' : opac_url
1114 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1115 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1120 obj.error.standard_unexpected_error_alert('',E);
1124 'cmd_holds_title_transfer' : [
1129 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1130 var htarget = obj.retrieve_ids[i].target;
1131 var htype = obj.retrieve_ids[i].type;
1134 continue; // not supported
1137 targets.push( htarget );
1140 continue; // not supported
1143 continue; // not supported
1146 continue; // not supported
1150 JSAN.use('cat.util');
1151 cat.util.transfer_title_holds(targets);
1152 obj.clear_and_retrieve();
1154 obj.error.standard_unexpected_error_alert('',E);
1162 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1166 'lib_filter_checkbox' : [
1169 var x_lib_type_menu = document.getElementById('lib_type_menu');
1170 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1171 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1172 obj.clear_and_retrieve();
1173 ev.target.setAttribute('checked',ev.target.checked);
1176 'cmd_view_expired_onshelf_holds' : [
1179 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1180 obj.expired = x.checked;
1181 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1182 obj.clear_and_retrieve();
1185 'cmd_clear_expired_onshelf_holds' : [
1189 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1190 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1191 if (robj == null) { robj = []; }
1192 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1193 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1195 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1196 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1197 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1198 var x_lib_type_menu = document.getElementById('lib_type_menu');
1199 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1200 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1201 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1202 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1203 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1205 // id's in xulG.holds will prevent the normal retrieval method from firing
1206 JSAN.use('util.functional');
1207 xulG.holds = util.functional.map_list(
1208 robj.sort(function(a,b) {
1209 if (a.action > b.action) { return 1; }
1210 if (a.action < b.action) { return -1; }
1213 function (element, idx) {
1214 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1215 return element.hold_id;
1218 obj.clear_and_retrieve();
1220 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1221 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1226 'cmd_search_opac' : [
1230 var content_params = {
1231 'show_nav_buttons' : false,
1232 'show_print_button' : true,
1233 'passthru_content_params' : {
1234 'authtoken' : ses(),
1235 'authtime' : ses('authtime'),
1236 'window_open' : function(a,b,c) {
1238 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1239 return window.open(a,b,c);
1241 obj.error.standard_unexpected_error_alert('window_open',E);
1244 'opac_hold_placed' : function(hold) {
1250 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1255 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1256 window.xulG.on_list_change();
1259 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1262 'patron_barcode' : obj.patron_barcode
1264 'url_prefix' : xulG.url_prefix,
1265 'url' : xulG.url_prefix( urls.browser )
1267 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1269 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1278 obj.determine_hold_interface_type();
1279 var x_fetch_more = document.getElementById('fetch_more');
1280 var x_lib_type_menu = document.getElementById('lib_type_menu');
1281 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1282 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1283 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1284 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1285 var x_expired_checkbox = document.getElementById('expired_checkbox');
1286 var x_print_full_pull_list = document.getElementById('print_full_btn');
1287 switch(obj.hold_interface_type) {
1289 obj.render_lib_menus({'pickup_lib':true});
1290 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1291 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1292 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1293 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1296 if (x_fetch_more) x_fetch_more.hidden = false;
1297 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1298 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1299 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1302 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1303 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1304 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1305 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1308 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1309 if (x_fetch_more) x_fetch_more.hidden = true;
1310 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1311 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1312 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1315 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
1317 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1318 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1319 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1321 obj.controller.render();
1324 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1325 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1326 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1327 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1328 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1329 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1330 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1331 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1332 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1333 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1334 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1335 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1336 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1340 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1341 JSAN.use('util.browser');
1342 obj.browser = new util.browser();
1345 'url' : urls.XUL_HOLD_DETAILS,
1347 'alt_print' : false,
1348 'browser_id' : 'hold_detail_frame',
1349 'passthru_content_params' : xulG,
1355 'determine_hold_interface_type' : function() {
1357 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1358 obj.hold_interface_type = 'patron';
1359 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1360 obj.hold_interface_type = 'record';
1361 } else if (obj.pull) { /*************************************************** PULL ******************************/
1362 obj.hold_interface_type = 'pull';
1363 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1364 obj.hold_interface_type = 'shelf';
1365 } else { /*************************************************** PULL ******************************/
1366 obj.hold_interface_type = 'pull';
1370 'clear_and_retrieve' : function() {
1373 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1375 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1376 window.xulG.on_list_change();
1379 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1383 'retrieve' : function() {
1384 var obj = this; var holds = [];
1385 if (window.xulG && window.xulG.holds) {
1386 holds = window.xulG.holds;
1388 var method; var params = [ ses() ];
1389 switch(obj.hold_interface_type) {
1391 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1392 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1394 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1396 params.push( obj.patron_id );
1397 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1400 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1401 params.push( obj.docid );
1402 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1403 var x_lib_type_menu = document.getElementById('lib_type_menu');
1405 if (x_lib_filter.checked) {
1406 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1408 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1413 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1417 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1419 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1421 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1422 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1426 method = 'FM_AHR_ID_LIST_PULL_LIST';
1427 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1428 var x = document.getElementById('hold_count');
1430 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1431 var count = req.getResultObject();
1432 if (typeof count.ilsevent == 'undefined' && count != null) {
1433 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1434 'staff.patron.holds.total_count',
1443 var robj = obj.network.simple_request( method, params );
1444 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1445 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1448 holds = holds.concat( robj.copy_holds );
1449 holds = holds.concat( robj.volume_holds );
1450 holds = holds.concat( robj.title_holds );
1451 holds = holds.concat( robj.metarecord_holds );
1452 holds = holds.sort();
1455 if (robj == null ) {
1458 if (typeof robj.length == 'undefined') {
1466 //alert('method = ' + method + ' params = ' + js2JSON(params));
1469 var x_fetch_more = document.getElementById('fetch_more');
1470 if (holds.length == 0) {
1471 if (x_fetch_more) x_fetch_more.disabled = true;
1473 if (x_fetch_more) x_fetch_more.disabled = false;
1479 'render' : function(holds) {
1483 function list_append(hold_id) {
1488 'hold_id' : hold_id,
1489 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1496 function gen_list_append(hold) {
1498 if (typeof obj.controller.view.lib_menu == 'undefined') {
1499 list_append(typeof hold == 'object' ? hold.id() : hold);
1501 list_append(typeof hold == 'object' ? hold.id() : hold);
1508 JSAN.use('util.exec'); var exec = new util.exec(2);
1510 for (var i in holds) {
1511 rows.push( gen_list_append(holds[i]) );
1516 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1520 'render_lib_menus' : function(types) {
1523 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1525 var x = document.getElementById('lib_type_menu');
1527 var nodes = x.firstChild.childNodes;
1528 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1529 for (var i in types) document.getElementById(i).hidden = false;
1531 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1533 x = document.getElementById('lib_menu_placeholder');
1534 util.widgets.remove_children( x );
1536 JSAN.use('util.file');
1537 var file = new util.file('offline_ou_list');
1538 if (file._file.exists()) {
1539 var list_data = file.get_object(); file.close();
1540 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1541 ml.setAttribute('id','lib_menu');
1542 x.appendChild( ml );
1543 ml.addEventListener(
1546 obj.filter_lib = ev.target.value;
1547 obj.clear_and_retrieve();
1551 obj.controller.view.lib_menu = ml;
1553 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1557 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1562 dump('exiting patron.holds.js\n');