Bug 17171: (QA follow-up) Remove cardnumber template variable
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / circ / circulation.tt
index 545d0e8..4d0dc91 100644 (file)
@@ -1,3 +1,5 @@
+[% USE raw %]
+[% USE Asset %]
 [% USE Koha %]
 [% USE Branches %]
 [% USE KohaDates %]
 [% USE ColumnsSettings %]
 [% USE ItemTypes %]
 [% USE Price %]
-[% IF Koha.Preference('ExportRemoveFields') OR Koha.Preference('ExportWithCsvProfile') %]
-   [% SET exports_enabled = 1 %]
-[% END %]
 [% USE AuthorisedValues %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 [% SET destination = "circ" %]
 <title>Koha &rsaquo; Circulation
-[% IF borrowernumber and borrower%]
-  &rsaquo; Checking out to [% INCLUDE 'patron-title.inc' invert_name = 1 %]
+[% IF patron %]
+  &rsaquo; Checking out to [% INCLUDE 'patron-title.inc' invert_name = 1 no_html = 1 %]
 [% END %]
 </title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'calendar.inc' %]
-
-<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'strings.inc' %]
-[% INCLUDE 'datatables.inc' %]
-[% INCLUDE 'columns_settings.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js"></script>
-[% INCLUDE 'timepicker.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.rowGrouping.js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/pages/circulation.js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/checkouts.js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/holds.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-/* Set some variable needed in circulation.js */
-var MSG_DT_LOADING_RECORDS = _("Loading... you may continue scanning.");
-var interface = "[% interface %]";
-var theme = "[% theme %]";
-var borrowernumber = "[% borrowernumber %]";
-var branchcode = "[% branch %]";
-var exports_enabled = "[% exports_enabled %]";
-var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
-var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %];
-var script = "circulation";
-var relatives_borrowernumbers = new Array();
-[% FOREACH b IN relatives_borrowernumbers %]
-    relatives_borrowernumbers.push("[% b %]");
-[% END %]
-
-var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export");
-var MSG_CONFIRM_DELETE_MESSAGE = _("Are you sure you want to delete this message? This cannot be undone.");
-
-columns_settings = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'issues-table', 'json' ) %]
-
-[% IF borrowernumber and borrower %]
-    if($.cookie("holdfor") != [% borrowernumber %]){
-        $.removeCookie("holdfor", { path: '/' });
-    }
-[% ELSE %]
-    $.removeCookie("holdfor", { path: '/' });
-[% END %]
-
-[% UNLESS ( borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
-
-// On-site checkout
-function toggle_onsite_checkout(){
-    if ( $("#onsite_checkout").prop('checked') ) {
-        $("#duedatespec").val("[% todaysdate | $KohaDates with_hours => 1%]")
-        [% IF !Koha.Preference('SpecifyDueDate') %]
-            $("#duedatespec").datetimepicker('destroy');
-        [% END %]
-    } else {
-        $("#duedatespec").datetimepicker({
-            onClose: function(dateText, inst) { $("#barcode").focus(); },
-            hour: 23,
-            minute: 59
-        });
-    }
-}
-
-function Dopop(link) {
-    var newin = window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
-}
-$(document).ready(function() {
-    $('#mainform').on('submit',function() {
-        if ($("#barcode") && $("#barcode").val()) {
-            $('#barcode').on('keypress',function(event) {
-                $('#barcodeSubmittedModal').modal();
-                event.preventDefault(); }
-            );
-        }
-    });
-
-    [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
-        // listen submit to trigger qslip on empty checkout
-        $('#mainform').bind('submit',function() {
-            if ($('#barcode').val() == '') {
-                return printx_window( '[% CircAutoPrintQuickSlip %]' );
-            }
-        });
-    [% END %]
-    toggle_onsite_checkout();
-    $("#onsite_checkout").click(function(){
-        toggle_onsite_checkout();
-    });
-});
-
-//]]>
-</script>
 </head>
+
 <body id="circ_circulation" class="circ">
 
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'circ-search.inc' %]
 
 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo;
-[% IF borrowernumber and borrower %]
+[% IF patron %]
     <a href="/cgi-bin/koha/circ/circulation.pl">Checkouts</a> &rsaquo; [% INCLUDE 'patron-title.inc' %]
 [% ELSE %]
     <strong>Checkouts</strong>
@@ -134,29 +45,37 @@ $(document).ready(function() {
        <div class="yui-b">
 [% END %]
 
-[% IF borrowernumber and borrower %]
+[% IF patron %]
 [% INCLUDE 'members-toolbar.inc' %]
 [% END %]
 
 <!--  INITIAL BLOC : PARAMETERS & BORROWER INFO -->
 [% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% expiry | $KohaDates %]</div>[% END %]
 
+[% IF autoswitched %]
+    <div id="autoswitched" class="dialog message">Patron was automatically switched by reading the patron card during checking out. Ensure you are working with the right patron.</div>
+[% END %]
+
 [% IF additional_materials %]
     <div id="materials" class="dialog message">Note about the accompanying materials: <br />
-    [% additional_materials %]
+    [% additional_materials | html %]
     </div>
 [% END %]
 
 [% IF ( alert.ITEM_LOST ) %]
-    <div class="dialog message">This item has been lost with a status of "[% alert.ITEM_LOST %]".</div>
+    <div class="dialog message">This item has been lost with a status of "[% alert.ITEM_LOST | html %]".</div>
 [% END %]
 
 [% IF ( alert.OTHER_CHARGES ) %]
-    <div class="dialog message">The patron has unpaid charges for holds, rentals etc of [% alert.OTHER_CHARGES %]</div>
+    <div class="dialog message">The patron has unpaid charges for holds, rentals etc of [% alert.OTHER_CHARGES | $Price %]</div>
 [% END %]
 
 [% IF alert.HIGHHOLDS %]
-    <div class="dialog message">High demand item. <b>Loan period was not shortened due to override.</b> Shortened due date would have been [% alert.HIGHHOLDS.returndate %] ([% alert.HIGHHOLDS.duration %] days).</div>
+    <div class="dialog message">High demand item. <b>Loan period was not shortened due to override.</b> Shortened due date would have been [% alert.HIGHHOLDS.returndate | $KohaDates %] ([% alert.HIGHHOLDS.duration  | html %] days).</div>
+[% END %]
+
+[% IF alert.RETURNED_FROM_ANOTHER %]
+    <div class="dialog alert">Item was checked out to [% INCLUDE 'patron-title.inc' patron = alert.RETURNED_FROM_ANOTHER.patron %] and was returned automatically.</div>
 [% END %]
 
 [% IF ( nopermission ) %]
@@ -175,7 +94,7 @@ $(document).ready(function() {
 
 <ul>
 [%IF ( AGE_RESTRICTION ) %]
-    <li>Age restriction [% AGE_RESTRICTION %].
+    <li>Age restriction [% AGE_RESTRICTION | html %].
       [% IF CAN_user_circulate_force_checkout %]
         Check out anyway?
       [% END %]
@@ -183,7 +102,7 @@ $(document).ready(function() {
 [% END %]
 
 [% IF ( DEBT ) %]
-    <li>The patron has a debt of [% DEBT %].</li>
+    <li>The patron has a debt of [% DEBT | $Price %].</li>
 [% END %]
 
 [% IF ( DEBT_GUARANTEES ) %]
@@ -191,23 +110,23 @@ $(document).ready(function() {
 [% END %]
 
 [% IF ( RENTALCHARGE && RENTALCHARGE > 0 ) %]
-    <li>Rental charge for this item: [% RENTALCHARGE %]</li>
+    <li>Rental charge for this item: [% RENTALCHARGE | $Price %]</li>
 [% END %]
 
 [% IF ( RENEW_ISSUE ) %]
-    <li>Item <i>[% getTitleMessageIteminfo %]</i> ([% getBarcodeMessageIteminfo %]) is currently checked out to this patron.  Renew?</li>
+    <li>Item <i>[% getTitleMessageIteminfo | html %]</i> ([% getBarcodeMessageIteminfo | html %]) is currently checked out to this patron.  Renew?</li>
 [% END %]
 
 [% IF ( RESERVE_WAITING ) %]
-    <li>Item <i>[% getTitleMessageIteminfo %]</i> ([% getBarcodeMessageIteminfo %]) has been waiting for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resborrowernumber %]">[% resfirstname %] [% ressurname %]</a> ([% rescardnumber %]) at [% resbranchname %] since [% reswaitingdate | $KohaDates %]</li>
+    <li>Item <i>[% getTitleMessageIteminfo | html %]</i> ([% getBarcodeMessageIteminfo | html %]) has been waiting for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resborrowernumber | uri %]">[% resfirstname | html %] [% ressurname | html %]</a> ([% rescardnumber | html %]) at [% Branches.GetName( resbranchcode ) | html %] since [% reswaitingdate | $KohaDates %]</li>
 [% END %]
 
 [% IF ( RESERVED ) %]
-    <li>Item <i>[% getTitleMessageIteminfo %]</i> ([% getBarcodeMessageIteminfo %]) has been on hold for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resborrowernumber %]">[% resfirstname %] [% ressurname %]</a> ([% rescardnumber %]) at [% resbranchname %] since [% resreservedate | $KohaDates %]</li>
+    <li>Item <i>[% getTitleMessageIteminfo | html %]</i> ([% getBarcodeMessageIteminfo | html %]) has been on hold for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resborrowernumber | uri %]">[% resfirstname | html %] [% ressurname | html %]</a> ([% rescardnumber | html %]) at [% Branches.GetName( resbranchcode ) | html %] since [% resreservedate | $KohaDates %]</li>
 [% END %]
 
 [% IF ( ISSUED_TO_ANOTHER ) %]
-    <li>Item <i>[% getTitleMessageIteminfo %]</i> ([% getBarcodeMessageIteminfo %]) is checked out to <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% issued_borrowernumber %]">[% issued_firstname %] [% issued_surname %]</a> ([% issued_cardnumber %]).
+    <li>Item <i>[% getTitleMessageIteminfo | html %]</i> ([% getBarcodeMessageIteminfo | html %]) is checked out to <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% issued_borrowernumber | uri %]">[% issued_firstname | html %] [% issued_surname | html %]</a> ([% issued_cardnumber | html %]).
       [% IF CAN_user_circulate_force_checkout %]
         Check in and check out?
       [% END %]
@@ -215,19 +134,23 @@ $(document).ready(function() {
 [% END %]
 
 [% IF TOO_MANY and TOO_MANY == 'TOO_MANY_CHECKOUTS' %]
-    <li>Too many checked out. [% current_loan_count %] checked out, only [% max_loans_allowed %] are allowed.</li>
+    <li>Too many checked out. [% current_loan_count | html %] checked out, only [% max_loans_allowed | html %] are allowed.</li>
 [% END %]
 
 [% IF TOO_MANY and TOO_MANY == 'TOO_MANY_ONSITE_CHECKOUTS' %]
-    <li>Too many on-site checked out. [% current_loan_count %] on-site checked out, only [% max_loans_allowed %] are allowed.</li>
+    <li>Too many on-site checked out. [% current_loan_count | html %] on-site checked out, only [% max_loans_allowed | html %] are allowed.</li>
 [% END %]
 
 [% IF ( BORRNOTSAMEBRANCH ) %]
-    <li>This patron is from a different library ([% BORRNOTSAMEBRANCH %])</li>
+    <li>This patron is from a different library ([% Branches.GetName( BORRNOTSAMEBRANCH ) | html %])</li>
 [% END %]
 
 [% IF ( PATRON_CANT ) %]
-    <li>This patron can't check out this item per library circulation policy</li>
+    <li>This patron can't check out this item per library circulation policy.</li>
+[% END %]
+
+[% IF ( TOO_MANY and TOO_MANY == 'NO_RULE_DEFINED' ) %]
+    <li>No circulation rule is defined for this patron and itemtype combination.</li>
 [% END %]
 
 [% IF ( NOT_FOR_LOAN_FORCING ) %]
@@ -235,8 +158,8 @@ $(document).ready(function() {
     [% IF ( itemtype_notforloan ) %]
         Item type is normally not for loan.
     [% ELSIF ( item_notforloan ) %]
-        [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
-        Item is normally not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
+        [% item_notforloan_lib = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.notforloan ) %]
+        Item is normally not for loan[% IF (item_notforloan_lib) %] ([% item_notforloan_lib | html %])[% END %].
     [% END %]
       [% IF CAN_user_circulate_force_checkout %]
         Check out anyway?
@@ -253,7 +176,7 @@ $(document).ready(function() {
 [% END %]
 
 [% IF ( ITEM_LOST ) %]
-    <li>This item has been lost with a status of "[% ITEM_LOST %]".
+    <li>This item has been lost with a status of "[% ITEM_LOST | html %]".
       [% IF CAN_user_circulate_force_checkout %]
         Check out anyway?
       [% END %]
@@ -261,11 +184,11 @@ $(document).ready(function() {
 [% END %]
 
 [% IF HIGHHOLDS %]
-    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration %] days (due [% HIGHHOLDS.returndate %]). Check out anyway?</li>
+    <li>High demand item. Loan period shortened to [% HIGHHOLDS.duration | html %] days (due [% HIGHHOLDS.returndate | $KohaDates %]). Check out anyway?</li>
 [% END %]
 
 [% IF PREVISSUE %]
-    <li>This item has previously been checked out to this patron.  Check out anyway?</li>
+    <li>Patron has previously checked out this title: <b>[% biblio.title | html %] [% IF biblio.author %] by [% biblio.author | html %][% END %]</b>. Check out anyway?</li>
 [% END %]
 
 [% IF BIBLIO_ALREADY_ISSUED %]
@@ -278,27 +201,6 @@ $(document).ready(function() {
 [% END %]
 </ul>
 
-[% IF HIGHHOLDS %]
-<script language="JavaScript" type="text/javascript">
-$(document).ready(function() {
-    [% IF !override_high_holds %]
-        $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate %]');
-        if ('[% duedatespec %]' === '') {
-            $("input[name=restoreduedatespec]:hidden").val('highholds_empty');
-        } else {
-            $("input[name=restoreduedatespec]:hidden").val('[% duedatespec %]');
-        }
-    [% END %]
-
-    $("#override_high_holds_tmp").on( 'change', function() {
-        if ( this.checked ) {
-            $("input[name=duedatespec]:hidden").val('');
-        }
-    });
-});
-</script>
-[% END %]
-
 [% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
 <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off">
     <input type="hidden" name="restoreduedatespec" />
@@ -328,56 +230,57 @@ $(document).ready(function() {
 </p>
 [% END %]
 
-    <input type="hidden" name="barcode" value="[% barcode |html %]" />
-    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+    <input type="hidden" name="barcode" value="[% barcode | html %]" />
+    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
     <input type="hidden" name="issueconfirmed" value="1" />
-    <input type="hidden" name="override_high_holds" value="[% override_high_holds %]"/>
+    <input type="hidden" name="override_high_holds" value="[% override_high_holds | html %]"/>
     [% IF ( DEBT ) %]<input type="hidden" name="debt_confirmed" value="1" />[% END %]
     [% IF ( INVALID_DATE ) %]
     <p>
-    <input type="text" size="13" id="duedatespec" name="duedatespec" readonly="readonly" value="[% duedatespec %]" />
+    <input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec | html %]" />
     <label for="duedatespec">Due date</label>
     </p>
     [% ELSE %]
-    <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
+    <input type="hidden" name="duedatespec" value="[% duedatespec | html %]" />
     [% END %]
-    <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
-    <input type="hidden" name="branch" value="[% branch %]" />
+    <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" />
+    <input type="hidden" name="branch" value="[% branch | html %]" />
     [% IF ( RENEW_ISSUE ) %]
     <button type="submit" class="approve" accesskey="y"><i class="fa fa-check"></i> Yes, renew (Y)</button>
     [% ELSE %]
     <button type="submit" class="approve" accesskey="y"><i class="fa fa-check"></i> Yes, check out (Y)</button>
     [% END %]
-    <input type="hidden" name="onsite_checkout" value="[% onsite_checkout %]" />
+    <input type="hidden" name="onsite_checkout" value="[% onsite_checkout | html %]" />
+    <input type="hidden" name="auto_renew" value="[% auto_renew | html %]" />
 </form>
 [% END %]
 
 [% IF ( RESERVED ) %]
 <form method="get" action="/cgi-bin/koha/circ/circulation.pl">
     <input type="hidden" name="restoreduedatespec" />
-    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
-    <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
-    <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
-    <button class="print" type="submit" onclick="Dopop('hold-transfer-slip.pl?borrowernumber=[% reserveborrowernumber %]&amp;biblionumber=[% itembiblionumber %]&amp;op=slip');this.form.submit();"><i class="fa fa-print"></i> Don't check out and print slip (P)</button>
+    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
+    <input type="hidden" name="duedatespec" value="[% duedatespec | html %]" />
+    <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" />
+    <button class="print" type="submit" onclick="Dopop('hold-transfer-slip.pl?borrowernumber=[% reserveborrowernumber | html %]&amp;biblionumber=[% itembiblionumber | html %]&amp;itemnumber=[% item.itemnumber | html %]&amp;op=slip');this.form.submit();"><i class="fa fa-print"></i> Don't check out and print slip (P)</button>
 </form>
 [% END %]
 
 [% IF ( RESERVE_WAITING ) %]
 <form method="get" action="/cgi-bin/koha/circ/circulation.pl">
     <input type="hidden" name="restoreduedatespec" />
-    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
-    <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
-    <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
-    <button class="print" type="submit" onclick="Dopop('hold-transfer-slip.pl?borrowernumber=[% reserveborrowernumber %]&amp;biblionumber=[% itembiblionumber %]&amp;op=slip');this.form.submit();"><i class="fa fa-print"></i> Don't check out and print slip (P)</button>
+    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
+    <input type="hidden" name="duedatespec" value="[% duedatespec | html %]" />
+    <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" />
+    <button class="print" type="submit" onclick="Dopop('hold-transfer-slip.pl?borrowernumber=[% reserveborrowernumber | html %]&amp;biblionumber=[% itembiblionumber | html %]&amp;itemnumber=[% item.itemnumber | html %]&amp;op=slip');this.form.submit();"><i class="fa fa-print"></i> Don't check out and print slip (P)</button>
 </form>
 [% END %]
 
 <form method="get" action="/cgi-bin/koha/circ/circulation.pl">
     [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
-    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
-    <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
+    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
+    <input type="hidden" name="duedatespec" value="[% duedatespec | html %]" />
     <input type="hidden" name="restoreduedatespec" />
-    <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
+    <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" />
     [% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
         [% IF ( RENEW_ISSUE ) %]
         <button type="submit" class="deny" accesskey="n"><i class="fa fa-times"></i> No, don't renew (N)</button>
@@ -391,7 +294,7 @@ $(document).ready(function() {
 
 [% IF ( RESERVED || ISSUED_TO_ANOTHER ) && (CAN_user_reserveforothers_place_holds ) %]
     [% UNLESS noissues %]
-        <button type="submit" onclick="window.location.href='/cgi-bin/koha/reserve/request.pl?biblionumber=[% itembiblionumber %]&borrowernumber=[% borrowernumber %]'"><i class="fa fa-sticky-note-o"></i> Cancel checkout and place a hold for [% INCLUDE 'patron-title.inc' %]</button>
+        <button type="submit" onclick="window.location.href='/cgi-bin/koha/reserve/request.pl?biblionumber=[% itembiblionumber | html %]&borrowernumber=[% patron.borrowernumber | html %]'"><i class="fa fa-sticky-note-o"></i> Cancel checkout and place a hold for [% INCLUDE 'patron-title.inc' %]</button>
     [% END %]
 [% END %]
 </div></div>
@@ -411,39 +314,29 @@ $(document).ready(function() {
         [% END %]
 
         [% IF ( INVALID_DATE ) %]
-            <li>The due date &quot;[% INVALID_DATE %]&quot; is invalid</li>
+            <li>The due date &quot;[% INVALID_DATE | html %]&quot; is invalid</li>
         [% END %]
 
         [% IF ( UNKNOWN_BARCODE ) %]
-            <li>The barcode was not found: <span class="ex">[% barcode |html %]</span>
-           [% IF ( fast_cataloging ) %]
-               [% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
-            <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA&amp;barcode=[% barcode |uri %]&amp;circborrowernumber=[% borrowernumber %]&amp;branch=[% branch %]&amp;duedatespec=[% duedatespec %]&amp;stickyduedate=[% stickyduedate %]">Fast cataloging</a>
-               [% END %]
-           [% END %]
+            <li>The barcode was not found: <span class="ex">[% barcode | html %]</span>
 
-        [% IF ( FALLBACK ) %]
-            [% IF options %]
-                <br />The following items were found by searching:
-                [% FOREACH book IN options %]
-                    <br />
-                    <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off">
-                    [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
-                        <input type="hidden" name="restoreduedatespec" />
-                        <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
-                        <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
-                        <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
-                        <input type="hidden" name="branch" value="[% branch %]" />
-                        <input type="hidden" name="barcode" value="[% book.barcode %]" />
-                        <button type="submit" name="x"><i class="fa fa-check"></i> Check out [% book.barcode %]: [% book.title %]</button>
-                    </form>
-                [% END %]
-            [% ELSE %]
-                <br />No items were found by searching.
-            [% END %]
-        [% END %]
+                <div>
+                    [% IF ( FALLBACK ) %]
+                        [% IF options %]
+                            <button type="button" class="approve" data-toggle="modal" data-target="#itemSearchFallback"><i class="fa fa-search"></i> Show matching titles</button>
+                        [% ELSE %]
+                            <div>No items were found by searching.</div>
+                        [% END %]
+                    [% END %]
+
+                    [% IF ( fast_cataloging ) %]
+                        [% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
+                            <a class="approve" href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA&amp;barcode=[% barcode |uri %]&amp;circborrowernumber=[% patron.borrowernumber | html %]&amp;branch=[% branch | html %]&amp;duedatespec=[% duedatespec | html %]&amp;stickyduedate=[% stickyduedate | html %]"><i class="fa fa-plus"></i> Add record using fast cataloging</a>
+                        [% END %]
+                    [% END %]
+                </div>
 
-     </li>
+            </li>
         [% END %]
 
         [% IF ( NOT_FOR_LOAN ) %]
@@ -451,14 +344,18 @@ $(document).ready(function() {
             [% IF ( itemtype_notforloan ) %]
                 Item type not for loan.
             [% ELSIF ( item_notforloan ) %]
-                [% item_notforloan_lib = AuthorisedValues.GetByCode( authvalcode_notforloan, item_notforloan, 0 ) %]
-                Item not for loan [% IF (item_notforloan_lib) %]([% item_notforloan_lib %])[% END %].
+                [% item_notforloan_lib = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.notforloan ) %]
+                Item not for loan[% IF (item_notforloan_lib) %] ([% item_notforloan_lib | html %])[% END %].
             [% END %]
             </li>
         [% END %]
 
         [% IF ( WTHDRAWN ) %]
-            <li>Item has been withdrawn</li>
+            <li>
+                <span>Item has been withdrawn</span>
+                [% item_withdrawn_lib = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) %]
+                [% IF (item_withdrawn_lib) %]<span class="co-withdrawn">([% item_withdrawn_lib | html %])</span>[% END %]
+            </li>
         [% END %]
 
         [% IF ( RESTRICTED ) %]
@@ -486,7 +383,7 @@ $(document).ready(function() {
         [% END %]
 
         [%IF ( AGE_RESTRICTION ) %]
-            <li>Age restriction [% AGE_RESTRICTION %].</li>
+            <li>Age restriction [% AGE_RESTRICTION | html %].</li>
         [% END %]
 
         [% IF ( EXPIRED ) %]
@@ -494,15 +391,15 @@ $(document).ready(function() {
         [% END %]
 
         [% IF ( TOO_MANY ) %]
-            <li>Too many checked out. [% current_loan_count %] checked out, only [% max_loans_allowed %] are allowed.</li>
+            <li>Too many checked out. [% current_loan_count | html %] checked out, only [% max_loans_allowed | html %] are allowed.</li>
         [% END %]
 
         [% IF ( ITEMNOTSAMEBRANCH ) %]
-            <li>This item belongs to [% Branches.GetName( itemhomebranch ) %] and cannot be checked out from this location.</li>
+            <li>This item belongs to [% Branches.GetName( itemhomebranch ) | html %] and cannot be checked out from this location.</li>
         [% END %]
 
         [% IF RETURN_IMPOSSIBLE %]
-            <li>This item must be returned to [% Branches.GetName( branch_to_return ) %].</li>
+            <li>This item must be returned to [% Branches.GetName( branch_to_return ) | html %].</li>
         [% END %]
 
         [% IF ( USERBLOCKEDWITHENDDATE ) %]
@@ -523,6 +420,53 @@ $(document).ready(function() {
         [% END %]
 
 </div></div>
+
+        [% IF ( FALLBACK ) %]
+            [% IF options %]
+
+                <!-- Modal -->
+                <div class="modal" id="itemSearchFallback" tabindex="-1" role="dialog" aria-labelledby="itemSearchFallbackLabel">
+                    <div class="modal-dialog modal-wide" role="document">
+                        <div class="modal-content">
+                            <div class="modal-header">
+                                <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                                <h3 id="itemSearchFallbackLabel"><h3>Barcode not found. The following items were found by searching:</h3>
+                            </div>
+                            <div class="modal-body">
+                                <table class="table_borrowers">
+                                    [% FOREACH book IN options %]
+                                        <tr>
+                                            <td>
+                                                <a class="popup" target="_blank" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% book.biblionumber | html %]">[% book.title | html %]</a>
+                                                [% book.barcode | html %]
+                                            </td>
+                                            <td>
+                                                <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off">
+                                                    [% IF (forceallow) %]
+                                                        <input type="hidden" name="forceallow" value="1">
+                                                    [% END %]
+                                                    <input type="hidden" name="restoreduedatespec" />
+                                                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
+                                                    <input type="hidden" name="duedatespec" value="[% duedatespec | html %]" />
+                                                    <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" />
+                                                    <input type="hidden" name="branch" value="[% branch | html %]" />
+                                                    <input type="hidden" name="barcode" value="[% book.barcode | html %]" />
+                                                    <button class="btn btn-default btn-xs" type="submit" name="x"><i class="fa fa-check"></i> Check out</button>
+                                                </form>
+                                            </td>
+                                        </tr>
+                                    [% END %]
+                                </table>
+                            </div>
+                            <div class="modal-footer">
+                                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            [% END %]
+        [% END %]
+
 [% ELSE %]
   [% IF (forceallow) %]
       <div id="overridden_debarment" class="dialog alert">Restriction overridden temporarily</div>
@@ -552,7 +496,7 @@ No patron matched <span class="ex">[% message | html %]</span>
 
 <!-- BARCODE ENTRY -->
 
-[% IF borrowernumber and borrower %]
+[% IF patron %]
 <div class="yui-g">
 
 [% IF privacy == 2 AND NOT Koha.Preference('AnonymousPatron') %]
@@ -571,20 +515,25 @@ No patron matched <span class="ex">[% message | html %]</span>
 [% END %]
     [% IF ( DisplayClearScreenButton ) %]
         <span id="clearscreen"><a href="/cgi-bin/koha/circ/circulation.pl" title="Clear screen">x</a></span>
+        <span id="printclearscreen"><a href="#" title="Print slip and clear screen"><i class="fa fa-print"></i></a></span>
     [% END %]
 
     [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
 
     <label class="circ_barcode" for="barcode">Checking out to [% INCLUDE 'patron-title.inc' %]</label>
 
-       <div class="hint">Enter item barcode:</div>
+        [% IF Koha.Preference('itemBarcodeFallbackSearch') %]
+            <div class="hint">Enter item barcode or keyword:</div>
+        [% ELSE %]
+            <div class="hint">Enter item barcode:</div>
+        [% END %]
 
     [% IF NEEDSCONFIRMATION %]
         <input type="text" name="barcode" id="barcode" class="barcode focus" size="14" disabled="disabled" />
     [% ELSE %]
         <input type="text" name="barcode" id="barcode" class="barcode focus" size="14" />
     [% END %]
-    <button type="submit" class="btn">Check out</button>
+    <button type="submit" class="btn btn-default">Check out</button>
 
     <div id="show-checkout-settings">
         <a href="#"><i class="fa fa-caret-right checkout-settings-icon"></i> Checkout settings</a>
@@ -597,9 +546,9 @@ No patron matched <span class="ex">[% message | html %]</span>
                 <div id="specify-due-date" class="checkout-setting">
                     <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
                     [% IF ( duedatespec ) %]
-                        <input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec %]" readonly="readonly" />
+                        <input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec | html %]" />
                     [% ELSE %]
-                        <input type="text" size="13" id="duedatespec" name="duedatespec" value="" readonly="readonly" />
+                        <input type="text" size="13" id="duedatespec" name="duedatespec" value="" />
                     [% END %]
                     <label for="stickyduedate"> Remember for session:</label>
                     [% IF ( stickyduedate ) %]
@@ -607,7 +556,7 @@ No patron matched <span class="ex">[% message | html %]</span>
                     [% ELSE %]
                         <input type="checkbox" id="stickyduedate" onclick="this.form.barcode.focus();" name="stickyduedate" />
                     [% END %]
-                    <button class="btn btn-small action" id="cleardate" name="cleardate" onclick="this.checked = false; this.form.duedatespec.value = ''; this.form.stickyduedate.checked = false; this.form.barcode.focus(); return false;" >Clear</button>
+                    <button class="btn btn-default btn-xs action" id="cleardate" name="cleardate" onclick="this.checked = false; this.form.duedatespec.value = ''; this.form.stickyduedate.checked = false; this.form.barcode.focus(); return false;" >Clear</button>
                 </div>
             [% END %]
         [% END %]
@@ -617,7 +566,7 @@ No patron matched <span class="ex">[% message | html %]</span>
                 [% IF NEEDSCONFIRMATION %]
                     <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" disabled="disabled" />
                 [% ELSE %]
-                    <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" />
+                    <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" class="circ_setting" />
                 [% END %]
 
                 <label for="auto_renew">Automatic renewal</label>
@@ -632,9 +581,9 @@ No patron matched <span class="ex">[% message | html %]</span>
                         [% END %]
                     [% ELSE %]
                         [% IF override_high_holds %]
-                            <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" checked="checked" />
+                            <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" class="circ_setting" checked="checked" />
                         [% ELSE %]
-                            <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" />
+                            <input type="checkbox" name="override_high_holds" id="override_high_holds" value="1" class="circ_setting" />
                         [% END %]
                     [% END %]
                     <label for="override_high_holds">Don't decrease checkout length based on holds</label>
@@ -647,29 +596,28 @@ No patron matched <span class="ex">[% message | html %]</span>
                 [% IF noissues %]
                     <div class="onsite-checkout-only">
                         <input type="checkbox" id="onsite_checkout" name="onsite_checkout_forced" checked="checked" disabled="disabled" /> <label for="onsite_checkout">On-site checkouts only. Automatic due date: </label>
-                        <input type="text" name="duedatespec" id="duedatespec" readonly="readonly" />
+                        <input type="text" name="duedatespec" id="duedatespec" />
                         <input type="hidden" name="onsite_checkout" checked="checked" value="1" />
                     </div>
                 [% ELSE %]
-                    <input type="checkbox" id="onsite_checkout" name="onsite_checkout" /> <label for="onsite_checkout">On-site checkout</label>
+                    <input type="checkbox" id="onsite_checkout" name="onsite_checkout" class="circ_setting" /> <label for="onsite_checkout">On-site checkout</label>
                 [% END %]
             </div>
         [% END %]
 
     </div> <!-- /.checkout-settings -->
 
-          <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
-          <input type="hidden" name="branch" value="[% branch %]" />
+          <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
+          <input type="hidden" name="branch" value="[% branch | html %]" />
           <input type="hidden" name="print" value="maybe" />
-          <input type="hidden" name="debt_confirmed" value="[% debt_confirmed %]" />
+          <input type="hidden" name="debt_confirmed" value="[% debt_confirmed | html %]" />
                 [% IF ( CHARGES ) %]
                         <input type="hidden" name="charges" value="yes" />
-                        <input type="hidden" name="oldamount" value="[% amountold %]" />
                 [% END %]
 </fieldset>
 [% IF ( issue ) %]
     <div class="lastchecked">
-        <p><strong>Checked out: </strong>[% issue.item.biblioitemnumber.biblionumber.title %] ([% issue.item.barcode %]). Due on [% issue.date_due | $KohaDates %]</p>
+        <p><strong>Checked out: </strong>[% issue.item.biblioitemnumber.biblionumber.title | html %] ([% issue.item.barcode | html %]). Due on [% issue.date_due | $KohaDates as_due_date => 1 %]</p>
     </div>
 [% END %]
 </form></div>
@@ -708,7 +656,7 @@ No patron matched <span class="ex">[% message | html %]</span>
 
                    [% IF ( has_modifications ) %]
                     <li><span class="circ-hlt">Pending modifications:</span> Patron has pending modifications.
-                            [% IF CAN_user_borrowers && ( !Koha.Preference('IndependentBranchesPatronModifications') || borrower.branch == branch ) %]
+                            [% IF CAN_user_borrowers_edit_borrowers && ( !Koha.Preference('IndependentBranchesPatronModifications') || borrower.branch == branch ) %]
                                     <a href="/cgi-bin/koha/members/members-update.pl">View all pending patron modifications</a>
                             [% END %]
                    </li>
@@ -716,7 +664,7 @@ No patron matched <span class="ex">[% message | html %]</span>
 
                        [% IF ( warndeparture ) %]
                        <li><span class="circ-hlt">Expiration:</span> Patron's card will expire soon.
-            Patron's card expires on [% expiry | $KohaDates %] <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=circ&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% borrowernumber %]&amp;categorycode=[% categorycode %]">Edit Details</a>
+            Patron's card expires on [% expiry | $KohaDates %] <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=circ&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;categorycode=[% categorycode | html %]">Edit details</a>
 
                        </li>
                        [% END %]
@@ -729,7 +677,7 @@ No patron matched <span class="ex">[% message | html %]</span>
 
                        [% IF ( expired ) %]
                        <li><span class="circ-hlt">Expiration:</span> Patron's card has expired.
-            [% IF ( expiry ) %]Patron's card expired on [% expiry | $KohaDates %][% END %] <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=circ&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% borrowernumber %]&amp;categorycode=[% categorycode %]">Edit Details</a>
+            [% IF ( expiry ) %]Patron's card expired on [% expiry | $KohaDates %][% END %] <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=circ&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;categorycode=[% categorycode | html %]">Edit details</a>
 
                        </li>
                        [% END %]
@@ -752,36 +700,34 @@ No patron matched <span class="ex">[% message | html %]</span>
 
                    [% IF ( debarredcomment ) %]
                        with the explanation: <br/><i>
-                          [% IF debarredcomment.search('OVERDUES_PROCESS') %]
-                              Restriction added by overdues process [% debarredcomment.remove('OVERDUES_PROCESS ') | html_line_break %]
-                          [% ELSE %]
-                              [% debarredcomment | html_line_break %]
-                          [% END %]
-                    </i>
+                       [% IF debarredcomment.search('OVERDUES_PROCESS') %]
+                           Restriction added by overdues process [% debarredcomment.remove('OVERDUES_PROCESS ') | $raw | html_line_break %]
+                       [% ELSE %]
+                           [% debarredcomment | $raw | html_line_break %]
+                       [% END %]
+                       </i>
                    [% END %]
                    <br/>
-                   <a class="btn btn-small" href="#reldebarments" onclick="$('#debarments-tab-link').click()"><i class="fa fa-ban"></i> View restrictions</a>
-                    [% IF (noissues && borrowernumber && CAN_user_circulate_force_checkout) %]
+                   <a class="btn btn-default" href="#reldebarments" onclick="$('#debarments-tab-link').click()"><i class="fa fa-ban"></i> View restrictions</a>
+                    [% IF (noissues && patron && CAN_user_circulate_force_checkout) %]
                         <span class="override_debarment">
-                            <a href="/cgi-bin/koha/circ/circulation.pl?forceallow=1&amp;borrowernumber=[% borrowernumber %]" class="btn btn-small">Override restriction temporarily</a>
+                            <a href="/cgi-bin/koha/circ/circulation.pl?forceallow=1&amp;borrowernumber=[% patron.borrowernumber | uri %]" class="btn btn-default">Override restriction temporarily</a>
                         </span>
                     [% END %]
                </li>
             [% END %]
 
-                [% IF ( odues ) %]<li>[% IF ( nonreturns ) %]<span class="circ-hlt">Overdues: Patron has ITEMS OVERDUE.</span> <a href="#checkouts">See highlighted items below</a>[% END %]</li>
+                [% IF ( odues ) %]<li><span class="circ-hlt">Overdues: Patron has ITEMS OVERDUE.</span> <a href="#checkouts">See highlighted items below</a></li>
             [% END %]
 
             [% IF ( charges ) %]
-                [% INCLUDE 'blocked-fines.inc'
-                    fines = chargesamount
-                %]
+                [% INCLUDE 'blocked-fines.inc' fines = chargesamount %]
             [% END %]
 
             [% IF ( charges_guarantees ) %]
                 <li>
-                    <span class="circ-hlt">Fees &amp; Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees %].
-                        [% IF ( charges_guarantees_is_blocker ) %]
+                    <span class="circ-hlt">Fees &amp; Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees | $Price %].
+                        [% IF noissues %]
                             <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
                         [% END %]
                 </li>
@@ -790,7 +736,7 @@ No patron matched <span class="ex">[% message | html %]</span>
 
             [% IF ( credits ) %]
                 <li>
-                    <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of [% creditsamount %][% END %]
+                    <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of [% creditsamount | $Price %][% END %]
                 </li>
             [% END %]
 
@@ -803,16 +749,16 @@ No patron matched <span class="ex">[% message | html %]</span>
                     [% FOREACH w IN WaitingHolds %]
                         <ul>
                             <li>
-                                <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% w.biblio.biblionumber %]">[% w.biblio.title | html %]</a>
-                                ([% ItemTypes.GetDescription( w.item.effective_itemtype ) %]),
+                                <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% w.biblio.biblionumber | uri %]">[% w.biblio.title | html %]</a>
+                                ([% ItemTypes.GetDescription( w.item.effective_itemtype ) | html %]),
                                 [% IF ( w.biblio.author ) %] by [% w.biblio.author | html %] [% END %]
-                                [% IF ( w.item.itemcallnumber ) %] [[% w.item.itemcallnumber %]] [% END %]
+                                [% IF ( w.item.itemcallnumber ) %] [[% w.item.itemcallnumber | html %]] [% END %]
                                 Hold placed on [% w.reservedate | $KohaDates %].
 
                                 <br/>
                                 [% IF ( w.branch.branchcode == Branches.GetLoggedInBranchcode()  ) %]<strong class="waitinghere">[% ELSE %]<strong>[% END %]
-                                    [% SET waiting_expires_on = w.waiting_expires_on %]
-                                    Waiting at [% w.branch.branchname | html %] [% IF waiting_expires_on %] until [% waiting_expires_on | $KohaDates %] [% END %]
+                                    [% SET expires_on = w.expirationdate %]
+                                    Waiting at [% w.branch.branchname | html %] [% IF expires_on %] until [% expires_on | $KohaDates %] [% END %]
                                 </strong>
                             </li>
                         </ul>
@@ -823,7 +769,7 @@ No patron matched <span class="ex">[% message | html %]</span>
        [% IF ( notes ) %]
                        <div id="circnotes" class="circmessage">
                        <h4>Notes:</h4>
-            <p><span class="circ-hlt">[% notesmsg %]</span></p>
+            <p><span class="circ-hlt">[% notesmsg | $raw %]</span></p>
                        </div>
 
 
@@ -832,26 +778,27 @@ No patron matched <span class="ex">[% message | html %]</span>
     <div id="messages" class="circmessage">
         <h4>Messages:</h4>
         <ul>
-            [% FOREACH message IN librarian_messages %]
+            [% FOREACH message IN messages %]
                 <li>
-                    <span class="circ-hlt">
+                    [% IF(message.message_type == "L") %]
+                        <span class="circ-hlt">
+                    [% ELSE %]
+                        <span>
+                    [% END %]
                         [% message.message_date | $KohaDates %]
-                        [% Branches.GetName( message.branchcode ) %]
-                        <i>"[% message.message %]"</i>
+                        [% Branches.GetName( message.branchcode ) | html %]
+                        [% IF message.manager_id %]
+                            ( <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% message.manager_id | uri %]">[% message.get_column('manager_firstname') | html %] [% message.get_column('manager_surname') | html %]</a> )
+                        [% END %]
+                        <i>"[% message.message | html %]"</i>
                     </span>
                     [% IF message.branchcode == branch OR Koha.Preference('AllowAllMessageDeletion') %]
-                        [<a href="/cgi-bin/koha/circ/del_message.pl?message_id=[% message.message_id %]&amp;borrowernumber=[% message.borrowernumber %]" onclick="return confirm(MSG_CONFIRM_DELETE_MESSAGE);"><i class="fa fa-trash"></i> Delete</a>]
+                        <a class="btn btn-link" href="/cgi-bin/koha/circ/del_message.pl?message_id=[% message.message_id | html %]&amp;borrowernumber=[% message.borrowernumber | html %]" onclick="return confirm(MSG_CONFIRM_DELETE_MESSAGE);"><i class="fa fa-trash"></i> Delete</a>
                     [% END %]
                 </li>
             [% END %]
-            [% FOREACH message IN patron_messages %]
-                <li><span class="">[% message.message_date | $KohaDates %] [% Branches.GetName( message.branchcode )%] <i>"[% message.message %]"</i></span>
-                [% IF message.branchcode == branch OR Koha.Preference('AllowAllMessageDeletion') %]
-                    [<a href="/cgi-bin/koha/circ/del_message.pl?message_id=[% message.message_id %]&amp;borrowernumber=[% message.borrowernumber %]"><i class="fa fa-trash"></i> Delete</a>]
-                [% END %]</li>
-            [% END %]
         </ul>
-        <a id="addnewmessageLabel" href="#add_message_form" data-toggle="modal"><i class="fa fa-plus"></i> Add a new message</a>
+        <a id="addnewmessageLabel" href="#add_message_form" class="btn btn-link" data-toggle="modal"><i class="fa fa-plus"></i> Add a new message</a>
     </div>
 
 </div>
@@ -862,7 +809,7 @@ No patron matched <span class="ex">[% message | html %]</span>
 <ul>
     <li>
         [% IF ( issuecount ) %]
-            <a href="#checkouts">[% issuecount %] Checkout(s)</a>
+            <a href="#checkouts">[% issuecount | html %] Checkout(s)</a>
         [% ELSE %]
             <a href="#checkouts">0 Checkouts</a>
         [% END %]
@@ -874,12 +821,30 @@ No patron matched <span class="ex">[% message | html %]</span>
 
     <li>
         [% IF ( holds_count ) %]
-            <a href="#reserves" id="holds-tab">[% holds_count %] Hold(s)</a>
+            <a href="#reserves" id="holds-tab">[% holds_count | html %] Hold(s)</a>
         [% ELSE %]
             <a href="#reserves" id="holds-tab">0 Holds</a>
         [% END %]
+    </li>
+
+    [% IF Koha.Preference('ArticleRequests') %]
+        <li>
+            <a href="#article-requests" id="article-requests-tab"> [% patron.article_requests_current.count | html %] Article requests</a>
+        </li>
+    [% END %]
+
+    <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.count | html %] Restrictions</a></li>
+
+    [% SET enrollments = patron.get_club_enrollments(1) %]
+    [% SET enrollable  = patron.get_enrollable_clubs(0,1) %]
+    [% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %]
+        <li>
+            <a id="clubs-tab-link" href="#clubs-tab">
+                Clubs ([% enrollments.count | html %]/[% enrollable.count | html %])
+            </a>
+        </li>
+    [% END %]
 
-    <li><a id="debarments-tab-link" href="#reldebarments">[% debarments.size %] Restrictions</a></li>
 </ul>
 
 <!-- SUMMARY : TODAY & PREVIOUS ISSUES -->
@@ -895,6 +860,7 @@ No patron matched <span class="ex">[% message | html %]</span>
                     <th scope="col">Due date</th>
                     <th scope="col">Title</th>
                     <th scope="col">Item type</th>
+                    <th scope="col">Collection code</th>
                     <th scope="col">Location</th>
                     <th scope="col">Checked out on</th>
                     <th scope="col">Checked out from</th>
@@ -909,6 +875,12 @@ No patron matched <span class="ex">[% message | html %]</span>
     </div>
 [% END %]
 
+[% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %]
+    <div id="clubs-tab">
+        Loading...
+    </div>
+[% END %]
+
 [% INCLUDE borrower_debarments.inc %]
 
 <div id="reserves">
@@ -925,8 +897,9 @@ No patron matched <span class="ex">[% message | html %]</span>
                     <th>Pickup at</th>
                     <th>Expiration</th>
                     <th>Priority</th>
-                    <th>Delete?</th>
+                    <th>Cancel?</th>
                     <th>Suspend?</th>
+                    <th>Status</th>
                 </tr>
             </thead>
         </table>
@@ -936,16 +909,16 @@ No patron matched <span class="ex">[% message | html %]</span>
         </fieldset>
     </form>
 
-    [% IF SuspendHoldsIntranet %]
+    [% IF Koha.Preference('SuspendHoldsIntranet') %]
     <fieldset class="action">
         <form action="/cgi-bin/koha/reserve/modrequest_suspendall.pl" method="post">
             <input type="hidden" name="from" value="circ" />
-            <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+            <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
             <input type="submit" value="Suspend all holds" />
 
-            [% IF AutoResumeSuspendedHolds %]
+            [% IF Koha.Preference('AutoResumeSuspendedHolds') %]
             <label for="suspend_until">until</label>
-            <input type="text" size="10" id="suspend_until" name="suspend_until" class="datepicker" />
+            <input type="text" size="10" id="suspend_until" name="suspend_until" class="datepicker"/>
             <span class="hint">Specify date on which to resume [% INCLUDE 'date-format.inc' %]: </span>
              [% END %]
         </form>
@@ -954,7 +927,7 @@ No patron matched <span class="ex">[% message | html %]</span>
     <fieldset class="action">
         <form action="/cgi-bin/koha/reserve/modrequest_suspendall.pl" method="post">
             <input type="hidden" name="from" value="circ" />
-            <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+            <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
             <input type="hidden" name="suspend" value="0" />
             <input type="submit" value="Resume all suspended holds" />
        </form>
@@ -966,20 +939,38 @@ No patron matched <span class="ex">[% message | html %]</span>
 [% END %]
 </div> <!-- reservesloop -->
 
+[% IF Koha.Preference('ArticleRequests') %]
+    [% INCLUDE 'patron-article-requests.inc' %]
+[% END %]
+
 [% ELSIF borrowernumber %]
-    <div class="dialog message">This patron does not exist. <a href="/cgi-bin/koha/members/members-home.pl">Find another patron?</a></div>
-[% END %] <!-- borrowernumber and borrower-->
+    <div class="dialog message">Patron not found. <a href="/cgi-bin/koha/members/members-home.pl">Return to search</a></div>
+[% END %]
 </div></div>
 [% END %]
-
+[% IF Koha.Preference('CircSidebar') %]
+[% UNLESS ( borrowers ) %]
+    [% IF not( borrowernumber and patron ) %]
+        <div class="yui-b noprint">
+            [% INCLUDE 'circ-nav.inc' %]
+        </div>
+    [% END %]
+[% END %]
+[% END %]
 </div>
 </div>
-[% UNLESS ( borrowers ) %][% IF borrowernumber and borrower %]<div class="yui-b">
-[% INCLUDE 'circ-menu.inc' %]
-</div>[% END %][% END %]
+[% UNLESS ( borrowers ) %]
+    [% IF borrowernumber and patron %]
+        <div class="yui-b">
+            [% INCLUDE 'circ-menu.inc' %]
+        </div>
+    [% END %]
+[% END %]
 </div>
 <!-- Modal -->
-<div id="barcodeSubmittedModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="barcodeSubmittedModalLabel" aria-hidden="true">
+<div id="barcodeSubmittedModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="barcodeSubmittedModalLabel" aria-hidden="true">
+    <div class="modal-dialog">
+    <div class="modal-content">
     <div class="modal-header">
         <h3 id="barcodeSubmittedModalLabel">Barcode submitted</h3>
     </div>
@@ -987,5 +978,137 @@ No patron matched <span class="ex">[% message | html %]</span>
     <div class="modal-body">
         <p>You have already submitted a barcode, please wait for the checkout to process...</p>
     </div>
+    </div>
+    </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'strings.inc' %]
+    [% INCLUDE 'calendar.inc' %]
+    [% INCLUDE 'datatables.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
+    [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
+    [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
+    [% INCLUDE 'timepicker.inc' %]
+    [% Asset.js("lib/jquery/plugins/jquery.dataTables.rowGrouping.js") | $raw %]
+    [% Asset.js("js/pages/circulation.js") | $raw %]
+    [% Asset.js("js/checkouts.js") | $raw %]
+    [% Asset.js("js/holds.js") | $raw %]
+    [% Asset.js("js/circ-patron-search-results.js") | $raw %]
+    <script type="text/javascript">
+        /* Set some variable needed in circulation.js */
+        var MSG_DT_LOADING_RECORDS = _("Loading... you may continue scanning.");
+        var interface = "[% interface | html %]";
+        var theme = "[% theme | html %]";
+        var borrowernumber = "[% patron.borrowernumber | html %]";
+        var branchcode = "[% branch | html %]";
+        var exports_enabled = "[% Koha.Preference('ExportCircHistory') | html %]";
+        var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 | html %];
+        var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 | html %];
+        var script = "circulation";
+        var relatives_borrowernumbers = new Array();
+        [% FOREACH b IN relatives_borrowernumbers %]
+            relatives_borrowernumbers.push("[% b | html %]");
+        [% END %]
+
+        var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export");
+        var MSG_CONFIRM_DELETE_MESSAGE = _("Are you sure you want to delete this message? This cannot be undone.");
+
+        columns_settings_issues_table = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'issues-table', 'json' ) | $raw %]
+        columns_settings_borrowers_table = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]
+
+        [% IF borrowernumber and patron %]
+            if($.cookie("holdfor") != [% patron.borrowernumber | html %]){
+                $.removeCookie("holdfor", { path: '/' });
+            }
+        [% ELSE %]
+            $.removeCookie("holdfor", { path: '/' });
+        [% END %]
+
+        [% UNLESS ( patron.borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
+
+        // On-site checkout
+        function toggle_onsite_checkout(){
+            if ( $("#onsite_checkout").prop('checked') ) {
+                $("#duedatespec").val("[% todaysdate | $KohaDates  with_hours => 1 %]")
+                [% IF !Koha.Preference('SpecifyDueDate') %]
+                    $("#duedatespec").datetimepicker('destroy');
+                [% END %]
+            } else {
+                $("#duedatespec").datetimepicker({
+                    onClose: function(dateText, inst) {
+                        if (validate_date(dateText, inst) ) {
+                            $("#barcode").focus();
+                        }
+                    },
+                    hour: 23,
+                    minute: 59
+                }).on("change", function(e, value) {
+                    if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
+                });
+            }
+        }
+
+        function Dopop(link) {
+            var newin = window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
+        }
+        $(document).ready(function() {
+            $('#mainform').on('submit',function() {
+                if ($("#barcode") && $("#barcode").val()) {
+                    $('#barcode').on('keypress',function(event) {
+                        $('#barcodeSubmittedModal').modal();
+                        event.preventDefault(); }
+                    );
+                }
+            });
+
+            if ( $('#clubs-tab').length ) {
+                $('#clubs-tab-link').on('click', function() {
+                    $('#clubs-tab').text(_("Loading..."));
+                    $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% patron.borrowernumber | html %]');
+                });
+            }
+
+            [% IF !( CircAutoPrintQuickSlip == 'clear' ) %]
+                // listen submit to trigger qslip on empty checkout
+                $('#mainform').bind('submit',function() {
+                    if ($('#barcode').val() == '') {
+                        return printx_window( '[% CircAutoPrintQuickSlip | html %]' );
+                    }
+                });
+            [% END %]
+            toggle_onsite_checkout();
+            $("#onsite_checkout").click(function(){
+                toggle_onsite_checkout();
+            });
+
+            $("#suspend_until").datepicker({
+                onClose: function(dateText, inst) {
+                    validate_date(dateText, inst);
+                },
+                minDate: 1, // require that hold suspended until date is after today
+            });
+
+            [% IF HIGHHOLDS %]
+                [% IF !override_high_holds %]
+                    $("input[name=duedatespec]:hidden").val('[% HIGHHOLDS.returndate | html %]');
+                    if ('[% duedatespec | html %]' === '') {
+                        $("input[name=restoreduedatespec]:hidden").val('highholds_empty');
+                    } else {
+                        $("input[name=restoreduedatespec]:hidden").val('[% duedatespec | html %]');
+                    }
+                [% END %]
+
+                $("#override_high_holds_tmp").on( 'change', function() {
+                    if ( this.checked ) {
+                        $("input[name=duedatespec]:hidden").val('');
+                    }
+                });
+            [% END %]
+        });
+    </script>
+    [% INCLUDE 'str/members-menu.inc' %]
+    [% Asset.js("js/members-menu.js") | $raw %]
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]