From 57e3b882f6021db354149ae6405b97f8d5c703de Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Tue, 15 Nov 2016 16:41:45 +0100
Subject: [PATCH] Bug 17624: [Follow-up] Consistency between Availability and
 Location
Content-Type: text/plain; charset=utf-8

If OpacItemLocation is set to location, the opac results xslt shows
something like:
    Availability: Copies available for loan: Library(1).
                  Copies available for reference: Library(1).
    Location(s):  Location_1 callnumber_1

Note that the reference item is not listed under Location, since the logic
for that section is different. Simply stated: Available is created by two
separate if statements, but Location is one if-else statement.

This patch changes the Location logic to two if statements. In this
process some single choose/when's are replaced by simple if's. Actually,
the change is quite minimal.

Test plan:
[1] Set OPACXSLTResultsHideNFL to Show.
    Set OpacItemLocation to Location.
[2] Use a biblio with two items. Put data in callnumber and location.
    Mark one item as not for loan.
[3] Verify that you now see both items in the Location line of the
    search results.
---
 .../bootstrap/en/xslt/MARC21slim2OPACResults.xsl      | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl
index b1ea15f..63b944f 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl
@@ -1294,12 +1294,11 @@
                        <xsl:text>). </xsl:text>                   </span>
                    </xsl:if>
                </span>
-    <xsl:choose>
-        <xsl:when test="($OPACItemLocation='location' or $OPACItemLocation='ccode') and (count(key('item-by-status', 'available'))>0 or ($OPACXSLTResultsHideNFL=0 and count(key('item-by-status', 'reference'))>0))">
+
+        <xsl:if test="($OPACItemLocation='location' or $OPACItemLocation='ccode') and (count(key('item-by-status', 'available'))>0 or ($OPACXSLTResultsHideNFL=0 and count(key('item-by-status', 'reference'))>0))">
             <span class="results_summary location">
                 <span class="label">Location(s): </span>
-                <xsl:choose>
-                <xsl:when test="count(key('item-by-status', 'available'))>0">
+                <xsl:if test="count(key('item-by-status', 'available'))>0">
                     <span class="available">
                         <xsl:variable name="available_items" select="key('item-by-status', 'available')"/>
                         <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]">
@@ -1311,8 +1310,9 @@
                             <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose>
                         </xsl:for-each>
                     </span>
-                </xsl:when>
-                <xsl:when test="$OPACXSLTResultsHideNFL=0 and count(key('item-by-status', 'reference'))>0">
+                </xsl:if>
+
+                <xsl:if test="$OPACXSLTResultsHideNFL=0 and count(key('item-by-status', 'reference'))>0">
                     <span class="available">
                         <xsl:variable name="reference_items" select="key('item-by-status', 'reference')"/>
                         <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]">
@@ -1324,11 +1324,10 @@
                             <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose>
                         </xsl:for-each>
                     </span>
-                </xsl:when>
-                </xsl:choose>
+                </xsl:if>
+
             </span>
-        </xsl:when>
-       </xsl:choose>
+        </xsl:if>
     </xsl:template>
 
     <xsl:template name="nameABCQ">
-- 
2.1.4