From 76003df43babeb22592d7aa9a5844a559d26215e Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Wed, 17 Apr 2013 16:54:59 +0200
Subject: [PATCH] Bug 9995: Followup for Location line
Content-Type: text/plain; charset=utf-8

Simplifying erroneous code mixing information from two levels.
Takes into account Singlebranchmode.
All items, available or for reference, are shown on this line.
---
 .../prog/en/xslt/MARC21slim2OPACResults.xsl        |   46 ++++++--------------
 1 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
index 83a0e15..ab16553 100644
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
@@ -1106,41 +1106,23 @@
                    </xsl:if>
                </span>
 
-    <xsl:choose>
-        <xsl:when test="($OPACItemLocation='location' or $OPACItemLocation='ccode') and (count(key('item-by-status', 'available'))!=0 or count(key('item-by-status', 'reference'))!=0)">
+        <xsl:if test="(count(key('item-by-status', 'available'))>0 or count(key('item-by-status', 'reference'))>0)">
             <span class="results_summary" id="location">
                 <span class="label">Location(s): </span>
-                <xsl:choose>
-                <xsl:when 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', concat(items:status, ' ', items:homebranch))[1])]">
-                            <xsl:choose>
-                                <xsl:when test="$OPACItemLocation='location'"><b><xsl:value-of select="concat(items:location,' ')"/></b></xsl:when>
-                                <xsl:when test="$OPACItemLocation='ccode'"><b><xsl:value-of select="concat(items:ccode,' ')"/></b></xsl:when>
-                            </xsl:choose>
-                            <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> <xsl:value-of select="items:itemcallnumber"/></xsl:if>
-                            <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="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', concat(items:status, ' ', items:homebranch))[1])]">
-                            <xsl:choose>
-                                <xsl:when test="$OPACItemLocation='location'"><b><xsl:value-of select="concat(items:location,' ')"/></b></xsl:when>
-                                <xsl:when test="$OPACItemLocation='ccode'"><b><xsl:value-of select="concat(items:ccode,' ')"/></b></xsl:when>
-                            </xsl:choose>
-                            <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> <xsl:value-of select="items:itemcallnumber"/></xsl:if>
-                            <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:for-each select="items:items">
+                    <xsl:for-each select="items:item[items:status='available' or items:status='reference']">
+                        <xsl:if test="$singleBranchMode=0"><xsl:value-of select="items:homebranch"/><xsl:text>:</xsl:text></xsl:if>
+                        <xsl:choose>
+                                <xsl:when test="$OPACItemLocation='location'"><b><xsl:value-of select="items:location"/></b><xsl:text> </xsl:text></xsl:when>
+                                <xsl:when test="$OPACItemLocation='ccode'"><b><xsl:value-of select="items:ccode"/></b><xsl:text> </xsl:text></xsl:when>
+                        </xsl:choose>
+                        <xsl:value-of select="items:itemcallnumber"/>
+                        <xsl:if test="position()!=last()"><xsl:text>, </xsl:text></xsl:if>
+                    </xsl:for-each>
+                </xsl:for-each>
             </span>
-        </xsl:when>
-       </xsl:choose>
+        </xsl:if>
+
     </xsl:template>
 
     <xsl:template name="nameABCDQ">
-- 
1.7.7.6