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' : 50, 'offset' : 0 },
19 'current' : { 'limit' : 50, 'offset' : 0 }
28 'flatten_copy' : function(hold) {
29 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); }
33 'init' : function( params ) {
37 obj.patron_id = params['patron_id'];
38 obj.patron_barcode = params['patron_barcode'];
39 obj.docid = params['docid'];
40 obj.shelf = params['shelf'];
41 obj.tree_id = params['tree_id'];
43 var progressmeter = document.getElementById('progress');
45 JSAN.use('circ.util');
46 var columns = circ.util.hold_columns(
48 'title' : { 'hidden' : false, 'flex' : '3' },
49 'request_time' : { 'hidden' : false },
50 'pickup_lib_shortname' : { 'hidden' : false },
51 'hold_type' : { 'hidden' : false },
52 'current_copy' : { 'hidden' : false },
53 'capture_time' : { 'hidden' : false },
54 'notify_time' : { 'hidden' : false },
55 'notify_count' : { 'hidden' : false },
56 'cancel_cause' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
57 'cancel_note' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
58 'cancel_time' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) }
62 JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
66 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
67 'retrieve_row' : function(params) {
70 obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
73 var blob = blob_req.getResultObject();
74 if (typeof blob.ilsevent != 'undefined') throw(blob);
75 row.my.ahr = blob.hold;
76 row.my.status = blob.status;
77 row.my.ahr.status( blob.status );
78 row.my.acp = blob.copy;
79 row.my.acn = blob.volume;
80 row.my.mvr = blob.mvr;
81 row.my.patron_family_name = blob.patron_last;
82 row.my.patron_first_given_name = blob.patron_first;
83 row.my.patron_barcode = blob.patron_barcode;
84 row.my.total_holds = blob.total_holds;
85 row.my.queue_position = blob.queue_position;
86 row.my.potential_copies = blob.potential_copies;
87 row.my.estimated_wait = blob.estimated_wait;
88 row.my.ahrn_count = blob.hold.notes().length;
90 var copy_id = row.my.ahr.current_copy();
91 if (typeof copy_id == 'object') {
92 if (copy_id == null) {
93 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
95 copy_id = copy_id.id();
98 copy_id = row.my.acp.id();
101 obj.holds_map[ row.my.ahr.id() ] = blob;
102 params.row_node.setAttribute('retrieve_id',
105 'barcode':row.my.acp ? row.my.acp.barcode() : null,
106 'id':row.my.ahr.id(),
107 'type':row.my.ahr.hold_type(),
108 'target':row.my.ahr.target(),
109 'usr':row.my.ahr.usr()
112 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
115 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
120 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
124 'on_select' : function(ev) {
125 JSAN.use('util.functional');
126 var sel = obj.list.retrieve_selection();
127 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
128 obj.retrieve_ids = util.functional.map_list(
130 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
132 if (obj.retrieve_ids.length > 0) {
133 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
134 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
135 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
136 obj.controller.view.sel_patron.setAttribute('disabled','false');
137 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
138 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
139 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
140 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
141 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
142 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
143 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
144 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
145 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
146 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
147 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
148 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
149 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
150 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
151 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
152 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
154 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
155 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
156 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
157 obj.controller.view.sel_patron.setAttribute('disabled','true');
158 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
159 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
160 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
161 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
162 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
163 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
164 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
165 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
166 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
167 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
168 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
169 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
170 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
171 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
172 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
173 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
179 JSAN.use('util.controller'); obj.controller = new util.controller();
183 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
186 function() { obj.list.clipboard(); }
190 function() { alert($("commonStrings").getString('common.unimplemented')); }
195 JSAN.use('circ.util');
196 circ.util.show_last_few_circs(obj.retrieve_ids);
202 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
203 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
210 var n = obj.controller.view.alt_view_btn;
211 if (n.getAttribute('toggle') == '1') {
212 document.getElementById('deck').selectedIndex = 0;
213 n.setAttribute('toggle','0');
214 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
215 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
217 document.getElementById('deck').selectedIndex = 1;
218 n.setAttribute('toggle','1');
219 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
220 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
221 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
222 if (obj.retrieve_ids.length == 0) return;
223 var f = obj.browser.get_content();
224 xulG.ahr_id = obj.retrieve_ids[0].id;
225 xulG.blob = obj.holds_map[ xulG.ahr_id ];
226 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
227 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
229 f.fetch_and_render_all();
232 alert('Error in holds.js, cmd_alt_view handler: ' + E);
236 'cmd_cancelled_holds_view' : [
239 document.getElementById('show_cancelled_deck').selectedIndex = 1;
240 /* For some reason attribute propogation on the <command> element isn't working with hidden */
241 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
242 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
243 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
244 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
245 obj.clear_and_retrieve();
248 'cmd_uncancelled_holds_view' : [
251 document.getElementById('show_cancelled_deck').selectedIndex = 0;
252 /* For some reason attribute propogation on the <command> element isn't working with hidden */
253 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
254 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
255 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
256 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
257 obj.clear_and_retrieve();
260 'sel_mark_items_damaged' : [
263 JSAN.use('cat.util'); JSAN.use('util.functional');
264 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
267 'sel_mark_items_missing' : [
270 JSAN.use('cat.util'); JSAN.use('util.functional');
271 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
274 'sel_copy_details' : [
277 JSAN.use('circ.util');
278 for (var i = 0; i < obj.retrieve_ids.length; i++) {
279 if (obj.retrieve_ids[i].copy_id) circ.util.show_copy_details( obj.retrieve_ids[i].copy_id );
284 'cmd_holds_print' : [
288 JSAN.use('patron.util');
290 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
293 obj.list.print(params);
295 obj.error.standard_unexpected_error_alert('print 1',E);
299 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
300 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
301 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
303 'cmd_holds_edit_selection_depth' : [
307 JSAN.use('util.widgets'); JSAN.use('util.functional');
308 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
309 var list = util.functional.map_list(
310 util.functional.filter_list(
313 if (o.depth() > ws_type.depth()) return false;
314 if (o.depth() < ws_type.depth()) return true;
315 return (o.id() == ws_type.id());
327 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
328 ml.setAttribute('id','selection');
329 ml.setAttribute('name','fancy_data');
330 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
331 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
332 xml += util.widgets.serialize_node(ml);
334 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
335 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
336 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
337 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
338 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
339 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
340 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
341 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
342 JSAN.use('util.window'); var win = new util.window();
343 var fancy_prompt_data = win.open(
344 urls.XUL_FANCY_PROMPT,
345 //+ '?xml_in_stash=temp_mid'
346 //+ '&bottom_xml_in_stash=temp_bot'
347 //+ '&title=' + window.escape('Choose a Pick Up Library'),
348 'fancy_prompt', 'chrome,resizable,modal',
349 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
351 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
352 var selection = fancy_prompt_data.selection;
354 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
356 if(obj.retrieve_ids.length > 1) {
357 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
359 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
362 var r = obj.error.yns_alert(msg,
363 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
364 $("commonStrings").getString('common.yes'),
365 $("commonStrings").getString('common.no'),
367 $("commonStrings").getString('common.check_to_confirm')
370 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
373 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
378 'cmd_holds_edit_pickup_lib' : [
382 JSAN.use('util.widgets'); JSAN.use('util.functional');
384 var list = util.functional.map_list(
387 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
389 o.name() ? sname + ' ' + o.name() : o.shortname(),
391 ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
392 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
396 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
397 ml.setAttribute('id','lib');
398 ml.setAttribute('name','fancy_data');
399 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
400 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
401 xml += util.widgets.serialize_node(ml);
403 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
404 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
405 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
406 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
407 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
408 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
409 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
410 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
411 JSAN.use('util.window'); var win = new util.window();
412 var fancy_prompt_data = win.open(
413 urls.XUL_FANCY_PROMPT,
414 //+ '?xml_in_stash=temp_mid'
415 //+ '&bottom_xml_in_stash=temp_bot'
416 //+ '&title=' + window.escape('Choose a Pick Up Library'),
417 'fancy_prompt', 'chrome,resizable,modal',
418 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
420 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
421 var pickup_lib = fancy_prompt_data.lib;
423 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
425 if(obj.retrieve_ids.length > 1) {
426 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()]);
428 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()]);
430 var r = obj.error.yns_alert(msg,
431 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
432 $("commonStrings").getString('common.yes'),
433 $("commonStrings").getString('common.no'),
435 $("commonStrings").getString('common.check_to_confirm')
438 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
441 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
445 'cmd_holds_edit_phone_notify' : [
449 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
450 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
451 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
453 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
454 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
455 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
456 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
457 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
458 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
459 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
460 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
461 JSAN.use('util.window'); var win = new util.window();
462 var fancy_prompt_data = win.open(
463 urls.XUL_FANCY_PROMPT,
464 //+ '?xml_in_stash=temp_mid'
465 //+ '&bottom_xml_in_stash=temp_bot'
466 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
468 'fancy_prompt', 'chrome,resizable,modal',
469 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
471 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
472 var phone = fancy_prompt_data.phone;
474 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
476 if(obj.retrieve_ids.length > 1) {
477 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
479 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
481 var r = obj.error.yns_alert(msg,
482 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
483 $("commonStrings").getString('common.yes'),
484 $("commonStrings").getString('common.no'),
486 $("commonStrings").getString('common.check_to_confirm')
489 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
492 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
496 'cmd_holds_edit_email_notify' : [
500 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
501 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
502 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
503 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
504 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
505 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
507 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
508 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
509 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
510 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
511 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
512 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
513 JSAN.use('util.window'); var win = new util.window();
514 var fancy_prompt_data = win.open(
515 urls.XUL_FANCY_PROMPT,
516 //+ '?xml_in_stash=temp_mid'
517 //+ '&bottom_xml_in_stash=temp_bot'
518 //+ '&title=' + window.escape('Set Email Notification for Holds'),
519 'fancy_prompt', 'chrome,resizable,modal',
520 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
522 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
523 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
525 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
527 if(get_bool(email)) {
528 if(obj.retrieve_ids.length > 1) {
529 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
531 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
534 if(obj.retrieve_ids.length > 1) {
535 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
537 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
541 var r = obj.error.yns_alert(msg,
542 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
543 $("commonStrings").getString('common.yes'),
544 $("commonStrings").getString('common.no'),
546 $("commonStrings").getString('common.check_to_confirm')
549 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
552 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
556 'cmd_holds_cut_in_line' : [
560 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
561 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
562 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
563 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
564 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
565 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
567 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
568 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
569 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
570 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
571 JSAN.use('util.window'); var win = new util.window();
572 var fancy_prompt_data = win.open(
573 urls.XUL_FANCY_PROMPT,
574 'fancy_prompt', 'chrome,resizable,modal',
575 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
577 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
578 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
580 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
583 if(obj.retrieve_ids.length > 1) {
584 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
586 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
589 if(obj.retrieve_ids.length > 1) {
590 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
592 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
596 var r = obj.error.yns_alert(msg,
597 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
598 $("commonStrings").getString('common.yes'),
599 $("commonStrings").getString('common.no'),
601 $("commonStrings").getString('common.check_to_confirm')
604 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
607 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
611 'cmd_holds_edit_desire_mint_condition' : [
615 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
616 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
617 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
618 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
619 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
620 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
622 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
623 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
624 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
625 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
626 JSAN.use('util.window'); var win = new util.window();
627 var fancy_prompt_data = win.open(
628 urls.XUL_FANCY_PROMPT,
629 'fancy_prompt', 'chrome,resizable,modal',
630 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
632 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
633 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
635 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
638 if(obj.retrieve_ids.length > 1) {
639 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
641 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
644 if(obj.retrieve_ids.length > 1) {
645 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
647 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
651 var r = obj.error.yns_alert(msg,
652 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
653 $("commonStrings").getString('common.yes'),
654 $("commonStrings").getString('common.no'),
656 $("commonStrings").getString('common.check_to_confirm')
659 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
662 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
668 'cmd_holds_suspend' : [
672 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
673 var r = obj.error.yns_alert(
674 obj.retrieve_ids.length > 1 ?
675 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
676 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
677 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
678 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
679 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
681 document.getElementById('commonStrings').getString('common.confirm')
684 var already_suspended = []; var filtered_hold_list = [];
685 for (var i = 0; i < obj.retrieve_ids.length; i++) {
686 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
687 if ( get_bool( hold.frozen() ) ) {
688 already_suspended.push( hold.id() );
691 filtered_hold_list.push( hold.id() );
693 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
694 if (already_suspended.length == 1) {
695 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
696 } else if (already_suspended.length > 1) {
697 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
699 obj.clear_and_retrieve(true);
703 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
707 'cmd_holds_activate' : [
711 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
712 var r = obj.error.yns_alert(
713 obj.retrieve_ids.length > 1 ?
714 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
715 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
716 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
717 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
718 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
720 document.getElementById('commonStrings').getString('common.confirm')
723 var already_activated = []; var filtered_hold_list = [];
724 for (var i = 0; i < obj.retrieve_ids.length; i++) {
725 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
726 if ( ! get_bool( hold.frozen() ) ) {
727 already_activated.push( hold.id() );
730 filtered_hold_list.push( hold.id() );
732 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
733 if (already_activated.length == 1) {
734 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
735 } else if (already_activated.length > 1) {
736 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
738 obj.clear_and_retrieve(true);
742 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
746 'cmd_holds_edit_thaw_date' : [
750 JSAN.use('util.date');
751 function check_date(value) {
753 if (! util.date.check('YYYY-MM-DD',value) ) { throw(document.getElementById('circStrings').getString('staff.circ.holds.activation_date.invalid_date')); }
754 if (util.date.check_past('YYYY-MM-DD',value) || util.date.formatted_date(new Date(),'%F') == value ) {
755 throw(document.getElementById('circStrings').getString('staff.circ.holds.activation_date.too_early.error'));
764 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
765 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
766 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
767 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
768 var value = 'YYYY-MM-DD';
769 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
770 var thaw_date; var invalid = true;
772 thaw_date = window.prompt(msg,value,title);
774 invalid = ! check_date(thaw_date);
779 if (thaw_date || thaw_date == '') {
780 circ.util.batch_hold_update(
782 { 'frozen' : 't', 'thaw_date' : thaw_date == '' ? null : util.date.formatted_date(thaw_date + ' 00:00:00','%{iso8601}') },
783 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
787 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
791 'cmd_holds_edit_expire_time' : [
795 JSAN.use('util.date');
796 function check_date(value) {
798 if (! util.date.check('YYYY-MM-DD',value) ) { throw(document.getElementById('circStrings').getString('staff.circ.holds.expire_time.invalid_date')); }
799 if (util.date.check_past('YYYY-MM-DD',value) || util.date.formatted_date(new Date(),'%F') == value ) {
800 throw(document.getElementById('circStrings').getString('staff.circ.holds.expire_time.too_early.error'));
809 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
810 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
811 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
812 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
813 var value = 'YYYY-MM-DD';
814 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
815 var expire_time; var invalid = true;
817 expire_time = window.prompt(msg,value,title);
819 invalid = ! check_date(expire_time);
824 if (expire_time || expire_time == '') {
825 circ.util.batch_hold_update(
827 { 'expire_time' : expire_time == '' ? null : util.date.formatted_date(expire_time + ' 00:00:00','%{iso8601}') },
828 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
832 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
836 'cmd_holds_edit_shelf_expire_time' : [
840 JSAN.use('util.date');
841 function check_date(value) {
843 if (! util.date.check('YYYY-MM-DD',value) ) { throw(document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.invalid_date')); }
851 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
852 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
853 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
854 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
855 var value = 'YYYY-MM-DD';
856 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
857 var shelf_expire_time; var invalid = true;
859 shelf_expire_time = window.prompt(msg,value,title);
860 if (shelf_expire_time) {
861 invalid = ! check_date(shelf_expire_time);
866 if (shelf_expire_time || shelf_expire_time == '') {
867 circ.util.batch_hold_update(
869 { 'shelf_expire_time' : shelf_expire_time == '' ? null : util.date.formatted_date(shelf_expire_time + ' 00:00:00','%{iso8601}') },
870 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
874 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
879 'cmd_holds_retarget' : [
883 JSAN.use('util.functional');
885 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
887 if(obj.retrieve_ids.length > 1) {
888 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
890 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
892 var r = obj.error.yns_alert(msg,
893 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
894 $("commonStrings").getString('common.yes'),
895 $("commonStrings").getString('common.no'),
897 $("commonStrings").getString('common.check_to_confirm')
900 for (var i = 0; i < obj.retrieve_ids.length; i++) {
901 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
902 if (typeof robj.ilsevent != 'undefined') throw(robj);
904 obj.clear_and_retrieve();
907 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
913 'cmd_holds_cancel' : [
917 JSAN.use('util.functional');
919 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
921 if(obj.retrieve_ids.length > 1 ) {
922 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
924 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
927 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
928 JSAN.use('util.window');
929 var win = new util.window();
930 var my_xulG = win.open(
931 urls.XUL_HOLD_CANCEL,
933 'chrome,resizable,modal',
936 /*var r = obj.error.yns_alert(msg,
937 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
938 $("commonStrings").getString('common.yes'),
939 $("commonStrings").getString('common.no'),
941 $("commonStrings").getString('common.check_to_confirm')
944 if (my_xulG.proceed) {
946 for (var i = 0; i < obj.retrieve_ids.length; i++) {
947 if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
948 transits.push( obj.retrieve_ids[i].barcode );
950 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
951 if (typeof robj.ilsevent != 'undefined') throw(robj);
953 if (transits.length > 0) {
954 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
955 var r2 = obj.error.yns_alert(msg2,
956 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
957 $("commonStrings").getString('common.yes'),
958 $("commonStrings").getString('common.no'),
960 $("commonStrings").getString('common.check_to_confirm'));
963 for (var i = 0; i < transits.length; i++) {
964 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
965 if (typeof robj.ilsevent != 'undefined') {
966 switch(Number(robj.ilsevent)) {
967 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
970 case 5000 /* PERM_FAILURE */ :
979 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
983 obj.clear_and_retrieve();
986 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
990 'cmd_holds_uncancel' : [
994 JSAN.use('util.functional');
995 for (var i = 0; i < obj.retrieve_ids.length; i++) {
996 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
997 if (typeof robj.ilsevent != 'undefined') throw(robj);
999 obj.clear_and_retrieve();
1001 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1006 'cmd_retrieve_patron' : [
1011 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1012 var patron_id = obj.retrieve_ids[i].usr;
1013 if (seen[patron_id]) continue; seen[patron_id] = true;
1014 xulG.new_patron_tab(
1016 { 'id' : patron_id }
1020 obj.error.standard_unexpected_error_alert('',E);
1024 'cmd_show_catalog' : [
1028 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1029 var htarget = obj.retrieve_ids[i].target;
1030 var htype = obj.retrieve_ids[i].type;
1034 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1037 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1040 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1041 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1044 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1046 if (typeof my_acp.call_number() == 'object') {
1047 my_acn = my.acp.call_number();
1049 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1050 [ my_acp.call_number() ]);
1052 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1055 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1059 var content_params = {
1061 'authtime' : ses('authtime'),
1062 'opac_url' : opac_url
1065 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1066 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1071 obj.error.standard_unexpected_error_alert('',E);
1078 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1082 'lib_filter_checkbox' : [
1085 var x_lib_type_menu = document.getElementById('lib_type_menu');
1086 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1087 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1088 obj.clear_and_retrieve();
1089 ev.target.setAttribute('checked',ev.target.checked);
1092 'cmd_search_opac' : [
1096 var content_params = {
1097 'show_nav_buttons' : false,
1098 'show_print_button' : true,
1099 'passthru_content_params' : {
1100 'authtoken' : ses(),
1101 'authtime' : ses('authtime'),
1102 'window_open' : function(a,b,c) {
1104 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1105 return window.open(a,b,c);
1107 obj.error.standard_unexpected_error_alert('window_open',E);
1110 'opac_hold_placed' : function(hold) {
1116 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1121 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1122 window.xulG.on_list_change();
1125 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1128 'patron_barcode' : obj.patron_barcode
1130 'url_prefix' : xulG.url_prefix,
1131 'url' : xulG.url_prefix( urls.browser )
1133 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1135 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1144 obj.determine_hold_interface_type();
1145 var x_fetch_more = document.getElementById('fetch_more');
1146 var x_lib_type_menu = document.getElementById('lib_type_menu');
1147 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1148 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1149 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1150 switch(obj.hold_interface_type) {
1152 obj.render_lib_menus({'pickup_lib':true});
1153 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1154 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1157 if (x_fetch_more) x_fetch_more.hidden = false;
1158 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1159 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1162 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1163 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1164 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1165 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1168 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1169 if (x_fetch_more) x_fetch_more.hidden = true;
1170 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1171 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1172 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1175 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
1177 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1178 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1179 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1181 obj.controller.render();
1184 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1185 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1186 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1187 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1188 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1189 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1190 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1191 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1192 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1193 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1194 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1195 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1196 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1200 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1201 JSAN.use('util.browser');
1202 obj.browser = new util.browser();
1205 'url' : urls.XUL_HOLD_DETAILS,
1207 'alt_print' : false,
1208 'browser_id' : 'hold_detail_frame',
1209 'passthru_content_params' : xulG,
1215 'determine_hold_interface_type' : function() {
1217 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1218 obj.hold_interface_type = 'patron';
1219 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1220 obj.hold_interface_type = 'record';
1221 } else if (obj.pull) { /*************************************************** PULL ******************************/
1222 obj.hold_interface_type = 'pull';
1223 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1224 obj.hold_interface_type = 'shelf';
1225 } else { /*************************************************** PULL ******************************/
1226 obj.hold_interface_type = 'pull';
1230 'clear_and_retrieve' : function() {
1233 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1235 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1236 window.xulG.on_list_change();
1239 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1243 'retrieve' : function() {
1244 var obj = this; var holds = [];
1245 if (window.xulG && window.xulG.holds) {
1246 holds = window.xulG.holds;
1248 var method; var params = [ ses() ];
1249 switch(obj.hold_interface_type) {
1251 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1252 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1254 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1256 params.push( obj.patron_id );
1257 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1260 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1261 params.push( obj.docid );
1262 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1263 var x_lib_type_menu = document.getElementById('lib_type_menu');
1265 if (x_lib_filter.checked) {
1266 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1268 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1273 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1276 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1277 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1278 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1282 method = 'FM_AHR_ID_LIST_PULL_LIST';
1283 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1284 //obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1287 var robj = obj.network.simple_request( method, params );
1288 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1289 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1292 holds = holds.concat( robj.copy_holds );
1293 holds = holds.concat( robj.volume_holds );
1294 holds = holds.concat( robj.title_holds );
1295 holds = holds.concat( robj.metarecord_holds );
1296 holds = holds.sort();
1299 if (robj == null ) {
1302 if (typeof robj.length == 'undefined') {
1310 //alert('method = ' + method + ' params = ' + js2JSON(params));
1313 var x_fetch_more = document.getElementById('fetch_more');
1314 if (holds.length == 0) {
1315 if (x_fetch_more) x_fetch_more.disabled = true;
1317 if (x_fetch_more) x_fetch_more.disabled = false;
1323 'render' : function(holds) {
1327 function list_append(hold_id) {
1339 function gen_list_append(hold) {
1341 if (typeof obj.controller.view.lib_menu == 'undefined') {
1342 list_append(typeof hold == 'object' ? hold.id() : hold);
1344 list_append(typeof hold == 'object' ? hold.id() : hold);
1351 JSAN.use('util.exec'); var exec = new util.exec(2);
1353 for (var i in holds) {
1354 rows.push( gen_list_append(holds[i]) );
1359 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1363 'render_lib_menus' : function(types) {
1366 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1368 var x = document.getElementById('lib_type_menu');
1370 var nodes = x.firstChild.childNodes;
1371 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1372 for (var i in types) document.getElementById(i).hidden = false;
1374 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1376 x = document.getElementById('lib_menu_placeholder');
1377 util.widgets.remove_children( x );
1379 JSAN.use('util.file');
1380 var file = new util.file('offline_ou_list');
1381 if (file._file.exists()) {
1382 var list_data = file.get_object(); file.close();
1383 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1384 ml.setAttribute('id','lib_menu');
1385 x.appendChild( ml );
1386 ml.addEventListener(
1389 obj.filter_lib = ev.target.value;
1390 obj.clear_and_retrieve();
1394 obj.controller.view.lib_menu = ml;
1396 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1400 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1405 dump('exiting patron.holds.js\n');