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

(-)a/C4/ILSDI/Utility.pm (-52 / +3 lines)
Lines 1-6 Link Here
1
package C4::ILSDI::Utility;
1
package C4::ILSDI::Utility;
2
2
3
# Copyright 2009 SARL Biblibre
3
# Copyright 2009 SARL Biblibre
4
# Copyright 2011 software.coop and MJ Ray
4
#
5
#
5
# This file is part of Koha.
6
# This file is part of Koha.
6
#
7
#
Lines 24-30 use C4::Members; Link Here
24
use C4::Items;
25
use C4::Items;
25
use C4::Circulation;
26
use C4::Circulation;
26
use C4::Biblio;
27
use C4::Biblio;
27
use C4::Reserves qw(GetReservesFromBorrowernumber);
28
use C4::Reserves qw(GetReservesFromBorrowernumber CanBookBeReserved);
28
use C4::Context;
29
use C4::Context;
29
use C4::Branch qw/GetBranchName/;
30
use C4::Branch qw/GetBranchName/;
30
use Digest::MD5 qw(md5_base64);
31
use Digest::MD5 qw(md5_base64);
Lines 38-44 BEGIN { Link Here
38
    require Exporter;
39
    require Exporter;
39
    @ISA    = qw(Exporter);
40
    @ISA    = qw(Exporter);
40
    @EXPORT = qw(
41
    @EXPORT = qw(
41
      &BorrowerExists &CanBookBeReserved &Availability
42
      &BorrowerExists &Availability
42
    );
43
    );
43
}
44
}
44
45
Lines 67-121 sub BorrowerExists { Link Here
67
    return $sth->fetchrow;
68
    return $sth->fetchrow;
68
}
69
}
69
70
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} ) {
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
71
=head2 Availability
120
72
121
Returns, for an itemnumber, an array containing availability information.
73
Returns, for an itemnumber, an array containing availability information.
122
- 

Return to bug 6142