my $password = $self->cgi->param('password');
my $pickup_lib = $self->cgi->param('pickup_lib');
+ return Apache2::Const::HTTP_BAD_REQUEST
+ unless $pickup_lib =~ /^\d+$/;
+
+ my $new_uri = $self->apache->unparsed_uri;
+ my $sep = ($new_uri =~ /\?/) ? '&' : '?';
+
if (!$ctx->{user}) {
# First, log the user in and return to
+ $self->apache->log->info("kpac: logging in $username");
+
# TODO: let user know username/password is required..
return Apache2::Const::OK unless $username and $password;
- my $new_uri = $self->apache->unparsed_uri;
- my $sep = ($new_uri =~ /\?/) ? '&' : '?';
+
$new_uri .= "${sep}pickup_lib=$pickup_lib&action=hold";
$self->cgi->param('redirect_to', $new_uri);
return $self->load_login;
- }
- # TODO: place hold
+ } else {
- my $hold_id = '';
-# (my $new_uri = $self->apache->unparsed_uri) =~ s/getit/getit_results/g;
-# $new_uri .= ($new_uri =~ /\?/) ? "&hold=$hold_id" : "?hold=$hold_id";
-# return $self->generic_redirect($new_uri);
+ $self->apache->log->info("kpac: placing hold for $bre_id");
- return Apache2::Const::OK;
+ $new_uri =~ s/getit/getit_results/g;
+ $self->cgi->param('hold_target', $bre_id);
+ $self->cgi->param('hold_type', 'T');
+ $self->cgi->param('part', ''); # needed even if unused
+
+ my $stat = $self->load_place_hold;
+
+ $self->apache->log->info("kpac: place hold returned $stat");
+
+ return $stat unless $stat == Apache2::Const::OK;
+
+ my $hdata = $ctx->{hold_data}->[0]; # only 1 hold placed
+ if (my $hold_id = $hdata ? $hdata->{hold_success} : undef) {
+
+ $self->apache->log->info("kpac: place hold succeeded");
+ $new_uri .= "${sep}hold=$hold_id";
+
+ } else {
+ $self->apache->log->info("kpac: place hold failed : " . $ctx->{hold_failed_event});
+ $new_uri .= "${sep}hold_failed=1";
+ }
+ }
+
+ $self->apache->log->info("kpac: place hold redirecting to: $new_uri");
+ return $self->generic_redirect($new_uri);
}
sub save_item_to_bookbag {
if ($list) {
if ($list eq 'anon') {
- $ctx->{anon_list} = 1;
+ $ctx->{added_to_anon} = 1;
} else {
- $ctx->{list} = $e->retrieve_container_biblio_record_entry_bucket($list);
+ $ctx->{added_to_list} = $e->retrieve_container_biblio_record_entry_bucket($list);
}
-
- } elsif ($hold_id) {
-
- # new hold means potential for replication lag
- $e->xact_start;
- # fetch the hold...
+ } else {
+ $e->xact_begin;
+ $ctx->{hold} = $e->retrieve_action_hold_request(8);
$e->xact_rollback;
}
attrs = {marc_xml => ctx.marc_xml};
PROCESS get_marc_attrs args=attrs;
ctx.page_title = l('Get it');
- kill_params = ['list', 'hold'];
+ kill_params = ['list', 'hold', 'hold_failed', 'pickup_lib'];
title_html = attrs.title | html;
%]
-<h2 class="sub_header2">You Got It!</h2>
<div class="checkout_res_body">
- [% IF ctx.anon_list %]
+ [% IF ctx.added_to_anon %]
+ <h2 class="sub_header2">[% l('You Saved It!') %]</h2>
<p>
[% |l(title_html) %]
You successfully saved [_1]. <br/>
To manage your lists, go to <a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {}, 1) %]">My Lists</a>
[% END %]
<p>
- [% ELSIF ctx.list %]
+ [% ELSIF ctx.added_to_list %]
[% list_html = ctx.list.name | html %]
+ <h2 class="sub_header2">[% l('You Saved It!') %]</h2>
<p>
[% |l(title_html, list_html) %]
You successfully saved [_1] to [_2]. <br/>
To manage your lists, go to <a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {}, 1) %]">My Lists</a>
[% END %]
<p>
- [% ELSE %]
+ [% ELSIF CGI.param('hold') %]
[% lib_html = ctx.get_aou(ctx.hold.pickup_lib).name | html %]
+ <h2 class="sub_header2">[% l('You Got It!') %]</h2>
<p>
[% |l(title_html, lib_html) %]
Your request for <a href="[% mkurl(ctx.kpac_root _ '/record/' _ ctx.bre_id, {}, kill_params) %]">[_1]</a> was successful.<br/>
You will be able to pick up this material at [_2].
[% END %]
<p>
+ [% ELSE %]
+ <p>
+ [% |l(title_html) %]
+ Unable to request <a href="[% mkurl(ctx.kpac_root _ '/record/' _ ctx.bre_id, {}, kill_params) %]">[_1]</a>.<br/>
+ Please see a librarian.
+ [% END %]
[% END %]
</div>