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

(-)a/C4/Circulation.pm (-16 / +15 lines)
Lines 801-826 sub CanBookBeIssued { Link Here
801
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
801
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
802
    }
802
    }
803
803
804
    my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'});
804
    my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
805
    if ($blocktype == -1) {
805
    if ( my $debarred_date = $patron->is_debarred ) {
806
        ## patron has outstanding overdue loans
806
         # patron has accrued fine days or has a restriction. $count is a date
807
	    if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){
807
        if ($debarred_date eq '9999-12-31') {
808
	        $issuingimpossible{USERBLOCKEDOVERDUE} = $count;
808
            $issuingimpossible{USERBLOCKEDNOENDDATE} = $debarred_date;
809
	    }
810
	    elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){
811
	        $needsconfirmation{USERBLOCKEDOVERDUE} = $count;
812
	    }
813
    } elsif($blocktype == 1) {
814
        # patron has accrued fine days or has a restriction. $count is a date
815
        if ($count eq '9999-12-31') {
816
            $issuingimpossible{USERBLOCKEDNOENDDATE} = $count;
817
        }
809
        }
818
        else {
810
        else {
819
            $issuingimpossible{USERBLOCKEDWITHENDDATE} = $count;
811
            $issuingimpossible{USERBLOCKEDWITHENDDATE} = $debarred_date;
812
        }
813
    } elsif ( my $num_overdues = $patron->has_overdues ) {
814
        ## patron has outstanding overdue loans
815
        if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){
816
            $issuingimpossible{USERBLOCKEDOVERDUE} = $num_overdues;
817
        }
818
        elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){
819
            $needsconfirmation{USERBLOCKEDOVERDUE} = $num_overdues;
820
        }
820
        }
821
    }
821
    }
822
822
823
#
824
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
823
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
825
    #
824
    #
826
    my $switch_onsite_checkout =
825
    my $switch_onsite_checkout =
Lines 848-854 sub CanBookBeIssued { Link Here
848
    #
847
    #
849
    # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
848
    # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
850
    #
849
    #
851
    my $patron = Koha::Patrons->find($borrower->{borrowernumber});
850
    $patron = Koha::Patrons->find($borrower->{borrowernumber});
852
    my $wants_check = $patron->wants_check_for_previous_checkout;
851
    my $wants_check = $patron->wants_check_for_previous_checkout;
853
    $needsconfirmation{PREVISSUE} = 1
852
    $needsconfirmation{PREVISSUE} = 1
854
        if ($wants_check and $patron->do_check_for_previous_checkout($item));
853
        if ($wants_check and $patron->do_check_for_previous_checkout($item));
(-)a/C4/Members.pm (-45 lines)
Lines 75-81 BEGIN { Link Here
75
75
76
        &GetHideLostItemsPreference
76
        &GetHideLostItemsPreference
77
77
78
        &IsMemberBlocked
79
        &GetMemberAccountRecords
78
        &GetMemberAccountRecords
80
        &GetBorNotifyAcctRecord
79
        &GetBorNotifyAcctRecord
81
80
Lines 461-509 sub GetMember { Link Here
461
    return;
460
    return;
462
}
461
}
463
462
464
=head2 IsMemberBlocked
465
466
  my ($block_status, $count) = IsMemberBlocked( $borrowernumber );
467
468
Returns whether a patron is restricted or has overdue items that may result
469
in a block of circulation privileges.
470
471
C<$block_status> can have the following values:
472
473
1 if the patron is currently restricted, in which case
474
C<$count> is the expiration date (9999-12-31 for indefinite)
475
476
-1 if the patron has overdue items, in which case C<$count> is the number of them
477
478
0 if the patron has no overdue items or outstanding fine days, in which case C<$count> is 0
479
480
Existing active restrictions are checked before current overdue items.
481
482
=cut
483
484
sub IsMemberBlocked {
485
    my $borrowernumber = shift;
486
    my $dbh            = C4::Context->dbh;
487
488
    my $blockeddate = Koha::Patrons->find( $borrowernumber )->is_debarred;
489
490
    return ( 1, $blockeddate ) if $blockeddate;
491
492
    # if he have late issues
493
    my $sth = $dbh->prepare(
494
        "SELECT COUNT(*) as latedocs
495
         FROM issues
496
         WHERE borrowernumber = ?
497
         AND date_due < now()"
498
    );
499
    $sth->execute($borrowernumber);
500
    my $latedocs = $sth->fetchrow_hashref->{'latedocs'};
501
502
    return ( -1, $latedocs ) if $latedocs > 0;
503
504
    return ( 0, 0 );
505
}
506
507
=head2 GetMemberIssuesAndFines
463
=head2 GetMemberIssuesAndFines
508
464
509
  ($overdue_count, $issue_count, $total_fines) = &GetMemberIssuesAndFines($borrowernumber);
465
  ($overdue_count, $issue_count, $total_fines) = &GetMemberIssuesAndFines($borrowernumber);
510
- 

Return to bug 16850