serial issue display and holds work
authorsenator <lebbeous@esilibrary.com>
Mon, 9 May 2011 19:01:41 +0000 (15:01 -0400)
committersenator <lebbeous@esilibrary.com>
Mon, 9 May 2011 19:01:41 +0000 (15:01 -0400)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/web/templates/default/opac/parts/record/extras.tt2
Open-ILS/web/templates/default/opac/parts/record/issues.tt2 [new file with mode: 0644]

index 2486e23..f8622b5 100644 (file)
@@ -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;
     }
     # ...
 
index 3a54fbc..7b56ee4 100644 (file)
@@ -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;
index 8bafc7d..b101603 100644 (file)
@@ -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 (file)
index 0000000..4f9f295
--- /dev/null
@@ -0,0 +1,26 @@
+<div id='rdetail_issues_div' class='rdetail_extras_div'>
+[%
+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; %]
+    <div class="rdetail-issue-type">
+        <a href="[% base_expando; expanded ? '' : '&amp;expand_holding_type=' _ type; %]#issues">[[% expanded ? '-' : '+' %]]</a>
+        [% ctx.holding_summaries.$type.join(", ") %]
+        [% IF expanded %]
+        <table>
+            [% FOR blob IN ctx.expanded_holdings %]
+            <tr>
+                <td class="rdetail-issue-issue">[% blob.issuance.label %]</td>
+                [% IF blob.has_units %]
+                <td class="rdetail-issue-place-hold">
+                    <a href="[% ctx.opac_root %]/place_hold?hold_target=[% blob.issuance.id %]&amp;hold_type=I">[% l("Place Hold") %]</a>
+                </td>
+                [% END %]
+            </tr>
+            [% END %]
+        </table>
+        [% END %]
+    </div>
+[% END %]
+</div>