5330deb5cb49df953c1079d72fe414d614903cb9
[koha-ffzg.git] / koha-tmpl / intranet-tmpl / prog / en / modules / catalogue / detail.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE KohaPlugins %]
6 [% USE AuthorisedValues %]
7 [% USE Branches %]
8 [% USE Biblio %]
9 [% USE Price %]
10 [% USE TablesSettings %]
11 [% PROCESS 'i18n.inc' %]
12
13 [% IF Koha.Preference('AmazonAssocTag') %]
14     [% AmazonAssocTag = '?tag=' _ Koha.Preference('AmazonAssocTag') %]
15 [% ELSE %]
16     [% AmazonAssocTag = '' %]
17 [% END %]
18
19 [% ShowCourseReserves = 0 | html %]
20 [% IF UseCourseReserves %]
21     [% FOREACH item IN itemloop %]
22        [% IF item.course_reserves %]
23            [% FOREACH r IN item.course_reserves %]
24                [% IF r.course.enabled == 'yes' %]
25                    [% ShowCourseReserves = 1 | html %]
26                [% END %]
27            [% END %]
28         [% END %]
29     [% END %]
30 [% END %]
31
32 [% SET plugins_intranet_catalog_biblio_tabs = KohaPlugins.get_plugins_intranet_catalog_biblio_tab({ biblio => biblio, biblio_id => biblionumber }) %]
33
34 [% SET footerjs = 1 %]
35 [% INCLUDE 'doc-head-open.inc' %]
36 <title>
37   [% IF ( unknownbiblionumber ) %]
38     Unknown record
39   [% ELSE %]
40     Details for [% INCLUDE 'biblio-title-head.inc' %]
41   [% END %] &rsaquo; Catalog &rsaquo; Koha
42 </title>
43 [% INCLUDE 'doc-head-close.inc' %]
44 [% Asset.css("lib/Chocolat/css/chocolat.css") | $raw %]
45 </head>
46
47 <body id="catalog_detail" class="catalog">
48
49 [% WRAPPER 'header.inc' %]
50     [% INCLUDE 'cat-search.inc' %]
51 [% END %]
52
53 [% WRAPPER 'sub-header.inc' %]
54 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
55     <ol>
56         <li>
57             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
58         </li>
59         <li>
60             <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
61         </li>
62
63         [% IF ( unknownbiblionumber ) %]
64             <li>
65                 <a href="#" aria-current="page">
66                     Unknown record
67                 </a>
68             </li>
69         [% ELSE %]
70             <li>
71                 [% INCLUDE 'biblio-title.inc' link = 1 %]
72             </li>
73             <li>
74                 <a href="#" aria-current="page">
75                     Details
76                 </a>
77             </li>
78         [% END %]
79     </ol>
80 </nav>
81 [% END %]
82
83 <div class="main container-fluid">
84     <div class="row">
85         <div class="col-sm-10 col-sm-push-2">
86             <main>
87                 <div class="row">
88
89 [% IF ( unknownbiblionumber ) %]
90   <div class="dialog message">The record you requested does not exist ([% biblionumber | html %]).</div>
91 [% ELSE %]
92
93 [% IntranetCoce    = Koha.Preference('IntranetCoce') %]
94 [% CoceProviders   = Koha.Preference('CoceProviders') %]
95 [% CoceHost        = Koha.Preference('CoceHost') %]
96 [% SyndeticsCovers = Koha.Preference('SyndeticsEnabled') && Koha.Preference('SyndeticsCoverImages') %]
97
98 [% INCLUDE 'cat-toolbar.inc' %]
99     [% IF decoding_error %]
100         <div>
101            <span class="biberror">
102             There is an error with this bibliographic record, the view may be degraded.</span>
103             <span class="error"><br/> Error: [% decoding_error | html %]</span>
104         </div>
105     [% END %]
106     [% IF analytics_error %]
107         <div>
108            <span class="analytics_error">
109             There was an error searching for analytic records, please see the logs for details.</span>
110         </div>
111     [% END %]
112     [% IF ( ocoins ) %]
113         <!-- COinS / OpenURL -->
114         <span class="Z3988" title="[% ocoins | html %]"></span>
115     [% END %]
116
117     [% IF ( AmazonCoverImages  || LocalCoverImages || IntranetCoce || ( SyndeticsCovers ) || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
118         <div id="catalogue_detail_biblio" class="col-xs-9">
119     [% ELSE %]
120         <div id="catalogue_detail_biblio" class="col-xs-12">
121     [% END %]
122         <div class="page-section">
123
124         [% XSLTBloc | $raw %]
125
126         [% IF shelves.count %]
127             <span class="results_summary"><span class="label">Lists that include this title: </span>
128             [% FOREACH s IN shelves %]
129                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber | uri %]">[% s.shelfname | html %]</a>
130                 [% IF ( loop.last ) %][% ELSE %]|[% END %]
131             [% END %]
132             </span>
133         [% END %]
134         [% IF ( TagsEnabled &&  TagsShowOnDetail &&  TagLoop ) %]
135                 <span class="results_summary"><span class="label">Tags:</span>
136                     [% FOREACH TagLoo IN TagLoop %]
137                         [% IF ( CAN_user_tools_moderate_tags ) %]
138                         <a href="/cgi-bin/koha/tags/list.pl?tag=[% TagLoo.term |uri %]">[% TagLoo.term | html %]</a>
139                         [% ELSE %]
140                         [% TagLoo.term | html %]
141                         [% END %]
142                         <span class="weight">([% TagLoo.weight_total | html %])</span>[% IF ( loop.last ) %][% ELSE %], [% END %]
143                     [% END %]
144                     </span>
145         [% END %]
146         <span id="catalogue_detail_marc_preview" class="results_summary"><span class="label">MARC preview:</span> <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblionumber | uri %]&amp;viewas=html" title="MARC" class="previewMARC">Show</a></span>
147         [% IF !item_level_itypes ||  Koha.Preference("BiblioItemtypeInfo") %]
148            <span class="results_summary itemtype"><span class="label">Itemtype:</span>
149           [% IF ( !noItemTypeImages && imageurl ) %]
150               <img src="[% imageurl | html %]" alt="" />
151           [% END %]
152           [% IF ( description ) %]
153               <span class="itypetext">[% description | html %]</span>
154           [% ELSE %]
155               <span class="itypetext">[% itemtype | html %]</span>
156           [% END %]
157           </span>
158         [% END %]
159
160         [% IF ( holdcount ) %]
161             <span class="results_summary">
162                 <span class="label">Holds:</span>
163                 <span class="number_box">
164                     [% IF CAN_user_reserveforothers_place_holds %]
165                         <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber | uri %]">[% holdcount | html %]</a>
166                     [% ELSE %]
167                         <span>[% holdcount | html %]</span>
168                     [% END %]
169                 </span>
170             </span>
171         [% END %]
172
173         [% IF illrequests.count %]
174             <span class="results_summary">
175                 <span class="label">ILL requests:</span>
176                 [% IF CAN_user_ill %]
177                     [% FOREACH ill IN illrequests %]
178                         <a href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=[% ill.illrequest_id | uri %]">Request [% ill.illrequest_id | html %]</a>[% IF ! loop.last %], [% END %]
179                     [% END %]
180                 [% ELSE %]
181                     [% FOREACH ill IN illrequests %]
182                         <span>Request [% ill.illrequest_id | html %]</span>[% IF ! loop.last %], [% END %]
183                     [% END %]
184                 [% END %]
185             </span>
186         [% END %]
187
188         [% IF ( article_requests_count = Biblio.ArticleRequestsActiveCount( biblionumber ) ) %]
189             <span class="results_summary">
190                 <span class="label">Article requests:</span>
191                 <span class="number_box">
192                     <a href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% biblionumber | uri %]">[% article_requests_count | html %]</a>
193                 </span>
194             </span>
195         [% END %]
196
197         [% IF course_reserves %]
198             <span class="results_summary"><span class="label">Courses that have reserved this title: </span>
199             [% FOREACH c IN course_reserves %]
200                 <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% c.course_id | uri %]">[% c.course.course_name | html %]</a>
201                 [% IF ( loop.last ) %][% ELSE %]|[% END %]
202             [% END %]
203             </span>
204         [% END %]
205         </div> [%# .page-section %]
206
207         [% IF ( AmazonCoverImages  || LocalCoverImages || IntranetCoce || ( SyndeticsCovers ) || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
208         </div>
209             <div class="col-xs-3 bookcoverimg">
210                 <div id="biblio-cover-slider" class="cover-slider">
211                     [% IF ( LocalCoverImages ) %]
212                         [% IF localimages.count %]
213                             [% FOREACH image IN localimages %]
214                                 <div class="cover-image local-coverimg">
215                                     <a href="/cgi-bin/koha/catalogue/image.pl?imagenumber=[% image.imagenumber | uri %]" title="Local cover image">
216                                         <img src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;imagenumber=[% image.imagenumber | uri %]" alt="Local cover image" data-link="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber | uri %]&amp;imagenumber=[% image.imagenumber | uri %]" />
217                                     </a>
218                                     <div class="hint">Local cover image</div>
219                                 </div>
220                             [% END %]
221                         [% END %]
222                     [% END %]
223
224                     [% IF ( AmazonCoverImages && normalized_isbn) %]
225                         <div class="cover-image" id="amazon-bookcoverimg">
226                             <a href="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | uri %].01.LZZZZZZZ.jpg" title="Amazon cover image">
227                                 <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | uri %].01.MZZZZZZZ.jpg" alt="Amazon cover image" data-link="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link"/>
228                             </a>
229                             <div class="hint">Image from Amazon.com</div>
230                         </div>
231                     [% END %]
232
233                     [% IF ( IntranetCoce && CoceProviders && normalized_isbn ) %]
234                         [% coce_id = normalized_ean || normalized_isbn %]
235                         <div class="cover-image coce-coverimg">
236                             [% IF ( coce_id ) %]
237                                 <a title="Image from Coce" class="[% coce_id | html %]" id="coce-thumbnail-preview"></a>
238                             [% ELSE %]
239                                 <span class="no-image">No cover image available</span>
240                             [% END %]
241                             <div class="hint">Image from Coce</div>
242                         </div>
243                     [% END %]
244
245                     [% IF ( SyndeticsCovers ) %]
246                         [% IF ( content_identifier_exists ) %]
247                         <div class="cover-image" id="syndetics-bookcoverimg">
248                             <a href="https://secure.syndetics.com/index.aspx?isbn=[% normalized_isbn | url %]/LC.GIF&amp;client=[% Koha.Preference('SyndeticsClientCode') | url %]&amp;type=xw10&amp;upc=[% normalized_upc | url %]&amp;oclc=[% normalized_oclc | url %]" title="Syndetics cover image">
249                                 <img src="https://secure.syndetics.com/index.aspx?isbn=[% normalized_isbn | url %]/[% Koha.Preference('SyndeticsCoverImageSize') | url %].GIF&amp;client=[% Koha.Preference('SyndeticsClientCode') | url %]&amp;type=xw10&amp;upc=[% normalized_upc | url %]&amp;oclc=[% normalized_oclc | url %]" alt="" class="thumbnail" />
250                             </a>
251                             <div class="hint">Image from Syndetics</div>
252                         </div>
253                             [% ELSE %]
254                                 <span class="no-image">No cover image available</span>
255                             [% END %]
256                     [% END %]
257
258                     [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %]
259                         [% SET custom_cover_image_url = biblio.custom_cover_image_url %]
260                         [% IF custom_cover_image_url %]
261                             <div class="cover-image" id="custom-coverimg">
262                                 <a class="custom_cover_image" href="[% custom_cover_image_url | url %]" title="Custom cover image">
263                                     <img id="custom-img" alt="Custom cover image" src="[% custom_cover_image_url | url %]" />
264                                 </a>
265                                 <div class="hint">Custom cover image</div>
266                             </div>
267                         [% END %]
268                     [% END %]
269                 </div> <!-- /.cover-slider -->
270             </div> <!-- /.bookcoverimg.col-xs-3 -->
271         [% ELSE %]
272         </div> <!-- /.col-xs-* -->
273         [% END # /IF ( AmazonCoverImages, etc ) %]
274 </div>
275
276 <div id="bibliodetails" class="toptabs">
277
278 <ul class="nav nav-tabs" role="tablist">
279     [% IF (SeparateHoldings) %]
280         <li role="presentation">
281             <a href="#holdings" aria-controls="holdings" role="tab" data-toggle="tab">[% Branches.GetLoggedInBranchname | html %] holdings ([% itemloop.size() || 0 | html %])</a>
282         </li>
283         <li role="presentation">
284             <a href="#otherholdings"  aria-controls="otherholdings" role="tab" data-toggle="tab">Other holdings ([% otheritemloop.size() || 0 | html %])</a>
285         </li>
286     [% ELSE %]
287         <li role="presentation">
288             <a href="#holdings" aria-controls="holdings" role="tab" data-toggle="tab">Holdings ([% itemloop.size() || 0 | html %])</a>
289         </li>
290     [% END %]
291     [% IF Koha.Preference('EnableItemGroups') %]
292         <li role="presentation">
293             <a href="#item_groups" aria-controls="item_groups" role="tab" data-toggle="tab">Item groups</a>
294         </li>
295     [% END %]
296 [% IF ( MARCNOTES || notes ) %]<li role="presentation"><a href="#description" aria-controls="description" role="tab" data-toggle="tab">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
297 [% IF ComponentParts && ComponentParts.size %]<li id="components_tab" role="presentation"><a href="#components"  aria-controls="components" role="tab" data-toggle="tab">Components ([% ComponentParts.size | html %])</a></li>[% END %]
298 [% IF ( subscriptionsnumber ) %]<li role="presentation"><a href="#subscriptions"  aria-controls="subscriptions" role="tab" data-toggle="tab">Subscriptions</a></li>[% END %]
299 [% IF Koha.Preference('AcquisitionDetails') %]<li role="presentation"><a href="#acq_details"  aria-controls="acq_details" role="tab" data-toggle="tab">Acquisition details</a></li>[% END %]
300 [% IF suggestions.count %]<li role="presentation"><a href="#suggestion_details"  aria-controls="suggestion_details" role="tab" data-toggle="tab">Suggestion details</a></li>[% END %]
301 [% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]<li role="presentation"><a href="#editions"  aria-controls="editions" role="tab" data-toggle="tab">Editions</a></li>[% END %][% END %]
302 [% IF ( LocalCoverImages ) %]
303     <li role="presentation">
304         <a href="#images"  aria-controls="images" role="tab" data-toggle="tab">Images ([% localimages.count || 0 | html %])</a>
305     </li>
306 [% END %]
307 [% IF HTML5MediaEnabled && HTML5MediaSets.size %]
308     <li id="media_tab" role="presentation"><a href="#html5media"  aria-controls="html5media" role="tab" data-toggle="tab">Play media</a></li>
309 [% END %]
310 [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
311     <li class="NovelistSelect" style="display:none;" role="presentation"><a href="#NovelistSelect"  aria-controls="NovelistSelect" role="tab" data-toggle="tab">NoveList Select</a></li>
312 [% END %]
313 [% FOREACH plugins_intranet_catalog_biblio_tab IN plugins_intranet_catalog_biblio_tabs %]
314     <li role="presentation"><a href="#[% plugins_intranet_catalog_biblio_tab.id | uri %]"  aria-controls="[% plugins_intranet_catalog_biblio_tab.id | uri %]" role="tab" data-toggle="tab">[% plugins_intranet_catalog_biblio_tab.title | html %]</a></li>
315 [% END %]
316 </ul>
317
318 <div class="tab-content">
319 [% items_table_block_iter = 0 %]
320 [% BLOCK items_table %]
321     [% items_table_block_iter = items_table_block_iter + 1 %]
322     <div class="[% tab | html %]_table_table_controls">
323         [% IF (StaffDetailItemSelection) %]
324             | <a href="#" class="SelectAll" data-tab="[% tab | html %]"><i class="fa fa-check"></i> Select all</a> |
325             <a href="#" class="ClearAll" data-tab="[% tab | html %]"><i class="fa fa-remove"></i> Clear all</a>
326             <span class="itemselection_actions">
327               | Actions:
328               [% IF CAN_user_tools_items_batchdel %]
329                 <a class="itemselection_action_delete"><i class="fa fa-trash"></i> Delete selected items</a>
330               [% END %]
331               [% IF CAN_user_tools_items_batchmod %]
332                 <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Modify selected items</a>
333               [% END %]
334               [% IF CAN_user_editcatalogue_manage_item_groups && biblio.item_groups.count %]
335                 <a class="itemselection_action_item_group_set" href="#"><i class="fa fa-book"></i> Add/move to item group</a>
336                 <a class="itemselection_action_item_group_unset" href="#"><i class="fa fa-unlink"></i> Remove from item group</a>
337               [% END %]
338             </span>
339         [% END %]
340     </div>
341     <table class="items_table" id="[% tab | html %]_table">
342         <thead>
343             <tr>
344                 [% IF (StaffDetailItemSelection) %]<th id="[% tab | html %]_checkbox" data-colname="[% tab | html %]_checkbox" class="NoSort"></th>[% END %]
345                 [% IF Koha.Preference('LocalCoverImages') && ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
346                     <th id="[% tab | html %]_cover_image" data-colname="[% tab | html %]_cover_image">Cover image</th>
347                 [% END %]
348                 [% IF ( item_level_itypes ) %]<th id="[% tab | html %]_itype" data-colname="[% tab | html %]_itype">Item type</th>[% END %]
349                 <th id="[% tab | html %]_holdingbranch" data-colname="[% tab | html %]_holdingbranch">Current library</th>
350                 <th id="[% tab | html %]_homebranch" data-colname="[% tab | html %]_homebranch">Home library</th>
351                 [% IF ( itemdata_ccode ) %]<th id="[% tab | html %]_ccode" data-colname="[% tab | html %]_ccode">Collection</th>[% END %]
352                 [% IF Koha.Preference('EnableItemGroups') %]
353                     <th id="[% tab | html %]_item_group" data-colname="[% tab | html %]_item_group">Item group</th>
354                 [% END %]
355                 <th id="[% tab | html %]_itemcallnumber" data-colname="[% tab | html %]_itemcallnumber">Call number</th>
356                 [% IF volinfo %]
357                     <th id="[% tab | html %]_enumchron" data-colname="[% tab | html %]_enumchron">Serial enumeration / chronology</th>
358                 [% END %]
359                 <th id="[% tab | html %]_status" data-colname="[% tab | html %]_status">Status</th>
360                 <th id="[% tab | html %]_lastseen" data-colname="[% tab | html %]_lastseen">Last seen</th>
361                 <th id="[% tab | html %]_issues" data-colname="[% tab | html %]_issues">Checkouts</th>
362                 <th id="[% tab | html %]_renewals" data-colname="[% tab | html %]_renewals">Renewals</th>
363                 <th id="[% tab | html %]_dateaccessioned" data-colname="[% tab | html %]_dateaccessioned">Date accessioned</th>
364                 <th id="[% tab | html %]_datelastborrowed" data-colname="[% tab | html %]_datelastborrowed">Date last borrowed</th>
365                 <th id="[% tab | html %]_barcode" data-colname="[% tab | html %]_barcode">Barcode</th>
366                 [% IF ( itemdata_uri ) %]<th id="[% tab | html %]_uri" data-colname="[% tab | html %]_uri">URL</th>[% END %]
367                 [% IF ( itemdata_copynumber ) %]<th id="[% tab | html %]_copynumber" data-colname="[% tab | html %]_copynumber">Copy number</th>[% END %]
368                 [% IF ( itemdata_stocknumber ) %]<th id="[% tab | html %]_stocknumber" data-colname="[% tab | html %]_stocknumber">Inventory number</th>[% END %]
369                 [% IF materials %]<th id="[% tab | html %]_materials" data-colname="[% tab | html %]_materials">Materials specified</th>[% END %]
370                 [% IF ( itemdata_itemnotes ) %]<th id="[% tab | html %]_itemnotes" data-colname="[% tab | html %]_itemnotes">Public notes</th>[% END %]
371                 [% IF ( itemdata_nonpublicnotes ) %]<th id="[% tab | html %]_itemnotes_nonpublic" data-colname="[% tab | html %]_itemnotes_nonpublic">Non-public notes</th>[% END %]
372                 [% IF ( hostrecords ) %]<th id="[% tab | html %]_hostrecord" data-colname="[% tab | html %]_hostrecord">Host records</th>[% END %]
373                 [% IF ( analyze ) %]<th id="[% tab | html %]_usedin" data-colname="[% tab | html %]_usedin">Used in</th><th></th>[% END %]
374                 [% IF ( ShowCourseReserves ) %]<th id="[% tab | html %]_course_reserves" data-colname="[% tab | html %]_course_reserves">Course reserves</th>[% END %]
375                 [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th id="[% tab | html %]_spinelabel" data-colname="[% tab | html %]_spinelabel" class="NoSort">Spine label</th>[% END %]
376                 [% IF ( CAN_user_editcatalogue_edit_items ) %]<th id="[% tab | html %]_actions" data-colname="[% tab | html %]_actions"class="NoSort noExport">&nbsp;</th>[% END %]
377             </tr>
378         </thead>
379         <tbody>
380             [% FOREACH item IN items %]
381                 <tr id="item_[% item.itemnumber | html %]" data-itemnumber="[% item.itemnumber | html %]" data-duedate="[% item.datedue | html %]">
382                 [% IF (StaffDetailItemSelection) %]
383                     <td style="text-align:center;vertical-align:middle">
384                         [% IF item.can_be_edited %]
385                             <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
386                         [% END %]
387                     </td>
388                 [% END %]
389                     [% IF Koha.Preference('LocalCoverImages') && ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
390                         <td class="cover">
391                             <div class="bookcoverimg">
392                                 <div class="cover-slider">
393                                     [% FOREACH image IN item.cover_images %]
394                                         <div class="cover-image local-coverimg">
395                                             <a href="/cgi-bin/koha/catalogue/image.pl?itemnumber=[% image.itemnumber | uri %]&amp;imagenumber=[% image.imagenumber | uri %]" title="Local cover image">
396                                                 <img src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;imagenumber=[% image.imagenumber | uri %]" alt="Local cover image" data-link="/cgi-bin/koha/catalogue/imageviewer.pl?itemnumber=[% item.itemnumber | uri %]&amp;imagenumber=[% image.imagenumber | uri %]" />
397                                             </a>
398                                         </div>
399                                     [% END %]
400                                 </div>
401                             </div>
402                         </td>
403                     [% END %]
404
405                     [% IF ( item_level_itypes ) %]
406                         <td class="itype">
407                             [% SET itemtype = item.itemtype %]
408                             [% IF !noItemTypeImages && itemtype.image_location('intranet') %]
409                                 <img src="[% itemtype.image_location('intranet') | html %]" alt="[% itemtype.translated_description | html %]" title="[% itemtype.translated_description | html %]" />
410                             [% END %]
411                             <span class="itypedesc itypetext">[% itemtype.translated_description | html %]</span>
412                         </td>
413                     [% END %]
414                     <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.holdingbranch ) | html %] [% END %]</td>
415                     <td class="homebranch">
416                         <span class="homebranchdesc">[% Branches.GetName(item.homebranch) | html %]</span>
417                         <span class="shelvingloc">
418 <!--
419 If permanent location is defined, show description or code and display current location in parentheses. If not, display current location.
420 Note that permanent location is a code, and location may be an authval.
421 -->
422                             [% IF item.permanent_location %]
423                                 [% SET permloc_authval = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => item.permanent_location ) %]
424                                 [% permloc_authval | html %]
425                                 [% IF item.location AND item.location != permloc_authval AND item.location != item.permanent_location %]
426                                     ([% item.location | html %])
427                                 [% END %]
428                             [% ELSE %]
429                                 [% item.location | html %]
430                             [% END %]
431                         </span>
432                     </td>
433                     [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
434                     [% IF Koha.Preference('EnableItemGroups') %]<td class="item_group">[% item.object.item_group.description | html %]</td>[% END %]
435                     <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
436                     [% IF ( volinfo ) %]
437                         [% SET serial = item.itemserial.serial %]
438                         [% IF itemdata_publisheddate #If there is at least one published date, use it for sorting %]
439                             <td class="enumchron" data-order="[% serial.publisheddate | html %]">
440                         [% ELSE %]
441                             <td class="enumchron">
442                         [% END %]
443                             [% IF ( itemdata_enumchron ) %]
444                                 [% IF item.enumchron && serial.serialseq %]
445                                     <span class="enum">[% item.enumchron | html %]</span>
446                                     [% IF ( item.serialseq && item.enumchron != serial.serialseq ) %]
447                                         <span class="sep"> -- </span>
448                                         <span class="serialseq">[% serial.serialseq | html %]</span>
449                                     [% END %]
450                                 [% ELSIF item.enumchron %]
451                                     <span class="enum">[% item.enumchron | html %]</span>
452                                 [% ELSIF item.serialseq %]
453                                     <span class="serialseq">[% serial.serialseq | html %]</span>
454                                 [% END %]
455                                 [% IF serial.publisheddate %]
456                                     <span class="pubdate">([% serial.publisheddate | $KohaDates %])</span>
457                                 [% END %]
458                             [% END %]
459                             </span>
460                         </td>
461                     [% END %]
462                     <td class="status">
463
464                         [% IF item.checkout %]
465                           [% IF item.checkout.onsite_checkout %]
466                             <span>Currently in local use
467                           [% ELSE %]
468                             <span class="datedue">Checked out
469                           [% END %]
470                                 [% UNLESS ( item.not_same_branch) %]
471                                   [% IF item.checkout.onsite_checkout %]
472                                     by
473                                   [% ELSE %]
474                                     to
475                                   [% END %]
476                                   [% INCLUDE 'patron-title.inc' patron=item.checkout.patron hide_patron_infos_if_needed=1 %]
477                                 [% END %]
478                                 : due [% item.checkout.date_due | $KohaDates as_due_date => 1 %]
479                             </span>
480                         [% ELSIF ( item.transfer ) %]
481                             [% IF (item.transfer.datesent) %]
482                                 <span class="intransit">In transit from [% Branches.GetName( item.transfer.frombranch ) | html %] to [% Branches.GetName( item.transfer.tobranch ) | html %] since [% item.transfer.datesent | $KohaDates %]</span>
483                             [% ELSE %]
484                                 <span class="transitrequested">Transit pending from [% Branches.GetName( item.transfer.frombranch ) | html %] to [% Branches.GetName( item.transfer.tobranch ) | html %] since [% item.transfer.daterequested | $KohaDates %]</span>
485
486                             [% END %]
487                         [% END %]
488
489                         [% IF ( item.itemlost ) %]
490                             [% IF itemlostloop %]
491                                 [% FOREACH itemlostloo IN itemlostloop %]
492                                     [% IF itemlostloo.authorised_value == item.itemlost %]
493                                         <span class="lost">[% itemlostloo.lib | html %]</span>
494                                     [% END %]
495                                 [% END %]
496                             [% ELSE %]
497                                 <span class="lost">Unavailable (lost or missing)</span>
498                             [% END %]
499                         [% END %]
500
501                         [% IF ( item.withdrawn ) %]
502                             [% IF itemwithdrawnloop %]
503                                 [% FOREACH itemwithdrawnloo IN itemwithdrawnloop %]
504                                     [% IF itemwithdrawnloo.authorised_value == item.withdrawn %]
505                                         <span class="wdn">[% itemwithdrawnloo.lib | html %]</span>
506                                     [% END %]
507                                 [% END %]
508                             [% ELSE %]
509                                 <span class="wdn">Withdrawn</span>
510                             [% END %]
511                         [% END %]
512
513                         [% IF ( item.damaged ) %]
514                             [% IF itemdamagedloop %]
515                                 [% FOREACH itemdamagedloo IN itemdamagedloop %]
516                                     [% IF itemdamagedloo.authorised_value == item.damaged %]
517                                         <span class="dmg">[% itemdamagedloo.lib | html %]</span>
518                                     [% END %]
519                                 [% END %]
520                             [% ELSE %]
521                                 <span class="dmg">Damaged</span>
522                             [% END %]
523                         [% END %]
524
525                         [% IF ( item.notforloan || item.itemtype.notforloan ) %]
526                             <span class="notforloan">Not for loan
527                             [% SET not_for_loan_description = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.notforloan ) %]
528                             [% IF not_for_loan_description %]
529                                 <span class="reason">([% not_for_loan_description | html %])</span>
530                             [% END %]
531                             </span>
532                         [% END %]
533
534                         [% SET hold = item.first_hold %]
535                         [% IF hold %]
536                             [% IF hold.waitingdate %]
537                                 <span class="waitingat">Waiting at [% Branches.GetName( hold.branchcode ) | html %][% IF ( hold.desk_id ) %], [% hold.desk.desk_name | html %][% END %] since [% hold.waitingdate | $KohaDates %].</span>
538                                 [% IF canreservefromotherbranches AND ( hold.waitingdate OR hold.priority == 1 ) %]
539                                     <span class="heldfor">Hold for:</span>
540                                     [% INCLUDE 'patron-title.inc' patron=hold.borrower hide_patron_infos_if_needed=1 %]
541                                 [% END %]
542                             [% ELSE %]
543                                 <span class="holdonitem">There is an item level hold on this item (priority = [% hold.priority | html %]).</span>
544                             [% END %]
545                         [% END %]
546
547                         [% SET recall = item.recall %]
548                         [% IF recall %]
549                             [% IF recall.waiting_date %]
550                                 <span>Waiting at [% Branches.GetName( recall.pickup_library_id ) | html %] since [% recall.waiting_date | $KohaDates %]</span>
551                             [% ELSE %]
552                                 [% patron_link = BLOCK %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% recall.patron_id | uri %]">[% recall.patron.firstname | html %] [% recall.patron.surname | html %] ([% recall.patron.cardnumber | html %])</a>[% END %]
553                                 <span>recalled by [% patron_link| $raw %] on [% recall.created_date | $KohaDates %]</span>
554                             [% END %]
555                         [% END %]
556
557                         [% UNLESS ( item.notforloan || item.itemtype.notforloan || item.onloan || item.itemlost || item.withdrawn || item.damaged || item.transfer || hold || ( Koha.Preference('UseRecalls') && recall ) ) %]
558                             <span>Available</span>
559                         [% END %]
560
561                         [% IF ( item.restricted ) %]
562                             <span class="restricted">([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.restricted', authorised_value => item.restricted ) | html %])</span>
563                         [% END %]
564
565                         [% IF ( item.bundle_host ) %]
566                             <span class="bundled">In bundle: [% INCLUDE 'biblio-title.inc' biblio = item.bundle_host.biblio link = 1 %]</span>
567                         [% END %]
568
569                     </td>
570                     <td class="datelastseen" data-order="[% item.datelastseen | html %]">[% item.datelastseen | $KohaDates %]</td>
571                     <td class="issues" data-order="[% item.issues || 0 | html %]">[% item.issues || 0 | html %]</td>
572                     <td class="renewals" data-order="[% item.renewals || 0 | html %]">[% item.renewals || 0 | html %]</td>
573                     <td class="dateaccessioned" data-order="[% item.dateaccessioned | html %]">[% item.dateaccessioned | $KohaDates %]</td>
574                     <td class="datelastborrowed" data-order="[% item.datelastborrowed | html %]">[% item.datelastborrowed | $KohaDates %]</td>
575                     <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% item.itemnumber | uri %]&amp;biblionumber=[% item.biblionumber | uri %]&amp;bi=[% item.biblioitemnumber | uri %]#item[% item.itemnumber | uri %]">[% item.barcode | html %]</a></td>
576                     [% IF ( itemdata_uri ) %]
577                         [% IF item.uri.split(' \| ').size > 1 %]
578                             <td class="uri">
579                                 [% FOREACH uri IN item.uri.split(' \| ') %]<a href="[% uri | url %]">[% uri | html %]</a><br>[% END %]
580                             </td>
581                         [% ELSE %]
582                             <td class="uri">
583                                 [% IF item.uri %]
584                                     <a href="[% item.uri | url %]">[% IF Koha.Preference('URLLinkText') %][% Koha.Preference('URLLinkText') | html %][% ELSE %]Link to resource[% END %]</a>
585                                 [% END %]
586                             </td>
587                         [% END %]
588                     [% END %]
589                     [% IF ( itemdata_copynumber ) %]
590                         <td class="copynumber">[% item.copynumber | html %]</td>
591                     [% END %]
592                     [% IF ( itemdata_stocknumber ) %]
593                         <td class="stocknumber">[% item.stocknumber | html %]</td>
594                     [% END %]
595                     [% IF materials %]
596                         <td class="materials"> [% item.materials | html %] </td>
597                     [% END %]
598                     [% IF ( itemdata_itemnotes ) %]
599                         <td><div class="itemnotes">[% item.itemnotes | $raw %]</div></td>
600                     [% END %]
601                     [% IF itemdata_nonpublicnotes %]
602                         <td class="nonpublicnote">[% item.itemnotes_nonpublic | html %]</td>
603                     [% END %]
604                     [% IF ( hostrecords ) %]
605                         <td>[% IF ( item.hostbiblionumber) %]<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item.hostbiblionumber | uri %]" >[% item.hosttitle | html %]</a>[% END %]</td>
606                     [% END %]
607                     [% IF ( analyze ) %]
608                         <td>
609                             [% IF ( item.countanalytics ) %]
610                                 <a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&amp;q=[% item.itemnumber | uri %]">[% item.countanalytics | html %] analytics</a>
611                             [% END %]
612                         </td>
613                     [% END %]
614                     [% IF ( analyze ) %]
615                         <td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% item.biblionumber | uri %]&amp;hostitemnumber=[% item.itemnumber | uri %]">Create analytics</a></td>
616                     [% END %]
617
618                 [% IF ShowCourseReserves %]
619                     <td>
620                         [% IF item.course_reserves %]
621                             [% FOREACH r IN item.course_reserves %]
622                                 [% IF r.course.enabled == 'yes' %]
623                                     <p>
624                                       <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% r.course.course_id | uri %]">
625                                          [% r.course.course_name | html %]
626                                          <!--[% IF r.course.course_number %] [% r.course.course_number | html %] [% END %]-->
627                                          [% IF r.course.section %] [% r.course.section | html %] [% END %]
628                                          [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) | html %] [% END %]
629                                       </a>
630                                    </p>
631                                [% END %]
632                            [% END %]
633                        [% END %]
634                     </td>
635                 [% END %]
636
637                 [% IF ( SpineLabelShowPrintOnBibDetails ) %]
638                     <td><a class="btn btn-default btn-xs print-label" href="/cgi-bin/koha/labels/spinelabel-print.pl?barcode=[% item.barcode | uri %]"><i class="fa fa-print"></i> Print label</a></td>
639                 [% END %]
640
641                 [% IF CAN_user_editcatalogue_edit_items %]
642                     <td class="actions">
643                         [% IF item.can_be_edited %]
644                             [% IF Koha.Preference('LocalCoverImages') OR Koha.Preference('OPACLocalCoverImages') %]
645                                 <div class="btn-group">
646                                     <a  class="btn btn-default btn-xs" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber | html %]&itemnumber=[% item.itemnumber | html %]#edititem"><i class="fa fa-pencil"></i> Edit</a><a class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
647                                     <ul class="dropdown-menu pull-right">
648                                         <li><a href="/cgi-bin/koha/tools/upload-cover-image.pl?itemnumber=[% item.itemnumber | uri %]&amp;filetype=image"><i class="fa fa-upload"></i> Upload image</a></li>
649                                     </ul>
650                                 </div>
651                             [% ELSE %]
652                                 <a class="btn btn-default btn-xs" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber | html %]&itemnumber=[% item.itemnumber | html %]#edititem"><i class="fa fa-pencil"></i> Edit</a>
653                             [% END %]
654                         [% END %]
655                         [% IF bundlesEnabled %]
656                             <button class="btn btn-default btn-xs details-control"><i class="fa fa-folder"></i> Manage bundle ([% item.bundled | html %]|[% item.bundled_lost | html %])</button>
657                         [% END %]
658                     </td>
659                 [% END %]
660                 </tr>
661             [% END %]
662         </tbody>
663     </table>
664
665 [% END %][%# end of block items_table %]
666
667 [% IF Koha.Preference('EnableItemGroups') %]
668     <div role="tabpanel" class="tab-pane" id="item_groups">
669         [% IF CAN_user_editcatalogue_manage_item_groups %]
670             <div class="item_groups_table_table_controls">
671                 <a href="#" class="item-group-create btn btn-default btn-xs"><i class="fa fa-plus"></i> New item group</a>
672             </div>
673         [% END %]
674         <table class="items-group-table" id="items-group-table">
675             <thead>
676                 <tr>
677                     <td>Display order</td>
678                     <td>Description</td>
679                     <td>&nbsp;</td>
680                 </tr>
681             </thead>
682         </table>
683     </div>
684 [% END %]
685
686
687 <div role="tabpanel" class="tab-pane" id="holdings">
688
689 [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
690     <span class="results_summary NovelistSelect" style="display:none;">
691         <span class="label">Novelist Select: </span>
692         <div data-novelist-novelistselect=[% normalized_isbn | html %]></div>
693     </span>
694 [% END %]
695
696 [% IF ( count ) %]
697     [% IF ( showncount ) %]
698         [% PROCESS items_table tab="holdings" items=itemloop %]
699         [% END %]
700                 [% IF ( hiddencount ) %]
701                    <p><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]&amp;showallitems=1">Show all items ([% hiddencount | html %] hidden)</a>
702                 [% END %]               
703                 [% IF ( debug_display ) %]
704                 <br /><br />
705                 <table>
706                         <tr><td>itemdata_enumchron</td><td>[% itemdata_enumchron | html %]</td></tr>
707                         <tr><td>itemdata_copynumber</td><td>[% itemdata_copynumber | html %]</td></tr>
708                         <tr><td>serial</td><td>[% serial | html %]</td></tr>
709                 </table>
710                 [% END %]
711 [% ELSE %]
712     [% IF ( ALTERNATEHOLDINGS ) %]
713     [% FOREACH ALTERNATEHOLDING IN ALTERNATEHOLDINGS %]
714         <div id="alternateholdings"><span class="holdings_label">Holdings:</span> [% ALTERNATEHOLDING.holding | html %]</div>
715     [% END %]
716     [% ELSE %]
717     <div id="noitems">No physical items for this record</div>
718     [% END %]
719 [% END %]
720
721 [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'below' ) %]
722     <span class="results_summary NovelistSelect" style="display:none;">
723         <span class="label">Novelist Select: </span>
724         <div data-novelist-novelistselect=[% normalized_isbn | html %]></div>
725     </span>
726 [% END %]
727     </div>
728
729 [% IF (SeparateHoldings) %]
730     <div role="tabpanel" class="tab-pane" id="otherholdings">
731         [% IF (otheritemloop.size) %]
732             [% PROCESS items_table tab="otherholdings" items=otheritemloop %]
733         [% ELSE %]
734             <span class="nootheritems">No other items.</span>
735         [% END %]
736     </div>
737 [% END %]
738
739 [% IF ( MARCNOTES ) %]
740
741 <div role="tabpanel" class="tab-pane" id="description">
742 <div class="content_set">
743
744     [% FOREACH MARCNOTE IN MARCNOTES %]
745         <p>
746         [% IF MARCNOTE.marcnote.match('^https?://\S+$') %]
747             <a href="[% MARCNOTE.marcnote | url %]">[% MARCNOTE.marcnote | html %]</a>
748         [% ELSE %]
749             [% MARCNOTE.marcnote | html | html_line_break %]
750         [% END %]
751         </p>
752 [% END %]
753 </div>
754 </div>
755
756 [% END %]
757
758 [% IF ComponentParts && ComponentParts.size %]
759 <div role="tabpanel" class="tab-pane" id="components">
760     <div class="content_set">
761         <table>
762             [% FOR PART IN ComponentParts %]
763             <tr>
764                 <td>
765                     [% PART | $raw %]
766                 </td>
767             </tr>
768             [% END %]
769         </table>
770         [% IF ComponentParts.size == Koha.Preference('MaxComponentRecords')%]
771         <p>Only [% ComponentParts.size | html %] results are shown: <a href="/cgi-bin/koha/catalogue/search.pl?q=[% ComponentPartsQuery | url %]"/>show all component parts</a></p>
772         [% END %]
773     </div> <!-- /.content_set -->
774 </div> <!-- /#components -->
775
776 [% END %]
777
778 [% IF ( subscriptionsnumber ) %]
779 <div role="tabpanel" class="tab-pane" id="subscriptions">
780 <div id="catalogue_detail_subscriptions">
781     <h2>This is a serial subscription</h2>
782     <p> (There are [% subscriptionsnumber | html %] subscriptions associated with this title).</p> 
783     [% FOREACH subscription IN subscriptions %]
784             [% IF subscription.branchcode %]
785                 <h3>At library: [% Branches.GetName(subscription.branchcode) || subscription.branchcode | html %]</h3>
786             [% END %]
787             [% IF ( subscription.closed ) %]<p>This subscription is closed.</p>[% END %]
788             [% IF ( subscription.location ) %]<p class="subscription_location">Location: [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => subscription.location ) | html %]</p>[% END %]
789             [% IF ( subscription.callnumber ) %]<p>Callnumber: [% subscription.callnumber | html %] </p>[% END %]
790             [% IF ( subscription.subscriptionnotes ) %]<p>[% subscription.subscriptionnotes | html | html_line_break %] </p>[% END %]
791             [% IF ( subscription.missinglist ) %]<p>Missing issues: [% subscription.missinglist | html %] </p>[% END %]
792             [% IF ( subscription.librariannote ) %]<p>([% subscription.librariannote | html %])</p>[% END %]
793             [% IF ( subscription.latestserials ) %]
794             <p> The [% subscription.staffdisplaycount | html %] latest issues related to this subscription:</p>
795             <table>
796                 <tr>
797                     <th>Issue #</th>
798                     <th>Date arrived</th>
799                     <th>Date published</th>
800                     <th>Status</th>
801                     <th>Note</th>
802                 </tr>
803             [% FOREACH latestserial IN subscription.latestserials %]
804                 <tr>
805                     <td>[% latestserial.serialseq | html %]</td>
806                     <td data-order="[% latestserial.planneddate | html %]">[% latestserial.planneddate | $KohaDates %]</td>
807                     <td data-order="[% latestserial.publisheddate | html %]">[% latestserial.publisheddate | $KohaDates %]</td>
808                     <td>
809                       [% IF ( latestserial.status1 ) %]<span>Expected</span>[% END %]
810                       [% IF ( latestserial.status2 ) %]<span>Arrived</span>[% END %]
811                       [% IF ( latestserial.status3 ) %]<span>Late</span>[% END %]
812                       [% IF ( latestserial.status4 ) %]<span>Missing</span>[% END %]
813                       [% IF ( latestserial.status41 ) %]<span>Missing (never received)</span>[% END %]
814                       [% IF ( latestserial.status42 ) %]<span>Missing (sold out)</span>[% END %]
815                       [% IF ( latestserial.status43 ) %]<span>Missing (damaged)</span>[% END %]
816                       [% IF ( latestserial.status44 ) %]<span>Missing (lost)</span>[% END %]
817                       [% IF ( latestserial.status5 ) %]<span>Not issued</span>[% END %]
818                       [% IF ( latestserial.status6 ) %]<span>Delete</span>[% END %]
819                       [% IF ( latestserial.status7 ) %]<span>Claimed</span>[% END %]
820                       [% IF ( latestserial.status8 ) %]<span>Stopped</span>[% END %]
821                     </td>
822                     <td>[% latestserial.notes | html %]</td>
823                 </tr>
824             [% END %]
825             </table>
826             [% END %]
827             <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid | uri %]">Subscription details</a>
828     [% END %]
829 </div>
830 </div>
831 [% END %]
832
833 [% IF Koha.Preference('AcquisitionDetails') %]
834 <div role="tabpanel" class="tab-pane" id="acq_details">
835   [% IF orders.count %]
836     <table id="orders">
837       <thead>
838         <tr>
839           <th>Vendor</th>
840           <th>Invoice</th>
841           <th>Basket group</th>
842           <th>Basket</th>
843           <th>Order number</th>
844           <th>Creation date</th>
845           <th>Receive date</th>
846           <th>Status</th>
847           <th>Quantity</th>
848           <th title="Estimated cost tax incl. while pending, actual cost tax incl. once received">Price</th>
849           <th>Internal note</th>
850           <th>Subscription</th>
851           <th>Subscription call number</th>
852         </tr>
853       </thead>
854       <tbody>
855       [% FOR order IN orders %]
856         [% SET basket = order.basket %]
857         [% SET vendor = basket.bookseller %]
858           <tr>
859             <td>
860                 <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% vendor.id | uri %]" title="Vendor detail page">[% vendor.name | html %]</a>
861             </td>
862             <td>
863             [% IF order.invoiceid %]
864                 [% IF CAN_user_acquisition %]
865                     <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% order.invoiceid | uri %]"
866                        title="Invoice detail page">
867                        [% order.invoice.invoicenumber | html %]</a>
868                 [% ELSE %]
869                     [% order.invoice.invoicenumber | html %]
870                 [% END %]
871             [% END %]
872             </td>
873             <td>
874             [% IF basket.basketgroupid %]
875                 [% SET basket_group = basket.basket_group %]
876                 [% IF CAN_user_acquisition_group_manage %]
877                     <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% vendor.id | uri %]&basketgroupid=[% basket_group.id | uri %]">[% basket_group.name | html%] ([% basket_group.id | html %])</a>
878                 [% ELSE %]
879                     [% basket_group.name | html %] ([% basket_group.id | html %])
880                 [% END %]
881             [% END %]
882             </td>
883             <td>[% IF CAN_user_acquisition_order_manage %]
884                 <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | uri %]">[% basket.basketname | html %] ([% basket.basketno | html %])</a>
885             [% ELSE %]
886                 [% basket.basketname | html %] ([% basket.basketno | html %])
887             [% END %]</td>
888             <td>[% order.ordernumber | html %]</td>
889             <td data-order="[% basket.creationdate | uri %]">[% basket.creationdate | $KohaDates%]</td>
890             <td data-order="[% order.datereceived | uri %]">[% order.datereceived | $KohaDates%]</td>
891             <td>
892               [% SWITCH order.orderstatus %]
893                 [% CASE 'new' %]<span>New</span>
894                 [% CASE 'ordered' %]<span>Ordered</span>
895                 [% CASE 'partial' %]<span>Partial</span>
896                 [% CASE 'complete' %]<span>Complete</span>
897                 [% CASE 'cancelled' %]<span>Cancelled</span>
898               [% END %]
899             </td>
900             <td>[% order.quantity | html %]</td>
901             <td>[% IF ( order.unitprice_tax_included > 0 ) %][% order.unitprice_tax_included | $Price %][% ELSE %][% order.ecost_tax_included | $Price %][% END %]
902             <td>[% order.order_internalnote | html %]</td>
903             <td>
904                 [% IF order.subscriptionid %]
905                     <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% order.subscriptionid | uri %]">[% order.subscriptionid | html %]</a>
906                 [% END %]
907             </td>
908             <td>
909                 [% IF order.subscriptionid %]
910                     [% order.subscription.callnumber | html %]
911                 [% END %]
912             </td>
913           </tr>
914       [% END %]
915       </tbody>
916     </table>
917   [% ELSE %]
918     <span class="noorder">There is no order for this bibliographic record.</span>
919   [% END %]
920 </div>
921 [% END %]
922
923 [% IF suggestions.count %]
924     <div role="tabpanel" class="tab-pane" id="suggestion_details">
925         [% IF nb_archived_suggestions > 0 %]
926             <p>[% tnpx('pluralization', 'There is one archived suggestion.', 'There are {count} archived suggestions.', nb_archived_suggestions, { count = nb_archived_suggestions }) | $raw  %]
927         [% END %]
928         <table id="suggestions" class="sorted">
929             <thead>
930                 <tr>
931                     <th class="NoSort">&nbsp;</th>
932                     <th class="anti-the">Suggestion</th>
933                     <th>Suggested by - on</th>
934                     <th>Managed by - on</th>
935                     <th>Last modification by - on</th>
936                     <th>Library</th>
937                     <th>Fund</th>
938                     <th>Status</th>
939                 </tr>
940             </thead>
941             <tbody>
942             [% FOREACH suggestion IN suggestions %]
943                 <tr>
944                     <td>[% suggestion.suggestionid | html %]</td>
945                     <td>
946                         <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show" title="suggestion" >
947                             [% suggestion.title | html %][% IF ( suggestion.author ) %], by [% suggestion.author | html %][% END %]</a>
948                         <br />
949                         [% IF ( suggestion.copyrightdate ) %]&copy; [% suggestion.copyrightdate | html %] [% END %]
950                         [% IF ( suggestion.volumedesc ) %]; Volume:<em>[% suggestion.volumedesc | html %]</em> [% END %]
951                         [% IF ( suggestion.isbn ) %]; ISBN:<em>[% suggestion.isbn | html %]</em> [% END %][% IF ( suggestion.publishercode ) %]; Published by [% suggestion.publishercode | html %] [% END %][% IF ( suggestion.publicationyear ) %] in <em>[% suggestion.publicationyear | html %]</em> [% END %][% IF ( suggestion.place ) %] in <em>[% suggestion.place | html %]</em> [% END %][% IF ( suggestion.collectiontitle ) %]; [% suggestion.collectiontitle | html %] [% END %][% IF ( suggestion.itemtype ) %]; [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestion.itemtype, 0 ) | html %] [% END %]<br />[% IF ( suggestion.note ) %]<div class="suggestion_note"><i class="fa fa-comment"></i> [% suggestion.note | html %]</div>[% END %]
952                     </td>
953                     <td>
954                         <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestion.suggestedby | uri %]">[% INCLUDE 'patron-title.inc' patron => suggestion.suggester %]</a>
955                         [% IF suggestion.suggesteddate %] - [% suggestion.suggesteddate | $KohaDates %][% END %]
956                     </td>
957                     <td>
958                         <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestion.managedby | uri %]">[% INCLUDE 'patron-title.inc' patron => suggestion.manager %]</a>
959                         [% IF suggestion.manageddate %] - [% suggestion.manageddate | $KohaDates %][% END %]
960                     </td>
961                     <td>
962                         <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestion.lastmodificationby | uri %]">[% INCLUDE 'patron-title.inc' patron => suggestion.last_modifier %]</a>
963                         [% IF suggestion.lastmodificationdate %] - [% suggestion.lastmodificationdate | $KohaDates %][% END %]
964                     </td>
965                     <td>
966                         [% Branches.GetName( suggestion.branchcode ) | html %]
967                     </td>
968                     <td>
969                         [% suggestion.fund.budget_name | html %]
970                     </td>
971                     <td>
972                         [% IF    suggestion.STATUS == 'ASKED'     %]<span>Pending</span>
973                         [% ELSIF suggestion.STATUS == 'ACCEPTED'  %]<span>Accepted</span>
974                         [% ELSIF suggestion.STATUS == 'ORDERED'   %]<span>Ordered</span>
975                         [% ELSIF suggestion.STATUS == 'REJECTED'  %]<span>Rejected</span>
976                         [% ELSIF suggestion.STATUS == 'CHECKED'   %]<span>Checked</span>
977                         [% ELSIF suggestion.STATUS == 'AVAILABLE' %]<span>Available</span>
978                         [% ELSIF AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.STATUS ) %]
979                             [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.STATUS ) | html %]
980                         [% ELSE %]<span>Status unknown</span>
981                         [% END %]
982                         [% IF suggestion.reason %]
983                             <br />([% suggestion.reason | html %])
984                         [% END %]
985                     </td>
986                 </tr>
987                 [% END %]
988             </tbody>
989         </table>
990     </div>
991 [% END %]
992
993 [% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]
994 <div role="tabpanel" class="tab-pane" id="editions"><h4>Editions</h4>
995 <table>
996 [% FOREACH XISBN IN XISBNS %]<tr>[% IF ( AmazonCoverImages ) %]<td><a href="http://www.amazon.com/gp/reader/[% XISBN.normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link"><img src="https://images-na.ssl-images-amazon.com/images/P/[% XISBN.normalized_isbn | html %].01._AA75_PU_PU-5_.jpg" /></a></td>[% END %]
997 [% IF ( !item_level_itypes || Koha.Preference('BiblioItemtypeInfo') ) %]<td>[% IF ( noItemTypeImages ) %]<span class="itypetext">[% XISBN.description | html %]</span>[% ELSE %]<img src="[% XISBN.imageurl | html %]" alt="[% XISBN.description | html %]" title="[% XISBN.description | html %]">[% END %]</td>[% END %]
998 <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% XISBN.biblionumber | uri %]">[% XISBN.title | html %]</a> <span>by</span> [% XISBN.author | html %] &copy;[% XISBN.copyrightdate | html %]
999   [% IF ( XISBN.publishercode ) %]
1000 [% XISBN.publishercode | html %] [% IF ( XISBN.place ) %]([% XISBN.place | html %])[% END %] [% IF ( XISBN.publicationyear ) %], [% XISBN.publicationyear | html %][% END %] [% IF ( XISBN.editionstatement ) %][% XISBN.editionstatement | html %][% END %] [% IF ( XISBN.editionresponsibility ) %][% XISBN.editionresponsibility | html %][% END %]
1001     [% END %]
1002                 [% IF ( XISBN.pages ) %] [% END %][% XISBN.pages | html %] [% IF ( XISBN.illus ) %][% XISBN.illus | html %][% END %]
1003                 [% IF ( XISBN.size ) %], [% END %][% XISBN.size | html %]
1004 </td>
1005
1006 [% END %]
1007 </table></div>[% END %]
1008 [% END %]
1009
1010 [% IF ( LocalCoverImages ) %]
1011     <div role="tabpanel" class="tab-pane" id="images">
1012         [% IF localimages.count %]
1013             <p>Click on an image to view it in the image viewer</p>
1014             <ul class="thumbnails">
1015                 [% FOREACH image IN localimages %]
1016                     [% IF image %]
1017                         <li id="imagenumber-[% image.imagenumber | html %]" class="thumbnail">
1018                             <a href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber | uri %]&amp;imagenumber=[% image.imagenumber | uri %]">
1019                                 <img src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;imagenumber=[% image.imagenumber | uri %]" />
1020                             </a>
1021                             [% IF CAN_user_tools_upload_local_cover_images %]
1022                                 <a href="#" class="remove"><i class="fa fa-trash"></i> Delete image</a>
1023                             [% END %]
1024                         </li>
1025                     [% END %]
1026                 [% END %]
1027             </ul>
1028         [% ELSE # - No image passed JavaScript takes care %]
1029             <span class="noimagesuploaded">No images have been uploaded for this bibliographic record yet.</span>
1030         [% END %]
1031         [% IF ( CAN_user_tools_upload_local_cover_images ) %]
1032             <p>Upload an image file: <a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=[% biblionumber | uri %]&amp;filetype=image"><i class="fa fa-upload" aria-hidden="true"></i> Upload</a>
1033             </p>
1034         [% END %]
1035     </div>
1036 [% END %]
1037
1038 [% IF ( HTML5MediaEnabled ) %]
1039 <div role="tabpanel" class="tab-pane" id="html5media">
1040           [% FOREACH HTML5MediaSet IN HTML5MediaSets %]
1041             <p>
1042                 [% IF HTML5MediaSet.is_youtube %]
1043                     <iframe id="player" width="640" height="360" src="[% HTML5MediaSet.srcblock | url %]"></iframe>
1044                 [% ELSE %]
1045                   <[% HTML5MediaParent | html %] controls preload=none>
1046                     <[% HTML5MediaSet.child | html %] src="[% HTML5MediaSet.srcblock | url %]"[% HTML5MediaSet.typeblock | html %] />
1047                     [[% HTML5MediaParent | html %] tag not supported by your browser.]
1048                   </[% HTML5MediaParent | html %]>
1049                 [% END %]
1050             </p>
1051           [% END %]
1052 </div>
1053 [% END %]
1054
1055
1056 [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
1057     <div role="tabpanel" class="tab-pane" id="NovelistSelect" class="novelistSelect">
1058         <div data-novelist-novelistselect=[% normalized_isbn | html %]></div>
1059     </div>
1060 [% END %]
1061
1062 [% FOREACH plugins_intranet_catalog_biblio_tab IN plugins_intranet_catalog_biblio_tabs %]
1063     <div role="tabpanel" class="tab-pane" id="[% plugins_intranet_catalog_biblio_tab.id | html %]">
1064         [% plugins_intranet_catalog_biblio_tab.content | $raw %]
1065     </div>
1066 [% END %]
1067
1068 </div><!-- /tab-content -->
1069 </div><!-- /bibliodetails -->
1070
1071 <div id="export" style="margin-top: 1em;">
1072 <form method="get" action="/cgi-bin/koha/catalogue/export.pl">
1073 <table>  <tr>
1074       <th>Save record</th>   </tr>
1075     <tr><td> Select download format:    <select name="format">
1076         <option value="mods">MODS (XML)</option>
1077         <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
1078         <option value="marcxml">MARCXML</option>
1079         <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1080         <option value="utf8">MARC (Unicode/UTF-8)</option>    </select>
1081         <input type="submit" name="save" class="btn btn-primary" value="Download record" /></td>
1082   </tr>
1083   <tr><td>
1084     <input type="hidden" name="op" value="export" /><input type="hidden" name="bib" value="[% biblionumber | html %]" />
1085   </td></tr>
1086 </table>
1087 </form>
1088 </div>
1089
1090 <div id="marcPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
1091     <div class="modal-dialog modal-lg">
1092     <div class="modal-content">
1093     <div class="modal-header">
1094         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1095         <h3 id="marcPreviewLabel">MARC preview</h3>
1096     </div>
1097     <div class="modal-body">
1098         <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
1099     </div>
1100     <div class="modal-footer">
1101         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
1102     </div>
1103     </div>
1104     </div>
1105 </div>
1106
1107             </main>
1108         </div> <!-- /.col-sm-10.col-sm-push-2 -->
1109
1110         <div class="col-sm-2 col-sm-pull-10">
1111             <aside>
1112                 [% INCLUDE 'biblio-view-menu.inc' %]
1113             </aside>
1114         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1115      </div> <!-- /.row -->
1116
1117 [% END %]
1118
1119 <div class="modal fade" id="modal-item-group-create" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-create-label">
1120     <div class="modal-dialog">
1121         <div class="modal-content">
1122             <div class="modal-header">
1123                 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1124                 <h3 id="modal-item-group-create-label"><i class="fa fa-plus"></i> Create a new item group</h3>
1125             </div>
1126             <form id="modal-item-group-create-form" class="validated">
1127                 <div class="modal-body">
1128                     <fieldset>
1129                         <p>
1130                             <label for="item_group_description" class="required">Name: </label>
1131                             <input name="description" id="modal-item-group-create-form-description" type="text" size="30" required="required" class="required" />
1132                             <span class="required">Required</span>
1133                         </p>
1134                         <p>
1135                             <label for="item_group_display_order" class="required">Display order: </label>
1136                             <input name="display_order" id="modal-item-group-create-form-display_order" value="0" size="5" required="required" class="required" />
1137                             <span class="required">Required</span>
1138                             <br/>
1139                             <span class="hint">Numbers only, item groups will be displayed in counting order</span>
1140                         </p>
1141                     </fieldset>
1142                 </div>
1143                 <div class="modal-footer">
1144                     <button id="modal-item-group-create-submit" class="btn btn-default"><i class="fa fa-plus"></i> Submit</button>
1145                     <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1146                 </div>
1147             </form>
1148         </div>
1149     </div>
1150 </div>
1151
1152 <div class="modal fade" id="modal-item-group-edit" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-edit-label">
1153     <div class="modal-dialog">
1154         <div class="modal-content">
1155             <div class="modal-header">
1156                 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1157                 <h3 id="modal-item-group-edit-label"><i class='fa fa-edit'></i> Edit item group</h3>
1158             </div>
1159             <form id="modal-item-group-edit-form" class="validated">
1160                 <div class="modal-body">
1161                     <fieldset>
1162                         <p>
1163                             <label for="item_group_description" class="required">Name: </label>
1164                             <input name="description" id="modal-item-group-edit-form-description" type="text" size="30" required="required" class="required" />
1165                             <span class="required">Required</span>
1166                         </p>
1167                         <p>
1168                             <label for="item_group_display_order" class="required">Sort order: </label>
1169                             <input name="display_order" id="modal-item-group-edit-form-display_order" size="5" />
1170                             <span class="hint">Numbers only, item groups will be displayed in counting order</span>
1171                         </p>
1172                     </fieldset>
1173                 </div>
1174                 <div class="modal-footer">
1175                     <button id="modal-item-group-edit-submit" class="btn btn-default"><i class='fa fa-edit'></i> Submit</button>
1176                     <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1177                 </div>
1178             </form>
1179         </div>
1180     </div>
1181 </div>
1182
1183 <div class="modal fade" id="modal-item-group-delete" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-delete-label">
1184     <div class="modal-dialog">
1185         <div class="modal-content">
1186             <div class="modal-header">
1187                 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1188                 <h3 id="modal-item-group-delete-label"><i class='fa fa-trash'></i> Delete item group</h3>
1189             </div>
1190             <div class="modal-body">
1191                 Are you sure you want to delete this item group?
1192             </div>
1193             <div class="modal-footer">
1194                 <button id="modal-item-group-delete-submit" class="btn btn-danger"><i class='fa fa-trash'></i> Delete</button>
1195                 <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1196             </div>
1197         </div>
1198     </div>
1199 </div>
1200
1201 <div class="modal fade" id="modal-item-group-set" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-set-label">
1202     <div class="modal-dialog">
1203         <div class="modal-content">
1204             <div class="modal-header">
1205                 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1206                 <h3 id="modal-item-group-set-label"><i class='fa fa-book'></i> Set item group for items</h3>
1207             </div>
1208             <form id="modal-item-group-set-form" class="validated">
1209                 <div class="modal-body">
1210                     <fieldset>
1211                         <p>
1212                             <label for="item_group" class="required">Item group: </label>
1213                             <select name="item_group" id="item-group-add-form-select">
1214                                 [% FOREACH ig IN biblio.item_groups %]
1215                                     <option value="[% ig.id | html %]">[% ig.description | html %]</option>
1216                                 [% END %]
1217                             </select>
1218                             <span class="required">Required</span>
1219                         </p>
1220                     </fieldset>
1221                 </div>
1222                 <div class="modal-footer">
1223                     <button id="modal-item-group-set-submit" class="btn btn-default"><i class='fa fa-book'></i> Set item group</button>
1224                     <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1225                 </div>
1226             </form>
1227         </div>
1228     </div>
1229 </div>
1230
1231 <div class="modal fade" id="modal-item-group-unset" tabindex="-1" role="dialog" aria-labelledby="modal-item-group-unset-label">
1232     <div class="modal-dialog">
1233         <div class="modal-content">
1234             <div class="modal-header">
1235                 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1236                 <h3 id="modal-item-group-unset-label"><i class='fa fa-unlink'></i> Remove item from item group</h3>
1237             </div>
1238             <div class="modal-body">
1239                 Are you sure you want to remove these item(s) from their item group(s)?
1240             </div>
1241             <div class="modal-footer">
1242                 <button id="modal-item-group-unset-submit" class="btn btn-danger"><i class='fa fa-unlink'></i> Remove</button>
1243                 <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1244             </div>
1245         </div>
1246     </div>
1247 </div>
1248
1249     [% IF bundlesEnabled %]
1250     <div class="modal" id="addToBundleModal" tabindex="-1" role="dialog" aria-labelledby="addToBundleLabel">
1251         <form id="addToBundleForm" action="">
1252             <div class="modal-dialog" role="document">
1253                 <div class="modal-content">
1254                     <div class="modal-header">
1255                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1256                         <h3 id="addToBundleLabel">Add to bundle</h3>
1257                     </div>
1258                     <div class="modal-body">
1259                         <div id="addResult"></div>
1260                         <fieldset class="rows">
1261                             <ol>
1262                                 <li>
1263                                     <label class="required" for="external_id">Item barcode: </label>
1264                                     <input type="text" id="external_id" name="external_id" required="required">
1265                                     <span class="required">Required</span>
1266                                 </li>
1267                             </ol>
1268                         </fieldset>
1269                     </div>
1270                     <div class="modal-footer">
1271                         <button type="submit" class="btn btn-default">Submit</button>
1272                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
1273                     </div>
1274                 </div>
1275             </div>
1276         </form>
1277     </div>
1278
1279     <div class="modal" id="removeFromBundleModal" tabindex="-1" role="dialog" aria-labelledby="removeFromBundleLabel">
1280         <form id="removeFromBundleForm" action="">
1281             <div class="modal-dialog" role="document">
1282                 <div class="modal-content">
1283                     <div class="modal-header">
1284                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1285                         <h3 id="removeFromBundleLabel">Remove from bundle</h3>
1286                     </div>
1287                     <div class="modal-body">
1288                         <div id="removeResult"></div>
1289                         <fieldset class="rows">
1290                             <ol>
1291                                 <li>
1292                                     <label class="required" for="external_id">Item barcode: </label>
1293                                     <input type="text" id="rm_external_id" name="external_id" required="required">
1294                                     <span class="required">Required</span>
1295                                 </li>
1296                             </ol>
1297                         </fieldset>
1298                     </div>
1299                     <div class="modal-footer">
1300                         <button type="submit" class="btn btn-default">Submit</button>
1301                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
1302                     </div>
1303                 </div>
1304             </div>
1305         </form>
1306     </div>
1307     [% END %]
1308
1309 [% MACRO jsinclude BLOCK %]
1310     [% INCLUDE 'catalog-strings.inc' %]
1311     [% Asset.js("js/catalog.js") | $raw %]
1312     [% Asset.js("js/recalls.js") | $raw %]
1313     [% Asset.js("js/coce.js") | $raw %]
1314     [% Asset.js("lib/Chocolat/js/chocolat.js") | $raw %]
1315     <script>
1316         var interface = "[% interface | html %]";
1317         var theme = "[% theme | html %]";
1318         // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
1319         function verify_cover_images() {
1320             // Loop over each container in the template which contains covers
1321             $(".cover-slider").each(function(){
1322                 var lightbox_descriptions = [];
1323                 $(this).find(".cover-image").each( function( index ){
1324                     var div = $(this);
1325                     // Find the image in the container
1326                     var img = div.find("img")[0];
1327                     if( $(img).length > 0 ){
1328                         var description = "";
1329                         if( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ){
1330                             // No image loaded in the container. Remove the slide
1331                             div.remove();
1332                         } else {
1333                             // All slides start hidden. If this is the first one, show it.
1334                             if( index == 0 ){
1335                                 div.show();
1336                             }
1337                             // Check if Amazon image is present
1338                             if ( div.attr("id") == "amazon-bookcoverimg"  ) {
1339                                 w = img.width;
1340                                 h = img.height;
1341                                 if ((w == 1) || (h == 1)) {
1342                                     // Amazon returned single-pixel placeholder
1343                                     // Remove the container
1344                                     div.remove();
1345                                 } else {
1346                                     lightbox_descriptions.push(_("Amazon cover image (<a href='%s'>see the original image</a>)").format($(img).data('link')));
1347                                 }
1348                             } else if( div.attr("id") == "custom-coverimg" ){
1349                                 if ( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ) {
1350                                     // No image was loaded via the CustomCoverImages system preference
1351                                     // Remove the container
1352                                     div.remove();
1353                                 } else {
1354                                     lightbox_descriptions.push("Custom cover image");
1355                                 }
1356                             } else if ( div.attr("id") == "syndetics-bookcoverimg" ){
1357                                     lightbox_descriptions.push(_("Syndetics cover image (<a href='%s'>see the original image</a>)").format($(img).data('link')));
1358                             }
1359                             else if( div.hasClass("coce-coverimg" ) ){
1360                                 // Identify which service's image is being loaded by Coce
1361                                 var coce_description;
1362                                 if( $(img).attr("src").indexOf('amazon.com') >= 0 ){
1363                                     coce_description = ("Coce image from Amazon.com");
1364                                 } else if( $(img).attr("src").indexOf('google.com') >= 0 ){
1365                                     coce_description = _("Coce image from Google Books");
1366                                 } else if( $(img).attr("src").indexOf('openlibrary.org') >= 0 ){
1367                                     coce_description = _("Coce image from Open Library");
1368                                 }
1369                                 div.find(".hint").html(coce_description);
1370                                 lightbox_descriptions.push(coce_description);
1371                             } else if ( div.attr("class") == "cover-image local-coverimg" ) {
1372                                 lightbox_descriptions.push(_("Local cover image (<a href='%s'>edit</a>)").format($(img).data('link')));
1373                             } else {
1374                                 lightbox_descriptions.push(_("Cover image source unknown"));
1375                             }
1376                         }
1377                     }
1378                 });
1379
1380                 // Lightbox for cover images
1381                 Chocolat(this.querySelectorAll('.cover-image a'), {
1382                     description: function(){
1383                         return lightbox_descriptions[this.settings.currentImageIndex];
1384                     }
1385                 });
1386
1387             });
1388
1389             $(".cover-slider").each(function(){
1390                 var coverSlide = this;
1391                 var coverImages = $(this).find(".cover-image");
1392                 if( coverImages.length > 1 ){
1393                     coverImages.each(function( index ){
1394                         // If more that one image is present, add a navigation link
1395                         // for activating the slide
1396                         var covernav = $("<a href=\"#\" data-num=\"" + index + "\" class=\"cover-nav\"></a>");
1397                         if( index == 0 ){
1398                             // Set the first navigation link as active
1399                             $(covernav).addClass("nav-active");
1400                         }
1401                         $(covernav).html("<i class=\"fa fa-circle\"></i>");
1402                         $(coverSlide).append( covernav );
1403                     });
1404                 }
1405
1406                 if( $(coverSlide).attr('id') == 'biblio-cover-slider' // Hide if not visible, but only for the biblio images. Images for items are only local cover images
1407                     && $(coverSlide).find(".cover-image:visible").length < 1 ){
1408                     $(coverSlide).remove();
1409                 } else {
1410                     $(coverSlide).addClass("cover-slides");
1411                     var img = $(coverSlide).find(".cover-image:visible").find("img")[0];
1412                     if( $(img).length > 0 && img.complete && img.naturalHeight > 0 ){
1413                         $(".cover-slides").css({"background-image":"none"});
1414                     }
1415                 }
1416             });
1417
1418             $("#editions img").each(function(i){
1419                 if ( this.src.indexOf('amazon.com') >= 0 ) {
1420                     w = this.width;
1421                     h = this.height;
1422                     if ((w == 1) || (h == 1)) {
1423                         this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
1424                     } else if ( (this.complete != null) && (!this.complete) || this.naturalHeight == 0 ) {
1425                         this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
1426                     }
1427                 }
1428             });
1429         }
1430
1431         function removeLocalImage(imagenumber) {
1432             var thumbnail = $("#imagenumber-" + imagenumber );
1433             var copy = thumbnail.html();
1434             thumbnail.find("img").css("opacity", ".2");
1435             thumbnail.find("a.remove").html("<img style='display:inline-block' src='" + interface + "/" + theme + "/img/spinner-small.gif' alt='' />");
1436             $.ajax({
1437                 url: "/cgi-bin/koha/svc/cover_images?action=delete&imagenumber=" + imagenumber,
1438                 success: function(data) {
1439                     $(data).each( function(i) {
1440                         if ( this.deleted == 1 ) {
1441                             thumbnail.remove();
1442                         } else {
1443                             thumbnail.html( copy );
1444                             alert(_("An error occurred on deleting this image"));
1445                         }
1446                         if ( $('ul.thumbnails > li').length == 0 ) {
1447                             showNoImageMessage();
1448                         }
1449                     });
1450                 },
1451                 error: function(data) {
1452                     thumbnail.html( copy );
1453                     alert(_("An error occurred on deleting this image"));
1454                 }
1455             });
1456         }
1457
1458         function showNoImageMessage() {
1459             var no_images_msg = _("No images have been uploaded for this bibliographic record yet.");
1460             no_images_msg = '<p>' + no_images_msg + '</p>';
1461             [% IF ( CAN_user_tools_upload_local_cover_images ) %]
1462                 var please_upload = _("Upload an image file: %sUpload%s").format("<a class='btn btn-default btn-xs' href='/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=" + biblionumber + "&amp;filetype=image'><i class='fa fa-upload' aria-hidden='true'></i> ","</a>");
1463                 no_images_msg += "<p id='upload_image'>" + please_upload + '</p>';
1464             [% END %]
1465             $('#images').html(no_images_msg);
1466         }
1467
1468         [% IF StaffDetailItemSelection %]
1469             function itemSelectionBuildDeleteLink(div) {
1470                 var itemnumbers = new Array();
1471                 $("input[name='itemnumber'][type='checkbox']:checked", div).each(function() {
1472                     itemnumbers.push($(this).val());
1473                 });
1474                 if (itemnumbers.length > 0) {
1475                     var url = '/cgi-bin/koha/tools/batchMod.pl?op=show&del=1';
1476                     url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1477                     url += '&biblionumber=[% biblionumber | uri %]';
1478                     url += '&src=CATALOGUING';
1479                     $('a.itemselection_action_delete').attr('href', url);
1480                 } else {
1481                     return false;
1482                 }
1483                 return true
1484             }
1485
1486             function itemSelectionBuildModifyLink(div) {
1487                 var itemnumbers = new Array();
1488                 $("input[name='itemnumber'][type='checkbox']:checked", div).each(function() {
1489                     itemnumbers.push($(this).val());
1490                 });
1491                 if (itemnumbers.length > 0) {
1492                     var url = '/cgi-bin/koha/tools/batchMod.pl?op=show';
1493                     url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
1494                     url += '&biblionumber=[% biblionumber | uri %]';
1495                     url += '&src=CATALOGUING';
1496                     $('a.itemselection_action_modify').attr('href', url);
1497                 } else {
1498                     return false;
1499                 }
1500                 return true;
1501             }
1502
1503             function itemSelectionBuildActionLinks(tab) {
1504                 var div = $("#" + tab);
1505                 var delete_link_ok = itemSelectionBuildDeleteLink(div);
1506                 var modify_link_ok = itemSelectionBuildModifyLink(div);
1507                 if (modify_link_ok || delete_link_ok) {
1508                     $('.itemselection_actions', div).show();
1509                 } else {
1510                     $('.itemselection_actions', div).hide();
1511                 }
1512             }
1513
1514             $(document).ready(function() {
1515                 $('table.items_table').each(function() {
1516                     var div = $(this).parent().attr("id");
1517                     itemSelectionBuildActionLinks(div);
1518                 });
1519
1520                 $("input[name='itemnumber'][type='checkbox']").change(function() {
1521                     var div = $(this).parents('table').parent().parent().attr("id");
1522                     itemSelectionBuildActionLinks(div);
1523                 });
1524
1525                 $(".SelectAll").on("click",function(e){
1526                     e.preventDefault();
1527                     var tab = $(this).data("tab");
1528                     $("input[name='itemnumber'][type='checkbox']", $("#"+tab)).prop('checked', true);
1529                     itemSelectionBuildActionLinks(tab);
1530                 });
1531
1532                 $(".ClearAll").on("click",function(e){
1533                     e.preventDefault();
1534                     var tab = $(this).data("tab");
1535                     $("input[name='itemnumber'][type='checkbox']", $("#"+tab)).prop('checked', false);
1536                     itemSelectionBuildActionLinks(tab);
1537                 });
1538             });
1539         [% END %]
1540
1541         $(document).ready(function() {
1542             // Pick details tab to display by default
1543             [% IF count == 0 %]
1544                 [% IF ( Koha.Preference('HTML5MediaEnabled') == 'staff' or Koha.Preference('HTML5MediaEnabled') == 'both' ) && HTML5MediaSets.size %]
1545                     $(".nav-tabs a[href='#html5media']").tab("show");
1546                 [% ELSIF ComponentParts && ComponentParts.size %]
1547                     $(".nav-tabs a[href='#components']").tab("show");
1548                 [% ELSE %]
1549                     $(".nav-tabs a[href='#holdings']").tab("show");
1550                 [% END %]
1551             [% ELSE %]
1552                 $(".nav-tabs a[href='#holdings']").tab("show");
1553             [% END %]
1554             $('#search-form').focus();
1555             $('.thumbnails > li > .remove').click(function() {
1556                 var result = confirm(_("Are you sure you want to delete this cover image?"));
1557
1558                 if ( result == true ) {
1559                     var imagenumber = $(this).parent().attr('id').split('-')[1];
1560                     removeLocalImage(imagenumber);
1561                 }
1562
1563                 return false;
1564             });
1565             [% IF ( IntranetCoce && CoceProviders ) %]
1566                 KOHA.coce.getURL('[% CoceHost | html %]', '[% CoceProviders | html %]');
1567             [% END %]
1568
1569             $("body").on("click",".previewMARC", function(e){
1570                 e.preventDefault();
1571                 var page = $(this).attr("href");
1572                 $("#marcPreview .modal-body").load(page + " table");
1573                 $('#marcPreview').modal({show:true});
1574             });
1575             $("#marcPreview").on("hidden.bs.modal", function(){
1576                 $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
1577             });
1578             [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
1579                 novSelect.loadContentForQuery({
1580                     ClientIdentifier : '[% IF normalized_isbn %][% normalized_isbn | html %][% ELSE %][% normalized_upc | html %][% END %]',
1581                     ISBN : '[% IF normalized_isbn %][% normalized_isbn | html %][% ELSE %][% normalized_upc | html %][% END %]',
1582                     version : '2.1'
1583                 },
1584                 '[% Koha.Preference('NovelistSelectStaffProfile') | html %]',
1585                 '[% Koha.Preference('NovelistSelectPassword') | html %]',
1586                 function(d){
1587                     if ( d.length > 0 ){ //If no content
1588                         $(".NovelistSelect").show();
1589                     }
1590                  });
1591              [% END %]
1592              $(".print-label").on("click", function(e){
1593                 e.preventDefault();
1594                 link = $(this).attr("href");
1595                 openWindow(link,"Print spine label",400,400);
1596              });
1597              $(".cover-slider").on("click",".cover-nav", function(e){
1598                  e.preventDefault();
1599                 var cover_slider = $(this).parent();
1600                 // Adding click handler for cover image navigation links
1601                 var num = $(this).data("num");
1602                 $(cover_slider).find(".cover-nav").removeClass("nav-active");
1603                 $(this).addClass("nav-active");
1604                 $(cover_slider).find(".cover-image").hide();
1605                 $(cover_slider).find(".cover-image").eq( num ).show();
1606              });
1607         });
1608
1609
1610         [% IF ( IntranetCoce && CoceProviders ) %]
1611             let counter_wait = 0;
1612             function wait_for_images(cb){
1613
1614                 var loaded = 1;
1615                 counter_wait++;
1616
1617                 if ( loaded ) {
1618                     loaded = KOHA.coce.done;
1619                 }
1620
1621                 if (!loaded && counter_wait < 50) {// Do not wait more than 5 seconds
1622                     window.setTimeout(function(){wait_for_images(cb);}, 100);
1623                 } else {
1624                     if (counter_wait >= 50 ) {
1625                         console.log("Could not retrieve the images")
1626                     }
1627                     cb();
1628                 }
1629             }
1630
1631             $(window).load(function() {
1632                 wait_for_images(verify_cover_images);
1633             });
1634         [% ELSE %]
1635             $(window).load(function() {
1636                 verify_cover_images;
1637             });
1638         [% END %]
1639     </script>
1640     [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
1641         <script src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script>
1642     [% END %]
1643     [% INCLUDE 'datatables.inc' %]
1644     [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
1645     [% INCLUDE 'columns_settings.inc' %]
1646     [% INCLUDE 'js-date-format.inc' %]
1647     [% INCLUDE 'js-patron-format.inc' %]
1648     [% INCLUDE 'js-biblio-format.inc' %]
1649     [% Asset.js("js/browser.js") | $raw %]
1650     [% Asset.js("js/table_filters.js") | $raw %]
1651     <script>
1652         var browser;
1653         browser = KOHA.browser('[% searchid | html %]', parseInt(biblionumber, 10));
1654         browser.show();
1655
1656         [% IF bundlesEnabled %]
1657         var bundle_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail','bundle_tables','json') | $raw %];
1658         var bundle_lost_value = [% Koha.Preference('BundleLostValue') | html %];
1659         [% END %]
1660         $(document).ready(function() {
1661
1662             [% IF bundlesEnabled %] // Bundle handling
1663             function createChild ( row, itemnumber, duedate ) {
1664
1665                 // Toolbar
1666                 var bundle_toolbar = $('<div id="toolbar" class="btn-toolbar"></div>');
1667                 bundle_toolbar.append('<a class="btn btn-default" data-toggle="modal" data-target="#addToBundleModal" data-item="' + itemnumber + '"><i class="fa fa-plus"></i> ' + _("Add to bundle") + '</a>');
1668                 bundle_toolbar.append('<a class="btn btn-default" data-toggle="modal" data-target="#removeFromBundleModal" data-item="' + itemnumber + '"><i class="fa fa-minus"></i> ' + _("Remove from bundle") + '</a>');
1669
1670                 // Disable management if there's a duedate
1671                 if(duedate) {
1672                     bundle_toolbar.children('.btn').addClass("disabled");
1673                 }
1674
1675                 // This is the table we'll convert into a DataTable
1676                 var bundles_table = $('<table class="display tbundle" data-itemnumber="'+itemnumber+'" id="bundle_table_'+itemnumber+'" width="100%"/>');
1677
1678                 // Display it the child row
1679                 row.child( bundle_toolbar.add(bundles_table), 'bundle' ).show();
1680
1681                 // Initialise as a DataTable
1682                 var bundle_table_url = "/api/v1/items/" + itemnumber + "/bundled_items?";
1683                 var bundle_table = bundles_table.kohaTable({
1684                     "ajax": {
1685                         "url": bundle_table_url
1686                     },
1687                     "embed": [
1688                         "biblio",
1689                         "return_claim.patron"
1690                     ],
1691                     "order": [[ 1, "asc" ]],
1692                     "columnDefs": [ {
1693                         "targets": [0,1,2,3],
1694                         "render": function (data, type, row, meta) {
1695                             if ( data && type == 'display' ) {
1696                                 return data.escapeHtml();
1697                             }
1698                             return data;
1699                         }
1700                     } ],
1701                     "columns": [
1702                         {
1703                             "data": "biblio.title:biblio.subtitle:biblio.medium",
1704                             "title": _("Title"),
1705                             "searchable": true,
1706                             "orderable": true,
1707                             "render": function(data, type, row, meta) {
1708                                 return $biblio_to_html(row.biblio, { link: 1 });
1709                             }
1710                         },
1711                         {
1712                             "data": "biblio.author",
1713                             "title": _("Author"),
1714                             "searchable": true,
1715                             "orderable": true,
1716                         },
1717                         {
1718                             "data": "callnumber",
1719                             "title": _("Callnumber"),
1720                             "searchable": true,
1721                             "orderable": true,
1722                         },
1723                         {
1724                             "data": "external_id",
1725                             "title": _("Barcode"),
1726                             "searchable": true,
1727                             "orderable": true,
1728                         },
1729                         {
1730                             "data": "lost_status:last_seen_date:return_claim.patron",
1731                             "title": _("Status"),
1732                             "searchable": false,
1733                             "orderable": true,
1734                             "render": function(data, type, row, meta) {
1735                                 if ( row.lost_status == bundle_lost_value ) {
1736                                     let out = '<span class="lost">' + _("Last seen") + ': ' + $date(row.last_seen_date) + '</span>';
1737                                     if ( row.return_claim ) {
1738                                         out = out + '<span class="claims_return">' + _("Claims returned by") + ': ' + $patron_to_html( row.return_claim.patron, { display_cardnumber: false, url: true } ) + '</span>';
1739                                     }
1740                                     return out;
1741                                 }
1742                                 else if ( row.lost_status !== 0 ) {
1743                                     return '<span class="lost">' + _("Lost") + ': ' + row.lost_status + '</span>';
1744                                 }
1745                                 return '<span class="available">' + _("Present") + '</span>';
1746                             }
1747                         },
1748                         {
1749                             "data": function( row, type, val, meta ) {
1750                                 var result;
1751                                 if (duedate) {
1752                                     result = '<button class="btn btn-default btn-xs remove disabled" role="button" data-itemnumber="'+row.item_id+'"><i class="fa fa-minus" aria-hidden="true"></i> '+_("Remove")+'</button>\n';
1753                                 } else {
1754                                     result = '<button class="btn btn-default btn-xs remove" role="button" data-itemnumber="'+row.item_id+'"><i class="fa fa-minus" aria-hidden="true"></i> '+_("Remove")+'</button>\n';
1755                                 }
1756                                 return result;
1757                             },
1758                             "title": _("Actions"),
1759                             "searchable": false,
1760                             "orderable": false,
1761                             "class": "noExport"
1762                         }
1763                     ]
1764                 }, bundle_settings, 1);
1765                 $(".tbundle").on("click", ".remove:not(.disabled)", function(){
1766                     var bundle_table = $(this).closest('table');
1767                     var host_itemnumber = bundle_table.data('itemnumber');
1768                     var component_itemnumber = $(this).data('itemnumber');
1769                     var unlink_item_url = "/api/v1/items/" + host_itemnumber + "/bundled_items/" + component_itemnumber;
1770                     $.ajax({
1771                         type: "DELETE",
1772                         url: unlink_item_url,
1773                         success: function(){
1774                             bundle_table.DataTable({ 'retrieve': true }).draw(false);
1775                         }
1776                     });
1777                 });
1778
1779                 return;
1780             }
1781
1782             var bundle_changed;
1783             var bundle_form_active;
1784             $("#addToBundleModal").on("shown.bs.modal", function(e){
1785                 var button = $(e.relatedTarget);
1786                 var item_id = button.data('item');
1787                 $("#addResult").replaceWith('<div id="addResult"></div>');
1788                 $("#addToBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items');
1789                 $("#external_id").focus();
1790                 bundle_changed = 0;
1791                 bundle_form_active = item_id;
1792             });
1793
1794             $("#addToBundleForm").submit(function(event) {
1795
1796                   /* stop form from submitting normally */
1797                   event.preventDefault();
1798
1799                   /* get the action attribute from the <form action=""> element */
1800                   var $form = $(this),
1801                   url = $form.attr('action');
1802
1803                   /* Send the data using post with external_id */
1804                   var posting = $.post({
1805                       url: url,
1806                       data: JSON.stringify({ external_id: $('#external_id').val()}),
1807                       contentType: "application/json; charset=utf-8",
1808                       dataType: "json"
1809                   });
1810
1811                   /* Report the results */
1812                   posting.done(function(data) {
1813                       var barcode = $('#external_id').val();
1814                       $('#addResult').replaceWith('<div id="addResult" class="alert alert-success">'+_("Success: Added '%s'").format(barcode)+'</div>');
1815                       $('#external_id').val('').focus();
1816                       bundle_changed = 1;
1817                   });
1818                   posting.fail(function(data) {
1819                       var barcode = $('#external_id').val();
1820                       if ( data.status === 409 ) {
1821                           var response = data.responseJSON;
1822                           if ( response.key === "PRIMARY" ) {
1823                               $('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>');
1824                           } else {
1825                               $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>');
1826                           }
1827                       } else if ( data.status === 404 ) {
1828                           $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' not found").format(barcode)+'</div>');
1829                       } else if ( data.status === 400 ) {
1830                           var response = data.responseJSON;
1831                           if ( response.error === "Bundles cannot be nested" ) {
1832                               $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' is a bundle and bundles cannot be nested").format(barcode)+'</div>');
1833                           } else {
1834                               $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>');
1835                           }
1836                       } else {
1837                           $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>');
1838                       }
1839                       $('#external_id').val('').focus();
1840                   });
1841             });
1842
1843             $("#addToBundleModal").on("hidden.bs.modal", function(e){
1844                 if ( bundle_changed ) {
1845                     $('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload();
1846                 }
1847                 bundle_form_active = 0;
1848                 bundle_changed = 0;
1849             });
1850
1851             $("#removeFromBundleModal").on("shown.bs.modal", function(e){
1852                 var button = $(e.relatedTarget);
1853                 var item_id = button.data('item');
1854                 $("#removeResult").replaceWith('<div id="removeResult"></div>');
1855                 $("#removeFromBundleForm").attr('action', '/api/v1/items/' + item_id + '/bundled_items/');
1856                 $("#rm_external_id").focus();
1857                 bundle_changed = 0;
1858                 bundle_form_active = item_id;
1859             });
1860
1861             $("#removeFromBundleForm").submit(function(event) {
1862
1863                 /* stop form from submitting normally */
1864                 event.preventDefault();
1865
1866                 /* get the action attribute from the <form action=""> element */
1867                 var $form = $(this),
1868                 url = $form.attr('action');
1869
1870                 var barcode = $('#rm_external_id').val();
1871
1872                 /* Fetch itemnumber using rm_external_id */
1873                 var itemReq = $.get('/api/v1/items', { q: JSON.stringify({
1874                     external_id: barcode
1875                 }) }, null, "json");
1876
1877                 var itemnumber;
1878                 itemReq.done(function(data) {
1879                     if (data.length === 1) {
1880                         itemnumber = data[0].item_id;
1881
1882                         /* Remove link using fetch itemnumber */
1883                         var deleteReq = $.ajax( url + itemnumber, {
1884                             type : 'DELETE'
1885                         });
1886
1887                         /* Report the results */
1888                         deleteReq.done(function(data) {
1889                             var barcode = $('#rm_external_id').val();
1890                             $('#removeResult').replaceWith('<div id="removeResult" class="alert alert-success">'+_("Success: Removed '%s'").format(barcode)+'</div>');
1891                             $('#rm_external_id').val('').focus();
1892                             bundle_changed = 1;
1893                         });
1894                         deleteReq.fail(function(data) {
1895                             var barcode = $('#rm_external_id').val();
1896                             if ( data.status === 409 ) {
1897                                 var response = data.responseJSON;
1898                                 if ( response.key === "PRIMARY" ) {
1899                                     $('#removeResult').replaceWith('<div id="removeResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>');
1900                                 } else {
1901                                     $('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>');
1902                                 }
1903                             } else if ( data.status === 404 ) {
1904                                 $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' not found").format(barcode)+'</div>');
1905                             } else {
1906                                 $('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>');
1907                             }
1908                             $('#rm_external_id').val('').focus();
1909                         });
1910                     } else {
1911                         $('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failed: Barcode matched more than one item '%s'").format(barcode)+'</div>');
1912                     }
1913                 });
1914                 itemReq.fail(function(data) {
1915                      $('#removeResult').replaceWith('<div id="removeResult" class="alert alert-danger">'+_("Failed: Item not found '%s'").format(barcode)+'</div>');
1916                     $('#rm_external_id').val('').focus();
1917
1918                 });
1919             });
1920
1921             $("#removeFromBundleModal").on("hidden.bs.modal", function(e){
1922                 if ( bundle_changed ) {
1923                     $('#bundle_table_'+bundle_form_active).DataTable({ 'retrieve': true }).ajax.reload();
1924                 }
1925                 bundle_form_active = 0;
1926                 bundle_changed = 0;
1927             });
1928             // End bundle handling
1929             [% END %]
1930
1931             var table_names = [ 'holdings_table', 'otherholdings_table' ];
1932             var table_settings = [ [% TablesSettings.GetTableSettings('catalogue', 'detail','holdings_table','json') | $raw %], [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json')  | $raw %] ];
1933             var has_images = [ "[% itemloop_has_images | html %]", "[% otheritemloop_has_images | html %]" ];
1934             table_names.forEach( function( table_name, index ) {
1935                 if ( !has_images[index] ) {
1936                     table_settings[index].columns.splice(1,1);
1937                 }
1938                 var dt_parameters = {
1939                     'sDom': 't',
1940                     'bPaginate': false,
1941                     'bAutoWidth': false,
1942                     "bKohaColumnsUseNames": true,
1943                     "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
1944                 };
1945                 var table = KohaTable( table_name, dt_parameters, table_settings[index], 'with_filters' );
1946
1947                 [% IF bundlesEnabled %]
1948                 // Add event listener for opening and closing bundle details
1949                 $('#' + table_name + ' tbody').on('click', 'button.details-control', function () {
1950                     var button = $(this);
1951                     var tr = button.closest('tr');
1952                     var dTable = button.closest('table').DataTable({ 'retrieve': true });
1953
1954                     var itemnumber = tr.data('itemnumber');
1955                     var duedate = tr.data('duedate');
1956                     var row = dTable.row( tr );
1957
1958                     if ( row.child.isShown() ) {
1959                         // This row is already open - close it
1960                         row.child.hide();
1961                         tr.removeClass('shown');
1962                         button.removeClass('active');
1963                     }
1964                     else {
1965                         // Open this row
1966                         createChild(row, itemnumber, duedate);
1967                         tr.addClass('shown');
1968                         button.addClass('active');
1969                     }
1970                 } );
1971                 [% END %]
1972             });
1973
1974             [% IF Koha.Preference('AcquisitionDetails') %]
1975                 var table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail', 'acquisitiondetails-table', 'json') | $raw %];
1976                 var acquisitiondetails_table = KohaTable("orders", {
1977                     "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
1978                     'bPaginate': false,
1979                     'bAutoWidth': false,
1980                     "aaSorting": [[ 4, "desc" ]],
1981                 }, table_settings);
1982             [% END %]
1983
1984             [% IF suggestions.count %]
1985                 $(".sorted").dataTable($.extend(true, {}, dataTablesDefaults, {
1986                     "aoColumnDefs": [
1987                         { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
1988                         { "sType": "anti-the", "aTargets" : [ "anti-the" ] }
1989                     ],
1990                     "sPaginationType": "full"
1991                 }));
1992             [% END %]
1993
1994         });
1995
1996         [% IF found1 && Koha.Preference('RetainCatalogSearchTerms') %]
1997             $(document).ready(function() {
1998                 var search_index = localStorage.getItem("cat_search_pulldown_selection");
1999                 var search_value = localStorage.getItem("searchbox_value");
2000                 if ( search_index ){ $('#cat-search-block select.advsearch').val(search_index)};
2001                 if ( search_value ){ $('#cat-search-block #search-form').val(search_value)};
2002             });
2003         [% END %]
2004
2005         [% IF Koha.Preference('EnableItemGroups') %]
2006             // Load item groups table
2007             var itemGroupsTable = KohaTable("items-group-table", {
2008                 "bAutoWidth": false,
2009                 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
2010                 "aoColumns": [
2011                     {
2012                         "mDataProp": function( oObj ) {
2013                             return oObj.display_order;
2014                         },
2015                     },
2016                     {
2017                         "mDataProp": function( oObj ) {
2018                             return oObj.description;
2019                         },
2020                     },
2021                     {
2022                         "mDataProp": function( oObj ) {
2023                             [% IF CAN_user_editcatalogue_manage_item_groups %]
2024                                 return `<button class='item-group-edit btn btn-default btn-xs' data-item-group-id='${oObj.item_group_id}'>
2025                                     <i class='fa fa-edit'></i> ${_("Edit")}
2026                                 </button>`
2027                                 + '&nbsp'
2028                                 + `<button class='item-group-delete btn btn-default btn-xs' data-item-group-id='${oObj.item_group_id}'>
2029                                     <i class='fa fa-trash'></i> ${('Delete')}
2030                                 </button>`;
2031                             [% ELSE %]
2032                                 return "";
2033                             [% END %]
2034                         },
2035                     },
2036                 ],
2037                 "bPaginate": false,
2038                 "bProcessing": true,
2039                 "bServerSide": false,
2040                 "sAjaxSource": `/api/v1/biblios/${biblionumber}/item_groups?_per_page=-1`,
2041                 "sAjaxDataProp": "",
2042                 "fnServerData": function ( sSource, aoData, fnCallback ) {
2043                     $.getJSON( sSource, aoData, function (json) {
2044                         fnCallback(json)
2045                     } );
2046                 },
2047             });
2048
2049             // Create new item groups
2050             $('.item-group-create').on('click', function(){
2051                 $('#modal-item-group-create-form-description').val("");
2052                 $('#modal-item-group-create-submit').removeAttr('disabled');
2053                 $('#modal-item-group-create').modal('show');
2054             });
2055
2056             $("#modal-item-group-create-form").validate({
2057                 submitHandler: function(form) {
2058                     $.ajax({
2059                         url: `/api/v1/biblios/${biblionumber}/item_groups`,
2060                         headers: { "x-koha-embed": "items" },
2061                         success: function(item_groups){
2062                             $('#modal-item-group-create-submit').attr('disabled', 'disabled');
2063
2064                             var settings = {
2065                               "url": `/api/v1/biblios/${biblionumber}/item_groups`,
2066                               "method": "POST",
2067                               "headers": {
2068                                 "Content-Type": "application/json"
2069                               },
2070                               "data": JSON.stringify(
2071                                   {
2072                                       "description": $("#modal-item-group-create-form-description").val(),
2073                                       "display_order": $("#modal-item-group-create-form-display_order").val(),
2074                                   }
2075                               ),
2076                             };
2077
2078                             $.ajax(settings)
2079                             .done(function (response) {
2080                                 $('#item-group-add-form-select').append($('<option>', {
2081                                     value: response.item_group_id,
2082                                     text: response.description
2083                                 }));
2084
2085                                 $('#modal-item-group-create').modal('hide');
2086                                 if ( item_groups.length == 0 ) {
2087                                     // This bib has no previous item groups, reload the page
2088                                     window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
2089                                 } else {
2090                                     // Has other item groups, just reload the table
2091                                     itemGroupsTable.api().ajax.reload();
2092                                 }
2093                             })
2094                             .fail(function(err) {
2095                                 var message = err.responseJSON.error;
2096                                 alert(message);
2097                             });
2098                         }
2099                     });
2100                 }
2101             });
2102
2103             $('#modal-item-group-create').on('shown.bs.modal', function () {
2104                 $('#modal-item-group-create-form-description').focus();
2105             })
2106
2107             // Edit existing item groups
2108             $('body').on( 'click', '.item-group-edit', function(){
2109                 const item_group_id = $(this).data('item-group-id');
2110                 const url = `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`;
2111                 $.get( url, function( data ) {
2112                     $('#modal-item-group-edit-form-description').val( data.description );
2113                     $('#modal-item-group-edit-form-display_order').val( data.display_order );
2114                     $('#modal-item-group-edit-submit').data('item-group-id', item_group_id );
2115                     $('#modal-item-group-edit-submit').removeAttr('disabled');
2116                     $('#modal-item-group-edit').modal('show');
2117                 });
2118             });
2119
2120             $("#modal-item-group-edit-form").validate({
2121                 submitHandler: function(form) {
2122                     $('#modal-item-group-edit-submit').attr('disabled', 'disabled');
2123
2124                     const item_group_id = $('#modal-item-group-edit-submit').data('item-group-id');
2125                     const url = `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`;
2126
2127                     var settings = {
2128                       "url": url,
2129                       "method": "PUT",
2130                       "headers": {
2131                         "Content-Type": "application/json"
2132                       },
2133                       "data": JSON.stringify(
2134                           {
2135                               "description": $("#modal-item-group-edit-form-description").val(),
2136                               "display_order": $("#modal-item-group-edit-form-display_order").val(),
2137                           }
2138                       ),
2139                     };
2140
2141                     $.ajax(settings)
2142                     .done(function (response) {
2143                         $('#modal-item-group-edit').modal('hide');
2144                         itemGroupsTable.api().ajax.reload();
2145                     })
2146                     .fail(function(err) {
2147                         var message = err.responseJSON.error;
2148                         alert(message);
2149                     });
2150                 }
2151             });
2152
2153             $('#modal-item-group-edit').on('shown.bs.modal', function () {
2154                 $('#modal-item-group-edit-form-description').focus();
2155             })
2156
2157             // Delete existing item groups
2158             $('body').on( 'click', '.item-group-delete', function(){
2159                 const item_group_id = $(this).data('item-group-id');
2160                 $('#modal-item-group-delete-submit').data('item-group-id', item_group_id );
2161                 $('#modal-item-group-delete-submit').removeAttr('disabled');
2162                 $('#modal-item-group-delete').modal('show');
2163             });
2164             $("#modal-item-group-delete-submit").on('click', function(){
2165                 $('#modal-item-group-delete-submit').attr('disabled', 'disabled');
2166                 const item_group_id = $("#modal-item-group-delete-submit").data('item-group-id');
2167
2168                 $.ajax({
2169                     url: `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`,
2170                     headers: { "x-koha-embed": "items" },
2171                     success: function(item_group_data){
2172                         $.ajax({
2173                           "url": `/api/v1/biblios/${biblionumber}/item_groups/${item_group_id}`,
2174                           "method": "DELETE",
2175                         })
2176                         .done(function (response) {
2177                             $('#modal-item-group-delete').modal('hide');
2178                             $(`#item-group-add-form-select option[value='${item_group_id}']`).remove();
2179                             if ( item_group_data.items === null ) {
2180                                 // No items for this item group, we can just refresh the table
2181                                 itemGroupsTable.api().ajax.reload();
2182                             } else {
2183                                 // This item group had items attached to it, we need to reload the page
2184                                 window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
2185                             }
2186                         })
2187                         .fail(function(err) {
2188                             var message = err.responseJSON.error;
2189                             alert(message);
2190                         });
2191                     }
2192                 });
2193             });
2194
2195             // Add item(s) to a item group
2196             $('.itemselection_action_item_group_set').on('click', function(){
2197                 $('#modal-item-group-set').modal('show');
2198             });
2199
2200             $("#modal-item-group-set-form").validate({
2201                 submitHandler: function(form) {
2202                     $('#modal-item-group-set-submit').attr('disabled', 'disabled');
2203
2204                     const item_group_id = $('#item-group-add-form-select').val();
2205
2206                     let itemnumbers = new Array();
2207                     $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
2208                         const itemnumber = $(this).val();
2209                         itemnumbers.push( itemnumber );
2210                     });
2211                     if (itemnumbers.length > 0) {
2212                         let url = '/cgi-bin/koha/catalogue/detail.pl?op=set_item_group';
2213                         url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
2214                         url += '&biblionumber=[% biblionumber | uri %]';
2215                         url += `&item_group_id=${item_group_id}`;
2216
2217                         window.location.replace(url);
2218                     }
2219
2220                     $('#modal-item-group-set').modal('hide');
2221                 }
2222             });
2223
2224             // Remove item(s) from an item group
2225             $('.itemselection_action_item_group_unset').on('click', function(){
2226                 $('#modal-item-group-unset').modal('show');
2227             });
2228
2229             $("#modal-item-group-unset-submit").on('click', function(){
2230                 $('#modal-item-group-unset-submit').attr('disabled', 'disabled');
2231
2232                 let itemnumbers = new Array();
2233                 $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
2234                     const itemnumber = $(this).val();
2235                     itemnumbers.push( itemnumber );
2236                 });
2237                 if (itemnumbers.length > 0) {
2238                     let url = '/cgi-bin/koha/catalogue/detail.pl?op=unset_item_group';
2239                     url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
2240                     url += '&biblionumber=[% biblionumber | uri %]';
2241
2242                     window.location.replace(url);
2243                 }
2244
2245                 $('#modal-item-group-unset').modal('hide');
2246
2247             });
2248         [% END %]
2249     </script>
2250 [% END %]
2251 [% INCLUDE 'intranet-bottom.inc' %]