From 0df5149266345f7e67ae0fe96631eac5c0a525ab Mon Sep 17 00:00:00 2001
From: Mason James
Date: Fri, 5 Jun 2015 00:14:32 +1200
Subject: [PATCH] Bug 10554: Add more options to 'AllowSelfCheckReturns'
syspref
Content-Type: text/plain; charset="utf-8"
---
installer/data/mysql/atomicupdate/bug_10554.perl | 33 ++++++++++++++++++++++
installer/data/mysql/sysprefs.sql | 2 +-
.../en/modules/admin/preferences/circulation.pref | 5 ++--
.../opac-tmpl/bootstrap/en/modules/sco/sco-main.tt | 8 ++++--
opac/sco/sco-main.pl | 7 +++--
5 files changed, 48 insertions(+), 7 deletions(-)
create mode 100755 installer/data/mysql/atomicupdate/bug_10554.perl
diff --git a/installer/data/mysql/atomicupdate/bug_10554.perl b/installer/data/mysql/atomicupdate/bug_10554.perl
new file mode 100755
index 0000000..1818a67
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_10554.perl
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use C4::Context;
+
+my $dbh = C4::Context->dbh;
+
+my $DBversion = "XXX";
+
+#if ( CheckVersion($DBversion) ) {
+
+#get current value
+my $newval = 0;
+my $oldval = $dbh->selectcol_arrayref(
+"SELECT value from systempreferences where variable = 'AllowSelfCheckReturns'"
+);
+
+$newval = $oldval =~ /1/ ? 'nonblocked' : 'none';
+
+# update syspref
+my $sth_update = $dbh->prepare(
+ "UPDATE systempreferences
+ SET value=?, options='all|nonblocked|none', type='Choice' WHERE variable='AllowSelfCheckReturns'"
+);
+$sth_update->execute($newval);
+
+print
+"Upgrade to $DBversion done (BZ-10544 added 'nonblocked' to AllowSelfCheckReturns syspref)\n";
+
+# SetVersion($DBversion);
+#}
+
diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index 6568967..1f0ba41 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -30,7 +30,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo'),
('AllowRenewalLimitOverride','0',NULL,'if ON, allows renewal limits to be overridden on the circulation screen','YesNo'),
('AllowReturnToBranch','anywhere','anywhere|homebranch|holdingbranch|homeorholdingbranch','Where an item may be returned','Choice'),
-('AllowSelfCheckReturns','0','','If enabled, patrons may return items through the Web-based Self Checkout','YesNo'),
+('AllowSelfCheckReturns','none','If enabled, patrons may return items through the Web-based Self Checkout','all|nonblocked|none','Choice');
('AllowTooManyOverride','1','','If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts','YesNo'),
('alphabet','A B C D E F G H I J K L M N O P Q R S T U V W X Y Z',NULL,'Alphabet than can be expanded into browse links, e.g. on Home > Patrons','free'),
('AlternateHoldingsField','',NULL,'The MARC field/subfield that contains alternate holdings information for bibs taht do not have items attached (e.g. 852abchi for libraries converting from MARC Magician).','free'),
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 df72493..666e62d 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
@@ -657,8 +657,9 @@ Circulation:
-
- pref: AllowSelfCheckReturns
choices:
- yes: Allow
- no: "Don't allow"
+ all: "Allow all"
+ nonblocked: "Allow non-blocked"
+ none: "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:"
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 3f0b1f3..ac01b53 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
@@ -75,7 +75,8 @@
Please see a member of the library staff.
- [% IF ( returnitem && AllowSelfCheckReturns ) %]
+ [% IF (AllowSelfCheckReturns == 'nonblocked' and returnitem ) or AllowSelfCheckReturns == 'all' %]
+
+ [% END %]
[% END %]
[% UNLESS ( renew ) %]
diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl
index b214f54..9998db7 100755
--- a/opac/sco/sco-main.pl
+++ b/opac/sco/sco-main.pl
@@ -83,7 +83,8 @@ if (C4::Context->preference('SelfCheckTimeout')) {
$template->param(SelfCheckTimeout => $selfchecktimeout);
# Checks policy laid out by AllowSelfCheckReturns, defaults to 'on' if preference is undefined
-my $allowselfcheckreturns = 1;
+my $allowselfcheckreturns = 'nonblocked';
+
if (defined C4::Context->preference('AllowSelfCheckReturns')) {
$allowselfcheckreturns = C4::Context->preference('AllowSelfCheckReturns');
}
@@ -124,7 +125,8 @@ my $return_only = 0;
if ($op eq "logout") {
$query->param( patronid => undef, patronlogin => undef, patronpw => undef );
}
-elsif ( $op eq "returnbook" && $allowselfcheckreturns ) {
+elsif ( $op eq "returnbook" && $allowselfcheckreturns =~ /nonblocked|all/) {
+
my ($doreturn) = AddReturn( $barcode, $branch );
#warn "returnbook: " . $doreturn;
$borrower = GetMemberDetails(undef,$patronid);
@@ -180,6 +182,7 @@ elsif ( $op eq "checkout" ) {
confirm => 1,
confirm_renew_issue => 1,
hide_main => 1,
+ barcode => $barcode,
);
}
} elsif ( $confirm_required && !$confirmed ) {
--
2.1.4