From: Lebbeous Fogle-Weekley Date: Mon, 18 Jul 2011 22:49:01 +0000 (-0400) Subject: Fix the wrongish way we were doing staff-assisted holds X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b77da9ed21b7602c5758472bce76755674135d6a;p=evergreen%2Fpines.git Fix the wrongish way we were doing staff-assisted holds Now the patron that a staff user wants to place a hold for is passed around as a cookie It's a little unclear when is best from a workflow perspective to kill said cookie... hrmmm.... Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 72fbf59eb3..b1d64830a7 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -168,6 +168,19 @@ sub redirect_auth { 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; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 410d06a912..a715ab34de 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -400,12 +400,19 @@ sub load_place_hold { $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) @@ -527,7 +534,21 @@ sub load_place_hold { $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; diff --git a/Open-ILS/web/js/ui/default/opac/staff.js b/Open-ILS/web/js/ui/default/opac/staff.js index 16234b569f..c170198fc6 100644 --- a/Open-ILS/web/js/ui/default/opac/staff.js +++ b/Open-ILS/web/js/ui/default/opac/staff.js @@ -18,31 +18,9 @@ function staff_hold_usr_input_disabler(input) { 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... } diff --git a/Open-ILS/web/templates/default/opac/parts/place_hold.tt2 b/Open-ILS/web/templates/default/opac/parts/place_hold.tt2 index 4dcd278898..8ca6075a2e 100644 --- a/Open-ILS/web/templates/default/opac/parts/place_hold.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/place_hold.tt2 @@ -68,11 +68,13 @@

+ name="hold_usr_is_requestor" value="0" + [% IF ctx.patron_recipient; ' checked="checked"'; END %] + /> -
+
[%# XXX multi-barcode users? %]