1 dump('entering patron.holds.js\n');
3 function $(id) { return document.getElementById(id); }
5 if (typeof patron == 'undefined') patron = {};
6 patron.holds = function (params) {
8 JSAN.use('util.error'); this.error = new util.error();
9 JSAN.use('util.network'); this.network = new util.network();
10 JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
13 patron.holds.prototype = {
15 'hold_interface_type' : null,
17 'pull_from_shelf_interface' : {
18 '_default' : { 'limit' : 100, 'offset' : 0 },
19 'current' : { 'limit' : 100, 'offset' : 0 }
25 'post_clear_shelf_hold_action_map' : {},
31 'flatten_copy' : function(hold) {
32 try { if ( hold.current_copy() && typeof hold.current_copy() == 'object') hold.current_copy( hold.current_copy().id() ); } catch(E) { alert('FIXME: Error flattening hold before hold update: ' + E); }
36 'init' : function( params ) {
40 obj.patron_id = params['patron_id'];
41 obj.patron_barcode = params['patron_barcode'];
42 obj.docid = params['docid'];
43 obj.shelf = params['shelf'];
44 obj.tree_id = params['tree_id'];
46 var progressmeter = document.getElementById('progress');
48 JSAN.use('circ.util');
49 var columns = circ.util.hold_columns(
51 'title' : { 'hidden' : false, 'flex' : '3' },
52 'request_time' : { 'hidden' : false },
53 'pickup_lib_shortname' : { 'hidden' : false },
54 'hold_type' : { 'hidden' : false },
55 'current_copy' : { 'hidden' : false },
56 'capture_time' : { 'hidden' : false },
57 'notify_time' : { 'hidden' : false },
58 'notify_count' : { 'hidden' : false },
59 'cancel_cause' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
60 'cancel_note' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
61 'cancel_time' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
62 'post_clear_shelf_action' : { 'hidden' : obj.shelf ? false : true }
66 JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
70 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
71 'retrieve_row' : function(params) {
74 obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
77 var blob = blob_req.getResultObject();
78 if (typeof blob.ilsevent != 'undefined') throw(blob);
79 row.my.ahr = blob.hold;
80 row.my.status = blob.status;
81 row.my.ahr.status( blob.status );
82 row.my.acp = blob.copy;
83 row.my.acn = blob.volume;
84 row.my.mvr = blob.mvr;
85 row.my.patron_family_name = blob.patron_last;
86 row.my.patron_first_given_name = blob.patron_first;
87 row.my.patron_barcode = blob.patron_barcode;
88 row.my.total_holds = blob.total_holds;
89 row.my.queue_position = blob.queue_position;
90 row.my.potential_copies = blob.potential_copies;
91 row.my.estimated_wait = blob.estimated_wait;
92 row.my.ahrn_count = blob.hold.notes().length;
94 var copy_id = row.my.ahr.current_copy();
95 if (typeof copy_id == 'object') {
96 if (copy_id == null) {
97 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
99 copy_id = copy_id.id();
102 copy_id = row.my.acp.id();
105 obj.holds_map[ row.my.ahr.id() ] = blob;
106 params.row_node.setAttribute('retrieve_id',
109 'barcode':row.my.acp ? row.my.acp.barcode() : null,
110 'id':row.my.ahr.id(),
111 'type':row.my.ahr.hold_type(),
112 'target':row.my.ahr.target(),
113 'usr':row.my.ahr.usr()
116 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
119 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
124 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
128 'on_select' : function(ev) {
129 JSAN.use('util.functional');
130 var sel = obj.list.retrieve_selection();
131 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
132 obj.retrieve_ids = util.functional.map_list(
134 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
136 if (obj.retrieve_ids.length > 0) {
137 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
138 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
139 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
140 obj.controller.view.sel_patron.setAttribute('disabled','false');
141 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
142 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
143 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
144 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
145 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
146 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
147 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
148 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
149 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
150 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
151 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
152 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
153 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
154 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
155 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
156 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
157 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
159 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
160 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
161 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
162 obj.controller.view.sel_patron.setAttribute('disabled','true');
163 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
164 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
165 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
166 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
167 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
168 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
169 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
170 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
171 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
172 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
173 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
174 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
175 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
176 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
177 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
178 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
179 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
185 JSAN.use('util.controller'); obj.controller = new util.controller();
189 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
192 function() { obj.list.clipboard(); }
196 function() { alert($("commonStrings").getString('common.unimplemented')); }
201 JSAN.use('circ.util');
202 circ.util.show_last_few_circs(obj.retrieve_ids);
208 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
209 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
216 var n = obj.controller.view.alt_view_btn;
217 if (n.getAttribute('toggle') == '1') {
218 document.getElementById('deck').selectedIndex = 0;
219 n.setAttribute('toggle','0');
220 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
221 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
223 document.getElementById('deck').selectedIndex = 1;
224 n.setAttribute('toggle','1');
225 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
226 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
227 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
228 if (obj.retrieve_ids.length == 0) return;
229 var f = obj.browser.get_content();
230 xulG.ahr_id = obj.retrieve_ids[0].id;
231 xulG.blob = obj.holds_map[ xulG.ahr_id ];
232 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
233 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
235 f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
236 f.fetch_and_render_all(true);
239 alert('Error in holds.js, cmd_alt_view handler: ' + E);
243 'cmd_cancelled_holds_view' : [
246 document.getElementById('show_cancelled_deck').selectedIndex = 1;
247 /* For some reason attribute propogation on the <command> element isn't working with hidden */
248 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
249 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
250 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
251 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
252 obj.clear_and_retrieve();
255 'cmd_uncancelled_holds_view' : [
258 document.getElementById('show_cancelled_deck').selectedIndex = 0;
259 /* For some reason attribute propogation on the <command> element isn't working with hidden */
260 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
261 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
262 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
263 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
264 obj.clear_and_retrieve();
267 'sel_mark_items_damaged' : [
270 JSAN.use('cat.util'); JSAN.use('util.functional');
271 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
274 'sel_mark_items_missing' : [
277 JSAN.use('cat.util'); JSAN.use('util.functional');
278 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
281 'sel_copy_details' : [
284 JSAN.use('circ.util');
285 circ.util.item_details_new(
286 util.functional.map_list(
288 function(o) { return o.barcode; }
293 'cmd_holds_print_full' : [
296 var x_print_full_pull_list = document.getElementById('print_full_btn');
299 progressmeter.mode = 'undetermined';
300 progressmeter.hidden = false;
301 x_print_full_pull_list.disabled = true;
303 JSAN.use('util.print');
304 var print = new util.print('default');
305 var robj = fieldmapper.standardRequest(
306 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
313 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
314 print.simple( robj.template_output().data() );
317 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
320 progressmeter.mode = 'determined';
321 progressmeter.hidden = true;
322 x_print_full_pull_list.disabled = false;
326 'cmd_holds_print' : [
330 JSAN.use('patron.util');
332 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
335 obj.list.print(params);
337 obj.error.standard_unexpected_error_alert('print 1',E);
341 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
342 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
343 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
345 'cmd_holds_edit_selection_depth' : [
349 JSAN.use('util.widgets'); JSAN.use('util.functional');
350 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
351 var list = util.functional.map_list(
352 util.functional.filter_list(
355 if (o.depth() > ws_type.depth()) return false;
356 if (o.depth() < ws_type.depth()) return true;
357 return (o.id() == ws_type.id());
369 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
370 ml.setAttribute('id','selection');
371 ml.setAttribute('name','fancy_data');
372 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
373 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
374 xml += util.widgets.serialize_node(ml);
376 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
377 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
378 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
379 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
380 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
381 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
382 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
383 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
384 JSAN.use('util.window'); var win = new util.window();
385 var fancy_prompt_data = win.open(
386 urls.XUL_FANCY_PROMPT,
387 //+ '?xml_in_stash=temp_mid'
388 //+ '&bottom_xml_in_stash=temp_bot'
389 //+ '&title=' + window.escape('Choose a Pick Up Library'),
390 'fancy_prompt', 'chrome,resizable,modal',
391 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
393 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
394 var selection = fancy_prompt_data.selection;
396 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
398 if(obj.retrieve_ids.length > 1) {
399 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
401 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
404 var r = obj.error.yns_alert(msg,
405 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
406 $("commonStrings").getString('common.yes'),
407 $("commonStrings").getString('common.no'),
409 $("commonStrings").getString('common.check_to_confirm')
412 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
415 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
420 'cmd_holds_edit_pickup_lib' : [
424 JSAN.use('util.widgets'); JSAN.use('util.functional');
426 var list = util.functional.map_list(
429 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
431 o.name() ? sname + ' ' + o.name() : o.shortname(),
433 ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
434 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
438 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
439 ml.setAttribute('id','lib');
440 ml.setAttribute('name','fancy_data');
441 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
442 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
443 xml += util.widgets.serialize_node(ml);
445 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
446 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
447 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
448 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
449 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
450 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
451 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
452 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
453 JSAN.use('util.window'); var win = new util.window();
454 var fancy_prompt_data = win.open(
455 urls.XUL_FANCY_PROMPT,
456 //+ '?xml_in_stash=temp_mid'
457 //+ '&bottom_xml_in_stash=temp_bot'
458 //+ '&title=' + window.escape('Choose a Pick Up Library'),
459 'fancy_prompt', 'chrome,resizable,modal',
460 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
462 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
463 var pickup_lib = fancy_prompt_data.lib;
465 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
467 if(obj.retrieve_ids.length > 1) {
468 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()]);
470 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()]);
472 var r = obj.error.yns_alert(msg,
473 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
474 $("commonStrings").getString('common.yes'),
475 $("commonStrings").getString('common.no'),
477 $("commonStrings").getString('common.check_to_confirm')
480 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
483 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
487 'cmd_holds_edit_phone_notify' : [
491 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
492 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
493 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
495 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
496 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
497 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
498 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
499 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
500 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
501 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
502 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
503 JSAN.use('util.window'); var win = new util.window();
504 var fancy_prompt_data = win.open(
505 urls.XUL_FANCY_PROMPT,
506 //+ '?xml_in_stash=temp_mid'
507 //+ '&bottom_xml_in_stash=temp_bot'
508 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
510 'fancy_prompt', 'chrome,resizable,modal',
511 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
513 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
514 var phone = fancy_prompt_data.phone;
516 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
518 if(obj.retrieve_ids.length > 1) {
519 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
521 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
523 var r = obj.error.yns_alert(msg,
524 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
525 $("commonStrings").getString('common.yes'),
526 $("commonStrings").getString('common.no'),
528 $("commonStrings").getString('common.check_to_confirm')
531 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
534 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
538 'cmd_holds_edit_email_notify' : [
542 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
543 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
544 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
545 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
546 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
547 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
549 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
550 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
551 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
552 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
553 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
554 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
555 JSAN.use('util.window'); var win = new util.window();
556 var fancy_prompt_data = win.open(
557 urls.XUL_FANCY_PROMPT,
558 //+ '?xml_in_stash=temp_mid'
559 //+ '&bottom_xml_in_stash=temp_bot'
560 //+ '&title=' + window.escape('Set Email Notification for Holds'),
561 'fancy_prompt', 'chrome,resizable,modal',
562 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
564 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
565 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
567 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
569 if(get_bool(email)) {
570 if(obj.retrieve_ids.length > 1) {
571 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
573 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
576 if(obj.retrieve_ids.length > 1) {
577 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
579 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
583 var r = obj.error.yns_alert(msg,
584 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
585 $("commonStrings").getString('common.yes'),
586 $("commonStrings").getString('common.no'),
588 $("commonStrings").getString('common.check_to_confirm')
591 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
594 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
598 'cmd_holds_cut_in_line' : [
602 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
603 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
604 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
605 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
606 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
607 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
609 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
610 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
611 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
612 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
613 JSAN.use('util.window'); var win = new util.window();
614 var fancy_prompt_data = win.open(
615 urls.XUL_FANCY_PROMPT,
616 'fancy_prompt', 'chrome,resizable,modal',
617 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
619 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
620 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
622 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
625 if(obj.retrieve_ids.length > 1) {
626 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
628 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
631 if(obj.retrieve_ids.length > 1) {
632 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
634 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
638 var r = obj.error.yns_alert(msg,
639 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
640 $("commonStrings").getString('common.yes'),
641 $("commonStrings").getString('common.no'),
643 $("commonStrings").getString('common.check_to_confirm')
646 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
649 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
653 'cmd_holds_edit_desire_mint_condition' : [
657 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
658 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
659 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
660 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
661 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
662 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
664 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
665 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
666 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
667 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
668 JSAN.use('util.window'); var win = new util.window();
669 var fancy_prompt_data = win.open(
670 urls.XUL_FANCY_PROMPT,
671 'fancy_prompt', 'chrome,resizable,modal',
672 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
674 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
675 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
677 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
680 if(obj.retrieve_ids.length > 1) {
681 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
683 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
686 if(obj.retrieve_ids.length > 1) {
687 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
689 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
693 var r = obj.error.yns_alert(msg,
694 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
695 $("commonStrings").getString('common.yes'),
696 $("commonStrings").getString('common.no'),
698 $("commonStrings").getString('common.check_to_confirm')
701 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
704 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
710 'cmd_holds_suspend' : [
714 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
715 var r = obj.error.yns_alert(
716 obj.retrieve_ids.length > 1 ?
717 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
718 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
719 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
720 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
721 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
723 document.getElementById('commonStrings').getString('common.confirm')
726 var already_suspended = []; var filtered_hold_list = [];
727 for (var i = 0; i < obj.retrieve_ids.length; i++) {
728 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
729 if ( get_bool( hold.frozen() ) ) {
730 already_suspended.push( hold.id() );
733 filtered_hold_list.push( hold.id() );
735 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
736 if (already_suspended.length == 1) {
737 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
738 } else if (already_suspended.length > 1) {
739 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
741 obj.clear_and_retrieve(true);
745 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
749 'cmd_holds_activate' : [
753 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
754 var r = obj.error.yns_alert(
755 obj.retrieve_ids.length > 1 ?
756 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
757 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
758 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
759 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
760 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
762 document.getElementById('commonStrings').getString('common.confirm')
765 var already_activated = []; var filtered_hold_list = [];
766 for (var i = 0; i < obj.retrieve_ids.length; i++) {
767 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
768 if ( ! get_bool( hold.frozen() ) ) {
769 already_activated.push( hold.id() );
772 filtered_hold_list.push( hold.id() );
774 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
775 if (already_activated.length == 1) {
776 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
777 } else if (already_activated.length > 1) {
778 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
780 obj.clear_and_retrieve(true);
784 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
788 'cmd_holds_edit_thaw_date' : [
792 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
793 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
794 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
795 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
796 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
797 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
799 JSAN.use('util.window'); var win = new util.window();
800 var my_xulG = win.open(
801 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
804 'description' : desc,
806 'allow_unset' : true,
807 'disallow_future_dates' : false,
808 'disallow_past_dates' : true,
809 'disallow_today' : true,
810 'default_time' : '00:00:00',
811 'time_readonly' : false
814 if (my_xulG.complete) {
815 circ.util.batch_hold_update(
817 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
818 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
822 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
826 'cmd_holds_edit_expire_time' : [
830 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
831 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
832 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
833 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
834 var value = 'YYYY-MM-DD';
835 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
836 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
838 JSAN.use('util.window'); var win = new util.window();
839 var my_xulG = win.open(
840 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
843 'description' : desc,
845 'allow_unset' : true,
846 'disallow_future_dates' : false,
847 'disallow_past_dates' : true,
848 'disallow_today' : true,
849 'default_time' : '00:00:00',
850 'time_readonly' : false
853 if (my_xulG.complete) {
854 circ.util.batch_hold_update(
856 { 'expire_time' : my_xulG.timestamp },
857 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
861 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
865 'cmd_holds_edit_shelf_expire_time' : [
869 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
870 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
871 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
872 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
873 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
874 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
876 JSAN.use('util.window'); var win = new util.window();
877 var my_xulG = win.open(
878 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
881 'description' : desc,
883 'allow_unset' : false,
884 'disallow_future_dates' : false,
885 'disallow_past_dates' : false,
886 'disallow_today' : false
889 if (my_xulG.complete) {
890 circ.util.batch_hold_update(
892 { 'shelf_expire_time' : my_xulG.timestamp },
893 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
897 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
901 'cmd_holds_edit_request_date' : [
905 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
906 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
907 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
908 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
909 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
910 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
912 JSAN.use('util.window'); var win = new util.window();
913 var my_xulG = win.open(
914 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
917 'description' : desc,
919 'allow_unset' : false,
920 'disallow_future_dates' : true,
921 'disallow_past_dates' : false,
922 'disallow_today' : false
925 if (my_xulG.complete) {
926 circ.util.batch_hold_update(
928 { 'request_time' : my_xulG.timestamp },
929 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
933 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
937 'cmd_holds_retarget' : [
941 JSAN.use('util.functional');
943 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
945 if(obj.retrieve_ids.length > 1) {
946 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
948 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
950 var r = obj.error.yns_alert(msg,
951 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
952 $("commonStrings").getString('common.yes'),
953 $("commonStrings").getString('common.no'),
955 $("commonStrings").getString('common.check_to_confirm')
958 for (var i = 0; i < obj.retrieve_ids.length; i++) {
959 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
960 if (typeof robj.ilsevent != 'undefined') throw(robj);
962 obj.clear_and_retrieve();
965 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
971 'cmd_holds_cancel' : [
975 JSAN.use('util.functional');
977 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
979 if(obj.retrieve_ids.length > 1 ) {
980 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
982 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
985 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
986 JSAN.use('util.window');
987 var win = new util.window();
988 var my_xulG = win.open(
989 urls.XUL_HOLD_CANCEL,
991 'chrome,resizable,modal',
994 /*var r = obj.error.yns_alert(msg,
995 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
996 $("commonStrings").getString('common.yes'),
997 $("commonStrings").getString('common.no'),
999 $("commonStrings").getString('common.check_to_confirm')
1002 if (my_xulG.proceed) {
1004 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1005 if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
1006 transits.push( obj.retrieve_ids[i].barcode );
1008 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1009 if (typeof robj.ilsevent != 'undefined') throw(robj);
1011 if (transits.length > 0) {
1012 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1013 var r2 = obj.error.yns_alert(msg2,
1014 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1015 $("commonStrings").getString('common.yes'),
1016 $("commonStrings").getString('common.no'),
1018 $("commonStrings").getString('common.check_to_confirm'));
1021 for (var i = 0; i < transits.length; i++) {
1022 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1023 if (typeof robj.ilsevent != 'undefined') {
1024 switch(Number(robj.ilsevent)) {
1025 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1028 case 5000 /* PERM_FAILURE */ :
1037 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1041 obj.clear_and_retrieve();
1044 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1048 'cmd_holds_uncancel' : [
1052 JSAN.use('util.functional');
1053 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1054 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1055 if (typeof robj.ilsevent != 'undefined') throw(robj);
1057 obj.clear_and_retrieve();
1059 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1064 'cmd_retrieve_patron' : [
1069 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1070 var patron_id = obj.retrieve_ids[i].usr;
1071 if (seen[patron_id]) continue; seen[patron_id] = true;
1072 xulG.new_patron_tab(
1074 { 'id' : patron_id }
1078 obj.error.standard_unexpected_error_alert('',E);
1082 'cmd_show_catalog' : [
1086 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1087 var htarget = obj.retrieve_ids[i].target;
1088 var htype = obj.retrieve_ids[i].type;
1092 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1095 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1098 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1099 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1102 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1104 if (typeof my_acp.call_number() == 'object') {
1105 my_acn = my.acp.call_number();
1107 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1108 [ my_acp.call_number() ]);
1110 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1113 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1117 var content_params = {
1119 'authtime' : ses('authtime'),
1120 'opac_url' : opac_url
1123 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1124 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1129 obj.error.standard_unexpected_error_alert('',E);
1133 'cmd_holds_title_transfer' : [
1138 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1139 var htarget = obj.retrieve_ids[i].target;
1140 var htype = obj.retrieve_ids[i].type;
1143 continue; // not supported
1146 targets.push( htarget );
1149 continue; // not supported
1152 continue; // not supported
1155 continue; // not supported
1159 JSAN.use('cat.util');
1160 cat.util.transfer_title_holds(targets);
1161 obj.clear_and_retrieve();
1163 obj.error.standard_unexpected_error_alert('',E);
1171 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1175 'lib_filter_checkbox' : [
1178 var x_lib_type_menu = document.getElementById('lib_type_menu');
1179 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1180 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1181 obj.clear_and_retrieve();
1182 ev.target.setAttribute('checked',ev.target.checked);
1185 'cmd_view_expired_onshelf_holds' : [
1188 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1189 obj.expired = x.checked;
1190 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1191 obj.clear_and_retrieve();
1194 'cmd_clear_expired_onshelf_holds' : [
1198 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1199 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1200 if (robj == null) { robj = []; }
1201 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1202 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1204 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1205 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1206 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1207 var x_lib_type_menu = document.getElementById('lib_type_menu');
1208 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1209 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1210 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1211 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1212 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1214 // id's in xulG.holds will prevent the normal retrieval method from firing
1215 JSAN.use('util.functional');
1216 xulG.holds = util.functional.map_list(
1217 robj.sort(function(a,b) {
1218 if (a.action > b.action) { return 1; }
1219 if (a.action < b.action) { return -1; }
1222 function (element, idx) {
1223 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1224 return element.hold_id;
1227 obj.clear_and_retrieve();
1229 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1230 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1235 'cmd_search_opac' : [
1239 var content_params = {
1240 'show_nav_buttons' : false,
1241 'show_print_button' : true,
1242 'passthru_content_params' : {
1243 'authtoken' : ses(),
1244 'authtime' : ses('authtime'),
1245 'window_open' : function(a,b,c) {
1247 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1248 return window.open(a,b,c);
1250 obj.error.standard_unexpected_error_alert('window_open',E);
1253 'opac_hold_placed' : function(hold) {
1259 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1264 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1265 window.xulG.on_list_change();
1268 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1271 'patron_barcode' : obj.patron_barcode
1273 'url_prefix' : xulG.url_prefix,
1274 'url' : xulG.url_prefix( urls.browser )
1276 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1278 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1287 obj.determine_hold_interface_type();
1288 var x_fetch_more = document.getElementById('fetch_more');
1289 var x_lib_type_menu = document.getElementById('lib_type_menu');
1290 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1291 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1292 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1293 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1294 var x_expired_checkbox = document.getElementById('expired_checkbox');
1295 var x_print_full_pull_list = document.getElementById('print_full_btn');
1296 switch(obj.hold_interface_type) {
1298 obj.render_lib_menus({'pickup_lib':true});
1299 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1300 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1301 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1302 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1305 if (x_fetch_more) x_fetch_more.hidden = false;
1306 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1307 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1308 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1311 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1312 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1313 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1314 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1317 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1318 if (x_fetch_more) x_fetch_more.hidden = true;
1319 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1320 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1321 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1324 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
1326 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1327 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1328 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1330 obj.controller.render();
1333 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1334 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1335 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1336 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1337 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1338 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1339 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1340 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1341 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1342 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1343 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1344 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1345 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1349 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1350 JSAN.use('util.browser');
1351 obj.browser = new util.browser();
1354 'url' : urls.XUL_HOLD_DETAILS,
1356 'alt_print' : false,
1357 'browser_id' : 'hold_detail_frame',
1358 'passthru_content_params' : xulG,
1364 'determine_hold_interface_type' : function() {
1366 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1367 obj.hold_interface_type = 'patron';
1368 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1369 obj.hold_interface_type = 'record';
1370 } else if (obj.pull) { /*************************************************** PULL ******************************/
1371 obj.hold_interface_type = 'pull';
1372 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1373 obj.hold_interface_type = 'shelf';
1374 } else { /*************************************************** PULL ******************************/
1375 obj.hold_interface_type = 'pull';
1379 'clear_and_retrieve' : function() {
1382 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1384 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1385 window.xulG.on_list_change();
1388 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1392 'retrieve' : function() {
1393 var obj = this; var holds = [];
1394 if (window.xulG && window.xulG.holds) {
1395 holds = window.xulG.holds;
1397 var method; var params = [ ses() ];
1398 switch(obj.hold_interface_type) {
1400 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1401 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1403 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1405 params.push( obj.patron_id );
1406 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1409 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1410 params.push( obj.docid );
1411 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1412 var x_lib_type_menu = document.getElementById('lib_type_menu');
1414 if (x_lib_filter.checked) {
1415 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1417 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1422 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1426 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1428 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1430 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1431 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1435 method = 'FM_AHR_ID_LIST_PULL_LIST';
1436 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1437 var x = document.getElementById('hold_count');
1439 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1440 var count = req.getResultObject();
1441 if (typeof count.ilsevent == 'undefined' && count != null) {
1442 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1443 'staff.patron.holds.total_count',
1452 var robj = obj.network.simple_request( method, params );
1453 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1454 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1457 holds = holds.concat( robj.copy_holds );
1458 holds = holds.concat( robj.volume_holds );
1459 holds = holds.concat( robj.title_holds );
1460 holds = holds.concat( robj.metarecord_holds );
1461 holds = holds.sort();
1464 if (robj == null ) {
1467 if (typeof robj.length == 'undefined') {
1475 //alert('method = ' + method + ' params = ' + js2JSON(params));
1478 var x_fetch_more = document.getElementById('fetch_more');
1479 if (holds.length == 0) {
1480 if (x_fetch_more) x_fetch_more.disabled = true;
1482 if (x_fetch_more) x_fetch_more.disabled = false;
1488 'render' : function(holds) {
1492 function list_append(hold_id) {
1497 'hold_id' : hold_id,
1498 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1505 function gen_list_append(hold) {
1507 if (typeof obj.controller.view.lib_menu == 'undefined') {
1508 list_append(typeof hold == 'object' ? hold.id() : hold);
1510 list_append(typeof hold == 'object' ? hold.id() : hold);
1517 JSAN.use('util.exec'); var exec = new util.exec(2);
1519 for (var i in holds) {
1520 rows.push( gen_list_append(holds[i]) );
1525 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1529 'render_lib_menus' : function(types) {
1532 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1534 var x = document.getElementById('lib_type_menu');
1536 var nodes = x.firstChild.childNodes;
1537 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1538 for (var i in types) document.getElementById(i).hidden = false;
1540 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1542 x = document.getElementById('lib_menu_placeholder');
1543 util.widgets.remove_children( x );
1545 JSAN.use('util.file');
1546 var file = new util.file('offline_ou_list');
1547 if (file._file.exists()) {
1548 var list_data = file.get_object(); file.close();
1549 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1550 ml.setAttribute('id','lib_menu');
1551 x.appendChild( ml );
1552 ml.addEventListener(
1555 obj.filter_lib = ev.target.value;
1556 obj.clear_and_retrieve();
1560 obj.controller.view.lib_menu = ml;
1562 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1566 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1571 dump('exiting patron.holds.js\n');