Bug 19641: (follow-up) Move patron templates to the footer
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / catalogue / itemsearch.tt
index 9c8da7b..172920b 100644 (file)
@@ -1,4 +1,3 @@
-[% USE CGI %]
 [% USE JSON.Escape %]
 
 [% BLOCK form_label %]
@@ -14,6 +13,7 @@
     [% CASE 'isbn' %]<span>ISBN</span>
     [% CASE 'issn' %]<span>ISSN</span>
     [% CASE 'homebranch' %]<span>Home library</span>
+    [% CASE 'holdingbranch' %]<span>Current location</span>
     [% CASE 'All libraries' %]<span>All libraries</span>
     [% CASE 'location' %]<span>Shelving location</span>
     [% CASE 'All locations' %]<span>All locations</span>
     <label class="form-field-label" for="[% name %]">[% INCLUDE form_label label=name %]</label>
     <select id="[% name %]_op" name="[% name %]_op">
       <option value="=">is</option>
-      [% IF CGI.param(name _ '_op') == '!=' %]
-        <option value="!=" selected="selected">is not</option>
-      [% ELSE %]
-        <option value="!=" >is not</option>
-      [% END %]
+      <option value="!=" >is not</option>
     </select>
-    [% values = CGI.param(name) %]
     <select id="[% name %]" name="[% name %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 %]">
-      [% IF (values == '') %]
-        <option value="" selected="selected">
-      [% ELSE %]
-        <option value="">
-      [% END %]
+      <option value="" selected="selected">
         [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
       </option>
       [% FOREACH option IN options %]
-        [% IF values != '' && values.grep(option.value).size %]
-          <option value="[% option.value %]" selected="selected">[% option.label %]</option>
-        [% ELSE %]
-          <option value="[% option.value %]">[% option.label %]</option>
-        [% END %]
+        <option value="[% option.value %]">[% option.label %]</option>
       [% END %]
     </select>
   </div>
 [% END %]
 
 [% BLOCK form_field_select_option %]
-  [% IF params.f == value %]
-    <option value="[% value %]" selected="selected">[% INCLUDE form_label label=value %]</option>
-  [% ELSE %]
-    <option value="[% value %]">[% INCLUDE form_label label=value %]</option>
-  [% END %]
+  <option value="[% value %]">[% INCLUDE form_label label=value %]</option>
 [% END %]
 
 [% BLOCK form_field_select_text %]
   <div class="form-field form-field-select-text">
-    [% IF params.exists('c') %]
-      <select name="c" class="form-field-conjunction">
-        <option value="and">AND</option>
-        [% IF params.c == 'or' %]
-          <option value="or" selected="selected">OR</option>
-        [% ELSE %]
-          <option value="or">OR</option>
-        [% END %]
-      </select>
-    [% ELSE %]
-      <select name="c" class="form-field-conjunction" disabled="disabled">
-        <option value="and">AND</option>
-        <option value="or">OR</option>
-      </select>
-    [% END %]
+    <select name="c" class="form-field-conjunction" disabled="disabled">
+      <option value="and">AND</option>
+      <option value="or">OR</option>
+    </select>
     <select name="f" class="form-field-column">
       [% INCLUDE form_field_select_option value='barcode' %]
       [% INCLUDE form_field_select_option value='itemcallnumber' %]
             [% IF field.tagsubfield %]
               [% marcfield = marcfield _ '$' _ field.tagsubfield %]
             [% END %]
-            [% IF params.f == "marc:$marcfield" %]
-              <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]" selected="selected">[% field.label %] ([% marcfield %])</option>
-            [% ELSE %]
-              <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]">[% field.label %] ([% marcfield %])</option>
-            [% END %]
+            <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]">[% field.label %] ([% marcfield %])</option>
           [% END %]
         </optgroup>
       [% END %]
     </select>
-    <input type="text" name="q" class="form-field-value" value="[% params.q %]" />
+    <input type="text" name="q" class="form-field-value" value="" />
     <input type="hidden" name="op" value="like" />
   </div>
 [% END %]
 
