From a67ef801a38b0829a20f36d2db4f0e4d86692b3b Mon Sep 17 00:00:00 2001
From: Elliott Davis <elliott@bywatersolutions.com>
Date: Thu, 5 Jul 2012 09:51:36 -0500
Subject: [PATCH] Adds a print receipt to Self Checkout
Content-Type: text/plain; charset="utf-8"

To Test:
Log in to self checkout
Enter a barcode and click submit
You will be asked if you would like a receipt
If you click ok you should be taken to the print receipt page and the item should check out
if you click cancel the item should be checked out

http://bugs.koha-community.org/show_bug.cgi?id=8033
---
 .../opac-tmpl/prog/en/modules/sco/sco-main.tt      |   10 ++++++++++
 opac/sco/printslip.pl                              |    8 ++------
 opac/sco/sco-main.pl                               |    1 +
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/prog/en/modules/sco/sco-main.tt
index 8eb9f08..baac23a 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/sco/sco-main.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/sco/sco-main.tt
@@ -8,6 +8,7 @@
 <script type="text/javascript" src="[% yuipath %]/container/container-min.js"></script>
 <script type="text/javascript" src="[% yuipath %]/menu/menu-min.js"></script>
 <script type="text/javascript" src="[% themelang %]/lib/jquery/jquery.js"></script>
+<script type="text/javascript" src="[% themelang %]/lib/jquery/jquery-ui.js"></script>
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
 <script type="text/javascript">//<![CDATA[
 function sco_init(valid_session) {
@@ -19,6 +20,12 @@ function dofocus() {    // named function req'd for body onload event by some FF
     // alert("dofocus called");
     $(".focus:last").select();
 }
+var slip_re = /slip/;
+function printx_window(print_type) {
+  var handler = print_type.match(slip_re) ? "printslip" : "moremember";
+
+  return false;
+}
 
 function checkout_confirm(patronid) {
     var   barcode = $("#barcode").val();
@@ -35,6 +42,9 @@ function checkout_confirm(patronid) {
             this.patronid.value='';
         }
     }
+    if(confirm("Would you like to print a receipt?")){
+      window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber %]&amp;print=qslip");
+    }
     return true;
 }
 
diff --git a/opac/sco/printslip.pl b/opac/sco/printslip.pl
index 3a499cd..70e97cf 100755
--- a/opac/sco/printslip.pl
+++ b/opac/sco/printslip.pl
@@ -60,15 +60,11 @@ my $error = $input->param('error');
 
 # circ staff who process checkouts but can't edit
 # patrons still need to be able to print receipts
-my $flagsrequired = { circulate => "circulate_remaining_permissions" };
-
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
-        template_name   => "circ/printslip.tmpl",
+        template_name   => "/sco/printslip.tmpl",
         query           => $input,
-        type            => "intranet",
-        authnotrequired => 0,
-        flagsrequired   => $flagsrequired,
+        type            => "opac",
         debug           => 1,
     }
 );
diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl
index 243dddd..2c22fd9 100755
--- a/opac/sco/sco-main.pl
+++ b/opac/sco/sco-main.pl
@@ -236,6 +236,7 @@ if ($borrower->{cardnumber}) {
         patronlogin => $patronlogin,
         patronpw => $patronpw,
         noitemlinks => 1 ,
+	borrowernumber => $borrower->{'borrowernumber'},
     );
     my $inputfocus = ($return_only      == 1) ? 'returnbook' :
                      ($confirm_required == 1) ? 'confirm'    : 'barcode' ;
-- 
1.7.2.5