Avoid top-level copy counts in TPAC
authorDan Scott <dscott@laurentian.ca>
Tue, 14 Aug 2012 20:51:59 +0000 (16:51 -0400)
committerDan Scott <dscott@laurentian.ca>
Tue, 14 Aug 2012 20:51:59 +0000 (16:51 -0400)
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/templates_conifer/opac/parts/record/copy_counts.tt2 [new file with mode: 0644]
Open-ILS/src/templates_conifer/opac/parts/result/copy_counts.tt2 [new file with mode: 0644]

diff --git a/Open-ILS/src/templates_conifer/opac/parts/record/copy_counts.tt2 b/Open-ILS/src/templates_conifer/opac/parts/record/copy_counts.tt2
new file mode 100644 (file)
index 0000000..b71e732
--- /dev/null
@@ -0,0 +1,48 @@
+<span id="rdetail_copy_counts">
+    <h2>[% l('Available copies') %]</h2>
+    <ul>
+    [%- depths = ctx.copy_summary.size;
+        depth = 1;
+        displayed_ous = {};
+        WHILE depth < depths;
+            ou_avail = ctx.copy_summary.$depth.available;
+            ou_id = ctx.copy_summary.$depth.org_unit;
+            cp_org_unit = ctx.get_aou(ou_id);
+            IF cp_org_unit.opac_visible == 'f' AND !ctx.is_staff;
+                depth = depth + 1;
+                NEXT;
+            END;
+            ou_name = cp_org_unit.name;
+            displayed_ous.$ou_name = 1;
+    %]
+    <li>
+    [% l('[quant,_1,copy,copies] at [_2].', ou_avail, ou_name) | html %]
+    [%- this_depth = ctx.get_aou(ou_id).ou_type.depth;
+        IF ou_avail > 0 && this_depth != ctx.copy_depth %]
+    <a href="[% mkurl('', {copy_depth => this_depth}, ['copy_offset']); %]"
+       title="[% l('Show copies at [_1]', ou_name); %]">
+       [%- l('(Show)'); %]</a>
+    [%- END; %]
+    </li>
+    [%- depth = depth + 1;
+        END;
+
+        depth = attrs.plib_copy_counts.size - 1;
+        ou_name = ctx.get_aou(attrs.plib_copy_counts.$depth.org_unit).name;
+        ou_id = attrs.plib_copy_counts.$depth.org_unit;
+        UNLESS depth < 0 || displayed_ous.exists(ou_name);
+    %]
+    [%- IF attrs.plib_copy_counts.$depth.count > 0; %]
+    <li class="preferred">[%
+        l('[_1] of [quant,_2,copy,copies] available at [_3].',
+            attrs.plib_copy_counts.$depth.available,
+            attrs.plib_copy_counts.$depth.count,
+            ou_name) | html
+    %] <a href="[% mkurl('', {locg => ou_id}, ['copy_offset']); %]"
+       title="[% l('Show copies at [_1]', ou_name); %]">[%
+       l('(Show preferred library)');
+    %]</a></li>
+    [%- END %]
+    [%- END %]
+    </ul>
+</span>
diff --git a/Open-ILS/src/templates_conifer/opac/parts/result/copy_counts.tt2 b/Open-ILS/src/templates_conifer/opac/parts/result/copy_counts.tt2
new file mode 100644 (file)
index 0000000..fec87fa
--- /dev/null
@@ -0,0 +1,36 @@
+[%- depths = attrs.copy_counts.size;
+    depth = 1;
+    displayed_ous = {};
+    WHILE depth < depths;
+        ou_name = ctx.get_aou(attrs.copy_counts.$depth.org_unit).name;
+        displayed_ous.$ou_name = 1;
+        IF attrs.copy_counts.$depth.count > 0;
+%]
+<div class="result_count">
+[% IF ctx.get_aou(attrs.copy_counts.$depth.org_unit).opac_visible == 't' %]
+    [% l('[_1] of [quant,_2,copy,copies] available at [_3].',
+        attrs.copy_counts.$depth.available,
+        attrs.copy_counts.$depth.count,
+        ou_name) | html
+    %]
+[% END %]
+</div>
+[%-     END;
+    depth = depth + 1;
+    END;
+
+    depth = attrs.plib_copy_counts.size - 1;
+    ou_name = ctx.get_aou(attrs.plib_copy_counts.$depth.org_unit).name;
+    UNLESS displayed_ous.exists(ou_name);
+    
+%]
+[%- IF attrs.plib_copy_counts.$depth.count > 0; %]
+<div class="result_count preferred">[%
+     l('[_1] of [quant,_2,copy,copies] available at [_3].',
+        attrs.plib_copy_counts.$depth.available,
+        attrs.plib_copy_counts.$depth.count,
+        ou_name) | html
+    %]
+</div>
+[%- END %]
+[%- END %]