Bug 22621: Fix filters on subscription search results
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / serials-search.tt
index f570669..6474c83 100644 (file)
+[% USE raw %]
+[% USE Asset %]
+[% USE AuthorisedValues %]
 [% USE Branches %]
-[% INCLUDE 'doc-head-open.inc' %]
+[% USE CGI %]
 [% USE KohaDates %]
-[% USE AuthorisedValues %]
-<title>Koha &rsaquo; Serials [% biblionumber %]</title>
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% USE Koha %]
+[% SET footerjs = 1 %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>Koha &rsaquo; Serials [% biblionumber | html %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'calendar.inc' %]
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-[% INCLUDE 'datatables-strings.inc' %]
-<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
-<script type="text/javascript">
-//<![CDATA[
- $(document).ready(function() {
-    [% IF (dateformat == 'metric') %]
-        dt_add_type_uk_date();
-    [% END %]
-    var osrlt = $("#osrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
-
-        "aoColumnDefs": [
-            { "aTargets": [ -1, -2, -3 ], "bSortable": false, "bSearchable": false },
-        ],
-        "sPaginationType": "four_button"
-    } ) );
-
-    var csrlt = $("#csrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
-        "aoColumnDefs": [
-            { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
-        ],
-        "sPaginationType": "four_button"
-    } ) );
-
-    osrlt.fnAddFilters("filter", 750);
-    csrlt.fnAddFilters("filter", 750);
-
-    $('#serialstabs').tabs();
-    $("#reopensub").click(function(){
-      return confirm(_("Are you sure you want to reopen this subscription?"));
-    });
- });
- //]]>
-</script>
+<style>input.dt-filter { width : 100%; font-size : 85%; }</style>
 </head>
+
 <body id="ser_serials-home" class="ser">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'serials-search.inc' %]
 
 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; [% IF ( done_searched ) %]<a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> &rsaquo; Search results[% ELSE %]Serials [% END %] </div>
 
