copy and volume level holds for staff
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 12 Jul 2011 21:24:16 +0000 (17:24 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 12 Jul 2011 21:24:16 +0000 (17:24 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/web/templates/default/opac/parts/record/summary.tt2

index 371ce14..9e762e9 100644 (file)
@@ -349,9 +349,36 @@ sub load_place_hold {
     $ctx->{hold_type} = $cgi->param('hold_type');
     $ctx->{default_pickup_lib} = $e->requestor->home_ou; # XXX staff
 
+    # XXX check for failure of the retrieve_* methods called below, and
+    # possibly replace all the if,elsif with a dispatch table (meh, elegance)
+
+    my $target_field;
     if ($ctx->{hold_type} eq 'T') {
+        $target_field = "titleid";
         $ctx->{record} = $e->retrieve_biblio_record_entry($ctx->{hold_target});
+    } elsif ($ctx->{hold_type} eq 'V') {
+        $target_field = "volume_id";
+        my $vol = $e->retrieve_asset_call_number([
+            $ctx->{hold_target}, {
+                "flesh" => 1,
+                "flesh_fields" => {"acn" => ["record"]}
+            }
+        ]);
+        $ctx->{record} = $vol->record;
+    } elsif ($ctx->{hold_type} eq 'C') {
+        $target_field = "copy_id";
+        my $copy = $e->retrieve_asset_copy([
+            $ctx->{hold_target}, {
+                "flesh" => 2,
+                "flesh_fields" => {
+                    "acn" => ["record"],
+                    "acp" => ["call_number"]
+                }
+            }
+        ]);
+        $ctx->{record} = $copy->call_number->record;
     } elsif ($ctx->{hold_type} eq 'I') {
+        $target_field = "issuanceid";
         my $iss = $e->retrieve_serial_issuance([
             $ctx->{hold_target}, {
                 "flesh" => 2,
@@ -388,8 +415,9 @@ sub load_place_hold {
 
         my $args = {
             patronid => $usr,
-            titleid => $ctx->{hold_target}, # XXX
+            $target_field => $ctx->{"hold_target"},
             pickup_lib => $pickup_lib,
+            hold_type => $ctx->{"hold_type"},
             depth => 0, # XXX
         };
 
index 4dbfadc..96748e4 100644 (file)
             [% IF ctx.is_staff %]
             <td>[% l("Age Hold Protection") %]</td>
             <td>[% l("Create Date") %]</td>
-            <td>[% l("Holdable") %]</td>
+            <td>[% l("Holdable?") %]</td>
             [% END %]
             <td>[% l("Status") %]</td>
             <td>[% l("Due Date") %]</td>
         </tr>
     </thead>
     <tbody class="copy_details_table">
-        [% FOR copy_info IN ctx.copies %]
+        [% last_cn = 0;
+        FOR copy_info IN ctx.copies %]
         <tr>
             <td>[%
                 # XXX KCLS-specific kludging
                 ctx.parse_datetime(copy_info.create_date),
                 DATE_FORMAT
             ) %]</td>
-            <td>[% (copy_info.holdable == 't' AND
-                    copy_info.location_holdable == 't' AND
-                    copy_info.status_holdable == 't') ? l('Yes') : l('No') %]</td>
+            <td>[%  # Show copy/volume hold links to staff (without
+                    # checking whether they have permissions to do those).
+                    overall_holdable = (copy_info.holdable == 't' AND
+                        copy_info.location_holdable == 't' AND
+                        copy_info.status_holdable == 't');
+                    IF overall_holdable;
+                        l("Place on"); %]
+                <a href="[% ctx.opac_root %]/place_hold[% propagator; propagator.length > 1 ? "&amp;" : ""; %]hold_target=[% copy_info.id %]&amp;hold_type=C">[% l("copy") %]</a>
+                [%      IF copy_info.call_number != last_cn;
+                            last_cn = copy_info.call_number;
+                            l(" / "); %]
+                <a href="[% ctx.opac_root %]/place_hold[% propagator; propagator.length > 1 ? "&amp;" : ""; %]hold_target=[% copy_info.call_number %]&amp;hold_type=V">[% l("volume") %]</a>
+                [%      END;
+                    ELSE;
+                        l("No");
+                    END %]</td>
             [% END %]
             <td>[% copy_info.copy_status %]</td>
             <td>[%