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('rendering_rows','false');
154 if (obj.controller.view.cmd_alt_view.getAttribute('ready')=='true') {
155 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
157 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
158 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
159 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
160 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
162 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
163 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
164 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
165 obj.controller.view.sel_patron.setAttribute('disabled','true');
166 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
167 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
168 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
169 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
170 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
171 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
172 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
173 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
174 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
175 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
176 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
177 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
178 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
179 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','true');
180 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
181 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
182 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
183 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
189 JSAN.use('util.controller'); obj.controller = new util.controller();
193 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
196 function() { obj.list.clipboard(); }
200 function() { alert($("commonStrings").getString('common.unimplemented')); }
205 JSAN.use('circ.util');
206 circ.util.show_last_few_circs(obj.retrieve_ids);
212 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
213 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
220 var n = obj.controller.view.alt_view_btn;
221 if (n.getAttribute('toggle') == '1') {
222 document.getElementById('deck').selectedIndex = 0;
223 n.setAttribute('toggle','0');
224 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
225 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
227 document.getElementById('deck').selectedIndex = 1;
228 n.setAttribute('toggle','1');
229 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
230 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
231 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
232 if (obj.retrieve_ids.length == 0) return;
233 var f = obj.browser.get_content();
234 xulG.ahr_id = obj.retrieve_ids[0].id;
235 xulG.blob = obj.holds_map[ xulG.ahr_id ];
236 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
237 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
239 f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
240 f.fetch_and_render_all(true);
243 alert('Error in holds.js, cmd_alt_view handler: ' + E);
247 'cmd_cancelled_holds_view' : [
250 document.getElementById('show_cancelled_deck').selectedIndex = 1;
251 /* For some reason attribute propogation on the <command> element isn't working with hidden */
252 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
253 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
254 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
255 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
256 obj.clear_and_retrieve();
259 'cmd_uncancelled_holds_view' : [
262 document.getElementById('show_cancelled_deck').selectedIndex = 0;
263 /* For some reason attribute propogation on the <command> element isn't working with hidden */
264 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
265 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
266 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
267 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
268 obj.clear_and_retrieve();
271 'sel_mark_items_damaged' : [
274 JSAN.use('cat.util'); JSAN.use('util.functional');
275 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
278 'sel_mark_items_missing' : [
281 JSAN.use('cat.util'); JSAN.use('util.functional');
282 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
285 'sel_copy_details' : [
288 JSAN.use('circ.util');
289 circ.util.item_details_new(
290 util.functional.map_list(
292 function(o) { return o.barcode; }
297 'cmd_holds_print_full' : [
300 var x_print_full_pull_list = document.getElementById('print_full_btn');
303 progressmeter.mode = 'undetermined';
304 progressmeter.hidden = false;
305 x_print_full_pull_list.disabled = true;
307 JSAN.use('util.print');
308 var print = new util.print('default');
309 var robj = fieldmapper.standardRequest(
310 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
317 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
318 print.simple( robj.template_output().data() );
321 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
324 progressmeter.mode = 'determined';
325 progressmeter.hidden = true;
326 x_print_full_pull_list.disabled = false;
330 'cmd_holds_print_alt' : [
334 var content_params = {
336 "authtime": ses("authtime"),
338 "show_nav_buttons": true,
339 "show_print_button": false
341 ["url_prefix", "new_tab", "set_tab",
342 "close_tab", "new_patron_tab",
343 "set_patron_tab", "volume_item_creator",
345 "holdings_maintenance_tab", "set_tab_name",
346 "open_chrome_window", "url_prefix",
347 "network_meter", "page_meter",
348 "set_statusbar", "set_help_context"
349 ].forEach(function(k) {
350 content_params[k] = xulG[k];
353 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
354 xulG.url_prefix("/opac/extras/circ/alt_pull_list.html").replace("http:","https:")
358 "tab_name": "Printable Pull List", /* XXX i18n */
363 g.error.sdump("D_ERROR", E);
367 'cmd_holds_print' : [
371 JSAN.use('patron.util');
373 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
376 obj.list.print(params);
378 obj.error.standard_unexpected_error_alert('print 1',E);
382 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
383 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
384 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
386 'cmd_holds_edit_selection_depth' : [
390 JSAN.use('util.widgets'); JSAN.use('util.functional');
391 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
392 var list = util.functional.map_list(
393 util.functional.filter_list(
396 if (o.depth() > ws_type.depth()) return false;
397 if (o.depth() < ws_type.depth()) return true;
398 return (o.id() == ws_type.id());
410 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
411 ml.setAttribute('id','selection');
412 ml.setAttribute('name','fancy_data');
413 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
414 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
415 xml += util.widgets.serialize_node(ml);
417 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
418 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
419 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
420 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
421 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
422 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
423 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
424 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
425 JSAN.use('util.window'); var win = new util.window();
426 var fancy_prompt_data = win.open(
427 urls.XUL_FANCY_PROMPT,
428 //+ '?xml_in_stash=temp_mid'
429 //+ '&bottom_xml_in_stash=temp_bot'
430 //+ '&title=' + window.escape('Choose a Pick Up Library'),
431 'fancy_prompt', 'chrome,resizable,modal',
432 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
434 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
435 var selection = fancy_prompt_data.selection;
437 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
439 if(obj.retrieve_ids.length > 1) {
440 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
442 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
445 var r = obj.error.yns_alert(msg,
446 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
447 $("commonStrings").getString('common.yes'),
448 $("commonStrings").getString('common.no'),
450 $("commonStrings").getString('common.check_to_confirm')
453 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
456 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
461 'cmd_holds_edit_pickup_lib' : [
465 JSAN.use('util.widgets'); JSAN.use('util.functional');
467 var list = util.functional.map_list(
470 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
472 o.name() ? sname + ' ' + o.name() : o.shortname(),
474 ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
475 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
479 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
480 ml.setAttribute('id','lib');
481 ml.setAttribute('name','fancy_data');
482 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
483 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
484 xml += util.widgets.serialize_node(ml);
486 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
487 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
488 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
489 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
490 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
491 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
492 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
493 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
494 JSAN.use('util.window'); var win = new util.window();
495 var fancy_prompt_data = win.open(
496 urls.XUL_FANCY_PROMPT,
497 //+ '?xml_in_stash=temp_mid'
498 //+ '&bottom_xml_in_stash=temp_bot'
499 //+ '&title=' + window.escape('Choose a Pick Up Library'),
500 'fancy_prompt', 'chrome,resizable,modal',
501 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
503 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
504 var pickup_lib = fancy_prompt_data.lib;
506 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
508 if(obj.retrieve_ids.length > 1) {
509 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()]);
511 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()]);
513 var r = obj.error.yns_alert(msg,
514 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
515 $("commonStrings").getString('common.yes'),
516 $("commonStrings").getString('common.no'),
518 $("commonStrings").getString('common.check_to_confirm')
521 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
524 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
528 'cmd_holds_edit_phone_notify' : [
532 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
533 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
534 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
536 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
537 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
538 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
539 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
540 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
541 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
542 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
543 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
544 JSAN.use('util.window'); var win = new util.window();
545 var fancy_prompt_data = win.open(
546 urls.XUL_FANCY_PROMPT,
547 //+ '?xml_in_stash=temp_mid'
548 //+ '&bottom_xml_in_stash=temp_bot'
549 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
551 'fancy_prompt', 'chrome,resizable,modal',
552 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
554 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
555 var phone = fancy_prompt_data.phone;
557 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
559 if(obj.retrieve_ids.length > 1) {
560 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
562 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
564 var r = obj.error.yns_alert(msg,
565 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
566 $("commonStrings").getString('common.yes'),
567 $("commonStrings").getString('common.no'),
569 $("commonStrings").getString('common.check_to_confirm')
572 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
575 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
579 'cmd_holds_edit_email_notify' : [
583 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
584 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
585 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
586 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
587 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
588 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
590 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
591 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
592 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
593 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
594 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
595 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
596 JSAN.use('util.window'); var win = new util.window();
597 var fancy_prompt_data = win.open(
598 urls.XUL_FANCY_PROMPT,
599 //+ '?xml_in_stash=temp_mid'
600 //+ '&bottom_xml_in_stash=temp_bot'
601 //+ '&title=' + window.escape('Set Email Notification for Holds'),
602 'fancy_prompt', 'chrome,resizable,modal',
603 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
605 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
606 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
608 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
610 if(get_bool(email)) {
611 if(obj.retrieve_ids.length > 1) {
612 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
614 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
617 if(obj.retrieve_ids.length > 1) {
618 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
620 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
624 var r = obj.error.yns_alert(msg,
625 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
626 $("commonStrings").getString('common.yes'),
627 $("commonStrings").getString('common.no'),
629 $("commonStrings").getString('common.check_to_confirm')
632 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
635 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
639 'cmd_holds_cut_in_line' : [
643 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
644 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
645 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
646 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
647 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
648 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
650 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
651 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
652 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
653 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
654 JSAN.use('util.window'); var win = new util.window();
655 var fancy_prompt_data = win.open(
656 urls.XUL_FANCY_PROMPT,
657 'fancy_prompt', 'chrome,resizable,modal',
658 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
660 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
661 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
663 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
666 if(obj.retrieve_ids.length > 1) {
667 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
669 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
672 if(obj.retrieve_ids.length > 1) {
673 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
675 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
679 var r = obj.error.yns_alert(msg,
680 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
681 $("commonStrings").getString('common.yes'),
682 $("commonStrings").getString('common.no'),
684 $("commonStrings").getString('common.check_to_confirm')
687 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
690 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
694 'cmd_holds_edit_desire_mint_condition' : [
698 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
699 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
700 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
701 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
702 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
703 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
705 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
706 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
707 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
708 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
709 JSAN.use('util.window'); var win = new util.window();
710 var fancy_prompt_data = win.open(
711 urls.XUL_FANCY_PROMPT,
712 'fancy_prompt', 'chrome,resizable,modal',
713 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
715 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
716 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
718 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
721 if(obj.retrieve_ids.length > 1) {
722 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
724 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
727 if(obj.retrieve_ids.length > 1) {
728 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
730 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
734 var r = obj.error.yns_alert(msg,
735 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
736 $("commonStrings").getString('common.yes'),
737 $("commonStrings").getString('common.no'),
739 $("commonStrings").getString('common.check_to_confirm')
742 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
745 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
751 'cmd_holds_suspend' : [
755 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
756 var r = obj.error.yns_alert(
757 obj.retrieve_ids.length > 1 ?
758 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
759 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
760 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
761 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
762 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
764 document.getElementById('commonStrings').getString('common.confirm')
767 var already_suspended = []; var filtered_hold_list = [];
768 for (var i = 0; i < obj.retrieve_ids.length; i++) {
769 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
770 if ( get_bool( hold.frozen() ) ) {
771 already_suspended.push( hold.id() );
774 filtered_hold_list.push( hold.id() );
776 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
777 if (already_suspended.length == 1) {
778 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
779 } else if (already_suspended.length > 1) {
780 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
782 obj.clear_and_retrieve(true);
786 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
790 'cmd_holds_activate' : [
794 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
795 var r = obj.error.yns_alert(
796 obj.retrieve_ids.length > 1 ?
797 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
798 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
799 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
800 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
801 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
803 document.getElementById('commonStrings').getString('common.confirm')
806 var already_activated = []; var filtered_hold_list = [];
807 for (var i = 0; i < obj.retrieve_ids.length; i++) {
808 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
809 if ( ! get_bool( hold.frozen() ) ) {
810 already_activated.push( hold.id() );
813 filtered_hold_list.push( hold.id() );
815 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
816 if (already_activated.length == 1) {
817 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
818 } else if (already_activated.length > 1) {
819 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
821 obj.clear_and_retrieve(true);
825 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
829 'cmd_holds_edit_thaw_date' : [
833 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
834 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
835 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
836 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
837 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
838 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
840 JSAN.use('util.window'); var win = new util.window();
841 var my_xulG = win.open(
842 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
845 'description' : desc,
847 'allow_unset' : true,
848 'disallow_future_dates' : false,
849 'disallow_past_dates' : true,
850 'disallow_today' : true,
851 'default_time' : '00:00:00',
852 'time_readonly' : false
855 if (my_xulG.complete) {
856 circ.util.batch_hold_update(
858 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
859 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
863 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
867 'cmd_holds_edit_expire_time' : [
871 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
872 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
873 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
874 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
875 var value = 'YYYY-MM-DD';
876 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
877 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
879 JSAN.use('util.window'); var win = new util.window();
880 var my_xulG = win.open(
881 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
884 'description' : desc,
886 'allow_unset' : true,
887 'disallow_future_dates' : false,
888 'disallow_past_dates' : true,
889 'disallow_today' : true,
890 'default_time' : '00:00:00',
891 'time_readonly' : false
894 if (my_xulG.complete) {
895 circ.util.batch_hold_update(
897 { 'expire_time' : my_xulG.timestamp },
898 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
902 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
906 'cmd_holds_edit_shelf_expire_time' : [
910 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
911 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
912 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
913 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
914 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
915 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
917 JSAN.use('util.window'); var win = new util.window();
918 var my_xulG = win.open(
919 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
922 'description' : desc,
924 'allow_unset' : false,
925 'disallow_future_dates' : false,
926 'disallow_past_dates' : false,
927 'disallow_today' : false
930 if (my_xulG.complete) {
931 circ.util.batch_hold_update(
933 { 'shelf_expire_time' : my_xulG.timestamp },
934 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
938 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
942 'cmd_holds_edit_request_date' : [
946 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
947 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
948 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
949 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
950 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
951 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
953 JSAN.use('util.window'); var win = new util.window();
954 var my_xulG = win.open(
955 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
958 'description' : desc,
960 'allow_unset' : false,
961 'disallow_future_dates' : true,
962 'disallow_past_dates' : false,
963 'disallow_today' : false
966 if (my_xulG.complete) {
967 circ.util.batch_hold_update(
969 { 'request_time' : my_xulG.timestamp },
970 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
974 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
978 'cmd_holds_retarget' : [
982 JSAN.use('util.functional');
984 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
986 if(obj.retrieve_ids.length > 1) {
987 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
989 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
991 var r = obj.error.yns_alert(msg,
992 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
993 $("commonStrings").getString('common.yes'),
994 $("commonStrings").getString('common.no'),
996 $("commonStrings").getString('common.check_to_confirm')
999 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1000 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
1001 if (typeof robj.ilsevent != 'undefined') throw(robj);
1003 obj.clear_and_retrieve();
1006 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
1012 'cmd_holds_cancel' : [
1016 JSAN.use('util.functional');
1018 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1020 if(obj.retrieve_ids.length > 1 ) {
1021 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
1023 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
1026 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1027 JSAN.use('util.window');
1028 var win = new util.window();
1029 var my_xulG = win.open(
1030 urls.XUL_HOLD_CANCEL,
1032 'chrome,resizable,modal',
1035 /*var r = obj.error.yns_alert(msg,
1036 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1037 $("commonStrings").getString('common.yes'),
1038 $("commonStrings").getString('common.no'),
1040 $("commonStrings").getString('common.check_to_confirm')
1043 if (my_xulG.proceed) {
1045 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1046 if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
1047 transits.push( obj.retrieve_ids[i].barcode );
1049 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1050 if (typeof robj.ilsevent != 'undefined') throw(robj);
1052 if (transits.length > 0) {
1053 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1054 var r2 = obj.error.yns_alert(msg2,
1055 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1056 $("commonStrings").getString('common.yes'),
1057 $("commonStrings").getString('common.no'),
1059 $("commonStrings").getString('common.check_to_confirm'));
1062 for (var i = 0; i < transits.length; i++) {
1063 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1064 if (typeof robj.ilsevent != 'undefined') {
1065 switch(Number(robj.ilsevent)) {
1066 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1069 case 5000 /* PERM_FAILURE */ :
1078 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1082 obj.clear_and_retrieve();
1085 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1089 'cmd_holds_uncancel' : [
1093 JSAN.use('util.functional');
1094 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1095 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1096 if (typeof robj.ilsevent != 'undefined') throw(robj);
1098 obj.clear_and_retrieve();
1100 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1105 'cmd_retrieve_patron' : [
1110 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1111 var patron_id = obj.retrieve_ids[i].usr;
1112 if (seen[patron_id]) continue; seen[patron_id] = true;
1113 xulG.new_patron_tab(
1115 { 'id' : patron_id }
1119 obj.error.standard_unexpected_error_alert('',E);
1123 'cmd_show_catalog' : [
1127 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1128 var htarget = obj.retrieve_ids[i].target;
1129 var htype = obj.retrieve_ids[i].type;
1133 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1136 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1139 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1140 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1143 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1145 if (typeof my_acp.call_number() == 'object') {
1146 my_acn = my.acp.call_number();
1148 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1149 [ my_acp.call_number() ]);
1151 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1154 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1158 var content_params = {
1160 'authtime' : ses('authtime'),
1161 'opac_url' : opac_url
1164 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1165 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1170 obj.error.standard_unexpected_error_alert('',E);
1174 'cmd_holds_title_transfer' : [
1179 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1180 var htarget = obj.retrieve_ids[i].target;
1181 var htype = obj.retrieve_ids[i].type;
1184 continue; // not supported
1187 targets.push( htarget );
1190 continue; // not supported
1193 continue; // not supported
1196 continue; // not supported
1200 JSAN.use('cat.util');
1201 cat.util.transfer_title_holds(targets);
1202 obj.clear_and_retrieve();
1204 obj.error.standard_unexpected_error_alert('',E);
1212 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1216 'lib_filter_checkbox' : [
1219 var x_lib_type_menu = document.getElementById('lib_type_menu');
1220 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1221 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1222 obj.clear_and_retrieve();
1223 ev.target.setAttribute('checked',ev.target.checked);
1226 'cmd_view_expired_onshelf_holds' : [
1229 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1230 obj.expired = x.checked;
1231 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1232 obj.clear_and_retrieve();
1235 'cmd_clear_expired_onshelf_holds' : [
1239 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1240 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1241 if (robj == null) { robj = []; }
1242 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1243 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1245 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1246 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1247 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1248 var x_lib_type_menu = document.getElementById('lib_type_menu');
1249 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1250 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1251 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1252 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1253 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1255 // id's in xulG.holds will prevent the normal retrieval method from firing
1256 JSAN.use('util.functional');
1257 xulG.holds = util.functional.map_list(
1258 robj.sort(function(a,b) {
1259 if (a.action > b.action) { return 1; }
1260 if (a.action < b.action) { return -1; }
1263 function (element, idx) {
1264 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1265 return element.hold_id;
1268 obj.clear_and_retrieve();
1270 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1271 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1276 'cmd_search_opac' : [
1280 var content_params = {
1281 'show_nav_buttons' : false,
1282 'show_print_button' : true,
1283 'passthru_content_params' : {
1284 'authtoken' : ses(),
1285 'authtime' : ses('authtime'),
1286 'window_open' : function(a,b,c) {
1288 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1289 return window.open(a,b,c);
1291 obj.error.standard_unexpected_error_alert('window_open',E);
1294 'opac_hold_placed' : function(hold) {
1300 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1305 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1306 window.xulG.on_list_change();
1309 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1312 'patron_barcode' : obj.patron_barcode
1314 'url_prefix' : xulG.url_prefix,
1315 'url' : xulG.url_prefix( urls.browser )
1317 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1319 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1328 obj.determine_hold_interface_type();
1329 var x_fetch_more = document.getElementById('fetch_more');
1330 var x_lib_type_menu = document.getElementById('lib_type_menu');
1331 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1332 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1333 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1334 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1335 var x_expired_checkbox = document.getElementById('expired_checkbox');
1336 var x_print_full_pull_list = document.getElementById('print_full_btn');
1337 switch(obj.hold_interface_type) {
1339 obj.render_lib_menus({'pickup_lib':true});
1340 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1341 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1342 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1343 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1346 if (x_fetch_more) x_fetch_more.hidden = false;
1347 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1348 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1349 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1352 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1353 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1354 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1355 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1358 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1359 if (x_fetch_more) x_fetch_more.hidden = true;
1360 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1361 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1362 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1365 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
1367 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1368 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1369 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1371 obj.controller.render();
1374 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1375 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1376 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1377 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1378 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1379 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1380 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1381 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1382 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1383 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1384 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1385 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1386 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1390 $('cmd_alt_view').setAttribute('disabled','true');
1391 xulG.when_done = function() {
1392 $('cmd_alt_view').setAttribute('ready','true');
1393 if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1394 $('cmd_alt_view').setAttribute('disabled','false');
1396 dump('hold details UI ready\n');
1398 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1399 JSAN.use('util.browser');
1400 obj.browser = new util.browser();
1403 'url' : urls.XUL_HOLD_DETAILS,
1405 'alt_print' : false,
1406 'browser_id' : 'hold_detail_frame',
1407 'passthru_content_params' : xulG
1413 'determine_hold_interface_type' : function() {
1415 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1416 obj.hold_interface_type = 'patron';
1417 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1418 obj.hold_interface_type = 'record';
1419 } else if (obj.pull) { /*************************************************** PULL ******************************/
1420 obj.hold_interface_type = 'pull';
1421 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1422 obj.hold_interface_type = 'shelf';
1423 } else { /*************************************************** PULL ******************************/
1424 obj.hold_interface_type = 'pull';
1428 'clear_and_retrieve' : function() {
1431 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1433 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1434 window.xulG.on_list_change();
1437 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1441 'retrieve' : function() {
1442 var obj = this; var holds = [];
1443 if (window.xulG && window.xulG.holds) {
1444 holds = window.xulG.holds;
1446 var method; var params = [ ses() ];
1447 switch(obj.hold_interface_type) {
1449 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1450 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1452 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1454 params.push( obj.patron_id );
1455 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1458 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1459 params.push( obj.docid );
1460 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1461 var x_lib_type_menu = document.getElementById('lib_type_menu');
1463 if (x_lib_filter.checked) {
1464 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1466 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1471 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1475 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1477 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1479 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1480 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1484 method = 'FM_AHR_ID_LIST_PULL_LIST';
1485 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1486 var x = document.getElementById('hold_count');
1488 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1489 var count = req.getResultObject();
1490 if (typeof count.ilsevent == 'undefined' && count != null) {
1491 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1492 'staff.patron.holds.total_count',
1501 var robj = obj.network.simple_request( method, params );
1502 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1503 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1506 holds = holds.concat( robj.copy_holds );
1507 holds = holds.concat( robj.volume_holds );
1508 holds = holds.concat( robj.title_holds );
1509 holds = holds.concat( robj.metarecord_holds );
1510 holds = holds.sort();
1513 if (robj == null ) {
1516 if (typeof robj.length == 'undefined') {
1524 //alert('method = ' + method + ' params = ' + js2JSON(params));
1527 var x_fetch_more = document.getElementById('fetch_more');
1528 if (holds.length == 0) {
1529 if (x_fetch_more) x_fetch_more.disabled = true;
1531 if (x_fetch_more) x_fetch_more.disabled = false;
1537 'render' : function(holds) {
1541 function list_append(hold_id) {
1546 'hold_id' : hold_id,
1547 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1554 function gen_list_append(hold) {
1556 if (typeof obj.controller.view.lib_menu == 'undefined') {
1557 list_append(typeof hold == 'object' ? hold.id() : hold);
1559 list_append(typeof hold == 'object' ? hold.id() : hold);
1566 JSAN.use('util.exec'); var exec = new util.exec(2);
1568 for (var i in holds) {
1569 rows.push( gen_list_append(holds[i]) );
1574 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1578 'render_lib_menus' : function(types) {
1581 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1583 var x = document.getElementById('lib_type_menu');
1585 var nodes = x.firstChild.childNodes;
1586 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1587 for (var i in types) document.getElementById(i).hidden = false;
1589 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1591 x = document.getElementById('lib_menu_placeholder');
1592 util.widgets.remove_children( x );
1594 JSAN.use('util.file');
1595 var file = new util.file('offline_ou_list');
1596 if (file._file.exists()) {
1597 var list_data = file.get_object(); file.close();
1598 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1599 ml.setAttribute('id','lib_menu');
1600 x.appendChild( ml );
1601 ml.addEventListener(
1604 obj.filter_lib = ev.target.value;
1605 obj.clear_and_retrieve();
1609 obj.controller.view.lib_menu = ml;
1611 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1615 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1620 dump('exiting patron.holds.js\n');