-[% BLOCK form_field_select_text_block %]
-  [% c = CGI.param('c').list %]
-  [% f = CGI.param('f').list %]
-  [% q = CGI.param('q').list %]
-  [% op = CGI.param('op').list %]
-  [% IF q.size %]
-    [% size = q.size - 1 %]
-    [% FOREACH i IN [0 .. size] %]
-      [%
-        params = {
-          f => f.$i
-          q = q.$i
-          op = op.$i
-        }
-      %]
-      [% IF i > 0 %]
-        [% j = i - 1 %]
-        [% params.c = c.$j %]
-      [% END %]
-      [% INCLUDE form_field_select_text params=params %]
-    [% END %]
-  [% ELSE %]
-    [% INCLUDE form_field_select_text %]
-  [% END %]
-[% END %]
-
 [% BLOCK form_field_radio_yes_no %]
   <div class="form-field">
     <label class="form-field-label">[% INCLUDE form_label label=name %]:</label>
 
 [%# Page starts here %]
 
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
   <title>Koha &rsaquo; Catalog &rsaquo; Item search</title>
   [% INCLUDE 'doc-head-close.inc' %]
-  <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>
-  <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/itemsearchform.css" />
-  <script type="text/javascript">
-    //<![CDATA[
-    var authorised_values = [% authorised_values_json %];
-
-    function loadAuthorisedValuesSelect(select) {
-      var selected = select.find('option:selected');
-      var category = selected.data('authorised-values-category');
-      var form_field_value = select.siblings('.form-field-value');
-      if (category && category in authorised_values) {
-        var values = authorised_values[category];
-        var html = '<select name="q" class="form-field-value">\n';
-        for (i in values) {
-          var value = values[i];
-          html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
-        }
-        html += '</select>\n';
-        var new_form_field_value = $(html);
-        new_form_field_value.val(form_field_value.val());
-        form_field_value.replaceWith(new_form_field_value);
-      } else {
-        if (form_field_value.prop('tagName').toLowerCase() == 'select') {
-          html = '<input name="q" type="text" class="form-field-value" />';
-          var new_form_field_value = $(html);
-          form_field_value.replaceWith(new_form_field_value);
-        }
-      }
-    }
-
-    function addNewField() {
-      var form_field = $('div.form-field-select-text').last();
-      var copy = form_field.clone(true);
-      copy.find('input,select').not('[type="hidden"]').each(function() {
-        $(this).val('');
-      });
-      copy.find('.form-field-conjunction').removeAttr('disabled');
-      form_field.after(copy);
-      copy.find('select.form-field-column').change();
-    }
-
-    function submitForm($form) {
-      var tr = ''
-        + '    <tr>'
-        + '      <th>' + _("Title") + '</th>'
-        + '      <th>' + _("Publication date") + '</th>'
-        + '      <th>' + _("Publisher") + '</th>'
-        + '      <th>' + _("Collection") + '</th>'
-        + '      <th>' + _("Barcode") + '</th>'
-        + '      <th>' + _("Call number") + '</th>'
-        + '      <th>' + _("Home library") + '</th>'
-        + '      <th>' + _("Current location") + '</th>'
-        + '      <th>' + _("Shelving location") + '</th>'
-        + '      <th>' + _("Inventory number") + '</th>'
-        + '      <th>' + _("Status") + '</th>'
-        + '      <th>' + _("Checkouts") + '</th>'
-        + '      <th></th>'
-        + '    </tr>'
-      var table = ''
-        + '<table id="results">'
-        + '  <thead>' + tr + tr + '</thead>'
-        + '  <tbody></tbody>'
-        + '</table>';
-      var results_heading = "<h1>" + _("Item search results") + "</h1>";
-      results_heading += "<p><a href=\"/cgi-bin/koha/catalogue/search.pl\">" + _("Go to advanced search") + "</a></p>";
-      results_heading += "<p><a class=\"editsearchlink\" href=\"#\">" + _("Edit search") + "</a></p>";
-      $('#results-wrapper').empty().html(results_heading + table);
-
-      var params = [];
-      $form.find('select').not('[disabled]').find('option:selected').each(function () {
-        var name = $(this).parent('select').attr('name');
-        var value = $(this).val();
-        params.push({ 'name': name, 'value': value });
-      });
-      $form.find('input[type="text"],input[type="hidden"]').not('[disabled]').each(function () {
-        params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
-      });
-      $form.find('input[type="radio"]:checked').each(function() {
-        params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
-      });
-
-      $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
-        'bDestroy': true,
-        'bServerSide': true,
-        'bProcessing': true,
-        'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
-        'fnServerData': function(sSource, aoData, fnCallback) {
-          aoData.push( { 'name': 'format', 'value': 'json' } );
-          for (i in params) {
-            aoData.push(params[i]);
-          }
-          $.ajax({
-              'dataType': 'json',
-              'type': 'POST',
-              'url': sSource,
-              'data': aoData,
-              'success': function(json){
-                  fnCallback(json);
-              }
-          });
-        },
-        'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
-        'aoColumns': [
-          { 'sName': 'title' },
-          { 'sName': 'publicationyear' },
-          { 'sName': 'publishercode' },
-          { 'sName': 'collectiontitle' },
-          { 'sName': 'barcode' },
-          { 'sName': 'itemcallnumber' },
-          { 'sName': 'homebranch' },
-          { 'sName': 'holdingbranch' },
-          { 'sName': 'location' },
-          { 'sName': 'stocknumber' },
-          { 'sName': 'notforloan' },
-          { 'sName': 'issues' },
-          { 'sName': 'checkbox', 'bSortable': false }
-        ],
-        "sPaginationType": "full_numbers"
-      })).columnFilter({
-        'sPlaceHolder': 'head:after',
-        'aoColumns': [
-          { 'type': 'text' },
-          { 'type': 'text' },
-          { 'type': 'text' },
-          { 'type': 'text' },
-          { 'type': 'text' },
-          { 'type': 'text' },
-          { 'type': 'select', 'values': [% branches.json %] },
-          { 'type': 'select', 'values': [% branches.json %] },
-          { 'type': 'select', 'values': [% locations.json %] },
-          { 'type': 'text' },
-          { 'type': 'select', 'values': [% notforloans.json %] },
-          { 'type': 'text' },
-          null
-        ]
-      });
-    }
-
-    function hideForm() {
-      $("#item-search-block").hide();
-      $('.editsearchlink').show();
-    }
-
-    $(document).ready(function () {
-      // Add the "New field" link.
-      var form_field = $('div.form-field-select-text').last()
-      var NEW_FIELD = _("New field");
-      var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field">' + NEW_FIELD + '</a>');
-      button_field_new.click(function() {
-        addNewField();
-        return false;
-      });
-      form_field.after(button_field_new);
-
-      // If a field is linked to an authorised values list, display the list.
-      $('div.form-field-select-text select').change(function() {
-        loadAuthorisedValuesSelect($(this));
-      }).change();
-
-      // Prevent user to select the 'All ...' option with other options.
-      $('div.form-field-select').each(function() {
-        $(this).find('select').filter(':last').change(function() {
-          values = $(this).val();
-          if (values.length > 1) {
-            var idx = $.inArray('', values);
-            if (idx != -1) {
-              values.splice(idx, 1);
-              $(this).val(values);
-            }
-          }
-        });
-      });
-
-      $('#itemsearchform').submit(function() {
-        var searchform = $(this);
-        var format = searchform.find('input[name="format"]:checked').val();
-        if (format == 'html') {
-          submitForm(searchform);
-          hideForm();
-          return false;
-        }
-      });
-
-      $("body").on("click",".editsearchlink",function(e) {
-        e.preventDefault();
-        $('#item-search-block').show();
-        $(this).hide();
-        return false;
-      });
-    });
-    //]]>
-  </script>
+  <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/itemsearchform_[% KOHA_VERSION %].css" />
+  <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
 </head>
