From 8a1c4527f6f56c1f26a9a8b09d85ed3a8b30abdb Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Mon, 5 Nov 2012 12:22:24 -0500
Subject: [PATCH] Bug 9009 - Add separate user js and css for SCO module
Content-Type: text/plain; charset="utf-8"

---
 installer/data/mysql/sysprefs.sql                  |    2 ++
 installer/data/mysql/updatedatabase.pl             |    8 ++++++++
 .../en/modules/admin/preferences/circulation.pref  |   10 ++++++++++
 koha-tmpl/opac-tmpl/prog/en/modules/sco/help.tt    |    3 +++
 koha-tmpl/opac-tmpl/prog/en/modules/sco/receipt.tt |    2 ++
 .../opac-tmpl/prog/en/modules/sco/sco-main.tt      |    3 ++-
 opac/sco/help.pl                                   |    5 +++++
 opac/sco/sco-main.pl                               |    5 +++++
 8 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index a4e4102..0c95776 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -386,3 +386,5 @@ INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidy
 INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free');
 INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HoldsToPullStartDate','2','Set the default start date for the Holds to pull list to this many days ago',NULL,'Integer');
+INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('SCOUserCSS', '', NULL, 'Add CSS to be included in the SCO module in an embedded <style> tag.', 'free');
+INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('SCOUserJS', '', NULL, 'Define custom javascript for inclusion in the SCO module', 'free');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 7ab48ee..0ca797e 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -6020,6 +6020,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
    SetVersion ($DBversion);
 }
 
+$DBversion = "3.09.00.XXX";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+   $dbh->do("INSERT INTO systempreferences ( variable, value, explanation, type ) VALUES ( 'SCOUserCSS', '', 'Add CSS to be included in the SCO module in an embedded <style> tag.', 'free' )");
+   $dbh->do("INSERT INTO systempreferences ( variable, value, explanation, type ) VALUES ( 'SCOUserJS', '', 'Define custom javascript for inclusion in the SCO module', 'free' )");
+   print "Upgrade to $DBversion done (Add SCOUserCSS and SCOUserJS  sysprefs)\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 c583bbe..17f164d 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
@@ -454,6 +454,16 @@ Circulation:
             - fines (when <code>misc/cronjobs/fines.pl</code> is being run).
     Self Checkout:
         -
+            - "Include the following JavaScript on all pages in the web-based self checkout:"
+            - pref: SCOUserJS
+              type: textarea
+              class: code
+        -
+            - "Include the following CSS on all pages in the web-based self checkout:"
+            - pref: SCOUserCSS
+              type: textarea
+              class: code
+        -
             - pref: ShowPatronImageInWebBasedSelfCheck
               choices:
                   yes: Show
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/sco/help.tt b/koha-tmpl/opac-tmpl/prog/en/modules/sco/help.tt
index 32b4f56..f2fa3a9 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/sco/help.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/sco/help.tt
@@ -6,6 +6,9 @@
 <link rel="stylesheet" type="text/css" href="[% yuipath %]/reset-fonts-grids.css" />
 <link rel="stylesheet" type="text/css" href="[% yuipath %]/skin.css" />
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/sco.css" />
+[% IF ( SCOUserCSS ) %]<style type="text/css">[% SCOUserCSS %]</style>[% END %]
+
+[% IF ( SCOUserJS ) %]<script type="text/javascript">[% SCOUserJS %]</script>[% END %]
 </head>
 <body>
 <div id="doc" class="yui-t7">
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/sco/receipt.tt b/koha-tmpl/opac-tmpl/prog/en/modules/sco/receipt.tt
index 8178412..7e363d2 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/sco/receipt.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/sco/receipt.tt
@@ -26,6 +26,8 @@ function closeNow()
 }
 </script> 
 
+[% IF ( SCOUserCSS ) %]<style type="text/css">[% SCOUserCSS %]</style>[% END %]
+[% IF ( SCOUserJS ) %]<script type="text/javascript">[% SCOUserJS %]</script>[% END %]
 
 </head>
 
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 66cace5..0366df9 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
@@ -95,12 +95,13 @@ $(document).ready(function() {
 
 </script>
 [% IF ( opacuserjs ) %]<script type="text/javascript">[% opacuserjs %]</script>[% END %]
-
+[% IF ( SCOUserJS ) %]<script type="text/javascript">[% SCOUserJS %]</script>[% END %]
 
 <link rel="stylesheet" type="text/css" href="[% yuipath %]/reset-fonts-grids.css" />
 <link rel="stylesheet" type="text/css" href="[% yuipath %]/skin.css" />
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/sco.css" />
 [% IF ( OPACUserCSS ) %]<style type="text/css">[% OPACUserCSS %]</style>[% END %]
+[% IF ( SCOUserCSS ) %]<style type="text/css">[% SCOUserCSS %]</style>[% END %]
 
 </head>
 <body onload="dofocus();">
diff --git a/opac/sco/help.pl b/opac/sco/help.pl
index b3f4398..abcb396 100755
--- a/opac/sco/help.pl
+++ b/opac/sco/help.pl
@@ -52,5 +52,10 @@ if (C4::Context->preference('SelfCheckHelpMessage')) {
     $template->param(SelfCheckHelpMessage => C4::Context->preference('SelfCheckHelpMessage'));
 }
 
+$template->param(
+    SCOUserJS  => C4::Context->preference('SCOUserJS'),
+    SCOUserCSS => C4::Context->preference('SCOUserCSS'),
+);
+
 output_html_with_http_headers $query, $cookie, $template->output;
 
diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl
index 26a8774..58ac2c6 100755
--- a/opac/sco/sco-main.pl
+++ b/opac/sco/sco-main.pl
@@ -263,4 +263,9 @@ if ($borrower->{cardnumber}) {
     );
 }
 
+$template->param(
+    SCOUserJS  => C4::Context->preference('SCOUserJS'),
+    SCOUserCSS => C4::Context->preference('SCOUserCSS'),
+);
+
 output_html_with_http_headers $query, $cookie, $template->output;
-- 
1.7.2.5