Bug 21526: Use the 'url' filter when needed
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / catalogue / detail.tt
index d53df31..cb2182a 100644 (file)
+[% USE raw %]
+[% USE Asset %]
 [% USE Koha %]
 [% USE KohaDates %]
 [% USE AuthorisedValues %]
 [% USE Branches %]
+[% USE Biblio %]
+[% USE ColumnsSettings %]
+[% SET AdlibrisEnabled = Koha.Preference('AdlibrisCoversEnabled') %]
+[% SET AdlibrisURL = Koha.Preference('AdlibrisCoversURL') %]
 
-[% ShowCourseReserves = 0 %]
+[% IF Koha.Preference('AmazonAssocTag') %]
+    [% AmazonAssocTag = '?tag=' _ Koha.Preference('AmazonAssocTag') %]
+[% ELSE %]
+    [% AmazonAssocTag = '' %]
+[% END %]
+
+[% ShowCourseReserves = 0 | html %]
 [% IF UseCourseReserves %]
     [% FOREACH item IN itemloop %]
        [% IF item.course_reserves %]
            [% FOREACH r IN item.course_reserves %]
                [% IF r.course.enabled == 'yes' %]
-                   [% ShowCourseReserves = 1 %]
+                   [% ShowCourseReserves = 1 | html %]
                [% END %]
            [% END %]
         [% END %]
     [% END %]
 [% END %]
 
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
-[% INCLUDE 'greybox.inc' %]
 <title>Koha &rsaquo; Catalog &rsaquo;
   [% IF ( unknownbiblionumber ) %]
     Unknown record
   [% ELSE %]
-    Details for [% title |html %] [% FOREACH subtitl IN subtitle %] [% subtitl.subfield | html %][% END %]
+    Details for [% title | html %] [% FOREACH subtitl IN subtitle %] [% subtitl.subfield | html %][% END %]
   [% END %]
 </title>
