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' : {},
28 'post_clear_shelf_hold_action_map' : {},
34 'flatten_copy' : function(hold) {
35 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); }
39 'init' : function( params ) {
43 dojo.require("openils.Util");
45 obj.patron_id = params['patron_id'];
46 obj.patron_barcode = params['patron_barcode'];
47 obj.docid = params['docid'];
48 obj.shelf = params['shelf'];
49 obj.tree_id = params['tree_id'];
51 var progressmeter = document.getElementById('progress');
53 JSAN.use('circ.util');
54 var columns = circ.util.hold_columns(
56 'title' : { 'hidden' : false, 'flex' : '3' },
57 'request_time' : { 'hidden' : false },
58 'pickup_lib_shortname' : { 'hidden' : false },
59 'hold_type' : { 'hidden' : false },
60 'current_copy' : { 'hidden' : false },
61 'capture_time' : { 'hidden' : false },
62 'notify_time' : { 'hidden' : false },
63 'notify_count' : { 'hidden' : false },
64 'cancel_cause' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
65 'cancel_note' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
66 'cancel_time' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
67 'post_clear_shelf_action' : { 'hidden' : obj.shelf ? false : true }
71 JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
74 'columns' : columns.concat(
75 obj.list.fm_columns('acp', {
76 '*' : { 'expanded_label' : true, 'hidden' : true },
77 // example of unhiding some columns by default
78 // 'acp_circ_modifier' : { 'hidden' : false }
81 'retrieve_row' : function(params) {
84 obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
87 var blob = blob_req.getResultObject();
88 if (typeof blob.ilsevent != 'undefined') throw(blob);
89 row.my.ahr = blob.hold;
90 row.my.status = blob.status;
91 row.my.ahr.status( blob.status );
92 row.my.acp = blob.copy;
93 row.my.acn = blob.volume;
94 row.my.mvr = blob.mvr;
95 row.my.part = blob.part;
97 obj.hold_part_map[ row.my.hold_id ] = row.my.part;
99 row.my.issuance = blob.issuance;
101 row.my.subscription = blob.issuance.subscription();
102 obj.hold_subscription_map[ row.my.hold_id ] = row.my.subscription;
104 row.my.patron_family_name = blob.patron_last;
105 row.my.patron_first_given_name = blob.patron_first;
106 row.my.patron_barcode = blob.patron_barcode;
107 row.my.patron_alias = blob.patron_alias;
108 row.my.total_holds = blob.total_holds;
109 row.my.queue_position = blob.queue_position;
110 row.my.potential_copies = blob.potential_copies;
111 row.my.estimated_wait = blob.estimated_wait;
112 row.my.ahrn_count = blob.hold.notes().length;
114 var copy_id = row.my.ahr.current_copy();
115 if (typeof copy_id == 'object') {
116 if (copy_id == null) {
117 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
119 copy_id = copy_id.id();
122 copy_id = row.my.acp.id();
125 obj.holds_map[ row.my.ahr.id() ] = blob;
126 params.row_node.setAttribute('retrieve_id',
129 'barcode':row.my.acp ? row.my.acp.barcode() : null,
130 'id':row.my.ahr.id(),
131 'type':row.my.ahr.hold_type(),
132 'target':row.my.ahr.target(),
133 'usr':row.my.ahr.usr()
136 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
139 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
144 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
148 'on_select' : function(ev) {
149 JSAN.use('util.functional');
150 var sel = obj.list.retrieve_selection();
151 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
152 obj.retrieve_ids = util.functional.map_list(
154 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
156 if (obj.retrieve_ids.length > 0) {
157 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
158 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
159 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
160 obj.controller.view.sel_patron.setAttribute('disabled','false');
161 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
162 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
163 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
164 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
165 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
166 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
167 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
168 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
169 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
170 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
171 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
172 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
173 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','false');
174 if (obj.controller.view.cmd_alt_view.getAttribute('ready')=='true') {
175 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
177 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
178 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
179 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
180 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
182 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
183 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
184 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
185 obj.controller.view.sel_patron.setAttribute('disabled','true');
186 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
187 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
188 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
189 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
190 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
191 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
192 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
193 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
194 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
195 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
196 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
197 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
198 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
199 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','true');
200 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
201 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
202 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
203 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
209 JSAN.use('util.controller'); obj.controller = new util.controller();
213 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
216 function() { obj.list.clipboard(); }
220 function() { alert($("commonStrings").getString('common.unimplemented')); }
225 JSAN.use('circ.util');
226 circ.util.show_last_few_circs(obj.retrieve_ids);
232 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
233 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
240 var n = obj.controller.view.alt_view_btn;
241 if (n.getAttribute('toggle') == '1') {
242 document.getElementById('deck').selectedIndex = 0;
243 n.setAttribute('toggle','0');
244 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
245 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
246 obj.controller.view.save_columns.setAttribute('disabled','false');
248 document.getElementById('deck').selectedIndex = 1;
249 n.setAttribute('toggle','1');
250 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
251 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
252 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
253 if (obj.retrieve_ids.length == 0) return;
254 var f = obj.browser.get_content();
255 xulG.ahr_id = obj.retrieve_ids[0].id;
256 xulG.blob = obj.holds_map[ xulG.ahr_id ];
257 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
258 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
260 f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
261 f.fetch_and_render_all(true);
262 obj.controller.view.save_columns.setAttribute('disabled','true');
265 alert('Error in holds.js, cmd_alt_view handler: ' + E);
269 'cmd_cancelled_holds_view' : [
272 document.getElementById('show_cancelled_deck').selectedIndex = 1;
273 /* For some reason attribute propogation on the <command> element isn't working with hidden */
274 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
275 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
276 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
277 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
278 obj.clear_and_retrieve();
281 'cmd_uncancelled_holds_view' : [
284 document.getElementById('show_cancelled_deck').selectedIndex = 0;
285 /* For some reason attribute propogation on the <command> element isn't working with hidden */
286 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
287 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
288 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
289 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
290 obj.clear_and_retrieve();
293 'sel_mark_items_damaged' : [
296 JSAN.use('cat.util'); JSAN.use('util.functional');
297 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
300 'sel_mark_items_missing' : [
303 JSAN.use('cat.util'); JSAN.use('util.functional');
304 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
307 'sel_copy_details' : [
310 JSAN.use('circ.util');
311 circ.util.item_details_new(
312 util.functional.map_list(
314 function(o) { return o.barcode; }
319 'cmd_holds_print_full' : [
322 var x_print_full_pull_list = document.getElementById('print_full_btn');
325 progressmeter.mode = 'undetermined';
326 progressmeter.hidden = false;
327 x_print_full_pull_list.disabled = true;
329 JSAN.use('util.print');
330 var print = new util.print('default');
331 var robj = fieldmapper.standardRequest(
332 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
339 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
340 print.simple( robj.template_output().data() );
343 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
346 progressmeter.mode = 'determined';
347 progressmeter.hidden = true;
348 x_print_full_pull_list.disabled = false;
352 'cmd_holds_print_alt' : [
356 var content_params = {
358 "authtime": ses("authtime"),
360 "show_nav_buttons": true,
361 "show_print_button": true
363 ["url_prefix", "new_tab", "set_tab",
364 "close_tab", "new_patron_tab",
365 "set_patron_tab", "volume_item_creator",
367 "holdings_maintenance_tab", "set_tab_name",
368 "open_chrome_window", "url_prefix",
369 "network_meter", "page_meter",
370 "set_statusbar", "set_help_context"
371 ].forEach(function(k) {
372 content_params[k] = xulG[k];
375 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
376 xulG.url_prefix("/opac/extras/circ/alt_holds_print.html").replace("http:","https:")
380 "tab_name": "Printable Pull List", /* XXX i18n */
385 g.error.sdump("D_ERROR", E);
389 'cmd_holds_print' : [
393 JSAN.use('patron.util');
395 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
398 obj.list.print(params);
400 obj.error.standard_unexpected_error_alert('print 1',E);
404 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
405 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
406 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
408 'cmd_holds_edit_selection_depth' : [
412 JSAN.use('util.widgets'); JSAN.use('util.functional');
413 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
414 var list = util.functional.map_list(
415 util.functional.filter_list(
418 if (o.depth() > ws_type.depth()) return false;
419 if (o.depth() < ws_type.depth()) return true;
420 return (o.id() == ws_type.id());
432 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
433 ml.setAttribute('id','selection');
434 ml.setAttribute('name','fancy_data');
435 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
436 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
437 xml += util.widgets.serialize_node(ml);
439 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
440 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
441 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
442 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
443 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
444 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
445 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
446 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
447 JSAN.use('util.window'); var win = new util.window();
448 var fancy_prompt_data = win.open(
449 urls.XUL_FANCY_PROMPT,
450 //+ '?xml_in_stash=temp_mid'
451 //+ '&bottom_xml_in_stash=temp_bot'
452 //+ '&title=' + window.escape('Choose a Pick Up Library'),
453 'fancy_prompt', 'chrome,resizable,modal',
454 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
456 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
457 var selection = fancy_prompt_data.selection;
459 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
461 if(obj.retrieve_ids.length > 1) {
462 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
464 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
467 var r = obj.error.yns_alert(msg,
468 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
469 $("commonStrings").getString('common.yes'),
470 $("commonStrings").getString('common.no'),
472 $("commonStrings").getString('common.check_to_confirm')
475 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
478 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
483 'cmd_holds_edit_pickup_lib' : [
487 JSAN.use('util.widgets'); JSAN.use('util.functional');
489 var list = util.functional.map_list(
492 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
494 o.name() ? sname + ' ' + o.name() : o.shortname(),
496 ( !isTrue(obj.data.hash.aout[ o.ou_type() ].can_have_users()) ),
497 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
501 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
502 ml.setAttribute('id','lib');
503 ml.setAttribute('name','fancy_data');
504 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
505 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
506 xml += util.widgets.serialize_node(ml);
508 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
509 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
510 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
511 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
512 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
513 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
514 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
515 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
516 JSAN.use('util.window'); var win = new util.window();
517 var fancy_prompt_data = win.open(
518 urls.XUL_FANCY_PROMPT,
519 //+ '?xml_in_stash=temp_mid'
520 //+ '&bottom_xml_in_stash=temp_bot'
521 //+ '&title=' + window.escape('Choose a Pick Up Library'),
522 'fancy_prompt', 'chrome,resizable,modal',
523 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
525 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
526 var pickup_lib = fancy_prompt_data.lib;
528 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
530 if(obj.retrieve_ids.length > 1) {
531 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()]);
533 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()]);
535 var r = obj.error.yns_alert(msg,
536 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
537 $("commonStrings").getString('common.yes'),
538 $("commonStrings").getString('common.no'),
540 $("commonStrings").getString('common.check_to_confirm')
543 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
546 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
550 'cmd_holds_edit_phone_notify' : [
554 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
555 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
556 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
558 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
559 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
560 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
561 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
562 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
563 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
564 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
565 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
566 JSAN.use('util.window'); var win = new util.window();
567 var fancy_prompt_data = win.open(
568 urls.XUL_FANCY_PROMPT,
569 //+ '?xml_in_stash=temp_mid'
570 //+ '&bottom_xml_in_stash=temp_bot'
571 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
573 'fancy_prompt', 'chrome,resizable,modal',
574 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
576 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
577 var phone = fancy_prompt_data.phone;
579 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
581 if(obj.retrieve_ids.length > 1) {
582 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
584 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
586 var r = obj.error.yns_alert(msg,
587 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
588 $("commonStrings").getString('common.yes'),
589 $("commonStrings").getString('common.no'),
591 $("commonStrings").getString('common.check_to_confirm')
594 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
597 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
602 'cmd_holds_edit_sms_notify' : [
606 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
607 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.new_phone_number')+'</description>';
608 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
610 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
611 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_done.label')+'"';
612 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
613 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_cancel.label')+'"';
614 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
615 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
616 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
617 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
618 JSAN.use('util.window'); var win = new util.window();
619 var fancy_prompt_data = win.open(
620 urls.XUL_FANCY_PROMPT,
621 //+ '?xml_in_stash=temp_mid'
622 //+ '&bottom_xml_in_stash=temp_bot'
623 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
625 'fancy_prompt', 'chrome,resizable,modal',
626 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.choose_phone_number'), 'focus' : 'phone' }
628 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
629 var phone = fancy_prompt_data.phone;
631 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
633 if(obj.retrieve_ids.length > 1) {
634 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
636 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
638 var r = obj.error.yns_alert(msg,
639 $("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.modifying_holds_title'),
640 $("commonStrings").getString('common.yes'),
641 $("commonStrings").getString('common.no'),
643 $("commonStrings").getString('common.check_to_confirm')
647 'sms_notify' : phone == '' ? null : phone
650 hparams.sms_carrier = null;
652 circ.util.batch_hold_update(hold_list, hparams, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
655 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
660 'cmd_holds_edit_sms_carrier' : [
664 JSAN.use('util.widgets'); JSAN.use('util.functional');
666 var list = util.functional.map_list(
670 o.name() + ' (' + o.region() + ')',
672 ( !isTrue(o.active()) ),
677 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
678 ml.setAttribute('id','carrier');
679 ml.setAttribute('name','fancy_data');
680 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
681 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.new_carrier')+'</description>';
682 xml += util.widgets.serialize_node(ml);
684 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
685 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_done.label') +'"';
686 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_done.accesskey')+'" name="fancy_submit"/>';
687 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_cancel.label')+'"';
688 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
689 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
690 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
691 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
692 JSAN.use('util.window'); var win = new util.window();
693 var fancy_prompt_data = win.open(
694 urls.XUL_FANCY_PROMPT,
695 //+ '?xml_in_stash=temp_mid'
696 //+ '&bottom_xml_in_stash=temp_bot'
697 //+ '&title=' + window.escape('Choose a Pick Up Library'),
698 'fancy_prompt', 'chrome,resizable,modal',
699 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.choose_carrier') }
701 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
702 var sms_carrier = fancy_prompt_data.carrier;
704 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
707 if(obj.retrieve_ids.length > 1) {
708 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_carrier.confirm_carrier_change.plural',[hold_list.join(', '), obj.data.hash.csc[sms_carrier].name()]);
710 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_carrier.confirm_carrier_change.singular',[hold_list.join(', '), obj.data.hash.csc[sms_carrier].name()]);
712 var r = obj.error.yns_alert(msg,
713 $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.modifying_holds_title'),
714 $("commonStrings").getString('common.yes'),
715 $("commonStrings").getString('common.no'),
717 $("commonStrings").getString('common.check_to_confirm')
720 circ.util.batch_hold_update(hold_list, { 'sms_carrier' : sms_carrier }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
723 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
728 'cmd_holds_edit_email_notify' : [
732 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
733 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
734 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
735 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
736 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
737 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
739 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
740 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
741 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
742 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
743 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
744 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
745 JSAN.use('util.window'); var win = new util.window();
746 var fancy_prompt_data = win.open(
747 urls.XUL_FANCY_PROMPT,
748 //+ '?xml_in_stash=temp_mid'
749 //+ '&bottom_xml_in_stash=temp_bot'
750 //+ '&title=' + window.escape('Set Email Notification for Holds'),
751 'fancy_prompt', 'chrome,resizable,modal',
752 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
754 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
755 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
757 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
759 if(get_bool(email)) {
760 if(obj.retrieve_ids.length > 1) {
761 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
763 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
766 if(obj.retrieve_ids.length > 1) {
767 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
769 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
773 var r = obj.error.yns_alert(msg,
774 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
775 $("commonStrings").getString('common.yes'),
776 $("commonStrings").getString('common.no'),
778 $("commonStrings").getString('common.check_to_confirm')
781 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
784 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
788 'cmd_holds_cut_in_line' : [
792 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
793 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
794 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
795 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
796 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
797 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
799 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
800 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
801 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
802 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
803 JSAN.use('util.window'); var win = new util.window();
804 var fancy_prompt_data = win.open(
805 urls.XUL_FANCY_PROMPT,
806 'fancy_prompt', 'chrome,resizable,modal',
807 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
809 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
810 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
812 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
815 if(obj.retrieve_ids.length > 1) {
816 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
818 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
821 if(obj.retrieve_ids.length > 1) {
822 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
824 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
828 var r = obj.error.yns_alert(msg,
829 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
830 $("commonStrings").getString('common.yes'),
831 $("commonStrings").getString('common.no'),
833 $("commonStrings").getString('common.check_to_confirm')
836 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
839 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
843 'cmd_holds_edit_desire_mint_condition' : [
847 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
848 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
849 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
850 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
851 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
852 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
854 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
855 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
856 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
857 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
858 JSAN.use('util.window'); var win = new util.window();
859 var fancy_prompt_data = win.open(
860 urls.XUL_FANCY_PROMPT,
861 'fancy_prompt', 'chrome,resizable,modal',
862 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
864 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
865 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
867 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
870 if(obj.retrieve_ids.length > 1) {
871 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
873 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
876 if(obj.retrieve_ids.length > 1) {
877 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
879 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
883 var r = obj.error.yns_alert(msg,
884 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
885 $("commonStrings").getString('common.yes'),
886 $("commonStrings").getString('common.no'),
888 $("commonStrings").getString('common.check_to_confirm')
891 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
894 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
900 'cmd_holds_suspend' : [
904 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
905 var r = obj.error.yns_alert(
906 obj.retrieve_ids.length > 1 ?
907 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
908 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
909 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
910 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
911 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
913 document.getElementById('commonStrings').getString('common.confirm')
916 var already_suspended = []; var filtered_hold_list = [];
917 for (var i = 0; i < obj.retrieve_ids.length; i++) {
918 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
919 if ( get_bool( hold.frozen() ) ) {
920 already_suspended.push( hold.id() );
923 filtered_hold_list.push( hold.id() );
925 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
926 if (already_suspended.length == 1) {
927 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
928 } else if (already_suspended.length > 1) {
929 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
931 obj.clear_and_retrieve(true);
935 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
939 'cmd_holds_activate' : [
943 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
944 var r = obj.error.yns_alert(
945 obj.retrieve_ids.length > 1 ?
946 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
947 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
948 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
949 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
950 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
952 document.getElementById('commonStrings').getString('common.confirm')
955 var already_activated = []; var filtered_hold_list = [];
956 for (var i = 0; i < obj.retrieve_ids.length; i++) {
957 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
958 if ( ! get_bool( hold.frozen() ) ) {
959 already_activated.push( hold.id() );
962 filtered_hold_list.push( hold.id() );
964 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
965 if (already_activated.length == 1) {
966 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
967 } else if (already_activated.length > 1) {
968 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
970 obj.clear_and_retrieve(true);
974 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
978 'cmd_holds_edit_thaw_date' : [
982 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
983 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
984 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
985 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
986 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
987 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
989 JSAN.use('util.window'); var win = new util.window();
990 var my_xulG = win.open(
991 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
994 'description' : desc,
996 'allow_unset' : true,
997 'disallow_future_dates' : false,
998 'disallow_past_dates' : true,
999 'disallow_today' : true,
1000 'default_time' : '00:00:00',
1001 'time_readonly' : false
1004 if (my_xulG.complete) {
1005 circ.util.batch_hold_update(
1007 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
1008 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1012 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1016 'cmd_holds_edit_expire_time' : [
1020 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1021 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
1022 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
1023 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1024 var value = 'YYYY-MM-DD';
1025 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1026 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
1028 JSAN.use('util.window'); var win = new util.window();
1029 var my_xulG = win.open(
1030 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
1033 'description' : desc,
1035 'allow_unset' : true,
1036 'disallow_future_dates' : false,
1037 'disallow_past_dates' : true,
1038 'disallow_today' : true,
1039 'default_time' : '00:00:00',
1040 'time_readonly' : false
1043 if (my_xulG.complete) {
1044 circ.util.batch_hold_update(
1046 { 'expire_time' : my_xulG.timestamp },
1047 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1051 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1055 'cmd_holds_edit_shelf_expire_time' : [
1059 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1060 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
1061 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
1062 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1063 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1064 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
1066 JSAN.use('util.window'); var win = new util.window();
1067 var my_xulG = win.open(
1068 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
1071 'description' : desc,
1073 'allow_unset' : false,
1074 'disallow_future_dates' : false,
1075 'disallow_past_dates' : false,
1076 'disallow_today' : false
1079 if (my_xulG.complete) {
1080 circ.util.batch_hold_update(
1082 { 'shelf_expire_time' : my_xulG.timestamp },
1083 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1087 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1091 'cmd_holds_edit_request_date' : [
1095 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1096 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
1097 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
1098 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1099 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1100 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
1102 JSAN.use('util.window'); var win = new util.window();
1103 var my_xulG = win.open(
1104 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
1107 'description' : desc,
1109 'allow_unset' : false,
1110 'disallow_future_dates' : true,
1111 'disallow_past_dates' : false,
1112 'disallow_today' : false
1115 if (my_xulG.complete) {
1116 circ.util.batch_hold_update(
1118 { 'request_time' : my_xulG.timestamp },
1119 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1123 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1127 'cmd_holds_retarget' : [
1131 JSAN.use('util.functional');
1133 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1135 if(obj.retrieve_ids.length > 1) {
1136 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
1138 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
1140 var r = obj.error.yns_alert(msg,
1141 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
1142 $("commonStrings").getString('common.yes'),
1143 $("commonStrings").getString('common.no'),
1145 $("commonStrings").getString('common.check_to_confirm')
1148 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1149 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
1150 if (typeof robj.ilsevent != 'undefined') throw(robj);
1152 obj.clear_and_retrieve();
1155 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
1161 'cmd_holds_cancel' : [
1165 JSAN.use('util.functional');
1167 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1169 if(obj.retrieve_ids.length > 1 ) {
1170 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
1172 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
1175 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1176 JSAN.use('util.window');
1177 var win = new util.window();
1178 var my_xulG = win.open(
1179 urls.XUL_HOLD_CANCEL,
1181 'chrome,resizable,modal',
1184 /*var r = obj.error.yns_alert(msg,
1185 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1186 $("commonStrings").getString('common.yes'),
1187 $("commonStrings").getString('common.no'),
1189 $("commonStrings").getString('common.check_to_confirm')
1192 if (my_xulG.proceed) {
1194 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1195 var transit = obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit();
1196 if (transit && ! transit.dest_recv_time() ) {
1197 transits.push( obj.retrieve_ids[i].barcode );
1199 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1200 if (typeof robj.ilsevent != 'undefined') throw(robj);
1202 if (transits.length > 0) {
1203 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1204 var r2 = obj.error.yns_alert(msg2,
1205 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1206 $("commonStrings").getString('common.yes'),
1207 $("commonStrings").getString('common.no'),
1209 $("commonStrings").getString('common.check_to_confirm'));
1212 for (var i = 0; i < transits.length; i++) {
1213 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1214 if (typeof robj.ilsevent != 'undefined') {
1215 switch(Number(robj.ilsevent)) {
1216 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1219 case 5000 /* PERM_FAILURE */ :
1228 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1232 obj.clear_and_retrieve();
1235 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1239 'cmd_holds_uncancel' : [
1243 JSAN.use('util.functional');
1244 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1245 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1246 if (typeof robj.ilsevent != 'undefined') throw(robj);
1248 obj.clear_and_retrieve();
1250 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1255 'cmd_retrieve_patron' : [
1260 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1261 var patron_id = obj.retrieve_ids[i].usr;
1262 if (seen[patron_id]) continue; seen[patron_id] = true;
1263 xulG.new_patron_tab(
1265 { 'id' : patron_id }
1269 obj.error.standard_unexpected_error_alert('',E);
1273 'cmd_show_catalog' : [
1277 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1278 var htarget = obj.retrieve_ids[i].target;
1279 var htype = obj.retrieve_ids[i].type;
1283 opac_url = xulG.url_prefix( urls.opac_rresult_metarecord ) + htarget;
1286 opac_url = xulG.url_prefix( urls.opac_rdetail ) + htarget;
1289 opac_url = xulG.url_prefix( urls.opac_rdetail )
1290 + obj.hold_part_map[ obj.retrieve_ids[i].id ].record();
1293 opac_url = xulG.url_prefix( urls.opac_rdetail )
1294 + obj.hold_subscription_map[ obj.retrieve_ids[i].id ].record_entry();
1297 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1298 opac_url = xulG.url_prefix( urls.opac_rdetail) + my_acn.record();
1303 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1305 if (typeof my_acp.call_number() == 'object') {
1306 my_acn = my.acp.call_number();
1308 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1309 [ my_acp.call_number() ]);
1311 opac_url = xulG.url_prefix( urls.opac_rdetail) + my_acn.record();
1314 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1318 var content_params = {
1320 'authtime' : ses('authtime'),
1321 'opac_url' : opac_url
1324 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1325 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1330 obj.error.standard_unexpected_error_alert('',E);
1334 'cmd_holds_title_transfer' : [
1339 var unique_targets = [];
1340 var seen_target = {};
1341 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1342 var hid = obj.retrieve_ids[i].id;
1343 var htarget = obj.retrieve_ids[i].id;
1344 var htype = obj.retrieve_ids[i].type;
1347 continue; // not supported
1351 if (! seen_target[htarget]) {
1352 unique_targets.push( htarget );
1353 seen_target[htarget] = 1;
1357 continue; // not supported
1360 continue; // not supported
1363 continue; // not supported
1367 JSAN.use('cat.util');
1368 cat.util.transfer_specific_title_holds(hids,unique_targets);
1369 obj.clear_and_retrieve();
1371 obj.error.standard_unexpected_error_alert('',E);
1379 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1383 'lib_filter_checkbox' : [
1386 var x_lib_type_menu = document.getElementById('lib_type_menu');
1387 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1388 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1389 obj.clear_and_retrieve();
1390 ev.target.setAttribute('checked',ev.target.checked);
1393 'cmd_view_expired_onshelf_holds' : [
1396 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1397 obj.expired = x.checked;
1398 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1399 obj.clear_and_retrieve();
1402 'cmd_clear_expired_onshelf_holds' : [
1405 obj.cmd_clear_expired_onshelf_holds();
1408 'cmd_search_opac' : [
1412 var use_url = urls.browser;
1413 use_url += use_url.match(/\?/) ? "&" : "?";
1414 use_url += "patron_barcode=" + obj.patron_barcode;
1415 var content_params = {
1416 'show_nav_buttons' : false,
1417 'show_print_button' : true,
1418 'passthru_content_params' : {
1419 'authtoken' : ses(),
1420 'authtime' : ses('authtime'),
1421 'window_open' : function(a,b,c) {
1423 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1424 return window.open(a,b,c);
1426 obj.error.standard_unexpected_error_alert('window_open',E);
1429 'opac_hold_placed' : function(hold) {
1435 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1440 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1441 window.xulG.on_list_change();
1444 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1447 'patron_barcode' : obj.patron_barcode
1449 'url_prefix' : xulG.url_prefix,
1450 'url' : xulG.url_prefix(use_url)
1452 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1454 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1463 obj.determine_hold_interface_type();
1464 var x_fetch_more = document.getElementById('fetch_more');
1465 var x_lib_type_menu = document.getElementById('lib_type_menu');
1466 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1467 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1468 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1469 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1470 var x_expired_checkbox = document.getElementById('expired_checkbox');
1471 var x_print_full_pull_list = document.getElementById('print_full_btn');
1472 var x_print_full_pull_list_alt = document.getElementById('print_alt_btn');
1473 switch(obj.hold_interface_type) {
1475 obj.render_lib_menus({'pickup_lib':true});
1476 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1477 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1478 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1479 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1480 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1483 if (x_fetch_more) x_fetch_more.hidden = false;
1484 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1485 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = false;
1486 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1487 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1490 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1491 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1492 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1493 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1494 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1497 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1498 if (x_fetch_more) x_fetch_more.hidden = true;
1499 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1500 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1501 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1502 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1505 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
1507 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1508 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1509 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1511 obj.controller.render();
1514 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1515 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1516 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1517 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1518 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1519 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1520 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1521 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1522 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1523 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1524 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1525 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1526 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1530 $('cmd_alt_view').setAttribute('disabled','true');
1531 xulG.when_done = function() {
1532 $('cmd_alt_view').setAttribute('ready','true');
1533 if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1534 $('cmd_alt_view').setAttribute('disabled','false');
1536 dump('hold details UI ready\n');
1538 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1539 JSAN.use('util.browser');
1540 obj.browser = new util.browser();
1543 'url' : urls.XUL_HOLD_DETAILS,
1545 'alt_print' : false,
1546 'browser_id' : 'hold_detail_frame',
1547 'passthru_content_params' : xulG
1553 'determine_hold_interface_type' : function() {
1555 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1556 obj.hold_interface_type = 'patron';
1557 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1558 obj.hold_interface_type = 'record';
1559 } else if (obj.pull) { /*************************************************** PULL ******************************/
1560 obj.hold_interface_type = 'pull';
1561 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1562 obj.hold_interface_type = 'shelf';
1563 } else { /*************************************************** PULL ******************************/
1564 obj.hold_interface_type = 'pull';
1568 'clear_and_retrieve' : function() {
1571 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1573 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1574 window.xulG.on_list_change();
1577 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1581 'retrieve' : function() {
1582 var obj = this; var holds = [];
1583 if (window.xulG && window.xulG.holds) {
1584 holds = window.xulG.holds;
1586 var method; var params = [ ses() ];
1587 switch(obj.hold_interface_type) {
1589 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1590 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1592 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1594 params.push( obj.patron_id );
1595 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1598 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1599 params.push( obj.docid );
1600 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1601 var x_lib_type_menu = document.getElementById('lib_type_menu');
1603 if (x_lib_filter.checked) {
1604 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1606 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1611 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1615 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1617 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1619 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1620 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1624 method = 'FM_AHR_ID_LIST_PULL_LIST';
1625 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1626 var x = document.getElementById('hold_count');
1628 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1629 var count = req.getResultObject();
1630 if (typeof count.ilsevent == 'undefined' && count != null) {
1631 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1632 'staff.patron.holds.total_count',
1641 var robj = obj.network.simple_request( method, params );
1642 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1643 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1646 holds = holds.concat( robj.copy_holds );
1647 holds = holds.concat( robj.recall_holds );
1648 holds = holds.concat( robj.force_holds );
1649 holds = holds.concat( robj.volume_holds );
1650 holds = holds.concat( robj.title_holds );
1651 holds = holds.concat( robj.part_holds );
1652 holds = holds.concat( robj.issuance_holds );
1653 holds = holds.concat( robj.metarecord_holds );
1654 holds = holds.sort();
1657 if (robj == null ) {
1660 if (typeof robj.length == 'undefined') {
1668 //alert('method = ' + method + ' params = ' + js2JSON(params));
1671 var x_fetch_more = document.getElementById('fetch_more');
1672 if (holds.length == 0) {
1673 if (x_fetch_more) x_fetch_more.disabled = true;
1675 if (x_fetch_more) x_fetch_more.disabled = false;
1681 'render' : function(holds) {
1685 function list_append(hold_id) {
1690 'hold_id' : hold_id,
1691 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1699 function gen_list_append(hold) {
1701 if (typeof obj.controller.view.lib_menu == 'undefined') {
1702 list_append(typeof hold == 'object' ? hold.id() : hold);
1704 list_append(typeof hold == 'object' ? hold.id() : hold);
1711 JSAN.use('util.exec'); var exec = new util.exec(2);
1713 for (var i in holds) {
1714 rows.push( gen_list_append(holds[i]) );
1719 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1723 'render_lib_menus' : function(types) {
1726 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1728 var x = document.getElementById('lib_type_menu');
1730 var nodes = x.firstChild.childNodes;
1731 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1732 for (var i in types) document.getElementById(i).hidden = false;
1734 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1736 x = document.getElementById('lib_menu_placeholder');
1737 util.widgets.remove_children( x );
1739 JSAN.use('util.file');
1740 var file = new util.file('offline_ou_list');
1741 if (file._file.exists()) {
1742 var list_data = file.get_object(); file.close();
1743 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1744 ml.setAttribute('id','lib_menu');
1745 x.appendChild( ml );
1746 ml.addEventListener(
1749 obj.filter_lib = ev.target.value;
1750 obj.clear_and_retrieve();
1754 obj.controller.view.lib_menu = ml;
1756 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1760 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1764 'cmd_clear_expired_onshelf_holds' : function() {
1767 // Disable anything such as filters that can have us accidentally
1768 // lose these non-repeatable results. Well, now that they're cached
1769 // it's less of an issue.
1770 if ($('lib_filter_checkbox')) {
1771 $('lib_filter_checkbox').checked = false;
1773 if ($('lib_type_menu')) {
1774 $('lib_type_menu').disabled = true;
1776 if ($('lib_menu_placeholder')) {
1777 $('lib_menu_placeholder').firstChild.disabled = true;
1779 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute(
1780 'disabled', 'true');
1781 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute(
1782 'disabled', 'true');
1784 // I could put this with the "retrieval" methods, but since it has
1785 // side effects, seems cleaner to invoke it here
1786 var robj = obj.network.simple_request(
1790 obj.filter_lib || obj.data.list.au[0].ws_ou()
1793 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1794 if (typeof robj.cache_key == 'undefined') { throw(robj); }
1796 var cache_key = robj.cache_key;
1798 // id's in xulG.holds will prevent the normal retrieval method from
1799 // firing. Let's put our affected hold.id's in here:
1802 // Start the progress meter
1803 $('progress').value = 0;
1804 $('progress').hidden = false;
1806 // Fetch the affected holds
1807 fieldmapper.standardRequest(
1808 [ 'open-ils.circ', 'open-ils.circ.hold.clear_shelf.get_cache' ],
1811 'params' : [ ses(), cache_key ],
1812 'onresponse' : function(r) {
1814 openils.Util.readResponse(r),
1817 $('progress').value = Number(resp.progress)
1821 obj.post_clear_shelf_hold_action_map[
1822 resp.hold_details.id
1824 xulG.holds.push( resp.hold_details.id );
1828 'oncomplete' : function() {
1829 obj.clear_and_retrieve();
1830 $('progress').hidden = true;
1836 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) {
1837 return; /* handled by network.js */
1839 obj.error.standard_unexpected_error_alert(
1840 'Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1845 dump('exiting patron.holds.js\n');