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_edit_request_date.setAttribute('disabled','false');
147 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
148 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
149 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
150 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
151 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
152 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
153 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
155 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
156 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
157 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
158 obj.controller.view.sel_patron.setAttribute('disabled','true');
159 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
160 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
161 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
162 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
163 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
164 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
165 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
166 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
167 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
168 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
169 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
170 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
171 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
172 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
173 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
174 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
175 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
181 JSAN.use('util.controller'); obj.controller = new util.controller();
185 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
188 function() { obj.list.clipboard(); }
192 function() { alert($("commonStrings").getString('common.unimplemented')); }
197 JSAN.use('circ.util');
198 circ.util.show_last_few_circs(obj.retrieve_ids);
204 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
205 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
212 var n = obj.controller.view.alt_view_btn;
213 if (n.getAttribute('toggle') == '1') {
214 document.getElementById('deck').selectedIndex = 0;
215 n.setAttribute('toggle','0');
216 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
217 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
219 document.getElementById('deck').selectedIndex = 1;
220 n.setAttribute('toggle','1');
221 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
222 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
223 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
224 if (obj.retrieve_ids.length == 0) return;
225 var f = obj.browser.get_content();
226 xulG.ahr_id = obj.retrieve_ids[0].id;
227 xulG.blob = obj.holds_map[ xulG.ahr_id ];
228 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
229 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
231 f.fetch_and_render_all();
234 alert('Error in holds.js, cmd_alt_view handler: ' + E);
238 'cmd_cancelled_holds_view' : [
241 document.getElementById('show_cancelled_deck').selectedIndex = 1;
242 /* For some reason attribute propogation on the <command> element isn't working with hidden */
243 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
244 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
245 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
246 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
247 obj.clear_and_retrieve();
250 'cmd_uncancelled_holds_view' : [
253 document.getElementById('show_cancelled_deck').selectedIndex = 0;
254 /* For some reason attribute propogation on the <command> element isn't working with hidden */
255 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
256 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
257 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
258 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
259 obj.clear_and_retrieve();
262 'sel_mark_items_damaged' : [
265 JSAN.use('cat.util'); JSAN.use('util.functional');
266 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
269 'sel_mark_items_missing' : [
272 JSAN.use('cat.util'); JSAN.use('util.functional');
273 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
276 'sel_copy_details' : [
279 JSAN.use('circ.util');
280 circ.util.item_details_new(
281 util.functional.map_list(
283 function(o) { return o.barcode; }
289 'cmd_holds_print' : [
293 JSAN.use('patron.util');
295 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
298 obj.list.print(params);
300 obj.error.standard_unexpected_error_alert('print 1',E);
304 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
305 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
306 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
308 'cmd_holds_edit_selection_depth' : [
312 JSAN.use('util.widgets'); JSAN.use('util.functional');
313 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
314 var list = util.functional.map_list(
315 util.functional.filter_list(
318 if (o.depth() > ws_type.depth()) return false;
319 if (o.depth() < ws_type.depth()) return true;
320 return (o.id() == ws_type.id());
332 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
333 ml.setAttribute('id','selection');
334 ml.setAttribute('name','fancy_data');
335 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
336 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
337 xml += util.widgets.serialize_node(ml);
339 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
340 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
341 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
342 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
343 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
344 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
345 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
346 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
347 JSAN.use('util.window'); var win = new util.window();
348 var fancy_prompt_data = win.open(
349 urls.XUL_FANCY_PROMPT,
350 //+ '?xml_in_stash=temp_mid'
351 //+ '&bottom_xml_in_stash=temp_bot'
352 //+ '&title=' + window.escape('Choose a Pick Up Library'),
353 'fancy_prompt', 'chrome,resizable,modal',
354 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
356 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
357 var selection = fancy_prompt_data.selection;
359 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
361 if(obj.retrieve_ids.length > 1) {
362 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
364 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
367 var r = obj.error.yns_alert(msg,
368 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
369 $("commonStrings").getString('common.yes'),
370 $("commonStrings").getString('common.no'),
372 $("commonStrings").getString('common.check_to_confirm')
375 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
378 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
383 'cmd_holds_edit_pickup_lib' : [
387 JSAN.use('util.widgets'); JSAN.use('util.functional');
389 var list = util.functional.map_list(
392 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
394 o.name() ? sname + ' ' + o.name() : o.shortname(),
396 ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
397 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
401 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
402 ml.setAttribute('id','lib');
403 ml.setAttribute('name','fancy_data');
404 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
405 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
406 xml += util.widgets.serialize_node(ml);
408 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
409 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
410 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
411 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
412 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
413 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
414 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
415 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
416 JSAN.use('util.window'); var win = new util.window();
417 var fancy_prompt_data = win.open(
418 urls.XUL_FANCY_PROMPT,
419 //+ '?xml_in_stash=temp_mid'
420 //+ '&bottom_xml_in_stash=temp_bot'
421 //+ '&title=' + window.escape('Choose a Pick Up Library'),
422 'fancy_prompt', 'chrome,resizable,modal',
423 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
425 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
426 var pickup_lib = fancy_prompt_data.lib;
428 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
430 if(obj.retrieve_ids.length > 1) {
431 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()]);
433 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()]);
435 var r = obj.error.yns_alert(msg,
436 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
437 $("commonStrings").getString('common.yes'),
438 $("commonStrings").getString('common.no'),
440 $("commonStrings").getString('common.check_to_confirm')
443 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
446 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
450 'cmd_holds_edit_phone_notify' : [
454 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
455 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
456 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
458 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
459 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
460 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
461 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
462 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
463 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
464 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
465 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
466 JSAN.use('util.window'); var win = new util.window();
467 var fancy_prompt_data = win.open(
468 urls.XUL_FANCY_PROMPT,
469 //+ '?xml_in_stash=temp_mid'
470 //+ '&bottom_xml_in_stash=temp_bot'
471 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
473 'fancy_prompt', 'chrome,resizable,modal',
474 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
476 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
477 var phone = fancy_prompt_data.phone;
479 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
481 if(obj.retrieve_ids.length > 1) {
482 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
484 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
486 var r = obj.error.yns_alert(msg,
487 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
488 $("commonStrings").getString('common.yes'),
489 $("commonStrings").getString('common.no'),
491 $("commonStrings").getString('common.check_to_confirm')
494 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
497 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
501 'cmd_holds_edit_email_notify' : [
505 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
506 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
507 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
508 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
509 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
510 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
512 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
513 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
514 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
515 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
516 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
517 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
518 JSAN.use('util.window'); var win = new util.window();
519 var fancy_prompt_data = win.open(
520 urls.XUL_FANCY_PROMPT,
521 //+ '?xml_in_stash=temp_mid'
522 //+ '&bottom_xml_in_stash=temp_bot'
523 //+ '&title=' + window.escape('Set Email Notification for Holds'),
524 'fancy_prompt', 'chrome,resizable,modal',
525 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
527 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
528 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
530 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
532 if(get_bool(email)) {
533 if(obj.retrieve_ids.length > 1) {
534 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
536 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
539 if(obj.retrieve_ids.length > 1) {
540 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
542 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
546 var r = obj.error.yns_alert(msg,
547 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
548 $("commonStrings").getString('common.yes'),
549 $("commonStrings").getString('common.no'),
551 $("commonStrings").getString('common.check_to_confirm')
554 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
557 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
561 'cmd_holds_cut_in_line' : [
565 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
566 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
567 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
568 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
569 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
570 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
572 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
573 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
574 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
575 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
576 JSAN.use('util.window'); var win = new util.window();
577 var fancy_prompt_data = win.open(
578 urls.XUL_FANCY_PROMPT,
579 'fancy_prompt', 'chrome,resizable,modal',
580 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
582 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
583 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
585 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
588 if(obj.retrieve_ids.length > 1) {
589 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
591 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
594 if(obj.retrieve_ids.length > 1) {
595 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
597 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
601 var r = obj.error.yns_alert(msg,
602 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
603 $("commonStrings").getString('common.yes'),
604 $("commonStrings").getString('common.no'),
606 $("commonStrings").getString('common.check_to_confirm')
609 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
612 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
616 'cmd_holds_edit_desire_mint_condition' : [
620 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
621 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
622 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
623 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
624 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
625 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
627 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
628 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
629 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
630 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
631 JSAN.use('util.window'); var win = new util.window();
632 var fancy_prompt_data = win.open(
633 urls.XUL_FANCY_PROMPT,
634 'fancy_prompt', 'chrome,resizable,modal',
635 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
637 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
638 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
640 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
643 if(obj.retrieve_ids.length > 1) {
644 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
646 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
649 if(obj.retrieve_ids.length > 1) {
650 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
652 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
656 var r = obj.error.yns_alert(msg,
657 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
658 $("commonStrings").getString('common.yes'),
659 $("commonStrings").getString('common.no'),
661 $("commonStrings").getString('common.check_to_confirm')
664 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
667 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
673 'cmd_holds_suspend' : [
677 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
678 var r = obj.error.yns_alert(
679 obj.retrieve_ids.length > 1 ?
680 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
681 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
682 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
683 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
684 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
686 document.getElementById('commonStrings').getString('common.confirm')
689 var already_suspended = []; var filtered_hold_list = [];
690 for (var i = 0; i < obj.retrieve_ids.length; i++) {
691 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
692 if ( get_bool( hold.frozen() ) ) {
693 already_suspended.push( hold.id() );
696 filtered_hold_list.push( hold.id() );
698 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
699 if (already_suspended.length == 1) {
700 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
701 } else if (already_suspended.length > 1) {
702 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
704 obj.clear_and_retrieve(true);
708 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
712 'cmd_holds_activate' : [
716 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
717 var r = obj.error.yns_alert(
718 obj.retrieve_ids.length > 1 ?
719 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
720 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
721 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
722 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
723 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
725 document.getElementById('commonStrings').getString('common.confirm')
728 var already_activated = []; var filtered_hold_list = [];
729 for (var i = 0; i < obj.retrieve_ids.length; i++) {
730 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
731 if ( ! get_bool( hold.frozen() ) ) {
732 already_activated.push( hold.id() );
735 filtered_hold_list.push( hold.id() );
737 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
738 if (already_activated.length == 1) {
739 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
740 } else if (already_activated.length > 1) {
741 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
743 obj.clear_and_retrieve(true);
747 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
751 'cmd_holds_edit_thaw_date' : [
755 JSAN.use('util.date');
756 function check_date(value) {
758 if (! util.date.check('YYYY-MM-DD',value) ) { throw(document.getElementById('circStrings').getString('staff.circ.holds.activation_date.invalid_date')); }
759 if (util.date.check_past('YYYY-MM-DD',value) || util.date.formatted_date(new Date(),'%F') == value ) {
760 throw(document.getElementById('circStrings').getString('staff.circ.holds.activation_date.too_early.error'));
769 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
770 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
771 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
772 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
773 var value = 'YYYY-MM-DD';
774 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
775 var thaw_date; var invalid = true;
777 thaw_date = window.prompt(msg,value,title);
779 invalid = ! check_date(thaw_date);
784 if (thaw_date || thaw_date == '') {
785 circ.util.batch_hold_update(
787 { 'frozen' : 't', 'thaw_date' : thaw_date == '' ? null : util.date.formatted_date(thaw_date + ' 00:00:00','%{iso8601}') },
788 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
792 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
796 'cmd_holds_edit_expire_time' : [
800 JSAN.use('util.date');
801 function check_date(value) {
803 if (! util.date.check('YYYY-MM-DD',value) ) { throw(document.getElementById('circStrings').getString('staff.circ.holds.expire_time.invalid_date')); }
804 if (util.date.check_past('YYYY-MM-DD',value) || util.date.formatted_date(new Date(),'%F') == value ) {
805 throw(document.getElementById('circStrings').getString('staff.circ.holds.expire_time.too_early.error'));
814 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
815 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
816 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
817 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
818 var value = 'YYYY-MM-DD';
819 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
820 var expire_time; var invalid = true;
822 expire_time = window.prompt(msg,value,title);
824 invalid = ! check_date(expire_time);
829 if (expire_time || expire_time == '') {
830 circ.util.batch_hold_update(
832 { 'expire_time' : expire_time == '' ? null : util.date.formatted_date(expire_time + ' 00:00:00','%{iso8601}') },
833 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
837 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
841 'cmd_holds_edit_shelf_expire_time' : [
845 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
846 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
847 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
848 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
849 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
850 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
852 JSAN.use('util.window'); var win = new util.window();
853 var my_xulG = win.open(
854 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
857 'description' : desc,
859 'allow_unset' : false,
860 'disallow_future_dates' : false,
861 'disallow_past_dates' : false,
862 'disallow_today' : false
865 if (my_xulG.complete) {
866 circ.util.batch_hold_update(
868 { 'shelf_expire_time' : my_xulG.timestamp },
869 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
873 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
877 'cmd_holds_edit_request_date' : [
881 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
882 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
883 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
884 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
885 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
886 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
888 JSAN.use('util.window'); var win = new util.window();
889 var my_xulG = win.open(
890 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
893 'description' : desc,
895 'allow_unset' : false,
896 'disallow_future_dates' : true,
897 'disallow_past_dates' : false,
898 'disallow_today' : false
901 if (my_xulG.complete) {
902 circ.util.batch_hold_update(
904 { 'request_time' : my_xulG.timestamp },
905 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
909 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
913 'cmd_holds_retarget' : [
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_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
924 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
926 var r = obj.error.yns_alert(msg,
927 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
928 $("commonStrings").getString('common.yes'),
929 $("commonStrings").getString('common.no'),
931 $("commonStrings").getString('common.check_to_confirm')
934 for (var i = 0; i < obj.retrieve_ids.length; i++) {
935 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
936 if (typeof robj.ilsevent != 'undefined') throw(robj);
938 obj.clear_and_retrieve();
941 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
947 'cmd_holds_cancel' : [
951 JSAN.use('util.functional');
953 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
955 if(obj.retrieve_ids.length > 1 ) {
956 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
958 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
961 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
962 JSAN.use('util.window');
963 var win = new util.window();
964 var my_xulG = win.open(
965 urls.XUL_HOLD_CANCEL,
967 'chrome,resizable,modal',
970 /*var r = obj.error.yns_alert(msg,
971 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
972 $("commonStrings").getString('common.yes'),
973 $("commonStrings").getString('common.no'),
975 $("commonStrings").getString('common.check_to_confirm')
978 if (my_xulG.proceed) {
980 for (var i = 0; i < obj.retrieve_ids.length; i++) {
981 if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
982 transits.push( obj.retrieve_ids[i].barcode );
984 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
985 if (typeof robj.ilsevent != 'undefined') throw(robj);
987 if (transits.length > 0) {
988 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
989 var r2 = obj.error.yns_alert(msg2,
990 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
991 $("commonStrings").getString('common.yes'),
992 $("commonStrings").getString('common.no'),
994 $("commonStrings").getString('common.check_to_confirm'));
997 for (var i = 0; i < transits.length; i++) {
998 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
999 if (typeof robj.ilsevent != 'undefined') {
1000 switch(Number(robj.ilsevent)) {
1001 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1004 case 5000 /* PERM_FAILURE */ :
1013 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1017 obj.clear_and_retrieve();
1020 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1024 'cmd_holds_uncancel' : [
1028 JSAN.use('util.functional');
1029 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1030 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1031 if (typeof robj.ilsevent != 'undefined') throw(robj);
1033 obj.clear_and_retrieve();
1035 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1040 'cmd_retrieve_patron' : [
1045 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1046 var patron_id = obj.retrieve_ids[i].usr;
1047 if (seen[patron_id]) continue; seen[patron_id] = true;
1048 xulG.new_patron_tab(
1050 { 'id' : patron_id }
1054 obj.error.standard_unexpected_error_alert('',E);
1058 'cmd_show_catalog' : [
1062 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1063 var htarget = obj.retrieve_ids[i].target;
1064 var htype = obj.retrieve_ids[i].type;
1068 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1071 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1074 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1075 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1078 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1080 if (typeof my_acp.call_number() == 'object') {
1081 my_acn = my.acp.call_number();
1083 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1084 [ my_acp.call_number() ]);
1086 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1089 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1093 var content_params = {
1095 'authtime' : ses('authtime'),
1096 'opac_url' : opac_url
1099 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1100 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1105 obj.error.standard_unexpected_error_alert('',E);
1112 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1116 'lib_filter_checkbox' : [
1119 var x_lib_type_menu = document.getElementById('lib_type_menu');
1120 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1121 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1122 obj.clear_and_retrieve();
1123 ev.target.setAttribute('checked',ev.target.checked);
1126 'cmd_search_opac' : [
1130 var content_params = {
1131 'show_nav_buttons' : false,
1132 'show_print_button' : true,
1133 'passthru_content_params' : {
1134 'authtoken' : ses(),
1135 'authtime' : ses('authtime'),
1136 'window_open' : function(a,b,c) {
1138 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1139 return window.open(a,b,c);
1141 obj.error.standard_unexpected_error_alert('window_open',E);
1144 'opac_hold_placed' : function(hold) {
1150 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1155 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1156 window.xulG.on_list_change();
1159 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1162 'patron_barcode' : obj.patron_barcode
1164 'url_prefix' : xulG.url_prefix,
1165 'url' : xulG.url_prefix( urls.browser )
1167 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1169 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1178 obj.determine_hold_interface_type();
1179 var x_fetch_more = document.getElementById('fetch_more');
1180 var x_lib_type_menu = document.getElementById('lib_type_menu');
1181 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1182 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1183 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1184 switch(obj.hold_interface_type) {
1186 obj.render_lib_menus({'pickup_lib':true});
1187 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1188 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1191 if (x_fetch_more) x_fetch_more.hidden = false;
1192 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1193 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1196 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1197 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1198 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1199 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1202 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1203 if (x_fetch_more) x_fetch_more.hidden = true;
1204 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1205 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1206 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1209 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
1211 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1212 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1213 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1215 obj.controller.render();
1218 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1219 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1220 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1221 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1222 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1223 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1224 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1225 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1226 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1227 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1228 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1229 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1230 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1234 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1235 JSAN.use('util.browser');
1236 obj.browser = new util.browser();
1239 'url' : urls.XUL_HOLD_DETAILS,
1241 'alt_print' : false,
1242 'browser_id' : 'hold_detail_frame',
1243 'passthru_content_params' : xulG,
1249 'determine_hold_interface_type' : function() {
1251 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1252 obj.hold_interface_type = 'patron';
1253 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1254 obj.hold_interface_type = 'record';
1255 } else if (obj.pull) { /*************************************************** PULL ******************************/
1256 obj.hold_interface_type = 'pull';
1257 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1258 obj.hold_interface_type = 'shelf';
1259 } else { /*************************************************** PULL ******************************/
1260 obj.hold_interface_type = 'pull';
1264 'clear_and_retrieve' : function() {
1267 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1269 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1270 window.xulG.on_list_change();
1273 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1277 'retrieve' : function() {
1278 var obj = this; var holds = [];
1279 if (window.xulG && window.xulG.holds) {
1280 holds = window.xulG.holds;
1282 var method; var params = [ ses() ];
1283 switch(obj.hold_interface_type) {
1285 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1286 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1288 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1290 params.push( obj.patron_id );
1291 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1294 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1295 params.push( obj.docid );
1296 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1297 var x_lib_type_menu = document.getElementById('lib_type_menu');
1299 if (x_lib_filter.checked) {
1300 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1302 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1307 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1310 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1311 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1312 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1316 method = 'FM_AHR_ID_LIST_PULL_LIST';
1317 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1318 //obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1321 var robj = obj.network.simple_request( method, params );
1322 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1323 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1326 holds = holds.concat( robj.copy_holds );
1327 holds = holds.concat( robj.volume_holds );
1328 holds = holds.concat( robj.title_holds );
1329 holds = holds.concat( robj.metarecord_holds );
1330 holds = holds.sort();
1333 if (robj == null ) {
1336 if (typeof robj.length == 'undefined') {
1344 //alert('method = ' + method + ' params = ' + js2JSON(params));
1347 var x_fetch_more = document.getElementById('fetch_more');
1348 if (holds.length == 0) {
1349 if (x_fetch_more) x_fetch_more.disabled = true;
1351 if (x_fetch_more) x_fetch_more.disabled = false;
1357 'render' : function(holds) {
1361 function list_append(hold_id) {
1373 function gen_list_append(hold) {
1375 if (typeof obj.controller.view.lib_menu == 'undefined') {
1376 list_append(typeof hold == 'object' ? hold.id() : hold);
1378 list_append(typeof hold == 'object' ? hold.id() : hold);
1385 JSAN.use('util.exec'); var exec = new util.exec(2);
1387 for (var i in holds) {
1388 rows.push( gen_list_append(holds[i]) );
1393 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1397 'render_lib_menus' : function(types) {
1400 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1402 var x = document.getElementById('lib_type_menu');
1404 var nodes = x.firstChild.childNodes;
1405 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1406 for (var i in types) document.getElementById(i).hidden = false;
1408 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1410 x = document.getElementById('lib_menu_placeholder');
1411 util.widgets.remove_children( x );
1413 JSAN.use('util.file');
1414 var file = new util.file('offline_ou_list');
1415 if (file._file.exists()) {
1416 var list_data = file.get_object(); file.close();
1417 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1418 ml.setAttribute('id','lib_menu');
1419 x.appendChild( ml );
1420 ml.addEventListener(
1423 obj.filter_lib = ev.target.value;
1424 obj.clear_and_retrieve();
1428 obj.controller.view.lib_menu = ml;
1430 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1434 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1439 dump('exiting patron.holds.js\n');