When staff place holds attempt to load the user's hold preferences.
This also hooks up the barcode completion code to the TPac hold placement
interface.
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
{
flesh => 1,
flesh_fields => {
- au => ['settings']
+ au => ['settings', 'card']
}
}
]) or return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
<label for="hold_usr_is_requestor_not">
[% l("Place hold for patron by barcode:") %]
</label>
- <input type="text" name="hold_usr" id="hold_usr_input" value="[% ctx.patron_recipient.card.barcode | html %]" /><br />[%# XXX multi-barcode users? %]
+ <input type="text" name="hold_usr" id="hold_usr_input" onchange="staff_hold_usr_barcode_changed();" value="[% ctx.patron_recipient.card.barcode | html %]" /><br />[%# XXX multi-barcode users? %]
+ <input type="hidden" id="staff_barcode" value="[% ctx.staff_recipient.card.barcode | html %]"/>
<span>
<input type="radio" id="hold_usr_is_requestor"
onchange="staff_hold_usr_input_disabler(this);"
function staff_hold_usr_input_disabler(input) {
document.getElementById("hold_usr_input").disabled =
Boolean(Number(input.value));
+ staff_hold_usr_barcode_changed();
+}
+var cur_hold_barcode = undefined;
+function staff_hold_usr_barcode_changed() {
+ if(typeof xulG != 'undefined' && xulG.get_barcode_and_settings) {
+ var barcode = document.getElementById('staff_barcode').value;
+ var only_settings = true;
+ if(!document.getElementById('hold_usr_is_requestor').checked) {
+ barcode = document.getElementById('hold_usr_input').value;
+ only_settings = false;
+ if(barcode && barcode != '' && !document.getElementById('hold_usr_is_requestor_not').checked)
+ document.getElementById('hold_usr_is_requestor_not').checked = 'checked';
+ }
+ if(barcode == undefined || barcode == '' || barcode == cur_hold_barcode)
+ return;
+ var load_info = xulG.get_barcode_and_settings(window, barcode, ['opac.hold_notify','opac.default_pickup_location','opac.default_sms_carrier','opac.default_sms_notify','opac.default_phone'], only_settings);
+ if(load_info == false || load_info == undefined)
+ return;
+ cur_hold_barcode = load_info.barcode;
+ if(!only_settings) document.getElementById('hold_usr_input').value = load_info.barcode; // Safe at this point as we already set cur_hold_barcode
+ if(load_info.settings['opac.default_pickup_location'])
+ document.getElementById('pickup_lib').value = load_info.settings['opac.default_pickup_location'];
+ if(load_info.settings['opac.hold_notify']) {
+ var email = load_info.settings['opac.hold_notify'].indexOf('email') > -1;
+ var phone = load_info.settings['opac.hold_notify'].indexOf('phone') > -1;
+ var sms = load_info.settings['opac.hold_notify'].indexOf('sms') > -1;
+ var update_elements = document.getElementsByName('email_notify');
+ for(var i in update_elements) update_elements[i].checked = (email ? 'checked' : '');
+ update_elements = document.getElementsByName('phone_notify_checkbox');
+ for(var i in update_elements) update_elements[i].checked = (phone ? 'checked' : '');
+ update_elements = document.getElementsByName('sms_notify_checkbox');
+ for(var i in update_elements) update_elements[i].checked = (sms ? 'checked' : '');
+ }
+ update_elements = document.getElementsByName('phone_notify');
+ for(var i in update_elements) update_elements[i].value = load_info.settings['opac.default_phone'];
+ update_elements = document.getElementsByName('sms_notify');
+ for(var i in update_elements) update_elements[i].value = load_info.settings['opac.default_sms_notify'];
+ update_elements = document.getElementsByName('sms_carrier');
+ for(var i in update_elements) update_elements[i].value = load_info.settings['opac.default_sms_carrier'];
+ }
}
window.onload = function() {
// record details page events
"set_patron_tab", "volume_item_creator", "get_new_session",
"holdings_maintenance_tab", "open_chrome_window", "url_prefix",
"network_meter", "page_meter", "set_statusbar", "set_help_context",
- "get_barcode", "reload_opac"
+ "get_barcode", "reload_opac", "get_barcode_and_settings"
].forEach(function(k) { content_params[k] = xulG[k]; });
top_pane.set_iframe(
"set_patron_tab", "volume_item_creator", "get_new_session",
"holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
"url_prefix", "network_meter", "page_meter", "set_statusbar",
- "set_help_context", "get_barcode", "reload_opac"
+ "set_help_context", "get_barcode", "reload_opac",
+ "get_barcode_and_settings"
].forEach(function(k) { content_params[k] = xulG[k]; });
var loc = urls.XUL_BROWSER + "?url=" + window.escape(
"set_patron_tab", "volume_item_creator", "get_new_session",
"holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
"url_prefix", "network_meter", "page_meter", "set_statusbar",
- "set_help_context", "get_barcode", "reload_opac"
+ "set_help_context", "get_barcode", "reload_opac",
+ "get_barcode_and_settings"
].forEach(function(k) { content_params[k] = xulG[k]; });
var loc = urls.XUL_BROWSER + "?url=" + window.escape(
g.error.standard_unexpected_error_alert('window_open',E);
}
},
- 'get_barcode' : xulG.get_barcode
+ 'get_barcode' : xulG.get_barcode,
+ 'get_barcode_and_settings' : xulG.get_barcode_and_settings
},
'on_url_load' : function(f) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
content_params.set_statusbar = xulG.set_statusbar;
content_params.set_help_context = xulG.set_help_context;
content_params.get_barcode = xulG.get_barcode;
+ content_params.get_barcode_and_settings = xulG.get_barcode_and_settings;
var secure_opac = true; // default to secure
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
content_params.set_statusbar = xulG.set_statusbar;
content_params.set_help_context = xulG.set_help_context;
content_params.get_barcode = xulG.get_barcode;
+ content_params.get_barcode_and_settings = xulG.get_barcode_and_settings;
xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
} catch(E) {
"set_patron_tab", "volume_item_creator", "get_new_session",
"holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
"url_prefix", "network_meter", "page_meter", "set_statusbar",
- "set_help_context", "get_barcode", "reload_opac"
+ "set_help_context", "get_barcode", "reload_opac",
+ "get_barcode_and_settings"
].forEach(function(k) { content_params[k] = xulG[k]; });
xulG.new_tab(
urls.remote = params['server'];
xulG.get_barcode = this.get_barcode;
+ xulG.get_barcode_and_settings = this.get_barcode_and_settings;
// Pull in local customizations
var r = new XMLHttpRequest();
content_params.network_meter = obj.network_meter;
content_params.page_meter = obj.page_meter;
content_params.get_barcode = obj.get_barcode;
+ content_params.get_barcode_and_settings = obj.get_barcode_and_settings;
content_params.render_toolbar_layout = function(layout) { return obj.render_toolbar_layout(layout); };
content_params.set_statusbar = function(slot,text,tooltiptext,click_handler) {
var e = document.getElementById('statusbarpanel'+slot);
return "user_false";
},
+ 'get_barcode_and_settings' : function(window, barcode, settings, settings_only) {
+ JSAN.use('util.network');
+ if(!settings_only) {
+ // We need to double-check the barcode for completion and such.
+ var new_barcode = xulG.get_barcode(window, 'actor', barcode);
+ if(new_barcode == "user_false") return;
+ // No error means we have a (hopefully valid) completed barcode to use.
+ // Otherwise, fall through to other methods of checking
+ if(typeof new_barcode.ilsevent == 'undefined')
+ barcode = new_barcode.barcode;
+ else
+ return false;
+ }
+ var network = new util.network();
+ // We have a barcode! Time to load settings.
+ // First, we need the user ID
+ var user_id = network.simple_request('FM_AU_ID_RETRIEVE_VIA_BARCODE_OR_USERNAME', [ ses(), barcode ]);
+ if(user_id.ilsevent != undefined || user_id.textcode != undefined)
+ return false;
+ var settings = network.simple_request('FM_AUS_RETRIEVE', [ ses(), user_id, settings ]);
+ return {"barcode": barcode, "settings" : settings};
+ },
+
'sort_menu' : function(menu, recurse) {
var curgroup = new Array();
var curstart = 1;
urls.EG_ACQ_USER_REQUESTS + '?usr=' + obj.patron.id(),
{},
{
- 'get_barcodes' : function(a) { return xulG.get_barcodes(a); }
+ 'get_barcode' : function(a,b,c) { return xulG.get_barcode(a,b,c); },
+ 'get_barcode_and_settings' : function(a,b,c,d) { return xulG.get_barcode_and_settings(a,b,c,d); }
}
);
}
}
},
'get_barcode' : xulG.get_barcode,
+ 'get_barcode_and_settings' : xulG.get_barcode_and_settings,
'url_prefix' : xulG.url_prefix
}
);