From bd6bf476af0d35f4693b2386f2ead980ad370013 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 SCO receipt printing

Toggled SCO receipt printing to be on by default for upgrades
in updatedatabase.pl.

Updated files to set default to 1 in sysprefs.sql.  Also added
code to read the system preference on the template page.

Added code to update prog theme with same changes as the
bootstrap theme.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
---
 installer/data/mysql/sysprefs.sql                  |    1 +
 installer/data/mysql/updatedatabase.pl             |    8 ++++++++
 .../en/modules/admin/preferences/circulation.pref  |    7 +++++++
 .../opac-tmpl/bootstrap/en/modules/sco/sco-main.tt |    4 ++++
 .../opac-tmpl/prog/en/modules/sco/sco-main.tt      |    3 +++
 5 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index 0de3ac7..556bd72 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','1','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 80ab210..e324198 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -7912,6 +7912,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', '1', '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..33ae4c9 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..b98ba61 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
@@ -1,3 +1,4 @@
+[% USE Koha %]
 [% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha [% END %] &rsaquo; Self checkout </title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@@ -356,8 +357,11 @@
 
             $("#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");
+     [% END %]
+
                 }
                 return true;
             });
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 6ab8b11..2fbdefb 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
@@ -1,3 +1,4 @@
+[% USE Koha %]
 [% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha [% END %] &rsaquo; Self checkout </title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@@ -90,8 +91,10 @@ $(document).ready(function() {
     }));
     $("#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");
+   [%END %]
         }
         return true;
     });
-- 
1.7.2.5