1 dump('entering patron.holds.js\n');
3 if (typeof patron == 'undefined') patron = {};
4 patron.holds = function (params) {
6 JSAN.use('util.error'); this.error = new util.error();
7 JSAN.use('util.network'); this.network = new util.network();
8 JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
11 patron.holds.prototype = {
13 'foreign_shelf' : null,
19 'init' : function( params ) {
23 obj.patron_id = params['patron_id'];
24 obj.docid = params['docid'];
25 obj.shelf = params['shelf'];
27 JSAN.use('circ.util');
28 var columns = circ.util.hold_columns(
30 'title' : { 'hidden' : false, 'flex' : '3' },
31 'request_time' : { 'hidden' : false },
32 'pickup_lib_shortname' : { 'hidden' : false },
33 'hold_type' : { 'hidden' : false },
34 'current_copy' : { 'hidden' : false },
35 'capture_time' : { 'hidden' : false },
36 'notify_time' : { 'hidden' : false },
37 'notify_count' : { 'hidden' : false },
41 JSAN.use('util.list'); obj.list = new util.list('holds_list');
45 'map_row_to_column' : circ.util.std_map_row_to_column(),
46 'retrieve_row' : function(params) {
49 obj.network.simple_request('FM_AHR_RETRIEVE', [ ses(), row.my.hold_id ],
52 var ahr_robj = ahr_req.getResultObject();
53 if (typeof ahr_robj.ilsevent != 'undefined') throw(ahr_robj);
54 row.my.ahr = ahr_robj[0];
55 obj.holds_map[ row.my.ahr.id() ] = row.my.ahr;
56 params.row_node.setAttribute('retrieve_id',
58 'copy_id':row.my.ahr.current_copy(),
60 'type':row.my.ahr.hold_type(),
61 'target':row.my.ahr.target(),
62 'usr':row.my.ahr.usr(),
66 obj.network.simple_request('FM_AHR_STATUS',[ ses(), row.my.ahr.id() ],
67 function(status_req) {
69 var status_robj = status_req.getResultObject();
70 row.my.status = status_robj;
71 switch(row.my.ahr.hold_type()) {
74 api.MODS_SLIM_METARECORD_RETRIEVE.app,
75 api.MODS_SLIM_METARECORD_RETRIEVE.method,
76 [ row.my.ahr.target() ],
78 row.my.mvr = mvr_req.getResultObject();
79 if ( row.my.ahr.current_copy() && ! row.my.acp) {
80 obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ],
82 row.my.acp = acp_req.getResultObject();
83 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
87 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
94 api.MODS_SLIM_RECORD_RETRIEVE.app,
95 api.MODS_SLIM_RECORD_RETRIEVE.method,
96 [ row.my.ahr.target() ],
98 row.my.mvr = mvr_req.getResultObject();
99 if ( row.my.ahr.current_copy() && ! row.my.acp) {
100 obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ],
102 row.my.acp = acp_req.getResultObject();
103 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
107 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
114 row.my.acn = obj.network.simple_request( 'FM_ACN_RETRIEVE', [ row.my.ahr.target() ],
116 row.my.acn = acn_req.getResultObject();
118 api.MODS_SLIM_RECORD_RETRIEVE.app,
119 api.MODS_SLIM_RECORD_RETRIEVE.method,
120 [ row.my.acn.record() ],
122 try { row.my.mvr = mvr_req.getResultObject(); } catch(E) {}
123 if ( row.my.ahr.current_copy() && ! row.my.acp) {
124 obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ],
126 row.my.acp = acp_req.getResultObject();
127 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
131 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
139 obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.target() ],
141 row.my.acp = acp_req.getResultObject();
142 obj.network.simple_request( 'FM_ACN_RETRIEVE', [ typeof row.my.acp.call_number() == 'object' ? row.my.acp.call_number().id() : row.my.acp.call_number() ],
144 row.my.acn = acn_req.getResultObject();
146 api.MODS_SLIM_RECORD_RETRIEVE.app,
147 api.MODS_SLIM_RECORD_RETRIEVE.method,
148 [ row.my.acn.record() ],
150 try { row.my.mvr = mvr_req.getResultObject(); } catch(E) {}
151 if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
161 obj.error.standard_unexpected_error_alert('Error retrieving status for hold #' + row.my.hold_id, E);
166 obj.error.standard_unexpected_error_alert('Error retrieving hold #' + row.my.hold_id, E);
172 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
176 'on_select' : function(ev) {
177 JSAN.use('util.functional');
178 var sel = obj.list.retrieve_selection();
179 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
180 obj.retrieve_ids = util.functional.map_list(
182 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
184 if (obj.retrieve_ids.length > 0) {
185 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
186 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
187 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
188 obj.controller.view.sel_patron.setAttribute('disabled','false');
189 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
190 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
191 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
192 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
193 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
194 obj.controller.view.cmd_show_notifications.setAttribute('disabled','false');
195 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
196 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
197 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
199 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
200 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
201 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
202 obj.controller.view.sel_patron.setAttribute('disabled','true');
203 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
204 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
205 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
206 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
207 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
208 obj.controller.view.cmd_show_notifications.setAttribute('disabled','true');
209 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
210 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
211 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
218 JSAN.use('util.controller'); obj.controller = new util.controller();
222 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
225 function() { obj.list.clipboard(); }
229 function() { alert('Not Yet Implemented'); }
234 JSAN.use('circ.util');
235 circ.util.show_last_few_circs(obj.retrieve_ids);
238 'sel_mark_items_damaged' : [
241 JSAN.use('cat.util'); JSAN.use('util.functional');
242 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
245 'sel_mark_items_missing' : [
248 JSAN.use('cat.util'); JSAN.use('util.functional');
249 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
252 'sel_copy_details' : [
255 JSAN.use('circ.util');
256 for (var i = 0; i < obj.retrieve_ids.length; i++) {
257 if (obj.retrieve_ids[i].copy_id) circ.util.show_copy_details( obj.retrieve_ids[i].copy_id );
261 'cmd_holds_print' : [
265 dump(js2JSON(obj.list.dump_with_keys()) + '\n');
266 function flesh_callback() {
268 JSAN.use('patron.util');
270 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
271 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
272 'staff' : obj.data.list.au[0],
273 'header' : obj.data.print_list_templates.holds.header,
274 'line_item' : obj.data.print_list_templates.holds.line_item,
275 'footer' : obj.data.print_list_templates.holds.footer,
276 'type' : obj.data.print_list_templates.holds.type,
277 'list' : obj.list.dump_with_keys(),
279 JSAN.use('util.print'); var print = new util.print();
280 print.tree_list( params );
281 setTimeout(function(){obj.list.on_all_fleshed = null;},0);
283 obj.error.standard_unexpected_error_alert('print 2',E);
286 obj.list.on_all_fleshed = flesh_callback;
287 obj.list.full_retrieve();
289 obj.error.standard_unexpected_error_alert('print 1',E);
293 'cmd_show_notifications' : [
297 JSAN.use('util.window'); var win = new util.window();
298 for (var i = 0; i < obj.retrieve_ids.length; i++) {
299 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
301 xulG.url_prefix(urls.XUL_HOLD_NOTICES)
302 + '?ahr_id=' + obj.retrieve_ids[i].id,
303 'hold_notices_' + obj.retrieve_ids[i].id,
308 obj.error.standard_unexpected_error_alert('Error rendering/retrieving hold notifications.',E);
312 'cmd_holds_edit_selection_depth' : [
316 JSAN.use('util.widgets'); JSAN.use('util.functional');
317 var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
318 var list = util.functional.map_list(
319 util.functional.filter_list(
322 if (o.depth() > ws_type.depth()) return false;
323 if (o.depth() < ws_type.depth()) return true;
324 return (o.id() == ws_type.id());
336 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
337 ml.setAttribute('id','selection');
338 ml.setAttribute('name','fancy_data');
339 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
340 xml += '<description>Please choose a Hold Range:</description>';
341 xml += util.widgets.serialize_node(ml);
343 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
344 bot_xml += '<spacer flex="1"/><button label="Done" accesskey="D" name="fancy_submit"/>';
345 bot_xml += '<button label="Cancel" accesskey="C" name="fancy_cancel"/></hbox>';
346 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
347 obj.data.temp_mid = xml; obj.data.stash('temp_mid');
348 obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
350 urls.XUL_FANCY_PROMPT
351 + '?xml_in_stash=temp_mid'
352 + '&bottom_xml_in_stash=temp_bot'
353 + '&title=' + window.escape('Choose a Pick Up Library'),
354 'fancy_prompt', 'chrome,resizable,modal'
356 obj.data.init({'via':'stash'});
357 if (obj.data.fancy_prompt_data == '') { return; }
358 var selection = obj.data.fancy_prompt_data.selection;
359 var msg = 'Are you sure you would like to change the Hold Range for hold' + ( obj.retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ') + ' to "' + obj.data.hash.aout[selection].opac_label() + '"?';
360 var r = obj.error.yns_alert(msg,'Modifying Holds','Yes','No',null,'Check here to confirm this message');
362 for (var i = 0; i < obj.retrieve_ids.length; i++) {
363 var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
364 hold.selection_depth( obj.data.hash.aout[selection].depth() ); hold.ischanged('1');
365 var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
366 if (typeof robj.ilsevent != 'undefined') throw(robj);
371 obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
376 'cmd_holds_edit_pickup_lib' : [
380 JSAN.use('util.widgets'); JSAN.use('util.functional');
381 var list = util.functional.map_list(
384 var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
386 o.name() ? sname + ' ' + o.name() : o.shortname(),
388 ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
389 ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
393 ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
394 ml.setAttribute('id','lib');
395 ml.setAttribute('name','fancy_data');
396 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
397 xml += '<description>Please choose a new Pickup Library:</description>';
398 xml += util.widgets.serialize_node(ml);
400 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
401 bot_xml += '<spacer flex="1"/><button label="Done" accesskey="D" name="fancy_submit"/>';
402 bot_xml += '<button label="Cancel" accesskey="C" name="fancy_cancel"/></hbox>';
403 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
404 obj.data.temp_mid = xml; obj.data.stash('temp_mid');
405 obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
407 urls.XUL_FANCY_PROMPT
408 + '?xml_in_stash=temp_mid'
409 + '&bottom_xml_in_stash=temp_bot'
410 + '&title=' + window.escape('Choose a Pick Up Library'),
411 'fancy_prompt', 'chrome,resizable,modal'
413 obj.data.init({'via':'stash'});
414 if (obj.data.fancy_prompt_data == '') { return; }
415 var pickup_lib = obj.data.fancy_prompt_data.lib;
416 var msg = 'Are you sure you would like to change the Pick Up Lib for hold' + ( obj.retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ') + ' to ' + obj.data.hash.aou[pickup_lib].shortname() + '?';
417 var r = obj.error.yns_alert(msg,'Modifying Holds','Yes','No',null,'Check here to confirm this message');
419 for (var i = 0; i < obj.retrieve_ids.length; i++) {
420 var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
421 hold.pickup_lib( pickup_lib ); hold.ischanged('1');
422 var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
423 if (typeof robj.ilsevent != 'undefined') throw(robj);
428 obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
432 'cmd_holds_edit_phone_notify' : [
436 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
437 xml += '<description>Please enter a new phone number for hold notification (leave the field empty to disable phone notification):</description>';
438 xml += '<textbox id="phone" name="fancy_data"/>';
440 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
441 bot_xml += '<spacer flex="1"/><button label="Done" accesskey="D" name="fancy_submit"/>';
442 bot_xml += '<button label="Cancel" accesskey="C" name="fancy_cancel"/></hbox>';
443 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
444 obj.data.temp_mid = xml; obj.data.stash('temp_mid');
445 obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
447 urls.XUL_FANCY_PROMPT
448 + '?xml_in_stash=temp_mid'
449 + '&bottom_xml_in_stash=temp_bot'
450 + '&title=' + window.escape('Choose a Hold Notification Phone Number')
452 'fancy_prompt', 'chrome,resizable,modal'
454 obj.data.init({'via':'stash'});
455 if (obj.data.fancy_prompt_data == '') { return; }
456 var phone = obj.data.fancy_prompt_data.phone;
457 var msg = 'Are you sure you would like to change the Notification Phone Number for hold' + ( obj.retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ') + ' to "' + phone + '"?';
458 var r = obj.error.yns_alert(msg,'Modifying Holds','Yes','No',null,'Check here to confirm this message');
460 for (var i = 0; i < obj.retrieve_ids.length; i++) {
461 var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
462 hold.phone_notify( phone ); hold.ischanged('1');
463 var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
464 if (typeof robj.ilsevent != 'undefined') throw(robj);
469 obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
473 'cmd_holds_edit_email_notify' : [
477 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
478 xml += '<description>Send email notifications (when appropriate)? The email address used is found in the hold recepient account.</description>';
479 xml += '<hbox><button value="email" label="Email" accesskey="E" name="fancy_submit"/>';
480 xml += '<button value="noemail" label="No Email" accesskey="N" name="fancy_submit"/></hbox>';
482 var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
483 bot_xml += '<spacer flex="1"/><button label="Cancel" accesskey="C" name="fancy_cancel"/></hbox>';
484 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
485 obj.data.temp_mid = xml; obj.data.stash('temp_mid');
486 obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
488 urls.XUL_FANCY_PROMPT
489 + '?xml_in_stash=temp_mid'
490 + '&bottom_xml_in_stash=temp_bot'
491 + '&title=' + window.escape('Set Email Notification for Holds'),
492 'fancy_prompt', 'chrome,resizable,modal'
494 obj.data.init({'via':'stash'});
495 if (obj.data.fancy_prompt_data == '') { return; }
496 var email = obj.data.fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
497 var msg = 'Are you sure you would like ' + ( get_bool( email ) ? 'enable' : 'disable' ) + ' email notification for hold' + ( obj.retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ') + '?';
498 var r = obj.error.yns_alert(msg,'Modifying Holds','Yes','No',null,'Check here to confirm this message');
500 for (var i = 0; i < obj.retrieve_ids.length; i++) {
501 var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
502 hold.email_notify( email ); hold.ischanged('1');
503 var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
504 if (typeof robj.ilsevent != 'undefined') throw(robj);
509 obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
515 'cmd_holds_retarget' : [
519 JSAN.use('util.functional');
520 var msg = 'Are you sure you would like to reset hold' + ( obj.retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ') + '?';
521 var r = obj.error.yns_alert(msg,'Resetting Holds','Yes','No',null,'Check here to confirm this message');
523 for (var i = 0; i < obj.retrieve_ids.length; i++) {
524 var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
525 if (typeof robj.ilsevent != 'undefined') throw(robj);
530 obj.error.standard_unexpected_error_alert('Holds not likely reset.',E);
536 'cmd_holds_cancel' : [
540 JSAN.use('util.functional');
541 var msg = 'Are you sure you would like to cancel hold' + ( obj.retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ') + '?';
542 var r = obj.error.yns_alert(msg,'Cancelling Holds','Yes','No',null,'Check here to confirm this message');
544 for (var i = 0; i < obj.retrieve_ids.length; i++) {
545 var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id]);
546 if (typeof robj.ilsevent != 'undefined') throw(robj);
551 obj.error.standard_unexpected_error_alert('Holds not likely cancelled.',E);
555 'cmd_retrieve_patron' : [
560 for (var i = 0; i < obj.retrieve_ids.length; i++) {
561 var patron_id = obj.retrieve_ids[i].usr;
562 if (seen[patron_id]) continue; seen[patron_id] = true;
564 xulG.url_prefix(urls.XUL_PATRON_DISPLAY) + '?id=' + patron_id,
570 obj.error.standard_unexpected_error_alert('',E);
574 'cmd_show_catalog' : [
578 for (var i = 0; i < obj.retrieve_ids.length; i++) {
579 var htarget = obj.retrieve_ids[i].target;
580 var htype = obj.retrieve_ids[i].type;
584 opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
587 opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
590 var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE', [ htarget ]);
591 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
594 var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
596 if (typeof my_acp.call_number() == 'object') {
597 my_acn = my.acp.call_number();
599 my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE',
600 [ my_acp.call_number() ]);
602 opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
605 obj.error.standard_unexpected_error_alert("I don't understand the hold type of " + htype + ", so I can't jump to the appropriate record in the catalog.", obj.retrieve_ids[i]);
609 var content_params = {
611 'authtime' : ses('authtime'),
612 'opac_url' : opac_url,
615 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
616 {'tab_name': htype == 'M' ? 'Catalog' : 'Retrieving title...'},
621 obj.error.standard_unexpected_error_alert('',E);
628 obj.controller.render();
632 obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
633 obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
634 obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
635 obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
636 obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
637 obj.controller.view.cmd_show_notifications.setAttribute('disabled','true');
638 obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
639 obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
640 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
643 'retrieve' : function(dont_show_me_the_list_change) {
645 if (window.xulG && window.xulG.holds) {
646 obj.holds = window.xulG.holds;
648 var method; var params = [ ses() ];
649 if (obj.patron_id) { /*************************************************** PATRON ******************************/
650 method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU';
651 params.push( obj.patron_id );
652 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
653 } else if (obj.docid) { /*************************************************** RECORD ******************************/
654 method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
655 params.push( obj.docid );
656 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
657 } else if (obj.pull) { /*************************************************** PULL ******************************/
658 method = 'FM_AHR_ID_LIST_PULL_LIST';
659 params.push( 50 ); params.push( 0 );
660 } else if (obj.shelf) {
661 method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE'; /*************************************************** HOLD SHELF ******************************/
662 params.push( obj.foreign_shelf || obj.data.list.au[0].ws_ou() );
663 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
664 obj.render_lib_menu();
666 //method = 'FM_AHR_RETRIEVE_VIA_PICKUP_AOU';
667 method = 'FM_AHR_ID_LIST_PULL_LIST'; /*************************************************** PULL ******************************/
668 params.push( 50 ); params.push( 0 );
669 obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
671 var robj = obj.network.simple_request( method, params );
672 if (typeof robj.ilsevent != 'undefined') throw(robj);
673 if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
675 obj.holds = obj.holds.concat( robj.copy_holds );
676 obj.holds = obj.holds.concat( robj.volume_holds );
677 obj.holds = obj.holds.concat( robj.title_holds );
678 obj.holds = obj.holds.sort();
682 //alert('method = ' + method + ' params = ' + js2JSON(params));
685 function list_append(hold_id) {
697 function gen_list_append(hold) {
699 if (typeof obj.controller.view.lib_menu == 'undefined') {
700 list_append(typeof hold == 'object' ? hold.id() : hold);
703 var pickup_lib = hold.pickup_lib();
704 if (typeof pickup_lib == 'object') pickup_lib = pickup_lib.id();
705 if (pickup_lib == obj.controller.view.lib_menu.value) {
707 list_append(typeof hold == 'object' ? hold.id() : hold);
717 //alert('obj.holds = ' + js2JSON(obj.holds));
718 JSAN.use('util.exec'); var exec = new util.exec(2);
720 for (var i in obj.holds) {
721 rows.push( gen_list_append(obj.holds[i]) );
725 if (!dont_show_me_the_list_change) {
726 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
727 try { window.xulG.on_list_change(obj.holds); } catch(E) { this.error.sdump('D_ERROR',E); }
732 'render_lib_menu' : function() {
735 JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
736 var x = document.getElementById('menu_placeholder');
737 if (x.firstChild) return;
738 util.widgets.remove_children( x );
740 var ml = util.widgets.make_menulist(
741 util.functional.map_list(
742 obj.data.list.my_aou.concat(
743 util.functional.filter_list(
744 util.fm_utils.find_ou(
746 obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou()
749 return o.id() != obj.data.list.au[0].ws_ou();
753 function(o) { return [
756 ( ! get_bool( obj.data.hash.aout[ o.ou_type() ].can_have_users() ) ),
757 ( obj.data.hash.aout[ o.ou_type() ].depth() ),
761 var A = obj.data.hash.aou[ a[1] ];
762 var B = obj.data.hash.aou[ b[1] ];
763 var X = obj.data.hash.aout[ A.ou_type() ];
764 var Y = obj.data.hash.aout[ B.ou_type() ];
765 if (X.depth() < Y.depth()) return -1;
766 if (X.depth() > Y.depth()) return 1;
767 if (A.shortname() < B.shortname()) return -1;
768 if (A.shortname() > B.shortname()) return 1;
772 obj.data.list.au[0].ws_ou()
779 obj.list.on_all_fleshed = function() {
781 obj.foreign_shelf = ev.target.value;
783 setTimeout( function() { obj.list.on_all_fleshed = null; }, 0);
785 obj.list.full_retrieve();
788 obj.foreign_shelf = ev.target.value;
793 obj.controller.view.lib_menu = ml;
795 this.error.standard_unexpected_error_alert('rendering lib menu',E);
800 dump('exiting patron.holds.js\n');