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 }
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 JSAN.use('util.date');
760 function check_date(value) {
762 if (! util.date.check('YYYY-MM-DD',value) ) { throw(document.getElementById('circStrings').getString('staff.circ.holds.activation_date.invalid_date')); }
763 if (util.date.check_past('YYYY-MM-DD',value) || util.date.formatted_date(new Date(),'%F') == value ) {
764 throw(document.getElementById('circStrings').getString('staff.circ.holds.activation_date.too_early.error'));
773 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
774 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
775 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
776 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
777 var value = 'YYYY-MM-DD';
778 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
779 var thaw_date; var invalid = true;
781 thaw_date = window.prompt(msg,value,title);
783 invalid = ! check_date(thaw_date);
788 if (thaw_date || thaw_date == '') {
789 circ.util.batch_hold_update(
791 { 'frozen' : 't', 'thaw_date' : thaw_date == '' ? null : util.date.formatted_date(thaw_date + ' 00:00:00','%{iso8601}') },
792 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
796 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
800 'cmd_holds_edit_expire_time' : [
804 JSAN.use('util.date');
805 function check_date(value) {
807 if (! util.date.check('YYYY-MM-DD',value) ) { throw(document.getElementById('circStrings').getString('staff.circ.holds.expire_time.invalid_date')); }
808 if (util.date.check_past('YYYY-MM-DD',value) || util.date.formatted_date(new Date(),'%F') == value ) {
809 throw(document.getElementById('circStrings').getString('staff.circ.holds.expire_time.too_early.error'));
818 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
819 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
820 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
821 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
822 var value = 'YYYY-MM-DD';
823 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
824 var expire_time; var invalid = true;
826 expire_time = window.prompt(msg,value,title);
828 invalid = ! check_date(expire_time);
833 if (expire_time || expire_time == '') {
834 circ.util.batch_hold_update(
836 { 'expire_time' : expire_time == '' ? null : util.date.formatted_date(expire_time + ' 00:00:00','%{iso8601}') },
837 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
841 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
845 'cmd_holds_edit_shelf_expire_time' : [
849 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
850 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
851 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
852 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
853 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
854 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
856 JSAN.use('util.window'); var win = new util.window();
857 var my_xulG = win.open(
858 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
861 'description' : desc,
863 'allow_unset' : false,
864 'disallow_future_dates' : false,
865 'disallow_past_dates' : false,
866 'disallow_today' : false
869 if (my_xulG.complete) {
870 circ.util.batch_hold_update(
872 { 'shelf_expire_time' : my_xulG.timestamp },
873 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
877 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
881 'cmd_holds_edit_request_date' : [
885 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
886 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
887 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
888 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
889 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
890 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
892 JSAN.use('util.window'); var win = new util.window();
893 var my_xulG = win.open(
894 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
897 'description' : desc,
899 'allow_unset' : false,
900 'disallow_future_dates' : true,
901 'disallow_past_dates' : false,
902 'disallow_today' : false
905 if (my_xulG.complete) {
906 circ.util.batch_hold_update(
908 { 'request_time' : my_xulG.timestamp },
909 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
913 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
917 'cmd_holds_retarget' : [
921 JSAN.use('util.functional');
923 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
925 if(obj.retrieve_ids.length > 1) {
926 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
928 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
930 var r = obj.error.yns_alert(msg,
931 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
932 $("commonStrings").getString('common.yes'),
933 $("commonStrings").getString('common.no'),
935 $("commonStrings").getString('common.check_to_confirm')
938 for (var i = 0; i < obj.retrieve_ids.length; i++) {
939 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
940 if (typeof robj.ilsevent != 'undefined') throw(robj);
942 obj.clear_and_retrieve();
945 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
951 'cmd_holds_cancel' : [
955 JSAN.use('util.functional');
957 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
959 if(obj.retrieve_ids.length > 1 ) {
960 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
962 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
965 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
966 JSAN.use('util.window');
967 var win = new util.window();
968 var my_xulG = win.open(
969 urls.XUL_HOLD_CANCEL,
971 'chrome,resizable,modal',
974 /*var r = obj.error.yns_alert(msg,
975 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
976 $("commonStrings").getString('common.yes'),
977 $("commonStrings").getString('common.no'),
979 $("commonStrings").getString('common.check_to_confirm')
982 if (my_xulG.proceed) {
984 for (var i = 0; i < obj.retrieve_ids.length; i++) {
985 if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
986 transits.push( obj.retrieve_ids[i].barcode );
988 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
989 if (typeof robj.ilsevent != 'undefined') throw(robj);
991 if (transits.length > 0) {
992 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
993 var r2 = obj.error.yns_alert(msg2,
994 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
995 $("commonStrings").getString('common.yes'),
996 $("commonStrings").getString('common.no'),
998 $("commonStrings").getString('common.check_to_confirm'));
1001 for (var i = 0; i < transits.length; i++) {
1002 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1003 if (typeof robj.ilsevent != 'undefined') {
1004 switch(Number(robj.ilsevent)) {
1005 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1008 case 5000 /* PERM_FAILURE */ :
1017 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1021 obj.clear_and_retrieve();
1024 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1028 'cmd_holds_uncancel' : [
1032 JSAN.use('util.functional');
1033 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1034 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1035 if (typeof robj.ilsevent != 'undefined') throw(robj);
1037 obj.clear_and_retrieve();
1039 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1044 'cmd_retrieve_patron' : [
1049 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1050 var patron_id = obj.retrieve_ids[i].usr;
1051 if (seen[patron_id]) continue; seen[patron_id] = true;
1052 xulG.new_patron_tab(
1054 { 'id' : patron_id }
1058 obj.error.standard_unexpected_error_alert('',E);
1062 'cmd_show_catalog' : [
1066 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1067 var htarget = obj.retrieve_ids[i].target;
1068 var htype = obj.retrieve_ids[i].type;
1072 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1075 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1078 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1079 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1082 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1084 if (typeof my_acp.call_number() == 'object') {
1085 my_acn = my.acp.call_number();
1087 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1088 [ my_acp.call_number() ]);
1090 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1093 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1097 var content_params = {
1099 'authtime' : ses('authtime'),
1100 'opac_url' : opac_url
1103 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1104 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1109 obj.error.standard_unexpected_error_alert('',E);
1113 'cmd_holds_title_transfer' : [
1118 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1119 var htarget = obj.retrieve_ids[i].target;
1120 var htype = obj.retrieve_ids[i].type;
1123 continue; // not supported
1126 targets.push( htarget );
1129 continue; // not supported
1132 continue; // not supported
1135 continue; // not supported
1139 JSAN.use('cat.util');
1140 cat.util.transfer_title_holds(targets);
1141 obj.clear_and_retrieve();
1143 obj.error.standard_unexpected_error_alert('',E);
1151 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1155 'lib_filter_checkbox' : [
1158 var x_lib_type_menu = document.getElementById('lib_type_menu');
1159 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1160 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1161 obj.clear_and_retrieve();
1162 ev.target.setAttribute('checked',ev.target.checked);
1165 'cmd_view_expired_onshelf_holds' : [
1168 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1169 obj.expired = x.checked;
1170 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1171 obj.clear_and_retrieve();
1174 'cmd_clear_expired_onshelf_holds' : [
1178 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1179 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1180 if (robj == null) { robj = []; }
1181 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1182 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1184 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1185 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1186 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1187 var x_lib_type_menu = document.getElementById('lib_type_menu');
1188 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1189 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1190 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1191 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1192 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1194 // id's in xulG.holds will prevent the normal retrieval method from firing
1195 JSAN.use('util.functional');
1196 xulG.holds = util.functional.map_list(
1197 robj.sort(function(a,b) {
1198 if (a.action > b.action) { return 1; }
1199 if (a.action < b.action) { return -1; }
1202 function (element, idx) {
1203 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1204 return element.hold_id;
1207 obj.clear_and_retrieve();
1209 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1210 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1215 'cmd_search_opac' : [
1219 var content_params = {
1220 'show_nav_buttons' : false,
1221 'show_print_button' : true,
1222 'passthru_content_params' : {
1223 'authtoken' : ses(),
1224 'authtime' : ses('authtime'),
1225 'window_open' : function(a,b,c) {
1227 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1228 return window.open(a,b,c);
1230 obj.error.standard_unexpected_error_alert('window_open',E);
1233 'opac_hold_placed' : function(hold) {
1239 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1244 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1245 window.xulG.on_list_change();
1248 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1251 'patron_barcode' : obj.patron_barcode
1253 'url_prefix' : xulG.url_prefix,
1254 'url' : xulG.url_prefix( urls.browser )
1256 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1258 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1267 obj.determine_hold_interface_type();
1268 var x_fetch_more = document.getElementById('fetch_more');
1269 var x_lib_type_menu = document.getElementById('lib_type_menu');
1270 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1271 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1272 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1273 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1274 var x_expired_checkbox = document.getElementById('expired_checkbox');
1275 switch(obj.hold_interface_type) {
1277 obj.render_lib_menus({'pickup_lib':true});
1278 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1279 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1280 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1281 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1284 if (x_fetch_more) x_fetch_more.hidden = false;
1285 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1286 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1289 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1290 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1291 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1292 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1295 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1296 if (x_fetch_more) x_fetch_more.hidden = true;
1297 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1298 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1299 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1302 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
1304 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1305 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1306 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1308 obj.controller.render();
1311 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1312 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1313 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1314 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1315 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1316 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1317 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1318 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1319 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1320 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1321 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1322 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1323 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1327 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1328 JSAN.use('util.browser');
1329 obj.browser = new util.browser();
1332 'url' : urls.XUL_HOLD_DETAILS,
1334 'alt_print' : false,
1335 'browser_id' : 'hold_detail_frame',
1336 'passthru_content_params' : xulG,
1342 'determine_hold_interface_type' : function() {
1344 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1345 obj.hold_interface_type = 'patron';
1346 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1347 obj.hold_interface_type = 'record';
1348 } else if (obj.pull) { /*************************************************** PULL ******************************/
1349 obj.hold_interface_type = 'pull';
1350 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1351 obj.hold_interface_type = 'shelf';
1352 } else { /*************************************************** PULL ******************************/
1353 obj.hold_interface_type = 'pull';
1357 'clear_and_retrieve' : function() {
1360 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1362 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1363 window.xulG.on_list_change();
1366 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1370 'retrieve' : function() {
1371 var obj = this; var holds = [];
1372 if (window.xulG && window.xulG.holds) {
1373 holds = window.xulG.holds;
1375 var method; var params = [ ses() ];
1376 switch(obj.hold_interface_type) {
1378 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1379 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1381 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1383 params.push( obj.patron_id );
1384 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1387 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1388 params.push( obj.docid );
1389 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1390 var x_lib_type_menu = document.getElementById('lib_type_menu');
1392 if (x_lib_filter.checked) {
1393 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1395 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1400 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1404 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1406 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1408 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1409 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1413 method = 'FM_AHR_ID_LIST_PULL_LIST';
1414 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1415 var x = document.getElementById('hold_count');
1417 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1418 var count = req.getResultObject();
1419 if (typeof count.ilsevent == 'undefined' && count != null) {
1420 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1421 'staff.patron.holds.total_count',
1430 var robj = obj.network.simple_request( method, params );
1431 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1432 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1435 holds = holds.concat( robj.copy_holds );
1436 holds = holds.concat( robj.volume_holds );
1437 holds = holds.concat( robj.title_holds );
1438 holds = holds.concat( robj.metarecord_holds );
1439 holds = holds.sort();
1442 if (robj == null ) {
1445 if (typeof robj.length == 'undefined') {
1453 //alert('method = ' + method + ' params = ' + js2JSON(params));
1456 var x_fetch_more = document.getElementById('fetch_more');
1457 if (holds.length == 0) {
1458 if (x_fetch_more) x_fetch_more.disabled = true;
1460 if (x_fetch_more) x_fetch_more.disabled = false;
1466 'render' : function(holds) {
1470 function list_append(hold_id) {
1475 'hold_id' : hold_id,
1476 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1483 function gen_list_append(hold) {
1485 if (typeof obj.controller.view.lib_menu == 'undefined') {
1486 list_append(typeof hold == 'object' ? hold.id() : hold);
1488 list_append(typeof hold == 'object' ? hold.id() : hold);
1495 JSAN.use('util.exec'); var exec = new util.exec(2);
1497 for (var i in holds) {
1498 rows.push( gen_list_append(holds[i]) );
1503 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1507 'render_lib_menus' : function(types) {
1510 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1512 var x = document.getElementById('lib_type_menu');
1514 var nodes = x.firstChild.childNodes;
1515 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1516 for (var i in types) document.getElementById(i).hidden = false;
1518 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1520 x = document.getElementById('lib_menu_placeholder');
1521 util.widgets.remove_children( x );
1523 JSAN.use('util.file');
1524 var file = new util.file('offline_ou_list');
1525 if (file._file.exists()) {
1526 var list_data = file.get_object(); file.close();
1527 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1528 ml.setAttribute('id','lib_menu');
1529 x.appendChild( ml );
1530 ml.addEventListener(
1533 obj.filter_lib = ev.target.value;
1534 obj.clear_and_retrieve();
1538 obj.controller.view.lib_menu = ml;
1540 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1544 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1549 dump('exiting patron.holds.js\n');