Bug 5578: Self checkout by Login enhancement
authorIan Walls <ian.walls@bywatersolutions.com>
Wed, 30 Mar 2011 20:40:12 +0000 (16:40 -0400)
committerChris Cormack <chrisc@catalyst.net.nz>
Fri, 1 Apr 2011 02:18:40 +0000 (15:18 +1300)
Enables the library to choose whether to have patrons scan their barcodes for self checkout, or login
with username and password.  Uses 'checkpw' for compatibility with LDAP authentication.

Also introduces a few new system preferences to make Self Checkout more secure and manageable:

  SelfCheckTimeOut:      the number of seconds before the self-checkout login times out for a patron
  AllowSelfCheckReturns: indicate whether or not patrons can return materials via self-checkout
  SelfCheckHelpMessage:  user-configurable HTML to show specific text on the Help page.

Thank you to Marlboro College in Marlboro, VT for sponsoring and testing this development!

Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
15 files changed:
C4/Circulation.pm
circ/circulation.pl
installer/data/mysql/de-DE/mandatory/sysprefs.sql
installer/data/mysql/en/mandatory/sysprefs.sql
installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
installer/data/mysql/it-IT/necessari/sysprefs.sql
installer/data/mysql/pl-PL/mandatory/sysprefs.sql
installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql
installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
koha-tmpl/opac-tmpl/prog/en/modules/sco/help.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/sco/sco-main.tmpl
opac/sco/help.pl
opac/sco/sco-main.pl

index 31adc21..275b7ba 100644 (file)
@@ -14,9 +14,9 @@ package C4::Circulation;
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
 
 
 use strict;
