From 842bca330cb250310c350c7b741baf1f71efb4bb Mon Sep 17 00:00:00 2001
From: JaTara Barnes <jendayi30@gmail.com>
Date: Sun, 5 Jan 2014 00:33:31 -0600
Subject: [PATCH] Bug 11415: Add syspref to toggle receipt printing for
 self-check

---
 installer/data/mysql/sysprefs.sql                                 | 1 +
 installer/data/mysql/updatedatabase.pl                            | 8 ++++++++
 .../prog/en/modules/admin/preferences/circulation.pref            | 7 +++++++
 koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt          | 3 +++
 4 files changed, 19 insertions(+)

diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index 0de3ac7..30733bf 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -332,6 +332,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('SearchEngine','Zebra','Solr|Zebra','Search Engine','Choice'),
 ('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
 ('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
+('SelfCheckReceiptPrompt','0','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'),
 ('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'),
 ('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
 ('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index d0255a4..068656e 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -7885,6 +7885,14 @@ if(CheckVersion($DBversion)) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.15.00.XXX";
+if(CheckVersion($DBversion)) {
+   $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('SelfCheckReceiptPrompt', '0', 'NULL', 'If ON, print receipt dialog pops up when self checkout is finished.', 'YesNo');");
+    print "Upgrade to $DBversion done (Bug 11415: add system preference for self checkout receipt print)\n";
+    SetVersion($DBversion);
+}
+
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
index 2c5469b..adba7a5 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -592,6 +592,13 @@ Circulation:
             - and this password
             - pref: AutoSelfCheckPass
             - .
+        -
+            - pref: SelfCheckReceiptPrompt
+              choices:
+                  yes: Show 
+                  no: "Don't show"
+            - "the print receipt popup dialog when self checkout is finished" 
+	    
     Course Reserves:
         -
             - pref: UseCourseReserves
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt
index b1c2f11..f87f201 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt
@@ -356,8 +356,11 @@
 
             $("#logout_form").submit(function(){
                 clearTimeout(mainTimeout);
+            [% IF ( SelfCheckReceiptPrompt ) %] 
                 if(confirm("Would you like to print a receipt?")){
                     window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber %]&amp;print=qslip");
+	    [% END %]
+
                 }
                 return true;
             });
-- 
1.8.5.2.msysgit.0