-<div id="doc3" class="yui-t2">
-  <div id="bd">
-    <div id="yui-main">
-      <div class="yui-b">
+[% url_params = [] %]
+[% FOREACH param IN CGI.params.pairs %]
+    [% escaped_value = BLOCK %][% param.value | uri %][% END %]
+    [% url_params.push(param.key _ '=' _ escaped_value) %]
+[% END %]
+[% SET referrer = '/cgi-bin/koha/serials/serials-search.pl?' %]
+[% referrer = BLOCK %][% referrer | url %][% url_params.join("&amp;") |uri %][% END %]
+[% SET edit_action_link = '/cgi-bin/koha/serials/subscription-batchedit.pl?referrer=' _ referrer %]
+
+[% BLOCK subscriptions_table %]
+  <form method="post">
+
+    [% IF closed %]
+        [% SET tab = 'closed' %]
+    [% ELSE %]
+        [% SET tab = 'opened' %]
+    [% END %]
+    [% IF CAN_user_serials_edit_subscription %]
+        <div class="actions">
+            <a class="select-all" href="#" data-tab="[% tab | html %]"><i class="fa fa-check"></i> Select all</a>
+            |
+            <a class="clear-all" href="#" data-tab="[% tab | html %]"><i class="fa fa-remove"></i> Clear all</a>
+            <span class="itemselection_actions">
+                | Actions:
+                <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Edit selected serials</a>
+            </span>
+        </div>
+    [% END %]
+    <table>
+      <thead>
+        <tr>
+            <th></th>
+            <th>ISSN</th>
+            <th class="anti-the">Title</th>
+            <th>Notes</th>
+            <th>Library</th>
+            <th>Location</th>
+            <th>Call number</th>
+            [% UNLESS closed %]
+                <th class="title-string">Expiration date</th>
+            [% END %]
+            [% FOR field IN additional_fields_for_subscription %]
+              <th>[% field.name | html %]</th>
+            [% END %]
+            <th class="NoSort">Actions</th>
+        </tr>
+      </thead>
+      <tfoot>
+        <tr>
+          <td></td>
+          <td><input type="text" class="dt-filter" data-column_num="1" placeholder="Search ISSN" /></td>
+          <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search title" /></td>
+          <td><input type="text" class="dt-filter" data-column_num="3" placeholder="Search notes" /></td>
+          <td><input type="text" class="dt-filter" data-column_num="4" placeholder="Search library" /></td>
+          <td><input type="text" class="dt-filter" data-column_num="5" placeholder="Search location" /></td>
+          <td><input type="text" class="dt-filter" data-column_num="6" placeholder="Search callnumber" /></td>
+          [% SET column_num = 6 %]
+          [% UNLESS closed %]
+              <td><input type="text" class="dt-filter" data-column_num="7" placeholder="Search expiration date" /></td>
+              [% SET column_num = column_num + 1 %]
+          [% END %]
+          [% FOR field IN additional_fields_for_subscription %]
+            <td><input type="text" class="dt-filter" data-column_num="[% loop.count + column_num | html %]" placeholder="Search [% field.name | html %]" /></td>
+          [% END %]
+          <td></td>
+        </tr>
+      </tfoot>
+      <tbody>
+        [% FOREACH subscription IN subscriptions %]
+        [% UNLESS subscription.cannotdisplay %]
+          <tr>
+            <td>
+                [% UNLESS subscription.cannotedit %]
+                    <input type="checkbox" name="subscriptionid" value="[% subscription.subscriptionid | html %]" />
+                [% ELSE %]
+                    <input type="checkbox" name="subscriptionid" value="[% subscription.subscriptionid | html %]" disabled="disabled" title="You cannot edit this subscription" />
+                [% END %]
+            </td>
+            <td>
+            [% IF ( subscription.issn ) %][% subscription.issn | html %]
+            [% END %]
+            </td>
+            <td><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid | uri %]" class="button" title="subscription detail">[% subscription.title | html %]</a>
+            </td>
+            <td>[% IF ( subscription.publicnotes ) %][% subscription.publicnotes | html %][% END %]
+            [% IF ( subscription.internalnotes ) %]([% subscription.internalnotes | html %])[% END %]
+            </td>
+            <td>
+              [% IF ( subscription.branchcode ) %][% Branches.GetName( subscription.branchcode ) | html %][% END %]
+            </td>
+            <td>
+              [% IF ( subscription.location ) %][% AuthorisedValues.GetByCode( 'LOC', subscription.location ) | html %][% END %]
+            </td>
+            <td>
+              [% IF ( subscription.callnumber ) %][% subscription.callnumber | html %][% END %]
+            </td>
+            [% UNLESS closed %]
+                <td>
+                    [% IF ( subscription.enddate ) %]
+                        <span title="[% subscription.enddate | html %]">[% subscription.enddate | $KohaDates %]</span>
+                    [% ELSE %]
+                        <span title="0000-00-00"></span>
+                    [% END %]
+                </td>
+            [% END %]
+
+            [% FOR field IN additional_fields_for_subscription %]
+              [% IF field.authorised_value_category %]
+                <td>[% AuthorisedValues.GetByCode( field.authorised_value_category, subscription.additional_fields.${field.name} ) | html %]</td>
+              [% ELSE %]
+                <td>[% subscription.additional_fields.${field.name} | html %]</td>
+              [% END %]
+            [% END %]
+
+            <td>
+                <div class="dropdown">
+                    [% IF closed %]
+                        <a class="btn btn-default btn-xs dropdown-toggle" id="closedsubactions[% subscription.subscriptionid | html %]" role="button" data-toggle="dropdown" href="#">
+                           Actions <b class="caret"></b>
+                        </a>
+                        <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="closedsubactions[% subscription.subscriptionid | html %]">
+
+                            [% IF ( routing && CAN_user_serials_routing ) %]
+                                [% UNLESS ( subscription.cannotedit ) %]
+                                    <li>
+                                        <a href="/cgi-bin/koha/serials/serials-search.pl?subscriptionid=[% subscription.subscriptionid | uri %]&amp;op=reopen&amp;routing=[% subscription.routing | uri %]&amp;searched=1&amp;title_filter=[% title_filter | uri %]&amp;ISSN_filter=[% ISSN_filter | uri %]&amp;EAN_filter=[% EAN_filter | uri %]&amp;published_filter=[% publisher_filter | uri %]&amp;bookseller_filter=[% bookseller_filter | uri %]&amp;branch_filter=[% branch_filter | uri %]" id="reopensub"> <i class="fa fa-repeat"></i> Reopen</a>
+                                    </li>
+                                [% END %]
+                            [% END # IF ( routing && CAN_user_serials_routing ) %]
+
+                            <li>
+                                <a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid | uri %]"><i class="fa fa-list-alt"></i> Issue history</a>
+                            </li>
+
+                        </ul>
+                    [% ELSE %]
+                        <div class="btn-group">
+                            [% IF ( CAN_user_serials_receive_serials ) %]
+                                [%# There should be no space between these two buttons, it would render badly %]
+                                <a class="btn btn-default btn-xs" role="button"
+                                   href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid | html %]&amp;serstatus=1,3,7"><i
+                                   class="fa fa-inbox"></i> Serial receive</a><a
+                                   class="btn btn-default btn-xs dropdown-toggle" id="subactions[% subscription.subscriptionid | html %]" role="button"
+                                   data-toggle="dropdown" href="#"><b class="caret"></b></a>
+                            [% ELSE %]
+                                <a class="btn btn-default btn-xs dropdown-toggle" id="subactions[% subscription.subscriptionid | html %]" role="button" data-toggle="dropdown" href="#">Actions <b class="caret"></b></a>
+                            [% END %]
+                        <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="subactions[% subscription.subscriptionid | html %]">
+
+                            [% IF ( routing && CAN_user_serials_routing ) %]
+                                [% IF ( subscription.cannotedit ) %]
+                                [% ELSE %]
+                                    [% IF ( subscription.routingedit ) %]
+                                        <li>
+                                            <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid | uri %]"><i class="fa fa-pencil"></i> Edit routing list ([% subscription.routingedit | html %])</a>
+                                        </li>
+                                    [% ELSE %]
+                                        <li>
+                                            <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid | uri %]&amp;op=new"> <i class="fa fa-plus"></i> New routing list</a>
+                                        </li>
+                                    [% END %]
+                                [% END %]
+                            [% END # IF ( routing && CAN_user_serials_routing ) %]
+
+                            <li>
+                                <a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid | uri %]"><i class="fa fa-list-alt"></i> Issue history</a>
+                            </li>
+                        </ul>
+                        </div>
+                    [% END %]
+                </div>
+            </td>
+
+          </tr>
+          [% END %]
+        [% END %]
+      </tbody>
+    </table>
+  </form>
+[% END %]
+
+<div class="main container-fluid">
+    <div class="row">
+        <div class="col-sm-10 col-sm-push-2">
+            <main>
+
       [% INCLUDE 'serials-toolbar.inc' %]
 
