KMAIN-324 Fixes bug: Copy and Hold count were not displaying properly
authorBill Erickson <berickxx@gmail.com>
Wed, 29 Oct 2014 21:05:59 +0000 (17:05 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
    Cross-port: 77f6b0d

KCLS/openils/var/templates_kcls/opac/parts/result/copy_counts.tt2 [new file with mode: 0644]
KCLS/openils/var/templates_kcls/opac/parts/result/table.tt2
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm

diff --git a/KCLS/openils/var/templates_kcls/opac/parts/result/copy_counts.tt2 b/KCLS/openils/var/templates_kcls/opac/parts/result/copy_counts.tt2
new file mode 100644 (file)
index 0000000..43d1ba2
--- /dev/null
@@ -0,0 +1,42 @@
+[%- depths = attrs.copy_counts.size;
+    depth = 0;
+    displayed_ous = {};
+    hiding_disabled = ctx.org_hiding_disabled();
+    WHILE depth < depths;
+        org_unit = ctx.get_aou(attrs.copy_counts.$depth.org_unit);
+        ou_name = org_unit.name;
+        displayed_ous.$ou_name = 1;
+        IF attrs.copy_counts.$depth.count > 0 AND (
+            hiding_disabled OR ctx.org_within_hiding_scope(org_unit.id));
+%]
+<div class="result_count">
+[% IF ctx.get_aou(attrs.copy_counts.$depth.org_unit).opac_visible == 't' %]
+    [% l('[quant,_1,hold,holds] on first copy returned of [quant,_2,copy,copies]',
+        rec.hold_count, attrs.copy_counts.$depth.count) | html
+    %]
+    </br>
+    [% l('[quant,_1,copy,copies] available',
+        attrs.copy_counts.$depth.available) | html
+    %]
+[% END %]
+</div>
+[%-     END;
+    depth = depth + 1;
+    END;
+
+    depth = attrs.plib_copy_counts.size - 1;
+    org_unit = ctx.get_aou(attrs.plib_copy_counts.$depth.org_unit);
+    ou_name = org_unit.name;
+    UNLESS displayed_ous.exists(ou_name);
+
+%]
+[%- IF attrs.plib_copy_counts.$depth.count > 0 AND (
+        hiding_disabled OR ctx.org_within_hiding_scope(org_unit.id)) %]
+<div class="result_count preferred">[%
+     l('[quant,_1,copy,copies] available',
+        attrs.copy_counts.$depth.available) | html
+    %]
+</div>
+[%- END %]
+[%- END %]
+
index 9375560..691a6bb 100644 (file)
                                                         [% END %]
 
                                                     </table>
-                                                    <div>
-                                                        [% l('[quant,_1,hold,holds] on first copy returned of [quant,_2,copy,copies]',
-                                                                rec.hold_count, attrs.copy_counts.count) %]
-                                                        <br/>
-                                                        [% l('[quant,_1,copy,copies] available', attrs.copy_counts.available) %]
-                                                    </div>
+                                                    [% PROCESS "opac/parts/result/copy_counts.tt2" %]
                                                     [% IF rec.user_circulated %]
                                                     <div class="result_item_circulated">
                                                         <img src="[% ctx.media_prefix %]/images/green_check.png" alt="[% l('Checked Out Before') %]"/>
index c21566a..01fb36f 100644 (file)
@@ -568,6 +568,13 @@ sub load_rresults {
         }
     }
 
+    # KCLS custom
+    # Adds hold count to records in context
+    for my $rec ( @{ $ctx->{records} } ) {
+        $rec->{hold_count} = $U->simplereq(
+            'open-ils.circ', 'open-ils.circ.bre.holds.count', $rec->{id});
+    }
+
     for my $rec (@{$ctx->{records}}) {
         my ($res_rec) = grep { $_->[0] == $rec->{$id_key} } @{$results->{ids}};
         $rec->{badges} = [split(',', $res_rec->[1])] if $res_rec->[1];