-
-[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectProfile') && ( normalized_isbn || normalized_upc ) ) %]
-    <script type="text/javascript" src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script>
-[% END %]
-
-[% INCLUDE 'doc-head-close.inc' %]<script type="text/JavaScript">
-//<![CDATA[
-// http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
-function verify_images() {
-    $("#bookcoverimg").each(function(i){
-        $(this).find('img').each(function(i){
-           if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0) || (this.src.indexOf('images-na.ssl-images-amazon.com'))) {
-                w = this.width;
-                h = this.height;
-                if ((w == 1) || (h == 1)) {
-                    $("#amazon-bookcoverimg").remove();
-                    $(".yui-gb").attr("class","yui-g");
-                } else if ((this.complete != null) && (!this.complete)) {
-                    $("#amazon-bookcoverimg").remove();
-                    $(".yui-gb").attr("class","yui-g");
-                }
-            }
-        });
-        if( $(this).find('img').length < 1 ) $(this).remove();
-    });
-       $("#editions img").each(function(i){
-           if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0) || (this.src.indexOf('images-na.ssl-images-amazon.com'))) {
-            w = this.width;
-            h = this.height;
-            if ((w == 1) || (h == 1)) {
-                          this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
-            } else if ((this.complete != null) && (!this.complete)) {
-                             this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
-            }
-        }
-        });
-}
-
-    function removeLocalImage(imagenumber) {
-
-        $.ajax({
-            url: "/cgi-bin/koha/svc/cover_images?action=delete&biblionumber=" + [% biblionumber %] + "&imagenumber=" + imagenumber,
-            success: function(data) {
-                $(data).each( function(i) {
-                    if ( this.deleted == 1 ) {
-                        $('#imagenumber-' + this.imagenumber).remove();
-                    }
-                    if ( $('ul.thumbnails > li').length == 0 ) {
-                        showNoImageMessage();
-                    }
-                });
-            },
-            error: function(data) {
-                alert(_("An error occurred on deleting this image"));
-            }
-        });
-
-    }
-
-    function showNoImageMessage() {
-
-        var no_images_msg = _("No images have been uploaded for this bibliographic record yet.");
-        no_images_msg = '<p>' + no_images_msg + '</p>';
-    [% IF ( CAN_user_tools_upload_local_cover_images ) %]
-        var please_upload = _("Please select the image file to upload. %sUpload%s").format(
-            "<a class='btn btn-mini' href='/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=[% biblionumber %]&amp;filetype=image'><i class='fa fa-upload' aria-hidden='true'></i> ",
-            "</a>");
-        no_images_msg += "<p id='upload_image'>" + please_upload + '</p>';
-    [% END %]
-
-        $('#images').html(no_images_msg);
-    }
-
-    [% IF StaffDetailItemSelection %]
-
-        function itemSelectionBuildDeleteLink(div) {
-            var itemnumbers = new Array();
-            $("input[name='itemnumber'][type='checkbox']:checked", div).each(function() {
-                itemnumbers.push($(this).val());
-            });
-            if (itemnumbers.length > 0) {
-                  var url = '/cgi-bin/koha/tools/batchMod.pl?op=show&del=1';
-                  url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
-                  url += '&src=' + '[% "/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber" |uri %]';
-                  $('a.itemselection_action_delete').attr('href', url);
-            } else {
-                return false;
-            }
-            return true
-        }
-
-        function itemSelectionBuildModifyLink(div) {
-            var itemnumbers = new Array();
-            $("input[name='itemnumber'][type='checkbox']:checked", div).each(function() {
-                itemnumbers.push($(this).val());
-            });
-            if (itemnumbers.length > 0) {
-                  var url = '/cgi-bin/koha/tools/batchMod.pl?op=show';
-                  url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
-                  url += '&src=' + '[% "/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber" |uri %]';
-                  $('a.itemselection_action_modify').attr('href', url);
-            } else {
-                return false;
-            }
-            return true;
-        }
-
-        function itemSelectionBuildActionLinks(tab) {
-            var div = $("#" + tab);
-          var delete_link_ok = itemSelectionBuildDeleteLink(div);
-          var modify_link_ok = itemSelectionBuildModifyLink(div);
-          if (modify_link_ok || delete_link_ok) {
-            $('.itemselection_actions', div).show();
-          } else {
-            $('.itemselection_actions', div).hide();
-          }
-        }
-
-        $(document).ready(function() {
-
-          $('table.items_table').each(function() {
-            var div = $(this).parent().attr("id");
-            itemSelectionBuildActionLinks(div);
-          });
-
-          $("input[name='itemnumber'][type='checkbox']").change(function() {
-            var div = $(this).parents('table').parent().parent().attr("id");
-            itemSelectionBuildActionLinks(div);
-          });
-
-            $(".SelectAll").on("click",function(e){
-                e.preventDefault();
-                var tab = $(this).data("tab");
-                $("input[name='itemnumber'][type='checkbox']", $("#"+tab)).prop('checked', true);
-                itemSelectionBuildActionLinks(tab);
-            });
-
-            $(".ClearAll").on("click",function(e){
-                e.preventDefault();
-                var tab = $(this).data("tab");
-                $("input[name='itemnumber'][type='checkbox']", $("#"+tab)).prop('checked', false);
-                itemSelectionBuildActionLinks(tab);
-            });
-
-        });
-    [% END %]
-
-    $(document).ready(function() {
-        $('#bibliodetails').tabs();
-        [% IF count == 0 %]
-            $('#bibliodetails').tabs("option", "active", 3);
-        [% END %]
-        $('#search-form').focus();
-        $('.thumbnails > li > a > span.remove').click(function() {
-            var result = confirm(_("Are you sure you want to delete this cover image?"));
-
-            if ( result == true ) {
-                var imagenumber = $(this).parent().parent().attr('id').split('-')[1];
-                removeLocalImage(imagenumber);
-            }
-
-            return false;
-        });
-    [%# inject no images message %]
-    [% IF ( LocalCoverImages && ! localimages.0 ) %]
-        showNoImageMessage();
-    [% END %]
-    [% IF LocalCoverImages %]
-        KOHA.LocalCover.GetCoverFromBibnumber(true);
-    [% END %]
-        $("body").on("click",".previewMARC", function(e){
-            e.preventDefault();
-            var page = $(this).attr("href");
-            $("#marcPreview .modal-body").load(page + " table");
-            $('#marcPreview').modal({show:true});
-        });
-        $("#marcPreview").on("hidden", function(){
-            $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/loading-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
-        });
-     [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectProfile') && ( normalized_isbn || normalized_upc ) ) %]
-         novSelect.loadContentForQuery(
-             {
-                 ClientIdentifier : '[% IF normalized_isbn %][% normalized_isbn %][% ELSE %][% normalized_upc %][% END %]',
-                 ISBN : '[% IF normalized_isbn %][% normalized_isbn %][% ELSE %][% normalized_upc %][% END %]',
-                 version : '2.1'
-             },
-             '[% Koha.Preference('NovelistSelectProfile') %]',
-             '[% Koha.Preference('NovelistSelectPassword') %]',
-             function(d){
-                 if ( d.length > 0 ){ //If no content
-                     $(".NovelistSelect").show();
-                 }
-             });
-     [% END %]
-
-    });
-
-     [% IF ( AmazonCoverImages || LocalCoverImages ) %]$(window).load(function() {
-        verify_images();
-     });[% END %]
-//]]>
-</script>
-<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
-[% INCLUDE 'browser-strings.inc' %]
-<!--[if lt IE 9]>
-<script type="text/javascript" src="[% interface %]/lib/shims/json2.min.js"></script>
-<![endif]-->
-<script type="text/javascript" src="[% interface %]/js/browser.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-    var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10));
-    browser.show();
-
-    function activate_filters(id) {
-        var table = $("#" + id + " table");
-        if (table.length == 1) {
-            filters_row = table.find('thead tr.filters_row');
-
-                var aoColumns = [];
-                filters_row.find('th').each(function() {
-                    if(this.className === "NoSort"){
-                        aoColumns.push(null);
-                    } else {
-                        aoColumns.push('text');
-                    }
-                });
-
-            if (table.find('thead tr.columnFilter').length == 0) {
-                table.dataTable().columnFilter({
-                    'sPlaceHolder': 'head:after'
-                    ,   'aoColumns': aoColumns
-                });
-                filters_row.addClass('columnFilter');
-            }
-            filters_row.show();
-        }
-
-        $('#' + id + '_activate_filters')
-            .html('<i class="fa fa-filter"></i> ' + _("Deactivate filters") )
-            .unbind('click')
-            .click(function() {
-                deactivate_filters(id);
-                return false;
-            });
-    }
-
-    function deactivate_filters(id) {
-        filters_row = $("#" + id + " table").find('thead tr.filters_row');
-
-        filters_row.find('input[type="text"]')
-            .val('')            // Empty filter text boxes
-            .trigger('keyup')   // Filter (display all rows)
-            .trigger('blur');   // Reset value to the column name
-        filters_row.hide();
-
-        $('#' + id + '_activate_filters')
-            .html('<i class="fa fa-filter"></i> ' + _("Activate filters") )
-            .unbind('click')
-            .click(function() {
-                activate_filters(id);
-                return false;
-            });
-    }
-
-    $(document).ready(function() {
-        var ids = ['holdings', 'otherholdings'];
-        for (var i in ids) {
-            var id = ids[i];
-            var table = $('#' + id + ' table');
-
-            // Duplicate the table header row for columnFilter
-            thead_row = table.find('thead tr');
-            clone = thead_row.clone().addClass('filters_row');
-            clone.find("th.NoSort").html('');
-            thead_row.before(clone);
-
-            // Enable sorting
-            table.dataTable($.extend(true, {}, dataTablesDefaults, {
-                'sDom': 't',
-                'bPaginate': false,
-                'bAutoWidth': false,
-                "aoColumnDefs": [
-                    { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }
-                ]
-            }));
-
-            // Show a link to activate filtering
-            link = $('<a>')
-                .attr('href', '#')
-                .attr('id', id + '_activate_filters');
-            $("." + id + "_table_controls").prepend(link);
-            deactivate_filters(id);
-        }
-        [% IF Koha.Preference('AcquisitionDetails') %]
-            $("#orders").dataTable($.extend(true, {}, dataTablesDefaults, {
-                'sDom': 't',
-                'bPaginate': false,
-                'bAutoWidth': false,
-                "aaSorting": [[ 4, "desc" ]],
-                "aoColumnDefs": [
-                    { "aTargets": "title-string", "sType": "title-string" }
-                ]
-            }));
-
-        [% END %]
-    });
-//]]>
-</script>
+[% INCLUDE 'doc-head-close.inc' %]
+[% Asset.css("css/datatables.css") | $raw %]
 </head>
 
 <body id="catalog_detail" class="catalog">
@@ -346,14 +50,14 @@ function verify_images() {
   [% IF ( unknownbiblionumber ) %]
     Unknown record
   [% ELSE %]
-    Details for <i>[% title |html %]  [% FOREACH subtitl IN subtitle %] [% subtitl.subfield | html %][% END %]</i>
+    Details for <i>[% title | html %]  [% FOREACH subtitl IN subtitle %] [% subtitl.subfield | html %][% END %]</i>
   [% END %]
 </div>
 
 <div id="doc3" class="yui-t2">
 
 [% IF ( unknownbiblionumber ) %]
-  <div class="dialog message">The record you requested does not exist ([% biblionumber %]).</div>
+  <div class="dialog message">The record you requested does not exist ([% biblionumber | html %]).</div>
 [% ELSE %]
    <div id="bd">
     <div id="yui-main">
@@ -362,10 +66,10 @@ function verify_images() {
 [% INCLUDE 'cat-toolbar.inc' %]
     [% IF ( ocoins ) %]
         <!-- COinS / OpenURL -->
-        <span class="Z3988" title="[% ocoins %]"></span>
+        <span class="Z3988" title="[% ocoins | html %]"></span>
     [% END %]
 
-    [% IF ( AmazonCoverImages  || LocalCoverImages ) %]
+    [% IF ( AmazonCoverImages  || LocalCoverImages || AdlibrisEnabled ) %]
         [% IF ( XSLTDetailsDisplay ) %]
             <div class="yui-gc">
             <div id="catalogue_detail_biblio" class="yui-u first">
@@ -384,12 +88,12 @@ function verify_images() {
     [% END %]
 
     [% IF ( XSLTDetailsDisplay ) %]
-        [% XSLTBloc %]
+        [% XSLTBloc | $raw %]
 
         [% IF shelves.count %]
             <span class="results_summary"><span class="label">Lists that include this title: </span>
             [% FOREACH s IN shelves %]
-                <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber %]">[% s.shelfname %]</a>
+                <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber | uri %]">[% s.shelfname | html %]</a>
                 [% IF ( loop.last ) %][% ELSE %]|[% END %]
             [% END %]
             </span>
@@ -398,42 +102,67 @@ function verify_images() {
                 <span class="results_summary"><span class="label">Tags:</span>
                     [% FOREACH TagLoo IN TagLoop %]
                         [% IF ( CAN_user_tools_moderate_tags ) %]
-                        <a href="/cgi-bin/koha/tags/list.pl?tag=[% TagLoo.term |url %]">[% TagLoo.term |html %]</a>
+                        <a href="/cgi-bin/koha/tags/list.pl?tag=[% TagLoo.term |url %]">[% TagLoo.term | html %]</a>
                         [% ELSE %]
-                        [% TagLoo.term |html %]
+                        [% TagLoo.term | html %]
                         [% END %]
-                        <span class="weight">([% TagLoo.weight_total %])</span>[% IF ( loop.last ) %][% ELSE %], [% END %]
+                        <span class="weight">([% TagLoo.weight_total | html %])</span>[% IF ( loop.last ) %][% ELSE %], [% END %]
                     [% END %]
                     </span>
         [% END %]
-        <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 %]&amp;viewas=html" title="MARC" class="previewMARC">Show</a></span>
+        <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>
+
+        [% IF ( holdcount ) %]
+            <span class="results_summary">
+                <span class="label">Holds:</span>
+                <span class="number_box">
+                    [% IF CAN_user_reserveforothers_place_holds %]
+                        <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber | uri %]">[% holdcount | html %]</a>
+                    [% ELSE %]
+                        <span>[% holdcount | html %]</span>
+                    [% END %]
+                </span>
+            </span>
+        [% END %]
 
-        [% IF ( AmazonCoverImages  || LocalCoverImages ) %]
+        [% IF ( article_requests_count = Biblio.ArticleRequestsActiveCount( biblionumber ) ) %]
+            <span class="results_summary">
+                <span class="label">Article requests:</span>
+                <span class="number_box">
+                    <a href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% biblionumber | uri %]">[% article_requests_count | html %]</a>
+                </span>
+            </span>
+        [% END %]
+
+        [% IF ( AmazonCoverImages  || LocalCoverImages || AdlibrisEnabled ) %]
         </div><div class="yui-u" id="bookcoverimg">
         [% IF ( LocalCoverImages ) %]
-            <div title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div>
+            <div title="[% biblionumber |url %]" class="[% biblionumber | html %]" id="local-thumbnail-preview"></div>
+        [% END %]
+        [% IF ( AdlibrisEnabled && normalized_isbn ) %]
+            <a href="[% AdlibrisURL | url %]?isbn=[% normalized_isbn | uri %]"><img src="[% AdlibrisURL | url %]?isbn=[% normalized_isbn | uri %]" class="adlibris-cover-big" alt="Adlibris cover image" /></a>
         [% END %]
         [% IF ( AmazonCoverImages ) %]
             <div id="amazon-bookcoverimg">
-            <a href="http://www.amazon[% AmazonTld %]/gp/reader/[% normalized_isbn %]/ref=sib_dp_pt/002-7879865-0184864#reader-link">
-                <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="" />
+            <a href="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link">
+                <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | html %].01.MZZZZZZZ.jpg" alt="" />
         </a></div>
         [% END %]
         [% END %]
     [% ELSE %]
 
-    <h3>[% title |html %]</h3>
+    <h3>[% title | html %]</h3>
     [% FOREACH subtitl IN subtitle %]
-       <h4>[% subtitl.subfield %]</h4>
+       <h4>[% subtitl.subfield | html %]</h4>
     [% END %]