@@ -2691,6 +2691,7 @@ C<$startdate>   = C4::Dates object representing start date of loan period (assum
 C<$itemtype>  = itemtype code of item in question
 C<$branch>  = location whose calendar to use
 C<$borrower> = Borrower object
+
 =cut
 
 sub CalcDateDue { 
@@ -2698,14 +2699,21 @@ sub CalcDateDue {
        my $datedue;
         my $loanlength = GetLoanLength($borrower->{'categorycode'},$itemtype, $branch);
 
-       if(C4::Context->preference('useDaysMode') eq 'Days') {  # ignoring calendar
-               my $timedue = time + ($loanlength) * 86400;
-       #FIXME - assumes now even though we take a startdate 
-               my @datearr  = localtime($timedue);
-               $datedue = C4::Dates->new( sprintf("%04d-%02d-%02d", 1900 + $datearr[5], $datearr[4] + 1, $datearr[3]), 'iso');
+       # if globalDueDate ON the datedue is set to that date
+       if ( C4::Context->preference('globalDueDate')
+             && ( C4::Context->preference('globalDueDate') =~ C4::Dates->regexp('syspref') ) ) {
+            $datedue = C4::Dates->new( C4::Context->preference('globalDueDate') );
        } else {
-               my $calendar = C4::Calendar->new(  branchcode => $branch );
-               $datedue = $calendar->addDate($startdate, $loanlength);
+       # otherwise, calculate the datedue as normal
+               if(C4::Context->preference('useDaysMode') eq 'Days') {  # ignoring calendar
+                       my $timedue = time + ($loanlength) * 86400;
+               #FIXME - assumes now even though we take a startdate 
+                       my @datearr  = localtime($timedue);
+                       $datedue = C4::Dates->new( sprintf("%04d-%02d-%02d", 1900 + $datearr[5], $datearr[4] + 1, $datearr[3]), 'iso');
+               } else {
+                       my $calendar = C4::Calendar->new(  branchcode => $branch );
+                       $datedue = $calendar->addDate($startdate, $loanlength);
+               }
        }
 
        # if Hard Due Dates are used, retreive them and apply as necessary
@@ -2729,7 +2737,6 @@ sub CalcDateDue {
            $datedue = C4::Dates->new( $borrower->{dateexpiry}, 'iso' );
        }
 
-
        return $datedue;
 }
 
index e521e19..1e7d42e 100755 (executable)
@@ -16,9 +16,9 @@
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
 #use warnings; FIXME - Bug 2505
index 394cc00..e96a1f6 100755 (executable)
@@ -138,6 +138,9 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 -- need AddressType to distinguish between US and other, telephone numbers, maori stuff, sex, nationality, etc.
 -- LDAP ? required fields?
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON, enables the web-based self-check system',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckTimeout',120,'Define the number of seconds before the Web-based Self Checkout times out a patron','','Integer');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowSelfCheckReturns',0,'If enabled, patrons may return items through the Web-based Self Checkout','','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckHelpMessage','','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','70|10','Textarea');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('numSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACnumSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortField',NULL,'Specify the default field used for sorting','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice');
index e370693..fa9c27f 100755 (executable)
@@ -139,6 +139,9 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 -- need AddressType to distinguish between US and other, telephone numbers, maori stuff, sex, nationality, etc.
 -- LDAP ? required fields?
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON, enables the web-based self-check system',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckTimeout',120,'Define the number of seconds before the Web-based Self Checkout times out a patron','','Integer');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowSelfCheckReturns',0,'If enabled, patrons may return items through the Web-based Self Checkout','','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckHelpMessage','','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','70|10','Textarea');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('numSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACnumSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortField',NULL,'Specify the default field used for sorting','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice');
index c5e0dbd..f489da8 100755 (executable)
@@ -140,6 +140,9 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ThingISBN',0,'Utilisé avec ''FRBRizeEditions''. Si activé, Koha utilisera le service ''ThingISBN'' dans l''onglet  supplémentaire de la page de détail de notice.','','YesNo');
 
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'Si activé, permet le système de prêt auto-controlé à partir de l''opac (/cgi-bin/koha/sco/sco-main.pl',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckTimeout',120,'Define the number of seconds before the Web-based Self Checkout times out a patron','','Integer');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowSelfCheckReturns',0,'If enabled, patrons may return items through the Web-based Self Checkout','','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckHelpMessage','','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','70|10','Textarea');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('numSearchResults',20,'Spécifie le nombre maximum de réponses à afficher sur les pages de résultats',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACnumSearchResults',20,'Spécifie le nombre maximum de réponses à afficher sur les pages de résultats',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortField',NULL,'Spécifie le champ utilisé par défaut pour le tri','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice');
index 12340d9..8022eed 100755 (executable)
@@ -211,6 +211,9 @@ insert into `systempreferences` (`variable`, `value`, `options`, `explanation`,
 ---
 --- Add from eng
 ---
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckTimeout',120,'Define the number of seconds before the Web-based Self Checkout times out a patron','','Integer');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowSelfCheckReturns',0,'If enabled, patrons may return items through the Web-based Self Checkout','','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckHelpMessage','','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','70|10','Textarea');
 INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('AcqCreateItem','cataloguing','ordering|receiving|cataloguing','Define when the item is created : when ordering, when receiving, or in cataloguing module','Choice');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowHoldDateInFuture','0','If set a date field is displayed on the Hold screen of the Staff Interface, allowing the hold date to be set in the future.','','YesNo');
