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.patron_alias = blob.patron_alias;
89 row.my.total_holds = blob.total_holds;
90 row.my.queue_position = blob.queue_position;
91 row.my.potential_copies = blob.potential_copies;
92 row.my.estimated_wait = blob.estimated_wait;
93 row.my.ahrn_count = blob.hold.notes().length;
95 var copy_id = row.my.ahr.current_copy();
96 if (typeof copy_id == 'object') {
97 if (copy_id == null) {
98 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
100 copy_id = copy_id.id();
103 copy_id = row.my.acp.id();
106 obj.holds_map[ row.my.ahr.id() ] = blob;
107 params.row_node.setAttribute('retrieve_id',
110 'barcode':row.my.acp ? row.my.acp.barcode() : null,
111 'id':row.my.ahr.id(),
112 'type':row.my.ahr.hold_type(),
113 'target':row.my.ahr.target(),
114 'usr':row.my.ahr.usr()
117 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
120 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
125 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
129 'on_select' : function(ev) {
130 JSAN.use('util.functional');
131 var sel = obj.list.retrieve_selection();
132 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
133 obj.retrieve_ids = util.functional.map_list(
135 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
137 if (obj.retrieve_ids.length > 0) {
138 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
139 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
140 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
141 obj.controller.view.sel_patron.setAttribute('disabled','false');
142 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
143 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
144 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
145 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
146 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
147 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
148 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
149 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
150 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
151 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
152 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
153 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
154 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','false');
155 if (obj.controller.view.cmd_alt_view.getAttribute('ready')=='true') {
156 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
158 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
159 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
160 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
161 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
163 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
164 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
165 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
166 obj.controller.view.sel_patron.setAttribute('disabled','true');
167 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
168 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
169 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
170 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
171 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
172 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
173 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
174 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
175 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
176 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
177 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
178 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
179 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
180 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','true');
181 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
182 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
183 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
184 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
190 JSAN.use('util.controller'); obj.controller = new util.controller();
194 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
197 function() { obj.list.clipboard(); }
201 function() { alert($("commonStrings").getString('common.unimplemented')); }
206 JSAN.use('circ.util');
207 circ.util.show_last_few_circs(obj.retrieve_ids);
213 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
214 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
221 var n = obj.controller.view.alt_view_btn;
222 if (n.getAttribute('toggle') == '1') {
223 document.getElementById('deck').selectedIndex = 0;
224 n.setAttribute('toggle','0');
225 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
226 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
228 document.getElementById('deck').selectedIndex = 1;
229 n.setAttribute('toggle','1');
230 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
231 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
232 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
233 if (obj.retrieve_ids.length == 0) return;
234 var f = obj.browser.get_content();
235 xulG.ahr_id = obj.retrieve_ids[0].id;
236 xulG.blob = obj.holds_map[ xulG.ahr_id ];
237 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
238 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
240 f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
241 f.fetch_and_render_all(true);
244 alert('Error in holds.js, cmd_alt_view handler: ' + E);
248 'cmd_cancelled_holds_view' : [
251 document.getElementById('show_cancelled_deck').selectedIndex = 1;
252 /* For some reason attribute propogation on the <command> element isn't working with hidden */
253 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
254 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
255 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
256 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
257 obj.clear_and_retrieve();
260 'cmd_uncancelled_holds_view' : [
263 document.getElementById('show_cancelled_deck').selectedIndex = 0;
264 /* For some reason attribute propogation on the <command> element isn't working with hidden */
265 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
266 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
267 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
268 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
269 obj.clear_and_retrieve();
272 'sel_mark_items_damaged' : [
275 JSAN.use('cat.util'); JSAN.use('util.functional');
276 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
279 'sel_mark_items_missing' : [
282 JSAN.use('cat.util'); JSAN.use('util.functional');
283 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
286 'sel_copy_details' : [
289 JSAN.use('circ.util');
290 circ.util.item_details_new(
291 util.functional.map_list(
293 function(o) { return o.barcode; }
298 'cmd_holds_print_full' : [
301 var x_print_full_pull_list = document.getElementById('print_full_btn');
304 progressmeter.mode = 'undetermined';
305 progressmeter.hidden = false;
306 x_print_full_pull_list.disabled = true;
308 JSAN.use('util.print');
309 var print = new util.print('default');
310 var robj = fieldmapper.standardRequest(
311 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
318 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
319 print.simple( robj.template_output().data() );
322 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
325 progressmeter.mode = 'determined';
326 progressmeter.hidden = true;
327 x_print_full_pull_list.disabled = false;
331 'cmd_holds_print_alt' : [
335 var content_params = {
337 "authtime": ses("authtime"),
339 "show_nav_buttons": true,
340 "show_print_button": false
342 ["url_prefix", "new_tab", "set_tab",
343 "close_tab", "new_patron_tab",
344 "set_patron_tab", "volume_item_creator",
346 "holdings_maintenance_tab", "set_tab_name",
347 "open_chrome_window", "url_prefix",
348 "network_meter", "page_meter",
349 "set_statusbar", "set_help_context"
350 ].forEach(function(k) {
351 content_params[k] = xulG[k];
354 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
355 xulG.url_prefix("/opac/extras/circ/alt_holds_print.html").replace("http:","https:")
359 "tab_name": "Printable Pull List", /* XXX i18n */
364 g.error.sdump("D_ERROR", E);
368 'cmd_holds_print' : [
372 JSAN.use('patron.util');
374 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
377 obj.list.print(params);
379 obj.error.standard_unexpected_error_alert('print 1',E);
383 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
384 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
385 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
387 'cmd_holds_edit_selection_depth' : [
391 JSAN.use('util.widgets'); JSAN.use('util.functional');
392 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
393 var list = util.functional.map_list(
394 util.functional.filter_list(
397 if (o.depth() > ws_type.depth()) return false;
398 if (o.depth() < ws_type.depth()) return true;
399 return (o.id() == ws_type.id());
411 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
412 ml.setAttribute('id','selection');
413 ml.setAttribute('name','fancy_data');
414 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
415 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
416 xml += util.widgets.serialize_node(ml);
418 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
419 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
420 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
421 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
422 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
423 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
424 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
425 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
426 JSAN.use('util.window'); var win = new util.window();
427 var fancy_prompt_data = win.open(
428 urls.XUL_FANCY_PROMPT,
429 //+ '?xml_in_stash=temp_mid'
430 //+ '&bottom_xml_in_stash=temp_bot'
431 //+ '&title=' + window.escape('Choose a Pick Up Library'),
432 'fancy_prompt', 'chrome,resizable,modal',
433 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
435 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
436 var selection = fancy_prompt_data.selection;
438 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
440 if(obj.retrieve_ids.length > 1) {
441 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
443 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
446 var r = obj.error.yns_alert(msg,
447 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
448 $("commonStrings").getString('common.yes'),
449 $("commonStrings").getString('common.no'),
451 $("commonStrings").getString('common.check_to_confirm')
454 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
457 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
462 'cmd_holds_edit_pickup_lib' : [
466 JSAN.use('util.widgets'); JSAN.use('util.functional');
468 var list = util.functional.map_list(
471 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
473 o.name() ? sname + ' ' + o.name() : o.shortname(),
475 ( !isTrue(obj.data.hash.aout[ o.ou_type() ].can_have_users()) ),
476 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
480 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
481 ml.setAttribute('id','lib');
482 ml.setAttribute('name','fancy_data');
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_pickup_lib.new_pickup_lib.description')+'</description>';
485 xml += util.widgets.serialize_node(ml);
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_pickup_lib.done.label') +'"';
489 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
490 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
491 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.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 Pick Up Library'),
501 'fancy_prompt', 'chrome,resizable,modal',
502 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
504 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
505 var pickup_lib = fancy_prompt_data.lib;
507 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
509 if(obj.retrieve_ids.length > 1) {
510 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.plural',[hold_list.join(', '), obj.data.hash.aou[pickup_lib].shortname()]);
512 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()]);
514 var r = obj.error.yns_alert(msg,
515 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
516 $("commonStrings").getString('common.yes'),
517 $("commonStrings").getString('common.no'),
519 $("commonStrings").getString('common.check_to_confirm')
522 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
525 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
529 'cmd_holds_edit_phone_notify' : [
533 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
534 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
535 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
537 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
538 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
539 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
540 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
541 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
542 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
543 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
544 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
545 JSAN.use('util.window'); var win = new util.window();
546 var fancy_prompt_data = win.open(
547 urls.XUL_FANCY_PROMPT,
548 //+ '?xml_in_stash=temp_mid'
549 //+ '&bottom_xml_in_stash=temp_bot'
550 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
552 'fancy_prompt', 'chrome,resizable,modal',
553 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
555 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
556 var phone = fancy_prompt_data.phone;
558 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
560 if(obj.retrieve_ids.length > 1) {
561 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
563 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
565 var r = obj.error.yns_alert(msg,
566 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
567 $("commonStrings").getString('common.yes'),
568 $("commonStrings").getString('common.no'),
570 $("commonStrings").getString('common.check_to_confirm')
573 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
576 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
580 'cmd_holds_edit_email_notify' : [
584 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
585 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
586 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
587 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
588 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
589 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
591 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
592 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
593 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
594 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
595 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
596 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
597 JSAN.use('util.window'); var win = new util.window();
598 var fancy_prompt_data = win.open(
599 urls.XUL_FANCY_PROMPT,
600 //+ '?xml_in_stash=temp_mid'
601 //+ '&bottom_xml_in_stash=temp_bot'
602 //+ '&title=' + window.escape('Set Email Notification for Holds'),
603 'fancy_prompt', 'chrome,resizable,modal',
604 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
606 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
607 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
609 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
611 if(get_bool(email)) {
612 if(obj.retrieve_ids.length > 1) {
613 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
615 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
618 if(obj.retrieve_ids.length > 1) {
619 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
621 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
625 var r = obj.error.yns_alert(msg,
626 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
627 $("commonStrings").getString('common.yes'),
628 $("commonStrings").getString('common.no'),
630 $("commonStrings").getString('common.check_to_confirm')
633 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
636 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
640 'cmd_holds_cut_in_line' : [
644 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
645 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
646 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
647 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
648 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
649 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
651 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
652 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
653 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
654 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
655 JSAN.use('util.window'); var win = new util.window();
656 var fancy_prompt_data = win.open(
657 urls.XUL_FANCY_PROMPT,
658 'fancy_prompt', 'chrome,resizable,modal',
659 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
661 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
662 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
664 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
667 if(obj.retrieve_ids.length > 1) {
668 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
670 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
673 if(obj.retrieve_ids.length > 1) {
674 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
676 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
680 var r = obj.error.yns_alert(msg,
681 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
682 $("commonStrings").getString('common.yes'),
683 $("commonStrings").getString('common.no'),
685 $("commonStrings").getString('common.check_to_confirm')
688 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
691 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
695 'cmd_holds_edit_desire_mint_condition' : [
699 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
700 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
701 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
702 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
703 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
704 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
706 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
707 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
708 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
709 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
710 JSAN.use('util.window'); var win = new util.window();
711 var fancy_prompt_data = win.open(
712 urls.XUL_FANCY_PROMPT,
713 'fancy_prompt', 'chrome,resizable,modal',
714 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
716 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
717 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
719 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
722 if(obj.retrieve_ids.length > 1) {
723 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
725 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
728 if(obj.retrieve_ids.length > 1) {
729 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
731 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
735 var r = obj.error.yns_alert(msg,
736 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
737 $("commonStrings").getString('common.yes'),
738 $("commonStrings").getString('common.no'),
740 $("commonStrings").getString('common.check_to_confirm')
743 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
746 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
752 'cmd_holds_suspend' : [
756 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
757 var r = obj.error.yns_alert(
758 obj.retrieve_ids.length > 1 ?
759 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
760 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
761 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
762 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
763 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
765 document.getElementById('commonStrings').getString('common.confirm')
768 var already_suspended = []; var filtered_hold_list = [];
769 for (var i = 0; i < obj.retrieve_ids.length; i++) {
770 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
771 if ( get_bool( hold.frozen() ) ) {
772 already_suspended.push( hold.id() );
775 filtered_hold_list.push( hold.id() );
777 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
778 if (already_suspended.length == 1) {
779 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
780 } else if (already_suspended.length > 1) {
781 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
783 obj.clear_and_retrieve(true);
787 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
791 'cmd_holds_activate' : [
795 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
796 var r = obj.error.yns_alert(
797 obj.retrieve_ids.length > 1 ?
798 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
799 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
800 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
801 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
802 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
804 document.getElementById('commonStrings').getString('common.confirm')
807 var already_activated = []; var filtered_hold_list = [];
808 for (var i = 0; i < obj.retrieve_ids.length; i++) {
809 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
810 if ( ! get_bool( hold.frozen() ) ) {
811 already_activated.push( hold.id() );
814 filtered_hold_list.push( hold.id() );
816 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
817 if (already_activated.length == 1) {
818 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
819 } else if (already_activated.length > 1) {
820 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
822 obj.clear_and_retrieve(true);
826 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
830 'cmd_holds_edit_thaw_date' : [
834 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
835 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
836 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
837 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
838 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
839 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
841 JSAN.use('util.window'); var win = new util.window();
842 var my_xulG = win.open(
843 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
846 'description' : desc,
848 'allow_unset' : true,
849 'disallow_future_dates' : false,
850 'disallow_past_dates' : true,
851 'disallow_today' : true,
852 'default_time' : '00:00:00',
853 'time_readonly' : false
856 if (my_xulG.complete) {
857 circ.util.batch_hold_update(
859 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
860 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
864 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
868 'cmd_holds_edit_expire_time' : [
872 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
873 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
874 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
875 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
876 var value = 'YYYY-MM-DD';
877 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
878 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
880 JSAN.use('util.window'); var win = new util.window();
881 var my_xulG = win.open(
882 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
885 'description' : desc,
887 'allow_unset' : true,
888 'disallow_future_dates' : false,
889 'disallow_past_dates' : true,
890 'disallow_today' : true,
891 'default_time' : '00:00:00',
892 'time_readonly' : false
895 if (my_xulG.complete) {
896 circ.util.batch_hold_update(
898 { 'expire_time' : my_xulG.timestamp },
899 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
903 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
907 'cmd_holds_edit_shelf_expire_time' : [
911 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
912 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
913 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
914 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
915 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
916 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
918 JSAN.use('util.window'); var win = new util.window();
919 var my_xulG = win.open(
920 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
923 'description' : desc,
925 'allow_unset' : false,
926 'disallow_future_dates' : false,
927 'disallow_past_dates' : false,
928 'disallow_today' : false
931 if (my_xulG.complete) {
932 circ.util.batch_hold_update(
934 { 'shelf_expire_time' : my_xulG.timestamp },
935 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
939 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
943 'cmd_holds_edit_request_date' : [
947 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
948 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
949 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
950 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
951 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
952 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
954 JSAN.use('util.window'); var win = new util.window();
955 var my_xulG = win.open(
956 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
959 'description' : desc,
961 'allow_unset' : false,
962 'disallow_future_dates' : true,
963 'disallow_past_dates' : false,
964 'disallow_today' : false
967 if (my_xulG.complete) {
968 circ.util.batch_hold_update(
970 { 'request_time' : my_xulG.timestamp },
971 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
975 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
979 'cmd_holds_retarget' : [
983 JSAN.use('util.functional');
985 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
987 if(obj.retrieve_ids.length > 1) {
988 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
990 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
992 var r = obj.error.yns_alert(msg,
993 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
994 $("commonStrings").getString('common.yes'),
995 $("commonStrings").getString('common.no'),
997 $("commonStrings").getString('common.check_to_confirm')
1000 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1001 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
1002 if (typeof robj.ilsevent != 'undefined') throw(robj);
1004 obj.clear_and_retrieve();
1007 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
1013 'cmd_holds_cancel' : [
1017 JSAN.use('util.functional');
1019 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1021 if(obj.retrieve_ids.length > 1 ) {
1022 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
1024 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
1027 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1028 JSAN.use('util.window');
1029 var win = new util.window();
1030 var my_xulG = win.open(
1031 urls.XUL_HOLD_CANCEL,
1033 'chrome,resizable,modal',
1036 /*var r = obj.error.yns_alert(msg,
1037 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1038 $("commonStrings").getString('common.yes'),
1039 $("commonStrings").getString('common.no'),
1041 $("commonStrings").getString('common.check_to_confirm')
1044 if (my_xulG.proceed) {
1046 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1047 var transit = obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit();
1048 if (transit && ! transit.dest_recv_time() ) {
1049 transits.push( obj.retrieve_ids[i].barcode );
1051 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1052 if (typeof robj.ilsevent != 'undefined') throw(robj);
1054 if (transits.length > 0) {
1055 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1056 var r2 = obj.error.yns_alert(msg2,
1057 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1058 $("commonStrings").getString('common.yes'),
1059 $("commonStrings").getString('common.no'),
1061 $("commonStrings").getString('common.check_to_confirm'));
1064 for (var i = 0; i < transits.length; i++) {
1065 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1066 if (typeof robj.ilsevent != 'undefined') {
1067 switch(Number(robj.ilsevent)) {
1068 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1071 case 5000 /* PERM_FAILURE */ :
1080 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1084 obj.clear_and_retrieve();
1087 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1091 'cmd_holds_uncancel' : [
1095 JSAN.use('util.functional');
1096 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1097 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1098 if (typeof robj.ilsevent != 'undefined') throw(robj);
1100 obj.clear_and_retrieve();
1102 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1107 'cmd_retrieve_patron' : [
1112 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1113 var patron_id = obj.retrieve_ids[i].usr;
1114 if (seen[patron_id]) continue; seen[patron_id] = true;
1115 xulG.new_patron_tab(
1117 { 'id' : patron_id }
1121 obj.error.standard_unexpected_error_alert('',E);
1125 'cmd_show_catalog' : [
1129 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1130 var htarget = obj.retrieve_ids[i].target;
1131 var htype = obj.retrieve_ids[i].type;
1135 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1138 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1141 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1142 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1145 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1147 if (typeof my_acp.call_number() == 'object') {
1148 my_acn = my.acp.call_number();
1150 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1151 [ my_acp.call_number() ]);
1153 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1156 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1160 var content_params = {
1162 'authtime' : ses('authtime'),
1163 'opac_url' : opac_url
1166 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1167 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1172 obj.error.standard_unexpected_error_alert('',E);
1176 'cmd_holds_title_transfer' : [
1181 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1182 var htarget = obj.retrieve_ids[i].target;
1183 var htype = obj.retrieve_ids[i].type;
1186 continue; // not supported
1189 targets.push( htarget );
1192 continue; // not supported
1195 continue; // not supported
1198 continue; // not supported
1202 JSAN.use('cat.util');
1203 cat.util.transfer_title_holds(targets);
1204 obj.clear_and_retrieve();
1206 obj.error.standard_unexpected_error_alert('',E);
1214 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1218 'lib_filter_checkbox' : [
1221 var x_lib_type_menu = document.getElementById('lib_type_menu');
1222 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1223 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1224 obj.clear_and_retrieve();
1225 ev.target.setAttribute('checked',ev.target.checked);
1228 'cmd_view_expired_onshelf_holds' : [
1231 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1232 obj.expired = x.checked;
1233 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1234 obj.clear_and_retrieve();
1237 'cmd_clear_expired_onshelf_holds' : [
1241 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1242 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1243 if (robj == null) { robj = []; }
1244 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1245 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1247 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1248 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1249 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1250 var x_lib_type_menu = document.getElementById('lib_type_menu');
1251 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1252 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1253 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1254 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1255 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1257 // id's in xulG.holds will prevent the normal retrieval method from firing
1258 JSAN.use('util.functional');
1259 xulG.holds = util.functional.map_list(
1260 robj.sort(function(a,b) {
1261 if (a.action > b.action) { return 1; }
1262 if (a.action < b.action) { return -1; }
1265 function (element, idx) {
1266 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1267 return element.hold_id;
1270 obj.clear_and_retrieve();
1272 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1273 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1278 'cmd_search_opac' : [
1282 var content_params = {
1283 'show_nav_buttons' : false,
1284 'show_print_button' : true,
1285 'passthru_content_params' : {
1286 'authtoken' : ses(),
1287 'authtime' : ses('authtime'),
1288 'window_open' : function(a,b,c) {
1290 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1291 return window.open(a,b,c);
1293 obj.error.standard_unexpected_error_alert('window_open',E);
1296 'opac_hold_placed' : function(hold) {
1302 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1307 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1308 window.xulG.on_list_change();
1311 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1314 'patron_barcode' : obj.patron_barcode
1316 'url_prefix' : xulG.url_prefix,
1317 'url' : xulG.url_prefix( urls.browser )
1319 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1321 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1330 obj.determine_hold_interface_type();
1331 var x_fetch_more = document.getElementById('fetch_more');
1332 var x_lib_type_menu = document.getElementById('lib_type_menu');
1333 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1334 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1335 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1336 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1337 var x_expired_checkbox = document.getElementById('expired_checkbox');
1338 var x_print_full_pull_list = document.getElementById('print_full_btn');
1339 var x_print_full_pull_list_alt = document.getElementById('print_alt_btn');
1340 switch(obj.hold_interface_type) {
1342 obj.render_lib_menus({'pickup_lib':true});
1343 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1344 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1345 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1346 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1347 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1350 if (x_fetch_more) x_fetch_more.hidden = false;
1351 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1352 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = false;
1353 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1354 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1357 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1358 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1359 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1360 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1361 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1364 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1365 if (x_fetch_more) x_fetch_more.hidden = true;
1366 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1367 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1368 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1369 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1372 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
1374 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1375 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1376 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1378 obj.controller.render();
1381 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1382 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1383 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1384 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1385 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1386 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1387 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1388 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1389 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1390 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1391 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1392 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1393 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1397 $('cmd_alt_view').setAttribute('disabled','true');
1398 xulG.when_done = function() {
1399 $('cmd_alt_view').setAttribute('ready','true');
1400 if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1401 $('cmd_alt_view').setAttribute('disabled','false');
1403 dump('hold details UI ready\n');
1405 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1406 JSAN.use('util.browser');
1407 obj.browser = new util.browser();
1410 'url' : urls.XUL_HOLD_DETAILS,
1412 'alt_print' : false,
1413 'browser_id' : 'hold_detail_frame',
1414 'passthru_content_params' : xulG
1420 'determine_hold_interface_type' : function() {
1422 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1423 obj.hold_interface_type = 'patron';
1424 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1425 obj.hold_interface_type = 'record';
1426 } else if (obj.pull) { /*************************************************** PULL ******************************/
1427 obj.hold_interface_type = 'pull';
1428 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1429 obj.hold_interface_type = 'shelf';
1430 } else { /*************************************************** PULL ******************************/
1431 obj.hold_interface_type = 'pull';
1435 'clear_and_retrieve' : function() {
1438 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1440 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1441 window.xulG.on_list_change();
1444 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1448 'retrieve' : function() {
1449 var obj = this; var holds = [];
1450 if (window.xulG && window.xulG.holds) {
1451 holds = window.xulG.holds;
1453 var method; var params = [ ses() ];
1454 switch(obj.hold_interface_type) {
1456 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1457 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1459 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1461 params.push( obj.patron_id );
1462 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1465 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1466 params.push( obj.docid );
1467 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1468 var x_lib_type_menu = document.getElementById('lib_type_menu');
1470 if (x_lib_filter.checked) {
1471 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1473 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1478 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1482 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1484 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1486 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1487 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1491 method = 'FM_AHR_ID_LIST_PULL_LIST';
1492 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1493 var x = document.getElementById('hold_count');
1495 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1496 var count = req.getResultObject();
1497 if (typeof count.ilsevent == 'undefined' && count != null) {
1498 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1499 'staff.patron.holds.total_count',
1508 var robj = obj.network.simple_request( method, params );
1509 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1510 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1513 holds = holds.concat( robj.copy_holds );
1514 holds = holds.concat( robj.volume_holds );
1515 holds = holds.concat( robj.title_holds );
1516 holds = holds.concat( robj.metarecord_holds );
1517 holds = holds.sort();
1520 if (robj == null ) {
1523 if (typeof robj.length == 'undefined') {
1531 //alert('method = ' + method + ' params = ' + js2JSON(params));
1534 var x_fetch_more = document.getElementById('fetch_more');
1535 if (holds.length == 0) {
1536 if (x_fetch_more) x_fetch_more.disabled = true;
1538 if (x_fetch_more) x_fetch_more.disabled = false;
1544 'render' : function(holds) {
1548 function list_append(hold_id) {
1553 'hold_id' : hold_id,
1554 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1562 function gen_list_append(hold) {
1564 if (typeof obj.controller.view.lib_menu == 'undefined') {
1565 list_append(typeof hold == 'object' ? hold.id() : hold);
1567 list_append(typeof hold == 'object' ? hold.id() : hold);
1574 JSAN.use('util.exec'); var exec = new util.exec(2);
1576 for (var i in holds) {
1577 rows.push( gen_list_append(holds[i]) );
1582 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1586 'render_lib_menus' : function(types) {
1589 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1591 var x = document.getElementById('lib_type_menu');
1593 var nodes = x.firstChild.childNodes;
1594 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1595 for (var i in types) document.getElementById(i).hidden = false;
1597 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1599 x = document.getElementById('lib_menu_placeholder');
1600 util.widgets.remove_children( x );
1602 JSAN.use('util.file');
1603 var file = new util.file('offline_ou_list');
1604 if (file._file.exists()) {
1605 var list_data = file.get_object(); file.close();
1606 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1607 ml.setAttribute('id','lib_menu');
1608 x.appendChild( ml );
1609 ml.addEventListener(
1612 obj.filter_lib = ev.target.value;
1613 obj.clear_and_retrieve();
1617 obj.controller.view.lib_menu = ml;
1619 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1623 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1628 dump('exiting patron.holds.js\n');