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 }
24 'hold_subscription_map' : {},
27 'post_clear_shelf_hold_action_map' : {},
33 'flatten_copy' : function(hold) {
34 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); }
38 'init' : function( params ) {
42 obj.patron_id = params['patron_id'];
43 obj.patron_barcode = params['patron_barcode'];
44 obj.docid = params['docid'];
45 obj.shelf = params['shelf'];
46 obj.tree_id = params['tree_id'];
48 var progressmeter = document.getElementById('progress');
50 JSAN.use('circ.util');
51 var columns = circ.util.hold_columns(
53 'title' : { 'hidden' : false, 'flex' : '3' },
54 'request_time' : { 'hidden' : false },
55 'pickup_lib_shortname' : { 'hidden' : false },
56 'hold_type' : { 'hidden' : false },
57 'current_copy' : { 'hidden' : false },
58 'capture_time' : { 'hidden' : false },
59 'notify_time' : { 'hidden' : false },
60 'notify_count' : { 'hidden' : false },
61 'cancel_cause' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
62 'cancel_note' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
63 'cancel_time' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
64 'post_clear_shelf_action' : { 'hidden' : obj.shelf ? false : true }
68 JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
71 'columns' : columns.concat(
72 obj.list.fm_columns('acp', {
73 '*' : { 'expanded_label' : true, 'hidden' : true },
74 // example of unhiding some columns by default
75 // 'acp_circ_modifier' : { 'hidden' : false }
78 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
79 'retrieve_row' : function(params) {
82 obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
85 var blob = blob_req.getResultObject();
86 if (typeof blob.ilsevent != 'undefined') throw(blob);
87 row.my.ahr = blob.hold;
88 row.my.status = blob.status;
89 row.my.ahr.status( blob.status );
90 row.my.acp = blob.copy;
91 row.my.acn = blob.volume;
92 row.my.mvr = blob.mvr;
93 row.my.part = blob.part;
94 row.my.issuance = blob.issuance;
96 row.my.subscription = blob.issuance.subscription();
97 obj.hold_subscription_map[ row.my.hold_id ] = row.my.subscription;
99 row.my.patron_family_name = blob.patron_last;
100 row.my.patron_first_given_name = blob.patron_first;
101 row.my.patron_barcode = blob.patron_barcode;
102 row.my.patron_alias = blob.patron_alias;
103 row.my.total_holds = blob.total_holds;
104 row.my.queue_position = blob.queue_position;
105 row.my.potential_copies = blob.potential_copies;
106 row.my.estimated_wait = blob.estimated_wait;
107 row.my.ahrn_count = blob.hold.notes().length;
109 var copy_id = row.my.ahr.current_copy();
110 if (typeof copy_id == 'object') {
111 if (copy_id == null) {
112 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
114 copy_id = copy_id.id();
117 copy_id = row.my.acp.id();
120 obj.holds_map[ row.my.ahr.id() ] = blob;
121 params.row_node.setAttribute('retrieve_id',
124 'barcode':row.my.acp ? row.my.acp.barcode() : null,
125 'id':row.my.ahr.id(),
126 'type':row.my.ahr.hold_type(),
127 'target':row.my.ahr.target(),
128 'usr':row.my.ahr.usr()
131 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
134 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
139 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
143 'on_select' : function(ev) {
144 JSAN.use('util.functional');
145 var sel = obj.list.retrieve_selection();
146 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
147 obj.retrieve_ids = util.functional.map_list(
149 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
151 if (obj.retrieve_ids.length > 0) {
152 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
153 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
154 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
155 obj.controller.view.sel_patron.setAttribute('disabled','false');
156 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
157 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
158 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
159 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
160 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
161 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
162 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
163 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
164 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
165 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
166 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
167 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
168 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','false');
169 if (obj.controller.view.cmd_alt_view.getAttribute('ready')=='true') {
170 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
172 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
173 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
174 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
175 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
177 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
178 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
179 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
180 obj.controller.view.sel_patron.setAttribute('disabled','true');
181 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
182 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
183 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
184 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
185 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
186 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
187 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
188 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
189 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
190 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
191 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
192 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
193 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
194 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','true');
195 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
196 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
197 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
198 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
204 JSAN.use('util.controller'); obj.controller = new util.controller();
208 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
211 function() { obj.list.clipboard(); }
215 function() { alert($("commonStrings").getString('common.unimplemented')); }
220 JSAN.use('circ.util');
221 circ.util.show_last_few_circs(obj.retrieve_ids);
227 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
228 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
235 var n = obj.controller.view.alt_view_btn;
236 if (n.getAttribute('toggle') == '1') {
237 document.getElementById('deck').selectedIndex = 0;
238 n.setAttribute('toggle','0');
239 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
240 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
242 document.getElementById('deck').selectedIndex = 1;
243 n.setAttribute('toggle','1');
244 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
245 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
246 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
247 if (obj.retrieve_ids.length == 0) return;
248 var f = obj.browser.get_content();
249 xulG.ahr_id = obj.retrieve_ids[0].id;
250 xulG.blob = obj.holds_map[ xulG.ahr_id ];
251 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
252 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
254 f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
255 f.fetch_and_render_all(true);
258 alert('Error in holds.js, cmd_alt_view handler: ' + E);
262 'cmd_cancelled_holds_view' : [
265 document.getElementById('show_cancelled_deck').selectedIndex = 1;
266 /* For some reason attribute propogation on the <command> element isn't working with hidden */
267 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
268 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
269 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
270 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
271 obj.clear_and_retrieve();
274 'cmd_uncancelled_holds_view' : [
277 document.getElementById('show_cancelled_deck').selectedIndex = 0;
278 /* For some reason attribute propogation on the <command> element isn't working with hidden */
279 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
280 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
281 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
282 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
283 obj.clear_and_retrieve();
286 'sel_mark_items_damaged' : [
289 JSAN.use('cat.util'); JSAN.use('util.functional');
290 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
293 'sel_mark_items_missing' : [
296 JSAN.use('cat.util'); JSAN.use('util.functional');
297 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
300 'sel_copy_details' : [
303 JSAN.use('circ.util');
304 circ.util.item_details_new(
305 util.functional.map_list(
307 function(o) { return o.barcode; }
312 'cmd_holds_print_full' : [
315 var x_print_full_pull_list = document.getElementById('print_full_btn');
318 progressmeter.mode = 'undetermined';
319 progressmeter.hidden = false;
320 x_print_full_pull_list.disabled = true;
322 JSAN.use('util.print');
323 var print = new util.print('default');
324 var robj = fieldmapper.standardRequest(
325 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
332 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
333 print.simple( robj.template_output().data() );
336 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
339 progressmeter.mode = 'determined';
340 progressmeter.hidden = true;
341 x_print_full_pull_list.disabled = false;
345 'cmd_holds_print_alt' : [
349 var content_params = {
351 "authtime": ses("authtime"),
353 "show_nav_buttons": true,
354 "show_print_button": true
356 ["url_prefix", "new_tab", "set_tab",
357 "close_tab", "new_patron_tab",
358 "set_patron_tab", "volume_item_creator",
360 "holdings_maintenance_tab", "set_tab_name",
361 "open_chrome_window", "url_prefix",
362 "network_meter", "page_meter",
363 "set_statusbar", "set_help_context"
364 ].forEach(function(k) {
365 content_params[k] = xulG[k];
368 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
369 xulG.url_prefix("/opac/extras/circ/alt_holds_print.html").replace("http:","https:")
373 "tab_name": "Printable Pull List", /* XXX i18n */
378 g.error.sdump("D_ERROR", E);
382 'cmd_holds_print' : [
386 JSAN.use('patron.util');
388 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
391 obj.list.print(params);
393 obj.error.standard_unexpected_error_alert('print 1',E);
397 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
398 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
399 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
401 'cmd_holds_edit_selection_depth' : [
405 JSAN.use('util.widgets'); JSAN.use('util.functional');
406 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
407 var list = util.functional.map_list(
408 util.functional.filter_list(
411 if (o.depth() > ws_type.depth()) return false;
412 if (o.depth() < ws_type.depth()) return true;
413 return (o.id() == ws_type.id());
425 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
426 ml.setAttribute('id','selection');
427 ml.setAttribute('name','fancy_data');
428 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
429 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
430 xml += util.widgets.serialize_node(ml);
432 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
433 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
434 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
435 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
436 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
437 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
438 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
439 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
440 JSAN.use('util.window'); var win = new util.window();
441 var fancy_prompt_data = win.open(
442 urls.XUL_FANCY_PROMPT,
443 //+ '?xml_in_stash=temp_mid'
444 //+ '&bottom_xml_in_stash=temp_bot'
445 //+ '&title=' + window.escape('Choose a Pick Up Library'),
446 'fancy_prompt', 'chrome,resizable,modal',
447 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
449 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
450 var selection = fancy_prompt_data.selection;
452 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
454 if(obj.retrieve_ids.length > 1) {
455 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
457 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
460 var r = obj.error.yns_alert(msg,
461 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
462 $("commonStrings").getString('common.yes'),
463 $("commonStrings").getString('common.no'),
465 $("commonStrings").getString('common.check_to_confirm')
468 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
471 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
476 'cmd_holds_edit_pickup_lib' : [
480 JSAN.use('util.widgets'); JSAN.use('util.functional');
482 var list = util.functional.map_list(
485 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
487 o.name() ? sname + ' ' + o.name() : o.shortname(),
489 ( !isTrue(obj.data.hash.aout[ o.ou_type() ].can_have_users()) ),
490 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
494 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
495 ml.setAttribute('id','lib');
496 ml.setAttribute('name','fancy_data');
497 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
498 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
499 xml += util.widgets.serialize_node(ml);
501 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
502 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
503 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
504 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
505 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
506 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
507 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
508 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
509 JSAN.use('util.window'); var win = new util.window();
510 var fancy_prompt_data = win.open(
511 urls.XUL_FANCY_PROMPT,
512 //+ '?xml_in_stash=temp_mid'
513 //+ '&bottom_xml_in_stash=temp_bot'
514 //+ '&title=' + window.escape('Choose a Pick Up Library'),
515 'fancy_prompt', 'chrome,resizable,modal',
516 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
518 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
519 var pickup_lib = fancy_prompt_data.lib;
521 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
523 if(obj.retrieve_ids.length > 1) {
524 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()]);
526 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()]);
528 var r = obj.error.yns_alert(msg,
529 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
530 $("commonStrings").getString('common.yes'),
531 $("commonStrings").getString('common.no'),
533 $("commonStrings").getString('common.check_to_confirm')
536 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
539 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
543 'cmd_holds_edit_phone_notify' : [
547 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
548 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
549 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
551 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
552 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
553 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
554 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
555 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
556 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
557 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
558 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
559 JSAN.use('util.window'); var win = new util.window();
560 var fancy_prompt_data = win.open(
561 urls.XUL_FANCY_PROMPT,
562 //+ '?xml_in_stash=temp_mid'
563 //+ '&bottom_xml_in_stash=temp_bot'
564 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
566 'fancy_prompt', 'chrome,resizable,modal',
567 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
569 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
570 var phone = fancy_prompt_data.phone;
572 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
574 if(obj.retrieve_ids.length > 1) {
575 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
577 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
579 var r = obj.error.yns_alert(msg,
580 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
581 $("commonStrings").getString('common.yes'),
582 $("commonStrings").getString('common.no'),
584 $("commonStrings").getString('common.check_to_confirm')
587 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
590 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
594 'cmd_holds_edit_email_notify' : [
598 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
599 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
600 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
601 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
602 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
603 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
605 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
606 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
607 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
608 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
609 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
610 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
611 JSAN.use('util.window'); var win = new util.window();
612 var fancy_prompt_data = win.open(
613 urls.XUL_FANCY_PROMPT,
614 //+ '?xml_in_stash=temp_mid'
615 //+ '&bottom_xml_in_stash=temp_bot'
616 //+ '&title=' + window.escape('Set Email Notification for Holds'),
617 'fancy_prompt', 'chrome,resizable,modal',
618 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
620 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
621 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
623 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
625 if(get_bool(email)) {
626 if(obj.retrieve_ids.length > 1) {
627 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
629 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
632 if(obj.retrieve_ids.length > 1) {
633 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
635 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
639 var r = obj.error.yns_alert(msg,
640 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
641 $("commonStrings").getString('common.yes'),
642 $("commonStrings").getString('common.no'),
644 $("commonStrings").getString('common.check_to_confirm')
647 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
650 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
654 'cmd_holds_cut_in_line' : [
658 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
659 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
660 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
661 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
662 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
663 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
665 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
666 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
667 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
668 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
669 JSAN.use('util.window'); var win = new util.window();
670 var fancy_prompt_data = win.open(
671 urls.XUL_FANCY_PROMPT,
672 'fancy_prompt', 'chrome,resizable,modal',
673 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
675 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
676 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
678 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
681 if(obj.retrieve_ids.length > 1) {
682 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
684 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
687 if(obj.retrieve_ids.length > 1) {
688 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
690 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
694 var r = obj.error.yns_alert(msg,
695 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
696 $("commonStrings").getString('common.yes'),
697 $("commonStrings").getString('common.no'),
699 $("commonStrings").getString('common.check_to_confirm')
702 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
705 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
709 'cmd_holds_edit_desire_mint_condition' : [
713 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
714 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
715 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
716 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
717 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
718 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
720 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
721 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
722 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
723 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
724 JSAN.use('util.window'); var win = new util.window();
725 var fancy_prompt_data = win.open(
726 urls.XUL_FANCY_PROMPT,
727 'fancy_prompt', 'chrome,resizable,modal',
728 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
730 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
731 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
733 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
736 if(obj.retrieve_ids.length > 1) {
737 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
739 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
742 if(obj.retrieve_ids.length > 1) {
743 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
745 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
749 var r = obj.error.yns_alert(msg,
750 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
751 $("commonStrings").getString('common.yes'),
752 $("commonStrings").getString('common.no'),
754 $("commonStrings").getString('common.check_to_confirm')
757 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
760 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
766 'cmd_holds_suspend' : [
770 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
771 var r = obj.error.yns_alert(
772 obj.retrieve_ids.length > 1 ?
773 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
774 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
775 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
776 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
777 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
779 document.getElementById('commonStrings').getString('common.confirm')
782 var already_suspended = []; var filtered_hold_list = [];
783 for (var i = 0; i < obj.retrieve_ids.length; i++) {
784 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
785 if ( get_bool( hold.frozen() ) ) {
786 already_suspended.push( hold.id() );
789 filtered_hold_list.push( hold.id() );
791 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
792 if (already_suspended.length == 1) {
793 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
794 } else if (already_suspended.length > 1) {
795 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
797 obj.clear_and_retrieve(true);
801 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
805 'cmd_holds_activate' : [
809 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
810 var r = obj.error.yns_alert(
811 obj.retrieve_ids.length > 1 ?
812 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
813 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
814 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
815 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
816 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
818 document.getElementById('commonStrings').getString('common.confirm')
821 var already_activated = []; var filtered_hold_list = [];
822 for (var i = 0; i < obj.retrieve_ids.length; i++) {
823 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
824 if ( ! get_bool( hold.frozen() ) ) {
825 already_activated.push( hold.id() );
828 filtered_hold_list.push( hold.id() );
830 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
831 if (already_activated.length == 1) {
832 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
833 } else if (already_activated.length > 1) {
834 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
836 obj.clear_and_retrieve(true);
840 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
844 'cmd_holds_edit_thaw_date' : [
848 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
849 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
850 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
851 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
852 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
853 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
855 JSAN.use('util.window'); var win = new util.window();
856 var my_xulG = win.open(
857 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
860 'description' : desc,
862 'allow_unset' : true,
863 'disallow_future_dates' : false,
864 'disallow_past_dates' : true,
865 'disallow_today' : true,
866 'default_time' : '00:00:00',
867 'time_readonly' : false
870 if (my_xulG.complete) {
871 circ.util.batch_hold_update(
873 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
874 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
878 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
882 'cmd_holds_edit_expire_time' : [
886 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
887 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
888 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
889 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
890 var value = 'YYYY-MM-DD';
891 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
892 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
894 JSAN.use('util.window'); var win = new util.window();
895 var my_xulG = win.open(
896 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
899 'description' : desc,
901 'allow_unset' : true,
902 'disallow_future_dates' : false,
903 'disallow_past_dates' : true,
904 'disallow_today' : true,
905 'default_time' : '00:00:00',
906 'time_readonly' : false
909 if (my_xulG.complete) {
910 circ.util.batch_hold_update(
912 { 'expire_time' : my_xulG.timestamp },
913 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
917 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
921 'cmd_holds_edit_shelf_expire_time' : [
925 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
926 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
927 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
928 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
929 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
930 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
932 JSAN.use('util.window'); var win = new util.window();
933 var my_xulG = win.open(
934 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
937 'description' : desc,
939 'allow_unset' : false,
940 'disallow_future_dates' : false,
941 'disallow_past_dates' : false,
942 'disallow_today' : false
945 if (my_xulG.complete) {
946 circ.util.batch_hold_update(
948 { 'shelf_expire_time' : my_xulG.timestamp },
949 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
953 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
957 'cmd_holds_edit_request_date' : [
961 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
962 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
963 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
964 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
965 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
966 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
968 JSAN.use('util.window'); var win = new util.window();
969 var my_xulG = win.open(
970 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
973 'description' : desc,
975 'allow_unset' : false,
976 'disallow_future_dates' : true,
977 'disallow_past_dates' : false,
978 'disallow_today' : false
981 if (my_xulG.complete) {
982 circ.util.batch_hold_update(
984 { 'request_time' : my_xulG.timestamp },
985 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
989 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
993 'cmd_holds_retarget' : [
997 JSAN.use('util.functional');
999 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1001 if(obj.retrieve_ids.length > 1) {
1002 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
1004 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
1006 var r = obj.error.yns_alert(msg,
1007 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
1008 $("commonStrings").getString('common.yes'),
1009 $("commonStrings").getString('common.no'),
1011 $("commonStrings").getString('common.check_to_confirm')
1014 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1015 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
1016 if (typeof robj.ilsevent != 'undefined') throw(robj);
1018 obj.clear_and_retrieve();
1021 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
1027 'cmd_holds_cancel' : [
1031 JSAN.use('util.functional');
1033 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1035 if(obj.retrieve_ids.length > 1 ) {
1036 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
1038 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
1041 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1042 JSAN.use('util.window');
1043 var win = new util.window();
1044 var my_xulG = win.open(
1045 urls.XUL_HOLD_CANCEL,
1047 'chrome,resizable,modal',
1050 /*var r = obj.error.yns_alert(msg,
1051 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1052 $("commonStrings").getString('common.yes'),
1053 $("commonStrings").getString('common.no'),
1055 $("commonStrings").getString('common.check_to_confirm')
1058 if (my_xulG.proceed) {
1060 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1061 var transit = obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit();
1062 if (transit && ! transit.dest_recv_time() ) {
1063 transits.push( obj.retrieve_ids[i].barcode );
1065 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1066 if (typeof robj.ilsevent != 'undefined') throw(robj);
1068 if (transits.length > 0) {
1069 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1070 var r2 = obj.error.yns_alert(msg2,
1071 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1072 $("commonStrings").getString('common.yes'),
1073 $("commonStrings").getString('common.no'),
1075 $("commonStrings").getString('common.check_to_confirm'));
1078 for (var i = 0; i < transits.length; i++) {
1079 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1080 if (typeof robj.ilsevent != 'undefined') {
1081 switch(Number(robj.ilsevent)) {
1082 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1085 case 5000 /* PERM_FAILURE */ :
1094 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1098 obj.clear_and_retrieve();
1101 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1105 'cmd_holds_uncancel' : [
1109 JSAN.use('util.functional');
1110 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1111 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1112 if (typeof robj.ilsevent != 'undefined') throw(robj);
1114 obj.clear_and_retrieve();
1116 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1121 'cmd_retrieve_patron' : [
1126 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1127 var patron_id = obj.retrieve_ids[i].usr;
1128 if (seen[patron_id]) continue; seen[patron_id] = true;
1129 xulG.new_patron_tab(
1131 { 'id' : patron_id }
1135 obj.error.standard_unexpected_error_alert('',E);
1139 'cmd_show_catalog' : [
1143 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1144 var htarget = obj.retrieve_ids[i].target;
1145 var htype = obj.retrieve_ids[i].type;
1149 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1153 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1156 opac_url = xulG.url_prefix( urls.opac_rdetail )
1157 + '?r=' + obj.hold_subscription_map[ obj.retrieve_ids[i].hold_id ].record_entry();
1160 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1161 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1164 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1166 if (typeof my_acp.call_number() == 'object') {
1167 my_acn = my.acp.call_number();
1169 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1170 [ my_acp.call_number() ]);
1172 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1175 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1179 var content_params = {
1181 'authtime' : ses('authtime'),
1182 'opac_url' : opac_url
1185 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1186 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1191 obj.error.standard_unexpected_error_alert('',E);
1195 'cmd_holds_title_transfer' : [
1200 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1201 var htarget = obj.retrieve_ids[i].target;
1202 var htype = obj.retrieve_ids[i].type;
1205 continue; // not supported
1208 targets.push( htarget );
1211 continue; // not supported
1214 continue; // not supported
1217 continue; // not supported
1221 JSAN.use('cat.util');
1222 cat.util.transfer_title_holds(targets);
1223 obj.clear_and_retrieve();
1225 obj.error.standard_unexpected_error_alert('',E);
1233 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1237 'lib_filter_checkbox' : [
1240 var x_lib_type_menu = document.getElementById('lib_type_menu');
1241 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1242 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1243 obj.clear_and_retrieve();
1244 ev.target.setAttribute('checked',ev.target.checked);
1247 'cmd_view_expired_onshelf_holds' : [
1250 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1251 obj.expired = x.checked;
1252 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1253 obj.clear_and_retrieve();
1256 'cmd_clear_expired_onshelf_holds' : [
1260 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1261 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1262 if (robj == null) { robj = []; }
1263 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1264 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1266 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1267 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1268 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1269 var x_lib_type_menu = document.getElementById('lib_type_menu');
1270 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1271 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1272 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1273 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1274 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1276 // id's in xulG.holds will prevent the normal retrieval method from firing
1277 JSAN.use('util.functional');
1278 xulG.holds = util.functional.map_list(
1279 robj.sort(function(a,b) {
1280 if (a.action > b.action) { return 1; }
1281 if (a.action < b.action) { return -1; }
1284 function (element, idx) {
1285 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1286 return element.hold_id;
1289 obj.clear_and_retrieve();
1291 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1292 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1297 'cmd_search_opac' : [
1301 var content_params = {
1302 'show_nav_buttons' : false,
1303 'show_print_button' : true,
1304 'passthru_content_params' : {
1305 'authtoken' : ses(),
1306 'authtime' : ses('authtime'),
1307 'window_open' : function(a,b,c) {
1309 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1310 return window.open(a,b,c);
1312 obj.error.standard_unexpected_error_alert('window_open',E);
1315 'opac_hold_placed' : function(hold) {
1321 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1326 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1327 window.xulG.on_list_change();
1330 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1333 'patron_barcode' : obj.patron_barcode
1335 'url_prefix' : xulG.url_prefix,
1336 'url' : xulG.url_prefix( urls.browser )
1338 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1340 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1349 obj.determine_hold_interface_type();
1350 var x_fetch_more = document.getElementById('fetch_more');
1351 var x_lib_type_menu = document.getElementById('lib_type_menu');
1352 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1353 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1354 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1355 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1356 var x_expired_checkbox = document.getElementById('expired_checkbox');
1357 var x_print_full_pull_list = document.getElementById('print_full_btn');
1358 var x_print_full_pull_list_alt = document.getElementById('print_alt_btn');
1359 switch(obj.hold_interface_type) {
1361 obj.render_lib_menus({'pickup_lib':true});
1362 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1363 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1364 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1365 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1366 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1369 if (x_fetch_more) x_fetch_more.hidden = false;
1370 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1371 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = false;
1372 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1373 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1376 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1377 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1378 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1379 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1380 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1383 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1384 if (x_fetch_more) x_fetch_more.hidden = true;
1385 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1386 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1387 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1388 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1391 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
1393 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1394 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1395 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1397 obj.controller.render();
1400 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1401 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1402 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1403 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1404 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1405 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1406 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1407 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1408 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1409 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1410 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1411 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1412 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1416 $('cmd_alt_view').setAttribute('disabled','true');
1417 xulG.when_done = function() {
1418 $('cmd_alt_view').setAttribute('ready','true');
1419 if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1420 $('cmd_alt_view').setAttribute('disabled','false');
1422 dump('hold details UI ready\n');
1424 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1425 JSAN.use('util.browser');
1426 obj.browser = new util.browser();
1429 'url' : urls.XUL_HOLD_DETAILS,
1431 'alt_print' : false,
1432 'browser_id' : 'hold_detail_frame',
1433 'passthru_content_params' : xulG
1439 'determine_hold_interface_type' : function() {
1441 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1442 obj.hold_interface_type = 'patron';
1443 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1444 obj.hold_interface_type = 'record';
1445 } else if (obj.pull) { /*************************************************** PULL ******************************/
1446 obj.hold_interface_type = 'pull';
1447 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1448 obj.hold_interface_type = 'shelf';
1449 } else { /*************************************************** PULL ******************************/
1450 obj.hold_interface_type = 'pull';
1454 'clear_and_retrieve' : function() {
1457 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1459 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1460 window.xulG.on_list_change();
1463 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1467 'retrieve' : function() {
1468 var obj = this; var holds = [];
1469 if (window.xulG && window.xulG.holds) {
1470 holds = window.xulG.holds;
1472 var method; var params = [ ses() ];
1473 switch(obj.hold_interface_type) {
1475 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1476 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1478 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1480 params.push( obj.patron_id );
1481 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1484 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1485 params.push( obj.docid );
1486 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1487 var x_lib_type_menu = document.getElementById('lib_type_menu');
1489 if (x_lib_filter.checked) {
1490 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1492 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1497 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1501 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1503 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1505 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1506 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1510 method = 'FM_AHR_ID_LIST_PULL_LIST';
1511 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1512 var x = document.getElementById('hold_count');
1514 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1515 var count = req.getResultObject();
1516 if (typeof count.ilsevent == 'undefined' && count != null) {
1517 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1518 'staff.patron.holds.total_count',
1527 var robj = obj.network.simple_request( method, params );
1528 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1529 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1532 holds = holds.concat( robj.copy_holds );
1533 holds = holds.concat( robj.volume_holds );
1534 holds = holds.concat( robj.title_holds );
1535 holds = holds.concat( robj.part_holds );
1536 holds = holds.concat( robj.issuance_holds );
1537 holds = holds.concat( robj.metarecord_holds );
1538 holds = holds.sort();
1541 if (robj == null ) {
1544 if (typeof robj.length == 'undefined') {
1552 //alert('method = ' + method + ' params = ' + js2JSON(params));
1555 var x_fetch_more = document.getElementById('fetch_more');
1556 if (holds.length == 0) {
1557 if (x_fetch_more) x_fetch_more.disabled = true;
1559 if (x_fetch_more) x_fetch_more.disabled = false;
1565 'render' : function(holds) {
1569 function list_append(hold_id) {
1574 'hold_id' : hold_id,
1575 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1583 function gen_list_append(hold) {
1585 if (typeof obj.controller.view.lib_menu == 'undefined') {
1586 list_append(typeof hold == 'object' ? hold.id() : hold);
1588 list_append(typeof hold == 'object' ? hold.id() : hold);
1595 JSAN.use('util.exec'); var exec = new util.exec(2);
1597 for (var i in holds) {
1598 rows.push( gen_list_append(holds[i]) );
1603 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1607 'render_lib_menus' : function(types) {
1610 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1612 var x = document.getElementById('lib_type_menu');
1614 var nodes = x.firstChild.childNodes;
1615 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1616 for (var i in types) document.getElementById(i).hidden = false;
1618 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1620 x = document.getElementById('lib_menu_placeholder');
1621 util.widgets.remove_children( x );
1623 JSAN.use('util.file');
1624 var file = new util.file('offline_ou_list');
1625 if (file._file.exists()) {
1626 var list_data = file.get_object(); file.close();
1627 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1628 ml.setAttribute('id','lib_menu');
1629 x.appendChild( ml );
1630 ml.addEventListener(
1633 obj.filter_lib = ev.target.value;
1634 obj.clear_and_retrieve();
1638 obj.controller.view.lib_menu = ml;
1640 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1644 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1649 dump('exiting patron.holds.js\n');