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 = fieldmapper.standardRequest(
306 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
312 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
313 print.simple( robj.template_output().data() );
315 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
318 progressmeter.mode = 'determined';
319 progressmeter.hidden = true;
320 x_print_full_pull_list.disabled = false;
324 'cmd_holds_print' : [
328 JSAN.use('patron.util');
330 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
333 obj.list.print(params);
335 obj.error.standard_unexpected_error_alert('print 1',E);
339 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
340 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
341 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
343 'cmd_holds_edit_selection_depth' : [
347 JSAN.use('util.widgets'); JSAN.use('util.functional');
348 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
349 var list = util.functional.map_list(
350 util.functional.filter_list(
353 if (o.depth() > ws_type.depth()) return false;
354 if (o.depth() < ws_type.depth()) return true;
355 return (o.id() == ws_type.id());
367 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
368 ml.setAttribute('id','selection');
369 ml.setAttribute('name','fancy_data');
370 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
371 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
372 xml += util.widgets.serialize_node(ml);
374 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
375 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
376 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
377 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
378 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
379 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
380 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
381 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
382 JSAN.use('util.window'); var win = new util.window();
383 var fancy_prompt_data = win.open(
384 urls.XUL_FANCY_PROMPT,
385 //+ '?xml_in_stash=temp_mid'
386 //+ '&bottom_xml_in_stash=temp_bot'
387 //+ '&title=' + window.escape('Choose a Pick Up Library'),
388 'fancy_prompt', 'chrome,resizable,modal',
389 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
391 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
392 var selection = fancy_prompt_data.selection;
394 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
396 if(obj.retrieve_ids.length > 1) {
397 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
399 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
402 var r = obj.error.yns_alert(msg,
403 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
404 $("commonStrings").getString('common.yes'),
405 $("commonStrings").getString('common.no'),
407 $("commonStrings").getString('common.check_to_confirm')
410 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
413 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
418 'cmd_holds_edit_pickup_lib' : [
422 JSAN.use('util.widgets'); JSAN.use('util.functional');
424 var list = util.functional.map_list(
427 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
429 o.name() ? sname + ' ' + o.name() : o.shortname(),
431 ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
432 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
436 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
437 ml.setAttribute('id','lib');
438 ml.setAttribute('name','fancy_data');
439 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
440 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
441 xml += util.widgets.serialize_node(ml);
443 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
444 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
445 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
446 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
447 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
448 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
449 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
450 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
451 JSAN.use('util.window'); var win = new util.window();
452 var fancy_prompt_data = win.open(
453 urls.XUL_FANCY_PROMPT,
454 //+ '?xml_in_stash=temp_mid'
455 //+ '&bottom_xml_in_stash=temp_bot'
456 //+ '&title=' + window.escape('Choose a Pick Up Library'),
457 'fancy_prompt', 'chrome,resizable,modal',
458 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
460 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
461 var pickup_lib = fancy_prompt_data.lib;
463 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
465 if(obj.retrieve_ids.length > 1) {
466 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()]);
468 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()]);
470 var r = obj.error.yns_alert(msg,
471 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
472 $("commonStrings").getString('common.yes'),
473 $("commonStrings").getString('common.no'),
475 $("commonStrings").getString('common.check_to_confirm')
478 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
481 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
485 'cmd_holds_edit_phone_notify' : [
489 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
490 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
491 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
493 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
494 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
495 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
496 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
497 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
498 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
499 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
500 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
501 JSAN.use('util.window'); var win = new util.window();
502 var fancy_prompt_data = win.open(
503 urls.XUL_FANCY_PROMPT,
504 //+ '?xml_in_stash=temp_mid'
505 //+ '&bottom_xml_in_stash=temp_bot'
506 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
508 'fancy_prompt', 'chrome,resizable,modal',
509 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
511 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
512 var phone = fancy_prompt_data.phone;
514 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
516 if(obj.retrieve_ids.length > 1) {
517 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
519 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
521 var r = obj.error.yns_alert(msg,
522 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
523 $("commonStrings").getString('common.yes'),
524 $("commonStrings").getString('common.no'),
526 $("commonStrings").getString('common.check_to_confirm')
529 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
532 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
536 'cmd_holds_edit_email_notify' : [
540 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
541 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
542 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
543 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
544 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
545 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
547 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
548 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
549 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
550 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
551 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
552 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
553 JSAN.use('util.window'); var win = new util.window();
554 var fancy_prompt_data = win.open(
555 urls.XUL_FANCY_PROMPT,
556 //+ '?xml_in_stash=temp_mid'
557 //+ '&bottom_xml_in_stash=temp_bot'
558 //+ '&title=' + window.escape('Set Email Notification for Holds'),
559 'fancy_prompt', 'chrome,resizable,modal',
560 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
562 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
563 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
565 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
567 if(get_bool(email)) {
568 if(obj.retrieve_ids.length > 1) {
569 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
571 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
574 if(obj.retrieve_ids.length > 1) {
575 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
577 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
581 var r = obj.error.yns_alert(msg,
582 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
583 $("commonStrings").getString('common.yes'),
584 $("commonStrings").getString('common.no'),
586 $("commonStrings").getString('common.check_to_confirm')
589 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
592 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
596 'cmd_holds_cut_in_line' : [
600 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
601 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
602 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
603 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
604 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
605 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
607 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
608 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
609 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
610 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
611 JSAN.use('util.window'); var win = new util.window();
612 var fancy_prompt_data = win.open(
613 urls.XUL_FANCY_PROMPT,
614 'fancy_prompt', 'chrome,resizable,modal',
615 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
617 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
618 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
620 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
623 if(obj.retrieve_ids.length > 1) {
624 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
626 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
629 if(obj.retrieve_ids.length > 1) {
630 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
632 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
636 var r = obj.error.yns_alert(msg,
637 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
638 $("commonStrings").getString('common.yes'),
639 $("commonStrings").getString('common.no'),
641 $("commonStrings").getString('common.check_to_confirm')
644 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
647 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
651 'cmd_holds_edit_desire_mint_condition' : [
655 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
656 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
657 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
658 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
659 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
660 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
662 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
663 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
664 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
665 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
666 JSAN.use('util.window'); var win = new util.window();
667 var fancy_prompt_data = win.open(
668 urls.XUL_FANCY_PROMPT,
669 'fancy_prompt', 'chrome,resizable,modal',
670 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
672 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
673 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
675 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
678 if(obj.retrieve_ids.length > 1) {
679 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
681 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
684 if(obj.retrieve_ids.length > 1) {
685 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
687 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
691 var r = obj.error.yns_alert(msg,
692 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
693 $("commonStrings").getString('common.yes'),
694 $("commonStrings").getString('common.no'),
696 $("commonStrings").getString('common.check_to_confirm')
699 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
702 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
708 'cmd_holds_suspend' : [
712 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
713 var r = obj.error.yns_alert(
714 obj.retrieve_ids.length > 1 ?
715 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
716 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
717 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
718 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
719 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
721 document.getElementById('commonStrings').getString('common.confirm')
724 var already_suspended = []; var filtered_hold_list = [];
725 for (var i = 0; i < obj.retrieve_ids.length; i++) {
726 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
727 if ( get_bool( hold.frozen() ) ) {
728 already_suspended.push( hold.id() );
731 filtered_hold_list.push( hold.id() );
733 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
734 if (already_suspended.length == 1) {
735 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
736 } else if (already_suspended.length > 1) {
737 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
739 obj.clear_and_retrieve(true);
743 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
747 'cmd_holds_activate' : [
751 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
752 var r = obj.error.yns_alert(
753 obj.retrieve_ids.length > 1 ?
754 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
755 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
756 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
757 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
758 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
760 document.getElementById('commonStrings').getString('common.confirm')
763 var already_activated = []; var filtered_hold_list = [];
764 for (var i = 0; i < obj.retrieve_ids.length; i++) {
765 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
766 if ( ! get_bool( hold.frozen() ) ) {
767 already_activated.push( hold.id() );
770 filtered_hold_list.push( hold.id() );
772 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
773 if (already_activated.length == 1) {
774 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
775 } else if (already_activated.length > 1) {
776 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
778 obj.clear_and_retrieve(true);
782 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
786 'cmd_holds_edit_thaw_date' : [
790 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
791 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
792 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
793 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
794 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
795 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
797 JSAN.use('util.window'); var win = new util.window();
798 var my_xulG = win.open(
799 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
802 'description' : desc,
804 'allow_unset' : true,
805 'disallow_future_dates' : false,
806 'disallow_past_dates' : true,
807 'disallow_today' : true,
808 'default_time' : '00:00:00',
809 'time_readonly' : false
812 if (my_xulG.complete) {
813 circ.util.batch_hold_update(
815 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
816 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
820 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
824 'cmd_holds_edit_expire_time' : [
828 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
829 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
830 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
831 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
832 var value = 'YYYY-MM-DD';
833 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
834 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
836 JSAN.use('util.window'); var win = new util.window();
837 var my_xulG = win.open(
838 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
841 'description' : desc,
843 'allow_unset' : true,
844 'disallow_future_dates' : false,
845 'disallow_past_dates' : true,
846 'disallow_today' : true,
847 'default_time' : '00:00:00',
848 'time_readonly' : false
851 if (my_xulG.complete) {
852 circ.util.batch_hold_update(
854 { 'expire_time' : my_xulG.timestamp },
855 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
859 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
863 'cmd_holds_edit_shelf_expire_time' : [
867 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
868 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
869 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
870 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
871 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
872 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
874 JSAN.use('util.window'); var win = new util.window();
875 var my_xulG = win.open(
876 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
879 'description' : desc,
881 'allow_unset' : false,
882 'disallow_future_dates' : false,
883 'disallow_past_dates' : false,
884 'disallow_today' : false
887 if (my_xulG.complete) {
888 circ.util.batch_hold_update(
890 { 'shelf_expire_time' : my_xulG.timestamp },
891 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
895 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
899 'cmd_holds_edit_request_date' : [
903 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
904 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
905 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
906 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
907 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
908 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
910 JSAN.use('util.window'); var win = new util.window();
911 var my_xulG = win.open(
912 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
915 'description' : desc,
917 'allow_unset' : false,
918 'disallow_future_dates' : true,
919 'disallow_past_dates' : false,
920 'disallow_today' : false
923 if (my_xulG.complete) {
924 circ.util.batch_hold_update(
926 { 'request_time' : my_xulG.timestamp },
927 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
931 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
935 'cmd_holds_retarget' : [
939 JSAN.use('util.functional');
941 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
943 if(obj.retrieve_ids.length > 1) {
944 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
946 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
948 var r = obj.error.yns_alert(msg,
949 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
950 $("commonStrings").getString('common.yes'),
951 $("commonStrings").getString('common.no'),
953 $("commonStrings").getString('common.check_to_confirm')
956 for (var i = 0; i < obj.retrieve_ids.length; i++) {
957 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
958 if (typeof robj.ilsevent != 'undefined') throw(robj);
960 obj.clear_and_retrieve();
963 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
969 'cmd_holds_cancel' : [
973 JSAN.use('util.functional');
975 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
977 if(obj.retrieve_ids.length > 1 ) {
978 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
980 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
983 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
984 JSAN.use('util.window');
985 var win = new util.window();
986 var my_xulG = win.open(
987 urls.XUL_HOLD_CANCEL,
989 'chrome,resizable,modal',
992 /*var r = obj.error.yns_alert(msg,
993 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
994 $("commonStrings").getString('common.yes'),
995 $("commonStrings").getString('common.no'),
997 $("commonStrings").getString('common.check_to_confirm')
1000 if (my_xulG.proceed) {
1002 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1003 if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
1004 transits.push( obj.retrieve_ids[i].barcode );
1006 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1007 if (typeof robj.ilsevent != 'undefined') throw(robj);
1009 if (transits.length > 0) {
1010 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1011 var r2 = obj.error.yns_alert(msg2,
1012 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1013 $("commonStrings").getString('common.yes'),
1014 $("commonStrings").getString('common.no'),
1016 $("commonStrings").getString('common.check_to_confirm'));
1019 for (var i = 0; i < transits.length; i++) {
1020 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1021 if (typeof robj.ilsevent != 'undefined') {
1022 switch(Number(robj.ilsevent)) {
1023 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1026 case 5000 /* PERM_FAILURE */ :
1035 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1039 obj.clear_and_retrieve();
1042 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1046 'cmd_holds_uncancel' : [
1050 JSAN.use('util.functional');
1051 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1052 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1053 if (typeof robj.ilsevent != 'undefined') throw(robj);
1055 obj.clear_and_retrieve();
1057 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1062 'cmd_retrieve_patron' : [
1067 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1068 var patron_id = obj.retrieve_ids[i].usr;
1069 if (seen[patron_id]) continue; seen[patron_id] = true;
1070 xulG.new_patron_tab(
1072 { 'id' : patron_id }
1076 obj.error.standard_unexpected_error_alert('',E);
1080 'cmd_show_catalog' : [
1084 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1085 var htarget = obj.retrieve_ids[i].target;
1086 var htype = obj.retrieve_ids[i].type;
1090 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1093 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1096 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1097 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1100 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1102 if (typeof my_acp.call_number() == 'object') {
1103 my_acn = my.acp.call_number();
1105 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1106 [ my_acp.call_number() ]);
1108 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1111 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1115 var content_params = {
1117 'authtime' : ses('authtime'),
1118 'opac_url' : opac_url
1121 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1122 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1127 obj.error.standard_unexpected_error_alert('',E);
1131 'cmd_holds_title_transfer' : [
1136 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1137 var htarget = obj.retrieve_ids[i].target;
1138 var htype = obj.retrieve_ids[i].type;
1141 continue; // not supported
1144 targets.push( htarget );
1147 continue; // not supported
1150 continue; // not supported
1153 continue; // not supported
1157 JSAN.use('cat.util');
1158 cat.util.transfer_title_holds(targets);
1159 obj.clear_and_retrieve();
1161 obj.error.standard_unexpected_error_alert('',E);
1169 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1173 'lib_filter_checkbox' : [
1176 var x_lib_type_menu = document.getElementById('lib_type_menu');
1177 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1178 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1179 obj.clear_and_retrieve();
1180 ev.target.setAttribute('checked',ev.target.checked);
1183 'cmd_view_expired_onshelf_holds' : [
1186 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1187 obj.expired = x.checked;
1188 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1189 obj.clear_and_retrieve();
1192 'cmd_clear_expired_onshelf_holds' : [
1196 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1197 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1198 if (robj == null) { robj = []; }
1199 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1200 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1202 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1203 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1204 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1205 var x_lib_type_menu = document.getElementById('lib_type_menu');
1206 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1207 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1208 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1209 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1210 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1212 // id's in xulG.holds will prevent the normal retrieval method from firing
1213 JSAN.use('util.functional');
1214 xulG.holds = util.functional.map_list(
1215 robj.sort(function(a,b) {
1216 if (a.action > b.action) { return 1; }
1217 if (a.action < b.action) { return -1; }
1220 function (element, idx) {
1221 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1222 return element.hold_id;
1225 obj.clear_and_retrieve();
1227 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1228 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1233 'cmd_search_opac' : [
1237 var content_params = {
1238 'show_nav_buttons' : false,
1239 'show_print_button' : true,
1240 'passthru_content_params' : {
1241 'authtoken' : ses(),
1242 'authtime' : ses('authtime'),
1243 'window_open' : function(a,b,c) {
1245 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1246 return window.open(a,b,c);
1248 obj.error.standard_unexpected_error_alert('window_open',E);
1251 'opac_hold_placed' : function(hold) {
1257 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1262 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1263 window.xulG.on_list_change();
1266 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1269 'patron_barcode' : obj.patron_barcode
1271 'url_prefix' : xulG.url_prefix,
1272 'url' : xulG.url_prefix( urls.browser )
1274 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1276 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1285 obj.determine_hold_interface_type();
1286 var x_fetch_more = document.getElementById('fetch_more');
1287 var x_lib_type_menu = document.getElementById('lib_type_menu');
1288 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1289 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1290 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1291 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1292 var x_expired_checkbox = document.getElementById('expired_checkbox');
1293 var x_print_full_pull_list = document.getElementById('print_full_btn');
1294 switch(obj.hold_interface_type) {
1296 obj.render_lib_menus({'pickup_lib':true});
1297 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1298 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1299 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1300 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1303 if (x_fetch_more) x_fetch_more.hidden = false;
1304 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1305 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1306 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1309 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1310 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1311 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1312 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1315 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1316 if (x_fetch_more) x_fetch_more.hidden = true;
1317 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1318 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1319 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1322 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
1324 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1325 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1326 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1328 obj.controller.render();
1331 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1332 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1333 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1334 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1335 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1336 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1337 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1338 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1339 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1340 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1341 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1342 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1343 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1347 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1348 JSAN.use('util.browser');
1349 obj.browser = new util.browser();
1352 'url' : urls.XUL_HOLD_DETAILS,
1354 'alt_print' : false,
1355 'browser_id' : 'hold_detail_frame',
1356 'passthru_content_params' : xulG,
1362 'determine_hold_interface_type' : function() {
1364 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1365 obj.hold_interface_type = 'patron';
1366 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1367 obj.hold_interface_type = 'record';
1368 } else if (obj.pull) { /*************************************************** PULL ******************************/
1369 obj.hold_interface_type = 'pull';
1370 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1371 obj.hold_interface_type = 'shelf';
1372 } else { /*************************************************** PULL ******************************/
1373 obj.hold_interface_type = 'pull';
1377 'clear_and_retrieve' : function() {
1380 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1382 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1383 window.xulG.on_list_change();
1386 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1390 'retrieve' : function() {
1391 var obj = this; var holds = [];
1392 if (window.xulG && window.xulG.holds) {
1393 holds = window.xulG.holds;
1395 var method; var params = [ ses() ];
1396 switch(obj.hold_interface_type) {
1398 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1399 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1401 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1403 params.push( obj.patron_id );
1404 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1407 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1408 params.push( obj.docid );
1409 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1410 var x_lib_type_menu = document.getElementById('lib_type_menu');
1412 if (x_lib_filter.checked) {
1413 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1415 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1420 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1424 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1426 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1428 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1429 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1433 method = 'FM_AHR_ID_LIST_PULL_LIST';
1434 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1435 var x = document.getElementById('hold_count');
1437 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1438 var count = req.getResultObject();
1439 if (typeof count.ilsevent == 'undefined' && count != null) {
1440 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1441 'staff.patron.holds.total_count',
1450 var robj = obj.network.simple_request( method, params );
1451 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1452 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1455 holds = holds.concat( robj.copy_holds );
1456 holds = holds.concat( robj.volume_holds );
1457 holds = holds.concat( robj.title_holds );
1458 holds = holds.concat( robj.metarecord_holds );
1459 holds = holds.sort();
1462 if (robj == null ) {
1465 if (typeof robj.length == 'undefined') {
1473 //alert('method = ' + method + ' params = ' + js2JSON(params));
1476 var x_fetch_more = document.getElementById('fetch_more');
1477 if (holds.length == 0) {
1478 if (x_fetch_more) x_fetch_more.disabled = true;
1480 if (x_fetch_more) x_fetch_more.disabled = false;
1486 'render' : function(holds) {
1490 function list_append(hold_id) {
1495 'hold_id' : hold_id,
1496 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1503 function gen_list_append(hold) {
1505 if (typeof obj.controller.view.lib_menu == 'undefined') {
1506 list_append(typeof hold == 'object' ? hold.id() : hold);
1508 list_append(typeof hold == 'object' ? hold.id() : hold);
1515 JSAN.use('util.exec'); var exec = new util.exec(2);
1517 for (var i in holds) {
1518 rows.push( gen_list_append(holds[i]) );
1523 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1527 'render_lib_menus' : function(types) {
1530 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1532 var x = document.getElementById('lib_type_menu');
1534 var nodes = x.firstChild.childNodes;
1535 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1536 for (var i in types) document.getElementById(i).hidden = false;
1538 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1540 x = document.getElementById('lib_menu_placeholder');
1541 util.widgets.remove_children( x );
1543 JSAN.use('util.file');
1544 var file = new util.file('offline_ou_list');
1545 if (file._file.exists()) {
1546 var list_data = file.get_object(); file.close();
1547 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1548 ml.setAttribute('id','lib_menu');
1549 x.appendChild( ml );
1550 ml.addEventListener(
1553 obj.filter_lib = ev.target.value;
1554 obj.clear_and_retrieve();
1558 obj.controller.view.lib_menu = ml;
1560 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1564 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1569 dump('exiting patron.holds.js\n');