-            [% UNLESS ( item_level_itypes ) %]<img src="[% imageurl %]" alt="[% translated_description %]" title="[% translated_description %]">[% END %]
-            [% IF ( unititle ) %]<p>[% unititle |html %]</p>[% END %]
+            [% UNLESS ( item_level_itypes ) %]<img src="[% imageurl | html %]" alt="[% translated_description | html %]" title="[% translated_description | html %]">[% END %]
+            [% IF ( unititle ) %]<p>[% unititle | html %]</p>[% END %]
             [% IF ( author ) %]<p>By <a href="/cgi-bin/koha/catalogue/search.pl?q=au:[% author |url %]">[% author | html %]</a></p>[% END %]
         <ul>
         [% IF ( MARCAUTHORS ) %]
             <li><strong>Additional authors:</strong><ul>
             [% FOREACH MARCAUTHOR IN MARCAUTHORS %]
-                <li>[% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %][% MARCAUTHOR_SUBFIELDS_LOO.separator %]<a title="‡[% MARCAUTHOR_SUBFIELDS_LOO.code %] [% MARCAUTHOR_SUBFIELDS_LOO.value |url %]" href="/cgi-bin/koha/catalogue/search.pl?q=[% FOREACH link_loo IN MARCAUTHOR_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit %]:[% link_loo.link |url %][% END %]">[% MARCAUTHOR_SUBFIELDS_LOO.value | html %]</a>[% END %]</li>
+                <li>[% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %][% MARCAUTHOR_SUBFIELDS_LOO.separator | html %]<a title="‡[% MARCAUTHOR_SUBFIELDS_LOO.code | html %] [% MARCAUTHOR_SUBFIELDS_LOO.value |url %]" href="/cgi-bin/koha/catalogue/search.pl?q=[% FOREACH link_loo IN MARCAUTHOR_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit | html %]:[% link_loo.link |url %][% END %]">[% MARCAUTHOR_SUBFIELDS_LOO.value | html %]</a>[% END %]</li>
                 [% END %]
 
         </ul>
@@ -441,7 +170,7 @@ function verify_images() {
         [% END %]
 [% IF ( MARCSERIES ) %]
                <li><strong>Series: </strong><ul>[% FOREACH MARCSERIE IN MARCSERIES %]
-               <li>[% FOREACH MARCSERIES_SUBFIELDS_LOO IN MARCSERIE.MARCSERIES_SUBFIELDS_LOOP %] [% IF ( MARCSERIES_SUBFIELDS_LOO.value ) %]<a href="/cgi-bin/koha/catalogue/search.pl?q=se:[% MARCSERIES_SUBFIELDS_LOO.value |url %]">[% MARCSERIES_SUBFIELDS_LOO.value %]</a>[% END %][% IF ( MARCSERIES_SUBFIELDS_LOO.volumenum ) %]. [% MARCSERIES_SUBFIELDS_LOO.volumenum %][% END %][% END %]</li> 
+               <li>[% FOREACH MARCSERIES_SUBFIELDS_LOO IN MARCSERIE.MARCSERIES_SUBFIELDS_LOOP %] [% IF ( MARCSERIES_SUBFIELDS_LOO.value ) %]<a href="/cgi-bin/koha/catalogue/search.pl?q=se:[% MARCSERIES_SUBFIELDS_LOO.value |url %]">[% MARCSERIES_SUBFIELDS_LOO.value | html %]</a>[% END %][% IF ( MARCSERIES_SUBFIELDS_LOO.volumenum ) %]. [% MARCSERIES_SUBFIELDS_LOO.volumenum | html %][% END %][% END %]</li> 
                [% END %]
                </ul>
                </li>
@@ -449,35 +178,35 @@ function verify_images() {
         [% IF ( publishercode ) %]
     <li><strong>Published by:</strong>
         <a href="/cgi-bin/koha/catalogue/search.pl?q=pb:[% publishercode |url %]">
-            [% publishercode |html %]
-        </a> [% IF ( place ) %]([% place %])[% END %] [% IF ( publicationyear ) %], [% publicationyear %][% END %] [% IF ( editionstatement ) %][% editionstatement %][% END %] [% IF ( editionresponsability ) %][% editionresponsability %][% END %]
+            [% publishercode | html %]
+        </a> [% IF ( place ) %]([% place | html %])[% END %] [% IF ( publicationyear ) %], [% publicationyear | html %][% END %] [% IF ( editionstatement ) %][% editionstatement | html %][% END %] [% IF ( editionresponsibility ) %][% editionresponsibility | html %][% END %]
     </li>
     [% END %]
         <li><strong>Description:</strong>
-                [% IF ( pages ) %] [% END %][% pages %] [% IF ( illus ) %][% illus %][% END %]
-                [% IF ( size ) %][% size %][% END %]
+                [% IF ( pages ) %] [% END %][% pages | html %] [% IF ( illus ) %][% illus | html %][% END %]
+                [% IF ( size ) %][% size | html %][% END %]
         </li>
 [% IF ( MARCURLS ) %]<li>
     
     <strong>Online resources:</strong>
     <ul>    [% FOREACH MARCurl IN MARCURLS %]
-               <li>[% IF ( MARCurl.part ) %][% MARCurl.part %]
+               <li>[% IF ( MARCurl.part ) %][% MARCurl.part | html %]
                        <br />[% END %] 
                <!-- here you might do a tmpl_if name="toc" and use greybox or equivalent for table of contents -->
-               <a href="[% MARCurl.MARCURL %]" title="[% MARCurl.MARCURL %]">[% MARCurl.linktext %]</a>
-                       [% IF ( MARCurl.notes ) %]<ul>[% FOREACH note IN MARCurl.notes %]<li>[% note.note %]</li>[% END %]</ul>[% END %]</li>
+        <a href="[% MARCurl.MARCURL | url %]" title="[% MARCurl.MARCURL | html %]">[% MARCurl.linktext | html %]</a>
+                       [% IF ( MARCurl.notes ) %]<ul>[% FOREACH note IN MARCurl.notes %]<li>[% note.note | html %]</li>[% END %]</ul>[% END %]</li>
             [% END %]</ul>
 </li>
     [% END %]
 
     [% IF ( OPACBaseURL ) %]
         <li><strong>OPAC view:</strong>
-        <a href="[% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]" target="_blank">Open in new window</a>
+        <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber | uri %]" target="_blank">Open in new window</a>
         </li>
     [% END %]
         <li id="catalogue_detail_marc_preview">
             <strong>MARC Preview:</strong>
-            <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Show</a>
+            <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblionumber | uri %]" title="MARC" rel="gb_page_center[600,500]">Show</a>
         </li>
         </ul>
         </div>
@@ -485,12 +214,12 @@ function verify_images() {
     [% IF ( AmazonCoverImages  || LocalCoverImages ) %]
         <div class="yui-u" id="bookcoverimg">
         [% IF ( LocalCoverImages ) %]
-            <div title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div>
+            <div title="[% biblionumber |url %]" class="[% biblionumber | html %]" id="local-thumbnail-preview"></div>
         [% END %]
         [% IF ( AmazonCoverImages ) %]
             <div id="amazon-bookcoverimg">
-            <a href="http://www.amazon[% AmazonTld %]/gp/reader/[% normalized_isbn %]/ref=sib_dp_pt/002-7879865-0184864#reader-link">
-            <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="" />
+            <a href="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link">
+            <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | html %].01.MZZZZZZZ.jpg" alt="" />
             </a>
         </div>
         [% END %]
