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