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

(-)a/C4/Circulation.pm (-16 / +15 lines)
Lines 800-825 sub CanBookBeIssued { Link Here
800
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
800
        $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges );
801
    }
801
    }
802
802
803
    my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'});
803
    my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
804
    if ($blocktype == -1) {
804
    if ( my $debarred_date = $patron->is_debarred ) {
805
        ## patron has outstanding overdue loans
805
         # patron has accrued fine days or has a restriction. $count is a date
806
	    if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){
806
        if ($debarred_date eq '9999-12-31') {
807
	        $issuingimpossible{USERBLOCKEDOVERDUE} = $count;
807
            $issuingimpossible{USERBLOCKEDNOENDDATE} = $debarred_date;
808
	    }
809
	    elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){
810
	        $needsconfirmation{USERBLOCKEDOVERDUE} = $count;
811
	    }
812
    } elsif($blocktype == 1) {
813
        # patron has accrued fine days or has a restriction. $count is a date
814
        if ($count eq '9999-12-31') {
815
            $issuingimpossible{USERBLOCKEDNOENDDATE} = $count;
816
        }
808
        }
817
        else {
809
        else {
818
            $issuingimpossible{USERBLOCKEDWITHENDDATE} = $count;
810
            $issuingimpossible{USERBLOCKEDWITHENDDATE} = $debarred_date;
811
        }
812
    } elsif ( my $num_overdues = $patron->has_overdues ) {
813
        ## patron has outstanding overdue loans
814
        if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){
815
            $issuingimpossible{USERBLOCKEDOVERDUE} = $num_overdues;
816
        }
817
        elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){
818
            $needsconfirmation{USERBLOCKEDOVERDUE} = $num_overdues;
819
        }
819
        }
820
    }
820
    }
821
821
822
#
823
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
822
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
824
    #
823
    #
825
    my $switch_onsite_checkout =
824
    my $switch_onsite_checkout =
Lines 847-853 sub CanBookBeIssued { Link Here
847
    #
846
    #
848
    # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
847
    # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON
849
    #
848
    #
850
    my $patron = Koha::Patrons->find($borrower->{borrowernumber});
849
    $patron = Koha::Patrons->find($borrower->{borrowernumber});
851
    my $wants_check = $patron->wants_check_for_previous_checkout;
850
    my $wants_check = $patron->wants_check_for_previous_checkout;
852
    $needsconfirmation{PREVISSUE} = 1
851
    $needsconfirmation{PREVISSUE} = 1
853
        if ($wants_check and $patron->do_check_for_previous_checkout($item));
852
        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