From cd60d1c12d17f8582ea106c75d87bfd6b8ff77c8 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 4 Apr 2012 15:02:11 -0400 Subject: [PATCH] kpac : getit save to existing list Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../perlmods/lib/OpenILS/WWW/EGKPacLoader.pm | 44 +++++++++++- Open-ILS/src/templates/kpac/getit_results.tt2 | 67 ++++++++++++++----- 2 files changed, 93 insertions(+), 18 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm index d758795e13..c0b1f5ea30 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm @@ -2,7 +2,7 @@ package OpenILS::WWW::EGKPacLoader; use base 'OpenILS::WWW::EGCatLoader'; use strict; use warnings; use XML::Simple; -use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST); +use Apache2::Const -compile => qw(OK HTTP_BAD_REQUEST); use OpenSRF::Utils::Logger qw/$logger/; use OpenILS::Application::AppUtils; use OpenILS::Utils::CStoreEditor qw/:funcs/; @@ -35,7 +35,7 @@ sub load { # ---------------------------------------------------------------- return $self->redirect_ssl unless $self->cgi->https; - return $self->load_simple("getit_results") if $path =~ m|kpac/getit_results|; + return $self->load_getit_results if $path =~ m|kpac/getit_results|; return $self->load_getit if $path =~ m|kpac/getit|; # ---------------------------------------------------------------- @@ -86,6 +86,12 @@ sub save_item_to_bookbag { if ($bookbag_id) { # save to existing bookbag + $self->cgi->param('record', $rec_id); + my $stat = $self->load_myopac_bookbag_update('add_rec', $bookbag_id); + # TODO: check for failure + (my $new_uri = $self->apache->unparsed_uri) =~ s/getit/getit_results/g; + $new_uri .= ($new_uri =~ /\?/) ? "&list=$bookbag_id" : "?list=$bookbag_id"; + return $self->generic_redirect($new_uri); } else { # save to anonymous list @@ -93,9 +99,41 @@ sub save_item_to_bookbag { # set some params assumed to exist for load_mylist_add $self->cgi->param('record', $rec_id); (my $new_uri = $self->apache->unparsed_uri) =~ s/getit/getit_results/g; + $new_uri .= ($new_uri =~ /\?/) ? '&list=anon' : '?list=anon'; $self->cgi->param('redirect_to', $new_uri); - $self->load_mylist_add; + return $self->load_mylist_add; + } + + return Apache2::Const::HTTP_BAD_REQUEST; +} + + +sub load_getit_results { + my $self = shift; + my $ctx = $self->ctx; + my $e = $self->editor; + my $list = $self->cgi->param('list'); + my $hold_id = $self->cgi->param('hold'); + my $rec_id = $ctx->{page_args}->[0]; + + my (undef, @rec_data) = $self->get_records_and_facets([$rec_id]); + $ctx->{bre_id} = $rec_data[0]->{id}; + $ctx->{marc_xml} = $rec_data[0]->{marc_xml}; + + if ($list) { + if ($list eq 'anon') { + $ctx->{anon_list} = 1; + } else { + $ctx->{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... + $e->xact_rollback; } return Apache2::Const::OK; diff --git a/Open-ILS/src/templates/kpac/getit_results.tt2 b/Open-ILS/src/templates/kpac/getit_results.tt2 index 56686f3069..ebd8de0fee 100644 --- a/Open-ILS/src/templates/kpac/getit_results.tt2 +++ b/Open-ILS/src/templates/kpac/getit_results.tt2 @@ -1,22 +1,59 @@ [% PROCESS "opac/parts/header.tt2"; PROCESS "kpac/parts/grid.tt2"; WRAPPER "kpac/parts/subpage.tt2"; - ctx.page_title = l('Get it') %] + PROCESS "opac/parts/misc_util.tt2"; # MARC + attrs = {marc_xml => ctx.marc_xml}; + PROCESS get_marc_attrs args=attrs; + ctx.page_title = l('Get it'); + kill_params = ['list', 'hold']; + title_html = attrs.title | html; +%] -

You Got It!

- -
-

Your Request for Book Name was successful.
You will be able to pick up this material at Fairwood.

-
- - +

You Got It!

+ +
+ [% IF ctx.anon_list %] +

+ [% |l(title_html) %] + You successfully saved [_1].
+ To manage your lists, go to My Lists + [% END %] +

+ [% ELSIF ctx.list %] + [% list_html = ctx.list.name | html %] +

+ [% |l(title_html, list_html) %] + You successfully saved [_1] to [_2].
+ To manage your lists, go to My Lists + [% END %] +

+ [% ELSE %] + [% lib_html = ctx.get_aou(ctx.hold.pickup_lib).name | html %] +

+ [% |l(title_html, lib_html) %] + Your request for [_1] was successful.
+ You will be able to pick up this material at [_2]. + [% END %] +

+ [% END %] +

+ + [% END %] -- 2.43.2