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.patron_family_name = blob.patron_last;
92 row.my.patron_first_given_name = blob.patron_first;
93 row.my.patron_barcode = blob.patron_barcode;
94 row.my.patron_alias = blob.patron_alias;
95 row.my.total_holds = blob.total_holds;
96 row.my.queue_position = blob.queue_position;
97 row.my.potential_copies = blob.potential_copies;
98 row.my.estimated_wait = blob.estimated_wait;
99 row.my.ahrn_count = blob.hold.notes().length;
101 var copy_id = row.my.ahr.current_copy();
102 if (typeof copy_id == 'object') {
103 if (copy_id == null) {
104 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
106 copy_id = copy_id.id();
109 copy_id = row.my.acp.id();
112 obj.holds_map[ row.my.ahr.id() ] = blob;
113 params.row_node.setAttribute('retrieve_id',
116 'barcode':row.my.acp ? row.my.acp.barcode() : null,
117 'id':row.my.ahr.id(),
118 'type':row.my.ahr.hold_type(),
119 'target':row.my.ahr.target(),
120 'usr':row.my.ahr.usr()
123 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
126 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
131 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
135 'on_select' : function(ev) {
136 JSAN.use('util.functional');
137 var sel = obj.list.retrieve_selection();
138 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
139 obj.retrieve_ids = util.functional.map_list(
141 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
143 if (obj.retrieve_ids.length > 0) {
144 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
145 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
146 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
147 obj.controller.view.sel_patron.setAttribute('disabled','false');
148 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
149 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
150 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
151 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
152 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
153 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
154 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
155 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
156 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
157 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
158 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
159 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
160 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','false');
161 if (obj.controller.view.cmd_alt_view.getAttribute('ready')=='true') {
162 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
164 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
165 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
166 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
167 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
169 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
170 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
171 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
172 obj.controller.view.sel_patron.setAttribute('disabled','true');
173 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
174 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
175 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
176 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
177 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
178 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
179 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
180 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
181 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
182 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
183 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
184 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
185 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
186 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','true');
187 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
188 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
189 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
190 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
196 JSAN.use('util.controller'); obj.controller = new util.controller();
200 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
203 function() { obj.list.clipboard(); }
207 function() { alert($("commonStrings").getString('common.unimplemented')); }
212 JSAN.use('circ.util');
213 circ.util.show_last_few_circs(obj.retrieve_ids);
219 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
220 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
227 var n = obj.controller.view.alt_view_btn;
228 if (n.getAttribute('toggle') == '1') {
229 document.getElementById('deck').selectedIndex = 0;
230 n.setAttribute('toggle','0');
231 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
232 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
234 document.getElementById('deck').selectedIndex = 1;
235 n.setAttribute('toggle','1');
236 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
237 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
238 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
239 if (obj.retrieve_ids.length == 0) return;
240 var f = obj.browser.get_content();
241 xulG.ahr_id = obj.retrieve_ids[0].id;
242 xulG.blob = obj.holds_map[ xulG.ahr_id ];
243 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
244 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
246 f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
247 f.fetch_and_render_all(true);
250 alert('Error in holds.js, cmd_alt_view handler: ' + E);
254 'cmd_cancelled_holds_view' : [
257 document.getElementById('show_cancelled_deck').selectedIndex = 1;
258 /* For some reason attribute propogation on the <command> element isn't working with hidden */
259 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
260 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
261 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
262 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
263 obj.clear_and_retrieve();
266 'cmd_uncancelled_holds_view' : [
269 document.getElementById('show_cancelled_deck').selectedIndex = 0;
270 /* For some reason attribute propogation on the <command> element isn't working with hidden */
271 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
272 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
273 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
274 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
275 obj.clear_and_retrieve();
278 'sel_mark_items_damaged' : [
281 JSAN.use('cat.util'); JSAN.use('util.functional');
282 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
285 'sel_mark_items_missing' : [
288 JSAN.use('cat.util'); JSAN.use('util.functional');
289 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
292 'sel_copy_details' : [
295 JSAN.use('circ.util');
296 circ.util.item_details_new(
297 util.functional.map_list(
299 function(o) { return o.barcode; }
304 'cmd_holds_print_full' : [
307 var x_print_full_pull_list = document.getElementById('print_full_btn');
310 progressmeter.mode = 'undetermined';
311 progressmeter.hidden = false;
312 x_print_full_pull_list.disabled = true;
314 JSAN.use('util.print');
315 var print = new util.print('default');
316 var robj = fieldmapper.standardRequest(
317 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
324 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
325 print.simple( robj.template_output().data() );
328 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
331 progressmeter.mode = 'determined';
332 progressmeter.hidden = true;
333 x_print_full_pull_list.disabled = false;
337 'cmd_holds_print_alt' : [
341 var content_params = {
343 "authtime": ses("authtime"),
345 "show_nav_buttons": true,
346 "show_print_button": false
348 ["url_prefix", "new_tab", "set_tab",
349 "close_tab", "new_patron_tab",
350 "set_patron_tab", "volume_item_creator",
352 "holdings_maintenance_tab", "set_tab_name",
353 "open_chrome_window", "url_prefix",
354 "network_meter", "page_meter",
355 "set_statusbar", "set_help_context"
356 ].forEach(function(k) {
357 content_params[k] = xulG[k];
360 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
361 xulG.url_prefix("/opac/extras/circ/alt_holds_print.html").replace("http:","https:")
365 "tab_name": "Printable Pull List", /* XXX i18n */
370 g.error.sdump("D_ERROR", E);
374 'cmd_holds_print' : [
378 JSAN.use('patron.util');
380 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
383 obj.list.print(params);
385 obj.error.standard_unexpected_error_alert('print 1',E);
389 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
390 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
391 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
393 'cmd_holds_edit_selection_depth' : [
397 JSAN.use('util.widgets'); JSAN.use('util.functional');
398 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
399 var list = util.functional.map_list(
400 util.functional.filter_list(
403 if (o.depth() > ws_type.depth()) return false;
404 if (o.depth() < ws_type.depth()) return true;
405 return (o.id() == ws_type.id());
417 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
418 ml.setAttribute('id','selection');
419 ml.setAttribute('name','fancy_data');
420 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
421 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
422 xml += util.widgets.serialize_node(ml);
424 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
425 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
426 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
427 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
428 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
429 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
430 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
431 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
432 JSAN.use('util.window'); var win = new util.window();
433 var fancy_prompt_data = win.open(
434 urls.XUL_FANCY_PROMPT,
435 //+ '?xml_in_stash=temp_mid'
436 //+ '&bottom_xml_in_stash=temp_bot'
437 //+ '&title=' + window.escape('Choose a Pick Up Library'),
438 'fancy_prompt', 'chrome,resizable,modal',
439 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
441 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
442 var selection = fancy_prompt_data.selection;
444 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
446 if(obj.retrieve_ids.length > 1) {
447 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
449 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
452 var r = obj.error.yns_alert(msg,
453 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
454 $("commonStrings").getString('common.yes'),
455 $("commonStrings").getString('common.no'),
457 $("commonStrings").getString('common.check_to_confirm')
460 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
463 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
468 'cmd_holds_edit_pickup_lib' : [
472 JSAN.use('util.widgets'); JSAN.use('util.functional');
474 var list = util.functional.map_list(
477 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
479 o.name() ? sname + ' ' + o.name() : o.shortname(),
481 ( !isTrue(obj.data.hash.aout[ o.ou_type() ].can_have_users()) ),
482 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
486 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
487 ml.setAttribute('id','lib');
488 ml.setAttribute('name','fancy_data');
489 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
490 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
491 xml += util.widgets.serialize_node(ml);
493 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
494 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
495 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
496 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
497 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
498 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
499 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
500 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
501 JSAN.use('util.window'); var win = new util.window();
502 var fancy_prompt_data = win.open(
503 urls.XUL_FANCY_PROMPT,
504 //+ '?xml_in_stash=temp_mid'
505 //+ '&bottom_xml_in_stash=temp_bot'
506 //+ '&title=' + window.escape('Choose a Pick Up Library'),
507 'fancy_prompt', 'chrome,resizable,modal',
508 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
510 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
511 var pickup_lib = fancy_prompt_data.lib;
513 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
515 if(obj.retrieve_ids.length > 1) {
516 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()]);
518 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()]);
520 var r = obj.error.yns_alert(msg,
521 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
522 $("commonStrings").getString('common.yes'),
523 $("commonStrings").getString('common.no'),
525 $("commonStrings").getString('common.check_to_confirm')
528 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
531 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
535 'cmd_holds_edit_phone_notify' : [
539 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
540 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
541 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
543 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
544 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
545 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
546 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
547 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
548 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
549 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
550 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
551 JSAN.use('util.window'); var win = new util.window();
552 var fancy_prompt_data = win.open(
553 urls.XUL_FANCY_PROMPT,
554 //+ '?xml_in_stash=temp_mid'
555 //+ '&bottom_xml_in_stash=temp_bot'
556 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
558 'fancy_prompt', 'chrome,resizable,modal',
559 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
561 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
562 var phone = fancy_prompt_data.phone;
564 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
566 if(obj.retrieve_ids.length > 1) {
567 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
569 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
571 var r = obj.error.yns_alert(msg,
572 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
573 $("commonStrings").getString('common.yes'),
574 $("commonStrings").getString('common.no'),
576 $("commonStrings").getString('common.check_to_confirm')
579 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
582 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
586 'cmd_holds_edit_email_notify' : [
590 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
591 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
592 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
593 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
594 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
595 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
597 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
598 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
599 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
600 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
601 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
602 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
603 JSAN.use('util.window'); var win = new util.window();
604 var fancy_prompt_data = win.open(
605 urls.XUL_FANCY_PROMPT,
606 //+ '?xml_in_stash=temp_mid'
607 //+ '&bottom_xml_in_stash=temp_bot'
608 //+ '&title=' + window.escape('Set Email Notification for Holds'),
609 'fancy_prompt', 'chrome,resizable,modal',
610 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
612 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
613 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
615 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
617 if(get_bool(email)) {
618 if(obj.retrieve_ids.length > 1) {
619 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
621 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
624 if(obj.retrieve_ids.length > 1) {
625 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
627 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
631 var r = obj.error.yns_alert(msg,
632 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
633 $("commonStrings").getString('common.yes'),
634 $("commonStrings").getString('common.no'),
636 $("commonStrings").getString('common.check_to_confirm')
639 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
642 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
646 'cmd_holds_cut_in_line' : [
650 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
651 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
652 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
653 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
654 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
655 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
657 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
658 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
659 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
660 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
661 JSAN.use('util.window'); var win = new util.window();
662 var fancy_prompt_data = win.open(
663 urls.XUL_FANCY_PROMPT,
664 'fancy_prompt', 'chrome,resizable,modal',
665 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
667 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
668 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
670 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
673 if(obj.retrieve_ids.length > 1) {
674 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
676 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
679 if(obj.retrieve_ids.length > 1) {
680 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
682 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
686 var r = obj.error.yns_alert(msg,
687 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
688 $("commonStrings").getString('common.yes'),
689 $("commonStrings").getString('common.no'),
691 $("commonStrings").getString('common.check_to_confirm')
694 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
697 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
701 'cmd_holds_edit_desire_mint_condition' : [
705 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
706 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
707 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
708 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
709 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
710 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
712 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
713 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
714 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
715 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
716 JSAN.use('util.window'); var win = new util.window();
717 var fancy_prompt_data = win.open(
718 urls.XUL_FANCY_PROMPT,
719 'fancy_prompt', 'chrome,resizable,modal',
720 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
722 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
723 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
725 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
728 if(obj.retrieve_ids.length > 1) {
729 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
731 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
734 if(obj.retrieve_ids.length > 1) {
735 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
737 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
741 var r = obj.error.yns_alert(msg,
742 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
743 $("commonStrings").getString('common.yes'),
744 $("commonStrings").getString('common.no'),
746 $("commonStrings").getString('common.check_to_confirm')
749 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
752 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
758 'cmd_holds_suspend' : [
762 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
763 var r = obj.error.yns_alert(
764 obj.retrieve_ids.length > 1 ?
765 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
766 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
767 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
768 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
769 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
771 document.getElementById('commonStrings').getString('common.confirm')
774 var already_suspended = []; var filtered_hold_list = [];
775 for (var i = 0; i < obj.retrieve_ids.length; i++) {
776 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
777 if ( get_bool( hold.frozen() ) ) {
778 already_suspended.push( hold.id() );
781 filtered_hold_list.push( hold.id() );
783 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
784 if (already_suspended.length == 1) {
785 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
786 } else if (already_suspended.length > 1) {
787 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
789 obj.clear_and_retrieve(true);
793 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
797 'cmd_holds_activate' : [
801 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
802 var r = obj.error.yns_alert(
803 obj.retrieve_ids.length > 1 ?
804 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
805 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
806 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
807 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
808 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
810 document.getElementById('commonStrings').getString('common.confirm')
813 var already_activated = []; var filtered_hold_list = [];
814 for (var i = 0; i < obj.retrieve_ids.length; i++) {
815 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
816 if ( ! get_bool( hold.frozen() ) ) {
817 already_activated.push( hold.id() );
820 filtered_hold_list.push( hold.id() );
822 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
823 if (already_activated.length == 1) {
824 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
825 } else if (already_activated.length > 1) {
826 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
828 obj.clear_and_retrieve(true);
832 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
836 'cmd_holds_edit_thaw_date' : [
840 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
841 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
842 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
843 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
844 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
845 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
847 JSAN.use('util.window'); var win = new util.window();
848 var my_xulG = win.open(
849 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
852 'description' : desc,
854 'allow_unset' : true,
855 'disallow_future_dates' : false,
856 'disallow_past_dates' : true,
857 'disallow_today' : true,
858 'default_time' : '00:00:00',
859 'time_readonly' : false
862 if (my_xulG.complete) {
863 circ.util.batch_hold_update(
865 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
866 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
870 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
874 'cmd_holds_edit_expire_time' : [
878 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
879 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
880 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
881 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
882 var value = 'YYYY-MM-DD';
883 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
884 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
886 JSAN.use('util.window'); var win = new util.window();
887 var my_xulG = win.open(
888 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
891 'description' : desc,
893 'allow_unset' : true,
894 'disallow_future_dates' : false,
895 'disallow_past_dates' : true,
896 'disallow_today' : true,
897 'default_time' : '00:00:00',
898 'time_readonly' : false
901 if (my_xulG.complete) {
902 circ.util.batch_hold_update(
904 { 'expire_time' : my_xulG.timestamp },
905 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
909 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
913 'cmd_holds_edit_shelf_expire_time' : [
917 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
918 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
919 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
920 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
921 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
922 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
924 JSAN.use('util.window'); var win = new util.window();
925 var my_xulG = win.open(
926 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
929 'description' : desc,
931 'allow_unset' : false,
932 'disallow_future_dates' : false,
933 'disallow_past_dates' : false,
934 'disallow_today' : false
937 if (my_xulG.complete) {
938 circ.util.batch_hold_update(
940 { 'shelf_expire_time' : my_xulG.timestamp },
941 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
945 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
949 'cmd_holds_edit_request_date' : [
953 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
954 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
955 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
956 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
957 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
958 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
960 JSAN.use('util.window'); var win = new util.window();
961 var my_xulG = win.open(
962 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
965 'description' : desc,
967 'allow_unset' : false,
968 'disallow_future_dates' : true,
969 'disallow_past_dates' : false,
970 'disallow_today' : false
973 if (my_xulG.complete) {
974 circ.util.batch_hold_update(
976 { 'request_time' : my_xulG.timestamp },
977 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
981 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
985 'cmd_holds_retarget' : [
989 JSAN.use('util.functional');
991 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
993 if(obj.retrieve_ids.length > 1) {
994 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
996 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
998 var r = obj.error.yns_alert(msg,
999 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
1000 $("commonStrings").getString('common.yes'),
1001 $("commonStrings").getString('common.no'),
1003 $("commonStrings").getString('common.check_to_confirm')
1006 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1007 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
1008 if (typeof robj.ilsevent != 'undefined') throw(robj);
1010 obj.clear_and_retrieve();
1013 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
1019 'cmd_holds_cancel' : [
1023 JSAN.use('util.functional');
1025 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1027 if(obj.retrieve_ids.length > 1 ) {
1028 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
1030 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
1033 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1034 JSAN.use('util.window');
1035 var win = new util.window();
1036 var my_xulG = win.open(
1037 urls.XUL_HOLD_CANCEL,
1039 'chrome,resizable,modal',
1042 /*var r = obj.error.yns_alert(msg,
1043 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1044 $("commonStrings").getString('common.yes'),
1045 $("commonStrings").getString('common.no'),
1047 $("commonStrings").getString('common.check_to_confirm')
1050 if (my_xulG.proceed) {
1052 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1053 var transit = obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit();
1054 if (transit && ! transit.dest_recv_time() ) {
1055 transits.push( obj.retrieve_ids[i].barcode );
1057 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1058 if (typeof robj.ilsevent != 'undefined') throw(robj);
1060 if (transits.length > 0) {
1061 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1062 var r2 = obj.error.yns_alert(msg2,
1063 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1064 $("commonStrings").getString('common.yes'),
1065 $("commonStrings").getString('common.no'),
1067 $("commonStrings").getString('common.check_to_confirm'));
1070 for (var i = 0; i < transits.length; i++) {
1071 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1072 if (typeof robj.ilsevent != 'undefined') {
1073 switch(Number(robj.ilsevent)) {
1074 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1077 case 5000 /* PERM_FAILURE */ :
1086 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1090 obj.clear_and_retrieve();
1093 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1097 'cmd_holds_uncancel' : [
1101 JSAN.use('util.functional');
1102 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1103 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1104 if (typeof robj.ilsevent != 'undefined') throw(robj);
1106 obj.clear_and_retrieve();
1108 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1113 'cmd_retrieve_patron' : [
1118 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1119 var patron_id = obj.retrieve_ids[i].usr;
1120 if (seen[patron_id]) continue; seen[patron_id] = true;
1121 xulG.new_patron_tab(
1123 { 'id' : patron_id }
1127 obj.error.standard_unexpected_error_alert('',E);
1131 'cmd_show_catalog' : [
1135 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1136 var htarget = obj.retrieve_ids[i].target;
1137 var htype = obj.retrieve_ids[i].type;
1141 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
1144 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
1147 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1148 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1151 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1153 if (typeof my_acp.call_number() == 'object') {
1154 my_acn = my.acp.call_number();
1156 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1157 [ my_acp.call_number() ]);
1159 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
1162 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1166 var content_params = {
1168 'authtime' : ses('authtime'),
1169 'opac_url' : opac_url
1172 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1173 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1178 obj.error.standard_unexpected_error_alert('',E);
1182 'cmd_holds_title_transfer' : [
1187 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1188 var htarget = obj.retrieve_ids[i].target;
1189 var htype = obj.retrieve_ids[i].type;
1192 continue; // not supported
1195 targets.push( htarget );
1198 continue; // not supported
1201 continue; // not supported
1204 continue; // not supported
1208 JSAN.use('cat.util');
1209 cat.util.transfer_title_holds(targets);
1210 obj.clear_and_retrieve();
1212 obj.error.standard_unexpected_error_alert('',E);
1220 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1224 'lib_filter_checkbox' : [
1227 var x_lib_type_menu = document.getElementById('lib_type_menu');
1228 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1229 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1230 obj.clear_and_retrieve();
1231 ev.target.setAttribute('checked',ev.target.checked);
1234 'cmd_view_expired_onshelf_holds' : [
1237 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1238 obj.expired = x.checked;
1239 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1240 obj.clear_and_retrieve();
1243 'cmd_clear_expired_onshelf_holds' : [
1247 // I could put this with the "retrieval" methods, but since it has side effects, seems cleaner to invoke it here
1248 var robj = obj.network.simple_request( 'CLEAR_HOLD_SHELF', [ ses(), obj.filter_lib || obj.data.list.au[0].ws_ou() ] );
1249 if (robj == null) { robj = []; }
1250 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1251 if (typeof robj.length == 'undefined') { robj = [ robj ]; }
1253 // Disable anything such as filters that can have us accidentally lose these non-repeatable results
1254 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1255 if (x_lib_filter_checkbox) { x_lib_filter_checkbox.checked = false; }
1256 var x_lib_type_menu = document.getElementById('lib_type_menu');
1257 if (x_lib_type_menu) { x_lib_type_menu.disabled = true; }
1258 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1259 if (x_lib_menu_placeholder) { x_lib_menu_placeholder.firstChild.disabled = true; }
1260 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute('disabled', 'true');
1261 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', 'true');
1263 // id's in xulG.holds will prevent the normal retrieval method from firing
1264 JSAN.use('util.functional');
1265 xulG.holds = util.functional.map_list(
1266 robj.sort(function(a,b) {
1267 if (a.action > b.action) { return 1; }
1268 if (a.action < b.action) { return -1; }
1271 function (element, idx) {
1272 obj.post_clear_shelf_hold_action_map[ element.hold_id ] = element.action; // necessary side-effect
1273 return element.hold_id;
1276 obj.clear_and_retrieve();
1278 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) { return; /* handled by network.js */ }
1279 obj.error.standard_unexpected_error_alert('Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1284 'cmd_search_opac' : [
1288 var content_params = {
1289 'show_nav_buttons' : false,
1290 'show_print_button' : true,
1291 'passthru_content_params' : {
1292 'authtoken' : ses(),
1293 'authtime' : ses('authtime'),
1294 'window_open' : function(a,b,c) {
1296 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1297 return window.open(a,b,c);
1299 obj.error.standard_unexpected_error_alert('window_open',E);
1302 'opac_hold_placed' : function(hold) {
1308 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1313 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1314 window.xulG.on_list_change();
1317 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1320 'patron_barcode' : obj.patron_barcode
1322 'url_prefix' : xulG.url_prefix,
1323 'url' : xulG.url_prefix( urls.browser )
1325 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1327 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1336 obj.determine_hold_interface_type();
1337 var x_fetch_more = document.getElementById('fetch_more');
1338 var x_lib_type_menu = document.getElementById('lib_type_menu');
1339 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1340 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1341 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1342 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1343 var x_expired_checkbox = document.getElementById('expired_checkbox');
1344 var x_print_full_pull_list = document.getElementById('print_full_btn');
1345 var x_print_full_pull_list_alt = document.getElementById('print_alt_btn');
1346 switch(obj.hold_interface_type) {
1348 obj.render_lib_menus({'pickup_lib':true});
1349 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1350 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1351 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1352 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1353 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1356 if (x_fetch_more) x_fetch_more.hidden = false;
1357 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1358 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = false;
1359 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1360 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1363 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1364 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1365 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1366 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1367 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1370 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1371 if (x_fetch_more) x_fetch_more.hidden = true;
1372 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1373 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1374 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1375 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1378 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
1380 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1381 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1382 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1384 obj.controller.render();
1387 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1388 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1389 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1390 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1391 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1392 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1393 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1394 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1395 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1396 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1397 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1398 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1399 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1403 $('cmd_alt_view').setAttribute('disabled','true');
1404 xulG.when_done = function() {
1405 $('cmd_alt_view').setAttribute('ready','true');
1406 if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1407 $('cmd_alt_view').setAttribute('disabled','false');
1409 dump('hold details UI ready\n');
1411 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1412 JSAN.use('util.browser');
1413 obj.browser = new util.browser();
1416 'url' : urls.XUL_HOLD_DETAILS,
1418 'alt_print' : false,
1419 'browser_id' : 'hold_detail_frame',
1420 'passthru_content_params' : xulG
1426 'determine_hold_interface_type' : function() {
1428 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1429 obj.hold_interface_type = 'patron';
1430 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1431 obj.hold_interface_type = 'record';
1432 } else if (obj.pull) { /*************************************************** PULL ******************************/
1433 obj.hold_interface_type = 'pull';
1434 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1435 obj.hold_interface_type = 'shelf';
1436 } else { /*************************************************** PULL ******************************/
1437 obj.hold_interface_type = 'pull';
1441 'clear_and_retrieve' : function() {
1444 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1446 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1447 window.xulG.on_list_change();
1450 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1454 'retrieve' : function() {
1455 var obj = this; var holds = [];
1456 if (window.xulG && window.xulG.holds) {
1457 holds = window.xulG.holds;
1459 var method; var params = [ ses() ];
1460 switch(obj.hold_interface_type) {
1462 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1463 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1465 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1467 params.push( obj.patron_id );
1468 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1471 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1472 params.push( obj.docid );
1473 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1474 var x_lib_type_menu = document.getElementById('lib_type_menu');
1476 if (x_lib_filter.checked) {
1477 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1479 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1484 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1488 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1490 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1492 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1493 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1497 method = 'FM_AHR_ID_LIST_PULL_LIST';
1498 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1499 var x = document.getElementById('hold_count');
1501 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1502 var count = req.getResultObject();
1503 if (typeof count.ilsevent == 'undefined' && count != null) {
1504 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1505 'staff.patron.holds.total_count',
1514 var robj = obj.network.simple_request( method, params );
1515 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1516 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1519 holds = holds.concat( robj.copy_holds );
1520 holds = holds.concat( robj.volume_holds );
1521 holds = holds.concat( robj.title_holds );
1522 holds = holds.concat( robj.metarecord_holds );
1523 holds = holds.sort();
1526 if (robj == null ) {
1529 if (typeof robj.length == 'undefined') {
1537 //alert('method = ' + method + ' params = ' + js2JSON(params));
1540 var x_fetch_more = document.getElementById('fetch_more');
1541 if (holds.length == 0) {
1542 if (x_fetch_more) x_fetch_more.disabled = true;
1544 if (x_fetch_more) x_fetch_more.disabled = false;
1550 'render' : function(holds) {
1554 function list_append(hold_id) {
1559 'hold_id' : hold_id,
1560 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1568 function gen_list_append(hold) {
1570 if (typeof obj.controller.view.lib_menu == 'undefined') {
1571 list_append(typeof hold == 'object' ? hold.id() : hold);
1573 list_append(typeof hold == 'object' ? hold.id() : hold);
1580 JSAN.use('util.exec'); var exec = new util.exec(2);
1582 for (var i in holds) {
1583 rows.push( gen_list_append(holds[i]) );
1588 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1592 'render_lib_menus' : function(types) {
1595 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1597 var x = document.getElementById('lib_type_menu');
1599 var nodes = x.firstChild.childNodes;
1600 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1601 for (var i in types) document.getElementById(i).hidden = false;
1603 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1605 x = document.getElementById('lib_menu_placeholder');
1606 util.widgets.remove_children( x );
1608 JSAN.use('util.file');
1609 var file = new util.file('offline_ou_list');
1610 if (file._file.exists()) {
1611 var list_data = file.get_object(); file.close();
1612 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1613 ml.setAttribute('id','lib_menu');
1614 x.appendChild( ml );
1615 ml.addEventListener(
1618 obj.filter_lib = ev.target.value;
1619 obj.clear_and_retrieve();
1623 obj.controller.view.lib_menu = ml;
1625 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1629 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1634 dump('exiting patron.holds.js\n');