From cf04347d6ad71f8d5d276a52b6e9b080cca4f344 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 22 May 2012 13:14:36 -0400 Subject: [PATCH] [SIGNED-OFF] Bug 8137 - Checkout limit by patron category for all libraries Content-Type: text/plain; charset="utf-8" We have a patron category Temporary Adult WTMP. Under "Checkout limit by patron category for all libraries" the limit is set to 5. This limit is not working. I was able to check out 7 items to a patron in the WTMP category. If the item's home library is LibA, and the borrower has 4 items checked out whose home library is LibA, than the item will be checked out ( regardless of how many items are checked out ). If the borrower has 5 items checked out whose home library is LibA, Koha will indeed warn of too many checkouts. I think circcontrol is being mis-used here. It should use the maxissueqty for the item's home library ( or fallback to the 'all libraries' rule ), but it should still count all issues from any library Signed-off-by: Marc Veron How I teested: Set patrons category restriction to 2 checkouts. Set checkout restrictions for libraries to 10 checkouts. Without patch, I could checkout more items than allowed by patrons category restriction (but only if items from different libraries were involved). With patch, the patrons category restriction was respected (warning: 'Too many checked out. 2 checked out, only 2 are allowed.'). Patch behaves as described.expected. --- C4/Circulation.pm | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 9508c78..88694be 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -433,23 +433,13 @@ sub TooMany { # Now count total loans against the limit for the branch my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower); if (defined($branch_borrower_circ_rule->{maxissueqty})) { - my @bind_params = (); - my $branch_count_query = "SELECT COUNT(*) FROM issues - JOIN items USING (itemnumber) - WHERE borrowernumber = ? "; - push @bind_params, $borrower->{borrowernumber}; - - if (C4::Context->preference('CircControl') eq 'PickupLibrary') { - $branch_count_query .= " AND issues.branchcode = ? "; - push @bind_params, $branch; - } elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') { - ; # if branch is the patron's home branch, then count all loans by patron - } else { - $branch_count_query .= " AND items.homebranch = ? "; - push @bind_params, $branch; - } + my $branch_count_query = " + SELECT COUNT(*) FROM issues + WHERE borrowernumber = ? + "; + my $branch_count_sth = $dbh->prepare($branch_count_query); - $branch_count_sth->execute(@bind_params); + $branch_count_sth->execute( $borrower->{borrowernumber} ); my ($current_loan_count) = $branch_count_sth->fetchrow_array; my $max_loans_allowed = $branch_borrower_circ_rule->{maxissueqty}; -- 1.7.2.5