-      <h2>Serials subscriptions ([% total %] found)</h2>
+      [% IF ( done_searched ) %]
+        <h2>Serials subscriptions ([% total | html %] found)</h2>
+      [% ELSE %]
+        <h2>Serials subscriptions search</h2>
+      [% END %]
+
       [% UNLESS ( done_searched ) %]
       <div id="advsearch" style="padding-bottom:3em;">
         <form action="/cgi-bin/koha/serials/serials-search.pl" method="get">
               <ol>
                 <li>
                   <label for="issn">ISSN:</label>
-                  <input type="text" id="issn" name="ISSN_filter" value="[% ISSN_filter %]" />
+                  <input type="text" id="issn" name="ISSN_filter" value="[% ISSN_filter | html %]" />
                 </li>
                 <li>
                   <label for="title">Title:</label>
-                  <input type="text" id="title" name="title_filter" value="[% title_filter %]" />
+                  <input type="text" id="title" name="title_filter" value="[% title_filter | html %]" />
                 </li>
                 [% IF ( marcflavour == "UNIMARC" ) %]
                 <li>
                   <label for="ean">EAN:</label>
-                  <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter %]" />
+                  <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter | html %]" />
                 </li>
                 [% END %]
                 <li>
                   <label for="callnumber">Call number:</label>
