Bug 21943: Clean up holds template
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reserve / request.tt
index 85f687a..c33f33f 100644 (file)
+[% USE raw %]
+[% USE Asset %]
 [% USE Koha %]
 [% USE KohaDates %]
+[% USE Branches %]
+[% USE Categories %]
+[% USE ItemTypes %]
+[% USE AuthorisedValues %]
+[% USE Price %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 [% UNLESS ( multi_hold ) %]
-    <title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Place a hold on [% title |html %]</title>
+    <title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Place a hold on [% title | html %]</title>
 [% ELSE %]
     <title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Confirm holds</title>
 [% END %]
 [% INCLUDE 'doc-head-close.inc' %]
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-[% INCLUDE 'calendar.inc' %]
-<script type="text/javascript">
-    // <![CDATA[
-var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
-var patron_homebranch = "[% borrower_branchname |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
-var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
-    [% itemloo.itemnumber %]: {
-        homebranch: "[% itemloo.homebranchname |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
-        holdallowed: [% itemloo.holdallowed %]
-    },
-[% END %][% END %][% END %]
-};
-var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
-
-$(document).ready(function() {
-    [% IF AutoResumeSuspendedHolds %]
-        $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
-    [% END %]
-
-    var table = $("#table_borrowers").dataTable($.extend(true, {}, dataTablesDefaults, {
-        "aoColumnDefs": [
-            { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
-        ],
-        "aaSorting": [[ 2, "asc" ]],
-        "sDom": "t",
-        "iDisplayLength": -1
-    }));
-    $(table).find('tbody tr').filter(':has(:radio:checked)').end().click(function(event) {
-        $('#table_borrowers tbody tr').removeClass('selected');
-        $(this).addClass('selected');
-        if (event.target.type !== 'radio') {
-            $(':radio', this).attr('checked', 'true')
-        }
-    });
-    var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
-        'bPaginate': false,
-        "sDom": '<"top pager"ilf>t',
-        "aoColumnDefs": [
-            { "sType": "title-string", "aTargets" : [ "title-string" ] }
-        ]
-    }));
-
-    //Override fieldset styling for dataTables search box
-    $("div.top.pager").css("margin-left","1em");
-    $(".dataTables_filter label").css({
-        "width":"auto",
-        "margin-right":"0em"
-    });
-
-});
-
-function check() {
-       var msg = "";
-       var count_reserv = 0;
-       var alreadyreserved = 0;
-
-    // check if we have checkitem form
-    if (document.form.checkitem){
-        for (i=0;i<document.form.checkitem.length;i++){
-            if (document.form.checkitem[i].checked == true) {
-                               count_reserv++ ;
-                       }
-        }
-        // for only one item, check the checkitem without consider the loop checkitem
-        if (i==0){
-                   if (document.form.checkitem.checked == true) {
-                           count_reserv++;
-                   }
-           }
-    }
-
-    if (document.form.request.checked == true){
-               count_reserv++ ;
-    }
-
-    if (document.form.alreadyreserved && document.form.alreadyreserved.value == "1"){
-                alreadyreserved++ ;
-    }
-
-    if (count_reserv == "0"){
-               msg += (_("- Please select an item to place a hold") + "\n");
-    }
-    if (count_reserv >= "2"){
-               msg += (_("- You may only place a hold on one item at a time") + "\n");
-    }
-
-    if (alreadyreserved > "0"){
-               msg += (_("- This patron had already placed a hold on this item") + "\n" + _("Please cancel the previous hold first") + "\n");
-    }
-
-       if (msg == "") return(true);
-       else    {
-               alert(msg);
-               return(false);
-       }
-}
-
-function checkMultiHold() {
-    var spans = $(".multi_hold_item");
-    if ($(spans).size() == 0) {
-        alert(MSG_NO_ITEMS_AVAILABLE);
-        return false;
-    }
-
-    var biblionumbers = "";
-    $(spans).each(function() {
-        var bibnum = $(this).attr("title");
-        biblionumbers += bibnum + "/";
-    });
-
-    var badSpans = $(".not_holdable");
-    var badBibs = "";
-    $(badSpans).each(function() {
-        var bibnum = $(this).attr("title");
-        badBibs += bibnum + "/";
-    });
-
-    $("#multi_hold_bibs").val(biblionumbers);
-    $("#bad_bibs").val(badBibs);
-
-    return true;
-}
-
- $(document).ready(function() {
-    $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
-        var itemnumber = this.value;
-        var msg = '';
-
-        switch (override_items[itemnumber].holdallowed) {
-            case 0: msg = _("This item normally cannot be put on hold."); break;
-            case 1: msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
-        }
-
-        msg += "\n\n" + _("Place hold on this item?");
-
-        return confirm(msg);
-    });
-    $("input.warning").click(function() {
-        return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
-    });
-       $("#requestany").click(function() {
-               if(this.checked){
-               $("input[name=checkitem]").each(function() {
-            $(this).removeAttr("checked");
-               });
-               }
-       });
-       $("input[name=checkitem]").click(function() {
-               onechecked = 0;
-               $("input[name=checkitem]").each(function() {
-                       if(this.checked){
-                               onechecked = 1;
-                       }
-               });
-               if(onechecked == 1){
-            $("#requestany").removeAttr("checked");
-               } else {
-                       $("#requestany").attr("checked","checked");
-               }
-       });
-
-    $(".clear-date").on("click",function(e){
-        e.preventDefault();
-        var fieldID = this.id.replace("clear-date-","");
-        $("#" + fieldID).val("");
-    });
-
-    $('#hold-request-form').preventDoubleFormSubmit();
-
-[% UNLESS ( borrowernumber || borrowers || noitems ) %]
-    [% IF ( CircAutocompl ) %]
-    $( "#patron" ).autocomplete({
-        source: "/cgi-bin/koha/circ/ysearch.pl",
-        minLength: 3,
-        select: function( event, ui ) {
-            $( "#patron" ).val( ui.item.cardnumber );
-            $( "#holds_patronsearch" ).submit();
-            return false;
-        }
-    })
-    .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
-        return $( "<li></li>" )
-        .data( "ui-autocomplete-item", item )
-        .append( "<a>" + item.surname + ", " + item.firstname +
-                 " (" + item.cardnumber + ") <small>" + item.address +
-                 " " + item.city + " " + item.zipcode + " " +
-                 item.country + "</small></a>" )
-        .appendTo( ul );
-    };
-    [% END %]
-[% END %]
-
- });
-
-// ]]>
-</script>
 </head>
+
 <body id="circ_request" class="catalog">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'circ-search.inc' %]
 
 [% UNLESS ( multi_hold ) %]
-    <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]">[% title |html %]</a> &rsaquo; Place a hold on [% title |html %]</div>
+    <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | html %]">[% title | html %]</a> &rsaquo; Place a hold on [% title | html %]</div>
 [% ELSE %]
     <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo; Confirm holds</div>
 [% END %]
 
