From: Kyle M Hall <[email protected]>

Adds a new system preference AllowTooManyOverride to control whether
a librarian can override the 'Too many checked out' message which is
currently always overridable.

Test Plan:
1) Apply patch
2) Run updatedatabase.pl
3) Attempt to check out 1 more item to a patron than the max issues
4) You should be allowed to override by default ( current behavior )
5) Set AllowTooManyOverride to "Don't allow"
6) Repeat step 3
7) You should be blocked from being able to issue the item

Signed-off-by: Srdjan <[email protected]>
---
 C4/Circulation.pm                                            | 12 +++++++++---
 installer/data/mysql/sysprefs.sql                            |  1 +
 installer/data/mysql/updatedatabase.pl                       |  6 ++++++
 .../prog/en/modules/admin/preferences/circulation.pref       |  6 ++++++
 koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt  |  4 ++++
 5 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 30cbe2f..6fd3bd0 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -826,9 +826,15 @@ sub CanBookBeIssued {
         $needsconfirmation{PATRON_CANT} = 1;
     } else {
         if($max_loans_allowed){
-            $needsconfirmation{TOO_MANY} = 1;
-            $needsconfirmation{current_loan_count} = $current_loan_count;
-            $needsconfirmation{max_loans_allowed} = $max_loans_allowed;
+            if ( C4::Context->preference("AllowTooManyOverride") ) {
+                $needsconfirmation{TOO_MANY} = 1;
+                $needsconfirmation{current_loan_count} = $current_loan_count;
+                $needsconfirmation{max_loans_allowed} = $max_loans_allowed;
+            } else {
+                $issuingimpossible{TOO_MANY} = 1;
+                $issuingimpossible{current_loan_count} = $current_loan_count;
+                $issuingimpossible{max_loans_allowed} = $max_loans_allowed;
+            }
         }
     }
 
diff --git a/installer/data/mysql/sysprefs.sql 
b/installer/data/mysql/sysprefs.sql
index 31485bc..55555f6 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -427,3 +427,4 @@ INSERT INTO systempreferences 
(variable,value,explanation,options,type) VALUES('
 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) 
VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 
'YesNo');
 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpacShowHoldNotes',0,'Show hold notes on OPAC','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES 
('CalculateFinesOnReturn','1','Switch to control if overdue fines are 
calculated on return or not', '', 'YesNo');
+INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) 
VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check 
out items when the patron has reached the maximum number of allowed checkouts', 
'', 'YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl 
b/installer/data/mysql/updatedatabase.pl
index f3a90d8..6f9edb9 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -6983,6 +6983,12 @@ INSERT INTO systempreferences 
(variable,value,explanation,options,type) VALUES (
     SetVersion($DBversion);
 }
 
+$DBversion ="3.13.00.XXX";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("INSERT IGNORE INTO systempreferences 
(variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 
'If on, allow staff to override and check out items when the patron has reached 
the maximum number of allowed checkouts', '', 'YesNo');");
+    print "Upgrade to $DBversion done (Bug 9576 - Enable or disable issue 
limit confirmation)\n";
+    SetVersion($DBversion);
+}
 
 =head1 FUNCTIONS
 
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 64cf338..c286ed1 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
@@ -126,6 +126,12 @@ Circulation:
 
     Checkout Policy:
         -
+            - pref: AllowTooManyOverride
+              choices:
+                  yes: Allow
+                  no: "Don't allow"
+            - staff to override and check out items when the patron has 
reached the maximum number of allowed checkouts.
+        -
             - pref: AllowNotForLoanOverride
               choices:
                   yes: Allow
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt 
b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
index 42a9b27..b71eee1 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
@@ -520,6 +520,10 @@ function validate1(date) {
             <li>Patron's card is expired</li>
         [% END %]
 
+        [% IF ( TOO_MANY ) %]
+            <li>Too many checked out. [% current_loan_count %] checked out, 
only [% max_loans_allowed %] are allowed.</li>
+        [% END %]
+
         [% IF ( ITEMNOTSAMEBRANCH ) %]
             <li>This item belongs to [% itemhomebranch %] and cannot be issued 
from this location.</li>
         [% END %]
-- 
1.8.1.2
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to