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('rendering_rows','false');
154 if (obj.controller.view.cmd_alt_view.getAttribute('ready')=='true') {
155 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
157 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
158 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
159 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
160 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
162 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
163 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
164 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
165 obj.controller.view.sel_patron.setAttribute('disabled','true');
166 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
167 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
168 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
169 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
170 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
171 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
172 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
173 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
174 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
175 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
176 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
177 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
178 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
179 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','true');
180 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
181 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
182 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
183 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
189 JSAN.use('util.controller'); obj.controller = new util.controller();
193 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
196 function() { obj.list.clipboard(); }
200 function() { alert($("commonStrings").getString('common.unimplemented')); }
205 JSAN.use('circ.util');
206 circ.util.show_last_few_circs(obj.retrieve_ids);
212 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
213 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
220 var n = obj.controller.view.alt_view_btn;
221 if (n.getAttribute('toggle') == '1') {
222 document.getElementById('deck').selectedIndex = 0;
223 n.setAttribute('toggle','0');
224 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
225 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
227 document.getElementById('deck').selectedIndex = 1;
228 n.setAttribute('toggle','1');
229 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
230 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
231 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
232 if (obj.retrieve_ids.length == 0) return;
233 var f = obj.browser.get_content();
234 xulG.ahr_id = obj.retrieve_ids[0].id;
235 xulG.blob = obj.holds_map[ xulG.ahr_id ];
236 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
237 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
239 f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
240 f.fetch_and_render_all(true);
243 alert('Error in holds.js, cmd_alt_view handler: ' + E);
247 'cmd_cancelled_holds_view' : [
250 document.getElementById('show_cancelled_deck').selectedIndex = 1;
251 /* For some reason attribute propogation on the <command> element isn't working with hidden */
252 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
253 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
254 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
255 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
256 obj.clear_and_retrieve();
259 'cmd_uncancelled_holds_view' : [
262 document.getElementById('show_cancelled_deck').selectedIndex = 0;
263 /* For some reason attribute propogation on the <command> element isn't working with hidden */
264 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
265 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
266 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
267 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
268 obj.clear_and_retrieve();
271 'sel_mark_items_damaged' : [
274 JSAN.use('cat.util'); JSAN.use('util.functional');
275 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
278 'sel_mark_items_missing' : [
281 JSAN.use('cat.util'); JSAN.use('util.functional');
282 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
285 'sel_copy_details' : [
288 JSAN.use('circ.util');
289 circ.util.item_details_new(
290 util.functional.map_list(
292 function(o) { return o.barcode; }
297 'cmd_holds_print_full' : [
300 var x_print_full_pull_list = document.getElementById('print_full_btn');
303 progressmeter.mode = 'undetermined';
304 progressmeter.hidden = false;
305 x_print_full_pull_list.disabled = true;
307 JSAN.use('util.print');
308 var print = new util.print('default');
309 var robj = fieldmapper.standardRequest(
310 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
317 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
318 print.simple( robj.template_output().data() );
321 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
324 progressmeter.mode = 'determined';
325 progressmeter.hidden = true;
326 x_print_full_pull_list.disabled = false;
330 'cmd_holds_print' : [
334 JSAN.use('patron.util');
336 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
339 obj.list.print(params);
341 obj.error.standard_unexpected_error_alert('print 1',E);
345 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
346 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
347 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
349 'cmd_holds_edit_selection_depth' : [
353 JSAN.use('util.widgets'); JSAN.use('util.functional');
354 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
355 var list = util.functional.map_list(
356 util.functional.filter_list(
359 if (o.depth() > ws_type.depth()) return false;
360 if (o.depth() < ws_type.depth()) return true;
361 return (o.id() == ws_type.id());
373 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
374 ml.setAttribute('id','selection');
375 ml.setAttribute('name','fancy_data');
376 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
377 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
378 xml += util.widgets.serialize_node(ml);
380 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
381 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
382 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
383 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
384 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
385 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
386 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
387 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
388 JSAN.use('util.window'); var win = new util.window();
389 var fancy_prompt_data = win.open(
390 urls.XUL_FANCY_PROMPT,
391 //+ '?xml_in_stash=temp_mid'
392 //+ '&bottom_xml_in_stash=temp_bot'
393 //+ '&title=' + window.escape('Choose a Pick Up Library'),
394 'fancy_prompt', 'chrome,resizable,modal',
395 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
397 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
398 var selection = fancy_prompt_data.selection;
400 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
402 if(obj.retrieve_ids.length > 1) {
403 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
405 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
408 var r = obj.error.yns_alert(msg,
409 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
410 $("commonStrings").getString('common.yes'),
411 $("commonStrings").getString('common.no'),
413 $("commonStrings").getString('common.check_to_confirm')
416 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
419 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
424 'cmd_holds_edit_pickup_lib' : [
428 JSAN.use('util.widgets'); JSAN.use('util.functional');
430 var list = util.functional.map_list(
433 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
435 o.name() ? sname + ' ' + o.name() : o.shortname(),
437 ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
438 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
442 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
443 ml.setAttribute('id','lib');
444 ml.setAttribute('name','fancy_data');
445 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
446 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
447 xml += util.widgets.serialize_node(ml);
449 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
450 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
451 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
452 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
453 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
454 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
455 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
456 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
457 JSAN.use('util.window'); var win = new util.window();
458 var fancy_prompt_data = win.open(
459 urls.XUL_FANCY_PROMPT,
460 //+ '?xml_in_stash=temp_mid'
461 //+ '&bottom_xml_in_stash=temp_bot'
462 //+ '&title=' + window.escape('Choose a Pick Up Library'),
463 'fancy_prompt', 'chrome,resizable,modal',
464 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
466 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
467 var pickup_lib = fancy_prompt_data.lib;
469 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
471 if(obj.retrieve_ids.length > 1) {
472 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()]);
474 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()]);
476 var r = obj.error.yns_alert(msg,
477 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
478 $("commonStrings").getString('common.yes'),
479 $("commonStrings").getString('common.no'),
481 $("commonStrings").getString('common.check_to_confirm')
484 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
487 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
491 'cmd_holds_edit_phone_notify' : [
495 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
496 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
497 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
499 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
500 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
501 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
502 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
503 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
504 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
505 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
506 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
507 JSAN.use('util.window'); var win = new util.window();
508 var fancy_prompt_data = win.open(
509 urls.XUL_FANCY_PROMPT,
510 //+ '?xml_in_stash=temp_mid'
511 //+ '&bottom_xml_in_stash=temp_bot'
512 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
514 'fancy_prompt', 'chrome,resizable,modal',
515 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
517 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
518 var phone = fancy_prompt_data.phone;
520 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
522 if(obj.retrieve_ids.length > 1) {
523 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
525 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
527 var r = obj.error.yns_alert(msg,
528 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
529 $("commonStrings").getString('common.yes'),
530 $("commonStrings").getString('common.no'),
532 $("commonStrings").getString('common.check_to_confirm')
535 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
538 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
542 'cmd_holds_edit_email_notify' : [
546 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
547 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
548 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
549 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
550 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
551 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
553 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
554 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
555 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
556 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
557 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
558 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
559 JSAN.use('util.window'); var win = new util.window();
560 var fancy_prompt_data = win.open(
561 urls.XUL_FANCY_PROMPT,
562 //+ '?xml_in_stash=temp_mid'
563 //+ '&bottom_xml_in_stash=temp_bot'
564 //+ '&title=' + window.escape('Set Email Notification for Holds'),
565 'fancy_prompt', 'chrome,resizable,modal',
566 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
568 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
569 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
571 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
573 if(get_bool(email)) {
574 if(obj.retrieve_ids.length > 1) {
575 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
577 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
580 if(obj.retrieve_ids.length > 1) {
581 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
583 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
587 var r = obj.error.yns_alert(msg,
588 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
589 $("commonStrings").getString('common.yes'),
590 $("commonStrings").getString('common.no'),
592 $("commonStrings").getString('common.check_to_confirm')
595 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
598 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
602 'cmd_holds_cut_in_line' : [
606 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
607 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
608 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
609 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
610 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
611 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
613 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
614 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
615 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
616 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
617 JSAN.use('util.window'); var win = new util.window();
618 var fancy_prompt_data = win.open(
619 urls.XUL_FANCY_PROMPT,
620 'fancy_prompt', 'chrome,resizable,modal',
621 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
623 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
624 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
626 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
629 if(obj.retrieve_ids.length > 1) {
630 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
632 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
635 if(obj.retrieve_ids.length > 1) {
636 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
638 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
642 var r = obj.error.yns_alert(msg,
643 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
644 $("commonStrings").getString('common.yes'),
645 $("commonStrings").getString('common.no'),
647 $("commonStrings").getString('common.check_to_confirm')
650 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
653 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
657 'cmd_holds_edit_desire_mint_condition' : [
661 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
662 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
663 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
664 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
665 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
666 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
668 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
669 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
670 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
671 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
672 JSAN.use('util.window'); var win = new util.window();
673 var fancy_prompt_data = win.open(
674 urls.XUL_FANCY_PROMPT,
675 'fancy_prompt', 'chrome,resizable,modal',
676 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
678 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
679 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
681 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
684 if(obj.retrieve_ids.length > 1) {
685 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
687 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
690 if(obj.retrieve_ids.length > 1) {
691 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
693 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
697 var r = obj.error.yns_alert(msg,
698 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
699 $("commonStrings").getString('common.yes'),
700 $("commonStrings").getString('common.no'),
702 $("commonStrings").getString('common.check_to_confirm')
705 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
708 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
714 'cmd_holds_suspend' : [
718 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
719 var r = obj.error.yns_alert(
720 obj.retrieve_ids.length > 1 ?
721 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
722 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
723 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
724 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
725 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
727 document.getElementById('commonStrings').getString('common.confirm')
730 var already_suspended = []; var filtered_hold_list = [];
731 for (var i = 0; i < obj.retrieve_ids.length; i++) {
732 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
733 if ( get_bool( hold.frozen() ) ) {
734 already_suspended.push( hold.id() );
737 filtered_hold_list.push( hold.id() );
739 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
740 if (already_suspended.length == 1) {
741 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
742 } else if (already_suspended.length > 1) {
743 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
745 obj.clear_and_retrieve(true);
749 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
753 'cmd_holds_activate' : [
757 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
758 var r = obj.error.yns_alert(
759 obj.retrieve_ids.length > 1 ?
760 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
761 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
762 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
763 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
764 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
766 document.getElementById('commonStrings').getString('common.confirm')
769 var already_activated = []; var filtered_hold_list = [];
770 for (var i = 0; i < obj.retrieve_ids.length; i++) {
771 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
772 if ( ! get_bool( hold.frozen() ) ) {
773 already_activated.push( hold.id() );
776 filtered_hold_list.push( hold.id() );
778 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
779 if (already_activated.length == 1) {
780 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
781 } else if (already_activated.length > 1) {
782 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
784 obj.clear_and_retrieve(true);
788 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
792 'cmd_holds_edit_thaw_date' : [
796 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
797 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
798 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
799 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
800 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
801 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
803 JSAN.use('util.window'); var win = new util.window();
804 var my_xulG = win.open(
805 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
808 'description' : desc,
810 'allow_unset' : true,
811 'disallow_future_dates' : false,
812 'disallow_past_dates' : true,
813 'disallow_today' : true,
814 'default_time' : '00:00:00',
815 'time_readonly' : false
818 if (my_xulG.complete) {
819 circ.util.batch_hold_update(
821 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
822 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
826 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
830 'cmd_holds_edit_expire_time' : [
834 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
835 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
836 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
837 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
838 var value = 'YYYY-MM-DD';
839 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
840 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
842 JSAN.use('util.window'); var win = new util.window();
843 var my_xulG = win.open(
844 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
847 'description' : desc,
849 'allow_unset' : true,
850 'disallow_future_dates' : false,
851 'disallow_past_dates' : true,
852 'disallow_today' : true,
853 'default_time' : '00:00:00',
854 'time_readonly' : false
857 if (my_xulG.complete) {
858 circ.util.batch_hold_update(
860 { 'expire_time' : my_xulG.timestamp },
861 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
865 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
869 'cmd_holds_edit_shelf_expire_time' : [
873 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
874 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
875 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
876 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
877 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
878 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
880 JSAN.use('util.window'); var win = new util.window();
881 var my_xulG = win.open(
882 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
885 'description' : desc,
887 'allow_unset' : false,
888 'disallow_future_dates' : false,
889 'disallow_past_dates' : false,
890 'disallow_today' : false
893 if (my_xulG.complete) {
894 circ.util.batch_hold_update(
896 { 'shelf_expire_time' : my_xulG.timestamp },
897 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
901 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
905 'cmd_holds_edit_request_date' : [
909 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
910 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
911 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
912 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
913 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
914 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
916 JSAN.use('util.window'); var win = new util.window();
917 var my_xulG = win.open(
918 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
921 'description' : desc,
923 'allow_unset' : false,
924 'disallow_future_dates' : true,
925 'disallow_past_dates' : false,
926 'disallow_today' : false
929 if (my_xulG.complete) {
930 circ.util.batch_hold_update(
932 { 'request_time' : my_xulG.timestamp },
933 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
937 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
941 'cmd_holds_retarget' : [
945 JSAN.use('util.functional');
947 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
949 if(obj.retrieve_ids.length > 1) {
950 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
952 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
954 var r = obj.error.yns_alert(msg,
955 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
956 $("commonStrings").getString('common.yes'),
957 $("commonStrings").getString('common.no'),
959 $("commonStrings").getString('common.check_to_confirm')
962 for (var i = 0; i < obj.retrieve_ids.length; i++) {
963 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
964 if (typeof robj.ilsevent != 'undefined') throw(robj);
966 obj.clear_and_retrieve();
969 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
975 'cmd_holds_cancel' : [
979 JSAN.use('util.functional');
981 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
983 if(obj.retrieve_ids.length > 1 ) {
984 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
986 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
989 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
990 JSAN.use('util.window');
991 var win = new util.window();
992 var my_xulG = win.open(
993 urls.XUL_HOLD_CANCEL,
995 'chrome,resizable,modal',
998 /*var r = obj.error.yns_alert(msg,
999 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1000 $("commonStrings").getString('common.yes'),
1001 $("commonStrings").getString('common.no'),
1003 $("commonStrings").getString('common.check_to_confirm')
1006 if (my_xulG.proceed) {
1008 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1009 if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
1010 transits.push( obj.retrieve_ids[i].barcode );
1012 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1013 if (typeof robj.ilsevent != 'undefined') throw(robj);
1015 if (transits.length > 0) {
1016 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1017 var r2 = obj.error.yns_alert(msg2,
1018 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1019 $("commonStrings").getString('common.yes'),
1020 $("commonStrings").getString('common.no'),
1022 $("commonStrings").getString('common.check_to_confirm'));
1025 for (var i = 0; i < transits.length; i++) {
1026 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1027 if (typeof robj.ilsevent != 'undefined') {
1028 switch(Number(robj.ilsevent)) {
1029 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1032 case 5000 /* PERM_FAILURE */ :
1041 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1045 obj.clear_and_retrieve();
1048 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1052 'cmd_holds_uncancel' : [
1056 JSAN.use('util.functional');
1057 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1058 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1059 if (typeof robj.ilsevent != 'undefined') throw(robj);
1061 obj.clear_and_retrieve();
1063 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1068 'cmd_retrieve_patron' : [
1073 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1074 var patron_id = obj.retrieve_ids[i].usr;
1075 if (seen[patron_id]) continue; seen[patron_id] = true;
1076 xulG.new_patron_tab(
1078 { 'id' : patron_id }
1082 obj.error.standard_unexpected_error_alert('',E);
1086 'cmd_show_catalog' : [
1090 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1091 var htarget = obj.retrieve_ids[i].target;
1092 var htype = obj.retrieve_ids[i].type;
1096 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1099 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1102 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1103 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1106 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1108 if (typeof my_acp.call_number() == 'object') {
1109 my_acn = my.acp.call_number();
1111 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1112 [ my_acp.call_number() ]);
1114 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1117 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1121 var content_params = {
1123 'authtime' : ses('authtime'),
1124 'opac_url' : opac_url
1127 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1128 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1133 obj.error.standard_unexpected_error_alert('',E);
1137 'cmd_holds_title_transfer' : [
1142 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1143 var htarget = obj.retrieve_ids[i].target;
1144 var htype = obj.retrieve_ids[i].type;
1147 continue; // not supported
1150 targets.push( htarget );
1153 continue; // not supported
1156 continue; // not supported
1159 continue; // not supported
1163 JSAN.use('cat.util');
1164 cat.util.transfer_title_holds(targets);
1165 obj.clear_and_retrieve();
1167 obj.error.standard_unexpected_error_alert('',E);
1175 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1179 'lib_filter_checkbox' : [
1182 var x_lib_type_menu = document.getElementById('lib_type_menu');
1183 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1184 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1185 obj.clear_and_retrieve();
1186 ev.target.setAttribute('checked',ev.target.checked);
1189 'cmd_view_expired_onshelf_holds' : [
1192 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1193 obj.expired = x.checked;
1194 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1195 obj.clear_and_retrieve();
1198 'cmd_clear_expired_onshelf_holds' : [
1202 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1203 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1204 if (robj == null) { robj = []; }
1205 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1206 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1208 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1209 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1210 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1211 var x_lib_type_menu = document.getElementById('lib_type_menu');
1212 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1213 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1214 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1215 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1216 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1218 // id's in xulG.holds will prevent the normal retrieval method from firing
1219 JSAN.use('util.functional');
1220 xulG.holds = util.functional.map_list(
1221 robj.sort(function(a,b) {
1222 if (a.action > b.action) { return 1; }
1223 if (a.action < b.action) { return -1; }
1226 function (element, idx) {
1227 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1228 return element.hold_id;
1231 obj.clear_and_retrieve();
1233 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1234 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1239 'cmd_search_opac' : [
1243 var content_params = {
1244 'show_nav_buttons' : false,
1245 'show_print_button' : true,
1246 'passthru_content_params' : {
1247 'authtoken' : ses(),
1248 'authtime' : ses('authtime'),
1249 'window_open' : function(a,b,c) {
1251 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1252 return window.open(a,b,c);
1254 obj.error.standard_unexpected_error_alert('window_open',E);
1257 'opac_hold_placed' : function(hold) {
1263 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1268 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1269 window.xulG.on_list_change();
1272 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1275 'patron_barcode' : obj.patron_barcode
1277 'url_prefix' : xulG.url_prefix,
1278 'url' : xulG.url_prefix( urls.browser )
1280 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1282 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1291 obj.determine_hold_interface_type();
1292 var x_fetch_more = document.getElementById('fetch_more');
1293 var x_lib_type_menu = document.getElementById('lib_type_menu');
1294 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1295 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1296 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1297 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1298 var x_expired_checkbox = document.getElementById('expired_checkbox');
1299 var x_print_full_pull_list = document.getElementById('print_full_btn');
1300 switch(obj.hold_interface_type) {
1302 obj.render_lib_menus({'pickup_lib':true});
1303 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1304 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1305 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1306 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1309 if (x_fetch_more) x_fetch_more.hidden = false;
1310 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1311 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1312 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1315 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1316 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1317 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1318 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1321 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1322 if (x_fetch_more) x_fetch_more.hidden = true;
1323 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1324 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1325 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1328 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
1330 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1331 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1332 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1334 obj.controller.render();
1337 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1338 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1339 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1340 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1341 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1342 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1343 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1344 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1345 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1346 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1347 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1348 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1349 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1353 $('cmd_alt_view').setAttribute('disabled','true');
1354 xulG.when_done = function() {
1355 $('cmd_alt_view').setAttribute('ready','true');
1356 if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1357 $('cmd_alt_view').setAttribute('disabled','false');
1359 dump('hold details UI ready\n');
1361 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1362 JSAN.use('util.browser');
1363 obj.browser = new util.browser();
1366 'url' : urls.XUL_HOLD_DETAILS,
1368 'alt_print' : false,
1369 'browser_id' : 'hold_detail_frame',
1370 'passthru_content_params' : xulG
1376 'determine_hold_interface_type' : function() {
1378 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1379 obj.hold_interface_type = 'patron';
1380 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1381 obj.hold_interface_type = 'record';
1382 } else if (obj.pull) { /*************************************************** PULL ******************************/
1383 obj.hold_interface_type = 'pull';
1384 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1385 obj.hold_interface_type = 'shelf';
1386 } else { /*************************************************** PULL ******************************/
1387 obj.hold_interface_type = 'pull';
1391 'clear_and_retrieve' : function() {
1394 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1396 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1397 window.xulG.on_list_change();
1400 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1404 'retrieve' : function() {
1405 var obj = this; var holds = [];
1406 if (window.xulG && window.xulG.holds) {
1407 holds = window.xulG.holds;
1409 var method; var params = [ ses() ];
1410 switch(obj.hold_interface_type) {
1412 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1413 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1415 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1417 params.push( obj.patron_id );
1418 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1421 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1422 params.push( obj.docid );
1423 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1424 var x_lib_type_menu = document.getElementById('lib_type_menu');
1426 if (x_lib_filter.checked) {
1427 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1429 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1434 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1438 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1440 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1442 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1443 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1447 method = 'FM_AHR_ID_LIST_PULL_LIST';
1448 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1449 var x = document.getElementById('hold_count');
1451 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1452 var count = req.getResultObject();
1453 if (typeof count.ilsevent == 'undefined' && count != null) {
1454 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1455 'staff.patron.holds.total_count',
1464 var robj = obj.network.simple_request( method, params );
1465 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1466 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1469 holds = holds.concat( robj.copy_holds );
1470 holds = holds.concat( robj.volume_holds );
1471 holds = holds.concat( robj.title_holds );
1472 holds = holds.concat( robj.metarecord_holds );
1473 holds = holds.sort();
1476 if (robj == null ) {
1479 if (typeof robj.length == 'undefined') {
1487 //alert('method = ' + method + ' params = ' + js2JSON(params));
1490 var x_fetch_more = document.getElementById('fetch_more');
1491 if (holds.length == 0) {
1492 if (x_fetch_more) x_fetch_more.disabled = true;
1494 if (x_fetch_more) x_fetch_more.disabled = false;
1500 'render' : function(holds) {
1504 function list_append(hold_id) {
1509 'hold_id' : hold_id,
1510 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1517 function gen_list_append(hold) {
1519 if (typeof obj.controller.view.lib_menu == 'undefined') {
1520 list_append(typeof hold == 'object' ? hold.id() : hold);
1522 list_append(typeof hold == 'object' ? hold.id() : hold);
1529 JSAN.use('util.exec'); var exec = new util.exec(2);
1531 for (var i in holds) {
1532 rows.push( gen_list_append(holds[i]) );
1537 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1541 'render_lib_menus' : function(types) {
1544 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1546 var x = document.getElementById('lib_type_menu');
1548 var nodes = x.firstChild.childNodes;
1549 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1550 for (var i in types) document.getElementById(i).hidden = false;
1552 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1554 x = document.getElementById('lib_menu_placeholder');
1555 util.widgets.remove_children( x );
1557 JSAN.use('util.file');
1558 var file = new util.file('offline_ou_list');
1559 if (file._file.exists()) {
1560 var list_data = file.get_object(); file.close();
1561 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1562 ml.setAttribute('id','lib_menu');
1563 x.appendChild( ml );
1564 ml.addEventListener(
1567 obj.filter_lib = ev.target.value;
1568 obj.clear_and_retrieve();
1572 obj.controller.view.lib_menu = ml;
1574 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1578 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1583 dump('exiting patron.holds.js\n');