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_simplified_pull_list' : [
398 var content_params = {
400 "authtime": ses("authtime"),
402 "show_nav_buttons": true,
403 "show_print_button": true
405 ["url_prefix", "new_tab", "set_tab",
406 "close_tab", "new_patron_tab",
407 "set_patron_tab", "volume_item_creator",
409 "holdings_maintenance_tab", "set_tab_name",
410 "open_chrome_window", "url_prefix",
411 "network_meter", "page_meter",
412 "set_statusbar", "set_help_context"
413 ].forEach(function(k) {
414 content_params[k] = xulG[k];
417 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
418 xulG.url_prefix("/eg/circ/hold_pull_list").replace("http:","https:")
422 "tab_name": "Simplified Pull List", /* XXX i18n */
424 "show_print_button": false
428 g.error.sdump("D_ERROR", E);
432 'cmd_holds_print' : [
436 JSAN.use('patron.util');
438 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id)
440 switch(obj.hold_interface_type) {
442 params.template = 'holds_for_patron';
445 params.template = 'holds_on_bib';
448 params.template = 'holds_shelf';
452 params.template = 'holds_pull_list';
455 obj.list.print(params);
457 obj.error.standard_unexpected_error_alert('print 1',E);
461 'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
462 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
463 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
465 'cmd_holds_edit_selection_depth' : [
469 JSAN.use('util.widgets'); JSAN.use('util.functional');
470 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
471 var list = util.functional.map_list(
472 util.functional.filter_list(
475 if (o.depth() > ws_type.depth()) return false;
476 if (o.depth() < ws_type.depth()) return true;
477 return (o.id() == ws_type.id());
489 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
490 ml.setAttribute('id','selection');
491 ml.setAttribute('name','fancy_data');
492 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
493 xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
494 xml += util.widgets.serialize_node(ml);
496 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
497 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
498 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
499 bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
500 bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
501 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
502 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
503 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
504 JSAN.use('util.window'); var win = new util.window();
505 var fancy_prompt_data = win.open(
506 urls.XUL_FANCY_PROMPT,
507 //+ '?xml_in_stash=temp_mid'
508 //+ '&bottom_xml_in_stash=temp_bot'
509 //+ '&title=' + window.escape('Choose a Pick Up Library'),
510 'fancy_prompt', 'chrome,resizable,modal',
511 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
513 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
514 var selection = fancy_prompt_data.selection;
516 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
518 if(obj.retrieve_ids.length > 1) {
519 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
521 msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list.join(', '), obj.data.hash.aout[selection].opac_label()])
524 var r = obj.error.yns_alert(msg,
525 $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
526 $("commonStrings").getString('common.yes'),
527 $("commonStrings").getString('common.no'),
529 $("commonStrings").getString('common.check_to_confirm')
532 circ.util.batch_hold_update(hold_list, { 'selection_depth' : obj.data.hash.aout[selection].depth() }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
535 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
540 'cmd_holds_edit_pickup_lib' : [
544 JSAN.use('util.widgets'); JSAN.use('util.functional');
546 var list = util.functional.map_list(
549 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
551 o.name() ? sname + ' ' + o.name() : o.shortname(),
553 ( !isTrue(obj.data.hash.aout[ o.ou_type() ].can_have_users()) ),
554 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
558 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
559 ml.setAttribute('id','lib');
560 ml.setAttribute('name','fancy_data');
561 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
562 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
563 xml += util.widgets.serialize_node(ml);
565 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
566 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
567 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
568 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
569 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
570 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
571 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
572 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
573 JSAN.use('util.window'); var win = new util.window();
574 var fancy_prompt_data = win.open(
575 urls.XUL_FANCY_PROMPT,
576 //+ '?xml_in_stash=temp_mid'
577 //+ '&bottom_xml_in_stash=temp_bot'
578 //+ '&title=' + window.escape('Choose a Pick Up Library'),
579 'fancy_prompt', 'chrome,resizable,modal',
580 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
582 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
583 var pickup_lib = fancy_prompt_data.lib;
585 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
587 if(obj.retrieve_ids.length > 1) {
588 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()]);
590 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()]);
592 var r = obj.error.yns_alert(msg,
593 $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
594 $("commonStrings").getString('common.yes'),
595 $("commonStrings").getString('common.no'),
597 $("commonStrings").getString('common.check_to_confirm')
600 circ.util.batch_hold_update(hold_list, { 'pickup_lib' : pickup_lib }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
603 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
607 'cmd_holds_edit_phone_notify' : [
611 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
612 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
613 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
615 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
616 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
617 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
618 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
619 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
620 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
621 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
622 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
623 JSAN.use('util.window'); var win = new util.window();
624 var fancy_prompt_data = win.open(
625 urls.XUL_FANCY_PROMPT,
626 //+ '?xml_in_stash=temp_mid'
627 //+ '&bottom_xml_in_stash=temp_bot'
628 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
630 'fancy_prompt', 'chrome,resizable,modal',
631 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
633 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
634 var phone = fancy_prompt_data.phone;
636 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
638 if(obj.retrieve_ids.length > 1) {
639 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
641 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
643 var r = obj.error.yns_alert(msg,
644 $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
645 $("commonStrings").getString('common.yes'),
646 $("commonStrings").getString('common.no'),
648 $("commonStrings").getString('common.check_to_confirm')
651 circ.util.batch_hold_update(hold_list, { 'phone_notify' : phone }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
654 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
659 'cmd_holds_edit_sms_notify' : [
663 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
664 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.new_phone_number')+'</description>';
665 xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
667 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
668 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_done.label')+'"';
669 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
670 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_cancel.label')+'"';
671 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
672 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
673 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
674 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
675 JSAN.use('util.window'); var win = new util.window();
676 var fancy_prompt_data = win.open(
677 urls.XUL_FANCY_PROMPT,
678 //+ '?xml_in_stash=temp_mid'
679 //+ '&bottom_xml_in_stash=temp_bot'
680 //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
682 'fancy_prompt', 'chrome,resizable,modal',
683 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.choose_phone_number'), 'focus' : 'phone' }
685 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
686 var phone = fancy_prompt_data.phone;
688 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
690 if(obj.retrieve_ids.length > 1) {
691 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_notify.confirm_phone_number_change.plural',[hold_list.join(', '), phone]);
693 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_notify.confirm_phone_number_change.singular',[hold_list.join(', '), phone]);
695 var r = obj.error.yns_alert(msg,
696 $("patronStrings").getString('staff.patron.holds.holds_edit_sms_notify.modifying_holds_title'),
697 $("commonStrings").getString('common.yes'),
698 $("commonStrings").getString('common.no'),
700 $("commonStrings").getString('common.check_to_confirm')
704 'sms_notify' : phone == '' ? null : phone
707 hparams.sms_carrier = null;
709 circ.util.batch_hold_update(hold_list, hparams, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
712 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
717 'cmd_holds_edit_sms_carrier' : [
721 JSAN.use('util.widgets'); JSAN.use('util.functional');
723 var list = util.functional.map_list(
727 o.name() + ' (' + o.region() + ')',
729 ( !isTrue(o.active()) ),
734 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
735 ml.setAttribute('id','carrier');
736 ml.setAttribute('name','fancy_data');
737 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
738 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.new_carrier')+'</description>';
739 xml += util.widgets.serialize_node(ml);
741 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
742 bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_done.label') +'"';
743 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_done.accesskey')+'" name="fancy_submit"/>';
744 bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_cancel.label')+'"';
745 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
746 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
747 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
748 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
749 JSAN.use('util.window'); var win = new util.window();
750 var fancy_prompt_data = win.open(
751 urls.XUL_FANCY_PROMPT,
752 //+ '?xml_in_stash=temp_mid'
753 //+ '&bottom_xml_in_stash=temp_bot'
754 //+ '&title=' + window.escape('Choose a Pick Up Library'),
755 'fancy_prompt', 'chrome,resizable,modal',
756 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.choose_carrier') }
758 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
759 var sms_carrier = fancy_prompt_data.carrier;
761 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
764 if(obj.retrieve_ids.length > 1) {
765 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_carrier.confirm_carrier_change.plural',[hold_list.join(', '), obj.data.hash.csc[sms_carrier].name()]);
767 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_sms_carrier.confirm_carrier_change.singular',[hold_list.join(', '), obj.data.hash.csc[sms_carrier].name()]);
769 var r = obj.error.yns_alert(msg,
770 $("patronStrings").getString('staff.patron.holds.holds_edit_sms_carrier.modifying_holds_title'),
771 $("commonStrings").getString('common.yes'),
772 $("commonStrings").getString('common.no'),
774 $("commonStrings").getString('common.check_to_confirm')
777 circ.util.batch_hold_update(hold_list, { 'sms_carrier' : sms_carrier }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
780 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
785 'cmd_holds_edit_email_notify' : [
789 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
790 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
791 xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
792 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
793 xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
794 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
796 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
797 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
798 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
799 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
800 //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
801 //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
802 JSAN.use('util.window'); var win = new util.window();
803 var fancy_prompt_data = win.open(
804 urls.XUL_FANCY_PROMPT,
805 //+ '?xml_in_stash=temp_mid'
806 //+ '&bottom_xml_in_stash=temp_bot'
807 //+ '&title=' + window.escape('Set Email Notification for Holds'),
808 'fancy_prompt', 'chrome,resizable,modal',
809 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
811 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
812 var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
814 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
816 if(get_bool(email)) {
817 if(obj.retrieve_ids.length > 1) {
818 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list.join(', ')]);
820 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list.join(', ')]);
823 if(obj.retrieve_ids.length > 1) {
824 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list.join(', ')]);
826 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list.join(', ')]);
830 var r = obj.error.yns_alert(msg,
831 $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
832 $("commonStrings").getString('common.yes'),
833 $("commonStrings").getString('common.no'),
835 $("commonStrings").getString('common.check_to_confirm')
838 circ.util.batch_hold_update(hold_list, { 'email_notify' : email }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
841 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
845 'cmd_holds_cut_in_line' : [
849 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
850 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.description')+'</description>';
851 xml += '<hbox><button value="cut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.label')+'"';
852 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cut.accesskey')+'" name="fancy_submit"/>';
853 xml += '<button value="nocut" label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.label')+'"';
854 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_no_cut.accesskey')+'" name="fancy_submit"/></hbox>';
856 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
857 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.label')+'"';
858 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_cut_in_line.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
859 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
860 JSAN.use('util.window'); var win = new util.window();
861 var fancy_prompt_data = win.open(
862 urls.XUL_FANCY_PROMPT,
863 'fancy_prompt', 'chrome,resizable,modal',
864 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.set_notifs') }
866 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
867 var cut = fancy_prompt_data.fancy_submit == 'cut' ? get_db_true() : get_db_false();
869 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
872 if(obj.retrieve_ids.length > 1) {
873 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.plural', [hold_list.join(', ')]);
875 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.enable_cut.singular', [hold_list.join(', ')]);
878 if(obj.retrieve_ids.length > 1) {
879 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.plural', [hold_list.join(', ')]);
881 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cut_in_line.disable_cut.singular', [hold_list.join(', ')]);
885 var r = obj.error.yns_alert(msg,
886 $("patronStrings").getString('staff.patron.holds.holds_cut_in_line.mod_holds_title'),
887 $("commonStrings").getString('common.yes'),
888 $("commonStrings").getString('common.no'),
890 $("commonStrings").getString('common.check_to_confirm')
893 circ.util.batch_hold_update(hold_list, { 'cut_in_line' : cut }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
896 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
900 'cmd_holds_edit_desire_mint_condition' : [
904 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
905 xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.description')+'</description>';
906 xml += '<hbox><button value="good" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.label')+'"';
907 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_good.accesskey')+'" name="fancy_submit"/>';
908 xml += '<button value="nogood" label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.label')+'"';
909 xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_mediocre.accesskey')+'" name="fancy_submit"/></hbox>';
911 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
912 bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.label')+'"';
913 bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
914 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
915 JSAN.use('util.window'); var win = new util.window();
916 var fancy_prompt_data = win.open(
917 urls.XUL_FANCY_PROMPT,
918 'fancy_prompt', 'chrome,resizable,modal',
919 { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.set_notifs') }
921 if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
922 var good = fancy_prompt_data.fancy_submit == 'good' ? get_db_true() : get_db_false();
924 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
927 if(obj.retrieve_ids.length > 1) {
928 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.plural', [hold_list.join(', ')]);
930 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.enable_good.singular', [hold_list.join(', ')]);
933 if(obj.retrieve_ids.length > 1) {
934 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.plural', [hold_list.join(', ')]);
936 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_desire_mint_condition.disable_good.singular', [hold_list.join(', ')]);
940 var r = obj.error.yns_alert(msg,
941 $("patronStrings").getString('staff.patron.holds.holds_desire_mint_condition.mod_holds_title'),
942 $("commonStrings").getString('common.yes'),
943 $("commonStrings").getString('common.no'),
945 $("commonStrings").getString('common.check_to_confirm')
948 circ.util.batch_hold_update(hold_list, { 'mint_condition' : good }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } });
951 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
957 'cmd_holds_suspend' : [
961 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
962 var r = obj.error.yns_alert(
963 obj.retrieve_ids.length > 1 ?
964 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list.join(', ')]) :
965 document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list.join(', ')]),
966 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
967 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
968 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
970 document.getElementById('commonStrings').getString('common.confirm')
973 var already_suspended = []; var filtered_hold_list = [];
974 for (var i = 0; i < obj.retrieve_ids.length; i++) {
975 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
976 if ( get_bool( hold.frozen() ) ) {
977 already_suspended.push( hold.id() );
980 filtered_hold_list.push( hold.id() );
982 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 't', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
983 if (already_suspended.length == 1) {
984 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
985 } else if (already_suspended.length > 1) {
986 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
988 obj.clear_and_retrieve(true);
992 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
996 'cmd_holds_activate' : [
1000 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1001 var r = obj.error.yns_alert(
1002 obj.retrieve_ids.length > 1 ?
1003 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list.join(', ')]) :
1004 document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list.join(', ')]),
1005 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds'),
1006 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.yes'),
1007 document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds.no'),
1009 document.getElementById('commonStrings').getString('common.confirm')
1012 var already_activated = []; var filtered_hold_list = [];
1013 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1014 var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
1015 if ( ! get_bool( hold.frozen() ) ) {
1016 already_activated.push( hold.id() );
1019 filtered_hold_list.push( hold.id() );
1021 circ.util.batch_hold_update(filtered_hold_list, { 'frozen' : 'f', 'thaw_date' : null }, { 'progressmeter' : progressmeter, 'oncomplete' : function() {
1022 if (already_activated.length == 1) {
1023 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
1024 } else if (already_activated.length > 1) {
1025 alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
1027 obj.clear_and_retrieve(true);
1031 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
1035 'cmd_holds_edit_thaw_date' : [
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.activation_date.prompt',[hold_list.join(', ')]);
1041 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt.plural',[hold_list.join(', ')]);
1042 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1043 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1044 var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description');
1046 JSAN.use('util.window'); var win = new util.window();
1047 var my_xulG = win.open(
1048 urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal',
1051 'description' : desc,
1053 'allow_unset' : true,
1054 'disallow_future_dates' : false,
1055 'disallow_past_dates' : true,
1056 'disallow_today' : true,
1057 'default_time' : '00:00:00',
1058 'time_readonly' : false
1061 if (my_xulG.complete) {
1062 circ.util.batch_hold_update(
1064 { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp },
1065 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1069 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1073 'cmd_holds_edit_expire_time' : [
1077 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1078 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_list.join(', ')]);
1079 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt.plural',[hold_list.join(', ')]);
1080 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1081 var value = 'YYYY-MM-DD';
1082 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1083 var desc = document.getElementById('circStrings').getString('staff.circ.holds.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_expire_time', 'chrome,resizable,modal',
1090 'description' : desc,
1092 'allow_unset' : true,
1093 'disallow_future_dates' : false,
1094 'disallow_past_dates' : true,
1095 'disallow_today' : true,
1096 'default_time' : '00:00:00',
1097 'time_readonly' : false
1100 if (my_xulG.complete) {
1101 circ.util.batch_hold_update(
1103 { 'expire_time' : my_xulG.timestamp },
1104 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1108 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1112 'cmd_holds_edit_shelf_expire_time' : [
1116 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1117 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
1118 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
1119 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1120 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1121 var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
1123 JSAN.use('util.window'); var win = new util.window();
1124 var my_xulG = win.open(
1125 urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
1128 'description' : desc,
1130 'allow_unset' : false,
1131 'disallow_future_dates' : false,
1132 'disallow_past_dates' : false,
1133 'disallow_today' : false
1136 if (my_xulG.complete) {
1137 circ.util.batch_hold_update(
1139 { 'shelf_expire_time' : my_xulG.timestamp },
1140 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1144 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1148 'cmd_holds_edit_request_date' : [
1152 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1153 var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt',[hold_list.join(', ')]);
1154 var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.request_date.prompt.plural',[hold_list.join(', ')]);
1155 var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
1156 var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
1157 var desc = document.getElementById('circStrings').getString('staff.circ.holds.request_date.dialog.description');
1159 JSAN.use('util.window'); var win = new util.window();
1160 var my_xulG = win.open(
1161 urls.XUL_TIMESTAMP_DIALOG, 'edit_request_date', 'chrome,resizable,modal',
1164 'description' : desc,
1166 'allow_unset' : false,
1167 'disallow_future_dates' : true,
1168 'disallow_past_dates' : false,
1169 'disallow_today' : false
1172 if (my_xulG.complete) {
1173 circ.util.batch_hold_update(
1175 { 'request_time' : my_xulG.timestamp },
1176 { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
1180 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
1184 'cmd_holds_retarget' : [
1188 JSAN.use('util.functional');
1190 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1192 if(obj.retrieve_ids.length > 1) {
1193 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list.join(', ')]);
1195 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list.join(', ')]);
1197 var r = obj.error.yns_alert(msg,
1198 $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
1199 $("commonStrings").getString('common.yes'),
1200 $("commonStrings").getString('common.no'),
1202 $("commonStrings").getString('common.check_to_confirm')
1205 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1206 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
1207 if (typeof robj.ilsevent != 'undefined') throw(robj);
1209 obj.clear_and_retrieve();
1212 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
1218 'cmd_holds_cancel' : [
1222 JSAN.use('util.functional');
1224 var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
1226 if(obj.retrieve_ids.length > 1 ) {
1227 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list.join(', ')]);
1229 msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list.join(', ')]);
1232 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1233 JSAN.use('util.window');
1234 var win = new util.window();
1235 var my_xulG = win.open(
1236 urls.XUL_HOLD_CANCEL,
1238 'chrome,resizable,modal',
1241 /*var r = obj.error.yns_alert(msg,
1242 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
1243 $("commonStrings").getString('common.yes'),
1244 $("commonStrings").getString('common.no'),
1246 $("commonStrings").getString('common.check_to_confirm')
1249 if (my_xulG.proceed) {
1251 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1252 var transit = obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit();
1253 if (transit && ! transit.dest_recv_time() ) {
1254 transits.push( obj.retrieve_ids[i].barcode );
1256 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
1257 if (typeof robj.ilsevent != 'undefined') throw(robj);
1259 if (transits.length > 0) {
1260 var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
1261 var r2 = obj.error.yns_alert(msg2,
1262 $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
1263 $("commonStrings").getString('common.yes'),
1264 $("commonStrings").getString('common.no'),
1266 $("commonStrings").getString('common.check_to_confirm'));
1269 for (var i = 0; i < transits.length; i++) {
1270 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
1271 if (typeof robj.ilsevent != 'undefined') {
1272 switch(Number(robj.ilsevent)) {
1273 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
1276 case 5000 /* PERM_FAILURE */ :
1285 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
1289 obj.clear_and_retrieve();
1292 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
1296 'cmd_holds_uncancel' : [
1300 JSAN.use('util.functional');
1301 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1302 var robj = obj.network.simple_request('FM_AHR_UNCANCEL',[ ses(), obj.retrieve_ids[i].id]);
1303 if (typeof robj.ilsevent != 'undefined') throw(robj);
1305 obj.clear_and_retrieve();
1307 obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_uncancel.hold_not_uncancelled'),E);
1312 'cmd_retrieve_patron' : [
1317 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1318 var patron_id = obj.retrieve_ids[i].usr;
1319 if (seen[patron_id]) continue; seen[patron_id] = true;
1320 xulG.new_patron_tab(
1322 { 'id' : patron_id }
1326 obj.error.standard_unexpected_error_alert('',E);
1330 'cmd_show_catalog' : [
1334 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1335 var htarget = obj.retrieve_ids[i].target;
1336 var htype = obj.retrieve_ids[i].type;
1340 opac_url = xulG.url_prefix( urls.opac_rresult_metarecord ) + htarget;
1343 opac_url = xulG.url_prefix( urls.opac_rdetail ) + htarget;
1346 opac_url = xulG.url_prefix( urls.opac_rdetail )
1347 + obj.hold_part_map[ obj.retrieve_ids[i].id ].record();
1350 opac_url = xulG.url_prefix( urls.opac_rdetail )
1351 + obj.hold_subscription_map[ obj.retrieve_ids[i].id ].record_entry();
1354 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
1355 opac_url = xulG.url_prefix( urls.opac_rdetail) + my_acn.record();
1360 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
1362 if (typeof my_acp.call_number() == 'object') {
1363 my_acn = my.acp.call_number();
1365 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
1366 [ my_acp.call_number() ]);
1368 opac_url = xulG.url_prefix( urls.opac_rdetail) + my_acn.record();
1371 obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
1375 var content_params = {
1377 'authtime' : ses('authtime'),
1378 'opac_url' : opac_url
1381 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1382 {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
1387 obj.error.standard_unexpected_error_alert('',E);
1391 'cmd_holds_title_transfer' : [
1396 var unique_targets = [];
1397 var seen_target = {};
1398 for (var i = 0; i < obj.retrieve_ids.length; i++) {
1399 var hid = obj.retrieve_ids[i].id;
1400 var htarget = obj.retrieve_ids[i].id;
1401 var htype = obj.retrieve_ids[i].type;
1404 continue; // not supported
1408 if (! seen_target[htarget]) {
1409 unique_targets.push( htarget );
1410 seen_target[htarget] = 1;
1414 continue; // not supported
1417 continue; // not supported
1420 continue; // not supported
1424 JSAN.use('cat.util');
1425 cat.util.transfer_specific_title_holds(hids,unique_targets);
1426 obj.clear_and_retrieve();
1428 obj.error.standard_unexpected_error_alert('',E);
1436 obj.pull_from_shelf_interface.current.offset += obj.pull_from_shelf_interface.current.limit;
1440 'lib_filter_checkbox' : [
1443 var x_lib_type_menu = document.getElementById('lib_type_menu');
1444 if (x_lib_type_menu) x_lib_type_menu.disabled = ! ev.target.checked;
1445 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = ! ev.target.checked;
1446 obj.clear_and_retrieve();
1447 ev.target.setAttribute('checked',ev.target.checked);
1450 'cmd_view_expired_onshelf_holds' : [
1453 var x = document.getElementById('expired_checkbox'); // can't trust ev.explicitOriginalTarget, sometimes gives a "button"
1454 obj.expired = x.checked;
1455 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute('disabled', !obj.expired);
1456 obj.clear_and_retrieve();
1459 'cmd_clear_expired_onshelf_holds' : [
1462 obj.cmd_clear_expired_onshelf_holds();
1465 'cmd_search_opac' : [
1469 var content_params = {
1470 'show_nav_buttons' : false,
1471 'show_print_button' : true,
1472 'passthru_content_params' : {
1473 'authtoken' : ses(),
1474 'authtime' : ses('authtime'),
1475 'window_open' : function(a,b,c) {
1477 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
1478 return window.open(a,b,c);
1480 obj.error.standard_unexpected_error_alert('window_open',E);
1483 'opac_hold_placed' : function(hold) {
1489 'hold_id' : typeof hold == 'object' ? hold.id() : hold
1494 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1495 window.xulG.on_list_change();
1498 obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
1501 'get_barcode' : xulG.get_barcode,
1502 'get_barcode_and_settings' : xulG.get_barcode_and_settings,
1503 'patron_barcode' : obj.patron_barcode
1505 'url_prefix' : xulG.url_prefix,
1506 'url' : xulG.url_prefix(urls.browser)
1508 xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
1510 obj.error.sdump('D_ERROR','cmd_search_opac: ' + E);
1519 obj.determine_hold_interface_type();
1520 var x_fetch_more = document.getElementById('fetch_more');
1521 var x_lib_type_menu = document.getElementById('lib_type_menu');
1522 var x_lib_menu_placeholder = document.getElementById('lib_menu_placeholder');
1523 var x_lib_filter_checkbox = document.getElementById('lib_filter_checkbox');
1524 var x_show_cancelled_deck = document.getElementById('show_cancelled_deck');
1525 var x_clear_shelf_widgets = document.getElementById('clear_shelf_widgets');
1526 var x_expired_checkbox = document.getElementById('expired_checkbox');
1527 var x_print_full_pull_list = document.getElementById('print_full_btn');
1528 var x_print_full_pull_list_alt = document.getElementById('print_alt_btn');
1529 var x_simplified_pull_list = document.getElementById('simplified_pull_list_btn');
1530 switch(obj.hold_interface_type) {
1532 obj.render_lib_menus({'pickup_lib':true});
1533 if (x_lib_filter_checkbox) x_lib_filter_checkbox.checked = true;
1534 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1535 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1536 if (x_clear_shelf_widgets) x_clear_shelf_widgets.hidden = false;
1537 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1538 if (x_simplified_pull_list) x_simplified_pull_list.hidden = true;
1541 if (x_fetch_more) x_fetch_more.hidden = false;
1542 if (x_print_full_pull_list) x_print_full_pull_list.hidden = false;
1543 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = false;
1544 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1545 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1546 if (x_simplified_pull_list) x_simplified_pull_list.hidden = false;
1549 obj.render_lib_menus({'pickup_lib':true,'request_lib':true});
1550 if (x_lib_filter_checkbox) x_lib_filter_checkbox.hidden = false;
1551 if (x_lib_type_menu) x_lib_type_menu.hidden = false;
1552 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1553 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = false;
1554 if (x_simplified_pull_list) x_simplified_pull_list.hidden = true;
1557 if (obj.controller.view.cmd_search_opac) obj.controller.view.cmd_search_opac.setAttribute('hidden', false);
1558 if (x_fetch_more) x_fetch_more.hidden = true;
1559 if (x_lib_type_menu) x_lib_type_menu.hidden = true;
1560 if (x_lib_menu_placeholder) x_lib_menu_placeholder.hidden = true;
1561 if (x_show_cancelled_deck) x_show_cancelled_deck.hidden = false;
1562 if (x_print_full_pull_list_alt) x_print_full_pull_list_alt.hidden = true;
1563 if (x_simplified_pull_list) x_simplified_pull_list.hidden = true;
1566 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
1568 if (x_lib_filter_checkbox) if (!x_lib_filter_checkbox.checked) {
1569 if (x_lib_type_menu) x_lib_type_menu.disabled = true;
1570 if (obj.controller.view.lib_menu) obj.controller.view.lib_menu.disabled = true;
1572 obj.controller.render();
1575 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
1576 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
1577 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
1578 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
1579 obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
1580 obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
1581 obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
1582 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
1583 obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
1584 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
1585 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
1586 obj.controller.view.cmd_holds_uncancel.setAttribute('disabled','true');
1587 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
1591 $('cmd_alt_view').setAttribute('disabled','true');
1592 xulG.when_done = function() {
1593 $('cmd_alt_view').setAttribute('ready','true');
1594 if ($('cmd_alt_view').getAttribute('rendering_rows') != 'true') {
1595 $('cmd_alt_view').setAttribute('disabled','false');
1597 dump('hold details UI ready\n');
1599 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
1600 JSAN.use('util.browser');
1601 obj.browser = new util.browser();
1604 'url' : urls.XUL_HOLD_DETAILS,
1606 'alt_print' : false,
1607 'browser_id' : 'hold_detail_frame',
1608 'passthru_content_params' : xulG
1614 'determine_hold_interface_type' : function() {
1616 if (obj.patron_id) { /*************************************************** PATRON ******************************/
1617 obj.hold_interface_type = 'patron';
1618 } else if (obj.docid) { /*************************************************** RECORD ******************************/
1619 obj.hold_interface_type = 'record';
1620 } else if (obj.pull) { /*************************************************** PULL ******************************/
1621 obj.hold_interface_type = 'pull';
1622 } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
1623 obj.hold_interface_type = 'shelf';
1624 } else { /*************************************************** PULL ******************************/
1625 obj.hold_interface_type = 'pull';
1629 'clear_and_retrieve' : function() {
1632 this.pull_from_shelf_interface.current.offset = this.pull_from_shelf_interface._default.offset;
1634 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
1635 window.xulG.on_list_change();
1638 this.error.standard_unexpected_error_alert('holds.js, clear_and_retrieve(): ',E);
1642 'retrieve' : function() {
1643 var obj = this; var holds = [];
1644 if (window.xulG && window.xulG.holds) {
1645 holds = window.xulG.holds;
1647 var method; var params = [ ses() ];
1648 switch(obj.hold_interface_type) {
1650 if (document.getElementById('show_cancelled_deck').selectedIndex == 0) {
1651 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1653 method = 'FM_AHR_CANCELLED_ID_LIST_RETRIEVE_VIA_AU.authoritative';
1655 params.push( obj.patron_id );
1656 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
1659 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
1660 params.push( obj.docid );
1661 var x_lib_filter = document.getElementById('lib_filter_checkbox');
1662 var x_lib_type_menu = document.getElementById('lib_type_menu');
1664 if (x_lib_filter.checked) {
1665 if (x_lib_type_menu && obj.controller.view.lib_menu) {
1667 x[ x_lib_type_menu.value ] = obj.controller.view.lib_menu.value;
1672 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1676 method = 'FM_AHR_ID_LIST_EXPIRED_ONSHELF_RETRIEVE';
1678 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
1680 params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
1681 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
1685 method = 'FM_AHR_ID_LIST_PULL_LIST';
1686 params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
1687 var x = document.getElementById('hold_count');
1689 obj.network.simple_request('FM_AHR_PULL_LIST_COUNT',[ses()],function(req) {
1690 var count = req.getResultObject();
1691 if (typeof count.ilsevent == 'undefined' && count != null) {
1692 x.setAttribute('value', document.getElementById('patronStrings').getFormattedString(
1693 'staff.patron.holds.total_count',
1702 var robj = obj.network.simple_request( method, params );
1703 if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
1704 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
1707 holds = holds.concat( robj.copy_holds );
1708 holds = holds.concat( robj.recall_holds );
1709 holds = holds.concat( robj.force_holds );
1710 holds = holds.concat( robj.volume_holds );
1711 holds = holds.concat( robj.title_holds );
1712 holds = holds.concat( robj.part_holds );
1713 holds = holds.concat( robj.issuance_holds );
1714 holds = holds.concat( robj.metarecord_holds );
1715 holds = holds.sort();
1718 if (robj == null ) {
1721 if (typeof robj.length == 'undefined') {
1729 //alert('method = ' + method + ' params = ' + js2JSON(params));
1732 var x_fetch_more = document.getElementById('fetch_more');
1733 if (holds.length == 0) {
1734 if (x_fetch_more) x_fetch_more.disabled = true;
1736 if (x_fetch_more) x_fetch_more.disabled = false;
1742 'render' : function(holds) {
1746 function list_append(hold_id) {
1751 'hold_id' : hold_id,
1752 'post_clear_shelf_action' : obj.post_clear_shelf_hold_action_map[ hold_id ]
1760 function gen_list_append(hold) {
1762 if (typeof obj.controller.view.lib_menu == 'undefined') {
1763 list_append(typeof hold == 'object' ? hold.id() : hold);
1765 list_append(typeof hold == 'object' ? hold.id() : hold);
1772 JSAN.use('util.exec'); var exec = new util.exec(2);
1774 for (var i in holds) {
1775 rows.push( gen_list_append(holds[i]) );
1780 this.error.standard_unexpected_error_alert('holds.js, render():',E);
1784 'render_lib_menus' : function(types) {
1787 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
1789 var x = document.getElementById('lib_type_menu');
1791 var nodes = x.firstChild.childNodes;
1792 for (var i = 0; i < nodes.length; i++) nodes[i].hidden = true;
1793 for (var i in types) document.getElementById(i).hidden = false;
1795 x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
1797 x = document.getElementById('lib_menu_placeholder');
1798 util.widgets.remove_children( x );
1800 JSAN.use('util.file');
1801 var file = new util.file('offline_ou_list');
1802 if (file._file.exists()) {
1803 var list_data = file.get_object(); file.close();
1804 var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
1805 ml.setAttribute('id','lib_menu');
1806 x.appendChild( ml );
1807 ml.addEventListener(
1810 obj.filter_lib = ev.target.value;
1811 obj.clear_and_retrieve();
1815 obj.controller.view.lib_menu = ml;
1817 throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
1821 this.error.standard_unexpected_error_alert('rendering lib menu',E);
1825 'cmd_clear_expired_onshelf_holds' : function() {
1828 // Disable anything such as filters that can have us accidentally
1829 // lose these non-repeatable results. Well, now that they're cached
1830 // it's less of an issue.
1831 if ($('lib_filter_checkbox')) {
1832 $('lib_filter_checkbox').checked = false;
1834 if ($('lib_type_menu')) {
1835 $('lib_type_menu').disabled = true;
1837 if ($('lib_menu_placeholder')) {
1838 $('lib_menu_placeholder').firstChild.disabled = true;
1840 obj.controller.view.cmd_view_expired_onshelf_holds.setAttribute(
1841 'disabled', 'true');
1842 obj.controller.view.cmd_clear_expired_onshelf_holds.setAttribute(
1843 'disabled', 'true');
1845 // I could put this with the "retrieval" methods, but since it has
1846 // side effects, seems cleaner to invoke it here
1847 var robj = obj.network.simple_request(
1851 obj.filter_lib || obj.data.list.au[0].ws_ou()
1854 if (typeof robj.ilsevent != 'undefined') { throw(robj); }
1855 if (typeof robj.cache_key == 'undefined') { throw(robj); }
1857 var cache_key = robj.cache_key;
1859 // id's in xulG.holds will prevent the normal retrieval method from
1860 // firing. Let's put our affected hold.id's in here:
1863 // Start the progress meter
1864 $('progress').value = 0;
1865 $('progress').hidden = false;
1867 // Fetch the affected holds
1868 fieldmapper.standardRequest(
1869 [ 'open-ils.circ', 'open-ils.circ.hold.clear_shelf.get_cache' ],
1872 'params' : [ ses(), cache_key ],
1873 'onresponse' : function(r) {
1875 openils.Util.readResponse(r),
1878 $('progress').value = Number(resp.progress)
1882 obj.post_clear_shelf_hold_action_map[
1883 resp.hold_details.id
1885 xulG.holds.push( resp.hold_details.id );
1889 'oncomplete' : function() {
1890 obj.clear_and_retrieve();
1891 $('progress').hidden = true;
1897 if (E.ilsevent == 5000 /* PERM_FAILURE */ ) {
1898 return; /* handled by network.js */
1900 obj.error.standard_unexpected_error_alert(
1901 'Error in holds.js, cmd_clear_expired_onshelf_holds', E);
1906 dump('exiting patron.holds.js\n');