-                  <input type="text" id="callnumber" name="callnumber_filter" value="[% callnumber_filter %]" />
+                  <input type="text" id="callnumber" name="callnumber_filter" value="[% callnumber_filter | html %]" />
                 </li>
                 <li>
                   <label for="publisher">Publisher:</label>
-                  <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter %]" />
+                  <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter | html %]" />
                 </li>
                 <li>
                   <label for="bookseller">Vendor:</label>
-                  <input type="text" id="bookseller" name="bookseller_filter" value="[% bookseller_filter %]" />
+                  <input type="text" id="bookseller" name="bookseller_filter" value="[% bookseller_filter | html %]" />
                 </li>
                 <li>
                   <label for="branch">Library:</label>
                   <select id="branch" name="branch_filter">
                     <option value="">All</option>
-                    [% FOREACH branch IN branches_loop %]
-                      [% IF ( branch.selected ) %]
-                        <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
-                      [% ELSE %]
-                        <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
-                      [% END %]
-                    [% END %]
+                    [%# FIXME Should not we filter the libraries? %]
+                    [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
                   </select>
                 </li>
-                [% IF locations %]
-                  <li>
-                    <label for="location">Location:</label>
-                    <select name="location_filter">
-                      <option value="">All</option>
-                      [% FOR loc IN locations %]
-                        [% IF loc.selected %]
-                          <option value="[% loc.authorised_value %]" selected="selected">[% loc.lib %]</option>
-                        [% ELSE %]
-                          <option value="[% loc.authorised_value %]">[% loc.lib %]</option>
-                        [% END %]
-                      [% END %]
-                    </select>
-                  </li>
-                [% END %]
+                <li>
+                  <label for="location">Location:</label>
+                  [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %]
+                </li>
                 <li>
                   <label for="to">Expires before:</label>
                   <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
                 </li>
+                [% INCLUDE 'additional-fields-entry.inc' available=additional_fields_for_subscription values=additional_field_filters wrap_fieldset=0 %]
               </ol>
               <input type="hidden" name="searched" value="1" />
+              [% IF ( mana ) %]<input type="hidden" name="mana" value="1" />[% END %]
               <fieldset class="action">
                 <input type="submit" value="Search" />
               </fieldset>
         [% IF ( total ) %]
           <div id="serialstabs" class="toptabs" style="clear:both;">
             <ul class="ui-tabs-nav">
-              <li><a href="#opened">Open ([% openedsubscriptions.size || 0 %])</a></li>
-              <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 %])</a></li>
+              [% IF mana %]
+                <li><a href="#mana">Mana ([% total || 0 | html %])</a></li>
+              [% ELSE %]
+                <li><a href="#opened">Open ([% openedsubscriptions.size || 0 | html %])</a></li>
+                <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 | html %])</a></li>
+              [% END %]
             </ul>
+            [% IF mana %]
+                <div id="mana">
+                    [% INCLUDE 'mana/mana-subscription-search-result.inc' %]
+                </div>
+            [% ELSE %]
             <div id="opened">
               [% IF openedsubscriptions %]
