Bug 18251: SCO alerts - need a trigger for successful checkouts
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / sco / sco-main.tt
index f903631..048923b 100644 (file)
@@ -1,23 +1,29 @@
+[% USE raw %]
+[% USE Asset %]
 [% USE Koha %]
 [% USE KohaDates %]
-[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha [% END %] &rsaquo; Self checkout </title>
+[% USE AudioAlerts %]
+[% USE To %]
+[% USE Price %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha [% END %] &rsaquo; Self checkout </title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Koha [% Version %]" /> <!-- leave this for stats -->
-<link rel="shortcut icon" href="[% IF ( OpacFavicon  ) %][% OpacFavicon  %][% ELSE %][% interface %]/[% theme %]/images/favicon.ico[% END %]" type="image/x-icon" />
-<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/lib/bootstrap/css/bootstrap.min.css" />
-<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/lib/jquery/jquery-ui.css" />
-<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/sco.css" />
-[% IF ( OPACUserCSS ) %]<style type="text/css">[% OPACUserCSS %]</style>[% END %]
-[% IF ( SCOUserCSS ) %]<style type="text/css">[% SCOUserCSS %]</style>[% END %]
+<meta name="generator" content="Koha [% Version | html %]" /> <!-- leave this for stats -->
+<link rel="shortcut icon" href="[% IF ( Koha.Preference('OpacFavicon') ) %][% Koha.Preference('OpacFavicon') | url %][% ELSE %][% interface | html %]/[% theme | html %]/images/favicon.ico[% END %]" type="image/x-icon" />
+[% Asset.css("lib/bootstrap/css/bootstrap.min.css") | $raw %]
+[% Asset.css("lib/jquery/jquery-ui.css") | $raw %]
+[% Asset.css("css/sco.css") | $raw %]
+[% IF ( Koha.Preference('OPACUserCSS') ) %]<style>[% Koha.Preference('OPACUserCSS') | $raw %]</style>[% END %]
+[% IF ( Koha.Preference('SCOUserCSS') ) %]<style>[% Koha.Preference('SCOUserCSS') | $raw %]</style>[% END %]
 <!--[if lt IE 9]>
-    <script src="[% interface %]/[% theme %]/lib/respond.min.js"></script>
+    <script src="[% interface | html %]/[% theme | html %]/lib/respond.min.js"></script>
 <![endif]-->
-<script type="text/javascript">
+<script>
     function _(s) { return s } // dummy function for gettext
 </script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/lib/modernizr.min.js"></script>
+[% Asset.js("lib/modernizr.min.js") | $raw %]
 </head>
-<body onload="dofocus();" onunload="mungeHistory();">
+<body id="sco_main" class="sco" onload="dofocus();" onunload="mungeHistory();">
 [% INCLUDE 'masthead-sco.inc' %]
 
     <div class="main">
                     <div class="span12">
                 [% END %]
 
-                    <div id="masthead"><h1>[% LibraryName %] Self checkout system</h1></div>
+                    <div id="masthead"><h1>[% LibraryName | html %] Self checkout system</h1></div>
 
                     [% IF ( impossible ) %]<!-- We tried to issue, but failed. -->
                         <div class="alert">
                             <h3>Item cannot be checked out.</h3>
                             <p>Sorry, this item cannot be checked out at this station.</p>
                             [% IF ( title ) %]
-                                <p>Title: <em>[% title |html %]</em> </p>
+                                <p>Title: <em>[% title | html %]</em> </p>
                             [% END %]
 
                             <p>
                                 [% IF ( circ_error_UNKNOWN_BARCODE ) %]
-                                    <em>MESSAGE 1:</em> The system does not recognize this barcode.
+                                    The system does not recognize this barcode.
                                 [% ELSIF ( circ_error_max_loans_allowed ) %]
-                                    <em>MESSAGE 2:</em> You have checked out too many items and can't check out any more.
+                                    You have checked out too many items and can't check out any more.
                                 [% ELSIF ( circ_error_ISSUED_TO_ANOTHER ) %]
-                                <em>MESSAGE 3:</em> This item is checked out to someone else.
+                                    This item is checked out to someone else.
                                 [% ELSIF ( circ_error_NO_MORE_RENEWALS ) %]
-                                    <em>MESSAGE 4:</em> You cannot renew this item again.
+                                    You cannot renew this item again.
                                 [% ELSIF ( circ_error_NOT_FOR_LOAN ) %]
-                                    <em>MESSAGE 5:</em> This item is not for loan.
+                                    This item is not for loan.
                                 [% ELSIF ( circ_error_DEBT ) %]
-                                    <em>MESSAGE 6:</em> You owe the library [% amount %] and cannot check out.
+                                    You owe the library [% DEBT | $Price %] and cannot check out.
                                 [% ELSIF ( circ_error_WTHDRAWN ) %]
-                                    <em>MESSAGE 7:</em> This item has been withdrawn from the collection.
+                                    This item has been withdrawn from the collection.
                                 [% ELSIF ( circ_error_RESTRICTED ) %]
-                                    <em>MESSAGE 8:</em>
+                                    This item is restricted.
                                 [% ELSIF ( circ_error_RESERVED ) %]
-                                    <em>MESSAGE 9:</em> This item is on hold for another patron.
+                                    This item is on hold for another patron.
                                 [% ELSIF ( circ_error_ITEMNOTSAMEBRANCH ) %]
-                                    <em>MESSAGE 10:</em>
+                                    This item belongs to another branch.
                                 [% ELSIF ( circ_error_EXPIRED ) %]
-                                    <em>MESSAGE 11:</em> Your account has expired.
+                                    Your account has expired.
                                 [% ELSIF ( circ_error_DEBARRED ) %]
-                                    <em>MESSAGE 12:</em> Your account has been suspended.
+                                    Your account has been suspended.
                                 [% ELSIF ( circ_error_CARD_LOST ) %]
-                                    <em>MESSAGE 13:</em> This card has been declared lost.
+                                    This card has been declared lost.
                                 [% ELSIF ( circ_error_GNA ) %]
-                                    <em>MESSAGE 14:</em>
+                                    Your contact information seems to be incomplete.
                                 [% ELSIF ( circ_error_INVALID_DATE ) %]
-                                    <em>MESSAGE 15:</em>
-                                [% END # / IF circ_error_UNKNOWN_BARCODE %]
+                                    Due date is not valid.
+                                [% END %]
                                 Please see a member of the library staff.
                             </p>
 
-                            [% IF ( returnitem && AllowSelfCheckReturns ) %]
+                            [% IF ( returnitem && Koha.Preference('AllowSelfCheckReturns') ) %]
                                 <form action="/cgi-bin/koha/sco/sco-main.pl" name="errorForm" class="inline" method="post">
                                     <input type="hidden" name="op" value="returnbook" />
-                                    <input type="hidden" name="patronid" value="[% patronid %]" />
-                                    <input type="hidden" name="barcode" value="[% barcode %]" />
+                                    <input type="hidden" name="patronid" value="[% patronid | html %]" />
+                                    <input type="hidden" name="barcode" value="[% barcode | html %]" />
+                                    <input type="hidden" name="newissues" value="[% newissues | html %]" />
                                     <button type="submit" name="returnbook" class="btn"><i class="return"></i> Return this item</button>
                                 </form>
                             [% END %]
 
                             <form action="/cgi-bin/koha/sco/sco-main.pl" name="errorForm" class="inline" method="post">
                                 <input type="hidden" name="op" value="" />
-                                <input type="hidden" name="patronid" value="[% patronid %]" />
-                                <input type="hidden" name="barcode" value="[% barcode %]" />
+                                <input type="hidden" name="patronid" value="[% patronid | html %]" />
+                                <input type="hidden" name="barcode" value="[% barcode | html %]" />
+                                <input type="hidden" name="newissues" value="[% newissues | html %]" />
                                 <input type="submit" name= "confirm" value="Return to account summary" class="btn back focus" />
                             </form>
                         </div> <!-- / .alert -->
                                 <p>This item is already checked out to you.</p>
                             [% END %]
 
-                            [% IF ( renew && AllowSelfCheckReturns ) %]
+                            [% IF ( renew && Koha.Preference('AllowSelfCheckReturns') ) %]
                                 <form action="/cgi-bin/koha/sco/sco-main.pl" name="confirmForm" class="inline" method="post">
                                     <input type="hidden" name="op" value="returnbook" />
-                                    <input type="hidden" name="patronid" value="[% patronid %]" />
-                                    <input type="hidden" name="barcode" value="[% barcode %]" />
+                                    <input type="hidden" name="patronid" value="[% patronid | html %]" />
+                                    <input type="hidden" name="barcode" value="[% barcode | html %]" />
                                     <input type="hidden" name="confirmed" value="" />
+                                    <input type="hidden" name="newissues" value="[% newissues | html %]" />
                                     <button type="submit" name="returnbook" class="btn"><i class="icon return"></i> Return this item</button>
                                 </form>
                             [% END %]
                             [% UNLESS ( renew ) %]
                                 <form action="/cgi-bin/koha/sco/sco-main.pl" name="confirmForm" class="inline" method="post">
                                     <input type="hidden" name="op" value="checkout" />
-                                    <input type="hidden" name="patronid" value="[% patronid %]" />
-                                    <input type="hidden" name="barcode" value="[% barcode %]" />
+                                    <input type="hidden" name="patronid" value="[% patronid | html %]" />
+                                    <input type="hidden" name="barcode" value="[% barcode | html %]" />
                                     <input type="hidden" name="confirmed" value="1" />
+                                    <input type="hidden" name="newissues" value="[% newissues | html %]" />
                                     <button type="submit" name="confirm" class="btn"><i class="icon renew"></i> Renew item</button>
                                   </form>
                             [% ELSE %]
                                 <form action="/cgi-bin/koha/sco/sco-main.pl" name="confirmForm" class="inline" method="post">
                                     <input type="hidden" name="op" value="checkout" />
-                                    <input type="hidden" name="patronid" value="[% patronid %]" />
-                                    <input type="hidden" name="barcode" value="[% barcode %]" />
+                                    <input type="hidden" name="patronid" value="[% patronid | html %]" />
+                                    <input type="hidden" name="barcode" value="[% barcode | html %]" />
                                     <input type="hidden" name="confirmed" value="1" />
+                                    <input type="hidden" name="newissues" value="[% newissues | html %]" />
                                     <button type="submit" class="btn"><i class="icon renew"></i> Renew item</button>
                                 </form>
                             [% END %]
 
                             <form action="/cgi-bin/koha/sco/sco-main.pl" name="confirmForm" class="inline" method="post">
                                 <input type="hidden" name="op" value="" />
-                                <input type="hidden" name="patronid" value="[% patronid %]" />
+                                <input type="hidden" name="patronid" value="[% patronid | html %]" />
+                                <input type="hidden" name="newissues" value="[% newissues | html %]" />
                                 <button type="submit" class="btn"><i class="icon cancel"></i> Cancel</button>
                             </form>
                         </div>
                     [% END # / IF confirm %]
 
                     [% IF ( nopermission ) %]
-                        <!-- This is what is displayed if user doesnt have permission -->
+                        <!-- This is what is displayed if user doesn't have permission -->
                         <div class="alert">
                             <h3>Access denied</h3>
                             <p>Sorry, this self-checkout station has lost authentication.  Please contact the administrator to resolve this problem.</p>
                     [% END %]
 
                     [% IF ( different_ip ) %]
-                        <!-- This is what is displayed if user doesnt have permission -->
+                        <!-- This is what is displayed if user doesn't have permission -->
                         <div class="alert">
                             <h3>Session lost</h3>
                             <p>You are accessing self-checkout from a different IP address! please log in again.</p>
                     [% END %]
 
                     [% IF ( invalid_username_or_password ) %]
-                        <!-- This is what is displayed if user doesnt have permission -->
+                        <!-- This is what is displayed if user doesn't have permission -->
                         <div class="alert">
                             <h3>Record not found</h3>
                             <p>Your userid was not found in the database.  Please try again.</p>
                         </div>
                     [% END %]
 
+                    [% IF ( issued ) %]
+                    <span class="sco-alert-success"></span>
+                    <p>Item checked out</p>
+                    [% END %]
+
 
                     [% UNLESS ( hide_main ) %]
 
                         [% IF ( patronid ) %]
                             [% IF ( validuser ) %]
-                                <div class="alert alert-info">You are logged in as [% borrowername %].</div>
+                                <div class="alert alert-info">You are logged in as [% borrowername | html %].</div>
+                                [% INCLUDE 'opac-note.inc' %]
+                                [% IF patron_has_hold_fee %]
+                                    <div class="alert">A hold fee was charged to your account for collecting this item.</div>
+                                [% END %]
                             [% END %]
 
                             [% IF ( nouser ) %]
                                 <div class="alert">
                                     <h4>Sorry</h4>
-                                    <p>The userid <strong>[% patronid %]</strong> was not found in the database.  Please try again.</p>
+                                    <p>The userid <strong>[% patronid | html %]</strong> was not found in the database.  Please try again.</p>
                                 </div>
                             [% END %]
                         [% END # / IF patronid %]
 
                         [% IF ( validuser ) %]
                             <div id="newcheckout" class="sco_entry">
-                                <form id="scan_form" name="scan_form" method="post" action="/cgi-bin/koha/sco/sco-main.pl" onsubmit="return checkout_confirm('[% patronid %]');">
+                                <form id="scan_form" name="scan_form" method="post" action="/cgi-bin/koha/sco/sco-main.pl" onsubmit="return checkout_confirm('[% patronid | html %]');">
                                     <fieldset>
-                                        <legend>Check out[% IF ( AllowSelfCheckReturns ) %], return[% END %] or renew an item: </legend>
+                                        <legend>Check out[% IF ( Koha.Preference('AllowSelfCheckReturns') ) %], return[% END %] or renew an item: </legend>
                                         <div class="input-append">
                                             <label for="barcode">Scan a new item or enter its barcode:</label>
                                             <input id="barcode" name="barcode" size="20" type="text" class="focus" autocomplete="off" />
                                             <button type="submit" class="btn">Submit</button>
                                         </div>
                                         <input type="hidden" name="op" value="checkout" />
-                                        <input type="hidden" name="patronid" value="[% patronid %]" />
+                                        <input type="hidden" name="patronid" value="[% patronid | html %]" />
+                                        <input type="hidden" name="newissues" value="[% newissues | html %]" />
                                     </fieldset>
                                 </form>
 
                 </div> <!-- / .span12/12 -->
                 [% IF ( display_patron_image ) %]
                     <div class="span2">
-                        <img src="/cgi-bin/koha/sco/sco-patron-image.pl?cardnumber=[% cardnumber %]" alt="" />
+                        <img src="/cgi-bin/koha/sco/sco-patron-image.pl?borrowernumber=[% borrowernumber | html %]&csrf_token=[% csrf_token | html %]" alt="" />
                     </div>
                 [% END %]
             </div> <!-- / .row-fluid -->
                         <div id="borrowerdetails">
                             [% IF ( issues_count ) %]
                                 <table id="loanTable" class="table table-bordered table-striped">
-                                    <caption>Checkouts for [% borrowername %] <span class="count">([%   issues_count %] total)</span></caption>
+                                    <caption>Checkouts for [% borrowername | html %] <span class="count">([% issues_count | html %] total)</span></caption>
                                     <!-- ISSUES TABLE ROWS -->
                                     <thead>
-                                        <tr><th class="anti-the">Title</th><th>Call no.</th><th class="title-string">Due</th><th class="nosort">Renew</th>[% UNLESS ( nofines ) %]<th>Fines</th>[% END %]</tr>
+                                        <tr>
+                                            <th class="noshow">Checked out on</th>
+                                            <th class="anti-the">Title</th>
+                                            <th>Call no.</th>
+                                            <th class="title-string">Due</th>
+                                            <th class="nosort">Renew</th>
+                                            [% UNLESS ( nofines ) %]
+                                                <th>Fines</th>
+                                            [% END %]
+                                        </tr>
                                     </thead>
                                     <tbody>
                                         [% FOREACH ISSUE IN ISSUES %]
                                             <tr>
+                                                <td>[% ISSUE.issuedate | html %]</td>
                                                 <td>
                                                     [% UNLESS ( noitemlinks ) %]
-                                                        <a href="/cgi-bin/koha/opac-detail.pl?bib=[% ISSUE.  biblionumber %]">[% ISSUE.title |html %]</a>
+                                                        <a href="/cgi-bin/koha/opac-detail.pl?bib=[% ISSUE.  biblionumber | uri %]">[% ISSUE.title | html %]</a>
                                                     [% ELSE %]
-                                                        <strong>[% ISSUE.title |html %]</strong>
+                                                        <strong>[% ISSUE.title | html %]</strong>
+                                                    [% END %]
+                                                    [% IF ( newissues.match(ISSUE.barcode)) %]
+                                                        <span class="label label-info">NEW</span>
                                                     [% END %]
-                                                    <span class="item-details">[% ISSUE.author %]</span>
-                                                    ([% ISSUE.barcode %])
+                                                    <span class="item-details">[% ISSUE.author | html %]</span>
+                                                    ([% ISSUE.barcode | html %])
                                                 </td>
-                                                <td>[% ISSUE.itemcallnumber %]</td>
+                                                <td>[% ISSUE.itemcallnumber | html %]</td>
                                                 [% IF ( ISSUE.overdue ) %]
-                                                    <td class="overdue"><span title="[% ISSUE.date_due %]">[% ISSUE.date_due | $KohaDates %]</span></td>
+                                                    <td class="overdue"><span title="[% ISSUE.date_due | html %]">[% ISSUE.date_due | $KohaDates  as_due_date => 1 %]</span></td>
                                                 [% ELSE   %]
-                                                    <td><span title="[% ISSUE.date_due %]">[% ISSUE.date_due | $KohaDates %]</span></td>
+                                                    <td><span title="[% ISSUE.date_due | html %]">[% ISSUE.date_due | $KohaDates  as_due_date => 1 %]</span></td>
                                                 [% END %]
                                                 <td>
                                                     <form action="/cgi-bin/koha/sco/sco-main.pl" method="post">
-                                                        <input type="hidden" name="patronid" value="[% patronid %]" />
-                                                        <input type="hidden" name="barcode" value="[% ISSUE.barcode %]" />
-                                                        [% IF ( ISSUE.norenew ) %]
-                                                            [% IF ( AllowSelfCheckReturns ) %]
-                                                                <input type="submit" value="Check in item" name="confirm" class="btn return" />
-                                                                <input type="hidden" name="op" value="returnbook" />
-                                                                <input type="hidden" name="confirmed" value=""  />
-                                                            [% ELSE %]
-                                                                <span>No renewals allowed</span>
-                                                            [% END %]
-                                                        [% ELSE %]
+                                                        <input type="hidden" name="patronid" value="[% patronid | html %]" />
+                                                        <input type="hidden" name="barcode" value="[% ISSUE.barcode | html %]" />
+                                                        <input type="hidden" name="newissues" value="[% newissues | html %]" />
+                                                        [% IF ISSUE.can_be_renewed %]
                                                             <input type="hidden" name="op" value="checkout" />
                                                             <input type="hidden" name="confirmed" value="1" />
                                                             [% UNLESS ( ISSUE.renew ) %]
                                                             [% ELSE %]
                                                                 <input type="submit" value="Renew item" class="btn renew" />
                                                             [% END %]
+                                                        [% ELSE %]
+                                                            [% IF ISSUE.renew_error == 'auto_renew' OR ISSUE.renew_error == 'auto_too_soon' %]
+                                                                <span>This item has been scheduled for automatic renewal and cannot be renewed</span>
+                                                            [% ELSIF ISSUE.renew_error == 'onsite_checkout' %]
+                                                                <span>This is a on-site checkout, it cannot be renewed.</span>
+                                                            [% ELSE %]
+                                                                <span>No renewals allowed</span>
+                                                            [% END %]
+                                                            [% IF Koha.Preference('AllowSelfCheckReturns') %]
+                                                                <input type="submit" value="Check in item" name="confirm" class="btn return" />
+                                                                <input type="hidden" name="op" value="returnbook" />
+                                                                <input type="hidden" name="confirmed" value=""  />
+                                                            [% END %]
                                                         [% END %]
                                                     </form>
                                                 </td>
                             <div class="sco_entry" >
                                 <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
                                     <fieldset class="checkout brief">
-                                        [% IF ( authbylogin ) %]
+                                        [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
                                             <legend>Log in to your account</legend>
                                             <label for="patronlogin">Login:</label>
                                             <input type="text" id="patronlogin" class="focus" size="20" name="patronlogin" />
                                                 <input type="text" id="patronid" class="focus" size="20" name="patronid" autocomplete="off" />
                                                 <button type="submit" class="btn">Submit</button>
                                             </div>
-                                        [% END # / IF authbylogin %]
+                                        [% END %]
 
                                         [% FOREACH INPUT IN INPUTS %]
-                                            <input type="hidden" name="[% INPUT.name |html %]" value="[% INPUT.value |html %]">
+                                            <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]">
                                         [% END %]
                                         <input type="hidden" name="op" value="login" />
                                     </fieldset>
                             </div> <!-- / .sco_entry -->
                         [% END # / IF validuser %]
                     [% END # / UNLESS ( hide_main %]
-
+                    [% IF ( Koha.Preference('SCOMainUserBlock' ) ) %]<div id="scomainuserblock">[% Koha.Preference('SCOMainUserBlock' ) | $raw %]</div>[% END %]
                 </div> <!-- / .span12 -->
             </div> <!-- / .row-fluid -->
         </div> <!-- / .container-fluid -->
     </div> <!-- / .main -->
+    <span id="audio-alert"></span>
 
 [% INCLUDE 'opac-bottom.inc' %]
 [% BLOCK jsinclude %]
     [% INCLUDE 'datatables.inc' %]
-    <script type="text/javascript">
+    <script>
         //<![CDATA[
         function mungeHistory() {
             // prevent back button from allowing form resubmission
         function sco_init() {
             mainTimeout = setTimeout(function() {
                 location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
-            }, [% SelfCheckTimeout %]);
+            }, [% SelfCheckTimeout | html %]);
         }
         function dofocus() {    // named function req'd for body onload event by some FF and IE7 security models
             // alert("dofocus called");
             }
             return true;
         }
+        [% IF Koha.Preference('AudioAlerts') %]
+            var AUDIO_ALERTS = JSON.parse( "[% To.json(AudioAlerts.AudioAlerts) | $raw %]" );
+            $( document ).ready(function() {
+                if ( AUDIO_ALERTS ) {
+                    for ( var k in AUDIO_ALERTS ) {
+                        var alert = AUDIO_ALERTS[k];
+                        if ( $( alert.selector ).length ) {
+                            playSound( alert.sound );
+                            break;
+                        }
+                    }
+                }
+            });
+            function playSound( sound ) {
+                if (  ( sound.indexOf('http://') == 0 || sound.indexOf('https://') == 0 )  ) {
+                    document.getElementById("audio-alert").innerHTML = '<audio src="' + sound + '" autoplay="autoplay" autobuffer="autobuffer"></audio>';
+                }
+            }
+        [% END %]
+
 
         $(document).ready(function() {
             dofocus();
             [% IF ( patronid ) %]sco_init();[% END %]
             $("#loanTable").dataTable($.extend(true, {}, dataTablesDefaults, {
-                "aaSorting": [ [2, "desc"], [0, "asc"] ],
-                "aoColumnDefs": [
-                    { "aTargets": [ "nosort" ],"bSortable": false,"bSearchable": false },
-                    { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
-                    { "sType": "title-string", "aTargets" : [ "title-string" ] }
+                "order": [ 0 ],
+                "columnDefs": [
+                    { "targets": [ "nosort" ], "sortable": false, "searchable": false },
+                    { "targets": [ "noshow" ], "visible": false, "searchable": false },
+                    { "type": "anti-the", "targets" : [ "anti-the" ] },
+                    { "type": "title-string", "targets" : [ "title-string" ] }
                 ]
             }));
 
             $("#logout_form").submit(function(){
                 clearTimeout(mainTimeout);
                 [% IF Koha.Preference('SelfCheckReceiptPrompt') %]
-                    if(confirm("Would you like to print a receipt?")){
-                        window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber %]&amp;print=qslip");
+                    var confirmStart = Date.now();
+                    if(confirm(_("Would you like to print a receipt?"))){
+                        if ( (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) {
+                            window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber | html %]&amp;print=qslip");
+                        } else {
+                            alert(_("Timeout while waiting for print confirmation"));
+                        }
                     }
                 [% END %]
 
     //]]>
     </script>
 
-    [% IF ( opacuserjs ) %]<script type="text/javascript">[% opacuserjs %]</script>[% END %]
-    [% IF ( SCOUserJS ) %]<script type="text/javascript">[% SCOUserJS %]</script>[% END %]
+    [% IF ( Koha.Preference('SCOUserJS') ) %]<script>[% Koha.Preference('SCOUserJS') | $raw %]</script>[% END %]
 [% END %]