Merge branch 'bootstrap-opac'
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / xslt / UNIMARCslim2OPACResults.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE stylesheet [<!ENTITY nbsp "&#160;" >]>
4
5 <xsl:stylesheet version="1.0"
6   xmlns:marc="http://www.loc.gov/MARC21/slim"
7   xmlns:items="http://www.koha-community.org/items"
8   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9   exclude-result-prefixes="marc items">
10
11 <xsl:import href="UNIMARCslimUtils.xsl"/>
12 <xsl:output method = "html" indent="yes" omit-xml-declaration = "yes" encoding="UTF-8"/>
13 <xsl:key name="item-by-status" match="items:item" use="items:status"/>
14 <xsl:key name="item-by-status-and-branch" match="items:item" use="concat(items:status, ' ', items:homebranch)"/>
15
16 <xsl:template match="/">
17   <xsl:apply-templates/>
18 </xsl:template>
19
20 <xsl:template match="marc:record">
21   <xsl:variable name="leader" select="marc:leader"/>
22   <xsl:variable name="leader6" select="substring($leader,7,1)"/>
23   <xsl:variable name="leader7" select="substring($leader,8,1)"/>
24   <xsl:variable name="biblionumber"
25    select="marc:datafield[@tag=090]/marc:subfield[@code='a']"/>
26   <xsl:variable name="isbn"
27    select="marc:datafield[@tag=010]/marc:subfield[@code='a']"/>
28
29   <xsl:variable name="hidelostitems" select="marc:sysprefs/marc:syspref[@name='hidelostitems']"/>
30   <xsl:variable name="singleBranchMode" select="marc:sysprefs/marc:syspref[@name='singleBranchMode']"/>
31
32   <xsl:if test="marc:datafield[@tag=200]">
33     <xsl:for-each select="marc:datafield[@tag=200]">
34         <xsl:call-template name="addClassRtl" />
35         <xsl:for-each select="marc:subfield">
36           <xsl:choose>
37             <xsl:when test="@code='a'">
38               <xsl:variable name="title" select="."/>
39               <xsl:variable name="ntitle"
40                 select="translate($title, '&#x0088;&#x0089;&#x0098;&#x009C;','')"/>
41               <a>
42                 <xsl:attribute name="href">
43                   <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
44                   <xsl:value-of select="$biblionumber"/>
45                 </xsl:attribute>
46                 <xsl:value-of select="$ntitle" />
47               </a>
48             </xsl:when>
49             <xsl:when test="@code='b'">
50               <xsl:text> [</xsl:text>
51               <xsl:value-of select="."/>
52               <xsl:text>]</xsl:text>
53             </xsl:when>
54             <xsl:when test="@code='d'">
55               <xsl:text> = </xsl:text>
56               <xsl:value-of select="."/>
57             </xsl:when>
58             <xsl:when test="@code='e'">
59               <xsl:text> : </xsl:text>
60               <xsl:value-of select="."/>
61             </xsl:when>
62             <xsl:when test="@code='f'">
63               <xsl:text> / </xsl:text>
64               <xsl:value-of select="."/>
65             </xsl:when>
66             <xsl:when test="@code='g'">
67               <xsl:text> ; </xsl:text>
68               <xsl:value-of select="."/>
69             </xsl:when>
70             <xsl:otherwise>
71               <xsl:text>, </xsl:text>
72               <xsl:value-of select="."/>
73             </xsl:otherwise>
74           </xsl:choose>
75         </xsl:for-each>
76     </xsl:for-each>
77   </xsl:if>
78
79   <xsl:call-template name="tag_title">
80     <xsl:with-param name="tag">454</xsl:with-param>
81     <xsl:with-param name="label">Translation of</xsl:with-param>
82   </xsl:call-template>
83
84   <xsl:call-template name="tag_title">
85     <xsl:with-param name="tag">461</xsl:with-param>
86     <xsl:with-param name="label">Set Level</xsl:with-param>
87   </xsl:call-template>
88
89   <xsl:call-template name="tag_title">
90     <xsl:with-param name="tag">464</xsl:with-param>
91     <xsl:with-param name="label">Piece-Analytic Level</xsl:with-param>
92   </xsl:call-template>
93
94   <xsl:call-template name="tag_210" />
95
96   <xsl:call-template name="tag_215" />
97
98   <span class="results_summary">
99     <span class="label">Availability: </span>
100     <xsl:choose>
101       <xsl:when test="marc:datafield[@tag=856]">
102         <xsl:for-each select="marc:datafield[@tag=856]">
103           <xsl:choose>
104             <xsl:when test="@ind2=0">
105               <a>
106                 <xsl:attribute name="href">
107                   <xsl:value-of select="marc:subfield[@code='u']"/>
108                 </xsl:attribute>
109                 <xsl:choose>
110                   <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
111                     <xsl:call-template name="subfieldSelect">
112                       <xsl:with-param name="codes">y3z</xsl:with-param>
113                     </xsl:call-template>
114                   </xsl:when>
115                   <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
116                     Click here to access online
117                   </xsl:when>
118                 </xsl:choose>
119               </a>
120               <xsl:choose>
121                 <xsl:when test="position()=last()"></xsl:when>
122                 <xsl:otherwise> | </xsl:otherwise>
123               </xsl:choose>
124             </xsl:when>
125           </xsl:choose>
126         </xsl:for-each>
127       </xsl:when>
128       <xsl:when test="count(key('item-by-status', 'available'))=0 and count(key('item-by-status', 'reference'))=0">
129         No copies available
130       </xsl:when>
131       <xsl:when test="count(key('item-by-status', 'available'))>0">
132         <span class="available">
133           <b><xsl:text>Copies available for loan: </xsl:text></b>
134           <xsl:variable name="available_items" select="key('item-by-status', 'available')"/>
135       <xsl:choose>
136       <xsl:when test="$singleBranchMode=1">
137       <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
138         <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
139           <xsl:text> (</xsl:text>
140           <xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
141           <xsl:text>)</xsl:text>
142           <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose>
143       </xsl:for-each>
144       </xsl:when>
145       <xsl:otherwise>
146           <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
147             <xsl:value-of select="items:homebranch"/>
148                             <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]
149                             </xsl:if>
150             <xsl:text> (</xsl:text>
151             <xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
152             <xsl:text>)</xsl:text>
153             <xsl:choose>
154               <xsl:when test="position()=last()">
155                 <xsl:text>. </xsl:text>
156               </xsl:when>
157               <xsl:otherwise>
158                 <xsl:text>, </xsl:text>
159               </xsl:otherwise>
160             </xsl:choose>
161           </xsl:for-each>
162       </xsl:otherwise>
163       </xsl:choose>
164         </span>
165       </xsl:when>
166     </xsl:choose>
167     <xsl:choose>
168       <xsl:when test="count(key('item-by-status', 'reference'))>0">
169         <span class="available">
170           <b><xsl:text>Copies available for reference: </xsl:text></b>
171           <xsl:variable name="reference_items"
172                         select="key('item-by-status', 'reference')"/>
173           <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
174             <xsl:value-of select="items:homebranch"/>
175             <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
176             <xsl:text> (</xsl:text>
177             <xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
178             <xsl:text>)</xsl:text>
179             <xsl:choose>
180               <xsl:when test="position()=last()">
181                 <xsl:text>. </xsl:text>
182               </xsl:when>
183               <xsl:otherwise>
184                 <xsl:text>, </xsl:text>
185               </xsl:otherwise>
186             </xsl:choose>
187           </xsl:for-each>
188         </span>
189       </xsl:when>
190     </xsl:choose>
191     <xsl:if test="count(key('item-by-status', 'Checked out'))>0">
192       <span class="unavailable">
193         <xsl:text>Checked out (</xsl:text>
194         <xsl:value-of select="count(key('item-by-status', 'Checked out'))"/>
195         <xsl:text>). </xsl:text>
196       </span>
197     </xsl:if>
198     <xsl:if test="count(key('item-by-status', 'Withdrawn'))>0">
199       <span class="unavailable">
200         <xsl:text>Withdrawn (</xsl:text>
201         <xsl:value-of select="count(key('item-by-status', 'Withdrawn'))"/>
202         <xsl:text>). </xsl:text>
203       </span>
204     </xsl:if>
205     <xsl:if test="$hidelostitems='0' and count(key('item-by-status', 'Lost'))>0">
206       <span class="unavailable">
207         <xsl:text>Lost (</xsl:text>
208         <xsl:value-of select="count(key('item-by-status', 'Lost'))"/>
209         <xsl:text>). </xsl:text>
210       </span>
211     </xsl:if>
212     <xsl:if test="count(key('item-by-status', 'Damaged'))>0">
213       <span class="unavailable">
214         <xsl:text>Damaged (</xsl:text>
215         <xsl:value-of select="count(key('item-by-status', 'Damaged'))"/>
216         <xsl:text>). </xsl:text>
217       </span>
218     </xsl:if>
219     <xsl:if test="count(key('item-by-status', 'On order'))>0">
220       <span class="unavailable">
221         <xsl:text>On order (</xsl:text>
222         <xsl:value-of select="count(key('item-by-status', 'On order'))"/>
223         <xsl:text>). </xsl:text>
224       </span>
225     </xsl:if>
226     <xsl:if test="count(key('item-by-status', 'In transit'))>0">
227       <span class="unavailable">
228         <xsl:text>In transit (</xsl:text>
229         <xsl:value-of select="count(key('item-by-status', 'In transit'))"/>
230         <xsl:text>). </xsl:text>
231       </span>
232     </xsl:if>
233     <xsl:if test="count(key('item-by-status', 'Waiting'))>0">
234       <span class="unavailable">
235         <xsl:text>On hold (</xsl:text>
236         <xsl:value-of select="count(key('item-by-status', 'Waiting'))"/>
237         <xsl:text>). </xsl:text>
238       </span>
239     </xsl:if>
240   </span>
241
242 </xsl:template>
243
244 </xsl:stylesheet>