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

(-)a/C4/ILSDI/Utility.pm (-51 / +1 lines)
Lines 38-44 BEGIN { Link Here
38
    require Exporter;
38
    require Exporter;
39
    @ISA    = qw(Exporter);
39
    @ISA    = qw(Exporter);
40
    @EXPORT = qw(
40
    @EXPORT = qw(
41
      &BorrowerExists &CanBookBeReserved &Availability
41
      &BorrowerExists &Availability
42
    );
42
    );
43
}
43
}
44
44
Lines 67-121 sub BorrowerExists { Link Here
67
    return $sth->fetchrow;
67
    return $sth->fetchrow;
68
}
68
}
69
69
70
=head2 CanBookBeReserved
71
72
Checks if a book (at bibliographic level) can be reserved by a borrower.
73
74
	if ( CanBookBeReserved($borrower, $biblionumber) ) {
75
		# Do stuff
76
	}
77
78
=cut
79
80
sub CanBookBeReserved {
81
    my ( $borrower, $biblionumber ) = @_;
82
83
    my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves");
84
    my $MAXOUTSTANDING             = C4::Context->preference("maxoutstanding");
85
86
    my $out = 1;
87
88
    if ( $borrower->{'amountoutstanding'} > $MAXOUTSTANDING ) {
89
        $out = undef;
90
    }
91
    if ( $borrower->{gonenoaddress} eq 1 ) {
92
        $out = undef;
93
    }
94
    if ( $borrower->{lost} eq 1 ) {
95
        $out = undef;
96
    }
97
    if ( $borrower->{debarred} eq 1 ) {
98
        $out = undef;
99
    }
100
    my @reserves = GetReservesFromBorrowernumber( $borrower->{'borrowernumber'} );
101
    if ( $MAXIMUM_NUMBER_OF_RESERVES && scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) {
102
        $out = undef;
103
    }
104
    foreach my $res (@reserves) {
105
        if ( $res->{'biblionumber'} == $biblionumber ) {
106
            $out = undef;
107
        }
108
    }
109
    my $issues = GetPendingIssues( $borrower->{'borrowernumber'} );
110
    foreach my $issue (@$issues) {
111
        if ( $issue->{'biblionumber'} == $biblionumber ) {
112
            $out = undef;
113
        }
114
    }
115
116
    return $out;
117
}
118
119
=head2 Availability
70
=head2 Availability
120
71
121
Returns, for an itemnumber, an array containing availability information.
72
Returns, for an itemnumber, an array containing availability information.
122
- 

Return to bug 6142