@@ -500,43 +229,43 @@ function verify_images() {
         <div class="yui-u" style="margin-top: 1em;">
         <ul>
         [% IF ( MARCISBNS ) %]
-            <li><strong>ISBN:</strong><ul>[% FOREACH MARCISBN IN MARCISBNS %]<li>[% MARCISBN %]</li>[% END %]</ul></li>
+            <li><strong>ISBN:</strong><ul>[% FOREACH MARCISBN IN MARCISBNS %]<li>[% MARCISBN | html %]</li>[% END %]</ul></li>
         [% ELSE %]
             [% IF ( normalized_isbn ) %]
-                <li><strong>ISBN:</strong> [% normalized_isbn %]</li>
+                <li><strong>ISBN:</strong> [% normalized_isbn | html %]</li>
             [% END %]
         [% END %]
         [% IF ( issn ) %]
-            <li><strong>ISSN:</strong>[% issn %]</li>
+            <li><strong>ISSN:</strong>[% issn | html %]</li>
         [% END %]
         [% IF ( collectiontitle ) %]
             <li><strong>Collection: </strong>
-                [% collectiontitle %] [% IF ( collectionvolume ) %], [% collectionvolume %][% END %][% IF ( collectionissn ) %] (<strong>ISSN:</strong> [% collectionissn %])[% END %]
+                [% collectiontitle | html %] [% IF ( collectionvolume ) %], [% collectionvolume | html %][% END %][% IF ( collectionissn ) %] (<strong>ISSN:</strong> [% collectionissn | html %])[% END %]
             </li>
         [% END %]
         [% IF ( MARCSUBJCTS ) %]
             <li><strong>Subjects:</strong> 
             <ul>
                 [% FOREACH MARCSUBJCT IN MARCSUBJCTS %]
-                <li>[% FOREACH MARCSUBJECT_SUBFIELDS_LOO IN MARCSUBJCT.MARCSUBJECT_SUBFIELDS_LOOP %] [% MARCSUBJECT_SUBFIELDS_LOO.separator %] <a title="‡[% MARCSUBJECT_SUBFIELDS_LOO.code %] [% MARCSUBJECT_SUBFIELDS_LOO.value %]" href="/cgi-bin/koha/catalogue/search.pl?q=[% FOREACH link_loo IN MARCSUBJECT_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit %]:[% link_loo.link |url %][% END %]">[% MARCSUBJECT_SUBFIELDS_LOO.value |html %]</a>[% END %]</li>
+                <li>[% FOREACH MARCSUBJECT_SUBFIELDS_LOO IN MARCSUBJCT.MARCSUBJECT_SUBFIELDS_LOOP %] [% MARCSUBJECT_SUBFIELDS_LOO.separator | html %] <a title="‡[% MARCSUBJECT_SUBFIELDS_LOO.code | html %] [% MARCSUBJECT_SUBFIELDS_LOO.value | html %]" href="/cgi-bin/koha/catalogue/search.pl?q=[% FOREACH link_loo IN MARCSUBJECT_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit | html %]:[% link_loo.link |url %][% END %]">[% MARCSUBJECT_SUBFIELDS_LOO.value | html %]</a>[% END %]</li>
                 [% END %]
                 </ul>
             </li>
         [% END %]
         [% IF ( copyrightdate ) %]
-            <li><strong>Copyright:</strong> [% copyrightdate %]</li>
+            <li><strong>Copyright:</strong> [% copyrightdate | html %]</li>
         [% END %]
      
         [% IF ( classification ) %]
-            <li><strong>Classification:</strong> [% subclass %][% classification %]</li>
+            <li><strong>Classification:</strong> [% subclass | html %][% classification | html %]</li>
         [% END %]
         [% IF ( dewey ) %]
-            <li><strong>Dewey:</strong> [% dewey %]</li>
+            <li><strong>Dewey:</strong> [% dewey | html %]</li>
         [% END %]
         [% IF ( urlS ) %]
-            <li><strong>url:</strong> 
+            <li><strong>URL:</strong>
                 [% FOREACH url IN urlS %]
-                    <a href="[% url.url %]">[% url.url %]</a>
+                    <a href="[% url.url | url %]">[% url.url | html %]</a>
                 [% END %]
             </li>
         [% END %]
@@ -545,7 +274,7 @@ function verify_images() {
             <li><strong>Lists that include this title: </strong>
             <ul>
             [% FOREACH s IN shelves %]
-                <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber %]">[% s.shelfname %]</a></li>
+                <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber | uri %]">[% s.shelfname | html %]</a></li>
             [% END %]
             </ul>
             </li>
@@ -556,15 +285,15 @@ function verify_images() {
                     [% FOREACH TagLoo IN TagLoop %]
                         <li>
                         [% IF ( CAN_user_tools_moderate_tags ) %]
-                        <a href="/cgi-bin/koha/tags/list.pl?tag=[% TagLoo.term |url %]">[% TagLoo.term |html %]</a>
+                        <a href="/cgi-bin/koha/tags/list.pl?tag=[% TagLoo.term |url %]">[% TagLoo.term | html %]</a>
                         [% ELSE %]
-                        [% TagLoo.term |html %]
+                        [% TagLoo.term | html %]
                         [% END %]
-                        <span class="weight">([% TagLoo.weight_total %])</span>[% IF ( loop.last ) %][% ELSE %], [% END %]</li>
+                        <span class="weight">([% TagLoo.weight_total | html %])</span>[% IF ( loop.last ) %][% ELSE %], [% END %]</li>
                     [% END %]
                     </ul></li>
         [% END %]
-            [% IF ( holdcount ) %]<li><strong>Holds:</strong> <span class="holdcount"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber %]">[% holdcount %]</a></span></li>[% ELSE %][% END %]
+            [% IF ( holdcount ) %]<li><strong>Holds:</strong> <span class="number_box"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber | uri %]">[% holdcount | html %]</a></span></li>[% ELSE %][% END %]
         </ul>
                [% END %]
 