+
 <body id="catalog_itemsearch" class="catalog">
   [% INCLUDE 'header.inc' %]
   [% INCLUDE 'home-search.inc' %]
     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo; Item search
   </div>
 
-  <div id="doc" class="yui-t7">
+<div class="main container-fluid">
+    <div class="row">
+        <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
+
     <div id="item-search-block">
       <h1>Item search</h1>
       <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p>
       <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform">
+          <div id="toolbar" class="btn-toolbar">
+              <fieldset class="action">
+                  <div class="btn-group">
+                      <button class="btn btn-default btn-sm"><i class="fa fa-search"></i> Search</button>
+                  </div>
+              </fieldset>
+          </div>
           <fieldset>
-            [% INCLUDE form_field_select
-              name="homebranch"
-              options = branches
-              empty_option = "All libraries"
-            %]
-            [% INCLUDE form_field_select
-              name="location"
-              options = locations
-              empty_option = "All locations"
-            %]
+            [% INCLUDE form_field_select name="homebranch" options = branches empty_option = "All libraries" %]
+            [% INCLUDE form_field_select name="holdingbranch" options = branches empty_option = "All libraries" %]
+            [% IF locations.size %]
+                [% INCLUDE form_field_select name="location" options = locations empty_option = "All locations" %]
+            [% END %]
           </fieldset>
           <fieldset>
