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');
69 'columns' : columns.concat(
70 obj.list.fm_columns('acp', {
71 '*' : { 'expanded_label' : true, 'hidden' : true },
72 // example of unhiding some columns by default
73 // 'acp_circ_modifier' : { 'hidden' : false }
76 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
77 'retrieve_row' : function(params) {
80 obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
83 var blob = blob_req.getResultObject();
84 if (typeof blob.ilsevent != 'undefined') throw(blob);
85 row.my.ahr = blob.hold;
86 row.my.status = blob.status;
87 row.my.ahr.status( blob.status );
88 row.my.acp = blob.copy;
89 row.my.acn = blob.volume;
90 row.my.mvr = blob.mvr;
91 row.my.part = blob.part;
92 row.my.patron_family_name = blob.patron_last;
93 row.my.patron_first_given_name = blob.patron_first;
94 row.my.patron_barcode = blob.patron_barcode;
95 row.my.patron_alias = blob.patron_alias;
96 row.my.total_holds = blob.total_holds;
97 row.my.queue_position = blob.queue_position;
98 row.my.potential_copies = blob.potential_copies;
99 row.my.estimated_wait = blob.estimated_wait;
100 row.my.ahrn_count = blob.hold.notes().length;
102 var copy_id = row.my.ahr.current_copy();
103 if (typeof copy_id == 'object') {
104 if (copy_id == null) {
105 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
107 copy_id = copy_id.id();
110 copy_id = row.my.acp.id();
113 obj.holds_map[ row.my.ahr.id() ] = blob;
114 params.row_node.setAttribute('retrieve_id',
117 'barcode':row.my.acp ? row.my.acp.barcode() : null,
118 'id':row.my.ahr.id(),
119 'type':row.my.ahr.hold_type(),
120 'target':row.my.ahr.target(),
121 'usr':row.my.ahr.usr()
124 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
127 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
132 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
136 'on_select' : function(ev) {
137 JSAN.use('util.functional');
138 var sel = obj.list.retrieve_selection();
139 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
140 obj.retrieve_ids = util.functional.map_list(
142 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
144 if (obj.retrieve_ids.length > 0) {
145 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
146 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
147 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
148 obj.controller.view.sel_patron.setAttribute('disabled','false');
149 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
150 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
151 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
152 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
153 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
154 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
155 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
156 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
157 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
158 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
159 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
160 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
161 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','false');
162 if (obj.controller.view.cmd_alt_view.getAttribute('ready')=='true') {
163 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
165 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
166 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
167 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
168 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
170 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
171 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
172 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
173 obj.controller.view.sel_patron.setAttribute('disabled','true');
174 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
175 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
176 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
177 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
178 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
179 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
180 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
181 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
182 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
183 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
184 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
185 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
186 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
187 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','true');
188 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
189 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
190 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
191 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
197 JSAN.use('util.controller'); obj.controller = new util.controller();
201 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
204 function() { obj.list.clipboard(); }
208 function() { alert($("commonStrings").getString('common.unimplemented')); }
213 JSAN.use('circ.util');
214 circ.util.show_last_few_circs(obj.retrieve_ids);
220 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
221 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
228 var n = obj.controller.view.alt_view_btn;
229 if (n.getAttribute('toggle') == '1') {
230 document.getElementById('deck').selectedIndex = 0;
231 n.setAttribute('toggle','0');
232 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
233 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
235 document.getElementById('deck').selectedIndex = 1;
236 n.setAttribute('toggle','1');
237 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
238 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
239 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
240 if (obj.retrieve_ids.length == 0) return;
241 var f = obj.browser.get_content();
242 xulG.ahr_id = obj.retrieve_ids[0].id;
243 xulG.blob = obj.holds_map[ xulG.ahr_id ];
244 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
245 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
247 f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
248 f.fetch_and_render_all(true);
251 alert('Error in holds.js, cmd_alt_view handler: ' + E);
255 'cmd_cancelled_holds_view' : [
258 document.getElementById('show_cancelled_deck').selectedIndex = 1;
259 /* For some reason attribute propogation on the <command> element isn't working with hidden */
260 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
261 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
262 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
263 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
264 obj.clear_and_retrieve();
267 'cmd_uncancelled_holds_view' : [
270 document.getElementById('show_cancelled_deck').selectedIndex = 0;
271 /* For some reason attribute propogation on the <command> element isn't working with hidden */
272 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
273 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
274 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
275 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
276 obj.clear_and_retrieve();
279 'sel_mark_items_damaged' : [
282 JSAN.use('cat.util'); JSAN.use('util.functional');
283 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
286 'sel_mark_items_missing' : [
289 JSAN.use('cat.util'); JSAN.use('util.functional');
290 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
293 'sel_copy_details' : [
296 JSAN.use('circ.util');
297 circ.util.item_details_new(
298 util.functional.map_list(
300 function(o) { return o.barcode; }
305 'cmd_holds_print_full' : [
308 var x_print_full_pull_list = document.getElementById('print_full_btn');
311 progressmeter.mode = 'undetermined';
312 progressmeter.hidden = false;
313 x_print_full_pull_list.disabled = true;
315 JSAN.use('util.print');
316 var print = new util.print('default');
317 var robj = fieldmapper.standardRequest(
318 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
325 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
326 print.simple( robj.template_output().data() );
329 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
332 progressmeter.mode = 'determined';
333 progressmeter.hidden = true;
334 x_print_full_pull_list.disabled = false;
338 'cmd_holds_print_alt' : [
342 var content_params = {
344 "authtime": ses("authtime"),
346 "show_nav_buttons": true,
347 "show_print_button": true
349 ["url_prefix", "new_tab", "set_tab",
350 "close_tab", "new_patron_tab",
351 "set_patron_tab", "volume_item_creator",
353 "holdings_maintenance_tab", "set_tab_name",
354 "open_chrome_window", "url_prefix",
355 "network_meter", "page_meter",
356 "set_statusbar", "set_help_context"
357 ].forEach(function(k) {
358 content_params[k] = xulG[k];
361 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
362 xulG.url_prefix("/opac/extras/circ/alt_holds_print.html").replace("http:","https:")
366 "tab_name": "Printable Pull List", /* XXX i18n */
371 g.error.sdump("D_ERROR", E);
375 'cmd_holds_print' : [
379 JSAN.use('patron.util');
381 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
384 obj.list.print(params);
386 obj.error.standard_unexpected_error_alert('print 1',E);
390 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
391 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
392 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
394 'cmd_holds_edit_selection_depth' : [
398 JSAN.use('util.widgets'); JSAN.use('util.functional');
399 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
400 var list = util.functional.map_list(
401 util.functional.filter_list(
404 if (o.depth() > ws_type.depth()) return false;
405 if (o.depth() < ws_type.depth()) return true;
406 return (o.id() == ws_type.id());
418 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
419 ml.setAttribute('id','selection');
420 ml.setAttribute('name','fancy_data');
421 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
422 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
423 xml += util.widgets.serialize_node(ml);
425 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
426 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
427 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
428 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
429 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
430 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
431 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
432 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
433 JSAN.use('util.window'); var win = new util.window();
434 var fancy_prompt_data = win.open(
435 urls.XUL_FANCY_PROMPT,
436 //+ '?xml_in_stash=temp_mid'
437 //+ '&bottom_xml_in_stash=temp_bot'
438 //+ '&title=' + window.escape('Choose a Pick Up Library'),
439 'fancy_prompt', 'chrome,resizable,modal',
440 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
442 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
443 var selection = fancy_prompt_data.selection;
445 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
447 if(obj.retrieve_ids.length > 1) {
448 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
450 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
453 var r = obj.error.yns_alert(msg,
454 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
455 $("commonStrings").getString('common.yes'),
456 $("commonStrings").getString('common.no'),
458 $("commonStrings").getString('common.check_to_confirm')
461 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
464 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
469 'cmd_holds_edit_pickup_lib' : [
473 JSAN.use('util.widgets'); JSAN.use('util.functional');
475 var list = util.functional.map_list(
478 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
480 o.name() ? sname + ' ' + o.name() : o.shortname(),
482 ( !isTrue(obj.data.hash.aout[ o.ou_type() ].can_have_users()) ),
483 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
487 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
488 ml.setAttribute('id','lib');
489 ml.setAttribute('name','fancy_data');
490 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
491 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
492 xml += util.widgets.serialize_node(ml);
494 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
495 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
496 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
497 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
498 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
499 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
500 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
501 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
502 JSAN.use('util.window'); var win = new util.window();
503 var fancy_prompt_data = win.open(
504 urls.XUL_FANCY_PROMPT,
505 //+ '?xml_in_stash=temp_mid'
506 //+ '&bottom_xml_in_stash=temp_bot'
507 //+ '&title=' + window.escape('Choose a Pick Up Library'),
508 'fancy_prompt', 'chrome,resizable,modal',
509 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
511 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
512 var pickup_lib = fancy_prompt_data.lib;
514 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
516 if(obj.retrieve_ids.length > 1) {
517 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()]);
519 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()]);
521 var r = obj.error.yns_alert(msg,
522 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
523 $("commonStrings").getString('common.yes'),
524 $("commonStrings").getString('common.no'),
526 $("commonStrings").getString('common.check_to_confirm')
529 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
532 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
536 'cmd_holds_edit_phone_notify' : [
540 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
541 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
542 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
544 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
545 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
546 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
547 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
548 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
549 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
550 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
551 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
552 JSAN.use('util.window'); var win = new util.window();
553 var fancy_prompt_data = win.open(
554 urls.XUL_FANCY_PROMPT,
555 //+ '?xml_in_stash=temp_mid'
556 //+ '&bottom_xml_in_stash=temp_bot'
557 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
559 'fancy_prompt', 'chrome,resizable,modal',
560 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
562 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
563 var phone = fancy_prompt_data.phone;
565 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
567 if(obj.retrieve_ids.length > 1) {
568 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
570 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
572 var r = obj.error.yns_alert(msg,
573 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
574 $("commonStrings").getString('common.yes'),
575 $("commonStrings").getString('common.no'),
577 $("commonStrings").getString('common.check_to_confirm')
580 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
583 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
587 'cmd_holds_edit_email_notify' : [
591 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
592 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
593 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
594 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
595 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
596 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
598 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
599 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
600 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
601 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
602 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
603 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
604 JSAN.use('util.window'); var win = new util.window();
605 var fancy_prompt_data = win.open(
606 urls.XUL_FANCY_PROMPT,
607 //+ '?xml_in_stash=temp_mid'
608 //+ '&bottom_xml_in_stash=temp_bot'
609 //+ '&title=' + window.escape('Set Email Notification for Holds'),
610 'fancy_prompt', 'chrome,resizable,modal',
611 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
613 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
614 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
616 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
618 if(get_bool(email)) {
619 if(obj.retrieve_ids.length > 1) {
620 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
622 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
625 if(obj.retrieve_ids.length > 1) {
626 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
628 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
632 var r = obj.error.yns_alert(msg,
633 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
634 $("commonStrings").getString('common.yes'),
635 $("commonStrings").getString('common.no'),
637 $("commonStrings").getString('common.check_to_confirm')
640 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
643 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
647 'cmd_holds_cut_in_line' : [
651 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
652 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
653 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
654 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
655 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
656 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
658 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
659 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
660 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
661 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
662 JSAN.use('util.window'); var win = new util.window();
663 var fancy_prompt_data = win.open(
664 urls.XUL_FANCY_PROMPT,
665 'fancy_prompt', 'chrome,resizable,modal',
666 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
668 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
669 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
671 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
674 if(obj.retrieve_ids.length > 1) {
675 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
677 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
680 if(obj.retrieve_ids.length > 1) {
681 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
683 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
687 var r = obj.error.yns_alert(msg,
688 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
689 $("commonStrings").getString('common.yes'),
690 $("commonStrings").getString('common.no'),
692 $("commonStrings").getString('common.check_to_confirm')
695 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
698 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
702 'cmd_holds_edit_desire_mint_condition' : [
706 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
707 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
708 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
709 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
710 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
711 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
713 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
714 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
715 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
716 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
717 JSAN.use('util.window'); var win = new util.window();
718 var fancy_prompt_data = win.open(
719 urls.XUL_FANCY_PROMPT,
720 'fancy_prompt', 'chrome,resizable,modal',
721 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
723 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
724 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
726 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
729 if(obj.retrieve_ids.length > 1) {
730 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
732 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
735 if(obj.retrieve_ids.length > 1) {
736 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
738 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
742 var r = obj.error.yns_alert(msg,
743 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
744 $("commonStrings").getString('common.yes'),
745 $("commonStrings").getString('common.no'),
747 $("commonStrings").getString('common.check_to_confirm')
750 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
753 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
759 'cmd_holds_suspend' : [
763 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
764 var r = obj.error.yns_alert(
765 obj.retrieve_ids.length > 1 ?
766 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
767 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
768 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
769 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
770 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
772 document.getElementById('commonStrings').getString('common.confirm')
775 var already_suspended = []; var filtered_hold_list = [];
776 for (var i = 0; i < obj.retrieve_ids.length; i++) {
777 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
778 if ( get_bool( hold.frozen() ) ) {
779 already_suspended.push( hold.id() );
782 filtered_hold_list.push( hold.id() );
784 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
785 if (already_suspended.length == 1) {
786 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
787 } else if (already_suspended.length > 1) {
788 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
790 obj.clear_and_retrieve(true);
794 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
798 'cmd_holds_activate' : [
802 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
803 var r = obj.error.yns_alert(
804 obj.retrieve_ids.length > 1 ?
805 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
806 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
807 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
808 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
809 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
811 document.getElementById('commonStrings').getString('common.confirm')
814 var already_activated = []; var filtered_hold_list = [];
815 for (var i = 0; i < obj.retrieve_ids.length; i++) {
816 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
817 if ( ! get_bool( hold.frozen() ) ) {
818 already_activated.push( hold.id() );
821 filtered_hold_list.push( hold.id() );
823 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
824 if (already_activated.length == 1) {
825 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
826 } else if (already_activated.length > 1) {
827 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
829 obj.clear_and_retrieve(true);
833 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
837 'cmd_holds_edit_thaw_date' : [
841 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
842 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
843 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
844 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
845 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
846 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
848 JSAN.use('util.window'); var win = new util.window();
849 var my_xulG = win.open(
850 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
853 'description' : desc,
855 'allow_unset' : true,
856 'disallow_future_dates' : false,
857 'disallow_past_dates' : true,
858 'disallow_today' : true,
859 'default_time' : '00:00:00',
860 'time_readonly' : false
863 if (my_xulG.complete) {
864 circ.util.batch_hold_update(
866 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
867 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
871 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
875 'cmd_holds_edit_expire_time' : [
879 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
880 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
881 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
882 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
883 var value = 'YYYY-MM-DD';
884 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
885 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
887 JSAN.use('util.window'); var win = new util.window();
888 var my_xulG = win.open(
889 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
892 'description' : desc,
894 'allow_unset' : true,
895 'disallow_future_dates' : false,
896 'disallow_past_dates' : true,
897 'disallow_today' : true,
898 'default_time' : '00:00:00',
899 'time_readonly' : false
902 if (my_xulG.complete) {
903 circ.util.batch_hold_update(
905 { 'expire_time' : my_xulG.timestamp },
906 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
910 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
914 'cmd_holds_edit_shelf_expire_time' : [
918 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
919 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
920 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
921 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
922 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
923 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
925 JSAN.use('util.window'); var win = new util.window();
926 var my_xulG = win.open(
927 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
930 'description' : desc,
932 'allow_unset' : false,
933 'disallow_future_dates' : false,
934 'disallow_past_dates' : false,
935 'disallow_today' : false
938 if (my_xulG.complete) {
939 circ.util.batch_hold_update(
941 { 'shelf_expire_time' : my_xulG.timestamp },
942 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
946 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
950 'cmd_holds_edit_request_date' : [
954 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
955 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
956 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
957 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
958 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
959 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
961 JSAN.use('util.window'); var win = new util.window();
962 var my_xulG = win.open(
963 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
966 'description' : desc,
968 'allow_unset' : false,
969 'disallow_future_dates' : true,
970 'disallow_past_dates' : false,
971 'disallow_today' : false
974 if (my_xulG.complete) {
975 circ.util.batch_hold_update(
977 { 'request_time' : my_xulG.timestamp },
978 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
982 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
986 'cmd_holds_retarget' : [
990 JSAN.use('util.functional');
992 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
994 if(obj.retrieve_ids.length > 1) {
995 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
997 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
999 var r = obj.error.yns_alert(msg,
1000 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
1001 $("commonStrings").getString('common.yes'),
1002 $("commonStrings").getString('common.no'),
1004 $("commonStrings").getString('common.check_to_confirm')
1007 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1008 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
1009 if (typeof robj.ilsevent != 'undefined') throw(robj);
1011 obj.clear_and_retrieve();
1014 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
1020 'cmd_holds_cancel' : [
1024 JSAN.use('util.functional');
1026 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1028 if(obj.retrieve_ids.length > 1 ) {
1029 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
1031 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
1034 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1035 JSAN.use('util.window');
1036 var win = new util.window();
1037 var my_xulG = win.open(
1038 urls.XUL_HOLD_CANCEL,
1040 'chrome,resizable,modal',
1043 /*var r = obj.error.yns_alert(msg,
1044 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1045 $("commonStrings").getString('common.yes'),
1046 $("commonStrings").getString('common.no'),
1048 $("commonStrings").getString('common.check_to_confirm')
1051 if (my_xulG.proceed) {
1053 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1054 var transit = obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit();
1055 if (transit && ! transit.dest_recv_time() ) {
1056 transits.push( obj.retrieve_ids[i].barcode );
1058 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1059 if (typeof robj.ilsevent != 'undefined') throw(robj);
1061 if (transits.length > 0) {
1062 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1063 var r2 = obj.error.yns_alert(msg2,
1064 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1065 $("commonStrings").getString('common.yes'),
1066 $("commonStrings").getString('common.no'),
1068 $("commonStrings").getString('common.check_to_confirm'));
1071 for (var i = 0; i < transits.length; i++) {
1072 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1073 if (typeof robj.ilsevent != 'undefined') {
1074 switch(Number(robj.ilsevent)) {
1075 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1078 case 5000 /* PERM_FAILURE */ :
1087 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1091 obj.clear_and_retrieve();
1094 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1098 'cmd_holds_uncancel' : [
1102 JSAN.use('util.functional');
1103 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1104 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1105 if (typeof robj.ilsevent != 'undefined') throw(robj);
1107 obj.clear_and_retrieve();
1109 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1114 'cmd_retrieve_patron' : [
1119 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1120 var patron_id = obj.retrieve_ids[i].usr;
1121 if (seen[patron_id]) continue; seen[patron_id] = true;
1122 xulG.new_patron_tab(
1124 { 'id' : patron_id }
1128 obj.error.standard_unexpected_error_alert('',E);
1132 'cmd_show_catalog' : [
1136 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1137 var htarget = obj.retrieve_ids[i].target;
1138 var htype = obj.retrieve_ids[i].type;
1142 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1146 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1149 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1150 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1153 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1155 if (typeof my_acp.call_number() == 'object') {
1156 my_acn = my.acp.call_number();
1158 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1159 [ my_acp.call_number() ]);
1161 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1164 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1168 var content_params = {
1170 'authtime' : ses('authtime'),
1171 'opac_url' : opac_url
1174 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1175 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1180 obj.error.standard_unexpected_error_alert('',E);
1184 'cmd_holds_title_transfer' : [
1189 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1190 var htarget = obj.retrieve_ids[i].target;
1191 var htype = obj.retrieve_ids[i].type;
1194 continue; // not supported
1197 targets.push( htarget );
1200 continue; // not supported
1203 continue; // not supported
1206 continue; // not supported
1210 JSAN.use('cat.util');
1211 cat.util.transfer_title_holds(targets);
1212 obj.clear_and_retrieve();
1214 obj.error.standard_unexpected_error_alert('',E);
1222 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1226 'lib_filter_checkbox' : [
1229 var x_lib_type_menu = document.getElementById('lib_type_menu');
1230 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1231 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1232 obj.clear_and_retrieve();
1233 ev.target.setAttribute('checked',ev.target.checked);
1236 'cmd_view_expired_onshelf_holds' : [
1239 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1240 obj.expired = x.checked;
1241 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1242 obj.clear_and_retrieve();
1245 'cmd_clear_expired_onshelf_holds' : [
1249 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1250 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1251 if (robj == null) { robj = []; }
1252 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1253 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1255 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1256 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1257 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1258 var x_lib_type_menu = document.getElementById('lib_type_menu');
1259 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1260 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1261 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1262 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1263 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1265 // id's in xulG.holds will prevent the normal retrieval method from firing
1266 JSAN.use('util.functional');
1267 xulG.holds = util.functional.map_list(
1268 robj.sort(function(a,b) {
1269 if (a.action > b.action) { return 1; }
1270 if (a.action < b.action) { return -1; }
1273 function (element, idx) {
1274 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1275 return element.hold_id;
1278 obj.clear_and_retrieve();
1280 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1281 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1286 'cmd_search_opac' : [
1290 var content_params = {
1291 'show_nav_buttons' : false,
1292 'show_print_button' : true,
1293 'passthru_content_params' : {
1294 'authtoken' : ses(),
1295 'authtime' : ses('authtime'),
1296 'window_open' : function(a,b,c) {
1298 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1299 return window.open(a,b,c);
1301 obj.error.standard_unexpected_error_alert('window_open',E);
1304 'opac_hold_placed' : function(hold) {
1310 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1315 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1316 window.xulG.on_list_change();
1319 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1322 'patron_barcode' : obj.patron_barcode
1324 'url_prefix' : xulG.url_prefix,
1325 'url' : xulG.url_prefix( urls.browser )
1327 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1329 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1338 obj.determine_hold_interface_type();
1339 var x_fetch_more = document.getElementById('fetch_more');
1340 var x_lib_type_menu = document.getElementById('lib_type_menu');
1341 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1342 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1343 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1344 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1345 var x_expired_checkbox = document.getElementById('expired_checkbox');
1346 var x_print_full_pull_list = document.getElementById('print_full_btn');
1347 var x_print_full_pull_list_alt = document.getElementById('print_alt_btn');
1348 switch(obj.hold_interface_type) {
1350 obj.render_lib_menus({'pickup_lib':true});
1351 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1352 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1353 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1354 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1355 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1358 if (x_fetch_more) x_fetch_more.hidden = false;
1359 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1360 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = false;
1361 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1362 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1365 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1366 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1367 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1368 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1369 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1372 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1373 if (x_fetch_more) x_fetch_more.hidden = true;
1374 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1375 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1376 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1377 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1380 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
1382 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1383 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1384 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1386 obj.controller.render();
1389 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1390 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1391 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1392 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1393 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1394 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1395 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1396 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1397 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1398 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1399 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1400 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1401 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1405 $('cmd_alt_view').setAttribute('disabled','true');
1406 xulG.when_done = function() {
1407 $('cmd_alt_view').setAttribute('ready','true');
1408 if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1409 $('cmd_alt_view').setAttribute('disabled','false');
1411 dump('hold details UI ready\n');
1413 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1414 JSAN.use('util.browser');
1415 obj.browser = new util.browser();
1418 'url' : urls.XUL_HOLD_DETAILS,
1420 'alt_print' : false,
1421 'browser_id' : 'hold_detail_frame',
1422 'passthru_content_params' : xulG
1428 'determine_hold_interface_type' : function() {
1430 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1431 obj.hold_interface_type = 'patron';
1432 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1433 obj.hold_interface_type = 'record';
1434 } else if (obj.pull) { /*************************************************** PULL ******************************/
1435 obj.hold_interface_type = 'pull';
1436 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1437 obj.hold_interface_type = 'shelf';
1438 } else { /*************************************************** PULL ******************************/
1439 obj.hold_interface_type = 'pull';
1443 'clear_and_retrieve' : function() {
1446 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1448 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1449 window.xulG.on_list_change();
1452 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1456 'retrieve' : function() {
1457 var obj = this; var holds = [];
1458 if (window.xulG && window.xulG.holds) {
1459 holds = window.xulG.holds;
1461 var method; var params = [ ses() ];
1462 switch(obj.hold_interface_type) {
1464 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1465 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1467 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1469 params.push( obj.patron_id );
1470 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1473 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1474 params.push( obj.docid );
1475 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1476 var x_lib_type_menu = document.getElementById('lib_type_menu');
1478 if (x_lib_filter.checked) {
1479 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1481 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1486 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1490 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1492 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1494 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1495 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1499 method = 'FM_AHR_ID_LIST_PULL_LIST';
1500 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1501 var x = document.getElementById('hold_count');
1503 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1504 var count = req.getResultObject();
1505 if (typeof count.ilsevent == 'undefined' && count != null) {
1506 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1507 'staff.patron.holds.total_count',
1516 var robj = obj.network.simple_request( method, params );
1517 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1518 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1521 holds = holds.concat( robj.copy_holds );
1522 holds = holds.concat( robj.volume_holds );
1523 holds = holds.concat( robj.title_holds );
1524 holds = holds.concat( robj.metarecord_holds );
1525 holds = holds.sort();
1528 if (robj == null ) {
1531 if (typeof robj.length == 'undefined') {
1539 //alert('method = ' + method + ' params = ' + js2JSON(params));
1542 var x_fetch_more = document.getElementById('fetch_more');
1543 if (holds.length == 0) {
1544 if (x_fetch_more) x_fetch_more.disabled = true;
1546 if (x_fetch_more) x_fetch_more.disabled = false;
1552 'render' : function(holds) {
1556 function list_append(hold_id) {
1561 'hold_id' : hold_id,
1562 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1570 function gen_list_append(hold) {
1572 if (typeof obj.controller.view.lib_menu == 'undefined') {
1573 list_append(typeof hold == 'object' ? hold.id() : hold);
1575 list_append(typeof hold == 'object' ? hold.id() : hold);
1582 JSAN.use('util.exec'); var exec = new util.exec(2);
1584 for (var i in holds) {
1585 rows.push( gen_list_append(holds[i]) );
1590 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1594 'render_lib_menus' : function(types) {
1597 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1599 var x = document.getElementById('lib_type_menu');
1601 var nodes = x.firstChild.childNodes;
1602 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1603 for (var i in types) document.getElementById(i).hidden = false;
1605 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1607 x = document.getElementById('lib_menu_placeholder');
1608 util.widgets.remove_children( x );
1610 JSAN.use('util.file');
1611 var file = new util.file('offline_ou_list');
1612 if (file._file.exists()) {
1613 var list_data = file.get_object(); file.close();
1614 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1615 ml.setAttribute('id','lib_menu');
1616 x.appendChild( ml );
1617 ml.addEventListener(
1620 obj.filter_lib = ev.target.value;
1621 obj.clear_and_retrieve();
1625 obj.controller.view.lib_menu = ml;
1627 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1631 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1636 dump('exiting patron.holds.js\n');