@@ -574,18 +303,30 @@ function verify_images() {
 
 <ul>
     [% IF (SeparateHoldings) %]
-        <li><a href="#holdings">[% LoginBranchname %] holdings</a></li>
-        <li><a href="#otherholdings">Other holdings</a></li>
+        <li>
+            <a href="#holdings">[% LoginBranchname | html %] holdings ([% itemloop.size() || 0 | html %])</a>
+        </li>
+        <li>
+            <a href="#otherholdings">Other holdings ([% otheritemloop.size() || 0 | html %])</a>
+        </li>
     [% ELSE %]
-        <li><a href="#holdings">Holdings</a></li>
+        <li>
+            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
+        </li>
     [% END %]
 [% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions</a></li>[% END %]
 [% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
 [% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
 [% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]<li><a href="#editions">Editions</a></li>[% END %][% END %]
-[% IF ( LocalCoverImages ) %][% IF ( localimages || CAN_user_tools_upload_local_cover_images ) %]<li><a href="#images">Images</a></li>[% END %][% END %]
+[% IF ( LocalCoverImages ) %]
+    [% IF ( localimages || CAN_user_tools_upload_local_cover_images ) %]
+        <li>
+            <a href="#images">Images ([% localimages.size() || 0 | html %])</a>
+        </li>
+    [% END %]
+[% END %]
 [% IF ( HTML5MediaEnabled ) %][% IF ( HTML5MediaSets ) %]<li><a href="#html5media">Play media</a></li>[% END %][% END %]
-[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
+[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
     <li class="NovelistSelect" style="display:none;"><a href="#NovelistSelect">NoveList Select</a></li>
 [% END %]
 </ul>
@@ -593,10 +334,10 @@ function verify_images() {
 [% items_table_block_iter = 0 %]
 [% BLOCK items_table %]
     [% items_table_block_iter = items_table_block_iter + 1 %]
-    <div class="[% tab %]_table_controls">
+    <div class="[% tab | html %]_table_table_controls">
         [% IF (StaffDetailItemSelection) %]
-            | <a href="#" class="SelectAll" data-tab="[% tab %]"><i class="fa fa-check"></i> Select all</a> |
-            <a href="#" class="ClearAll" data-tab="[% tab %]"><i class="fa fa-remove"></i> Clear all</a>
+            | <a href="#" class="SelectAll" data-tab="[% tab | html %]"><i class="fa fa-check"></i> Select all</a> |
+            <a href="#" class="ClearAll" data-tab="[% tab | html %]"><i class="fa fa-remove"></i> Clear all</a>
             <span class="itemselection_actions">
               | Actions:
               [% IF CAN_user_tools_items_batchdel %]
@@ -608,7 +349,7 @@ function verify_images() {
             </span>
         [% END %]
     </div>
-    <table class="items_table">
+    <table class="items_table" id="[% tab | html %]_table">
         <thead>
             <tr>
                 [% IF (StaffDetailItemSelection) %]<th class="NoSort"></th>[% END %]
@@ -617,11 +358,12 @@ function verify_images() {
                 <th>Home library</th>
                 [% IF ( itemdata_ccode ) %]<th>Collection</th>[% END %]
                 <th>Call number</th>
+                [% IF ( volinfo ) %]<th>Serial enumeration / chronology</th>[% END %]
                 <th>Status</th>
-                <th>Last seen</th>
+                <th class="title-string">Last seen</th>
+                <th class="title-string">Date accessioned</th>
                 <th>Barcode</th>
-                [% IF ( volinfo ) %]<th>Serial enumeration / chronology</th>[% END %]
-                [% IF ( itemdata_uri ) %]<th>url</th>[% END %]
+                [% IF ( itemdata_uri ) %]<th>URL</th>[% END %]
                 [% IF ( itemdata_copynumber ) %]<th>Copy number</th>[% END %]
                 [% IF ( itemdata_stocknumber ) %]<th>Inventory number</th>[% END %]
                 [% IF materials %]<th>Materials specified</th>[% END %]
@@ -639,24 +381,44 @@ function verify_images() {
                 <tr>
                 [% IF (StaffDetailItemSelection) %]
                     <td style="text-align:center;vertical-align:middle">
-                        <input type="checkbox" value="[% item.itemnumber %]" name="itemnumber" />
+                        <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
                     </td>
                 [% END %]
                     [% IF ( item_level_itypes ) %]
                         <td class="itype">
                             [% IF !noItemTypeImages && item.imageurl %]
-                                <img src="[% item.imageurl %]" alt="[% item.translated_description %]" title="[% item.translated_description %]" />
+                                <img src="[% item.imageurl | html %]" alt="[% item.translated_description | html %]" title="[% item.translated_description | html %]" />
+                            [% END %]
+                            [% item.translated_description | html %]
+                        </td>
+                    [% END %]
+                    <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.branchcode ) | html %] [% END %]</td>
+                    <td class="homebranch">[% Branches.GetName(item.homebranch) | html %]<span class="shelvingloc">[% item.location | html %]</span> </td>
+                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode | html %]</td>[% END %]
+                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber | html %][% END %]</td>
+                    [% IF ( volinfo ) %]
+                        <td class="enumchron">
+                            [% IF ( itemdata_enumchron ) %]
+                                [% IF item.enumchron && item.serialseq %]
+                                    <span class="enum">[% item.enumchron | html %]</span>
+                                    [% IF ( item.serialseq && item.enumchron!=item.serialseq ) %]
+                                        <span class="sep"> -- </span>
+                                        <span class="serialseq">[% item.serialseq | html %]</span>
+                                    [% END %]
+                                [% ELSIF item.enumchron %]
+                                    <span class="enum">[% item.enumchron | html %]</span>
+                                [% ELSIF item.serialseq %]
+                                    <span class="serialseq">[% item.serialseq | html %]</span>
+                                [% END %]
+                                [% IF ( item.publisheddate ) %]
+                                    <span class="pubdate">([% item.publisheddate | $KohaDates %])</span>
+                                [% END %]
                             [% END %]
-                            [% item.translated_description %]
                         </td>
                     [% END %]
-                    <td class="location">[% UNLESS ( singlebranchmode ) %][% Branches.GetName( item.branchcode ) %] [% END %]</td>
-                    <td class="homebranch">[% Branches.GetName(item.homebranch) %]<span class="shelvingloc">[% item.location %]</span> </td>
-                    [% IF ( itemdata_ccode ) %]<td>[% item.ccode %]</td>[% END %]
-                    <td class="itemcallnumber">[% IF ( item.itemcallnumber ) %] [% item.itemcallnumber %][% END %]</td>
                     <td class="status">
 
-                        [% IF ( item.datedue ) %]
+                        [% IF item.CheckedOutFor %]
                           [% IF item.onsite_checkout %]
                             <span>Currently in local use
                           [% ELSE %]
@@ -664,28 +426,23 @@ function verify_images() {
                           [% END %]
                                 [% UNLESS ( item.NOTSAMEBRANCH ) %]
                                   [% IF item.onsite_checkout %]
-                                    by <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% item.borrowernumber %]">
+                                    by
                                   [% ELSE %]
-                                    to <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% item.borrowernumber %]">
+                                    to
                                   [% END %]
-                                        [% IF ( item.hidepatronname ) %]
-                                            [% item.cardnumber %]
-                                        [% ELSE %]
-                                            [% item.firstname %] [% item.surname %]
-                                        [% END %]
-                                    </a>
+                                  [% INCLUDE 'patron-title.inc' patron=item.CheckedOutFor hide_patron_infos_if_needed=1 %]
                                 [% END %]
-                                : due [% item.datedue %]
+                                : due [% item.datedue | html %]
                             </span>
                         [% ELSIF ( item.transfertwhen ) %]
-                            <span class="intransit">In transit from [% Branches.GetName( item.transfertfrom ) %] to [% Branches.GetName( item.transfertto ) %] since [% item.transfertwhen | $KohaDates %]</span>
+                            <span class="intransit">In transit from [% Branches.GetName( item.transfertfrom ) | html %] to [% Branches.GetName( item.transfertto ) | html %] since [% item.transfertwhen | $KohaDates %]</span>
                         [% END %]
 
                         [% IF ( item.itemlost ) %]
                             [% IF itemlostloop %]
                                 [% FOREACH itemlostloo IN itemlostloop %]
                                     [% IF itemlostloo.authorised_value == item.itemlost %]
-                                        <span class="lost">[% itemlostloo.lib %]</span>
+                                        <span class="lost">[% itemlostloo.lib | html %]</span>
                                     [% END %]
                                 [% END %]
                             [% ELSE %]
@@ -694,14 +451,22 @@ function verify_images() {
                         [% END %]
 
                         [% IF ( item.withdrawn ) %]
-                            <span class="wdn">Withdrawn</span>
+                            [% IF itemwithdrawnloop %]
+                                [% FOREACH itemwithdrawnloo IN itemwithdrawnloop %]
+                                    [% IF itemwithdrawnloo.authorised_value == item.withdrawn %]
+                                        <span class="wdn">[% itemwithdrawnloo.lib | html %]</span>
+                                    [% END %]
+                                [% END %]
+                            [% ELSE %]
+                                <span class="wdn">Withdrawn</span>
+                            [% END %]
                         [% END %]
 
                         [% IF ( item.damaged ) %]
                             [% IF itemdamagedloop %]
                                 [% FOREACH itemdamagedloo IN itemdamagedloop %]
                                     [% IF itemdamagedloo.authorised_value == item.damaged %]
-                                        <span class="dmg">[% itemdamagedloo.lib %]</span>
+                                        <span class="dmg">[% itemdamagedloo.lib | html %]</span>
                                     [% END %]
                                 [% END %]
                             [% ELSE %]
@@ -712,24 +477,19 @@ function verify_images() {
                         [% IF ( item.itemnotforloan || item.notforloan_per_itemtype ) %]
                             Not for loan
                             [% IF ( item.notforloanvalue ) %]
-                                ([% item.notforloanvalue %])
+                                ([% item.notforloanvalue | html %])
                             [% END %]
                         [% END %]
 
                         [% IF ( item.reservedate ) %]
                             [% IF ( item.waitingdate ) %]
-                                Waiting at [% Branches.GetName( item.ExpectedAtLibrary ) %] since [% item.waitingdate | $KohaDates %].
+                                Waiting at [% Branches.GetName( item.ExpectedAtLibrary ) | html %] since [% item.waitingdate | $KohaDates %].
                             [% ELSE %]
-                                Item-level hold (placed [% item.reservedate | $KohaDates %]) for delivery at [% Branches.GetName( item.ExpectedAtLibrary ) %].
+                                Item-level hold (placed [% item.reservedate | $KohaDates %]) for delivery at [% Branches.GetName( item.ExpectedAtLibrary ) | html %].
                             [% END %]
                             [% IF ( canreservefromotherbranches ) %]
-                                Hold for: <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% item.ReservedForBorrowernumber %]">
-                                    [% IF ( item.hidepatronname ) %]
-                                        [% item.Reservedcardnumber %]
-                                    [% ELSE %]
-                                        [% item.ReservedForFirstname _ " " _ item.ReservedForSurname _ " (" _ item.Reservedcardnumber _ ")" %]
-                                    [% END %]
-                                </a>
+                                Hold for:
+                                [% INCLUDE 'patron-title.inc' patron=item.ReservedFor hide_patron_infos_if_needed=1 %]
                             [% END %]
                         [% END %]
                         [% UNLESS ( item.itemnotforloan || item.notforloan_per_itemtype || item.onloan || item.itemlost || item.withdrawn || item.damaged || item.transfertwhen || item.reservedate ) %]
@@ -737,65 +497,46 @@ function verify_images() {
                         [% END %]
 
                         [% IF ( item.restricted ) %]
-                            <span class="restricted">([% item.restricted %])</span>
+                            <span class="restricted">([% item.restricted | html %])</span>
                         [% END %]
 
                     </td>
-                    <td class="datelastseen">[% item.datelastseen | $KohaDates %]</td>
-                    <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?type=[% item.type %]&amp;itemnumber=[% item.itemnumber %]&amp;biblionumber=[% item.biblionumber %]&amp;bi=[% item.biblioitemnumber %]#item[% item.itemnumber %]">[% item.barcode %]</a></td>
-                    [% IF ( volinfo ) %]
-                        <td class="enumchron">
-                            [% IF ( itemdata_enumchron ) %]
-                                [% IF item.enumchron && item.serialseq %]
-                                    <span class="enum">[% item.enumchron %]</span>
-                                    [% IF ( item.serialseq && item.enumchron!=item.serialseq ) %]
-                                        <span class="sep"> -- </span>
-                                        <span class="serialseq">[% item.serialseq %]</span>
-                                    [% END %]
-                                [% ELSIF item.enumchron %]
-                                    <span class="enum">[% item.enumchron %]</span>
-                                [% ELSIF item.serialseq %]
-                                    <span class="serialseq">[% item.serialseq %]</span>
-                                [% END %]
-                                [% IF ( item.publisheddate ) %]
-                                    <span class="pubdate">([% item.publisheddate | $KohaDates %])</span>
-                                [% END %]
-                            [% END %]
-                        </td>
-                    [% END %]
+                    <td class="datelastseen"><span title="[% item.datelastseen | html %]">[% item.datelastseen | $KohaDates %]</span></td>
+                    <td class="dateaccessioned"><span title="[% item.dateaccessioned | html %]">[% item.dateaccessioned | $KohaDates %]</span></td>
+                    <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?type=[% item.type | uri %]&amp;itemnumber=[% item.itemnumber | uri %]&amp;biblionumber=[% item.biblionumber | uri %]&amp;bi=[% item.biblioitemnumber | uri %]#item[% item.itemnumber | uri %]">[% item.barcode | html %]</a></td>
                     [% IF ( itemdata_uri ) %]
-                        <td class="uri"><a href="[% item.uri %]">[% item.uri %]</a></td>
+                        <td class="uri"><a href="[% item.uri | url %]">[% item.uri | html %]</a></td>
                     [% END %]
                     [% IF ( itemdata_copynumber ) %]
-                        <td class="copynumber">[% item.copynumber %]</td>
+                        <td class="copynumber">[% item.copynumber | html %]</td>
                     [% END %]
                     [% IF ( itemdata_stocknumber ) %]
-                        <td class="stocknumber">[% item.stocknumber %]</td>
+                        <td class="stocknumber">[% item.stocknumber | html %]</td>
                     [% END %]
                     [% IF materials %]
-                        <td class="materials"> [% item.materials %] </td>
+                        <td class="materials"> [% item.materials | html %] </td>
                     [% END %]
                     [% IF ( itemdata_itemnotes ) %]
-                        <td><div class="itemnotes">[% item.itemnotes %]</div></td>
+                        <td><div class="itemnotes">[% item.itemnotes | html %]</div></td>
                     [% END %]
                     [% IF itemdata_nonpublicnotes %]
-                        <td class="nonpublicnote">[% item.itemnotes_nonpublic %]</td>
+                        <td class="nonpublicnote">[% item.itemnotes_nonpublic | html %]</td>
                     [% END %]
                     [% IF ( SpineLabelShowPrintOnBibDetails ) %]
-                        <td><a href="/cgi-bin/koha/labels/spinelabel-print.pl?barcode=[% item.barcode %]" >Print label</a></td>
+                        <td><a href="/cgi-bin/koha/labels/spinelabel-print.pl?barcode=[% item.barcode | uri %]" >Print label</a></td>
                     [% END %]
                     [% IF ( hostrecords ) %]
-                        <td>[% IF ( item.hostbiblionumber) %]<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item.hostbiblionumber %]" >[% item.hosttitle %]</a>[% END %]</td>
+                        <td>[% IF ( item.hostbiblionumber) %]<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item.hostbiblionumber | uri %]" >[% item.hosttitle | html %]</a>[% END %]</td>
                     [% END %]
                     [% IF ( analyze ) %]
                         <td>
                             [% IF ( item.countanalytics ) %]
-                                <a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&amp;q=[% item.itemnumber %]">[% item.countanalytics %] analytics</a>
+                                <a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&amp;q=[% item.itemnumber | uri %]">[% item.countanalytics | html %] analytics</a>
                             [% END %]
                         </td>
                     [% END %]
                     [% IF ( analyze ) %]
-                        <td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% item.biblionumber %]&amp;hostitemnumber=[% item.itemnumber %]">Create analytics</a></td>
+                        <td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% item.biblionumber | uri %]&amp;hostitemnumber=[% item.itemnumber | uri %]">Create analytics</a></td>
                     [% END %]
 
                 [% IF ShowCourseReserves %]
@@ -804,11 +545,11 @@ function verify_images() {
                             [% FOREACH r IN item.course_reserves %]
                                 [% IF r.course.enabled == 'yes' %]
                                     <p>
-                                      <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% r.course.course_id %]">
-                                         [% r.course.course_name %]
-                                         <!--[% IF r.course.course_number %] [% r.course.course_number %] [% END %]-->
-                                         [% IF r.course.section %] [% r.course.section %] [% END %]
-                                         [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) %] [% END %]
+                                      <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% r.course.course_id | uri %]">
+                                         [% r.course.course_name | html %]
+                                         <!--[% IF r.course.course_number %] [% r.course.course_number | html %] [% END %]-->
+                                         [% IF r.course.section %] [% r.course.section | html %] [% END %]
+                                         [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) | html %] [% END %]
                                       </a>
                                    </p>
                                [% END %]