-            [% INCLUDE form_field_select
-              name="itype"
-              options = itemtypes
-              empty_option = "All item types"
-            %]
-            [% INCLUDE form_field_select
-              name="ccode"
-              options = ccodes
-              empty_option = "All collection codes"
-            %]
-            [% INCLUDE form_field_select
-              name="notforloan"
-              options = notforloans
-              empty_option = "All statuses"
-            %]
+            [% INCLUDE form_field_select name="itype" options = itemtypes empty_option = "All item types" %]
+            [% IF ccodes.size %]
+                [% INCLUDE form_field_select name="ccode" options = ccodes empty_option = "All collection codes" %]
+            [% END %]
+            [% IF notforloans.size %]
+                [% INCLUDE form_field_select name="notforloan" options = notforloans empty_option = "All statuses" %]
+            [% END %]
           </fieldset>
           <fieldset>
-            [% INCLUDE form_field_select_text_block %]
+            [% INCLUDE form_field_select_text %]
             <p class="hint">You can use the following wildcard characters: % _</p>
             <p class="hint">% matches any number of characters</p>
             <p class="hint">_ matches only a single character</p>
           <fieldset>
             <div class="form-field">
               <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
-              [% value = CGI.param('itemcallnumber_from') %]
-              <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="[% value %]" />
+              <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="" />
               <span class="hint">(inclusive)</span>
             </div>
             <div class="form-field">
-              [% value = CGI.param('itemcallnumber_to') %]
               <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
-              <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="[% value %]" />
+              <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="" />
               <span class="hint">(inclusive)</span>
             </div>
             [% INCLUDE form_field_radio_yes_no name="damaged" %]
               <label>Output:</label>
               <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
               <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
-            </div>
-            <div class="form-actions">
-              <input type="submit" value="Search" />
+              <input type="radio" id="format-barcodes" name="format" value="barcodes"/> <label for="format-barcodes">Barcodes file</label>
             </div>
           </fieldset>
       </form>
-
-      <p><a id="editsearchlink" href="#" style="display:none">Edit search</a></p>
+    </div>
     </div>
   </div>
-  <div id="doc3" class="yui-t7">
-      <div id="results-wrapper">
-        [% IF search_done %]
-          [% IF total_rows > 0 %]
-            <p>Found [% total_rows %] results.</p>
-          [% ELSE %]
-            <p>No results found.</p>
-          [% END %]
+    <div class="row">
+        <div class="col-md-12">
+      <div id="results-wrapper"></div>
+        </div>
+      </div>
 
-          [% IF results %]
-            [% INCLUDE 'catalogue/itemsearch_items.inc' items = results %]
-          [% END %]
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript">
+        var authorised_values = [% authorised_values_json %];
 
