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

(-)a/C4/Circulation.pm (-16 / +15 lines)
Lines 903-928 sub CanBookBeIssued { Link Here
903
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
903
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
904
    }
904
    }
905
905
906
    my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'});
906
    my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
907
    if ($blocktype == -1) {
907
    if ( my $debarred_date = $patron->is_debarred ) {
908
        ## patron has outstanding overdue loans
908
         # patron has accrued fine days or has a restriction. $count is a date
909
	    if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){
909
        if ($debarred_date eq '9999-12-31') {
910
	        $issuingimpossible{USERBLOCKEDOVERDUE} = $count;
910
            $issuingimpossible{USERBLOCKEDNOENDDATE} = $debarred_date;
911
	    }
912
	    elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){
913
	        $needsconfirmation{USERBLOCKEDOVERDUE} = $count;
914
	    }
915
    } elsif($blocktype == 1) {
916
        # patron has accrued fine days or has a restriction. $count is a date
917
        if ($count eq '9999-12-31') {
918
            $issuingimpossible{USERBLOCKEDNOENDDATE} = $count;
919
        }
911
        }
920
        else {
912
        else {
921
            $issuingimpossible{USERBLOCKEDWITHENDDATE} = $count;
913
            $issuingimpossible{USERBLOCKEDWITHENDDATE} = $debarred_date;
914
        }
915
    } elsif ( my $num_overdues = $patron->has_overdues ) {
916
        ## patron has outstanding overdue loans
917
        if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){
918
            $issuingimpossible{USERBLOCKEDOVERDUE} = $num_overdues;
919
        }
920
        elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){
921
            $needsconfirmation{USERBLOCKEDOVERDUE} = $num_overdues;
922
        }
922
        }
923
    }
923
    }
924
924
925
#
926
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
925
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
927
    #
926
    #
928
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
927
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
Lines 945-951 sub CanBookBeIssued { Link Here
945
    #
944
    #
946
    # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
945
    # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
947
    #
946
    #
948
    my $patron = Koha::Patrons->find($borrower->{borrowernumber});
947
    $patron = Koha::Patrons->find($borrower->{borrowernumber});
949
    my $wants_check = $patron->wants_check_for_previous_checkout;
948
    my $wants_check = $patron->wants_check_for_previous_checkout;
950
    $needsconfirmation{PREVISSUE} = 1
949
    $needsconfirmation{PREVISSUE} = 1
951
        if ($wants_check and $patron->do_check_for_previous_checkout($item));
950
        if ($wants_check and $patron->do_check_for_previous_checkout($item));
(-)a/C4/Members.pm (-45 lines)
Lines 76-82 BEGIN { Link Here
76
76
77
        &GetHideLostItemsPreference
77
        &GetHideLostItemsPreference
78
78
79
        &IsMemberBlocked
80
        &GetMemberAccountRecords
79
        &GetMemberAccountRecords
81
        &GetBorNotifyAcctRecord
80
        &GetBorNotifyAcctRecord
82
81
Lines 467-515 sub GetMember { Link Here
467
    return;
466
    return;
468
}
467
}
469
468
470
=head2 IsMemberBlocked
471
472
  my ($block_status, $count) = IsMemberBlocked( $borrowernumber );
473
474
Returns whether a patron is restricted or has overdue items that may result
475
in a block of circulation privileges.
476
477
C<$block_status> can have the following values:
478
479
1 if the patron is currently restricted, in which case
480
C<$count> is the expiration date (9999-12-31 for indefinite)
481
482
-1 if the patron has overdue items, in which case C<$count> is the number of them
483
484
0 if the patron has no overdue items or outstanding fine days, in which case C<$count> is 0
485
486
Existing active restrictions are checked before current overdue items.
487
488
=cut
489
490
sub IsMemberBlocked {
491
    my $borrowernumber = shift;
492
    my $dbh            = C4::Context->dbh;
493
494
    my $blockeddate = Koha::Patrons->find( $borrowernumber )->is_debarred;
495
496
    return ( 1, $blockeddate ) if $blockeddate;
497
498
    # if he have late issues
499
    my $sth = $dbh->prepare(
500
        "SELECT COUNT(*) as latedocs
501
         FROM issues
502
         WHERE borrowernumber = ?
503
         AND date_due < now()"
504
    );
505
    $sth->execute($borrowernumber);
506
    my $latedocs = $sth->fetchrow_hashref->{'latedocs'};
507
508
    return ( -1, $latedocs ) if $latedocs > 0;
509
510
    return ( 0, 0 );
511
}
512
513
=head2 GetMemberIssuesAndFines
469
=head2 GetMemberIssuesAndFines
514
470
515
  ($overdue_count, $issue_count, $total_fines) = &GetMemberIssuesAndFines($borrowernumber);
471
  ($overdue_count, $issue_count, $total_fines) = &GetMemberIssuesAndFines($borrowernumber);
516
- 

Return to bug 16850