@@ -819,7 +560,7 @@ function verify_images() {
                 [% IF CAN_user_editcatalogue_edit_items %]
                     <td class="actions">
                         [% UNLESS item.cannot_be_edited %]
-                            <a class="btn btn-mini" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber %]&itemnumber=[% item.itemnumber %]#edititem"><i class="fa fa-pencil"></i> Edit</a>
+                            <a class="btn btn-default btn-xs" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber | html %]&itemnumber=[% item.itemnumber | html %]#edititem"><i class="fa fa-pencil"></i> Edit</a>
                         [% END %]
                     </td>
                 [% END %]
@@ -831,10 +572,10 @@ function verify_images() {
 
 <div id="holdings">
 
-[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
+[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
     <span class="results_summary NovelistSelect" style="display:none;">
         <span class="label">Novelist Select: </span>
-        <div data-novelist-novelistselect=[% normalized_isbn %]></div>
+        <div data-novelist-novelistselect=[% normalized_isbn | html %]></div>
     </span>
 [% END %]
 
@@ -843,30 +584,30 @@ function verify_images() {
         [% PROCESS items_table tab="holdings" items=itemloop %]
         [% END %]
                 [% IF ( hiddencount ) %]
-                   <p><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]&amp;showallitems=1">Show all items ([% hiddencount %] hidden)</a>
+                   <p><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]&amp;showallitems=1">Show all items ([% hiddencount | html %] hidden)</a>
                 [% END %]              
                [% IF ( debug_display ) %]
                <br /><br />
                <table>
-                       <tr><td>itemdata_enumchron</td><td>[% itemdata_enumchron %]</td></tr>
-                       <tr><td>itemdata_copynumber</td><td>[% itemdata_copynumber %]</td></tr>
-                       <tr><td>serial</td><td>[% serial %]</td></tr>
+                       <tr><td>itemdata_enumchron</td><td>[% itemdata_enumchron | html %]</td></tr>
+                       <tr><td>itemdata_copynumber</td><td>[% itemdata_copynumber | html %]</td></tr>
+                       <tr><td>serial</td><td>[% serial | html %]</td></tr>
                </table>
                 [% END %]
 [% ELSE %]
     [% IF ( ALTERNATEHOLDINGS ) %]
     [% FOREACH ALTERNATEHOLDING IN ALTERNATEHOLDINGS %]
-        <div id="alternateholdings"><span class="holdings_label">Holdings:</span> [% ALTERNATEHOLDING.holding %]</div>
+        <div id="alternateholdings"><span class="holdings_label">Holdings:</span> [% ALTERNATEHOLDING.holding | html %]</div>
     [% END %]
     [% ELSE %]
     <div id="noitems">No physical items for this record</div>
     [% END %]
 [% END %]
 
-[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectProfile') && Koha.Preference('NovelistSelectStaffView') == 'below' ) %]
+[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'below' ) %]
     <span class="results_summary NovelistSelect" style="display:none;">
         <span class="label">Novelist Select: </span>
-        <div data-novelist-novelistselect=[% normalized_isbn %]></div>
+        <div data-novelist-novelistselect=[% normalized_isbn | html %]></div>
     </span>
 [% END %]
     </div>
@@ -890,15 +631,15 @@ function verify_images() {
     [% FOREACH MARCNOTE IN MARCNOTES %]
         <p>
         [% IF MARCNOTE.marcnote.match('^https?://\S+$') %]
-            <a href="[% MARCNOTE.marcnote %]">[% MARCNOTE.marcnote %]</a>
+            <a href="[% MARCNOTE.marcnote | url %]">[% MARCNOTE.marcnote | html %]</a>
         [% ELSE %]
-            [% MARCNOTE.marcnote FILTER html_line_break %]
+            [% MARCNOTE.marcnote FILTER html_line_break | html %]
         [% END %]
         </p>
     [% END %]
 [% ELSE %]
     [% IF ( notes ) %]
-        <p>[% notes %]</p>
+        <p>[% notes | html %]</p>
     [% END %]
 [% END %]
 </div>
@@ -911,18 +652,18 @@ function verify_images() {
 <div class="yui-g">
 <div id="catalogue_detail_subscriptions">
     <h2>This is a serial subscription</h2>
-    <p> (There are [% subscriptionsnumber %] subscriptions associated with this title).</p> 
+    <p> (There are [% subscriptionsnumber | html %] subscriptions associated with this title).</p> 
     [% FOREACH subscription IN subscriptions %]
             [% IF subscription.branchcode %]
-                <h3>At library: [% Branches.GetName(subscription.branchcode) || subscription.branchcode %]</h3>
+                <h3>At library: [% Branches.GetName(subscription.branchcode) || subscription.branchcode | html %]</h3>
             [% END %]
             [% IF ( subscription.closed ) %]<p>This subscription is closed.</p>[% END %]
-            [% IF ( subscription.callnumber ) %]<p>Callnumber: [% subscription.callnumber %] </p>[% END %]
-            [% IF ( subscription.subscriptionnotes ) %]<p>[% subscription.subscriptionnotes FILTER html_line_break %] </p>[% END %]
-            [% IF ( subscription.missinglist ) %]<p>Missing issues: [% subscription.missinglist %] </p>[% END %]
-            [% IF ( subscription.librariannote ) %]<p>([% subscription.librariannote %])</p>[% END %]
+            [% IF ( subscription.callnumber ) %]<p>Callnumber: [% subscription.callnumber | html %] </p>[% END %]
+            [% IF ( subscription.subscriptionnotes ) %]<p>[% subscription.subscriptionnotes FILTER html_line_break | html %] </p>[% END %]
+            [% IF ( subscription.missinglist ) %]<p>Missing issues: [% subscription.missinglist | html %] </p>[% END %]
+            [% IF ( subscription.librariannote ) %]<p>([% subscription.librariannote | html %])</p>[% END %]
             [% IF ( subscription.latestserials ) %]
-            <p> The [% subscription.staffdisplaycount %] latest issues related to this subscription:</p>
+            <p> The [% subscription.staffdisplaycount | html %] latest issues related to this subscription:</p>
             <table>
                 <tr>
                     <th>Issue #</th>
@@ -933,9 +674,9 @@ function verify_images() {
                 </tr>
             [% FOREACH latestserial IN subscription.latestserials %]
                 <tr>
-                    <td>[% latestserial.serialseq %]</td>
-                    <td>[% latestserial.planneddate %]</td>
-                    <td>[% latestserial.publisheddate%]</td>
+                    <td>[% latestserial.serialseq | html %]</td>
+                    <td>[% latestserial.planneddate | html %]</td>
+                    <td>[% latestserial.publisheddate | html %]</td>
                     <td>
                       [% IF ( latestserial.status1 ) %]Expected[% END %]
                       [% IF ( latestserial.status2 ) %]Arrived[% END %]
@@ -950,12 +691,12 @@ function verify_images() {
                       [% IF ( latestserial.status7 ) %]Claimed[% END %]
                       [% IF ( latestserial.status8 ) %]Stopped[% END %]
                     </td>
-                    <td>[% latestserial.notes %]</td>
+                    <td>[% latestserial.notes | html %]</td>
                 </tr>
             [% END %]
             </table>
             [% END %]
-            <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid %]">Subscription details</a>
+            <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid | uri %]">Subscription details</a>
     [% END %]
 </div>
 </div>
@@ -969,6 +710,7 @@ function verify_images() {
       <thead>
         <tr>
           <th>Vendor</th>
+          <th>Invoice</th>
           <th>Basket group</th>
           <th>Basket</th>
           <th>Order number</th>
@@ -976,33 +718,47 @@ function verify_images() {
           <th class="title-string">Receive date</th>
           <th>Status</th>
           <th>Quantity</th>
+          <th>Subscription</th>
+          <th>Subscription callnumber</th>
         </tr>
       </thead>
       <tbody>
       [% FOR order IN orders %]
+        [% SET basket = order.basket %]
+        [% SET vendor = basket.bookseller %]
           <tr>
             <td>
-            [% IF (order.id) %]
-                <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.id %]" title="Vendor detail page">[% order.name %]</a>
+                <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% vendor.id | uri %]" title="Vendor detail page">[% vendor.name | html %]</a>
+            </td>
+            <td>
+            [% IF order.invoiceid %]
+                [% IF CAN_user_acquisition %]
+                    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% order.invoiceid | uri %]"
+                       title="Invoice detail page">
+                       [% order.invoice.invoicenumber | html %]</a>
+                [% ELSE %]
+                    [% order.invoice.invoicenumber | html %]
+                [% END %]
             [% END %]
             </td>
             <td>
-            [% IF (order.basketgroupid) %]
+            [% IF basket.basketgroupid %]
+                [% SET basket_group = basket.basket_group %]
                 [% IF CAN_user_acquisition_group_manage %]
-                    <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% order.id %]&basketgroupid=[% order.basketgroupid %]">[% order.groupname %] ([% order.basketgroupid %])</a>
+                    <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>
                 [% ELSE %]
-                    [% order.groupname %] ([% order.basketgroupid %])
+                    [% basket_group.name | html %] ([% basket_group.id | html %])
                 [% END %]
             [% END %]
             </td>
             <td>[% IF CAN_user_acquisition_order_manage %]
-                <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% order.basketno %]">[% order.basketname %] ([% order.basketno %])</a>
+                <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | uri %]">[% basket.basketname | html %] ([% basket.basketno | html %])</a>
             [% ELSE %]