-          <div class="pages">
-            [% pagination_bar %]
-          </div>
+        function loadAuthorisedValuesSelect(select) {
+            var selected = select.find('option:selected');
+            var category = selected.data('authorised-values-category');
+            var form_field_value = select.siblings('.form-field-value');
+            if (category && category in authorised_values) {
+                var values = authorised_values[category];
+                var html = '<select name="q" class="form-field-value">\n';
+                for (i in values) {
+                    var value = values[i];
+                    html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
+                }
+                html += '</select>\n';
+                var new_form_field_value = $(html);
+                new_form_field_value.val(form_field_value.val());
+                form_field_value.replaceWith(new_form_field_value);
+            } else {
+                if (form_field_value.prop('tagName').toLowerCase() == 'select') {
+                    html = '<input name="q" type="text" class="form-field-value" />';
+                    var new_form_field_value = $(html);
+                    form_field_value.replaceWith(new_form_field_value);
+                }
+            }
+        }
 
-        [% END %]
-      </div>
+    function addNewField( link ) {
+            var form_field = $('div.form-field-select-text').last();
+            var copy = form_field.clone(true);
+            copy.find('input,select').not('[type="hidden"]').each(function() {
+                $(this).val('');
+            });
+            copy.find('.form-field-conjunction').prop('disabled', false);
+            form_field.after(copy);
+      link.remove();
+            copy.find('select.form-field-column').change();
+        }
+
+        function submitForm($form) {
+            var tr = ''
+                + '    <tr>'
+                + '      <th id="items_title">' + _("Title") + '</th>'
+                + '      <th id="items_pubdate">' + _("Publication date") + '</th>'
+                + '      <th id="items_publisher">' + _("Publisher") + '</th>'
+                + '      <th id="items_collection">' + _("Collection") + '</th>'
+                + '      <th id="items_barcode">' + _("Barcode") + '</th>'
+                + '      <th id="items_callno">' + _("Call number") + '</th>'
+                + '      <th id="items_homebranch">' + _("Home library") + '</th>'
+                + '      <th id="items_holdingbranch">' + _("Current location") + '</th>'
+                + '      <th id="items_location">' + _("Shelving location") + '</th>'
+                + '      <th id="item_inventoryno">' + _("Inventory number") + '</th>'
+                + '      <th id="items_status">' + _("Status") + '</th>'
+                + '      <th id="items_checkouts">' + _("Checkouts") + '</th>'
+                + '      <th id=""></th>'
+                + '    </tr>'
+            var table = ''
+                + '<table id="results">'
+                + '  <thead>' + tr + tr + '</thead>'
+                + '  <tbody></tbody>'
+                + '</table>';
+
+            var advSearchLink = $('<a>')
+                .attr('href', '/cgi-bin/koha/catalogue/search.pl')
+                .html(_("Go to advanced search"));
+            var editSearchLink = $('<a>')
+                .attr('href', '#')
+                .html(_("Edit search"))
+                .addClass('btn btn-default btn-xs')
+                .on('click', function(e) {
+                    e.preventDefault();
+                    $('#item-search-block').show();
+                });
+
+            var csvExportLink = $('<a>')
+                .attr('href', '#')
+                .html(_("Export results to CSV"))
+                .addClass('btn btn-default btn-xs')
+                .on('click', function(e) {
+                    e.preventDefault();
+                    $('#format-csv').prop('checked', true);
+                    $('#itemsearchform').submit();
+                    $('#format-html').prop('checked', true);
+                });
+            var barcodesExportLink = $('<a>')
+                .attr('href', '#')
+                .html(_("Export results to barcodes file"))
+                .addClass('btn btn-default btn-xs')
+                .on('click', function(e) {
+                    e.preventDefault();
+                    $('#format-barcodes').prop('checked', true);
+                    $('#itemsearchform').submit();
+                    $('#format-html').prop('checked', true);
+              });
+
+            var editSearchAndExportLinks = $('<p>')
+                .append(editSearchLink)
+                .append(' | ')
+                .append(csvExportLink)
+                .append(' ')
+                .append(barcodesExportLink);
+
+            var results_heading = $('<div>').addClass('results-heading')
+                .append("<h1>" + _("Item search results") + "</h1>")
+                .append($('<p>').append(advSearchLink))
+                .append(editSearchAndExportLinks);
+            $('#results-wrapper').empty()
+                .append(results_heading)
+                .append(table);
+
+            var params = [];
+            $form.find('select').not(':disabled').find('option:selected').each(function () {
+                var name = $(this).parents('select').first().attr('name');
+                var value = $(this).val();
+                params.push({ 'name': name, 'value': value });
+            });
+            $form.find('input[type="text"],input[type="hidden"]').not(':disabled').each(function () {
+                params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
+            });
+            $form.find('input[type="radio"]:checked').each(function() {
+                params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
+            });
+
+            $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
+                'bDestroy': true,
+                'bServerSide': true,
+                'bProcessing': true,
+                'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
+                'fnServerData': function(sSource, aoData, fnCallback) {
+                    aoData.push( { 'name': 'format', 'value': 'json' } );
+                    for (i in params) {
+                        aoData.push(params[i]);
+                    }
+                    $.ajax({
+                        'dataType': 'json',
+                        'type': 'POST',
+                        'url': sSource,
+                        'data': aoData,
+                        'success': function(json){
+                            fnCallback(json);
+                        }
+                    });
+                },
+                'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
+                'aoColumns': [
+                    { 'sName': 'title' },
+                    { 'sName': 'publicationyear' },
+                    { 'sName': 'publishercode' },
+          { 'sName': 'ccode' },
+                    { 'sName': 'barcode' },
+                    { 'sName': 'itemcallnumber' },
+                    { 'sName': 'homebranch' },
+                    { 'sName': 'holdingbranch' },
+                    { 'sName': 'location' },
+                    { 'sName': 'stocknumber' },
+                    { 'sName': 'notforloan' },
+                    { 'sName': 'issues' },
+                    { 'sName': 'checkbox', 'bSortable': false }
+                ],
+                "sPaginationType": "full_numbers"
+            })).columnFilter({
+                'sPlaceHolder': 'head:after',
+                'aoColumns': [
+                    { 'type': 'text' },
+                    { 'type': 'text' },
+                    { 'type': 'text' },
+                    [% IF ccodes.size %]
+                        { 'type': 'select', 'values': [% ccodes.json %] },
+                    [% ELSE %]
+                        null,
+                    [% END %]
+                    { 'type': 'text' },
+                    { 'type': 'text' },
+                    { 'type': 'select', 'values': [% branches.json %] },
+                    { 'type': 'select', 'values': [% branches.json %] },
+                    [% IF locations.size %]
+                        { 'type': 'select', 'values': [% locations.json %] },
+                    [% ELSE %]
+                        null,
+                    [% END %]
+                    { 'type': 'text' },
+                    [% IF notforloans.size %]
+                        { 'type': 'select', 'values': [% notforloans.json %] },
+                    [% ELSE %]
+                        null,
+                    [% END %]
+                    { 'type': 'text' },
+                    null
+                ]
+            });
+        }
+
+        $(document).ready(function () {
+            $('#toolbar').fixFloat();
+            // Add the "New field" link.
+            var form_field = $('div.form-field-select-text').last()
+            var NEW_FIELD = _("New field");
+      var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field"><i class="fa fa-plus"></i> ' + NEW_FIELD + '</a>');
+      button_field_new.click(function(e) {
+          e.preventDefault();
+          addNewField( $(this) );
+            });
+      form_field.append(button_field_new);
+
+            // If a field is linked to an authorised values list, display the list.
+            $('div.form-field-select-text select').change(function() {
+                loadAuthorisedValuesSelect($(this));
+            }).change();
+
+            // Prevent user to select the 'All ...' option with other options.
+            $('div.form-field-select').each(function() {
+                $(this).find('select').filter(':last').change(function() {
+                    values = $(this).val();
+                    if (values.length > 1) {
+                        var idx = $.inArray('', values);
+                        if (idx != -1) {
+                            values.splice(idx, 1);
+                            $(this).val(values);
+                        }
+                    }
+                });
+                $('#itemsearchform').submit(function() {
+                  var searchform = $(this);
+                  var format = searchform.find('input[name="format"]:checked').val();
+                  if (format == 'html') {
+                    submitForm(searchform);
+                    $("#item-search-block").hide();
+                    return false;
+                  }
+                });
+            });
+        });
+    </script>
+[% END %]
 
-    [% INCLUDE 'intranet-bottom.inc' %]
+[% INCLUDE 'intranet-bottom.inc' %]