@@ -, +, @@ --- C4/Circulation.pm | 31 +++++++++++++++---------------- C4/Members.pm | 44 -------------------------------------------- 2 files changed, 15 insertions(+), 60 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -903,26 +903,25 @@ sub CanBookBeIssued { $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges ); } - my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'}); - if ($blocktype == -1) { - ## patron has outstanding overdue loans - if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){ - $issuingimpossible{USERBLOCKEDOVERDUE} = $count; - } - elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){ - $needsconfirmation{USERBLOCKEDOVERDUE} = $count; - } - } elsif($blocktype == 1) { - # patron has accrued fine days or has a restriction. $count is a date - if ($count eq '9999-12-31') { - $issuingimpossible{USERBLOCKEDNOENDDATE} = $count; + my $patron = Koha::Patrons->find( $borrower->{borrowernumber} ); + if ( my $debarred_date = $patron->is_debarred ) { + # patron has accrued fine days or has a restriction. $count is a date + if ($debarred_date eq '9999-12-31') { + $issuingimpossible{USERBLOCKEDNOENDDATE} = $debarred_date; } else { - $issuingimpossible{USERBLOCKEDWITHENDDATE} = $count; + $issuingimpossible{USERBLOCKEDWITHENDDATE} = $debarred_date; + } + } elsif ( my $num_overdues = $patron->has_overdues ) { + ## patron has outstanding overdue loans + if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){ + $issuingimpossible{USERBLOCKEDOVERDUE} = $num_overdues; + } + elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){ + $needsconfirmation{USERBLOCKEDOVERDUE} = $num_overdues; } } -# # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS # my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } ); @@ -945,7 +944,7 @@ sub CanBookBeIssued { # # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON # - my $patron = Koha::Patrons->find($borrower->{borrowernumber}); + $patron = Koha::Patrons->find($borrower->{borrowernumber}); my $wants_check = $patron->wants_check_for_previous_checkout; $needsconfirmation{PREVISSUE} = 1 if ($wants_check and $patron->do_check_for_previous_checkout($item)); --- a/C4/Members.pm +++ a/C4/Members.pm @@ -74,7 +74,6 @@ BEGIN { &GetHideLostItemsPreference - &IsMemberBlocked &GetMemberAccountRecords &GetBorNotifyAcctRecord @@ -465,49 +464,6 @@ sub GetMember { return; } -=head2 IsMemberBlocked - - my ($block_status, $count) = IsMemberBlocked( $borrowernumber ); - -Returns whether a patron is restricted or has overdue items that may result -in a block of circulation privileges. - -C<$block_status> can have the following values: - -1 if the patron is currently restricted, in which case -C<$count> is the expiration date (9999-12-31 for indefinite) - --1 if the patron has overdue items, in which case C<$count> is the number of them - -0 if the patron has no overdue items or outstanding fine days, in which case C<$count> is 0 - -Existing active restrictions are checked before current overdue items. - -=cut - -sub IsMemberBlocked { - my $borrowernumber = shift; - my $dbh = C4::Context->dbh; - - my $blockeddate = Koha::Patrons->find( $borrowernumber )->is_debarred; - - return ( 1, $blockeddate ) if $blockeddate; - - # if he have late issues - my $sth = $dbh->prepare( - "SELECT COUNT(*) as latedocs - FROM issues - WHERE borrowernumber = ? - AND date_due < now()" - ); - $sth->execute($borrowernumber); - my $latedocs = $sth->fetchrow_hashref->{'latedocs'}; - - return ( -1, $latedocs ) if $latedocs > 0; - - return ( 0, 0 ); -} - =head2 GetMemberIssuesAndFines ($overdue_count, $issue_count, $total_fines) = &GetMemberIssuesAndFines($borrowernumber); --