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 obj.determine_hold_interface_type();
53 var progressmeter = document.getElementById('progress');
55 JSAN.use('circ.util');
56 var columns = circ.util.hold_columns(
58 'title' : { 'hidden' : false, 'flex' : '3' },
59 'request_time' : { 'hidden' : false },
60 'pickup_lib_shortname' : { 'hidden' : false },
61 'hold_type' : { 'hidden' : false },
62 'current_copy' : { 'hidden' : false },
63 'capture_time' : { 'hidden' : false },
64 'notify_time' : { 'hidden' : false },
65 'notify_count' : { 'hidden' : false },
66 'cancel_cause' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
67 'cancel_note' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
68 'cancel_time' : { 'hidden' : ! ( obj.data.hash.aous['circ.holds.canceled.display_count'] || obj.data.hash.aous['circ.holds.canceled.display_age'] ) },
69 'post_clear_shelf_action' : { 'hidden' : obj.shelf ? false : true }
73 JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
76 'columns_saved_under' : 'holds_' + obj.hold_interface_type,
77 'columns' : columns.concat(
78 obj.list.fm_columns('acp', {
79 '*' : { 'expanded_label' : true, 'hidden' : true },
80 // example of unhiding some columns by default
81 // 'acp_circ_modifier' : { 'hidden' : false }
84 'retrieve_row' : function(params) {
87 obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
90 var blob = blob_req.getResultObject();
91 if (typeof blob.ilsevent != 'undefined') throw(blob);
92 row.my.ahr = blob.hold;
93 row.my.status = blob.status;
94 row.my.ahr.status( blob.status );
95 row.my.acp = blob.copy;
96 row.my.acn = blob.volume;
97 row.my.mvr = blob.mvr;
98 row.my.part = blob.part;
100 obj.hold_part_map[ row.my.hold_id ] = row.my.part;
102 row.my.issuance = blob.issuance;
104 row.my.subscription = blob.issuance.subscription();
105 obj.hold_subscription_map[ row.my.hold_id ] = row.my.subscription;
107 row.my.patron_family_name = blob.patron_last;
108 row.my.patron_first_given_name = blob.patron_first;
109 row.my.patron_barcode = blob.patron_barcode;
110 row.my.patron_alias = blob.patron_alias;
111 row.my.total_holds = blob.total_holds;
112 row.my.queue_position = blob.queue_position;
113 row.my.potential_copies = blob.potential_copies;
114 row.my.estimated_wait = blob.estimated_wait;
115 row.my.ahrn_count = blob.hold.notes().length;
117 var copy_id = row.my.ahr.current_copy();
118 if (typeof copy_id == 'object') {
119 if (copy_id == null) {
120 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
122 copy_id = copy_id.id();
125 copy_id = row.my.acp.id();
128 obj.holds_map[ row.my.ahr.id() ] = blob;
129 params.treeitem_node.setAttribute('retrieve_id',
132 'barcode':row.my.acp ? row.my.acp.barcode() : null,
133 'id':row.my.ahr.id(),
134 'type':row.my.ahr.hold_type(),
135 'target':row.my.ahr.target(),
136 'usr':row.my.ahr.usr()
139 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
142 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
147 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
151 'on_select' : function(ev) {
152 JSAN.use('util.functional');
153 var sel = obj.list.retrieve_selection();
154 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
155 obj.retrieve_ids = util.functional.map_list(
157 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
159 if (obj.retrieve_ids.length > 0) {
160 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
161 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
162 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
163 obj.controller.view.sel_patron.setAttribute('disabled','false');
164 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
165 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
166 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','false');
167 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
168 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
169 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
170 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
171 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','false');
172 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
173 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','false');
174 obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
175 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
176 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','false');
177 if (obj.controller.view.cmd_alt_view.getAttribute('ready')=='true') {
178 obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
180 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
181 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
182 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','false');
183 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
185 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
186 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
187 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
188 obj.controller.view.sel_patron.setAttribute('disabled','true');
189 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
190 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
191 obj.controller.view.cmd_holds_edit_desire_mint_condition.setAttribute('disabled','true');
192 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
193 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
194 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
195 obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
196 obj.controller.view.cmd_holds_edit_shelf_expire_time.setAttribute('disabled','true');
197 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
198 obj.controller.view.cmd_holds_edit_request_date.setAttribute('disabled','true');
199 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
200 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
201 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
202 obj.controller.view.cmd_alt_view.setAttribute('rendering_rows','true');
203 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
204 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
205 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
206 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
212 JSAN.use('util.controller'); obj.controller = new util.controller();
216 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
219 function() { obj.list.clipboard(); }
223 function() { alert($("commonStrings").getString('common.unimplemented')); }
228 JSAN.use('circ.util');
229 circ.util.show_last_few_circs(obj.retrieve_ids);
236 e.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
237 e.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
245 var n = obj.controller.view.alt_view_btn;
246 if (n.getAttribute('toggle') == '1') {
247 document.getElementById('deck').selectedIndex = 0;
248 n.setAttribute('toggle','0');
249 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.label'));
250 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.alt_view.accesskey'));
251 obj.controller.view.save_columns.setAttribute('disabled','false');
253 document.getElementById('deck').selectedIndex = 1;
254 n.setAttribute('toggle','1');
255 n.setAttribute('label', document.getElementById("circStrings").getString('staff.circ.holds.list_view.label'));
256 n.setAttribute('accesskey', document.getElementById("circStrings").getString('staff.circ.holds.list_view.accesskey'));
257 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
258 if (obj.retrieve_ids.length == 0) return;
259 var f = obj.browser.get_content();
260 xulG.ahr_id = obj.retrieve_ids[0].id;
261 xulG.blob = obj.holds_map[ xulG.ahr_id ];
262 xulG.patron_rendered_elsewhere = (obj.hold_interface_type == 'patron');
263 xulG.bib_rendered_elsewhere = (obj.hold_interface_type == 'record');
265 f.xulG.clear_and_retrieve = function() { obj.clear_and_retrieve(); };
266 f.fetch_and_render_all(true);
267 obj.controller.view.save_columns.setAttribute('disabled','true');
270 alert('Error in holds.js, cmd_alt_view handler: ' + E);
274 'cmd_cancelled_holds_view' : [
277 document.getElementById('show_cancelled_deck').selectedIndex = 1;
278 /* For some reason attribute propogation on the <command> element isn't working with hidden */
279 document.getElementById('holds_cancel_btn').setAttribute('hidden','true');
280 document.getElementById('holds_uncancel_btn').setAttribute('hidden','false');
281 document.getElementById('holds_cancel_btn2').setAttribute('hidden','true');
282 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','false');
283 obj.clear_and_retrieve();
286 'cmd_uncancelled_holds_view' : [
289 document.getElementById('show_cancelled_deck').selectedIndex = 0;
290 /* For some reason attribute propogation on the <command> element isn't working with hidden */
291 document.getElementById('holds_cancel_btn').setAttribute('hidden','false');
292 document.getElementById('holds_uncancel_btn').setAttribute('hidden','true');
293 document.getElementById('holds_cancel_btn2').setAttribute('hidden','false');
294 document.getElementById('holds_uncancel_btn2').setAttribute('hidden','true');
295 obj.clear_and_retrieve();
298 'sel_mark_items_damaged' : [
301 JSAN.use('cat.util'); JSAN.use('util.functional');
302 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
305 'sel_mark_items_missing' : [
308 JSAN.use('cat.util'); JSAN.use('util.functional');
309 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
312 'sel_copy_details' : [
315 JSAN.use('circ.util');
316 circ.util.item_details_new(
317 util.functional.map_list(
319 function(o) { return o.barcode; }
324 'cmd_holds_print_full' : [
327 var x_print_full_pull_list = document.getElementById('print_full_btn');
330 progressmeter.mode = 'undetermined';
331 progressmeter.hidden = false;
332 x_print_full_pull_list.disabled = true;
334 JSAN.use('util.print');
335 var print = new util.print('default');
336 var robj = fieldmapper.standardRequest(
337 [ api.HTML_HOLD_PULL_LIST.app, api.HTML_HOLD_PULL_LIST.method ],
344 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
345 print.simple( robj.template_output().data() );
348 obj.error.standard_unexpected_error_alert('cmd_holds_print_full',E);
351 progressmeter.mode = 'determined';
352 progressmeter.hidden = true;
353 x_print_full_pull_list.disabled = false;
357 'cmd_holds_print_alt' : [
361 var content_params = {
363 "authtime": ses("authtime"),
365 "show_nav_buttons": true,
366 "show_print_button": true
368 ["url_prefix", "new_tab", "set_tab",
369 "close_tab", "new_patron_tab",
370 "set_patron_tab", "volume_item_creator",
372 "holdings_maintenance_tab", "set_tab_name",
373 "open_chrome_window", "url_prefix",
374 "network_meter", "page_meter",
375 "set_statusbar", "set_help_context"
376 ].forEach(function(k) {
377 content_params[k] = xulG[k];
380 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
381 xulG.url_prefix("/opac/extras/circ/alt_holds_print.html").replace("http:","https:")
385 "tab_name": "Printable Pull List", /* XXX i18n */
390 g.error.sdump("D_ERROR", E);
394 'cmd_holds_print' : [
398 JSAN.use('patron.util');
400 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id)
402 switch(obj.hold_interface_type) {
404 params.template = 'holds_for_patron';
407 params.template = 'holds_on_bib';
410 params.template = 'holds_shelf';
414 params.template = 'holds_pull_list';
417 obj.list.print(params);
419 obj.error.standard_unexpected_error_alert('print 1',E);
423 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
424 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
425 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
427 'cmd_holds_edit_selection_depth' : [
431 JSAN.use('util.widgets'); JSAN.use('util.functional');
432 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
433 var list = util.functional.map_list(
434 util.functional.filter_list(
437 if (o.depth() > ws_type.depth()) return false;
438 if (o.depth() < ws_type.depth()) return true;
439 return (o.id() == ws_type.id());
451 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
452 ml.setAttribute('id','selection');
453 ml.setAttribute('name','fancy_data');
454 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
455 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
456 xml += util.widgets.serialize_node(ml);
458 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
459 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
460 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
461 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
462 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
463 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
464 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
465 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
466 JSAN.use('util.window'); var win = new util.window();
467 var fancy_prompt_data = win.open(
468 urls.XUL_FANCY_PROMPT,
469 //+ '?xml_in_stash=temp_mid'
470 //+ '&bottom_xml_in_stash=temp_bot'
471 //+ '&title=' + window.escape('Choose a Pick Up Library'),
472 'fancy_prompt', 'chrome,resizable,modal',
473 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
475 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
476 var selection = fancy_prompt_data.selection;
478 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
480 if(obj.retrieve_ids.length > 1) {
481 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
483 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
486 var r = obj.error.yns_alert(msg,
487 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
488 $("commonStrings").getString('common.yes'),
489 $("commonStrings").getString('common.no'),
491 $("commonStrings").getString('common.check_to_confirm')
494 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
497 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
502 'cmd_holds_edit_pickup_lib' : [
506 JSAN.use('util.widgets'); JSAN.use('util.functional');
508 var list = util.functional.map_list(
511 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
513 o.name() ? sname + ' ' + o.name() : o.shortname(),
515 ( !isTrue(obj.data.hash.aout[ o.ou_type() ].can_have_users()) ),
516 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
520 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
521 ml.setAttribute('id','lib');
522 ml.setAttribute('name','fancy_data');
523 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
524 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
525 xml += util.widgets.serialize_node(ml);
527 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
528 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
529 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
530 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
531 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
532 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
533 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
534 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
535 JSAN.use('util.window'); var win = new util.window();
536 var fancy_prompt_data = win.open(
537 urls.XUL_FANCY_PROMPT,
538 //+ '?xml_in_stash=temp_mid'
539 //+ '&bottom_xml_in_stash=temp_bot'
540 //+ '&title=' + window.escape('Choose a Pick Up Library'),
541 'fancy_prompt', 'chrome,resizable,modal',
542 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
544 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
545 var pickup_lib = fancy_prompt_data.lib;
547 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
549 if(obj.retrieve_ids.length > 1) {
550 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()]);
552 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()]);
554 var r = obj.error.yns_alert(msg,
555 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
556 $("commonStrings").getString('common.yes'),
557 $("commonStrings").getString('common.no'),
559 $("commonStrings").getString('common.check_to_confirm')
562 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
565 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
569 'cmd_holds_edit_phone_notify' : [
573 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
574 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
575 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
577 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
578 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
579 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
580 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
581 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
582 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
583 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
584 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
585 JSAN.use('util.window'); var win = new util.window();
586 var fancy_prompt_data = win.open(
587 urls.XUL_FANCY_PROMPT,
588 //+ '?xml_in_stash=temp_mid'
589 //+ '&bottom_xml_in_stash=temp_bot'
590 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
592 'fancy_prompt', 'chrome,resizable,modal',
593 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
595 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
596 var phone = fancy_prompt_data.phone;
598 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
600 if(obj.retrieve_ids.length > 1) {
601 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
603 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
605 var r = obj.error.yns_alert(msg,
606 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
607 $("commonStrings").getString('common.yes'),
608 $("commonStrings").getString('common.no'),
610 $("commonStrings").getString('common.check_to_confirm')
613 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
616 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
621 'cmd_holds_edit_sms_notify' : [
625 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
626 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.new_phone_number')+'</description>';
627 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
629 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
630 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_done.label')+'"';
631 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
632 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_cancel.label')+'"';
633 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
634 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
635 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
636 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
637 JSAN.use('util.window'); var win = new util.window();
638 var fancy_prompt_data = win.open(
639 urls.XUL_FANCY_PROMPT,
640 //+ '?xml_in_stash=temp_mid'
641 //+ '&bottom_xml_in_stash=temp_bot'
642 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
644 'fancy_prompt', 'chrome,resizable,modal',
645 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.choose_phone_number'), 'focus' : 'phone' }
647 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
648 var phone = fancy_prompt_data.phone;
650 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
652 if(obj.retrieve_ids.length > 1) {
653 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
655 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
657 var r = obj.error.yns_alert(msg,
658 $("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.modifying_holds_title'),
659 $("commonStrings").getString('common.yes'),
660 $("commonStrings").getString('common.no'),
662 $("commonStrings").getString('common.check_to_confirm')
666 'sms_notify' : phone == '' ? null : phone
669 hparams.sms_carrier = null;
671 circ.util.batch_hold_update(hold_list, hparams, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
674 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
679 'cmd_holds_edit_sms_carrier' : [
683 JSAN.use('util.widgets'); JSAN.use('util.functional');
685 var list = util.functional.map_list(
689 o.name() + ' (' + o.region() + ')',
691 ( !isTrue(o.active()) ),
696 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
697 ml.setAttribute('id','carrier');
698 ml.setAttribute('name','fancy_data');
699 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
700 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.new_carrier')+'</description>';
701 xml += util.widgets.serialize_node(ml);
703 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
704 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_done.label') +'"';
705 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_done.accesskey')+'" name="fancy_submit"/>';
706 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_cancel.label')+'"';
707 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
708 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
709 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
710 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
711 JSAN.use('util.window'); var win = new util.window();
712 var fancy_prompt_data = win.open(
713 urls.XUL_FANCY_PROMPT,
714 //+ '?xml_in_stash=temp_mid'
715 //+ '&bottom_xml_in_stash=temp_bot'
716 //+ '&title=' + window.escape('Choose a Pick Up Library'),
717 'fancy_prompt', 'chrome,resizable,modal',
718 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.choose_carrier') }
720 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
721 var sms_carrier = fancy_prompt_data.carrier;
723 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
726 if(obj.retrieve_ids.length > 1) {
727 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_carrier.confirm_carrier_change.plural',[hold_list.join(', '), obj.data.hash.csc[sms_carrier].name()]);
729 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_carrier.confirm_carrier_change.singular',[hold_list.join(', '), obj.data.hash.csc[sms_carrier].name()]);
731 var r = obj.error.yns_alert(msg,
732 $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.modifying_holds_title'),
733 $("commonStrings").getString('common.yes'),
734 $("commonStrings").getString('common.no'),
736 $("commonStrings").getString('common.check_to_confirm')
739 circ.util.batch_hold_update(hold_list, { 'sms_carrier' : sms_carrier }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
742 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
747 'cmd_holds_edit_email_notify' : [
751 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
752 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
753 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
754 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
755 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
756 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
758 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
759 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
760 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
761 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
762 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
763 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
764 JSAN.use('util.window'); var win = new util.window();
765 var fancy_prompt_data = win.open(
766 urls.XUL_FANCY_PROMPT,
767 //+ '?xml_in_stash=temp_mid'
768 //+ '&bottom_xml_in_stash=temp_bot'
769 //+ '&title=' + window.escape('Set Email Notification for Holds'),
770 'fancy_prompt', 'chrome,resizable,modal',
771 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
773 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
774 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
776 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
778 if(get_bool(email)) {
779 if(obj.retrieve_ids.length > 1) {
780 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
782 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
785 if(obj.retrieve_ids.length > 1) {
786 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
788 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
792 var r = obj.error.yns_alert(msg,
793 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
794 $("commonStrings").getString('common.yes'),
795 $("commonStrings").getString('common.no'),
797 $("commonStrings").getString('common.check_to_confirm')
800 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
803 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
807 'cmd_holds_cut_in_line' : [
811 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
812 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
813 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
814 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
815 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
816 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
818 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
819 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
820 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
821 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
822 JSAN.use('util.window'); var win = new util.window();
823 var fancy_prompt_data = win.open(
824 urls.XUL_FANCY_PROMPT,
825 'fancy_prompt', 'chrome,resizable,modal',
826 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
828 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
829 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
831 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
834 if(obj.retrieve_ids.length > 1) {
835 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
837 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
840 if(obj.retrieve_ids.length > 1) {
841 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
843 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
847 var r = obj.error.yns_alert(msg,
848 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
849 $("commonStrings").getString('common.yes'),
850 $("commonStrings").getString('common.no'),
852 $("commonStrings").getString('common.check_to_confirm')
855 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
858 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
862 'cmd_holds_edit_desire_mint_condition' : [
866 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
867 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
868 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
869 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
870 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
871 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
873 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
874 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
875 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
876 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
877 JSAN.use('util.window'); var win = new util.window();
878 var fancy_prompt_data = win.open(
879 urls.XUL_FANCY_PROMPT,
880 'fancy_prompt', 'chrome,resizable,modal',
881 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
883 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
884 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
886 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
889 if(obj.retrieve_ids.length > 1) {
890 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
892 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
895 if(obj.retrieve_ids.length > 1) {
896 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
898 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
902 var r = obj.error.yns_alert(msg,
903 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
904 $("commonStrings").getString('common.yes'),
905 $("commonStrings").getString('common.no'),
907 $("commonStrings").getString('common.check_to_confirm')
910 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
913 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
919 'cmd_holds_suspend' : [
923 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
924 var r = obj.error.yns_alert(
925 obj.retrieve_ids.length > 1 ?
926 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
927 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
928 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
929 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
930 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
932 document.getElementById('commonStrings').getString('common.confirm')
935 var already_suspended = []; var filtered_hold_list = [];
936 for (var i = 0; i < obj.retrieve_ids.length; i++) {
937 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
938 if ( get_bool( hold.frozen() ) ) {
939 already_suspended.push( hold.id() );
942 filtered_hold_list.push( hold.id() );
944 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
945 if (already_suspended.length == 1) {
946 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
947 } else if (already_suspended.length > 1) {
948 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
950 obj.clear_and_retrieve(true);
954 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
958 'cmd_holds_activate' : [
962 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
963 var r = obj.error.yns_alert(
964 obj.retrieve_ids.length > 1 ?
965 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
966 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
967 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
968 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
969 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
971 document.getElementById('commonStrings').getString('common.confirm')
974 var already_activated = []; var filtered_hold_list = [];
975 for (var i = 0; i < obj.retrieve_ids.length; i++) {
976 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
977 if ( ! get_bool( hold.frozen() ) ) {
978 already_activated.push( hold.id() );
981 filtered_hold_list.push( hold.id() );
983 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
984 if (already_activated.length == 1) {
985 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
986 } else if (already_activated.length > 1) {
987 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
989 obj.clear_and_retrieve(true);
993 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
997 'cmd_holds_edit_thaw_date' : [
1001 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1002 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_list.join(', ')]);
1003 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
1004 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1005 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1006 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
1008 JSAN.use('util.window'); var win = new util.window();
1009 var my_xulG = win.open(
1010 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
1013 'description' : desc,
1015 'allow_unset' : true,
1016 'disallow_future_dates' : false,
1017 'disallow_past_dates' : true,
1018 'disallow_today' : true,
1019 'default_time' : '00:00:00',
1020 'time_readonly' : false
1023 if (my_xulG.complete) {
1024 circ.util.batch_hold_update(
1026 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
1027 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1031 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1035 'cmd_holds_edit_expire_time' : [
1039 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1040 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
1041 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
1042 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1043 var value = 'YYYY-MM-DD';
1044 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1045 var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description');
1047 JSAN.use('util.window'); var win = new util.window();
1048 var my_xulG = win.open(
1049 urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal',
1052 'description' : desc,
1054 'allow_unset' : true,
1055 'disallow_future_dates' : false,
1056 'disallow_past_dates' : true,
1057 'disallow_today' : true,
1058 'default_time' : '00:00:00',
1059 'time_readonly' : false
1062 if (my_xulG.complete) {
1063 circ.util.batch_hold_update(
1065 { 'expire_time' : my_xulG.timestamp },
1066 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1070 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1074 'cmd_holds_edit_shelf_expire_time' : [
1078 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1079 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
1080 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
1081 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1082 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1083 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
1085 JSAN.use('util.window'); var win = new util.window();
1086 var my_xulG = win.open(
1087 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
1090 'description' : desc,
1092 'allow_unset' : false,
1093 'disallow_future_dates' : false,
1094 'disallow_past_dates' : false,
1095 'disallow_today' : false
1098 if (my_xulG.complete) {
1099 circ.util.batch_hold_update(
1101 { 'shelf_expire_time' : my_xulG.timestamp },
1102 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1106 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1110 'cmd_holds_edit_request_date' : [
1114 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1115 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
1116 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
1117 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1118 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1119 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
1121 JSAN.use('util.window'); var win = new util.window();
1122 var my_xulG = win.open(
1123 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
1126 'description' : desc,
1128 'allow_unset' : false,
1129 'disallow_future_dates' : true,
1130 'disallow_past_dates' : false,
1131 'disallow_today' : false
1134 if (my_xulG.complete) {
1135 circ.util.batch_hold_update(
1137 { 'request_time' : my_xulG.timestamp },
1138 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1142 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1146 'cmd_holds_retarget' : [
1150 JSAN.use('util.functional');
1152 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1154 if(obj.retrieve_ids.length > 1) {
1155 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
1157 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
1159 var r = obj.error.yns_alert(msg,
1160 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
1161 $("commonStrings").getString('common.yes'),
1162 $("commonStrings").getString('common.no'),
1164 $("commonStrings").getString('common.check_to_confirm')
1167 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1168 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
1169 if (typeof robj.ilsevent != 'undefined') throw(robj);
1171 obj.clear_and_retrieve();
1174 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
1180 'cmd_holds_cancel' : [
1184 JSAN.use('util.functional');
1186 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1188 if(obj.retrieve_ids.length > 1 ) {
1189 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
1191 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
1194 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1195 JSAN.use('util.window');
1196 var win = new util.window();
1197 var my_xulG = win.open(
1198 urls.XUL_HOLD_CANCEL,
1200 'chrome,resizable,modal',
1203 /*var r = obj.error.yns_alert(msg,
1204 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1205 $("commonStrings").getString('common.yes'),
1206 $("commonStrings").getString('common.no'),
1208 $("commonStrings").getString('common.check_to_confirm')
1211 if (my_xulG.proceed) {
1213 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1214 var transit = obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit();
1215 if (transit && ! transit.dest_recv_time() ) {
1216 transits.push( obj.retrieve_ids[i].barcode );
1218 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1219 if (typeof robj.ilsevent != 'undefined') throw(robj);
1221 if (transits.length > 0) {
1222 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1223 var r2 = obj.error.yns_alert(msg2,
1224 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1225 $("commonStrings").getString('common.yes'),
1226 $("commonStrings").getString('common.no'),
1228 $("commonStrings").getString('common.check_to_confirm'));
1231 for (var i = 0; i < transits.length; i++) {
1232 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1233 if (typeof robj.ilsevent != 'undefined') {
1234 switch(Number(robj.ilsevent)) {
1235 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1238 case 5000 /* PERM_FAILURE */ :
1247 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1251 obj.clear_and_retrieve();
1254 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1258 'cmd_holds_uncancel' : [
1262 JSAN.use('util.functional');
1263 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1264 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1265 if (typeof robj.ilsevent != 'undefined') throw(robj);
1267 obj.clear_and_retrieve();
1269 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1274 'cmd_retrieve_patron' : [
1279 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1280 var patron_id = obj.retrieve_ids[i].usr;
1281 if (seen[patron_id]) continue; seen[patron_id] = true;
1282 xulG.new_patron_tab(
1284 { 'id' : patron_id }
1288 obj.error.standard_unexpected_error_alert('',E);
1292 'cmd_show_catalog' : [
1296 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1297 var htarget = obj.retrieve_ids[i].target;
1298 var htype = obj.retrieve_ids[i].type;
1302 opac_url = xulG.url_prefix( urls.opac_rresult_metarecord ) + htarget;
1305 opac_url = xulG.url_prefix( urls.opac_rdetail ) + htarget;
1308 opac_url = xulG.url_prefix( urls.opac_rdetail )
1309 + obj.hold_part_map[ obj.retrieve_ids[i].id ].record();
1312 opac_url = xulG.url_prefix( urls.opac_rdetail )
1313 + obj.hold_subscription_map[ obj.retrieve_ids[i].id ].record_entry();
1316 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1317 opac_url = xulG.url_prefix( urls.opac_rdetail) + my_acn.record();
1322 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1324 if (typeof my_acp.call_number() == 'object') {
1325 my_acn = my.acp.call_number();
1327 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1328 [ my_acp.call_number() ]);
1330 opac_url = xulG.url_prefix( urls.opac_rdetail) + my_acn.record();
1333 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1337 var content_params = {
1339 'authtime' : ses('authtime'),
1340 'opac_url' : opac_url
1343 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1344 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1349 obj.error.standard_unexpected_error_alert('',E);
1353 'cmd_holds_title_transfer' : [
1358 var unique_targets = [];
1359 var seen_target = {};
1360 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1361 var hid = obj.retrieve_ids[i].id;
1362 var htarget = obj.retrieve_ids[i].id;
1363 var htype = obj.retrieve_ids[i].type;
1366 continue; // not supported
1370 if (! seen_target[htarget]) {
1371 unique_targets.push( htarget );
1372 seen_target[htarget] = 1;
1376 continue; // not supported
1379 continue; // not supported
1382 continue; // not supported
1386 JSAN.use('cat.util');
1387 cat.util.transfer_specific_title_holds(hids,unique_targets);
1388 obj.clear_and_retrieve();
1390 obj.error.standard_unexpected_error_alert('',E);
1398 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1402 'lib_filter_checkbox' : [
1405 var x_lib_type_menu = document.getElementById('lib_type_menu');
1406 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1407 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1408 obj.clear_and_retrieve();
1409 ev.target.setAttribute('checked',ev.target.checked);
1412 'cmd_view_expired_onshelf_holds' : [
1415 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1416 obj.expired = x.checked;
1417 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1418 obj.clear_and_retrieve();
1421 'cmd_clear_expired_onshelf_holds' : [
1424 obj.cmd_clear_expired_onshelf_holds();
1427 'cmd_search_opac' : [
1431 var content_params = {
1432 'show_nav_buttons' : false,
1433 'show_print_button' : true,
1434 'passthru_content_params' : {
1435 'authtoken' : ses(),
1436 'authtime' : ses('authtime'),
1437 'window_open' : function(a,b,c) {
1439 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1440 return window.open(a,b,c);
1442 obj.error.standard_unexpected_error_alert('window_open',E);
1445 'opac_hold_placed' : function(hold) {
1451 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1456 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1457 window.xulG.on_list_change();
1460 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1463 'get_barcode' : xulG.get_barcode,
1464 'get_barcode_and_settings' : xulG.get_barcode_and_settings,
1465 'patron_barcode' : obj.patron_barcode
1467 'url_prefix' : xulG.url_prefix,
1468 'url' : xulG.url_prefix(urls.browser)
1470 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1472 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1481 obj.determine_hold_interface_type();
1482 var x_fetch_more = document.getElementById('fetch_more');
1483 var x_lib_type_menu = document.getElementById('lib_type_menu');
1484 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1485 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1486 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1487 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1488 var x_expired_checkbox = document.getElementById('expired_checkbox');
1489 var x_print_full_pull_list = document.getElementById('print_full_btn');
1490 var x_print_full_pull_list_alt = document.getElementById('print_alt_btn');
1491 switch(obj.hold_interface_type) {
1493 obj.render_lib_menus({'pickup_lib':true});
1494 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1495 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1496 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1497 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1498 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1501 if (x_fetch_more) x_fetch_more.hidden = false;
1502 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1503 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = false;
1504 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1505 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1508 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1509 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1510 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1511 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1512 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1515 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1516 if (x_fetch_more) x_fetch_more.hidden = true;
1517 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1518 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1519 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1520 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1523 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
1525 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1526 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1527 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1529 obj.controller.render();
1532 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1533 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1534 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1535 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1536 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1537 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1538 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1539 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1540 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1541 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1542 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1543 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1544 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1548 $('cmd_alt_view').setAttribute('disabled','true');
1549 xulG.when_done = function() {
1550 $('cmd_alt_view').setAttribute('ready','true');
1551 if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1552 $('cmd_alt_view').setAttribute('disabled','false');
1554 dump('hold details UI ready\n');
1556 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1557 JSAN.use('util.browser');
1558 obj.browser = new util.browser();
1561 'url' : urls.XUL_HOLD_DETAILS,
1563 'alt_print' : false,
1564 'browser_id' : 'hold_detail_frame',
1565 'passthru_content_params' : xulG
1571 'determine_hold_interface_type' : function() {
1573 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1574 obj.hold_interface_type = 'patron';
1575 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1576 obj.hold_interface_type = 'record';
1577 } else if (obj.pull) { /*************************************************** PULL ******************************/
1578 obj.hold_interface_type = 'pull';
1579 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1580 obj.hold_interface_type = 'shelf';
1581 } else { /*************************************************** PULL ******************************/
1582 obj.hold_interface_type = 'pull';
1586 'clear_and_retrieve' : function() {
1589 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1591 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1592 window.xulG.on_list_change();
1595 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1599 'retrieve' : function() {
1600 var obj = this; var holds = [];
1601 if (window.xulG && window.xulG.holds) {
1602 holds = window.xulG.holds;
1604 var method; var params = [ ses() ];
1605 switch(obj.hold_interface_type) {
1607 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1608 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1610 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1612 params.push( obj.patron_id );
1613 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1616 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1617 params.push( obj.docid );
1618 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1619 var x_lib_type_menu = document.getElementById('lib_type_menu');
1621 if (x_lib_filter.checked) {
1622 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1624 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1629 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1633 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1635 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1637 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1638 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1642 method = 'FM_AHR_ID_LIST_PULL_LIST';
1643 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1644 var x = document.getElementById('hold_count');
1646 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1647 var count = req.getResultObject();
1648 if (typeof count.ilsevent == 'undefined' && count != null) {
1649 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1650 'staff.patron.holds.total_count',
1659 var robj = obj.network.simple_request( method, params );
1660 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1661 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1664 holds = holds.concat( robj.copy_holds );
1665 holds = holds.concat( robj.recall_holds );
1666 holds = holds.concat( robj.force_holds );
1667 holds = holds.concat( robj.volume_holds );
1668 holds = holds.concat( robj.title_holds );
1669 holds = holds.concat( robj.part_holds );
1670 holds = holds.concat( robj.issuance_holds );
1671 holds = holds.concat( robj.metarecord_holds );
1672 holds = holds.sort();
1675 if (robj == null ) {
1678 if (typeof robj.length == 'undefined') {
1686 //alert('method = ' + method + ' params = ' + js2JSON(params));
1689 var x_fetch_more = document.getElementById('fetch_more');
1690 if (holds.length == 0) {
1691 if (x_fetch_more) x_fetch_more.disabled = true;
1693 if (x_fetch_more) x_fetch_more.disabled = false;
1699 'render' : function(holds) {
1703 function list_append(hold_id) {
1708 'hold_id' : hold_id,
1709 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1717 function gen_list_append(hold) {
1719 if (typeof obj.controller.view.lib_menu == 'undefined') {
1720 list_append(typeof hold == 'object' ? hold.id() : hold);
1722 list_append(typeof hold == 'object' ? hold.id() : hold);
1729 JSAN.use('util.exec'); var exec = new util.exec(2);
1731 for (var i in holds) {
1732 rows.push( gen_list_append(holds[i]) );
1737 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1741 'render_lib_menus' : function(types) {
1744 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1746 var x = document.getElementById('lib_type_menu');
1748 var nodes = x.firstChild.childNodes;
1749 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1750 for (var i in types) document.getElementById(i).hidden = false;
1752 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1754 x = document.getElementById('lib_menu_placeholder');
1755 util.widgets.remove_children( x );
1757 JSAN.use('util.file');
1758 var file = new util.file('offline_ou_list');
1759 if (file._file.exists()) {
1760 var list_data = file.get_object(); file.close();
1761 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1762 ml.setAttribute('id','lib_menu');
1763 x.appendChild( ml );
1764 ml.addEventListener(
1767 obj.filter_lib = ev.target.value;
1768 obj.clear_and_retrieve();
1772 obj.controller.view.lib_menu = ml;
1774 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1778 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1782 'cmd_clear_expired_onshelf_holds' : function() {
1785 // Disable anything such as filters that can have us accidentally
1786 // lose these non-repeatable results. Well, now that they're cached
1787 // it's less of an issue.
1788 if ($('lib_filter_checkbox')) {
1789 $('lib_filter_checkbox').checked = false;
1791 if ($('lib_type_menu')) {
1792 $('lib_type_menu').disabled = true;
1794 if ($('lib_menu_placeholder')) {
1795 $('lib_menu_placeholder').firstChild.disabled = true;
1797 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute(
1798 'disabled', 'true');
1799 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute(
1800 'disabled', 'true');
1802 // I could put this with the "retrieval" methods, but since it has
1803 // side effects, seems cleaner to invoke it here
1804 var robj = obj.network.simple_request(
1808 obj.filter_lib || obj.data.list.au[0].ws_ou()
1811 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1812 if (typeof robj.cache_key == 'undefined') { throw(robj); }
1814 var cache_key = robj.cache_key;
1816 // id's in xulG.holds will prevent the normal retrieval method from
1817 // firing. Let's put our affected hold.id's in here:
1820 // Start the progress meter
1821 $('progress').value = 0;
1822 $('progress').hidden = false;
1824 // Fetch the affected holds
1825 fieldmapper.standardRequest(
1826 [ 'open-ils.circ', 'open-ils.circ.hold.clear_shelf.get_cache' ],
1829 'params' : [ ses(), cache_key ],
1830 'onresponse' : function(r) {
1832 openils.Util.readResponse(r),
1835 $('progress').value = Number(resp.progress)
1839 obj.post_clear_shelf_hold_action_map[
1840 resp.hold_details.id
1842 xulG.holds.push( resp.hold_details.id );
1846 'oncomplete' : function() {
1847 obj.clear_and_retrieve();
1848 $('progress').hidden = true;
1854 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) {
1855 return; /* handled by network.js */
1857 obj.error.standard_unexpected_error_alert(
1858 'Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1863 dump('exiting patron.holds.js\n');