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.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
236 f.fetch_and_render_all(true);
239 alert('Error in holds.js, cmd_alt_view handler: ' + E);
243 'cmd_cancelled_holds_view' : [
246 document.getElementById('show_cancelled_deck').selectedIndex = 1;
247 /* For some reason attribute propogation on the <command> element isn't working with hidden */
248 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
249 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
250 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
251 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
252 obj.clear_and_retrieve();
255 'cmd_uncancelled_holds_view' : [
258 document.getElementById('show_cancelled_deck').selectedIndex = 0;
259 /* For some reason attribute propogation on the <command> element isn't working with hidden */
260 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
261 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
262 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
263 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
264 obj.clear_and_retrieve();
267 'sel_mark_items_damaged' : [
270 JSAN.use('cat.util'); JSAN.use('util.functional');
271 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
274 'sel_mark_items_missing' : [
277 JSAN.use('cat.util'); JSAN.use('util.functional');
278 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
281 'sel_copy_details' : [
284 JSAN.use('circ.util');
285 circ.util.item_details_new(
286 util.functional.map_list(
288 function(o) { return o.barcode; }
293 'cmd_holds_print_full' : [
296 var x_print_full_pull_list = document.getElementById('print_full_btn');
299 progressmeter.mode = 'undetermined';
300 progressmeter.hidden = false;
301 x_print_full_pull_list.disabled = true;
303 JSAN.use('util.print');
304 var print = new util.print('default');
305 var robj = obj.network.simple_request('HTML_HOLD_PULL_LIST',[ses()]);
306 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
307 print.simple( robj.template_output().data() );
309 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
312 progressmeter.mode = 'determined';
313 progressmeter.hidden = true;
314 x_print_full_pull_list.disabled = false;
318 'cmd_holds_print' : [
322 JSAN.use('patron.util');
324 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
327 obj.list.print(params);
329 obj.error.standard_unexpected_error_alert('print 1',E);
333 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
334 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
335 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
337 'cmd_holds_edit_selection_depth' : [
341 JSAN.use('util.widgets'); JSAN.use('util.functional');
342 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
343 var list = util.functional.map_list(
344 util.functional.filter_list(
347 if (o.depth() > ws_type.depth()) return false;
348 if (o.depth() < ws_type.depth()) return true;
349 return (o.id() == ws_type.id());
361 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
362 ml.setAttribute('id','selection');
363 ml.setAttribute('name','fancy_data');
364 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
365 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
366 xml += util.widgets.serialize_node(ml);
368 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
369 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
370 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
371 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
372 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
373 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
374 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
375 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
376 JSAN.use('util.window'); var win = new util.window();
377 var fancy_prompt_data = win.open(
378 urls.XUL_FANCY_PROMPT,
379 //+ '?xml_in_stash=temp_mid'
380 //+ '&bottom_xml_in_stash=temp_bot'
381 //+ '&title=' + window.escape('Choose a Pick Up Library'),
382 'fancy_prompt', 'chrome,resizable,modal',
383 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
385 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
386 var selection = fancy_prompt_data.selection;
388 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
390 if(obj.retrieve_ids.length > 1) {
391 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
393 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
396 var r = obj.error.yns_alert(msg,
397 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
398 $("commonStrings").getString('common.yes'),
399 $("commonStrings").getString('common.no'),
401 $("commonStrings").getString('common.check_to_confirm')
404 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
407 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
412 'cmd_holds_edit_pickup_lib' : [
416 JSAN.use('util.widgets'); JSAN.use('util.functional');
418 var list = util.functional.map_list(
421 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
423 o.name() ? sname + ' ' + o.name() : o.shortname(),
425 ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
426 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
430 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
431 ml.setAttribute('id','lib');
432 ml.setAttribute('name','fancy_data');
433 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
434 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
435 xml += util.widgets.serialize_node(ml);
437 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
438 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
439 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
440 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
441 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
442 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
443 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
444 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
445 JSAN.use('util.window'); var win = new util.window();
446 var fancy_prompt_data = win.open(
447 urls.XUL_FANCY_PROMPT,
448 //+ '?xml_in_stash=temp_mid'
449 //+ '&bottom_xml_in_stash=temp_bot'
450 //+ '&title=' + window.escape('Choose a Pick Up Library'),
451 'fancy_prompt', 'chrome,resizable,modal',
452 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
454 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
455 var pickup_lib = fancy_prompt_data.lib;
457 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
459 if(obj.retrieve_ids.length > 1) {
460 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()]);
462 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()]);
464 var r = obj.error.yns_alert(msg,
465 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
466 $("commonStrings").getString('common.yes'),
467 $("commonStrings").getString('common.no'),
469 $("commonStrings").getString('common.check_to_confirm')
472 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
475 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
479 'cmd_holds_edit_phone_notify' : [
483 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
484 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
485 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
487 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
488 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
489 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
490 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
491 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
492 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
493 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
494 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
495 JSAN.use('util.window'); var win = new util.window();
496 var fancy_prompt_data = win.open(
497 urls.XUL_FANCY_PROMPT,
498 //+ '?xml_in_stash=temp_mid'
499 //+ '&bottom_xml_in_stash=temp_bot'
500 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
502 'fancy_prompt', 'chrome,resizable,modal',
503 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
505 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
506 var phone = fancy_prompt_data.phone;
508 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
510 if(obj.retrieve_ids.length > 1) {
511 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
513 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
515 var r = obj.error.yns_alert(msg,
516 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
517 $("commonStrings").getString('common.yes'),
518 $("commonStrings").getString('common.no'),
520 $("commonStrings").getString('common.check_to_confirm')
523 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
526 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
530 'cmd_holds_edit_email_notify' : [
534 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
535 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
536 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
537 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
538 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
539 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
541 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
542 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
543 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
544 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
545 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
546 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
547 JSAN.use('util.window'); var win = new util.window();
548 var fancy_prompt_data = win.open(
549 urls.XUL_FANCY_PROMPT,
550 //+ '?xml_in_stash=temp_mid'
551 //+ '&bottom_xml_in_stash=temp_bot'
552 //+ '&title=' + window.escape('Set Email Notification for Holds'),
553 'fancy_prompt', 'chrome,resizable,modal',
554 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
556 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
557 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
559 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
561 if(get_bool(email)) {
562 if(obj.retrieve_ids.length > 1) {
563 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
565 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
568 if(obj.retrieve_ids.length > 1) {
569 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
571 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
575 var r = obj.error.yns_alert(msg,
576 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
577 $("commonStrings").getString('common.yes'),
578 $("commonStrings").getString('common.no'),
580 $("commonStrings").getString('common.check_to_confirm')
583 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
586 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
590 'cmd_holds_cut_in_line' : [
594 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
595 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
596 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
597 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
598 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
599 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
601 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
602 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
603 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
604 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
605 JSAN.use('util.window'); var win = new util.window();
606 var fancy_prompt_data = win.open(
607 urls.XUL_FANCY_PROMPT,
608 'fancy_prompt', 'chrome,resizable,modal',
609 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
611 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
612 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
614 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
617 if(obj.retrieve_ids.length > 1) {
618 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
620 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
623 if(obj.retrieve_ids.length > 1) {
624 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
626 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
630 var r = obj.error.yns_alert(msg,
631 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
632 $("commonStrings").getString('common.yes'),
633 $("commonStrings").getString('common.no'),
635 $("commonStrings").getString('common.check_to_confirm')
638 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
641 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
645 'cmd_holds_edit_desire_mint_condition' : [
649 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
650 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
651 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
652 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
653 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
654 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
656 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
657 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
658 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
659 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
660 JSAN.use('util.window'); var win = new util.window();
661 var fancy_prompt_data = win.open(
662 urls.XUL_FANCY_PROMPT,
663 'fancy_prompt', 'chrome,resizable,modal',
664 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
666 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
667 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
669 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
672 if(obj.retrieve_ids.length > 1) {
673 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
675 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
678 if(obj.retrieve_ids.length > 1) {
679 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
681 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
685 var r = obj.error.yns_alert(msg,
686 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
687 $("commonStrings").getString('common.yes'),
688 $("commonStrings").getString('common.no'),
690 $("commonStrings").getString('common.check_to_confirm')
693 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
696 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
702 'cmd_holds_suspend' : [
706 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
707 var r = obj.error.yns_alert(
708 obj.retrieve_ids.length > 1 ?
709 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
710 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
711 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
712 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
713 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
715 document.getElementById('commonStrings').getString('common.confirm')
718 var already_suspended = []; var filtered_hold_list = [];
719 for (var i = 0; i < obj.retrieve_ids.length; i++) {
720 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
721 if ( get_bool( hold.frozen() ) ) {
722 already_suspended.push( hold.id() );
725 filtered_hold_list.push( hold.id() );
727 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
728 if (already_suspended.length == 1) {
729 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
730 } else if (already_suspended.length > 1) {
731 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
733 obj.clear_and_retrieve(true);
737 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
741 'cmd_holds_activate' : [
745 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
746 var r = obj.error.yns_alert(
747 obj.retrieve_ids.length > 1 ?
748 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
749 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
750 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
751 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
752 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
754 document.getElementById('commonStrings').getString('common.confirm')
757 var already_activated = []; var filtered_hold_list = [];
758 for (var i = 0; i < obj.retrieve_ids.length; i++) {
759 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
760 if ( ! get_bool( hold.frozen() ) ) {
761 already_activated.push( hold.id() );
764 filtered_hold_list.push( hold.id() );
766 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
767 if (already_activated.length == 1) {
768 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
769 } else if (already_activated.length > 1) {
770 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
772 obj.clear_and_retrieve(true);
776 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
780 'cmd_holds_edit_thaw_date' : [
784 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
785 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
786 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
787 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
788 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
789 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
791 JSAN.use('util.window'); var win = new util.window();
792 var my_xulG = win.open(
793 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
796 'description' : desc,
798 'allow_unset' : true,
799 'disallow_future_dates' : false,
800 'disallow_past_dates' : true,
801 'disallow_today' : true,
802 'default_time' : '00:00:00',
803 'time_readonly' : false
806 if (my_xulG.complete) {
807 circ.util.batch_hold_update(
809 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
810 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
814 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
818 'cmd_holds_edit_expire_time' : [
822 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
823 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
824 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
825 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
826 var value = 'YYYY-MM-DD';
827 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
828 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
830 JSAN.use('util.window'); var win = new util.window();
831 var my_xulG = win.open(
832 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
835 'description' : desc,
837 'allow_unset' : true,
838 'disallow_future_dates' : false,
839 'disallow_past_dates' : true,
840 'disallow_today' : true,
841 'default_time' : '00:00:00',
842 'time_readonly' : false
845 if (my_xulG.complete) {
846 circ.util.batch_hold_update(
848 { 'expire_time' : my_xulG.timestamp },
849 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
853 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
857 'cmd_holds_edit_shelf_expire_time' : [
861 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
862 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
863 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
864 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
865 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
866 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
868 JSAN.use('util.window'); var win = new util.window();
869 var my_xulG = win.open(
870 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
873 'description' : desc,
875 'allow_unset' : false,
876 'disallow_future_dates' : false,
877 'disallow_past_dates' : false,
878 'disallow_today' : false
881 if (my_xulG.complete) {
882 circ.util.batch_hold_update(
884 { 'shelf_expire_time' : my_xulG.timestamp },
885 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
889 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
893 'cmd_holds_edit_request_date' : [
897 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
898 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
899 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
900 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
901 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
902 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
904 JSAN.use('util.window'); var win = new util.window();
905 var my_xulG = win.open(
906 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
909 'description' : desc,
911 'allow_unset' : false,
912 'disallow_future_dates' : true,
913 'disallow_past_dates' : false,
914 'disallow_today' : false
917 if (my_xulG.complete) {
918 circ.util.batch_hold_update(
920 { 'request_time' : my_xulG.timestamp },
921 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
925 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
929 'cmd_holds_retarget' : [
933 JSAN.use('util.functional');
935 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
937 if(obj.retrieve_ids.length > 1) {
938 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
940 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
942 var r = obj.error.yns_alert(msg,
943 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
944 $("commonStrings").getString('common.yes'),
945 $("commonStrings").getString('common.no'),
947 $("commonStrings").getString('common.check_to_confirm')
950 for (var i = 0; i < obj.retrieve_ids.length; i++) {
951 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
952 if (typeof robj.ilsevent != 'undefined') throw(robj);
954 obj.clear_and_retrieve();
957 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
963 'cmd_holds_cancel' : [
967 JSAN.use('util.functional');
969 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
971 if(obj.retrieve_ids.length > 1 ) {
972 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
974 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
977 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
978 JSAN.use('util.window');
979 var win = new util.window();
980 var my_xulG = win.open(
981 urls.XUL_HOLD_CANCEL,
983 'chrome,resizable,modal',
986 /*var r = obj.error.yns_alert(msg,
987 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
988 $("commonStrings").getString('common.yes'),
989 $("commonStrings").getString('common.no'),
991 $("commonStrings").getString('common.check_to_confirm')
994 if (my_xulG.proceed) {
996 for (var i = 0; i < obj.retrieve_ids.length; i++) {
997 if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
998 transits.push( obj.retrieve_ids[i].barcode );
1000 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1001 if (typeof robj.ilsevent != 'undefined') throw(robj);
1003 if (transits.length > 0) {
1004 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1005 var r2 = obj.error.yns_alert(msg2,
1006 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1007 $("commonStrings").getString('common.yes'),
1008 $("commonStrings").getString('common.no'),
1010 $("commonStrings").getString('common.check_to_confirm'));
1013 for (var i = 0; i < transits.length; i++) {
1014 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1015 if (typeof robj.ilsevent != 'undefined') {
1016 switch(Number(robj.ilsevent)) {
1017 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1020 case 5000 /* PERM_FAILURE */ :
1029 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1033 obj.clear_and_retrieve();
1036 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1040 'cmd_holds_uncancel' : [
1044 JSAN.use('util.functional');
1045 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1046 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1047 if (typeof robj.ilsevent != 'undefined') throw(robj);
1049 obj.clear_and_retrieve();
1051 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1056 'cmd_retrieve_patron' : [
1061 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1062 var patron_id = obj.retrieve_ids[i].usr;
1063 if (seen[patron_id]) continue; seen[patron_id] = true;
1064 xulG.new_patron_tab(
1066 { 'id' : patron_id }
1070 obj.error.standard_unexpected_error_alert('',E);
1074 'cmd_show_catalog' : [
1078 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1079 var htarget = obj.retrieve_ids[i].target;
1080 var htype = obj.retrieve_ids[i].type;
1084 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1087 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1090 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1091 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1094 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1096 if (typeof my_acp.call_number() == 'object') {
1097 my_acn = my.acp.call_number();
1099 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1100 [ my_acp.call_number() ]);
1102 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1105 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1109 var content_params = {
1111 'authtime' : ses('authtime'),
1112 'opac_url' : opac_url
1115 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1116 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1121 obj.error.standard_unexpected_error_alert('',E);
1125 'cmd_holds_title_transfer' : [
1130 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1131 var htarget = obj.retrieve_ids[i].target;
1132 var htype = obj.retrieve_ids[i].type;
1135 continue; // not supported
1138 targets.push( htarget );
1141 continue; // not supported
1144 continue; // not supported
1147 continue; // not supported
1151 JSAN.use('cat.util');
1152 cat.util.transfer_title_holds(targets);
1153 obj.clear_and_retrieve();
1155 obj.error.standard_unexpected_error_alert('',E);
1163 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1167 'lib_filter_checkbox' : [
1170 var x_lib_type_menu = document.getElementById('lib_type_menu');
1171 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1172 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1173 obj.clear_and_retrieve();
1174 ev.target.setAttribute('checked',ev.target.checked);
1177 'cmd_view_expired_onshelf_holds' : [
1180 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1181 obj.expired = x.checked;
1182 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1183 obj.clear_and_retrieve();
1186 'cmd_clear_expired_onshelf_holds' : [
1190 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1191 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1192 if (robj == null) { robj = []; }
1193 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1194 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1196 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1197 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1198 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1199 var x_lib_type_menu = document.getElementById('lib_type_menu');
1200 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1201 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1202 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1203 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1204 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1206 // id's in xulG.holds will prevent the normal retrieval method from firing
1207 JSAN.use('util.functional');
1208 xulG.holds = util.functional.map_list(
1209 robj.sort(function(a,b) {
1210 if (a.action > b.action) { return 1; }
1211 if (a.action < b.action) { return -1; }
1214 function (element, idx) {
1215 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1216 return element.hold_id;
1219 obj.clear_and_retrieve();
1221 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1222 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1227 'cmd_search_opac' : [
1231 var content_params = {
1232 'show_nav_buttons' : false,
1233 'show_print_button' : true,
1234 'passthru_content_params' : {
1235 'authtoken' : ses(),
1236 'authtime' : ses('authtime'),
1237 'window_open' : function(a,b,c) {
1239 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1240 return window.open(a,b,c);
1242 obj.error.standard_unexpected_error_alert('window_open',E);
1245 'opac_hold_placed' : function(hold) {
1251 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1256 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1257 window.xulG.on_list_change();
1260 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1263 'patron_barcode' : obj.patron_barcode
1265 'url_prefix' : xulG.url_prefix,
1266 'url' : xulG.url_prefix( urls.browser )
1268 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1270 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1279 obj.determine_hold_interface_type();
1280 var x_fetch_more = document.getElementById('fetch_more');
1281 var x_lib_type_menu = document.getElementById('lib_type_menu');
1282 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1283 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1284 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1285 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1286 var x_expired_checkbox = document.getElementById('expired_checkbox');
1287 var x_print_full_pull_list = document.getElementById('print_full_btn');
1288 switch(obj.hold_interface_type) {
1290 obj.render_lib_menus({'pickup_lib':true});
1291 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1292 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1293 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1294 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1297 if (x_fetch_more) x_fetch_more.hidden = false;
1298 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1299 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1300 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1303 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1304 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1305 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1306 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1309 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1310 if (x_fetch_more) x_fetch_more.hidden = true;
1311 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1312 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1313 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1316 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
1318 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1319 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1320 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1322 obj.controller.render();
1325 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1326 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1327 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1328 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1329 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1330 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1331 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1332 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1333 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1334 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1335 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1336 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1337 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1341 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1342 JSAN.use('util.browser');
1343 obj.browser = new util.browser();
1346 'url' : urls.XUL_HOLD_DETAILS,
1348 'alt_print' : false,
1349 'browser_id' : 'hold_detail_frame',
1350 'passthru_content_params' : xulG,
1356 'determine_hold_interface_type' : function() {
1358 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1359 obj.hold_interface_type = 'patron';
1360 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1361 obj.hold_interface_type = 'record';
1362 } else if (obj.pull) { /*************************************************** PULL ******************************/
1363 obj.hold_interface_type = 'pull';
1364 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1365 obj.hold_interface_type = 'shelf';
1366 } else { /*************************************************** PULL ******************************/
1367 obj.hold_interface_type = 'pull';
1371 'clear_and_retrieve' : function() {
1374 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1376 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1377 window.xulG.on_list_change();
1380 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1384 'retrieve' : function() {
1385 var obj = this; var holds = [];
1386 if (window.xulG && window.xulG.holds) {
1387 holds = window.xulG.holds;
1389 var method; var params = [ ses() ];
1390 switch(obj.hold_interface_type) {
1392 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1393 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1395 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1397 params.push( obj.patron_id );
1398 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1401 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1402 params.push( obj.docid );
1403 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1404 var x_lib_type_menu = document.getElementById('lib_type_menu');
1406 if (x_lib_filter.checked) {
1407 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1409 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1414 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1418 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1420 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1422 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1423 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1427 method = 'FM_AHR_ID_LIST_PULL_LIST';
1428 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1429 var x = document.getElementById('hold_count');
1431 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1432 var count = req.getResultObject();
1433 if (typeof count.ilsevent == 'undefined' && count != null) {
1434 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1435 'staff.patron.holds.total_count',
1444 var robj = obj.network.simple_request( method, params );
1445 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1446 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1449 holds = holds.concat( robj.copy_holds );
1450 holds = holds.concat( robj.volume_holds );
1451 holds = holds.concat( robj.title_holds );
1452 holds = holds.concat( robj.metarecord_holds );
1453 holds = holds.sort();
1456 if (robj == null ) {
1459 if (typeof robj.length == 'undefined') {
1467 //alert('method = ' + method + ' params = ' + js2JSON(params));
1470 var x_fetch_more = document.getElementById('fetch_more');
1471 if (holds.length == 0) {
1472 if (x_fetch_more) x_fetch_more.disabled = true;
1474 if (x_fetch_more) x_fetch_more.disabled = false;
1480 'render' : function(holds) {
1484 function list_append(hold_id) {
1489 'hold_id' : hold_id,
1490 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1497 function gen_list_append(hold) {
1499 if (typeof obj.controller.view.lib_menu == 'undefined') {
1500 list_append(typeof hold == 'object' ? hold.id() : hold);
1502 list_append(typeof hold == 'object' ? hold.id() : hold);
1509 JSAN.use('util.exec'); var exec = new util.exec(2);
1511 for (var i in holds) {
1512 rows.push( gen_list_append(holds[i]) );
1517 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1521 'render_lib_menus' : function(types) {
1524 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1526 var x = document.getElementById('lib_type_menu');
1528 var nodes = x.firstChild.childNodes;
1529 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1530 for (var i in types) document.getElementById(i).hidden = false;
1532 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1534 x = document.getElementById('lib_menu_placeholder');
1535 util.widgets.remove_children( x );
1537 JSAN.use('util.file');
1538 var file = new util.file('offline_ou_list');
1539 if (file._file.exists()) {
1540 var list_data = file.get_object(); file.close();
1541 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1542 ml.setAttribute('id','lib_menu');
1543 x.appendChild( ml );
1544 ml.addEventListener(
1547 obj.filter_lib = ev.target.value;
1548 obj.clear_and_retrieve();
1552 obj.controller.view.lib_menu = ml;
1554 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1558 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1563 dump('exiting patron.holds.js\n');