Bug 2093: (follow-up) Add OPAC dashboard for logged-in users
[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-home" match="items:item" use="concat(items:status, ' ', items:homebranch)"/>
15 <xsl:key name="item-by-status-and-branch-holding" match="items:item" use="concat(items:status, ' ', items:holdingbranch)"/>
16
17 <xsl:template match="/">
18   <xsl:apply-templates/>
19 </xsl:template>
20
21 <xsl:template match="marc:record">
22   <xsl:variable name="leader" select="marc:leader"/>
23   <xsl:variable name="leader6" select="substring($leader,7,1)"/>
24   <xsl:variable name="leader7" select="substring($leader,8,1)"/>
25   <xsl:variable name="biblionumber"
26    select="marc:datafield[@tag=090]/marc:subfield[@code='a']"/>
27   <xsl:variable name="isbn"
28    select="marc:datafield[@tag=010]/marc:subfield[@code='a']"/>
29   <xsl:variable name="OPACResultsLibrary" select="marc:sysprefs/marc:syspref[@name='OPACResultsLibrary']"/>
30   <xsl:variable name="BiblioDefaultView" select="marc:sysprefs/marc:syspref[@name='BiblioDefaultView']"/>
31   <xsl:variable name="hidelostitems" select="marc:sysprefs/marc:syspref[@name='hidelostitems']"/>
32   <xsl:variable name="singleBranchMode" select="marc:sysprefs/marc:syspref[@name='singleBranchMode']"/>
33   <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
34
35   <xsl:if test="marc:datafield[@tag=200]">
36     <xsl:for-each select="marc:datafield[@tag=200]">
37         <xsl:call-template name="addClassRtl" />
38         <xsl:for-each select="marc:subfield">
39           <xsl:choose>
40             <xsl:when test="@code='a'">
41               <xsl:variable name="title" select="."/>
42               <xsl:variable name="ntitle"
43                 select="translate($title, '&#x0088;&#x0089;&#x0098;&#x009C;','')"/>
44               <a>
45                 <xsl:attribute name="href">
46                   <xsl:call-template name="buildBiblioDefaultViewURL">
47                       <xsl:with-param name="BiblioDefaultView">
48                           <xsl:value-of select="$BiblioDefaultView"/>
49                       </xsl:with-param>
50                   </xsl:call-template>
51                   <xsl:value-of select="$biblionumber"/>
52                 </xsl:attribute>
53                 <xsl:attribute name="class">title</xsl:attribute>
54                 <xsl:value-of select="$ntitle" />
55               </a>
56             </xsl:when>
57             <xsl:when test="@code='b'">
58               <xsl:text> [</xsl:text>
59               <xsl:value-of select="."/>
60               <xsl:text>]</xsl:text>
61             </xsl:when>
62             <xsl:when test="@code='d'">
63               <xsl:text> = </xsl:text>
64               <xsl:value-of select="."/>
65             </xsl:when>
66             <xsl:when test="@code='e'">
67               <xsl:text> : </xsl:text>
68               <xsl:value-of select="."/>
69             </xsl:when>
70             <xsl:when test="@code='f'">
71               <xsl:text> / </xsl:text>
72               <xsl:value-of select="."/>
73             </xsl:when>
74             <xsl:when test="@code='g'">
75               <xsl:text> ; </xsl:text>
76               <xsl:value-of select="."/>
77             </xsl:when>
78             <xsl:otherwise>
79               <xsl:text>, </xsl:text>
80               <xsl:value-of select="."/>
81             </xsl:otherwise>
82           </xsl:choose>
83         </xsl:for-each>
84     </xsl:for-each>
85   </xsl:if>
86
87   <xsl:call-template name="tag_title">
88     <xsl:with-param name="tag">454</xsl:with-param>
89     <xsl:with-param name="label">Translation of</xsl:with-param>
90     <xsl:with-param name="spanclass">original_title</xsl:with-param>
91   </xsl:call-template>
92
93   <xsl:call-template name="tag_title">
94     <xsl:with-param name="tag">461</xsl:with-param>
95     <xsl:with-param name="label">Set Level</xsl:with-param>
96     <xsl:with-param name="spanclass">set_level</xsl:with-param>
97   </xsl:call-template>
98
99   <xsl:call-template name="tag_title">
100     <xsl:with-param name="tag">464</xsl:with-param>
101     <xsl:with-param name="label">Piece-Analytic Level</xsl:with-param>
102     <xsl:with-param name="spanclass">piece_analytic_level</xsl:with-param>
103   </xsl:call-template>
104
105   <xsl:call-template name="tag_210" />
106
107   <xsl:call-template name="tag_215" />
108
109   <span class="results_summary availability">
110     <span class="label">Availability: </span>
111     <xsl:choose>
112       <xsl:when test="marc:datafield[@tag=856]">
113         <xsl:for-each select="marc:datafield[@tag=856]">
114           <xsl:choose>
115             <xsl:when test="@ind2=0">
116               <a>
117                 <xsl:attribute name="href">
118                   <xsl:value-of select="marc:subfield[@code='u']"/>
119                 </xsl:attribute>
120                 <xsl:if test="$OPACURLOpenInNewWindow='1'">
121                     <xsl:attribute name="target">_blank</xsl:attribute>
122                 </xsl:if>
123                 <xsl:choose>
124                   <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
125                     <xsl:call-template name="subfieldSelect">
126                       <xsl:with-param name="codes">y3z</xsl:with-param>
127                     </xsl:call-template>
128                   </xsl:when>
129                   <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
130                     Click here to access online
131                   </xsl:when>
132                 </xsl:choose>
133               </a>
134               <xsl:choose>
135                 <xsl:when test="position()=last()"></xsl:when>
136                 <xsl:otherwise> | </xsl:otherwise>
137               </xsl:choose>
138             </xsl:when>
139           </xsl:choose>
140         </xsl:for-each>
141       </xsl:when>
142       <xsl:when test="count(key('item-by-status', 'available'))=0 and count(key('item-by-status', 'reference'))=0">
143         No items available
144       </xsl:when>
145       <xsl:when test="count(key('item-by-status', 'available'))>0">
146         <span class="available">
147           <b><xsl:text>Items available for loan: </xsl:text></b>
148           <xsl:variable name="available_items" select="key('item-by-status', 'available')"/>
149       <xsl:choose>
150       <xsl:when test="$singleBranchMode=1">
151       <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]">
152         <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
153           <xsl:text> (</xsl:text>
154           <xsl:value-of select="count(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch)))"/>
155           <xsl:text>)</xsl:text>
156           <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose>
157       </xsl:for-each>
158       </xsl:when>
159       <xsl:otherwise>
160           <xsl:choose>
161               <xsl:when test="$OPACResultsLibrary='homebranch'">
162                   <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]">
163                     <xsl:value-of select="items:homebranch"/>
164                         <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]
165                         </xsl:if>
166                     <xsl:text> (</xsl:text>
167                     <xsl:value-of select="count(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch)))"/>
168                     <xsl:text>)</xsl:text>
169                     <xsl:choose>
170                       <xsl:when test="position()=last()">
171                         <xsl:text>. </xsl:text>
172                       </xsl:when>
173                       <xsl:otherwise>
174                         <xsl:text>, </xsl:text>
175                       </xsl:otherwise>
176                     </xsl:choose>
177                   </xsl:for-each>
178               </xsl:when>
179               <xsl:otherwise>
180                   <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-holding', concat(items:status, ' ', items:holdingbranch))[1])]">
181                     <xsl:value-of select="items:holdingbranch"/>
182                         <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]
183                         </xsl:if>
184                     <xsl:text> (</xsl:text>
185                     <xsl:value-of select="count(key('item-by-status-and-branch-holding', concat(items:status, ' ', items:holdingbranch)))"/>
186                     <xsl:text>)</xsl:text>
187                     <xsl:choose>
188                       <xsl:when test="position()=last()">
189                         <xsl:text>. </xsl:text>
190                       </xsl:when>
191                       <xsl:otherwise>
192                         <xsl:text>, </xsl:text>
193                       </xsl:otherwise>
194                     </xsl:choose>
195                   </xsl:for-each>
196               </xsl:otherwise>
197             </xsl:choose>
198       </xsl:otherwise>
199       </xsl:choose>
200         </span>
201       </xsl:when>
202     </xsl:choose>
203     <xsl:choose>
204       <xsl:when test="count(key('item-by-status', 'reference'))>0">
205         <span class="available">
206           <b><xsl:text>Items available for reference: </xsl:text></b>
207           <xsl:variable name="reference_items"
208                         select="key('item-by-status', 'reference')"/>
209           <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]">
210             <xsl:if test="$singleBranchMode=0">
211                 <xsl:value-of select="items:homebranch"/>
212             </xsl:if>
213             <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
214             <xsl:text> (</xsl:text>
215             <xsl:value-of select="count(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch)))"/>
216             <xsl:text>)</xsl:text>
217             <xsl:choose>
218               <xsl:when test="position()=last()">
219                 <xsl:text>. </xsl:text>
220               </xsl:when>
221               <xsl:otherwise>
222                 <xsl:text>, </xsl:text>
223               </xsl:otherwise>
224             </xsl:choose>
225           </xsl:for-each>
226         </span>
227       </xsl:when>
228     </xsl:choose>
229     <xsl:if test="count(key('item-by-status', 'Checked out'))>0">
230       <span class="unavailable">
231         <xsl:text>Checked out (</xsl:text>
232         <xsl:value-of select="count(key('item-by-status', 'Checked out'))"/>
233         <xsl:text>). </xsl:text>
234       </span>
235     </xsl:if>
236     <xsl:if test="count(key('item-by-status', 'Withdrawn'))>0">
237       <span class="unavailable">
238         <xsl:text>Withdrawn (</xsl:text>
239         <xsl:value-of select="count(key('item-by-status', 'Withdrawn'))"/>
240         <xsl:text>). </xsl:text>
241       </span>
242     </xsl:if>
243     <xsl:if test="$hidelostitems='0' and count(key('item-by-status', 'Lost'))>0">
244       <span class="unavailable">
245         <xsl:text>Lost (</xsl:text>
246         <xsl:value-of select="count(key('item-by-status', 'Lost'))"/>
247         <xsl:text>). </xsl:text>
248       </span>
249     </xsl:if>
250     <xsl:if test="count(key('item-by-status', 'Damaged'))>0">
251       <span class="unavailable">
252         <xsl:text>Damaged (</xsl:text>
253         <xsl:value-of select="count(key('item-by-status', 'Damaged'))"/>
254         <xsl:text>). </xsl:text>
255       </span>
256     </xsl:if>
257     <xsl:if test="count(key('item-by-status', 'On order'))>0">
258       <span class="unavailable">
259         <xsl:text>On order (</xsl:text>
260         <xsl:value-of select="count(key('item-by-status', 'On order'))"/>
261         <xsl:text>). </xsl:text>
262       </span>
263     </xsl:if>
264     <xsl:if test="count(key('item-by-status', 'In transit'))>0">
265       <span class="unavailable">
266         <xsl:text>In transit (</xsl:text>
267         <xsl:value-of select="count(key('item-by-status', 'In transit'))"/>
268         <xsl:text>). </xsl:text>
269       </span>
270     </xsl:if>
271     <xsl:if test="count(key('item-by-status', 'Waiting'))>0">
272       <span class="unavailable">
273         <xsl:text>On hold (</xsl:text>
274         <xsl:value-of select="count(key('item-by-status', 'Waiting'))"/>
275         <xsl:text>). </xsl:text>
276       </span>
277     </xsl:if>
278   </span>
279
280 </xsl:template>
281
282 </xsl:stylesheet>