From 6a6780086a52c4fa855b5a787e04b82d001847ec Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 22 May 2012 13:14:36 -0400 Subject: [PATCH] Bug 8137 - Checkout limit by patron category for all libraries 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 --- C4/Circulation.pm | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index c26de76..00a0018 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