index 443d93e..9a62f0d 100755 (executable)
@@ -137,6 +137,9 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 -- need AddressType to distinguish between US and other, telephone numbers, maori stuff, sex, nationality, etc.
 -- LDAP ? required fields?
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON, enables the web-based self-check system',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckTimeout',120,'Define the number of seconds before the Web-based Self Checkout times out a patron','','Integer');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowSelfCheckReturns',0,'If enabled, patrons may return items through the Web-based Self Checkout','','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckHelpMessage','','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','70|10','Textarea');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('numSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACnumSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortField',NULL,'Specify the default field used for sorting','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice');
index 4653834..8e87494 100755 (executable)
@@ -166,6 +166,9 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 -- need AddressType to distinguish between US and other, telephone numbers, maori stuff, sex, nationality, etc.
 -- LDAP ? required fields?
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON, enables the web-based self-check system',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckTimeout',120,'Define the number of seconds before the Web-based Self Checkout times out a patron','','Integer');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowSelfCheckReturns',0,'If enabled, patrons may return items through the Web-based Self Checkout','','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckHelpMessage','','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','70|10','Textarea');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('numSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACnumSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortField',NULL,'Specify the default field used for sorting','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice');
index 2c8b7de..1523ee3 100755 (executable)
@@ -165,6 +165,9 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 -- need AddressType to distinguish between US and other, telephone numbers, maori stuff, sex, nationality, etc.
 -- LDAP ? required fields?
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON, enables the web-based self-check system',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckTimeout',120,'Define the number of seconds before the Web-based Self Checkout times out a patron','','Integer');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowSelfCheckReturns',0,'If enabled, patrons may return items through the Web-based Self Checkout','','YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SelfCheckHelpMessage','','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','70|10','Textarea');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('numSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACnumSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'Integer');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortField',NULL,'Specify the default field used for sorting','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice');
index e710b51..c011887 100755 (executable)
@@ -4181,6 +4181,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = '3.03.00.XXX';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SelfCheckTimeout',120,'Define the number of seconds before the Web-based Self Checkout times out a patron','','Integer')");
+    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowSelfCheckReturns',0,'If enabled, patrons may return items through the Web-based Self Checkout','','YesNo')");
+    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SelfCheckHelpMessage','','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','70|10','Textarea')");
+    print "Upgrade to $DBversion done ( Add Self-checkout by Login system preferences )\n";
+    SetVersion ($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 DropAllForeignKeys($table)
index 6670dee..9e74e4a 100644 (file)
@@ -320,6 +320,28 @@ Circulation:
                   yes: Enable
                   no: "Don't enable"
             - "the web-based self checkout system. (available at: /cgi-bin/koha/sco/sco-main.pl)"
+        -
+            - Have patrons login into the web-based self checkout system with their 
+            - pref: SelfCheckoutByLogin
+              choices:
+                  yes: Username and Password
+                  no: Barcode
+        -
+            - "Time out the current patron's web-based self checkout system login after"
+            - pref: SelfCheckTimeout
+              class: integer
+            - seconds.
+        -
+            - pref: AllowSelfCheckReturns
+              choices:
+                  yes: Allow
+                  no: "Don't allow"
+            - patrons to return items through web-based self checkout system. 
+        -
+            - "Include the following HTML in the Help page of the web-based self checkout system:"
+            - pref: SelfCheckHelpMessage
+              type: textarea
+              class: code
         -
             - pref: AutoSelfCheckAllowed
               choices:
index 5af86f9..1f56727 100644 (file)
 
 <h1>Self Checkout Help</h1>
 
+<!-- TMPL_IF NAME="SelfCheckHelpMessage" -->
+<div id="selfcheckhelpmessage">
+<!-- TMPL_VAR NAME="SelfCheckHelpMessage" -->
+</div>
+<!-- /TMPL_IF -->
+
 <p>If this is your first time using the self checkout system, or if the system
 is not behaving as expected, you may want to refer to this guide to get
 yourself started.</p>
 
-<h3>Step One: Enter your user id</h3>
-<p>Enter your User ID, and click the submit button (or press the enter key).</p>
+<h3>Step One: Enter your user id<!-- TMPL_IF name="SelfCheckoutByLogin" --> and password<!-- /TMPL_IF --></h3>
+<p>Enter your User ID<!-- TMPL_IF name="SelfCheckoutByLogin" --> and password<!-- /TMPL_IF -->, and click the 
+submit button (or press the enter key).</p>
 
 <h3>Step Two: Scan the barcode for each item, one at a time</h3>
 <p>Scan each item and wait for the page to reload before scanning the next item.
@@ -25,6 +32,8 @@ The checked-out item should appear in your checkouts list.
 The Submit button only needs to be clicked if you enter the barcode manually.</p>
 
 <h3>Step Three: Click the 'Finish' button</h3>
+<p>If you do not click the 'Finish' button, your session will automatically expire in
+<!-- TMPL_VAR name="SelfCheckTimeout" --> seconds.</p>
 
     <div class="button">
         <a href="javascript:history.go(-1)">Return to the Self-Checkout</a>
index bf5b33d..bb260e2 100644 (file)
@@ -7,7 +7,7 @@
 <script type="text/javascript">//<![CDATA[
 function sco_init(valid_session) {
     if (valid_session == 1) {
-        setTimeout("location.href='/cgi-bin/koha/sco/sco-main.pl?op=logout';",120000); // TODO: syspref for timeout
+        setTimeout("location.href='/cgi-bin/koha/sco/sco-main.pl?op=logout';",<!-- TMPL_VAR name="SelfCheckTimeout" -->); 
     }
 }
 function dofocus() {    // named function req'd for body onload event by some FF and IE7 security models
@@ -110,15 +110,17 @@ $(document).ready(function() {
 <input type="hidden" name="op" value="login" />
 <input type="hidden" name="patronid" value="<!-- TMPL_VAR NAME="patronid" -->" />
 <!-- TMPL_IF NAME="returnitem" -->
+<!-- TMPL_IF NAME="AllowSelfCheckReturns" -->
 <input type="hidden" name="barcode" value="<!-- TMPL_VAR NAME="barcode" -->" />
 <input type="button" name="returnbook" value="Return this item" class="return" onclick="this.form.op.value='returnbook';this.form.submit();"  />
 <!-- /TMPL_IF -->
+<!-- /TMPL_IF -->
 <input type="submit" name= "confirm" value="Return to Account Summary" class="back focus" />
 </form>
 <!-- /TMPL_IF -->
 <!-- TMPL_IF NAME="confirm" --><!-- We need to confirm the issue.. -->
 <div class="dialog alert"><h3>Please confirm the checkout:</h3>
-<p><!-- TMPL_IF NAME="confirm_renew_issue" -->This item is already checked out to you.  Return it?<!-- /TMPL_IF --></p>
+<p><!-- TMPL_IF NAME="confirm_renew_issue" -->This item is already checked out to you.<!-- /TMPL_IF --></p>
 
 <form action="/cgi-bin/koha/sco/sco-main.pl" name="confirmForm" method="post">
 <input type="hidden" name="op" value="checkout" />
@@ -126,8 +128,10 @@ $(document).ready(function() {
 <input type="hidden" name="barcode" value="<!-- TMPL_VAR NAME="barcode" -->" />
 <input type="hidden" name="confirmed" value="" />
 <!-- TMPL_IF NAME="renew" -->
+<!-- TMPL_IF NAME="AllowSelfCheckReturns" -->
 <input type="button" value="Return Item" name="confirm" class="return" onclick="this.form.op.value='returnbook';this.form.submit();"  />
 <!-- /TMPL_IF -->
+<!-- /TMPL_IF -->
 <input type="button" value="Renew Item" <!-- TMPL_UNLESS NAME="renew" --> name="confirm"<!-- /TMPL_UNLESS --> class="renew" onclick="this.form.confirmed.value='1';this.form.submit();" />
 <input type="button" value="Cancel" class="cancel" onclick="this.form.op.value='';this.form.submit();return true;"  />
 </form>
@@ -175,7 +179,7 @@ Sorry, This Self-Checkout Station has lost authentication.  Please contact the a
        <!-- TMPL_IF NAME="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('<!-- TMPL_VAR NAME='patronid' -->');">
-       <fieldset><legend> Check out or return an item: </legend>
+       <fieldset><legend> Check out<!--TMPL_IF NAME="AllowSelfCheckReturns" -->, return<!--/TMPL_IF --> or renew an item: </legend>
        <label for="barcode">Scan a new item or enter its barcode:</label>
        <input id="barcode" name="barcode" size="20" class="focus" />
        <input type="hidden" name="op" value="checkout" />
@@ -209,7 +213,11 @@ Sorry, This Self-Checkout Station has lost authentication.  Please contact the a
     <input type="hidden" name="barcode" value="<!-- TMPL_VAR NAME="barcode" -->" />
     <input type="hidden" name="confirmed" value=""  />
         <!-- TMPL_IF NAME="norenew" -->
-        <input type="button" value="Return Item" name="confirm" class="return" onclick="this.form.op.value='returnbook';this.form.submit();"  />
+          <!-- TMPL_IF NAME="AllowSelfCheckReturns" -->
+          <input type="button" value="Return Item" name="confirm" class="return" onclick="this.form.op.value='returnbook';this.form.submit();"  />
+          <!-- TMPL_ELSE -->
+          <span>No renewals allowed</span>
+          <!-- /TMPL_IF -->
         <!-- TMPL_ELSE  -->
         <input type="button" value="Renew Item" <!-- TMPL_UNLESS NAME="renew" --> name="confirm"<!-- /TMPL_UNLESS --> class="renew" onclick="this.form.confirmed.value='1';this.form.submit();" />
         <!-- /TMPL_IF -->
@@ -227,8 +235,17 @@ Sorry, This Self-Checkout Station has lost authentication.  Please contact the a
        <!-- TMPL_ELSE --><!-- not validuser -->
        <div class="sco_entry" >
        <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
+       <!-- TMPL_IF NAME="authbylogin" -->
+       <fieldset class="checkout">
+       <legend>Please login with your username and password</legend>
+       <label for="patronlogin">Username:</label>
+       <input type="text" id="patronlogin" class="focus" size="20" name="patronlogin" />
+       <label for="patronpw">Password:</label>
+       <input type="password" id="patronpw" size="20" name="patronpw" />
+       <!-- TMPL_ELSE -->
        <fieldset class="checkout"><label for="patronid">Please enter your card number:</label> 
        <input type="text" id="patronid" class="focus" size="20" name="patronid" />
+       <!-- /TMPL_IF -->
 
        <!-- TMPL_LOOP NAME="INPUTS" --><input type="hidden" name="<!-- TMPL_VAR ESCAPE=HTML NAME="name" -->" value="<!-- TMPL_VAR ESCAPE=HTML NAME="value" -->"><!-- /TMPL_LOOP -->
        <input type="hidden" name="op" value="login" />
index b2cbd00..fbc182d 100755 (executable)
@@ -22,5 +22,19 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({
       flagsrequired => {circulate => "circulate_remaining_permissions"},
 });
 
+if (C4::Context->preference('SelfCheckoutByLogin')) {
+    $template->param(SelfCheckoutByLogin => 1);
+}
+my $selfchecktimeout = 120;
+if (C4::Context->preference('SelfCheckTimeout')) {
+   $selfchecktimeout = C4::Context->preference('SelfCheckTimeout');
+}
+
+$template->param(SelfCheckTimeout => $selfchecktimeout);
+
+if (C4::Context->preference('SelfCheckHelpMessage')) {
+    $template->param(SelfCheckHelpMessage => C4::Context->preference('SelfCheckHelpMessage'));
+}
+
 output_html_with_http_headers $query, $cookie, $template->output;
 
index 9895892..b36ff64 100755 (executable)
@@ -18,8 +18,9 @@ use strict;
 use warnings;
 
 use CGI;
+use Digest::MD5 qw(md5_base64);
 
-use C4::Auth;
+use C4::Auth qw(get_template_and_user checkpw);
 use C4::Koha;
 use C4::Dates qw/format_date/;
 use C4::Circulation;
@@ -54,35 +55,60 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({
     type  => "opac",
     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);
+
+# 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, $barcode, $confirmed, $timedout) = (
+my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $timedout) = (
     $query->param("op")         || '',
     $query->param("patronid")   || '',
+    $query->param("patronlogin")|| '',
+    $query->param("patronpw")   || '',
     $query->param("barcode")    || '',
     $query->param("confirmed")  || '',
     $query->param("timedout")   || '', #not actually using this...
 );
 
-my %confirmation_strings = ( RENEW_ISSUE => "This item is already checked out to you.  Return it?", );
 my $issuenoconfirm = 1; #don't need to confirm on issue.
 #warn "issuerid: " . $issuerid;
 my $issuer   = GetMemberDetails($issuerid);
 my $item     = GetItem(undef,$barcode);
+if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) {
+    my $dbh = C4::Context->dbh;
+    my $resval, $patronid = checkpw($dbh, $patronlogin, $patronpw);
+}
 my $borrower = GetMemberDetails(undef,$patronid);
 
+
 my $branch = $issuer->{branchcode};
 my $confirm_required = 0;
 my $return_only = 0;
 #warn "issuer cardnumber: " .   $issuer->{cardnumber};
 #warn "patron cardnumber: " . $borrower->{cardnumber};
 if ($op eq "logout") {
-    $query->param( patronid => undef );
+    $query->param( patronid => undef, patronlogin => undef, patronpw => undef );
 }
-elsif ( $op eq "returnbook" ) {
+elsif ( $op eq "returnbook" && $allowselfcheckreturns ) {
     my ($doreturn) = AddReturn( $barcode, $branch );
     #warn "returnbook: " . $doreturn;
-    $borrower = GetMemberDetails( undef, $patronid );   # update borrower
+    $borrower = GetMemberDetails(undef,$patronid);
 }
 elsif ( $op eq "checkout" ) {
     my $impossible  = {};
@@ -180,6 +206,8 @@ if ($borrower->{cardnumber}) {
         issues_count => scalar(@issues),
         ISSUES => \@issues,
         patronid => $patronid,
+        patronlogin => $patronlogin,
+        patronpw => $patronpw,
         noitemlinks => 1 ,
     );
     my $inputfocus = ($return_only      == 1) ? 'returnbook' :