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 dojo.require("openils.Util");
44 obj.patron_id = params['patron_id'];
45 obj.patron_barcode = params['patron_barcode'];
46 obj.docid = params['docid'];
47 obj.shelf = params['shelf'];
48 obj.tree_id = params['tree_id'];
50 var progressmeter = document.getElementById('progress');
52 JSAN.use('circ.util');
53 var columns = circ.util.hold_columns(
55 'title' : { 'hidden' : false, 'flex' : '3' },
56 'request_time' : { 'hidden' : false },
57 'pickup_lib_shortname' : { 'hidden' : false },
58 'hold_type' : { 'hidden' : false },
59 'current_copy' : { 'hidden' : false },
60 'capture_time' : { 'hidden' : false },
61 'notify_time' : { 'hidden' : false },
62 'notify_count' : { 'hidden' : false },
63 'cancel_cause' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
64 'cancel_note' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
65 'cancel_time' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
66 'post_clear_shelf_action' : { 'hidden' : obj.shelf ? false : true }
70 JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
73 'columns' : columns.concat(
74 obj.list.fm_columns('acp', {
75 '*' : { 'expanded_label' : true, 'hidden' : true },
76 // example of unhiding some columns by default
77 // 'acp_circ_modifier' : { 'hidden' : false }
80 'retrieve_row' : function(params) {
83 obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
86 var blob = blob_req.getResultObject();
87 if (typeof blob.ilsevent != 'undefined') throw(blob);
88 row.my.ahr = blob.hold;
89 row.my.status = blob.status;
90 row.my.ahr.status( blob.status );
91 row.my.acp = blob.copy;
92 row.my.acn = blob.volume;
93 row.my.mvr = blob.mvr;
94 row.my.part = blob.part;
95 row.my.issuance = blob.issuance;
97 row.my.subscription = blob.issuance.subscription();
98 obj.hold_subscription_map[ row.my.hold_id ] = row.my.subscription;
100 row.my.patron_family_name = blob.patron_last;
101 row.my.patron_first_given_name = blob.patron_first;
102 row.my.patron_barcode = blob.patron_barcode;
103 row.my.patron_alias = blob.patron_alias;
104 row.my.total_holds = blob.total_holds;
105 row.my.queue_position = blob.queue_position;
106 row.my.potential_copies = blob.potential_copies;
107 row.my.estimated_wait = blob.estimated_wait;
108 row.my.ahrn_count = blob.hold.notes().length;
110 var copy_id = row.my.ahr.current_copy();
111 if (typeof copy_id == 'object') {
112 if (copy_id == null) {
113 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
115 copy_id = copy_id.id();
118 copy_id = row.my.acp.id();
121 obj.holds_map[ row.my.ahr.id() ] = blob;
122 params.row_node.setAttribute('retrieve_id',
125 'barcode':row.my.acp ? row.my.acp.barcode() : null,
126 'id':row.my.ahr.id(),
127 'type':row.my.ahr.hold_type(),
128 'target':row.my.ahr.target(),
129 'usr':row.my.ahr.usr()
132 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
135 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
140 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
144 'on_select' : function(ev) {
145 JSAN.use('util.functional');
146 var sel = obj.list.retrieve_selection();
147 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
148 obj.retrieve_ids = util.functional.map_list(
150 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
152 if (obj.retrieve_ids.length > 0) {
153 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
154 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
155 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
156 obj.controller.view.sel_patron.setAttribute('disabled','false');
157 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
158 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
159 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
160 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
161 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
162 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
163 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
164 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
165 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
166 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
167 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
168 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
169 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','false');
170 if (obj.controller.view.cmd_alt_view.getAttribute('ready')=='true') {
171 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
173 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
174 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
175 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
176 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
178 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
179 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
180 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
181 obj.controller.view.sel_patron.setAttribute('disabled','true');
182 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
183 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
184 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
185 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
186 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
187 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
188 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
189 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
190 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
191 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
192 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
193 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
194 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
195 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','true');
196 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
197 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
198 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
199 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
205 JSAN.use('util.controller'); obj.controller = new util.controller();
209 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
212 function() { obj.list.clipboard(); }
216 function() { alert($("commonStrings").getString('common.unimplemented')); }
221 JSAN.use('circ.util');
222 circ.util.show_last_few_circs(obj.retrieve_ids);
228 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
229 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
236 var n = obj.controller.view.alt_view_btn;
237 if (n.getAttribute('toggle') == '1') {
238 document.getElementById('deck').selectedIndex = 0;
239 n.setAttribute('toggle','0');
240 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
241 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
242 obj.controller.view.save_columns.setAttribute('disabled','false');
244 document.getElementById('deck').selectedIndex = 1;
245 n.setAttribute('toggle','1');
246 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
247 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
248 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
249 if (obj.retrieve_ids.length == 0) return;
250 var f = obj.browser.get_content();
251 xulG.ahr_id = obj.retrieve_ids[0].id;
252 xulG.blob = obj.holds_map[ xulG.ahr_id ];
253 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
254 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
256 f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
257 f.fetch_and_render_all(true);
258 obj.controller.view.save_columns.setAttribute('disabled','true');
261 alert('Error in holds.js, cmd_alt_view handler: ' + E);
265 'cmd_cancelled_holds_view' : [
268 document.getElementById('show_cancelled_deck').selectedIndex = 1;
269 /* For some reason attribute propogation on the <command> element isn't working with hidden */
270 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
271 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
272 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
273 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
274 obj.clear_and_retrieve();
277 'cmd_uncancelled_holds_view' : [
280 document.getElementById('show_cancelled_deck').selectedIndex = 0;
281 /* For some reason attribute propogation on the <command> element isn't working with hidden */
282 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
283 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
284 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
285 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
286 obj.clear_and_retrieve();
289 'sel_mark_items_damaged' : [
292 JSAN.use('cat.util'); JSAN.use('util.functional');
293 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
296 'sel_mark_items_missing' : [
299 JSAN.use('cat.util'); JSAN.use('util.functional');
300 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
303 'sel_copy_details' : [
306 JSAN.use('circ.util');
307 circ.util.item_details_new(
308 util.functional.map_list(
310 function(o) { return o.barcode; }
315 'cmd_holds_print_full' : [
318 var x_print_full_pull_list = document.getElementById('print_full_btn');
321 progressmeter.mode = 'undetermined';
322 progressmeter.hidden = false;
323 x_print_full_pull_list.disabled = true;
325 JSAN.use('util.print');
326 var print = new util.print('default');
327 var robj = fieldmapper.standardRequest(
328 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
335 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
336 print.simple( robj.template_output().data() );
339 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
342 progressmeter.mode = 'determined';
343 progressmeter.hidden = true;
344 x_print_full_pull_list.disabled = false;
348 'cmd_holds_print_alt' : [
352 var content_params = {
354 "authtime": ses("authtime"),
356 "show_nav_buttons": true,
357 "show_print_button": true
359 ["url_prefix", "new_tab", "set_tab",
360 "close_tab", "new_patron_tab",
361 "set_patron_tab", "volume_item_creator",
363 "holdings_maintenance_tab", "set_tab_name",
364 "open_chrome_window", "url_prefix",
365 "network_meter", "page_meter",
366 "set_statusbar", "set_help_context"
367 ].forEach(function(k) {
368 content_params[k] = xulG[k];
371 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
372 xulG.url_prefix("/opac/extras/circ/alt_holds_print.html").replace("http:","https:")
376 "tab_name": "Printable Pull List", /* XXX i18n */
381 g.error.sdump("D_ERROR", E);
385 'cmd_holds_print' : [
389 JSAN.use('patron.util');
391 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
394 obj.list.print(params);
396 obj.error.standard_unexpected_error_alert('print 1',E);
400 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
401 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
402 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
404 'cmd_holds_edit_selection_depth' : [
408 JSAN.use('util.widgets'); JSAN.use('util.functional');
409 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
410 var list = util.functional.map_list(
411 util.functional.filter_list(
414 if (o.depth() > ws_type.depth()) return false;
415 if (o.depth() < ws_type.depth()) return true;
416 return (o.id() == ws_type.id());
428 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
429 ml.setAttribute('id','selection');
430 ml.setAttribute('name','fancy_data');
431 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
432 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
433 xml += util.widgets.serialize_node(ml);
435 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
436 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
437 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
438 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
439 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
440 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
441 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
442 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
443 JSAN.use('util.window'); var win = new util.window();
444 var fancy_prompt_data = win.open(
445 urls.XUL_FANCY_PROMPT,
446 //+ '?xml_in_stash=temp_mid'
447 //+ '&bottom_xml_in_stash=temp_bot'
448 //+ '&title=' + window.escape('Choose a Pick Up Library'),
449 'fancy_prompt', 'chrome,resizable,modal',
450 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
452 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
453 var selection = fancy_prompt_data.selection;
455 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
457 if(obj.retrieve_ids.length > 1) {
458 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
460 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
463 var r = obj.error.yns_alert(msg,
464 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
465 $("commonStrings").getString('common.yes'),
466 $("commonStrings").getString('common.no'),
468 $("commonStrings").getString('common.check_to_confirm')
471 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
474 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
479 'cmd_holds_edit_pickup_lib' : [
483 JSAN.use('util.widgets'); JSAN.use('util.functional');
485 var list = util.functional.map_list(
488 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
490 o.name() ? sname + ' ' + o.name() : o.shortname(),
492 ( !isTrue(obj.data.hash.aout[ o.ou_type() ].can_have_users()) ),
493 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
497 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
498 ml.setAttribute('id','lib');
499 ml.setAttribute('name','fancy_data');
500 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
501 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
502 xml += util.widgets.serialize_node(ml);
504 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
505 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
506 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
507 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
508 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
509 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
510 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
511 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
512 JSAN.use('util.window'); var win = new util.window();
513 var fancy_prompt_data = win.open(
514 urls.XUL_FANCY_PROMPT,
515 //+ '?xml_in_stash=temp_mid'
516 //+ '&bottom_xml_in_stash=temp_bot'
517 //+ '&title=' + window.escape('Choose a Pick Up Library'),
518 'fancy_prompt', 'chrome,resizable,modal',
519 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
521 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
522 var pickup_lib = fancy_prompt_data.lib;
524 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
526 if(obj.retrieve_ids.length > 1) {
527 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()]);
529 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()]);
531 var r = obj.error.yns_alert(msg,
532 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
533 $("commonStrings").getString('common.yes'),
534 $("commonStrings").getString('common.no'),
536 $("commonStrings").getString('common.check_to_confirm')
539 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
542 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
546 'cmd_holds_edit_phone_notify' : [
550 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
551 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
552 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
554 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
555 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
556 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
557 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
558 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
559 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
560 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
561 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
562 JSAN.use('util.window'); var win = new util.window();
563 var fancy_prompt_data = win.open(
564 urls.XUL_FANCY_PROMPT,
565 //+ '?xml_in_stash=temp_mid'
566 //+ '&bottom_xml_in_stash=temp_bot'
567 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
569 'fancy_prompt', 'chrome,resizable,modal',
570 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
572 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
573 var phone = fancy_prompt_data.phone;
575 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
577 if(obj.retrieve_ids.length > 1) {
578 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
580 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
582 var r = obj.error.yns_alert(msg,
583 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
584 $("commonStrings").getString('common.yes'),
585 $("commonStrings").getString('common.no'),
587 $("commonStrings").getString('common.check_to_confirm')
590 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
593 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
597 'cmd_holds_edit_email_notify' : [
601 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
602 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
603 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
604 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
605 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
606 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
608 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
609 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
610 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
611 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
612 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
613 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
614 JSAN.use('util.window'); var win = new util.window();
615 var fancy_prompt_data = win.open(
616 urls.XUL_FANCY_PROMPT,
617 //+ '?xml_in_stash=temp_mid'
618 //+ '&bottom_xml_in_stash=temp_bot'
619 //+ '&title=' + window.escape('Set Email Notification for Holds'),
620 'fancy_prompt', 'chrome,resizable,modal',
621 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
623 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
624 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
626 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
628 if(get_bool(email)) {
629 if(obj.retrieve_ids.length > 1) {
630 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
632 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
635 if(obj.retrieve_ids.length > 1) {
636 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
638 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
642 var r = obj.error.yns_alert(msg,
643 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
644 $("commonStrings").getString('common.yes'),
645 $("commonStrings").getString('common.no'),
647 $("commonStrings").getString('common.check_to_confirm')
650 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
653 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
657 'cmd_holds_cut_in_line' : [
661 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
662 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
663 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
664 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
665 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
666 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
668 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
669 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
670 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
671 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
672 JSAN.use('util.window'); var win = new util.window();
673 var fancy_prompt_data = win.open(
674 urls.XUL_FANCY_PROMPT,
675 'fancy_prompt', 'chrome,resizable,modal',
676 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
678 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
679 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
681 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
684 if(obj.retrieve_ids.length > 1) {
685 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
687 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
690 if(obj.retrieve_ids.length > 1) {
691 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
693 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
697 var r = obj.error.yns_alert(msg,
698 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
699 $("commonStrings").getString('common.yes'),
700 $("commonStrings").getString('common.no'),
702 $("commonStrings").getString('common.check_to_confirm')
705 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
708 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
712 'cmd_holds_edit_desire_mint_condition' : [
716 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
717 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
718 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
719 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
720 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
721 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
723 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
724 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
725 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
726 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
727 JSAN.use('util.window'); var win = new util.window();
728 var fancy_prompt_data = win.open(
729 urls.XUL_FANCY_PROMPT,
730 'fancy_prompt', 'chrome,resizable,modal',
731 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
733 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
734 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
736 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
739 if(obj.retrieve_ids.length > 1) {
740 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
742 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
745 if(obj.retrieve_ids.length > 1) {
746 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
748 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
752 var r = obj.error.yns_alert(msg,
753 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
754 $("commonStrings").getString('common.yes'),
755 $("commonStrings").getString('common.no'),
757 $("commonStrings").getString('common.check_to_confirm')
760 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
763 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
769 'cmd_holds_suspend' : [
773 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
774 var r = obj.error.yns_alert(
775 obj.retrieve_ids.length > 1 ?
776 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
777 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
778 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
779 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
780 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
782 document.getElementById('commonStrings').getString('common.confirm')
785 var already_suspended = []; var filtered_hold_list = [];
786 for (var i = 0; i < obj.retrieve_ids.length; i++) {
787 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
788 if ( get_bool( hold.frozen() ) ) {
789 already_suspended.push( hold.id() );
792 filtered_hold_list.push( hold.id() );
794 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
795 if (already_suspended.length == 1) {
796 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
797 } else if (already_suspended.length > 1) {
798 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
800 obj.clear_and_retrieve(true);
804 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
808 'cmd_holds_activate' : [
812 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
813 var r = obj.error.yns_alert(
814 obj.retrieve_ids.length > 1 ?
815 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
816 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
817 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
818 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
819 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
821 document.getElementById('commonStrings').getString('common.confirm')
824 var already_activated = []; var filtered_hold_list = [];
825 for (var i = 0; i < obj.retrieve_ids.length; i++) {
826 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
827 if ( ! get_bool( hold.frozen() ) ) {
828 already_activated.push( hold.id() );
831 filtered_hold_list.push( hold.id() );
833 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
834 if (already_activated.length == 1) {
835 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
836 } else if (already_activated.length > 1) {
837 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
839 obj.clear_and_retrieve(true);
843 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
847 'cmd_holds_edit_thaw_date' : [
851 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
852 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
853 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
854 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
855 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
856 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
858 JSAN.use('util.window'); var win = new util.window();
859 var my_xulG = win.open(
860 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
863 'description' : desc,
865 'allow_unset' : true,
866 'disallow_future_dates' : false,
867 'disallow_past_dates' : true,
868 'disallow_today' : true,
869 'default_time' : '00:00:00',
870 'time_readonly' : false
873 if (my_xulG.complete) {
874 circ.util.batch_hold_update(
876 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
877 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
881 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
885 'cmd_holds_edit_expire_time' : [
889 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
890 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
891 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
892 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
893 var value = 'YYYY-MM-DD';
894 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
895 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
897 JSAN.use('util.window'); var win = new util.window();
898 var my_xulG = win.open(
899 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
902 'description' : desc,
904 'allow_unset' : true,
905 'disallow_future_dates' : false,
906 'disallow_past_dates' : true,
907 'disallow_today' : true,
908 'default_time' : '00:00:00',
909 'time_readonly' : false
912 if (my_xulG.complete) {
913 circ.util.batch_hold_update(
915 { 'expire_time' : my_xulG.timestamp },
916 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
920 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
924 'cmd_holds_edit_shelf_expire_time' : [
928 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
929 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
930 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
931 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
932 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
933 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
935 JSAN.use('util.window'); var win = new util.window();
936 var my_xulG = win.open(
937 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
940 'description' : desc,
942 'allow_unset' : false,
943 'disallow_future_dates' : false,
944 'disallow_past_dates' : false,
945 'disallow_today' : false
948 if (my_xulG.complete) {
949 circ.util.batch_hold_update(
951 { 'shelf_expire_time' : my_xulG.timestamp },
952 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
956 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
960 'cmd_holds_edit_request_date' : [
964 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
965 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
966 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
967 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
968 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
969 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
971 JSAN.use('util.window'); var win = new util.window();
972 var my_xulG = win.open(
973 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
976 'description' : desc,
978 'allow_unset' : false,
979 'disallow_future_dates' : true,
980 'disallow_past_dates' : false,
981 'disallow_today' : false
984 if (my_xulG.complete) {
985 circ.util.batch_hold_update(
987 { 'request_time' : my_xulG.timestamp },
988 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
992 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
996 'cmd_holds_retarget' : [
1000 JSAN.use('util.functional');
1002 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1004 if(obj.retrieve_ids.length > 1) {
1005 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
1007 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
1009 var r = obj.error.yns_alert(msg,
1010 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
1011 $("commonStrings").getString('common.yes'),
1012 $("commonStrings").getString('common.no'),
1014 $("commonStrings").getString('common.check_to_confirm')
1017 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1018 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
1019 if (typeof robj.ilsevent != 'undefined') throw(robj);
1021 obj.clear_and_retrieve();
1024 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
1030 'cmd_holds_cancel' : [
1034 JSAN.use('util.functional');
1036 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1038 if(obj.retrieve_ids.length > 1 ) {
1039 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
1041 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
1044 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1045 JSAN.use('util.window');
1046 var win = new util.window();
1047 var my_xulG = win.open(
1048 urls.XUL_HOLD_CANCEL,
1050 'chrome,resizable,modal',
1053 /*var r = obj.error.yns_alert(msg,
1054 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1055 $("commonStrings").getString('common.yes'),
1056 $("commonStrings").getString('common.no'),
1058 $("commonStrings").getString('common.check_to_confirm')
1061 if (my_xulG.proceed) {
1063 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1064 var transit = obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit();
1065 if (transit && ! transit.dest_recv_time() ) {
1066 transits.push( obj.retrieve_ids[i].barcode );
1068 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1069 if (typeof robj.ilsevent != 'undefined') throw(robj);
1071 if (transits.length > 0) {
1072 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1073 var r2 = obj.error.yns_alert(msg2,
1074 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1075 $("commonStrings").getString('common.yes'),
1076 $("commonStrings").getString('common.no'),
1078 $("commonStrings").getString('common.check_to_confirm'));
1081 for (var i = 0; i < transits.length; i++) {
1082 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1083 if (typeof robj.ilsevent != 'undefined') {
1084 switch(Number(robj.ilsevent)) {
1085 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1088 case 5000 /* PERM_FAILURE */ :
1097 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1101 obj.clear_and_retrieve();
1104 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1108 'cmd_holds_uncancel' : [
1112 JSAN.use('util.functional');
1113 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1114 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1115 if (typeof robj.ilsevent != 'undefined') throw(robj);
1117 obj.clear_and_retrieve();
1119 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1124 'cmd_retrieve_patron' : [
1129 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1130 var patron_id = obj.retrieve_ids[i].usr;
1131 if (seen[patron_id]) continue; seen[patron_id] = true;
1132 xulG.new_patron_tab(
1134 { 'id' : patron_id }
1138 obj.error.standard_unexpected_error_alert('',E);
1142 'cmd_show_catalog' : [
1146 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1147 var htarget = obj.retrieve_ids[i].target;
1148 var htype = obj.retrieve_ids[i].type;
1152 opac_url = xulG.url_prefix( urls.opac_rresult_metarecord ) + htarget;
1156 opac_url = xulG.url_prefix( urls.opac_rdetail ) + htarget;
1159 opac_url = xulG.url_prefix( urls.opac_rdetail )
1160 + obj.hold_subscription_map[ obj.retrieve_ids[i].id ].record_entry();
1163 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1164 opac_url = xulG.url_prefix( urls.opac_rdetail) + my_acn.record();
1169 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1171 if (typeof my_acp.call_number() == 'object') {
1172 my_acn = my.acp.call_number();
1174 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1175 [ my_acp.call_number() ]);
1177 opac_url = xulG.url_prefix( urls.opac_rdetail) + my_acn.record();
1180 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1184 var content_params = {
1186 'authtime' : ses('authtime'),
1187 'opac_url' : opac_url
1190 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1191 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1196 obj.error.standard_unexpected_error_alert('',E);
1200 'cmd_holds_title_transfer' : [
1205 var unique_targets = [];
1206 var seen_target = {};
1207 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1208 var hid = obj.retrieve_ids[i].id;
1209 var htarget = obj.retrieve_ids[i].id;
1210 var htype = obj.retrieve_ids[i].type;
1213 continue; // not supported
1217 if (! seen_target[htarget]) {
1218 unique_targets.push( htarget );
1219 seen_target[htarget] = 1;
1223 continue; // not supported
1226 continue; // not supported
1229 continue; // not supported
1233 JSAN.use('cat.util');
1234 cat.util.transfer_specific_title_holds(hids,unique_targets);
1235 obj.clear_and_retrieve();
1237 obj.error.standard_unexpected_error_alert('',E);
1245 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1249 'lib_filter_checkbox' : [
1252 var x_lib_type_menu = document.getElementById('lib_type_menu');
1253 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1254 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1255 obj.clear_and_retrieve();
1256 ev.target.setAttribute('checked',ev.target.checked);
1259 'cmd_view_expired_onshelf_holds' : [
1262 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1263 obj.expired = x.checked;
1264 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1265 obj.clear_and_retrieve();
1268 'cmd_clear_expired_onshelf_holds' : [
1271 obj.cmd_clear_expired_onshelf_holds();
1274 'cmd_search_opac' : [
1278 var use_url = urls.browser;
1279 use_url += use_url.match(/\?/) ? "&" : "?";
1280 use_url += "patron_barcode=" + obj.patron_barcode;
1281 var content_params = {
1282 'show_nav_buttons' : false,
1283 'show_print_button' : true,
1284 'passthru_content_params' : {
1285 'authtoken' : ses(),
1286 'authtime' : ses('authtime'),
1287 'window_open' : function(a,b,c) {
1289 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1290 return window.open(a,b,c);
1292 obj.error.standard_unexpected_error_alert('window_open',E);
1295 'opac_hold_placed' : function(hold) {
1301 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1306 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1307 window.xulG.on_list_change();
1310 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1313 'patron_barcode' : obj.patron_barcode
1315 'url_prefix' : xulG.url_prefix,
1316 'url' : xulG.url_prefix(use_url)
1318 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1320 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1329 obj.determine_hold_interface_type();
1330 var x_fetch_more = document.getElementById('fetch_more');
1331 var x_lib_type_menu = document.getElementById('lib_type_menu');
1332 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1333 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1334 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1335 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1336 var x_expired_checkbox = document.getElementById('expired_checkbox');
1337 var x_print_full_pull_list = document.getElementById('print_full_btn');
1338 var x_print_full_pull_list_alt = document.getElementById('print_alt_btn');
1339 switch(obj.hold_interface_type) {
1341 obj.render_lib_menus({'pickup_lib':true});
1342 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1343 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1344 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1345 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1346 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1349 if (x_fetch_more) x_fetch_more.hidden = false;
1350 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1351 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = false;
1352 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1353 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1356 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1357 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1358 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1359 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1360 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1363 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1364 if (x_fetch_more) x_fetch_more.hidden = true;
1365 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1366 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1367 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1368 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1371 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
1373 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1374 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1375 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1377 obj.controller.render();
1380 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1381 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1382 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1383 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1384 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1385 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1386 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1387 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1388 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1389 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1390 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1391 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1392 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1396 $('cmd_alt_view').setAttribute('disabled','true');
1397 xulG.when_done = function() {
1398 $('cmd_alt_view').setAttribute('ready','true');
1399 if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1400 $('cmd_alt_view').setAttribute('disabled','false');
1402 dump('hold details UI ready\n');
1404 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1405 JSAN.use('util.browser');
1406 obj.browser = new util.browser();
1409 'url' : urls.XUL_HOLD_DETAILS,
1411 'alt_print' : false,
1412 'browser_id' : 'hold_detail_frame',
1413 'passthru_content_params' : xulG
1419 'determine_hold_interface_type' : function() {
1421 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1422 obj.hold_interface_type = 'patron';
1423 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1424 obj.hold_interface_type = 'record';
1425 } else if (obj.pull) { /*************************************************** PULL ******************************/
1426 obj.hold_interface_type = 'pull';
1427 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1428 obj.hold_interface_type = 'shelf';
1429 } else { /*************************************************** PULL ******************************/
1430 obj.hold_interface_type = 'pull';
1434 'clear_and_retrieve' : function() {
1437 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1439 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1440 window.xulG.on_list_change();
1443 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1447 'retrieve' : function() {
1448 var obj = this; var holds = [];
1449 if (window.xulG && window.xulG.holds) {
1450 holds = window.xulG.holds;
1452 var method; var params = [ ses() ];
1453 switch(obj.hold_interface_type) {
1455 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1456 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1458 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1460 params.push( obj.patron_id );
1461 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1464 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1465 params.push( obj.docid );
1466 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1467 var x_lib_type_menu = document.getElementById('lib_type_menu');
1469 if (x_lib_filter.checked) {
1470 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1472 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1477 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1481 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1483 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1485 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1486 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1490 method = 'FM_AHR_ID_LIST_PULL_LIST';
1491 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1492 var x = document.getElementById('hold_count');
1494 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1495 var count = req.getResultObject();
1496 if (typeof count.ilsevent == 'undefined' && count != null) {
1497 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1498 'staff.patron.holds.total_count',
1507 var robj = obj.network.simple_request( method, params );
1508 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1509 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1512 holds = holds.concat( robj.copy_holds );
1513 holds = holds.concat( robj.recall_holds );
1514 holds = holds.concat( robj.force_holds );
1515 holds = holds.concat( robj.volume_holds );
1516 holds = holds.concat( robj.title_holds );
1517 holds = holds.concat( robj.part_holds );
1518 holds = holds.concat( robj.issuance_holds );
1519 holds = holds.concat( robj.metarecord_holds );
1520 holds = holds.sort();
1523 if (robj == null ) {
1526 if (typeof robj.length == 'undefined') {
1534 //alert('method = ' + method + ' params = ' + js2JSON(params));
1537 var x_fetch_more = document.getElementById('fetch_more');
1538 if (holds.length == 0) {
1539 if (x_fetch_more) x_fetch_more.disabled = true;
1541 if (x_fetch_more) x_fetch_more.disabled = false;
1547 'render' : function(holds) {
1551 function list_append(hold_id) {
1556 'hold_id' : hold_id,
1557 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1565 function gen_list_append(hold) {
1567 if (typeof obj.controller.view.lib_menu == 'undefined') {
1568 list_append(typeof hold == 'object' ? hold.id() : hold);
1570 list_append(typeof hold == 'object' ? hold.id() : hold);
1577 JSAN.use('util.exec'); var exec = new util.exec(2);
1579 for (var i in holds) {
1580 rows.push( gen_list_append(holds[i]) );
1585 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1589 'render_lib_menus' : function(types) {
1592 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1594 var x = document.getElementById('lib_type_menu');
1596 var nodes = x.firstChild.childNodes;
1597 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1598 for (var i in types) document.getElementById(i).hidden = false;
1600 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1602 x = document.getElementById('lib_menu_placeholder');
1603 util.widgets.remove_children( x );
1605 JSAN.use('util.file');
1606 var file = new util.file('offline_ou_list');
1607 if (file._file.exists()) {
1608 var list_data = file.get_object(); file.close();
1609 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1610 ml.setAttribute('id','lib_menu');
1611 x.appendChild( ml );
1612 ml.addEventListener(
1615 obj.filter_lib = ev.target.value;
1616 obj.clear_and_retrieve();
1620 obj.controller.view.lib_menu = ml;
1622 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1626 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1630 'cmd_clear_expired_onshelf_holds' : function() {
1633 // Disable anything such as filters that can have us accidentally
1634 // lose these non-repeatable results. Well, now that they're cached
1635 // it's less of an issue.
1636 if ($('lib_filter_checkbox')) {
1637 $('lib_filter_checkbox').checked = false;
1639 if ($('lib_type_menu')) {
1640 $('lib_type_menu').disabled = true;
1642 if ($('lib_menu_placeholder')) {
1643 $('lib_menu_placeholder').firstChild.disabled = true;
1645 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute(
1646 'disabled', 'true');
1647 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute(
1648 'disabled', 'true');
1650 // I could put this with the "retrieval" methods, but since it has
1651 // side effects, seems cleaner to invoke it here
1652 var robj = obj.network.simple_request(
1656 obj.filter_lib || obj.data.list.au[0].ws_ou()
1659 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1660 if (typeof robj.cache_key == 'undefined') { throw(robj); }
1662 var cache_key = robj.cache_key;
1664 // id's in xulG.holds will prevent the normal retrieval method from
1665 // firing. Let's put our affected hold.id's in here:
1668 // Start the progress meter
1669 $('progress').value = 0;
1670 $('progress').hidden = false;
1672 // Fetch the affected holds
1673 fieldmapper.standardRequest(
1674 [ 'open-ils.circ', 'open-ils.circ.hold.clear_shelf.get_cache' ],
1677 'params' : [ ses(), cache_key ],
1678 'onresponse' : function(r) {
1680 openils.Util.readResponse(r),
1683 $('progress').value = Number(resp.progress)
1687 obj.post_clear_shelf_hold_action_map[
1688 resp.hold_details.id
1690 xulG.holds.push( resp.hold_details.id );
1694 'oncomplete' : function() {
1695 obj.clear_and_retrieve();
1696 $('progress').hidden = true;
1702 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) {
1703 return; /* handled by network.js */
1705 obj.error.standard_unexpected_error_alert(
1706 'Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1711 dump('exiting patron.holds.js\n');