Bug 12691: Use Koha.Preference in Self-Checkout
authorAleisha Amohia <aleishaamohia@hotmail.com>
Fri, 27 Jan 2017 03:37:31 +0000 (03:37 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 7 Sep 2017 17:03:45 +0000 (14:03 -0300)
For calls to SCOUserJS, SCOUserCSS, OPACUserCSS, AllowSelfCheckReturns,
OpacFavicon, ShowPatronImageInWebBasedSelfCheck, SelfCheckoutByLogin

Sponsored-by: Catalyst IT
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Bug 12691: [FOLLOW-UP] Follow-up patch

This patch fixes merge conflicts and fixes the problems in Comment 7

QA tools complain about missing bracket, will be fixed in next followup
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Bug 12691: [FOLLOW-UP] Missing bracket

Patch adds bracket to template file (Comment 16)

Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Bug 12691: [FOLLOW-UP] Fixing some logic

Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Patches have been squashed for readability and 1 removal occurrence of
display_patron_image has been reintroduced.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt
opac/sco/sco-main.pl

index f7fae7b..7357d89 100644 (file)
@@ -5,12 +5,12 @@
 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% 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="shortcut icon" href="[% IF ( Koha.Preference('OpacFavicon') ) %][% Koha.Preference('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 %]
+[% IF ( Koha.Preference('OPACUserCSS') ) %]<style type="text/css">[% Koha.Preference('OPACUserCSS') %]</style>[% END %]
+[% IF ( Koha.Preference('SCOUserCSS') ) %]<style type="text/css">[% Koha.Preference('SCOUserCSS') %]</style>[% END %]
 <!--[if lt IE 9]>
     <script src="[% interface %]/[% theme %]/lib/respond.min.js"></script>
 <![endif]-->
@@ -76,7 +76,7 @@
                                 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 %]" />
                                 <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 %]" />
                             <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 %]');">
                                     <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" />
                                                             [% ELSE %]
                                                                 <span>No renewals allowed</span>
                                                             [% END %]
-                                                            [% IF AllowSelfCheckReturns %]
+                                                            [% 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=""  />
                             <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 %]">
     //]]>
     </script>
 
-    [% IF ( SCOUserJS ) %]<script type="text/javascript">[% SCOUserJS %]</script>[% END %]
+    [% IF ( Koha.Preference('SCOUserJS') ) %]<script type="text/javascript">[% Koha.Preference('SCOUserJS') %]</script>[% END %]
 [% END %]
index 4020e27..d6e4176 100755 (executable)
@@ -76,25 +76,18 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({
     debug => 1,
 });
 
-if (C4::Context->preference('SelfCheckoutByLogin'))
-{
-    $template->param(authbylogin  => 1);
-}
-
 # Get the self checkout timeout preference, or use 120 seconds as a default
 my $selfchecktimeout = 120000;
 if (C4::Context->preference('SelfCheckTimeout')) { 
     $selfchecktimeout = C4::Context->preference('SelfCheckTimeout') * 1000;
 }
-$template->param(SelfCheckTimeout => $selfchecktimeout);
+$template->param( SelfCheckTimeout => $selfchecktimeout );
 
 # Checks policy laid out by AllowSelfCheckReturns, defaults to 'on' if preference is undefined
 my $allowselfcheckreturns = 1;
 if (defined C4::Context->preference('AllowSelfCheckReturns')) {
     $allowselfcheckreturns = C4::Context->preference('AllowSelfCheckReturns');
 }
-$template->param(AllowSelfCheckReturns => $allowselfcheckreturns);
-
 
 my $issuerid = $loggedinuser;
 my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed) = (
@@ -304,7 +297,6 @@ if ($borrower) {
         my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
         $template->param(
             display_patron_image => 1,
-            cardnumber           => $borrower->{cardnumber},
             csrf_token           => Koha::Token->new->generate_csrf( { session_id => scalar $query->cookie('CGISESSID') . $borrower->{cardnumber}, id => $borrower->{userid}} ),
         ) if $patron_image;
     }
@@ -315,9 +307,4 @@ if ($borrower) {
     );
 }
 
-$template->param(
-    SCOUserJS  => C4::Context->preference('SCOUserJS'),
-    SCOUserCSS => C4::Context->preference('SCOUserCSS'),
-);
-
 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };