From 35db902ccd97696d360772c43c37d4add035aff6 Mon Sep 17 00:00:00 2001 From: senator Date: Mon, 9 May 2011 15:01:41 -0400 Subject: [PATCH] serial issue display and holds work --- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 12 ++++- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 52 +++++++++++++++++++- .../templates/default/opac/parts/record/extras.tt2 | 1 + .../templates/default/opac/parts/record/issues.tt2 | 26 ++++++++++ 4 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/web/templates/default/opac/parts/record/issues.tt2 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 2486e23..f8622b5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -304,8 +304,18 @@ sub load_place_hold { $ctx->{hold_type} = $cgi->param('hold_type'); $ctx->{default_pickup_lib} = $e->requestor->home_ou; # XXX staff - if($ctx->{hold_type} eq 'T') { + if ($ctx->{hold_type} eq 'T') { $ctx->{record} = $e->retrieve_biblio_record_entry($ctx->{hold_target}); + } elsif ($ctx->{hold_type} eq 'I') { + my $iss = $e->retrieve_serial_issuance([ + $ctx->{hold_target}, { + "flesh" => 2, + "flesh_fields" => { + "siss" => ["subscription"], "ssub" => ["record_entry"] + } + } + ]); + $ctx->{record} = $iss->subscription->record_entry; } # ... diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 3a54fbc..7b56ee4 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -36,11 +36,30 @@ sub load_record { $ctx->{copy_limit} = $copy_limit; $ctx->{copy_offset} = $copy_offset; + $ctx->{have_holdings_to_show} = 0; + + # XXX TODO we'll also need conditional logic to show MFHD-based holdings + if ( + $ctx->{get_org_setting}-> + ($org, "opac.fully_compressed_serial_holdings") + ) { + $ctx->{holding_summaries} = + $self->get_holding_summaries($rec_id, $org, $depth); + + $ctx->{have_holdings_to_show} = + scalar(@{$ctx->{holding_summaries}->{basic}}) || + scalar(@{$ctx->{holding_summaries}->{index}}) || + scalar(@{$ctx->{holding_summaries}->{supplement}}); + } + for my $expand ($self->cgi->param('expand')) { $ctx->{"expand_$expand"} = 1; - if($expand eq 'marchtml') { + if ($expand eq 'marchtml') { $ctx->{marchtml} = $self->mk_marc_html($rec_id); - } + } elsif ($expand eq 'issues' and $ctx->{have_holdings_to_show}) { + $ctx->{expanded_holdings} = + $self->get_expanded_holdings($rec_id, $org, $depth); + } } return Apache2::Const::OK; @@ -137,4 +156,33 @@ sub mk_marc_html { 'open-ils.search.biblio.record.html', $rec_id, 1); } +sub get_holding_summaries { + my ($self, $rec_id, $org, $depth) = @_; + + return ( + create OpenSRF::AppSession("open-ils.serial")->request( + "open-ils.serial.bib.summary_statements", + $rec_id, {"org_id" => $org, "depth" => $depth} + )->gather(1) + ); +} + +sub get_expanded_holdings { + my ($self, $rec_id, $org, $depth) = @_; + + my $holding_limit = int($self->cgi->param("holding_limit") || 10); + my $holding_offset = int($self->cgi->param("holding_offset") || 0); + my $type = $self->cgi->param("expand_holding_type"); + + return create OpenSRF::AppSession("open-ils.serial")->request( + "open-ils.serial.received_siss.retrieve.by_bib.atomic", + $rec_id, { + "ou" => $org, "depth" => $depth, + "limit" => $holding_limit, "offset" => $holding_offset, + "type" => $type + } + )->gather(1); +} + + 1; diff --git a/Open-ILS/web/templates/default/opac/parts/record/extras.tt2 b/Open-ILS/web/templates/default/opac/parts/record/extras.tt2 index 8bafc7d..b101603 100644 --- a/Open-ILS/web/templates/default/opac/parts/record/extras.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/record/extras.tt2 @@ -36,6 +36,7 @@ {name => 'annotation', label => l('Annotation'), hide => 1}, {name => 'reviews', label => l('Reviews'), hide => 1}, {name => 'excerpt', label => l('Excerpt'), hide => 1}, + {name => 'issues', label => l('Issues Held'), hide => !ctx.have_holdings_to_show}, {name => 'preview', label => l('Preview'), hide => 1}, {name => 'novelist', label => l('Suggestions by NoveList'), hide => 1}, {name => 'cnbrowse', label => l('Shelf Browser'), hide => 1}, diff --git a/Open-ILS/web/templates/default/opac/parts/record/issues.tt2 b/Open-ILS/web/templates/default/opac/parts/record/issues.tt2 new file mode 100644 index 0000000..4f9f295 --- /dev/null +++ b/Open-ILS/web/templates/default/opac/parts/record/issues.tt2 @@ -0,0 +1,26 @@ +
+[% +base_expando = ctx.full_path _ "?expand=issues"; +FOREACH type IN ctx.holding_summaries.keys; + NEXT UNLESS ctx.holding_summaries.$type.size; + expanded = CGI.param('expand_holding_type') == type; %] +
+ [[% expanded ? '-' : '+' %]] + [% ctx.holding_summaries.$type.join(", ") %] + [% IF expanded %] + + [% FOR blob IN ctx.expanded_holdings %] + + + [% IF blob.has_units %] + + [% END %] + + [% END %] +
[% blob.issuance.label %] + [% l("Place Hold") %] +
+ [% END %] +
+[% END %] +
-- 1.7.2.5