-                <table id="osrlt">
-                  <thead>
-                    <tr>
-                        <th>ISSN</th>
-                        <th>Title</th>
-                        <th> Notes </th>
-                        <th>Library</th>
-                        <th>Location</th>
-                        <th>Call number</th>
-                        <th>Expiration date</th>
-                        [% IF ( routing && CAN_user_serials_routing ) %]
-                          <th>Routing list</th>
-                        [% END %]
-                        <th>&nbsp;</th>
-                        <th>&nbsp;</th>
-                    </tr>
-                  </thead>
-                  <tfoot>
-                    <tr>
-                      <td><input type="text" class="filter" data-column_num="0" placeholder="Search ISSN" /></td>
-                      <td><input type="text" class="filter" data-column_num="1" placeholder="Search title" /></td>
-                      <td><input type="text" class="filter" data-column_num="2" placeholder="Search notes" /></td>
-                      <td><input type="text" class="filter" data-column_num="3" placeholder="Search library" /></td>
-                      <td><input type="text" class="filter" data-column_num="4" placeholder="Search location" /></td>
-                      <td><input type="text" class="filter" data-column_num="5" placeholder="Search callnumber" /></td>
-                      <td><input type="text" class="filter" data-column_num="6" placeholder="Search expiration date" /></td>
-                      [% IF ( routing && CAN_user_serials_routing ) %]<td></td>[% END %]
-                      <td></td>
-                      <td></td>
-                    </tr>
-                  </tfoot>
-                  <tbody>
-                    [% FOREACH subscription IN openedsubscriptions %]
-                    [% UNLESS subscription.cannotdisplay %]
-                      <tr>
-                        <td>
-                        [% IF ( subscription.issn ) %][% subscription.issn %]
-                        [% END %]
-                        </td>
-                        <td><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid %]" class="button" title="subscription detail">[% subscription.title |html %]</a>
-                        </td>
-                        <td>[% IF ( subscription.publicnotes ) %][% subscription.publicnotes %][% END %]
-                        [% IF ( subscription.internalnotes ) %]([% subscription.internalnotes %])[% END %]
-                        </td>
-                        <td>
-                          [% IF ( subscription.branchcode ) %][% Branches.GetName( subscription.branchcode ) %][% END %]
-                        </td>
-                        <td>
-                          [% IF ( subscription.location ) %][% AuthorisedValues.GetByCode( 'LOC', subscription.location ) %][% END %]
-                        </td>
-                        <td>
-                          [% IF ( subscription.callnumber ) %][% subscription.callnumber %][% END %]
-                        </td>
-                        <td>
-                          [% IF ( subscription.enddate ) %][% subscription.enddate | $KohaDates %][% END %]
-                        </td>
-                        [% IF ( routing && CAN_user_serials_routing ) %]
-                        <td>
-                          [% IF ( subscription.cannotedit ) %]
-                            &nbsp;
-                          [% ELSE %]
-                            [% IF ( subscription.routingedit ) %]
-                              <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]">Edit</a>
-                              ([% subscription.routingedit %])
-                            [% ELSE %]
-                              <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]&amp;op=new">New</a>
-                            [% END %]
-                          [% END %]
-                        </td>
-                        [% END %]
-                        <td><a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]">Issue history</a>
-                        </td>
-                        <td>
-                        [% IF ( CAN_user_serials_receive_serials ) %]
-                          <a href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid %]&amp;serstatus=1,3,7">Serial receive</a>
-                        [% END %]
-                        </td>
-                      </tr>
-                      [% END %]
-                    [% END %]
-                  </tbody>
-                </table>
+                  [% INCLUDE subscriptions_table subscriptions = openedsubscriptions %]
               [% ELSE %]
                 <div class="dialog message">
                   <p>Your search returned no open subscriptions.</p>
             </div>
             <div id="closed">
               [% IF closedsubscriptions %]
