1 dump('entering patron.holds.js\n');
3 function $(id) { return document.getElementById(id); }
5 if (typeof patron == 'undefined') patron = {};
6 patron.holds = function (params) {
8 JSAN.use('util.error'); this.error = new util.error();
9 JSAN.use('util.network'); this.network = new util.network();
10 JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
13 patron.holds.prototype = {
15 'hold_interface_type' : null,
17 'pull_from_shelf_interface' : {
18 '_default' : { 'limit' : 100, 'offset' : 0 },
19 'current' : { 'limit' : 100, 'offset' : 0 }
25 'post_clear_shelf_hold_action_map' : {},
31 'flatten_copy' : function(hold) {
32 try { if ( hold.current_copy() && typeof hold.current_copy() == 'object') hold.current_copy( hold.current_copy().id() ); } catch(E) { alert('FIXME: Error flattening hold before hold update: ' + E); }
36 'init' : function( params ) {
40 obj.patron_id = params['patron_id'];
41 obj.patron_barcode = params['patron_barcode'];
42 obj.docid = params['docid'];
43 obj.shelf = params['shelf'];
44 obj.tree_id = params['tree_id'];
46 var progressmeter = document.getElementById('progress');
48 JSAN.use('circ.util');
49 var columns = circ.util.hold_columns(
51 'title' : { 'hidden' : false, 'flex' : '3' },
52 'request_time' : { 'hidden' : false },
53 'pickup_lib_shortname' : { 'hidden' : false },
54 'hold_type' : { 'hidden' : false },
55 'current_copy' : { 'hidden' : false },
56 'capture_time' : { 'hidden' : false },
57 'notify_time' : { 'hidden' : false },
58 'notify_count' : { 'hidden' : false },
59 'cancel_cause' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
60 'cancel_note' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
61 'cancel_time' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
62 'post_clear_shelf_action' : { 'hidden' : obj.shelf ? false : true }
66 JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
70 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
71 'retrieve_row' : function(params) {
74 obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
77 var blob = blob_req.getResultObject();
78 if (typeof blob.ilsevent != 'undefined') throw(blob);
79 row.my.ahr = blob.hold;
80 row.my.status = blob.status;
81 row.my.ahr.status( blob.status );
82 row.my.acp = blob.copy;
83 row.my.acn = blob.volume;
84 row.my.mvr = blob.mvr;
85 row.my.patron_family_name = blob.patron_last;
86 row.my.patron_first_given_name = blob.patron_first;
87 row.my.patron_barcode = blob.patron_barcode;
88 row.my.total_holds = blob.total_holds;
89 row.my.queue_position = blob.queue_position;
90 row.my.potential_copies = blob.potential_copies;
91 row.my.estimated_wait = blob.estimated_wait;
92 row.my.ahrn_count = blob.hold.notes().length;
94 var copy_id = row.my.ahr.current_copy();
95 if (typeof copy_id == 'object') {
96 if (copy_id == null) {
97 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
99 copy_id = copy_id.id();
102 copy_id = row.my.acp.id();
105 obj.holds_map[ row.my.ahr.id() ] = blob;
106 params.row_node.setAttribute('retrieve_id',
109 'barcode':row.my.acp ? row.my.acp.barcode() : null,
110 'id':row.my.ahr.id(),
111 'type':row.my.ahr.hold_type(),
112 'target':row.my.ahr.target(),
113 'usr':row.my.ahr.usr()
116 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
119 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
124 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
128 'on_select' : function(ev) {
129 JSAN.use('util.functional');
130 var sel = obj.list.retrieve_selection();
131 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
132 obj.retrieve_ids = util.functional.map_list(
134 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
136 if (obj.retrieve_ids.length > 0) {
137 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
138 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
139 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
140 obj.controller.view.sel_patron.setAttribute('disabled','false');
141 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
142 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
143 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
144 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
145 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
146 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
147 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
148 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
149 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
150 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
151 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
152 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
153 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
154 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
155 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
156 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
157 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
159 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
160 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
161 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
162 obj.controller.view.sel_patron.setAttribute('disabled','true');
163 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
164 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
165 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
166 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
167 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
168 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
169 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
170 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
171 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
172 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
173 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
174 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
175 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
176 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
177 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
178 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
179 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
185 JSAN.use('util.controller'); obj.controller = new util.controller();
189 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
192 function() { obj.list.clipboard(); }
196 function() { alert($("commonStrings").getString('common.unimplemented')); }
201 JSAN.use('circ.util');
202 circ.util.show_last_few_circs(obj.retrieve_ids);
208 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
209 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
216 var n = obj.controller.view.alt_view_btn;
217 if (n.getAttribute('toggle') == '1') {
218 document.getElementById('deck').selectedIndex = 0;
219 n.setAttribute('toggle','0');
220 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
221 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
223 document.getElementById('deck').selectedIndex = 1;
224 n.setAttribute('toggle','1');
225 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
226 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
227 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
228 if (obj.retrieve_ids.length == 0) return;
229 var f = obj.browser.get_content();
230 xulG.ahr_id = obj.retrieve_ids[0].id;
231 xulG.blob = obj.holds_map[ xulG.ahr_id ];
232 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
233 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
235 f.fetch_and_render_all();
238 alert('Error in holds.js, cmd_alt_view handler: ' + E);
242 'cmd_cancelled_holds_view' : [
245 document.getElementById('show_cancelled_deck').selectedIndex = 1;
246 /* For some reason attribute propogation on the <command> element isn't working with hidden */
247 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
248 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
249 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
250 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
251 obj.clear_and_retrieve();
254 'cmd_uncancelled_holds_view' : [
257 document.getElementById('show_cancelled_deck').selectedIndex = 0;
258 /* For some reason attribute propogation on the <command> element isn't working with hidden */
259 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
260 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
261 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
262 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
263 obj.clear_and_retrieve();
266 'sel_mark_items_damaged' : [
269 JSAN.use('cat.util'); JSAN.use('util.functional');
270 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
273 'sel_mark_items_missing' : [
276 JSAN.use('cat.util'); JSAN.use('util.functional');
277 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
280 'sel_copy_details' : [
283 JSAN.use('circ.util');
284 circ.util.item_details_new(
285 util.functional.map_list(
287 function(o) { return o.barcode; }
293 'cmd_holds_print' : [
297 JSAN.use('patron.util');
299 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
302 obj.list.print(params);
304 obj.error.standard_unexpected_error_alert('print 1',E);
308 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
309 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
310 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
312 'cmd_holds_edit_selection_depth' : [
316 JSAN.use('util.widgets'); JSAN.use('util.functional');
317 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
318 var list = util.functional.map_list(
319 util.functional.filter_list(
322 if (o.depth() > ws_type.depth()) return false;
323 if (o.depth() < ws_type.depth()) return true;
324 return (o.id() == ws_type.id());
336 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
337 ml.setAttribute('id','selection');
338 ml.setAttribute('name','fancy_data');
339 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
340 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
341 xml += util.widgets.serialize_node(ml);
343 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
344 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
345 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
346 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
347 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
348 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
349 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
350 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
351 JSAN.use('util.window'); var win = new util.window();
352 var fancy_prompt_data = win.open(
353 urls.XUL_FANCY_PROMPT,
354 //+ '?xml_in_stash=temp_mid'
355 //+ '&bottom_xml_in_stash=temp_bot'
356 //+ '&title=' + window.escape('Choose a Pick Up Library'),
357 'fancy_prompt', 'chrome,resizable,modal',
358 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
360 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
361 var selection = fancy_prompt_data.selection;
363 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
365 if(obj.retrieve_ids.length > 1) {
366 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
368 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
371 var r = obj.error.yns_alert(msg,
372 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
373 $("commonStrings").getString('common.yes'),
374 $("commonStrings").getString('common.no'),
376 $("commonStrings").getString('common.check_to_confirm')
379 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
382 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
387 'cmd_holds_edit_pickup_lib' : [
391 JSAN.use('util.widgets'); JSAN.use('util.functional');
393 var list = util.functional.map_list(
396 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
398 o.name() ? sname + ' ' + o.name() : o.shortname(),
400 ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
401 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
405 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
406 ml.setAttribute('id','lib');
407 ml.setAttribute('name','fancy_data');
408 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
409 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
410 xml += util.widgets.serialize_node(ml);
412 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
413 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
414 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
415 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
416 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
417 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
418 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
419 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
420 JSAN.use('util.window'); var win = new util.window();
421 var fancy_prompt_data = win.open(
422 urls.XUL_FANCY_PROMPT,
423 //+ '?xml_in_stash=temp_mid'
424 //+ '&bottom_xml_in_stash=temp_bot'
425 //+ '&title=' + window.escape('Choose a Pick Up Library'),
426 'fancy_prompt', 'chrome,resizable,modal',
427 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
429 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
430 var pickup_lib = fancy_prompt_data.lib;
432 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
434 if(obj.retrieve_ids.length > 1) {
435 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()]);
437 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()]);
439 var r = obj.error.yns_alert(msg,
440 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
441 $("commonStrings").getString('common.yes'),
442 $("commonStrings").getString('common.no'),
444 $("commonStrings").getString('common.check_to_confirm')
447 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
450 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
454 'cmd_holds_edit_phone_notify' : [
458 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
459 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
460 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
462 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
463 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
464 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
465 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
466 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
467 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
468 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
469 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
470 JSAN.use('util.window'); var win = new util.window();
471 var fancy_prompt_data = win.open(
472 urls.XUL_FANCY_PROMPT,
473 //+ '?xml_in_stash=temp_mid'
474 //+ '&bottom_xml_in_stash=temp_bot'
475 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
477 'fancy_prompt', 'chrome,resizable,modal',
478 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
480 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
481 var phone = fancy_prompt_data.phone;
483 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
485 if(obj.retrieve_ids.length > 1) {
486 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
488 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
490 var r = obj.error.yns_alert(msg,
491 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
492 $("commonStrings").getString('common.yes'),
493 $("commonStrings").getString('common.no'),
495 $("commonStrings").getString('common.check_to_confirm')
498 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
501 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
505 'cmd_holds_edit_email_notify' : [
509 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
510 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
511 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
512 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
513 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
514 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
516 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
517 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
518 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
519 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
520 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
521 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
522 JSAN.use('util.window'); var win = new util.window();
523 var fancy_prompt_data = win.open(
524 urls.XUL_FANCY_PROMPT,
525 //+ '?xml_in_stash=temp_mid'
526 //+ '&bottom_xml_in_stash=temp_bot'
527 //+ '&title=' + window.escape('Set Email Notification for Holds'),
528 'fancy_prompt', 'chrome,resizable,modal',
529 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
531 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
532 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
534 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
536 if(get_bool(email)) {
537 if(obj.retrieve_ids.length > 1) {
538 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
540 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
543 if(obj.retrieve_ids.length > 1) {
544 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
546 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
550 var r = obj.error.yns_alert(msg,
551 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
552 $("commonStrings").getString('common.yes'),
553 $("commonStrings").getString('common.no'),
555 $("commonStrings").getString('common.check_to_confirm')
558 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
561 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
565 'cmd_holds_cut_in_line' : [
569 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
570 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
571 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
572 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
573 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
574 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
576 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
577 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
578 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
579 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
580 JSAN.use('util.window'); var win = new util.window();
581 var fancy_prompt_data = win.open(
582 urls.XUL_FANCY_PROMPT,
583 'fancy_prompt', 'chrome,resizable,modal',
584 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
586 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
587 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
589 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
592 if(obj.retrieve_ids.length > 1) {
593 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
595 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
598 if(obj.retrieve_ids.length > 1) {
599 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
601 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
605 var r = obj.error.yns_alert(msg,
606 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
607 $("commonStrings").getString('common.yes'),
608 $("commonStrings").getString('common.no'),
610 $("commonStrings").getString('common.check_to_confirm')
613 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
616 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
620 'cmd_holds_edit_desire_mint_condition' : [
624 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
625 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
626 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
627 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
628 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
629 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
631 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
632 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
633 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
634 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
635 JSAN.use('util.window'); var win = new util.window();
636 var fancy_prompt_data = win.open(
637 urls.XUL_FANCY_PROMPT,
638 'fancy_prompt', 'chrome,resizable,modal',
639 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
641 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
642 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
644 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
647 if(obj.retrieve_ids.length > 1) {
648 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
650 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
653 if(obj.retrieve_ids.length > 1) {
654 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
656 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
660 var r = obj.error.yns_alert(msg,
661 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
662 $("commonStrings").getString('common.yes'),
663 $("commonStrings").getString('common.no'),
665 $("commonStrings").getString('common.check_to_confirm')
668 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
671 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
677 'cmd_holds_suspend' : [
681 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
682 var r = obj.error.yns_alert(
683 obj.retrieve_ids.length > 1 ?
684 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
685 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
686 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
687 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
688 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
690 document.getElementById('commonStrings').getString('common.confirm')
693 var already_suspended = []; var filtered_hold_list = [];
694 for (var i = 0; i < obj.retrieve_ids.length; i++) {
695 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
696 if ( get_bool( hold.frozen() ) ) {
697 already_suspended.push( hold.id() );
700 filtered_hold_list.push( hold.id() );
702 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
703 if (already_suspended.length == 1) {
704 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
705 } else if (already_suspended.length > 1) {
706 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
708 obj.clear_and_retrieve(true);
712 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
716 'cmd_holds_activate' : [
720 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
721 var r = obj.error.yns_alert(
722 obj.retrieve_ids.length > 1 ?
723 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
724 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
725 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
726 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
727 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
729 document.getElementById('commonStrings').getString('common.confirm')
732 var already_activated = []; var filtered_hold_list = [];
733 for (var i = 0; i < obj.retrieve_ids.length; i++) {
734 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
735 if ( ! get_bool( hold.frozen() ) ) {
736 already_activated.push( hold.id() );
739 filtered_hold_list.push( hold.id() );
741 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
742 if (already_activated.length == 1) {
743 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
744 } else if (already_activated.length > 1) {
745 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
747 obj.clear_and_retrieve(true);
751 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
755 'cmd_holds_edit_thaw_date' : [
759 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
760 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
761 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
762 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
763 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
764 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
766 JSAN.use('util.window'); var win = new util.window();
767 var my_xulG = win.open(
768 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
771 'description' : desc,
773 'allow_unset' : true,
774 'disallow_future_dates' : false,
775 'disallow_past_dates' : true,
776 'disallow_today' : true,
777 'default_time' : '00:00:00',
778 'time_readonly' : false
781 if (my_xulG.complete) {
782 circ.util.batch_hold_update(
784 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
785 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
789 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
793 'cmd_holds_edit_expire_time' : [
797 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
798 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
799 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
800 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
801 var value = 'YYYY-MM-DD';
802 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
803 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
805 JSAN.use('util.window'); var win = new util.window();
806 var my_xulG = win.open(
807 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
810 'description' : desc,
812 'allow_unset' : true,
813 'disallow_future_dates' : false,
814 'disallow_past_dates' : true,
815 'disallow_today' : true,
816 'default_time' : '00:00:00',
817 'time_readonly' : false
820 if (my_xulG.complete) {
821 circ.util.batch_hold_update(
823 { 'expire_time' : my_xulG.timestamp },
824 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
828 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
832 'cmd_holds_edit_shelf_expire_time' : [
836 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
837 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
838 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
839 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
840 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
841 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
843 JSAN.use('util.window'); var win = new util.window();
844 var my_xulG = win.open(
845 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
848 'description' : desc,
850 'allow_unset' : false,
851 'disallow_future_dates' : false,
852 'disallow_past_dates' : false,
853 'disallow_today' : false
856 if (my_xulG.complete) {
857 circ.util.batch_hold_update(
859 { 'shelf_expire_time' : my_xulG.timestamp },
860 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
864 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
868 'cmd_holds_edit_request_date' : [
872 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
873 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
874 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
875 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
876 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
877 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
879 JSAN.use('util.window'); var win = new util.window();
880 var my_xulG = win.open(
881 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
884 'description' : desc,
886 'allow_unset' : false,
887 'disallow_future_dates' : true,
888 'disallow_past_dates' : false,
889 'disallow_today' : false
892 if (my_xulG.complete) {
893 circ.util.batch_hold_update(
895 { 'request_time' : my_xulG.timestamp },
896 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
900 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
904 'cmd_holds_retarget' : [
908 JSAN.use('util.functional');
910 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
912 if(obj.retrieve_ids.length > 1) {
913 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
915 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
917 var r = obj.error.yns_alert(msg,
918 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
919 $("commonStrings").getString('common.yes'),
920 $("commonStrings").getString('common.no'),
922 $("commonStrings").getString('common.check_to_confirm')
925 for (var i = 0; i < obj.retrieve_ids.length; i++) {
926 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
927 if (typeof robj.ilsevent != 'undefined') throw(robj);
929 obj.clear_and_retrieve();
932 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
938 'cmd_holds_cancel' : [
942 JSAN.use('util.functional');
944 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
946 if(obj.retrieve_ids.length > 1 ) {
947 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
949 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
952 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
953 JSAN.use('util.window');
954 var win = new util.window();
955 var my_xulG = win.open(
956 urls.XUL_HOLD_CANCEL,
958 'chrome,resizable,modal',
961 /*var r = obj.error.yns_alert(msg,
962 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
963 $("commonStrings").getString('common.yes'),
964 $("commonStrings").getString('common.no'),
966 $("commonStrings").getString('common.check_to_confirm')
969 if (my_xulG.proceed) {
971 for (var i = 0; i < obj.retrieve_ids.length; i++) {
972 if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
973 transits.push( obj.retrieve_ids[i].barcode );
975 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
976 if (typeof robj.ilsevent != 'undefined') throw(robj);
978 if (transits.length > 0) {
979 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
980 var r2 = obj.error.yns_alert(msg2,
981 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
982 $("commonStrings").getString('common.yes'),
983 $("commonStrings").getString('common.no'),
985 $("commonStrings").getString('common.check_to_confirm'));
988 for (var i = 0; i < transits.length; i++) {
989 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
990 if (typeof robj.ilsevent != 'undefined') {
991 switch(Number(robj.ilsevent)) {
992 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
995 case 5000 /* PERM_FAILURE */ :
1004 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1008 obj.clear_and_retrieve();
1011 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1015 'cmd_holds_uncancel' : [
1019 JSAN.use('util.functional');
1020 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1021 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1022 if (typeof robj.ilsevent != 'undefined') throw(robj);
1024 obj.clear_and_retrieve();
1026 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1031 'cmd_retrieve_patron' : [
1036 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1037 var patron_id = obj.retrieve_ids[i].usr;
1038 if (seen[patron_id]) continue; seen[patron_id] = true;
1039 xulG.new_patron_tab(
1041 { 'id' : patron_id }
1045 obj.error.standard_unexpected_error_alert('',E);
1049 'cmd_show_catalog' : [
1053 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1054 var htarget = obj.retrieve_ids[i].target;
1055 var htype = obj.retrieve_ids[i].type;
1059 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1062 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1065 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1066 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1069 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1071 if (typeof my_acp.call_number() == 'object') {
1072 my_acn = my.acp.call_number();
1074 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1075 [ my_acp.call_number() ]);
1077 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1080 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1084 var content_params = {
1086 'authtime' : ses('authtime'),
1087 'opac_url' : opac_url
1090 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1091 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1096 obj.error.standard_unexpected_error_alert('',E);
1100 'cmd_holds_title_transfer' : [
1105 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1106 var htarget = obj.retrieve_ids[i].target;
1107 var htype = obj.retrieve_ids[i].type;
1110 continue; // not supported
1113 targets.push( htarget );
1116 continue; // not supported
1119 continue; // not supported
1122 continue; // not supported
1126 JSAN.use('cat.util');
1127 cat.util.transfer_title_holds(targets);
1128 obj.clear_and_retrieve();
1130 obj.error.standard_unexpected_error_alert('',E);
1138 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1142 'lib_filter_checkbox' : [
1145 var x_lib_type_menu = document.getElementById('lib_type_menu');
1146 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1147 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1148 obj.clear_and_retrieve();
1149 ev.target.setAttribute('checked',ev.target.checked);
1152 'cmd_view_expired_onshelf_holds' : [
1155 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1156 obj.expired = x.checked;
1157 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1158 obj.clear_and_retrieve();
1161 'cmd_clear_expired_onshelf_holds' : [
1165 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1166 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1167 if (robj == null) { robj = []; }
1168 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1169 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1171 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1172 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1173 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1174 var x_lib_type_menu = document.getElementById('lib_type_menu');
1175 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1176 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1177 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1178 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1179 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1181 // id's in xulG.holds will prevent the normal retrieval method from firing
1182 JSAN.use('util.functional');
1183 xulG.holds = util.functional.map_list(
1184 robj.sort(function(a,b) {
1185 if (a.action > b.action) { return 1; }
1186 if (a.action < b.action) { return -1; }
1189 function (element, idx) {
1190 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1191 return element.hold_id;
1194 obj.clear_and_retrieve();
1196 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1197 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1202 'cmd_search_opac' : [
1206 var content_params = {
1207 'show_nav_buttons' : false,
1208 'show_print_button' : true,
1209 'passthru_content_params' : {
1210 'authtoken' : ses(),
1211 'authtime' : ses('authtime'),
1212 'window_open' : function(a,b,c) {
1214 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1215 return window.open(a,b,c);
1217 obj.error.standard_unexpected_error_alert('window_open',E);
1220 'opac_hold_placed' : function(hold) {
1226 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1231 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1232 window.xulG.on_list_change();
1235 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1238 'patron_barcode' : obj.patron_barcode
1240 'url_prefix' : xulG.url_prefix,
1241 'url' : xulG.url_prefix( urls.browser )
1243 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1245 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1254 obj.determine_hold_interface_type();
1255 var x_fetch_more = document.getElementById('fetch_more');
1256 var x_lib_type_menu = document.getElementById('lib_type_menu');
1257 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1258 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1259 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1260 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1261 var x_expired_checkbox = document.getElementById('expired_checkbox');
1262 switch(obj.hold_interface_type) {
1264 obj.render_lib_menus({'pickup_lib':true});
1265 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1266 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1267 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1268 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1271 if (x_fetch_more) x_fetch_more.hidden = false;
1272 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1273 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1276 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1277 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1278 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1279 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1282 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1283 if (x_fetch_more) x_fetch_more.hidden = true;
1284 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1285 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1286 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1289 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
1291 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1292 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1293 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1295 obj.controller.render();
1298 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1299 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1300 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1301 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1302 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1303 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1304 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1305 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1306 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1307 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1308 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1309 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1310 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1314 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1315 JSAN.use('util.browser');
1316 obj.browser = new util.browser();
1319 'url' : urls.XUL_HOLD_DETAILS,
1321 'alt_print' : false,
1322 'browser_id' : 'hold_detail_frame',
1323 'passthru_content_params' : xulG,
1329 'determine_hold_interface_type' : function() {
1331 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1332 obj.hold_interface_type = 'patron';
1333 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1334 obj.hold_interface_type = 'record';
1335 } else if (obj.pull) { /*************************************************** PULL ******************************/
1336 obj.hold_interface_type = 'pull';
1337 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1338 obj.hold_interface_type = 'shelf';
1339 } else { /*************************************************** PULL ******************************/
1340 obj.hold_interface_type = 'pull';
1344 'clear_and_retrieve' : function() {
1347 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1349 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1350 window.xulG.on_list_change();
1353 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1357 'retrieve' : function() {
1358 var obj = this; var holds = [];
1359 if (window.xulG && window.xulG.holds) {
1360 holds = window.xulG.holds;
1362 var method; var params = [ ses() ];
1363 switch(obj.hold_interface_type) {
1365 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1366 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1368 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1370 params.push( obj.patron_id );
1371 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1374 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1375 params.push( obj.docid );
1376 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1377 var x_lib_type_menu = document.getElementById('lib_type_menu');
1379 if (x_lib_filter.checked) {
1380 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1382 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1387 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1391 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1393 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1395 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1396 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1400 method = 'FM_AHR_ID_LIST_PULL_LIST';
1401 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1402 var x = document.getElementById('hold_count');
1404 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1405 var count = req.getResultObject();
1406 if (typeof count.ilsevent == 'undefined' && count != null) {
1407 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1408 'staff.patron.holds.total_count',
1417 var robj = obj.network.simple_request( method, params );
1418 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1419 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1422 holds = holds.concat( robj.copy_holds );
1423 holds = holds.concat( robj.volume_holds );
1424 holds = holds.concat( robj.title_holds );
1425 holds = holds.concat( robj.metarecord_holds );
1426 holds = holds.sort();
1429 if (robj == null ) {
1432 if (typeof robj.length == 'undefined') {
1440 //alert('method = ' + method + ' params = ' + js2JSON(params));
1443 var x_fetch_more = document.getElementById('fetch_more');
1444 if (holds.length == 0) {
1445 if (x_fetch_more) x_fetch_more.disabled = true;
1447 if (x_fetch_more) x_fetch_more.disabled = false;
1453 'render' : function(holds) {
1457 function list_append(hold_id) {
1462 'hold_id' : hold_id,
1463 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1470 function gen_list_append(hold) {
1472 if (typeof obj.controller.view.lib_menu == 'undefined') {
1473 list_append(typeof hold == 'object' ? hold.id() : hold);
1475 list_append(typeof hold == 'object' ? hold.id() : hold);
1482 JSAN.use('util.exec'); var exec = new util.exec(2);
1484 for (var i in holds) {
1485 rows.push( gen_list_append(holds[i]) );
1490 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1494 'render_lib_menus' : function(types) {
1497 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1499 var x = document.getElementById('lib_type_menu');
1501 var nodes = x.firstChild.childNodes;
1502 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1503 for (var i in types) document.getElementById(i).hidden = false;
1505 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1507 x = document.getElementById('lib_menu_placeholder');
1508 util.widgets.remove_children( x );
1510 JSAN.use('util.file');
1511 var file = new util.file('offline_ou_list');
1512 if (file._file.exists()) {
1513 var list_data = file.get_object(); file.close();
1514 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1515 ml.setAttribute('id','lib_menu');
1516 x.appendChild( ml );
1517 ml.addEventListener(
1520 obj.filter_lib = ev.target.value;
1521 obj.clear_and_retrieve();
1525 obj.controller.view.lib_menu = ml;
1527 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1531 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1536 dump('exiting patron.holds.js\n');