-                [% order.basketname %] ([% order.basketno %])
+                [% basket.basketname | html %] ([% basket.basketno | html %])
             [% END %]</td>
-            <td>[% order.ordernumber %]</td>
-            <td><span title="[% order.creationdate %]">[% order.creationdate | $KohaDates%]</span></td>
-            <td><span title="[% order.datereceived %]">[% order.datereceived | $KohaDates%]</span></td>
+            <td>[% order.ordernumber | html %]</td>
+            <td><span title="[% basket.creationdate | uri %]">[% basket.creationdate | $KohaDates%]</span></td>
+            <td><span title="[% order.datereceived | uri %]">[% order.datereceived | $KohaDates%]</span></td>
             <td>
               [% SWITCH order.orderstatus %]
                 [% CASE 'new' %]New
@@ -1012,7 +768,17 @@ function verify_images() {
                 [% CASE 'cancelled' %]Cancelled
               [% END %]
             </td>
-            <td>[% order.quantity %]</td>
+            <td>[% order.quantity | html %]</td>
+            <td>
+                [% IF order.subscriptionid %]
+                    <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% order.subscriptionid | uri %]">[% order.subscriptionid | html %]</a>
+                [% END %]
+            </td>
+            <td>
+                [% IF order.subscriptionid %]
+                    [% order.subscription.callnumber | html %]
+                [% END %]
+            </td>
           </tr>
       [% END %]
       </tbody>
@@ -1026,14 +792,14 @@ function verify_images() {
 [% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]
 <div id="editions"><h4>Editions</h4>
 <table>
-[% FOREACH XISBN IN XISBNS %]<tr>[% IF ( AmazonCoverImages ) %]<td><a href="http://www.amazon.com/gp/reader/[% XISBN.normalized_isbn %]/ref=sib_dp_pt/002-7879865-0184864#reader-link"><img src="https://images-na.ssl-images-amazon.com/images/P/[% XISBN.normalized_isbn %].01._AA75_PU_PU-5_.jpg" /></a></td>[% END %]
-[% UNLESS ( item_level_itypes ) %]<td>[% IF ( noItemTypeImages ) %][% XISBN.description %][% ELSE %]<img src="[% XISBN.imageurl %]" alt="[% XISBN.description %]" title="[% XISBN.description %]">[% END %]</td>[% END %]
-<td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% XISBN.biblionumber %]">[% XISBN.title |html %]</a> by [% XISBN.author | html %] &copy;[% XISBN.copyrightdate %]
+[% 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 %]
+[% UNLESS ( item_level_itypes ) %]<td>[% IF ( noItemTypeImages ) %][% XISBN.description | html %][% ELSE %]<img src="[% XISBN.imageurl | html %]" alt="[% XISBN.description | html %]" title="[% XISBN.description | html %]">[% END %]</td>[% END %]
+<td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% XISBN.biblionumber | uri %]">[% XISBN.title | html %]</a> by [% XISBN.author | html %] &copy;[% XISBN.copyrightdate | html %]
   [% IF ( XISBN.publishercode ) %]
-[% XISBN.publishercode %] [% IF ( XISBN.place ) %]([% XISBN.place %])[% END %] [% IF ( XISBN.publicationyear ) %], [% XISBN.publicationyear %][% END %] [% IF ( XISBN.editionstatement ) %][% XISBN.editionstatement %][% END %] [% IF ( XISBN.editionresponsability ) %][% XISBN.editionresponsability %][% END %]
+[% 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 %]
     [% END %]
-                [% IF ( XISBN.pages ) %] [% END %][% XISBN.pages %] [% IF ( XISBN.illus ) %][% XISBN.illus %][% END %]
-                [% IF ( XISBN.size ) %], [% END %][% XISBN.size %]
+                [% IF ( XISBN.pages ) %] [% END %][% XISBN.pages | html %] [% IF ( XISBN.illus ) %][% XISBN.illus | html %][% END %]
+                [% IF ( XISBN.size ) %], [% END %][% XISBN.size | html %]
 </td>
 
 [% END %]
@@ -1047,9 +813,9 @@ function verify_images() {
     <ul class="thumbnails">
 [% FOREACH image IN localimages %]
     [% IF image %]
-        <li id="imagenumber-[% image %]">
-            <a class="thumbnail" href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber %]&amp;imagenumber=[% image %]">
-                <img alt="remove this image" src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;imagenumber=[% image %]" />
+        <li id="imagenumber-[% image | html %]">
+            <a class="thumbnail" href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber | html %]&amp;imagenumber=[% image | html %]">
+                <img alt="remove this image" src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;imagenumber=[% image | html %]" />
                 [% IF CAN_user_tools_upload_local_cover_images %]
                   <span class="remove" title="remove this image">Delete image</span>
                 [% END %]
