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