- <div id="doc3" class="yui-t2">
+<div class="main container-fluid">
+    <div class="row">
+        [% IF ( multi_hold ) # No sidebar menu when placing multiple holds %]
+            <div class="col-md-10 col-md-offset-1">
+        [% ELSE %]
+            <div class="col-sm-10 col-sm-push-2">
+        [% END %]
+            <main>
 
-   <div id="bd">
-       <div id="yui-main">
-       <div class="yui-b">
 [% IF ( noitems ) %]
     <div class="dialog alert">
     [%IF (multi_hold) %]
@@ -233,8 +48,8 @@ function checkMultiHold() {
 
   [% IF ( messagetransfert ) %]
                <div class="dialog message">
-                               <h2>Hold found for ([% nextreservtitle %]), please transfer</h2>
-                       <p>Hold placed by : <strong> [% nextreservsurname %] [% nextreservfirstname %]</strong> at : <strong> [% branchname %] </strong>, Please transfer this item.
+                               <h2>Hold found for ([% nextreservtitle | html %]), please transfer</h2>
+                       <p>Hold placed by : <strong> [% nextreservsurname | html %] [% nextreservfirstname | html %]</strong> at : <strong> [% branchname | html %] </strong>, Please transfer this item.
                        </p>
                        <form name="cancelReservewithtransfert" action="branchreserves.pl" method="post">
                                <input type="submit" class="button" />
@@ -243,108 +58,96 @@ function checkMultiHold() {
   [% END %]
 
   [% UNLESS ( multi_hold ) %]
-    <h1>Place a hold on [% INCLUDE 'biblio-default-view.inc' %][% title |html %]</a></h1>
+    <h1>Place a hold on [% INCLUDE 'biblio-default-view.inc' %][% title | html %]</a></h1>
   [% ELSE %]
     <h1>Confirm holds</h1>
   [% END %]
 
-  [% UNLESS borrowernumber OR noitems %]
+  [% UNLESS patron OR patron.borrowernumber OR noitems %]
     [% IF ( messageborrower ) %]
       <div class="dialog alert"><h3>Patron not found</h3><p>No patron with this name, please, try another</p> </div>
     [% END %]
-    <form  id="holds_patronsearch" action="request.pl?biblionumber=[% biblionumber %]" method="post">
+    <form  id="holds_patronsearch" action="request.pl?biblionumber=[% biblionumber | html %]" method="post">
+        <fieldset id="circ_holds_selectborrower" class="brief">
+
         [% UNLESS borrowers %]
-            <fieldset class="brief">
                 <label for="patron">Patron: </label>
                 <div class="hint">Enter patron card number or partial name:</div>
-                <input type="text" size="40" id="patron" class="focus" name="findborrower" />
+                <input type="text" size="40" id="patron" class="focus" name="findborrower" autocomplete="off" />
                 <input type="submit" value="Search" />
-                <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
+            [% IF multi_hold %]
+                <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
+                <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
+            [% ELSE %]
+                <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
+            [% END %]
             </fieldset>
         [% ELSE %]
-          <fieldset>
-            <table id="table_borrowers">
-                <thead>
-                    <tr>
-                        <th></th>
-                        <th>Name</th>
-                        <th>Cardnumber</th>
-                        <th>Category</th>
-                        <th>Library</th>
-                        <th>Address</th>
-                    </tr>
-                </thead>
-                <tbody>
-                    [% FOREACH borrower IN borrowers %]
-                    <tr>
-                        <td><input type="radio" name="borrowernumber" value="[% borrower.borrowernumber %]" /></td>
-                        <td>[% borrower.surname %], [% borrower.firstname %]</td>
-                        <td>[% borrower.cardnumber %]</td>
-                        <td>[% borrower.categorycode %]</td>
-                        <td>[% borrower.branchcode %]</td>
-                        <td>[% borrower.address %]</td>
-                    </tr>
-                    [% END %]
-                </tbody>
-            </table>
-            <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
-            <fieldset class="action"><input type="submit" value="Select" /></fieldset>
+            [% INCLUDE 'circ-patron-search-results.inc' destination = "holds" %]
           </fieldset>
 
         [% END %]
         [% IF ( multi_hold ) %]
-            <input type="hidden" name="multi_hold" value="[% multi_hold %]"/>
-            <input type="hidden" name="biblionumbers" value="[% biblionumbers %]"/>
+            <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
+            <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
         [% END %]
     </form>
   [% ELSIF NOT noitems %]
 
-[% IF ( exceeded_maxreserves || alreadyreserved || none_available || alreadypossession || ageRestricted ) %]
+[% IF ( exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %]
     <div class="dialog alert">
 
     [% UNLESS ( multi_hold ) %]
       <h3>Cannot place hold</h3>
       <ul>
         [% IF ( exceeded_maxreserves ) %]
-          <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can only place a maximum of [% maxreserves %] total holds.</li>
+          <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can only place a maximum of [% maxreserves | html %] total holds.</li>
+        [% ELSIF ( exceeded_holds_per_record ) %]
+          <li><strong>Too many holds for this record: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can only place a maximum of [% max_holds_for_record | html %] hold(s) on this record.</li>
         [% ELSIF ( alreadypossession ) %]
-          <li> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>is already in possession</strong> of one item</li>
+          <li> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> <strong>is already in possession</strong> of one item.</li>
         [% ELSIF ( alreadyreserved ) %]
-          <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>already has a hold</strong> on this item </li>
+          <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> <strong>already has a hold</strong> on this item.</li>
         [% ELSIF ( ageRestricted ) %]
           <li><strong>Age restricted</strong></li>
         [% ELSIF ( none_available ) %]
-          <li> <strong>No items are available</strong> to be placed on hold</li>
+          <li> <strong>No items are available</strong> to be placed on hold.</li>
         [% ELSIF ( maxreserves ) %]
-          <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> has too many holds.</li>
+          <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> has too many holds.</li>
         [% END %]
       </ul>
     [% ELSE %]
         <h3>Cannot place hold on some items</h3>
         [% IF ( exceeded_maxreserves ) %]
-          <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can place [% new_reserves_allowed %] of the requested [% new_reserves_count %] holds for a maximum of [% maxreserves %] total holds.</li>
+          <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can place [% new_reserves_allowed | html %] of the requested [% new_reserves_count | html %] holds for a maximum of [% maxreserves | html %] total holds.</li>
+        [% ELSIF ( exceeded_holds_per_record ) %]
+            [% FOREACH biblioloo IN biblioloop %]
+                [% IF (biblioloo.tooManyHoldsForThisRecord) %]
+                    <li><strong>Too many holds for <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]"> [% biblioloo.title | html %]</a>: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can only place a maximum of [% max_holds_for_record | html %] hold(s) on this record.</li>
+                [% END %]
+            [% END %]
         [% END %]
     [% END %]
 
     </div>
 [% END %]
 
-[% IF ( expiry || diffbranch ) %]
+[% IF ( expiry || diffbranch || patron.is_debarred || ( amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') ) ) %]
 <div class="dialog message"><ul>
     [% IF ( expiry ) %]
-    <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a>'s <strong>account has expired</strong></li>
+    <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Account has expired</strong></li>
     [% END %]
 
-    [% IF restricted %]
-    <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]#reldebarments">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>has restrictions</strong></li>
+    [% IF patron.is_debarred %]
+    <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]#reldebarments">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Patron has restrictions</strong></li>
     [% END %]
 
     [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
-    <li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>owes [% amount_outstanding | format('%.2f') %]</strong></li>
+    <li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Patron has outstanding fines: [% amount_outstanding | $Price %]</strong></li>
     [% END %]
 
     [% IF ( diffbranch ) %]
-    <li> <strong>Pickup library is different</strong> than <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a>'s home library ([% borrower_branchname %] / [% borrower_branchcode %] )</li>
+    <li> <strong>Pickup library is different. </strong>Patron: <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> Patron's home library: ([% Branches.GetName(patron.branchcode) | html %] / [% patron.branchcode | html %] )</li>
     [% END %]
 
 </ul></div>
@@ -362,27 +165,27 @@ function checkMultiHold() {
             <form action="placerequest.pl" method="post" onsubmit="return checkMultiHold();" name="form">
         [% END %]
 
-        <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+        <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
         <input type="hidden" name="type" value="str8" />
 
         [% IF ( multi_hold ) %]
-            <input type="hidden" name="multi_hold" value="[% multi_hold %]"/>
-            <input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="[% biblionumbers %]"/>
+            <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
+            <input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="[% biblionumbers | html %]"/>
             <input type="hidden" name="bad_bibs" id="bad_bibs" value=""/>
             <input type="hidden" name="request" value="any"/>
             [% FOREACH biblioloo IN biblioloop %]
-              <input type="hidden" name="title_[% biblioloo.biblionumber %]" value="[% biblioloo.title |html %]"/>
-              <input type="hidden" name="rank_[% biblioloo.biblionumber %]" value="[% biblioloo.rank %]"/>
+              <input type="hidden" name="title_[% biblioloo.biblionumber | html %]" value="[% biblioloo.title | html %]"/>
+              <input type="hidden" name="rank_[% biblioloo.biblionumber | html %]" value="[% biblioloo.rank | html %]"/>
             [% END %]
         [% ELSE %]
-            <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
-            <input type="hidden" name="title" value="[% title |html %]" />
-            <input type="hidden" name="rank-request" value="[% fixedRank %]" />
+            <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
+            <input type="hidden" name="title" value="[% title | html %]" />
+            <input type="hidden" name="rank-request" value="[% fixedRank | html %]" />
         [% END %]
 
        <ol> <li><span class="label">Patron:</span>
-            [% IF ( borrowernumber ) %]
-                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] ([% cardnumber %])</a>
+            [% IF ( patron.borrowernumber ) %]
+                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] ([% patron.cardnumber | html %])</a>
             [% ELSE %]
                 Not defined yet
             [% END %]
@@ -390,7 +193,7 @@ function checkMultiHold() {
         [% UNLESS ( multi_hold ) %]
           <li>
               <span class="label">Estimated priority:</span>
-              <strong>[% fixedRank %]</strong>
+              <strong>[% fixedRank | html %]</strong>
           </li>
         [% END %]
         <li>
@@ -400,42 +203,66 @@ function checkMultiHold() {
         <li>
             <label for="pickup">Pickup at:</label>
             <select name="pickup" size="1" id="pickup">
-            [%- FOREACH branchloo IN branchloop %]
-              [% IF ( branchloo.selected ) -%]
-                <option value="[% branchloo.branchcode %]" selected="selected">[% branchloo.branchname %]</option>
-              [%- ELSE -%]
-                <option value="[% branchloo.branchcode %]">[% branchloo.branchname %]</option>
-              [%- END -%]
-            [%- END %]
+                [% PROCESS options_for_libraries libraries => Branches.all({ selected => pickup, search_params => { pickup_location => 1 } }) %]
             </select>
         </li>
 
+        [% UNLESS ( multi_hold ) %]
+            [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
+                <li>
+                    <label for="itemtype">Request specific item type:</label>
+                    <select name="itemtype" size="1" id="itemtype">
+                        <option value="">Any item type</option>
+                        [%- FOREACH itemtype IN available_itemtypes %]
+                            <option value="[% itemtype | html %]">[% ItemTypes.GetDescription( itemtype ) | html %]</option>
+                        [%- END %]
+                    </select>
+                </li>
+            [% END %]
+        [% END %]
+
        [% IF ( reserve_in_future ) %]
        <li>
         <label for="from">Hold starts on date:</label>
-        <input name="reserve_date" id="from" size="10" readonly="readonly" class="datepickerfrom">
+        <input name="reserve_date" id="from" size="10" class="datepickerfrom" type="text" >
         <a href="#" id="clear-date-from" class="clear-date">Clear date</a>
        </li>
        [% END %]
 
        <li>
         <label for="to">Hold expires on date:</label>
-        <input name="expiration_date" id="to" size="10" readonly="readonly" class="datepickerto" />
+        <input name="expiration_date" id="to" size="10" class="datepickerto" type="text" />
         <a href="#" id="clear-date-to" class="clear-date">Clear date</a>
        </li>
 
         [% UNLESS ( multi_hold ) %]
-          <li> <label for="requestany">Place a hold on the next available item </label>
-               <input type="checkbox" id="requestany" name="request" checked="checked" value="Any" />
-               <input type="hidden" name="biblioitem" value="[% biblioitemnumber %]" />
-               <input type="hidden" name="alreadyreserved" value="[% alreadyreserved %]" />
+          <li> <label for="requestany">Hold next available item </label>
+               [% IF force_hold_level == 'item' %]
+                   <input type="checkbox" id="requestany" name="request" disabled="true" />
+               [% ELSIF force_hold_level == 'record' %]
+                   <input type="checkbox" id="requestany" checked="checked" value="Any" disabled="true"/>
+                   <input type="hidden" name="request" value="Any"/>
+               [% ELSE %]
+                   <input type="checkbox" id="requestany" name="request" checked="checked" value="Any" />
+                [% END %]
+               <input type="hidden" name="biblioitem" value="[% biblioitemnumber | html %]" />
+               <input type="hidden" name="alreadyreserved" value="[% alreadyreserved | html %]" />
           </li>
+
+          [% IF remaining_holds_for_record > 1 %]
+              <li>
+                   <label for="holds_to_place_count">Holds to place (count)</label>
+                   <input type="number" name="holds_to_place_count" min="1" max="[% remaining_holds_for_record | html %]" step="1" value="1" />
+              </li>
+            [% ELSE %]
+                <input type="hidden" name="holds_to_place_count" value="1" />
+            [% END %]
         [% END %]
 
 </ol>
    [% UNLESS ( multi_hold ) %]
         <fieldset class="action">
-            [% IF ( borrowernumber ) %]
+            [% IF ( patron.borrowernumber ) %]
                 [% IF ( override_required ) %]
                     <input type="submit" class="warning" value="Place hold" />
                 [% ELSIF ( none_available ) %]
@@ -448,13 +275,18 @@ function checkMultiHold() {
         [% FOREACH bibitemloo IN bibitemloop %]
           <ol>
             [% UNLESS ( item_level_itypes ) %]
-              <li><span class="label">Item type:</span> [% bibitemloo.description %]</li>
+              <li><span class="label">Item type:</span> [% bibitemloo.description | html %]</li>
             [% END %]
 
-            [% IF ( bibitemloo.publicationyear ) %]<li><span class="label">Publication year:</span> [% bibitemloo.publicationyear %]</li>[% END %]
+            [% IF ( bibitemloo.publicationyear ) %]<li><span class="label">Publication year:</span> [% bibitemloo.publicationyear | html %]</li>[% END %]
           </ol>
 
-        <h2 style="padding: 0 1em;">Place a hold on a specific item</h2>
+        <h2 style="padding: 0 1em;">
+            Place a hold on a specific item
+            [% IF bibitemloo.force_hold_level == 'item' %]
+                <span class="error"><i>(Required)</i></span>
+            [% END %]
+        </h2>
         <table id="requestspecific">
             <thead>
                 <tr>
@@ -465,6 +297,9 @@ function checkMultiHold() {
                     <th>Barcode</th>
                     <th>Home library</th>
                     <th>Last location</th>
+                [% IF itemdata_ccode %]
+                    <th>Collection</th>
+                [% END %]
                     <th>Call no.</th>
                     <th>Copy number</th>
                 [% IF itemdata_enumchron %]
@@ -474,67 +309,101 @@ function checkMultiHold() {
                 </tr>
             </thead>
             <tbody>
+            [% SET selected = 0 %]
             [% FOREACH itemloo IN bibitemloo.itemloop %]
             [% UNLESS ( itemloo.hide ) %]
-                <tr class="[% itemloo.backgroundcolor %]">
+                <tr class="[% itemloo.backgroundcolor | html %]">
                     <td>
-                [% IF ( itemloo.available ) %]
-                    <input type="radio" name="checkitem" value="[% itemloo.itemnumber %]" />
+                [% IF itemloo.force_hold_level == 'record' # Patron has placed a record level hold previously for this record %]
+                    <span class="error">
+                        <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i>
+                        Hold must be record level
+                    </span>
+                [% ELSIF ( itemloo.available ) %]
+                    <input type="radio" name="checkitem" value="[% itemloo.itemnumber | html %]" />
                 [% ELSIF ( itemloo.override ) %]
-                    <input type="radio" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber %]" />
-                    <img src="[% interface %]/[% theme %]/img/famfamfam/silk/error.png" alt="Requires override of hold policy" />
+                    <input type="radio" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber | html %]" />
+                    <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" title="Requires override of hold policy"/></i>
                 [% ELSE %]
-                    <input disabled="disabled" type="radio" name="checkitem" value="[% itemloo.itemnumber %]" />
-                    <img src="[% interface %]/[% theme %]/img/famfamfam/silk/cross.png" alt="Cannot be put on hold" />
+                    <span class="error">
+                        <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i>
+                        [% IF itemloo.not_holdable %]
+                            [% IF itemloo.not_holdable == 'damaged' %]
+                                Item damaged
+                            [% ELSIF itemloo.not_holdable == 'ageRestricted' %]
+                                Age restricted
+                            [% ELSIF itemloo.not_holdable == 'tooManyHoldsForThisRecord' %]
+                                Exceeded max holds per record
+                            [% ELSIF itemloo.not_holdable == 'tooManyReservesToday' %]
+                                Daily hold limit reached for patron
+                            [% ELSIF itemloo.not_holdable == 'tooManyReserves' %]
+                                Too many holds
+                            [% ELSIF itemloo.not_holdable == 'notReservable' %]
+                                Not holdable
+                            [% ELSIF itemloo.not_holdable == 'cannotReserveFromOtherBranches' %]
+                                Patron is from different library
+                            [% ELSIF itemloo.not_holdable == 'itemAlreadyOnHold' %]
+                                Patron already has hold for this item
+                            [% ELSIF itemloo.not_holdable == 'cannotBeTransferred' %]
+                                Cannot be transferred to pickup library
+                            [% ELSE %]
+                                [% itemloo.not_holdable | html %]
+                            [% END %]
+                        [% END %]
+                    </span>
                 [% END %]
                     </td>
                 [% IF ( item_level_itypes ) %]
                     <td>
                     [% UNLESS ( noItemTypeImages ) %]
-                        [% IF ( itemloo.imageurl ) %]<img src="[% itemloo.imageurl %]" alt="" /> <br /> [% END %]
+                        [% IF ( itemloo.imageurl ) %]<img src="[% itemloo.imageurl | html %]" alt="" /> <br /> [% END %]
                     [% END %]
-                        [% itemloo.itypename %]
+                        [% itemloo.itypename | html %]
                     </td>
                 [% END %]
 
                     <td>
-                        [% itemloo.barcode %]
+                        [% itemloo.barcode | html %]
                     </td>
                     <td>
-                        [% itemloo.homebranchname %]
+                        [% Branches.GetName( itemloo.homebranch ) | html %]
                     </td>
                     <td>
-                        [% itemloo.holdingbranchname %]
+                        [% Branches.GetName( itemloo.holdingbranch ) | html %]
                     </td>
+                [% IF itemdata_ccode %]
                     <td>
-                        [% itemloo.itemcallnumber %]
+                        [% IF ( itemloo.ccode ) %][% AuthorisedValues.GetByCode( 'CCODE', itemloo.ccode ) | html %][% END %]
+                    </td>
+                [% END %]
+                    <td>
+                        [% itemloo.itemcallnumber | html %]
                     </td>
                     <td>
-                        [% IF ( itemloo.copynumber ) %][% itemloo.copynumber %][% ELSE %]&nbsp;[% END %]
+                        [% IF ( itemloo.copynumber ) %][% itemloo.copynumber | html %][% ELSE %]&nbsp;[% END %]
                     </td>
                 [% IF itemdata_enumchron %]
                     <td>
-                        [% itemloo.enumchron %]
+                        [% itemloo.enumchron | html %]
                     </td>
                 [% END %]
                     <td>
                 [% IF ( itemloo.onloan ) %]
-                    <span title="[% itemloo.date_due %]" class="checkedout">Due [% itemloo.date_due | $KohaDates as_due_date => 1 %]</span>
+                    <span title="[% itemloo.date_due | html %]" class="checkedout">Due [% itemloo.date_due | $KohaDates  as_due_date => 1 %]</span>
                 [% ELSE %]
                     <span title="0000-00-00">
                         [% IF ( itemloo.transfertwhen ) %]
-                            In transit from [% itemloo.transfertfrom %],
-                            to [% itemloo.transfertto %], since [% itemloo.transfertwhen %]
+                            In transit from [% Branches.GetName( itemloo.transfertfrom ) | html %],
+                            to [% Branches.GetName( itemloo.transfertto ) | html %], since [% itemloo.transfertwhen | html %]
                         [% END %]
                     </span>
                 [% END %]
-
                 [% IF ( itemloo.message ) %]
                    Unavailable (lost or missing)
                 [% END %]
 
                 [% IF ( itemloo.notforloan ) %]
-                   Not for loan ([% itemloo.notforloanvalue %])
+                   Not for loan ([% itemloo.notforloanvalue | html %])
                 [% END %]
 
                 [% IF ( itemloo.reservedate ) %]
@@ -542,14 +411,23 @@ function checkMultiHold() {
                             Can't be cancelled when item is in transit
                     [% ELSE %]
                     [% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
-                    [% IF ( itemloo.canreservefromotherbranches ) %]for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedForBorrowernumber %]">[% itemloo.ReservedForFirstname %] [% itemloo.ReservedForSurname %]</a>[% END %] [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %] [% itemloo.ExpectedAtLibrary %]
+                    [% IF ( itemloo.canreservefromotherbranches ) %]for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedFor.borrowernumber | uri %]">[% itemloo.ReservedFor.firstname | html %] [% itemloo.ReservedFor.surname | html %]</a>[% END %] [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %] [% Branches.GetName( itemloo.ExpectedAtLibrary ) | html %]
                     since
-                    [% IF ( itemloo.waitingdate ) %][% itemloo.waitingdate | $KohaDates %][% ELSE %][% IF ( itemloo.reservedate ) %][% itemloo.reservedate %][% END %][% END %]. <a class="info" href="modrequest.pl?CancelBiblioNumber=[% itemloo.biblionumber %]&amp;CancelBorrowerNumber=[% itemloo.ReservedForBorrowernumber %]&amp;CancelItemnumber=[% itemloo.itemnumber %]"  onclick="return confirmDelete(MSG_CONFIRM_DELETE_HOLD);">Cancel hold</a>
+                    [% IF ( itemloo.waitingdate ) %][% itemloo.waitingdate | $KohaDates %][% ELSE %][% IF ( itemloo.reservedate ) %][% itemloo.reservedate | html %][% END %][% END %]. <a class="info" href="modrequest.pl?CancelBiblioNumber=[% itemloo.biblionumber | html %]&amp;CancelBorrowerNumber=[% itemloo.ReservedFor.borrowernumber | html %]&amp;CancelItemnumber=[% itemloo.itemnumber | html %]"  onclick="return confirmDelete(MSG_CONFIRM_DELETE_HOLD);">Cancel hold</a>
 
                     [% END %]
-                 [% ELSE %]
+                [% ELSE %]
                     Not on hold
                 [% END %]
+
+                [% IF itemloo.item_level_holds == "N" %]
+                    <br/>Item level hold not allowed from OPAC
+                [% ELSIF itemloo.item_level_holds == "F" %]
+                    <br/>Item level hold forced from OPAC
+                [% END %]
+                [% IF ( itemloo.damaged ) %]
+                    <br />Damaged
+                [% END %]
                     </td>
                 </tr>
             [% END %] <!--UNLESS item hide-->
@@ -558,7 +436,7 @@ function checkMultiHold() {
         </table>
     [% IF ( bibitemloo.hiddencount ) %]
         <form>
-        <p class="hiddencount"><a href="request.pl?biblionumber=[% bibitemloo.biblionumber %]&amp;borrowernumber=[% bibitemloo.borrowernumber %]&amp;showallitems=1">Show all items ([% bibitemloo.hiddencount %] hidden)</a></p>
+        <p class="hiddencount"><a href="request.pl?biblionumber=[% bibitemloo.biblionumber | uri %]&amp;borrowernumber=[% bibitemloo.borrowernumber | uri %]&amp;showallitems=1">Show all items ([% bibitemloo.hiddencount | html %] hidden)</a></p>
         </form>
     [% END %] <!-- hiddencount -->
     [% END %] <!-- bibitemloop -->
@@ -582,23 +460,23 @@ function checkMultiHold() {
         [% END %]
           <td>
             <ul>
-              <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber %]">[% biblioloo.title |html %]</a></li>
+              <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">[% biblioloo.title | html %]</a></li>
               [% IF ( biblioloo.publicationyear ) %]
-                <li><span class="label">Publication year:</span> [% biblioloo.publicationyear %]</li>
+                <li><span class="label">Publication year:</span> [% biblioloo.publicationyear | html %]</li>
               [% END %]
             </ul>
             [% UNLESS ( biblioloo.warn ) %]
-              <span class="multi_hold_item" title="[% biblioloo.biblionumber %]"></span>
+              <span class="multi_hold_item" title="[% biblioloo.biblionumber | html %]"></span>
             [% ELSE %]
-              <span class="not_holdable" title="[% biblioloo.biblionumber %]"></span>
+              <span class="not_holdable" title="[% biblioloo.biblionumber | html %]"></span>
             [% END %]
           </td>
           [% UNLESS ( item_level_itypes ) %]
             <td>
-              <img src="[% biblioloo.imageurl %]" alt="[% biblioloo.itypename %]" title="[% biblioloo.itypename %]" />
+              <img src="[% biblioloo.imageurl | html %]" alt="[% biblioloo.itypename | html %]" title="[% biblioloo.itypename | html %]" />
             </td>
           [% END %]
-            <td>[% biblioloo.rank %]</td>
+            <td>[% biblioloo.rank | html %]</td>
           <td>
             [% IF ( biblioloo.alreadyres ) %]
               <ul>
@@ -609,7 +487,7 @@ function checkMultiHold() {
             [% END %]
 
           [% IF ( biblioloo.alreadyres ) %]
-              <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>already has a hold</strong> on this item </li>
+              <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> <strong>already has a hold</strong> on this item </li>
           [% END %]
           [% IF ( biblioloo.none_avail ) %]
               <li> <strong>No items are available</strong> to be placed on hold</li>
@@ -631,7 +509,7 @@ function checkMultiHold() {
   [% END %]<!-- /multi_hold -->
 
     <fieldset class="action">
-        [% IF ( borrowernumber ) %]
+        [% IF ( patron AND patron.borrowernumber ) %]
             [% IF ( override_required ) %]
                 <input type="submit" class="warning" value="Place hold" />
             [% ELSIF ( none_available ) %]
@@ -645,221 +523,375 @@ function checkMultiHold() {
        </fieldset>
 [% END %]
 
-[% UNLESS ( borrowernumber ) %]
-[% IF ( reserveloop ) %]
-<form name="T[% time %]" action="modrequest.pl" method="post">
-  [% IF ( multi_hold ) %]
-    <input type = "hidden" name="multi_hold" value="1"/>
-    <input type = "hidden" name="biblionumbers" value="[% biblionumbers %]"/>
-  [% END %]
+[% UNLESS ( patron ) %]
+    [% IF ( reserveloop ) %]
+        <form name="T[% time | html %]" action="modrequest.pl" method="post">
+            [% IF ( multi_hold ) %]
+                <input type = "hidden" name="multi_hold" value="1"/>
+                <input type = "hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
+            [% END %]
 
-<fieldset class="rows left">
-<legend>Existing holds</legend>
+            <fieldset class="rows left">
+                <legend>Existing holds</legend>
+
+                [% FOREACH biblioloo IN biblioloop %]
+                    [% IF ( biblioloo.reserveloop ) %]
+                        [% IF ( multi_hold ) %]
+                            <h3>
+                                <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">
+                                    [% biblioloo.title | html %]
+                                </a>
+                            </h3>
+                        [% END %]
 
-[% FOREACH biblioloo IN biblioloop %]
+                        [% IF Koha.Preference('HoldsSplitQueue') == 'branch' %]
+                            [% SET branchcodes = [] %]
+
+                            [% FOREACH h IN biblioloo.reserveloop %]
+                                [% branchcodes.push( h.branchcode ) %]
+                            [% END %]
+                            [% branchcodes = branchcodes.unique %]
+
+                            [% FOREACH b IN branchcodes.sort %]
+                                [% SET holds_by_branch = [] %]
+                                [% FOREACH h IN biblioloo.reserveloop %]
+                                    [% IF h.branchcode == b %]
+                                        [% holds_by_branch.push( h ) %]
+                                    [% END %]
+                                [% END %]
+                                <fieldset>
+                                    <legend>[% Branches.GetName( b ) | html %]</legend>
+                                    [% INCLUDE holds_table.inc holds=holds_by_branch %]
+                                </fieldset>
+                            [% END %]
+                        [% ELSIF Koha.Preference('HoldsSplitQueue') == 'itemtype' %]
+                            [% SET itemtypes = [] %]
+
+                            [% FOREACH h IN biblioloo.reserveloop %]
+                                [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
+                                [% itemtypes.push( hold_itemtype ) %]
+                            [% END %]
+                            [% itemtypes = itemtypes.unique %]
+
+                            [% FOREACH i IN itemtypes.sort %]
+                                [% SET holds_by_itemtype = [] %]
+                                [% FOREACH h IN biblioloo.reserveloop %]
+                                    [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
+                                    [% IF hold_itemtype == i %]
+                                        [% holds_by_itemtype.push( h ) %]
+                                    [% END %]
+                                [% END %]
+
+                                <fieldset>
+                                    [% IF i %]
+                                        <legend>[% ItemTypes.GetDescription( i ) | html %]</legend>
+                                    [% ELSE %]
+                                        <legend>Any item type</legend>
+                                    [% END %]
+                                    [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
+                                </fieldset>
+                            [% END %]
+                        [% ELSIF Koha.Preference('HoldsSplitQueue') == 'branch_itemtype' %]
+                            [% SET branchcodes = [] %]
+
+                            [% FOREACH h IN biblioloo.reserveloop %]
+                                [% branchcodes.push( h.branchcode ) %]
+                            [% END %]
+                            [% branchcodes = branchcodes.unique %]
+
+                            [% FOREACH b IN branchcodes.sort %]
+                                <fieldset class="contrast">
+                                    <legend>[% Branches.GetName( b ) | html %]</legend>
+                                    [% SET holds_by_branch = [] %]
+                                    [% FOREACH h IN biblioloo.reserveloop %]
+                                        [% IF h.branchcode == b %]
+                                            [% holds_by_branch.push( h ) %]
+                                        [% END %]
+                                    [% END %]
+
+                                    [% SET itemtypes = [] %]
+                                    [% FOREACH h IN holds_by_branch %]
+                                        [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
+                                        [% itemtypes.push( hold_itemtype ) %]
+                                    [% END %]
+                                    [% itemtypes = itemtypes.unique %]
+
+                                    [% FOREACH i IN itemtypes.sort %]
+                                        <fieldset class="standard">
+                                            [% IF i %]
+                                                <legend>[% ItemTypes.GetDescription( i ) | html %]</legend>
+                                            [% ELSE %]
+                                                <legend>Any item type</legend>
+                                            [% END %]
+
+                                            [% SET holds_by_itemtype = [] %]
+                                            [% FOREACH h IN holds_by_branch %]
+                                                [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
+                                                [% IF hold_itemtype == i %]
+                                                    [% holds_by_itemtype.push( h ) %]
+                                                [% END %]
+                                            [% END %]
+                                            [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
+                                        </fieldset>
+                                    [% END %]
+                                </fieldset>
+                            [% END %]
+                        [% ELSE %]
+                            [% INCLUDE holds_table.inc holds=biblioloo.reserveloop %]
+                        [% END %]
 
-    [% IF ( biblioloo.reserveloop ) %]
-    <table>
-      [% IF ( multi_hold ) %]
-          <caption><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber %]">[% biblioloo.title |html %]</a></caption>
-      [% END %]
-      <tr>
-        [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
-            <th>Priority</th>
-               <th>&nbsp;</th>
-        [% ELSE %]
-            <th>Delete?</th>
-        [% END %]
-        <th>Patron</th>
-        <th>Notes</th>
-        <th>Date</th>
-       <th>Expiration</th>
-        <th>Pickup library</th>
-        <th>Details</th>
-        [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
-            <th><img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Toggle set to lowest priority" /></th>
-        [% END %]
-       <th>&nbsp;</th>
-    [% IF SuspendHoldsIntranet %]<th>&nbsp;</th><!-- Suspend Holds Column Header -->[% END %]
-      </tr>
-  [% FOREACH reserveloo IN biblioloo.reserveloop %]
-  [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
-        <td>
-          <input type="hidden" name="reserve_id" value="[% reserveloo.reserve_id %]" />
-          <input type="hidden" name="borrowernumber" value="[% reserveloo.borrowernumber %]" />
-          <input type="hidden" name="biblionumber" value="[% reserveloo.biblionumber %]" />
-          <select name="rank-request">
-              [% IF ( reserveloo.wait ) %]
-                  [% IF ( reserveloo.intransit ) %]
-                      <option value="T" selected="selected">In transit</option>
-                  [% ELSE %]
-                      <option value="W" selected="selected">Waiting</option>
-                  [% END %]
-              [% END %]
+                    [% END %]<!-- /reserveloop -->
+                [% END %]<!-- /biblioloop -->
 
-              [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
-                  [% FOREACH optionloo IN reserveloo.optionloop %]
-                      [% IF ( optionloo.selected ) %]
-                          <option value="[% optionloo.num %]" selected="selected">[% optionloo.num %]</option>
-                      [% ELSE %]
-                          <option value="[% optionloo.num %]">[% optionloo.num %]</option>
-                      [% END %]
-                  [% END %]
-              [% ELSIF !reserveloo.wait %]
-                  <option value="[% reserveloo.priority %]" selected="selected">[% reserveloo.priority %]</option>
-              [% END %]
-              <option value="del">del</option>
-          </select>
-        </td>
-
-     [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
-        <td style="white-space:nowrap;">
-            <a title="Move hold up" href="request.pl?action=move&amp;where=up&amp;borrowernumber=[% reserveloo.borrowernumber %]&amp;biblionumber=[% reserveloo.biblionumber %]&amp;reserve_id=[% reserveloo.reserve_id %]&amp;date=[% reserveloo.date %]">
-            <img src="[% interface %]/[% theme %]/img/go-up.png" border="0" alt="Go up" />
-                </a>
-
-                <a title="Move hold to top" href="request.pl?action=move&amp;where=top&amp;borrowernumber=[% reserveloo.borrowernumber %]&amp;biblionumber=[% reserveloo.biblionumber %]&amp;reserve_id=[% reserveloo.reserve_id %]&amp;date=[% reserveloo.date %]">
-                    <img src="[% interface %]/[% theme %]/img/go-top.png" border="0" alt="Go top" />
-                </a>
-
-                <a title="Move hold to bottom" href="request.pl?action=move&amp;where=bottom&amp;borrowernumber=[% reserveloo.borrowernumber %]&amp;biblionumber=[% reserveloo.biblionumber %]&amp;reserve_id=[% reserveloo.reserve_id %]&amp;date=[% reserveloo.date %]">
-                    <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
-                </a>
-
-                <a title="Move hold down" href="request.pl?action=move&amp;where=down&amp;borrowernumber=[% reserveloo.borrowernumber %]&amp;biblionumber=[% reserveloo.biblionumber %]&amp;reserve_id=[% reserveloo.reserve_id %]&amp;date=[% reserveloo.date %]">
-                    <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Go down" />
-                </a>
-        </td>
+                <fieldset class="action">
+                    <input type="submit" name="submit" value="Update hold(s)" />
+                </fieldset>
+            </fieldset>
+        </form>
     [% END %]
+[% END %]
 
-        <td>
-          <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% reserveloo.borrowernumber %]" >
-         [% IF ( reserveloo.hidename ) %]
-             [% reserveloo.cardnumber (reserveloo.borrowernumber) %]
-         [% ELSE %]
-             [% reserveloo.firstname %] [% reserveloo.surname %]
-         [% END %]
-         </a>
-        </td>
-        <td>[% reserveloo.notes %]</td>
-        <td>[% reserveloo.date %]</td>
-        <td>
-            [% IF reserveloo.waiting_until %]
-                [% reserveloo.waiting_until | $KohaDates %]
-            [% ELSE %]
-                [% reserveloo.expirationdate %]
-            [% END %]
-        </td>
-        <td>
-    [% IF ( reserveloo.wait ) %]
-       [% IF ( reserveloo.atdestination ) %]
-            [% IF ( reserveloo.found ) %]
-                Item waiting at <b> [% reserveloo.wbrname %]</b> <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" /> since [% reserveloo.waiting_date | $KohaDates %]
-            [% ELSE %]
-                Waiting to be pulled <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" />
-            [% END %]
-          [% ELSE %]
-            Item being transferred to <b> [% reserveloo.wbrname %]</b> <input type="hidden" name="pickup" value="[% reserveloo.wbrcode %]" />
-         [% END %]
-    [% ELSE %]
-          <select name="pickup">
-      [% FOREACH branchloo IN reserveloo.branchloop %]
-        [% IF ( branchloo.selected ) %]
-            <option value="[% branchloo.branchcode %]" selected="selected">
+            </main>
+
+        [% IF ( multi_hold ) # No sidebar menu when placing multiple holds %]
+            </div> <!-- /.col-md-10.col-md-offset-1 -->
         [% ELSE %]
-            <option value="[% branchloo.branchcode %]">
+            </div> <!-- /.col-sm-10.col-sm-push-2 -->
+                <div class="col-sm-2 col-sm-pull-10">
+                    <aside>
+                            [% INCLUDE 'biblio-view-menu.inc' %]
+                    </aside>
+                </div> <!-- /.col-sm-2.col-sm-pull-10 -->
         [% END %]
-              [% branchloo.branchname %]
-            </option>
-      [% END %]
-          </select>
-    [% END %]
-        </td>
-        <td>
-    [% IF ( reserveloo.wait ) %]
-          <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% reserveloo.biblionumber %]">
-                [% IF ( reserveloo.barcodenumber ) %]
-                    [% reserveloo.barcodenumber %]
-                    <input type="hidden" name="itemnumber" value="[% reserveloo.itemnumber %]" />
-                [% ELSE %]
-                    No barcode
-                [% END %]
-          </a>
-    [% ELSE %]
-            [% IF ( reserveloo.item_level_hold ) %]
-                <i>Only item
-                <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% reserveloo.biblionumber %]">
-                     [% IF ( reserveloo.barcodenumber ) %]
-                         [% reserveloo.barcodenumber %]
-                        <input type="hidden" name="itemnumber" value="[% reserveloo.itemnumber %]" />
-                    [% ELSE %]
-                        No barcode
-                    [% END %]
-                </a>
-                </i>
-            [% ELSE %]
-                <i>Next available</i>
-                 <input type="hidden" name="itemnumber" value="" />
+    </div> <!-- /.row -->
+
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    [% INCLUDE 'calendar.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
+    [% Asset.js("js/circ-patron-search-results.js") | $raw %]
+    <script>
+        var biblionumber = "[% biblionumber | $raw %]";
+        var borrowernumber = "[% patron.borrowernumber | $raw %]";
+        var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
+        var patron_homebranch = "[% Branches.GetName( patron.branchcode ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html %]";
+        var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
+        [% itemloo.itemnumber | html %]: {
+            homebranch: "[% Branches.GetName( itemloo.homebranch ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html %]",
+            holdallowed: [% itemloo.holdallowed | html %]
+            },
+            [% END %][% END %][% END %]
+        };
+        var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
+        columns_settings_borrowers_table = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]
+
+        $(document).ready(function() {
+            function ToggleHoldsToPlace() {
+                if ( $("#requestany").prop('checked') ) {
+                    $("#holds_to_place_count").prop('disabled', false);
+                } else {
+                    $("#holds_to_place_count").prop('disabled', true);
+                }
+            }
+            ToggleHoldsToPlace();
+            $("#requestany").on('change', function(){
+                ToggleHoldsToPlace();
+            });
+
+            [% IF Koha.Preference('UseBranchTransferLimits') %]
+                $("#pickup").on('change', function(){
+                    var pickup = $("#pickup").val();
+                    var url = "?pickup=" + pickup;
+                    url += "&borrowernumber=" + borrowernumber;
+                    url += "&biblionumber=" + biblionumber;
+                    window.location.replace(url);
+                });
             [% END %]
-    [% END %]
-        </td>
-
-    [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
-       <td>
-                <a title="Toggle lowest priority" href="request.pl?action=setLowestPriority&amp;borrowernumber=[% reserveloo.borrowernumber %]&amp;biblionumber=[% reserveloo.biblionumber %]&amp;reserve_id=[% reserveloo.reserve_id %]&amp;date=[% reserveloo.date %]">
-                       [% IF ( reserveloo.lowestPriority ) %]
-                        <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Unset lowest priority" />
-                       [% ELSE %]
-                        <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Set to lowest priority" />
-                       [% END %]
-               </a>
-       </td>
-    [% END %]
-
-       <td>
-           <a title="Cancel hold" href="request.pl?action=cancel&amp;borrowernumber=[% reserveloo.borrowernumber %]&amp;biblionumber=[% reserveloo.biblionumber %]&amp;reserve_id=[% reserveloo.reserve_id %]&amp;date=[% reserveloo.date %]">
-                    <img src="[% interface %]/[% theme %]/img/x.png" border="0" alt="Cancel" />
-                </a>
-       </td>
-
-        [% IF SuspendHoldsIntranet %]
-       <td>
-       [% UNLESS ( reserveloo.wait ) %]
-            <input type="button" value="[% IF ( reserveloo.suspend ) %]Unsuspend[% ELSE %]Suspend[% END %]" onclick="window.location.href='request.pl?action=toggleSuspend&amp;reserve_id=[% reserveloo.reserve_id %]&amp;borrowernumber=[% reserveloo.borrowernumber %]&amp;biblionumber=[% reserveloo.biblionumber %]&amp;date=[% reserveloo.date %]&amp;suspend_until=' + $('#suspend_until_[% reserveloo.reserve_id %]').val()" />
 
             [% IF AutoResumeSuspendedHolds %]
-        <label for="suspend_until_[% reserveloo.reserve_id %]">[% IF ( reserveloo.suspend ) %] on [% ELSE %] until [% END %]</label>
-            <input name="suspend_until" id="suspend_until_[% reserveloo.reserve_id %]" size="10" readonly="readonly" value="[% reserveloo.suspend_until | $KohaDates %]" class="datepicker suspend_until_datepicker" />
-            <a href='#' onclick="document.getElementById('suspend_until_[% reserveloo.reserve_id %]').value='';">Clear date</a>
+                $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
             [% END %]
-       [% ELSE %]
-               <input type="hidden" name="suspend_until" value="" />
-       [% END %]
-       </td>
-        [% END # IF SuspendHoldsIntranet %]
 
-      </tr>
+            var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
+                'bPaginate': false,
+                "sDom": '<"top pager"ilf>t',
+                "aoColumnDefs": [
+                    { "sType": "title-string", "aTargets" : [ "title-string" ] }
+                ]
+            }));
+
+            //Override fieldset styling for dataTables search box
+            $("div.top.pager").css("margin-left","1em");
+            $(".dataTables_filter label").css({
+                "width":"auto",
+                "margin-right":"0em"
+            });
+
+        });
+
+        function check() {
+            var msg = "";
+            var count_reserv = 0;
+
+            // check if we have checkitem form
+            if (document.form.checkitem){
+                for (i=0;i<document.form.checkitem.length;i++){
+                    if (document.form.checkitem[i].checked == true) {
+                        count_reserv++ ;
+                    }
+                }
+                // for only one item, check the checkitem without consider the loop checkitem
+                if (i==0){
+                    if (document.form.checkitem.checked == true) {
+                        count_reserv++;
+                    }
+                }
+            }
+
+            if (document.form.requestany.checked == true){
+                count_reserv++ ;
+            }
+
+            if (count_reserv == "0"){
+                msg += (_("- Please select an item to place a hold") + "\n");
+            }
+
+            if (msg == "") {
+                $('#hold-request-form').preventDoubleFormSubmit();
+                return(true);
+            } else {
+                alert(msg);
+                return(false);
+            }
+        }
 
-  [% END %] <!-- existing reserveloop -->
-     </table>
-  [% END %]<!-- /reserveloop -->
-[% END %]<!-- /biblioloop -->
+        function checkMultiHold() {
+            var spans = $(".multi_hold_item");
+            if ($(spans).size() == 0) {
+                alert(MSG_NO_ITEMS_AVAILABLE);
+                return false;
+            }
 
-<fieldset class="action">
-  <input type="submit" name="submit" value="Update hold(s)" />
-</fieldset>
-</fieldset>
-</form>
-[% END %]
-[% END %]
-</div>
-</div>
+            var biblionumbers = "";
+            $(spans).each(function() {
+                var bibnum = $(this).attr("title");
+                biblionumbers += bibnum + "/";
+            });
 
-<div class="yui-b">
-[% UNLESS ( multi_hold ) %]
-  [% INCLUDE 'biblio-view-menu.inc' %]
+            var badSpans = $(".not_holdable");
+            var badBibs = "";
+            $(badSpans).each(function() {
+                var bibnum = $(this).attr("title");
+                badBibs += bibnum + "/";
+            });
+
+            $("#multi_hold_bibs").val(biblionumbers);
+            $("#bad_bibs").val(badBibs);
+
+            $('#hold-request-form').preventDoubleFormSubmit();
+
+            return true;
+        }
+
+         $(document).ready(function() {
+            $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
+                var itemnumber = this.value;
+                var msg = '';
+
+                switch (override_items[itemnumber].holdallowed) {
+                    case 0: msg = _("This item normally cannot be put on hold."); break;
+                    case 1: msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
+                }
+
+                msg += "\n\n" + _("Place hold on this item?");
+
+                return confirm(msg);
+            });
+            $("input.warning").click(function() {
+                return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
+            });
+            $("#requestany").click(function() {
+                if(this.checked){
+                    $("input[name=checkitem]").each(function() {
+                        $(this).prop("checked", false);
+                    });
+                }
+            });
+            $("input[name=checkitem]").click(function() {
+                onechecked = 0;
+                $("input[name=checkitem]").each(function() {
+                    if(this.checked){
+                        onechecked = 1;
+                    }
+                });
+                if(onechecked == 1){
+                    $("#requestany").prop("checked", false);
+                } else {
+                    $("#requestany").prop("checked",true);
+                }
+            });
+            var prev_rank_request;
+            $("select[name=rank-request]").on("focus", function() {
+                prev_rank_request = $(this).val();
+                var row = $(this).parents("tr:first");
+            }).change(function() {
+                var row = $(this).parents("tr:first");
+                var value = parseInt($(this).val());
+                var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found
+                if( !isNaN(value) ) {  //If moved to 'del'
+                    var after = row.parent().find("tr:nth-child("+(value+1+found_holds )+")"); //Go to the row 1 after the new value (and skip found holds)
+                    if (prev_rank_request > value) {
+                        row.insertBefore(after);
+                    } else {
+                        row.insertAfter(after);
+                    }
+                }
+
+                var next_priority = 1;
+                $("select[name=rank-request]").each(function () {
+                    if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds
+                    $(this).val(next_priority);
+                    next_priority++;
+                });
+            });
+
+            $(".clear-date").on("click",function(e){
+                e.preventDefault();
+                var fieldID = this.id.replace("clear-date-","");
+                $("#" + fieldID).val("");
+            });
+
+            // Confirm cancelation of hold
+            $(".cancel-hold").on("click",function(e) {
+                return confirmDelete(MSG_CONFIRM_DELETE_HOLD);
+            });
+
+            [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems ) %]
+                [% IF ( CircAutocompl ) %]
+                $( "#patron" ).autocomplete({
+                    source: "/cgi-bin/koha/circ/ysearch.pl",
+                    minLength: 3,
+                    select: function( event, ui ) {
+                        $( "#patron" ).val( ui.item.cardnumber );
+                        $( "#holds_patronsearch" ).submit();
+                        return false;
+                    }
+                })
+                .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
+                    return $( "<li></li>" )
+                    .data( "ui-autocomplete-item", item )
+                    .append( "<a>" + item.surname + ", " + item.firstname +
+                             " (" + item.cardnumber + ") <small>" + item.address +
+                             " " + item.city + " " + item.zipcode + " " +
+                             item.country + "</small></a>" )
+                    .appendTo( ul );
+                };
+                [% END %]
+            [% END %]
+
+        });
+    </script>
 [% END %]
 
-</div>
-</div>
 [% INCLUDE 'intranet-bottom.inc' %]