sub load_simple {
my ($self, $page) = @_;
$self->ctx->{page} = $page;
+
+ 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;
}
$ctx->{hold_target} = $cgi->param('hold_target');
$ctx->{hold_type} = $cgi->param('hold_type');
- # Although in the context of staff placing holds for other users, this
- # does not yield the appropriate pickup lib, that situation is addressed
- # in the client with javascript when possible.
- $ctx->{default_pickup_lib} = $e->requestor->home_ou;
+ $ctx->{default_pickup_lib} = $e->requestor->home_ou; # unless changed below
- my $request_lib = $e->requestor->ws_ou || $e->requestor->home_ou;
+ if (my $bc = $self->cgi->cookie("patron_barcode")) {
+ # passed in from staff client
+ $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_INTERNAL_SERVER_ERROR;
+
+ $ctx->{default_pickup_lib} = $ctx->{patron_recipient}->home_ou;
+ }
+
+ my $request_lib = $e->requestor->ws_ou;
# XXX check for failure of the retrieve_* methods called below, and
# possibly replace all the if,elsif with a dispatch table (meh, elegance)
$self->apache->log->info(
"Redirecting back to " . $cgi->param('redirect_to')
);
- return $self->generic_redirect;
+
+ # We also clear the patron_barcode (from the staff client)
+ # cookie at this point (otherwise it haunts the staff user
+ # later). XXX todo make sure this is best; also see that
+ # template when staff mode calls xulG.opac_hold_placed()
+ return $self->generic_redirect(
+ undef,
+ $self->cgi->cookie(
+ -name => "patron_barcode",
+ -path => "/",
+ -secure => 1,
+ -value => "",
+ -expires => "-1h"
+ )
+ );
} else {
$ctx->{hold_failed} = 1;
document.getElementById("hold_usr_input").disabled =
Boolean(Number(input.value));
}
-function staff_hold_usr_prepop() {
- if (xulG && xulG.patron_barcode) {
- var sel = document.getElementById("pickup_lib");
- for (var i = 0; i < sel.options.length; i++) {
- if (sel.options[i].value == xulG.patron_home_ou) {
- sel.selectedIndex = i;
- break;
- }
- }
- document.getElementById("hold_usr_input").value = xulG.patron_barcode;
- document.getElementById("hold_usr_input").disabled = false;
- document.getElementById("hold_usr_is_requestor_not").checked = true;
-
- var kill_this =
- document.getElementById("hold_usr_is_requestor").parentNode;
- kill_this.parentNode.removeChild(kill_this);
- }
-}
window.onload = function() {
// record details page events
var rec = location.href.match(/\/opac\/record\/(\d+)/);
if(rec && rec[1]) { runEvt('rdetail', 'recordRetrieved', rec[1]); }
-
- if (document.getElementById("hold_usr_input"))
- staff_hold_usr_prepop();
-
// fire other events the staff client is expecting...
}
<p class="staff-hold">
<input type="radio" id="hold_usr_is_requestor_not"
onchange="staff_hold_usr_input_disabler(this);"
- name="hold_usr_is_requestor" value="0" />
+ 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" /><br />
+ <input type="text" name="hold_usr" id="hold_usr_input" value="[% ctx.patron_recipient.card.barcode %]" /><br />[%# XXX multi-barcode users? %]
<span>
<input type="radio" id="hold_usr_is_requestor"
onchange="staff_hold_usr_input_disabler(this);"
['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,
obj.error.standard_unexpected_error_alert('holds.js, opac_hold_placed(): ',E);
}
},
- 'patron_barcode' : obj.patron_barcode,
- 'patron_home_ou': patron.util.retrieve_au_via_id(ses(),obj.patron_id).home_ou()
+ 'patron_barcode' : obj.patron_barcode
},
'url_prefix' : xulG.url_prefix,
- 'url' : xulG.url_prefix( urls.browser )
+ 'url' : xulG.url_prefix(use_url)
};
xulG.display_window.g.patron.right_deck.set_iframe( urls.XUL_REMOTE_BROWSER + '?patron_hold=1', {}, content_params);
} catch(E) {