View | Details | Raw Unified | Return to bug 8137
Collapse All | Expand All

(-)a/C4/Circulation.pm (-17 / +7 lines)
Lines 433-455 sub TooMany { Link Here
433
    # Now count total loans against the limit for the branch
433
    # Now count total loans against the limit for the branch
434
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
434
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
435
    if (defined($branch_borrower_circ_rule->{maxissueqty})) {
435
    if (defined($branch_borrower_circ_rule->{maxissueqty})) {
436
        my @bind_params = ();
436
        my $branch_count_query = "
437
        my $branch_count_query = "SELECT COUNT(*) FROM issues
437
            SELECT COUNT(*) FROM issues
438
                                  JOIN items USING (itemnumber)
438
            JOIN items USING (itemnumber)
439
                                  WHERE borrowernumber = ? ";
439
            WHERE borrowernumber = ?
440
        push @bind_params, $borrower->{borrowernumber};
440
        ";
441
441
442
        if (C4::Context->preference('CircControl') eq 'PickupLibrary') {
443
            $branch_count_query .= " AND issues.branchcode = ? ";
444
            push @bind_params, $branch;
445
        } elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') {
446
            ; # if branch is the patron's home branch, then count all loans by patron
447
        } else {
448
            $branch_count_query .= " AND items.homebranch = ? ";
449
            push @bind_params, $branch;
450
        }
451
        my $branch_count_sth = $dbh->prepare($branch_count_query);
442
        my $branch_count_sth = $dbh->prepare($branch_count_query);
452
        $branch_count_sth->execute(@bind_params);
443
        $branch_count_sth->execute( $borrower->{borrowernumber} );
453
        my ($current_loan_count) = $branch_count_sth->fetchrow_array;
444
        my ($current_loan_count) = $branch_count_sth->fetchrow_array;
454
445
455
        my $max_loans_allowed = $branch_borrower_circ_rule->{maxissueqty};
446
        my $max_loans_allowed = $branch_borrower_circ_rule->{maxissueqty};
456
- 

Return to bug 8137