$self->ctx->{page} = $page;
$self->ctx->{search_ou} = $self->_get_search_lib();
- if (my $patron_barcode = $self->cgi->param("patron_barcode")) {
- # Special CGI variable from staff client; propagate henceforth as cookie
- $self->apache->headers_out->add(
- "Set-Cookie" => $self->cgi->cookie(
- -name => "patron_barcode",
- -path => "/",
- -secure => 1,
- -value => $patron_barcode,
- -expires => undef
- )
- );
- }
return Apache2::Const::OK;
}
$logger->info("Looking at hold_type: " . $ctx->{hold_type} . " and targets: @targets");
- # if the staff client provides a patron barcode, fetch the patron
- if (my $bc = $self->cgi->cookie("patron_barcode")) {
- $ctx->{patron_recipient} = $U->simplereq(
- "open-ils.actor", "open-ils.actor.user.fleshed.retrieve_by_barcode",
- $self->editor->authtoken, $bc
- ) or return Apache2::Const::HTTP_BAD_REQUEST;
-
- $ctx->{default_pickup_lib} = $ctx->{patron_recipient}->home_ou;
- } else {
- $ctx->{staff_recipient} = $self->editor->retrieve_actor_user([
- $e->requestor->id,
- {
- flesh => 1,
- flesh_fields => {
- au => ['settings', 'card']
- }
+ $ctx->{staff_recipient} = $self->editor->retrieve_actor_user([
+ $e->requestor->id,
+ {
+ flesh => 1,
+ flesh_fields => {
+ au => ['settings', 'card']
}
- ]) or return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
- }
+ }
+ ]) or return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
my $user_setting_map = {
map { $_->name => OpenSRF::Utils::JSON->JSON2perl($_->value) }
@{
- $ctx->{patron_recipient}
- ? $ctx->{patron_recipient}->settings
- : $ctx->{staff_recipient}->settings
+ $ctx->{staff_recipient}->settings
}
};
$ctx->{user_setting_map} = $user_setting_map;
<input type="radio" id="hold_usr_is_requestor_not"
onchange="staff_hold_usr_input_disabler(this);"
name="hold_usr_is_requestor" value="0"
- [% IF ctx.patron_recipient; ' checked="checked"'; END %] />
+ />
<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" onchange="staff_hold_usr_barcode_changed();" 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();" /><br />
<input type="hidden" id="staff_barcode" value="[% ctx.staff_recipient.card.barcode | html %]"/>
<span>
<input type="radio" id="hold_usr_is_requestor"
var cur_hold_barcode = undefined;
function staff_hold_usr_barcode_changed(isload) {
if(typeof xulG != 'undefined' && xulG.get_barcode_and_settings) {
- var barcode = document.getElementById('staff_barcode').value;
+ var barcode = isload;
+ if(!barcode || barcode === true) 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;
- if(!isload)
+ if(!isload) {
+ 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(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(!only_settings || (isload && isload !== true)) 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.default_phone']) load_info.settings['opac.default_phone'] = '';
runEvt('rdetail', 'MFHDDrawn');
}
if(location.href.match(/place_hold/)) {
- staff_hold_usr_barcode_changed(true);
+ if(xulG.patron_barcode) {
+ staff_hold_usr_barcode_changed(xulG.patron_barcode);
+ } else {
+ staff_hold_usr_barcode_changed(true);
+ }
}
}
['command'],
function(ev) {
try {
- var use_url = urls.browser;
- use_url += use_url.match(/\?/) ? "&" : "?";
- use_url += "patron_barcode=" + obj.patron_barcode;
var content_params = {
'show_nav_buttons' : false,
'show_print_button' : true,
'patron_barcode' : obj.patron_barcode
},
'url_prefix' : xulG.url_prefix,
- 'url' : xulG.url_prefix(use_url)
+ 'url' : xulG.url_prefix(urls.browser)
};
xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
} catch(E) {