@@ -1067,19 +833,19 @@ function verify_images() {
 <div id="html5media">
           [% FOREACH HTML5MediaSet IN HTML5MediaSets %]
             <p>
-              <[% HTML5MediaParent %] controls preload=none>
-                <[% HTML5MediaSet.child  %] src="[% HTML5MediaSet.srcblock %]"[% HTML5MediaSet.typeblock %] />
-                [[% HTML5MediaParent %] tag not supported by your browser.]
-              </[% HTML5MediaParent %]>
+              <[% HTML5MediaParent | html %] controls preload=none>
+                <[% HTML5MediaSet.child | html %] src="[% HTML5MediaSet.srcblock | html %]"[% HTML5MediaSet.typeblock | html %] />
+                [[% HTML5MediaParent | html %] tag not supported by your browser.]
+              </[% HTML5MediaParent | html %]>
             </p>
           [% END %]
 </div>
 [% END %]
 
 
-[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
+[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
     <div id="NovelistSelect" class="novelistSelect">
-        <div data-novelist-novelistselect=[% normalized_isbn %]></div>
+        <div data-novelist-novelistselect=[% normalized_isbn | html %]></div>
     </div>
 [% END %]
 
@@ -1098,22 +864,26 @@ function verify_images() {
         <input type="submit" name="save" value="Download Record" /></td>
   </tr>
   <tr><td>
-    <input type="hidden" name="op" value="export" /><input type="hidden" name="bib" value="[% biblionumber %]" />
+    <input type="hidden" name="op" value="export" /><input type="hidden" name="bib" value="[% biblionumber | html %]" />
   </td></tr>
 </table>
 </form>
 </div>
 
-<div id="marcPreview" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
+<div id="marcPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
+    <div class="modal-dialog modal-lg">
+    <div class="modal-content">
     <div class="modal-header">
         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
         <h3 id="marcPreviewLabel">MARC preview</h3>
     </div>
     <div class="modal-body">
-        <div id="loading"> <img src="[% interface %]/[% theme %]/img/loading-small.gif" alt="" /> Loading </div>
+        <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
     </div>
     <div class="modal-footer">
-        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
+        <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
+    </div>
+    </div>
     </div>
 </div>
 
@@ -1125,4 +895,239 @@ function verify_images() {
 [% END %]
 </div>
 
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'catalog-strings.inc' %]
+    [% Asset.js("js/catalog.js") | $raw %]
+    [% INCLUDE 'greybox.inc' %]
+    <script type="text/javascript">
+        // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
+        function verify_images() {
+            $("#bookcoverimg").each(function(i){
+                $(this).find('img').each(function(i){
+                   if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0) || (this.src.indexOf('images-na.ssl-images-amazon.com'))) {
+                        w = this.width;
+                        h = this.height;
+                        if ((w == 1) || (h == 1)) {
+                            $("#amazon-bookcoverimg").remove();
+                            $(".yui-gb").attr("class","yui-g");
+                        } else if ((this.complete != null) && (!this.complete)) {
+                            $("#amazon-bookcoverimg").remove();
+                            $(".yui-gb").attr("class","yui-g");
+                        }
+                    }
+                });
+                if( $(this).find('img').length < 1 ) $(this).remove();
+            });
+            $("#editions img").each(function(i){
+                if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0) || (this.src.indexOf('images-na.ssl-images-amazon.com'))) {
+                    w = this.width;
+                    h = this.height;
+                    if ((w == 1) || (h == 1)) {
+                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
+                    } else if ((this.complete != null) && (!this.complete)) {
+                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
+                    }
+                }
+            });
+        }
+
+        function removeLocalImage(imagenumber) {
+            $.ajax({
+                url: "/cgi-bin/koha/svc/cover_images?action=delete&biblionumber=" + biblionumber + "&imagenumber=" + imagenumber,
+                success: function(data) {
+                    $(data).each( function(i) {
+                        if ( this.deleted == 1 ) {
+                            $('#imagenumber-' + this.imagenumber).remove();
+                        }
+                        if ( $('ul.thumbnails > li').length == 0 ) {
+                            showNoImageMessage();
+                        }
+                    });
+                },
+                error: function(data) {
+                    alert(_("An error occurred on deleting this image"));
+                }
+            });
+        }
+
+        function showNoImageMessage() {
+            var no_images_msg = _("No images have been uploaded for this bibliographic record yet.");
+            no_images_msg = '<p>' + no_images_msg + '</p>';
+            [% IF ( CAN_user_tools_upload_local_cover_images ) %]
+                var please_upload = _("Please select the image file to upload. %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>");
+                no_images_msg += "<p id='upload_image'>" + please_upload + '</p>';
+            [% END %]
+            $('#images').html(no_images_msg);
+        }
+
+        [% IF StaffDetailItemSelection %]
+            function itemSelectionBuildDeleteLink(div) {
+                var itemnumbers = new Array();
+                $("input[name='itemnumber'][type='checkbox']:checked", div).each(function() {
+                    itemnumbers.push($(this).val());
+                });
+                if (itemnumbers.length > 0) {
+                    var url = '/cgi-bin/koha/tools/batchMod.pl?op=show&del=1';
+                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
+                    url += '&src=' + '[% "/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber" |uri %]';
+                    $('a.itemselection_action_delete').attr('href', url);
+                } else {
+                    return false;
+                }
+                return true
+            }
+
+            function itemSelectionBuildModifyLink(div) {
+                var itemnumbers = new Array();
+                $("input[name='itemnumber'][type='checkbox']:checked", div).each(function() {
+                    itemnumbers.push($(this).val());
+                });
+                if (itemnumbers.length > 0) {
+                    var url = '/cgi-bin/koha/tools/batchMod.pl?op=show';
+                    url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
+                    url += '&src=' + '[% "/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber" |uri %]';
+                    $('a.itemselection_action_modify').attr('href', url);
+                } else {
+                    return false;
+                }
+                return true;
+            }
+
+            function itemSelectionBuildActionLinks(tab) {
+                var div = $("#" + tab);
+                var delete_link_ok = itemSelectionBuildDeleteLink(div);
+                var modify_link_ok = itemSelectionBuildModifyLink(div);
+                if (modify_link_ok || delete_link_ok) {
+                    $('.itemselection_actions', div).show();
+                } else {
+                    $('.itemselection_actions', div).hide();
+                }
+            }
+
+            $(document).ready(function() {
+                $('table.items_table').each(function() {
+                    var div = $(this).parent().attr("id");
+                    itemSelectionBuildActionLinks(div);
+                });
+
+                $("input[name='itemnumber'][type='checkbox']").change(function() {
+                    var div = $(this).parents('table').parent().parent().attr("id");
+                    itemSelectionBuildActionLinks(div);
+                });
+
+                $(".SelectAll").on("click",function(e){
+                    e.preventDefault();
+                    var tab = $(this).data("tab");
+                    $("input[name='itemnumber'][type='checkbox']", $("#"+tab)).prop('checked', true);
+                    itemSelectionBuildActionLinks(tab);
+                });
+
+                $(".ClearAll").on("click",function(e){
+                    e.preventDefault();
+                    var tab = $(this).data("tab");
+                    $("input[name='itemnumber'][type='checkbox']", $("#"+tab)).prop('checked', false);
+                    itemSelectionBuildActionLinks(tab);
+                });
+            });
+        [% END %]
+
+        $(document).ready(function() {
+            $('#bibliodetails').tabs();
+            [% IF count == 0 %]
+                $('#bibliodetails').tabs("option", "active", 3);
+            [% END %]
+            $('#search-form').focus();
+            $('.thumbnails > li > a > span.remove').click(function() {
+                var result = confirm(_("Are you sure you want to delete this cover image?"));
+
+                if ( result == true ) {
+                    var imagenumber = $(this).parent().parent().attr('id').split('-')[1];
+                    removeLocalImage(imagenumber);
+                }
+
+                return false;
+            });
+            [%# inject no images message %]
+            [% IF ( LocalCoverImages && ! localimages.0 ) %]
+                showNoImageMessage();
+            [% END %]
+            [% IF LocalCoverImages %]
+                KOHA.LocalCover.GetCoverFromBibnumber(true);
+            [% END %]
+            $("body").on("click",".previewMARC", function(e){
+                e.preventDefault();
+                var page = $(this).attr("href");
+                $("#marcPreview .modal-body").load(page + " table");
+                $('#marcPreview').modal({show:true});
+            });
+            $("#marcPreview").on("hidden.bs.modal", function(){
+                $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
+            });
+            [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
+                novSelect.loadContentForQuery({
+                    ClientIdentifier : '[% IF normalized_isbn %][% normalized_isbn | html %][% ELSE %][% normalized_upc | html %][% END %]',
+                    ISBN : '[% IF normalized_isbn %][% normalized_isbn | html %][% ELSE %][% normalized_upc | html %][% END %]',
+                    version : '2.1'
+                },
+                '[% Koha.Preference('NovelistSelectStaffProfile') | html %]',
+                '[% Koha.Preference('NovelistSelectPassword') | html %]',
+                function(d){
+                    if ( d.length > 0 ){ //If no content
+                        $(".NovelistSelect").show();
+                    }
+                 });
+             [% END %]
+
+        });
+
+        [% IF ( AmazonCoverImages || LocalCoverImages ) %]$(window).load(function() {
+            verify_images();
+        });[% END %]
+    </script>
+    [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
+        <script src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script>
+    [% END %]
+    [% INCLUDE 'datatables.inc' %]
+    [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
+    [% INCLUDE 'browser-strings.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
+    [% Asset.js("js/browser.js") | $raw %]
+    [% Asset.js("js/table_filters.js") | $raw %]
+    <script type="text/javascript">
+        var browser;
+        browser = KOHA.browser('[% searchid | html %]', parseInt(biblionumber, 10));
+        browser.show();
+
+        $(document).ready(function() {
+            var ids = ['holdings_table', 'otherholdings_table'];
+
+            for (var i in ids) {
+                var id = ids[i];
+                var dt_parameters = {
+                    'sDom': 't',
+                    'bPaginate': false,
+                    'bAutoWidth': false,
+                    "aoColumnDefs": [
+                        { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
+                        { "sType": "title-string", "aTargets" : [ "title-string" ] }
+                    ]
+                };
+                var table = KohaTable(id, dt_parameters, null, 'with_filters');
+            }
+
+            [% IF Koha.Preference('AcquisitionDetails') %]
+                var columns_settings = [% ColumnsSettings.GetColumns('catalogue', 'detail', 'acquisitiondetails-table', 'json') %];
+                var acquisitiondetails_table = KohaTable("orders", {
+                    "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
+                    'bPaginate': false,
+                    'bAutoWidth': false,
+                    "aaSorting": [[ 4, "desc" ]],
+                    "aoColumnDefs": [
+                        { "aTargets": "title-string", "sType": "title-string" }
+                    ]
+                }, columns_settings);
+            [% END %]
+        });
+    </script>
+[% END %]
 [% INCLUDE 'intranet-bottom.inc' %]