-                <table id="csrlt">
-                  <thead>
-                    <tr>
-                        <th>ISSN</th>
-                        <th>Title</th>
-                        <th> Notes </th>
-                        <th>Library</th>
-                        <th>Location</th>
-                        <th>Call number</th>
-                        <th>&nbsp;</th>
-                        <th>&nbsp;</th>
-                    </tr>
-                  </thead>
-                  <tfoot>
-                    <tr>
-                      <td><input type="text" class="filter" data-column_num="0" placeholder="Search ISSN" /></td>
-                      <td><input type="text" class="filter" data-column_num="1" placeholder="Search title" /></td>
-                      <td><input type="text" class="filter" data-column_num="2" placeholder="Search notes" /></td>
-                      <td><input type="text" class="filter" data-column_num="3" placeholder="Search library" /></td>
-                      <td><input type="text" class="filter" data-column_num="4" placeholder="Search location" /></td>
-                      <td><input type="text" class="filter" data-column_num="5" placeholder="Search callnumber" /></td>
-                      <td></td>
-                      <td></td>
-                    </tr>
-                  </tfoot>
-                  <tbody>
-                    [% FOREACH subscription IN closedsubscriptions %]
-                    [% UNLESS subscription.cannotdisplay %]
-                      <tr>
-                        <td>
-                          [% IF ( subscription.issn ) %]
-                            [% subscription.issn %]
-                          [% END %]
-                        </td>
-                        <td>
-                          <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid %]" class="button" title="subscription detail">[% subscription.title |html %]</a>
-                        </td>
-                        <td>
-                          [% IF ( subscription.notes ) %][% subscription.notes %][% END %]
-                          [% IF ( subscription.internalnotes ) %]([% subscription.internalnotes %])[% END %]
-                        </td>
-                        <td>
-                          [% IF ( subscription.branchcode ) %][% Branches.GetName( subscription.branchcode ) %][% END %]
-                        </td>
-                        <td>
-                          [% IF ( subscription.location ) %][% AuthorisedValues.GetByCode( 'LOC', subscription.location ) %][% END %]
-                        </td>
-                        <td>
-                          [% IF ( subscription.callnumber ) %][% subscription.callnumber %][% END %]
-                        </td>
-                        <td>
-                          [% UNLESS subscription.cannotedit %]
-                            <a href="/cgi-bin/koha/serials/serials-search.pl?subscriptionid=[% subscription.subscriptionid %]&amp;op=reopen&amp;routing=[% subscription.routing %]&amp;searched=1&amp;title_filter=[% title_filter %]&amp;ISSN_filter=[% ISSN_filter %]&amp;EAN_filter=[% EAN_filter %]&amp;published_filter=[% publisher_filter %]&amp;bookseller_filter=[% bookseller_filter %]&amp;branch_filter=[% branch_filter %]" id="reopensub">Reopen</a>
-                          [% ELSE %]
-                            Cannot edit
-                          [% END %]
-                        </td>
-                        <td>
-                          <a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]">Issue history</a>
-                        </td>
-                      </tr>
-                    [% END %]
-                    [% END %]
-                  </tbody>
-                </table>
+                [% INCLUDE subscriptions_table subscriptions = closedsubscriptions closed = 1 %]
               [% ELSE %]
                 <div class="dialog message">
                   <p>Your search returned no closed subscriptions.</p>
                 </div>
               [% END %]
             </div>
+            [% END %]
           </div>
         [% ELSE %]
             <div class="dialog message">
             </div>
         [% END %]
       [% END %]
-    </div>
-  </div>
 
-  <div class="yui-b">
+            </main>
+        </div> <!-- /.col-sm-10.col-sm-push-2 -->
+
+        <div class="col-sm-2 col-sm-pull-10">
+            <aside>
+
     [% INCLUDE 'serials-menu.inc' %]
     [% IF ( done_searched ) %]
+    [% UNLESS ( mana ) %]
     <div id="advsearch">
         <form action="/cgi-bin/koha/serials/serials-search.pl" method="get">
           <fieldset class="brief">
               <ol>
                 <li>
                   <label for="issn">ISSN:</label>
-                  <input type="text" id="issn" name="ISSN_filter" value="[% ISSN_filter %]" />
+                  <input type="text" id="issn" name="ISSN_filter" value="[% ISSN_filter | html %]" />
                 </li>
                 <li>
                   <label for="title">Title:</label>
-                  <input type="text" id="title" name="title_filter" value="[% title_filter %]" />
+                  <input type="text" id="title" name="title_filter" value="[% title_filter | html %]" />
                 </li>
                 [% IF ( marcflavour == "UNIMARC" ) %]
                 <li>
                   <label for="ean">EAN:</label>
-                  <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter %]" />
+                  <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter | html %]" />
                 </li>
                 [% END %]
                 <li>
                   <label for="callnumber">Call number:</label>
-                  <input type="text" id="callnumber" name="callnumber_filter" value="[% callnumber_filter %]" />
+                  <input type="text" id="callnumber" name="callnumber_filter" value="[% callnumber_filter | html %]" />
                 </li>
                 <li>
                   <label for="publisher">Publisher:</label>
-                  <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter %]" />
+                  <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter | html %]" />
                 </li>
                 <li>
                   <label for="bookseller">Vendor:</label>
-                  <input type="text" id="bookseller" name="bookseller_filter" value="[% bookseller_filter %]" />
+                  <input type="text" id="bookseller" name="bookseller_filter" value="[% bookseller_filter | html %]" />
                 </li>
                 <li>
                   <label for="branch">Library:</label>
                   <select id="branch" name="branch_filter">
                     <option value="">All</option>
-                    [% FOREACH branch IN branches_loop %]
-                      [% IF ( branch.selected ) %]
-                        <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
-                      [% ELSE %]
-                        <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
-                      [% END %]
-                    [% END %]
+                    [%# FIXME Should not we filter the libraries? %]
+                    [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
                   </select>
                 </li>
-                [% IF locations %]
-                  <li>
-                    <label for="location">Location:</label>
-                    <select name="location_filter">
-                      <option value="">All</option>
-                      [% FOR loc IN locations %]
-                        [% IF loc.selected %]
-                          <option value="[% loc.authorised_value %]" selected="selected">[% loc.lib %]</option>
-                        [% ELSE %]
-                          <option value="[% loc.authorised_value %]">[% loc.lib %]</option>
-                        [% END %]
-                      [% END %]
-                    </select>
-                  </li>
-                [% END %]
+                <li>
+                  <label for="location">Location:</label>
+                  [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %]
+                </li>
                 <li>
                   <label for="to">Expires before:</label>
                   <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
                 </li>
 
+                [% FOR field IN additional_fields_for_subscription %]
+                  <li>
+                    <label for="additional_field_[% field.id | html %]ID"> [% field.name | html %]: </label>
+                    [% IF field.authorised_value_category %]
+                      <select id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]">
+                        <option value="">All</option>
+                        [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox(field.authorised_value_category) %]
+                          [% IF av.authorised_value == additional_field_filters.${field.id} %]
+                            <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
+                          [% ELSE %]
+                            <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
+                          [% END %]
+                        [% END %]
+                      </select>
+                    [% ELSE %]
+                      <input id="additional_field_[% field.id | html %]" type="text" value="[% additional_field_filters.${field.id} | html %]" name="additional_field_[% field.id | html %]" />
+                    [% END %]
+                  </li>
+                [% END %]
               </ol>
               <input type="hidden" name="searched" value="1" />
               <fieldset class="action">
                 <input type="submit" value="Search" />
               </fieldset>
+
             </div>
           </fieldset>
         </form>
       [% END %]
-  </div>
-</div>
+      [% END %]
+            </aside>
+        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
+     </div> <!-- /.row -->
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'calendar.inc' %]
+    [% INCLUDE 'datatables.inc' %]
+    <script>
+        var subscriptionid = "[% subscriptionid | html %]";
+        var MSG_CLOSE_SUBSCRIPTION = _("Are you sure you want to close this subscription?");
+        var MSG_REOPEN_SUBSCRIPTION = _("Are you sure you want to reopen this subscription?");
+        var CONFIRM_DELETE_SUBSCRIPTION = _("Are you sure you want to delete this subscription?");
+    </script>
+    [% Asset.js("js/serials-toolbar.js") | $raw %]
+    <script>
+
+            function itemSelectionBuildEditLink(div) {
+                var subscription_ids = new Array();
+                $("input[name='subscriptionid'][type='checkbox']:checked", div).each(function() {
+                    subscription_ids.push($(this).val());
+                });
+                if (subscription_ids.length > 0) {
+                    var url = "[% edit_action_link | html %]";
+                    url += '&subscriptionid=' + subscription_ids.join('&subscriptionid=');
+                    $('a.itemselection_action_modify').attr('href', url);
+                } else {
+                    return false;
+                }
+                return true;
+            }
+
+            function itemSelectionBuildActionLinks(tab) {
+                var div = $("#" + tab);
+                var modify_link_ok = itemSelectionBuildEditLink(div);
+                if (modify_link_ok) {
+                    $('.itemselection_actions', div).show();
+                } else {
+                    $('.itemselection_actions', div).hide();
+                }
+            }
+
+        $(document).ready(function() {
+            var osrlt = $("#opened table").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sPaginationType": "four_button",
+                "order": [[ 2, "asc" ]],
+                "aoColumnDefs": [
+                    { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
+                    { "sType": "title-string", "aTargets" : [ "title-string" ] },
+                    { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
+                ]
+            }));
+
+            var csrlt = $("#closed table").dataTable($.extend(true, {}, dataTablesDefaults, {
+                // FIXME sort function of additional_fields!
+                "order": [[ 2, "asc" ]],
+                "sPaginationType": "four_button",
+                "aoColumnDefs": [
+                    { 'bSortable': false, 'aTargets': [ 'NoSort' ] },
+                    { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
+                ]
+            }));
+
+            var manarlt = $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sPaginationType": "four_button",
+                "aoColumnDefs": [
+                    { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
+                    { "sType": "title-string", "aTargets" : [ "title-string" ] },
+                    { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
+                ]
+            }));
+
+            osrlt.fnAddFilters("dt-filter", 750);
+            csrlt.fnAddFilters("dt-filter", 750);
+            manarlt.fnAddFilters("dt-filter", 750);
+
+            $('#serialstabs').tabs();
+            $("#reopensub").click(function(){
+                return confirm(_("Are you sure you want to reopen this subscription?"));
+            });
+
+            $('.select-all, .clear-all').on('click', function(e) {
+                e.preventDefault();
+                var checkboxes = $(this).parents('form').find('input[type="checkbox"]');
+                checkboxes.prop('checked', $(this).hasClass('select-all'));
+                var tab = $(this).data("tab");
+                itemSelectionBuildActionLinks(tab);
+            });
+
+            itemSelectionBuildActionLinks("opened");
+            itemSelectionBuildActionLinks("closed");
+            $("input[name='subscriptionid'][type='checkbox']").change(function() {
+                var div = $(this).parents('form').parent().attr("id");
+                itemSelectionBuildActionLinks(div);
+            });
+
+            [% IF ( mana ) %]
+                $("label[for=callnumber], input#callnumber").hide();
+                $("label[for=bookseller], input#bookseller").hide();
+                $("label[for=branch], select#branch").hide();
+                $("label[for=to], input#to").hide();
+                $(".ui-datepicker-trigger").hide();
+                $("label[for=location], select#location_filter").hide();
+                [% FOR field IN additional_fields_for_subscription %]
+                      $("label[for=additional_field_[% field.id | $raw %]], input#additional_field_[% field.id | $raw %]").hide();
+                [% END %]
+            [% END %]
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]