Bug #6142 - Delete sub CanBookBeReserved and delete function's reference on @EXPORT
[koha.git] / C4 / ILSDI / Utility.pm
blob37220c670a6ede1bc2c3492a5e60c1dc9d40b8d4
1 package C4::ILSDI::Utility;
3 # Copyright 2009 SARL Biblibre
4 # Copyright 2011 software.coop and MJ Ray
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 use strict;
22 use warnings;
24 use C4::Members;
25 use C4::Items;
26 use C4::Circulation;
27 use C4::Biblio;
28 use C4::Reserves qw(GetReservesFromBorrowernumber CanBookBeReserved);
29 use C4::Context;
30 use C4::Branch qw/GetBranchName/;
31 use Digest::MD5 qw(md5_base64);
33 use vars qw($VERSION @ISA @EXPORT);
35 BEGIN {
37 # set the version for version checking
38 $VERSION = 3.00;
39 require Exporter;
40 @ISA = qw(Exporter);
41 @EXPORT = qw(
42 &BorrowerExists &Availability
46 =head1 NAME
48 C4::ILS-DI::Utility - ILS-DI Utilities
50 =cut
52 =head2 BorrowerExists
54 Checks, for a given userid and password, if the borrower exists.
56 if ( BorrowerExists($userid, $password) ) {
57 # Do stuff
60 =cut
62 sub BorrowerExists {
63 my ( $userid, $password ) = @_;
64 $password = md5_base64($password);
65 my $dbh = C4::Context->dbh;
66 my $sth = $dbh->prepare("SELECT COUNT(*) FROM borrowers WHERE userid =? and password=? ");
67 $sth->execute( $userid, $password );
68 return $sth->fetchrow;
71 =head2 Availability
73 Returns, for an itemnumber, an array containing availability information.
75 my ($biblionumber, $status, $msg, $location) = Availability($id);
77 =cut
79 sub Availability {
80 my ($itemnumber) = @_;
81 my $item = GetItem( $itemnumber, undef, undef );
83 if ( not $item->{'itemnumber'} ) {
84 return ( undef, 'unknown', 'Error: could not retrieve availability for this ID', undef );
87 my $biblionumber = $item->{'biblioitemnumber'};
88 my $location = GetBranchName( $item->{'holdingbranch'} );
90 if ( $item->{'notforloan'} ) {
91 return ( $biblionumber, 'not available', 'Not for loan', $location );
92 } elsif ( $item->{'onloan'} ) {
93 return ( $biblionumber, 'not available', 'Checked out', $location );
94 } elsif ( $item->{'itemlost'} ) {
95 return ( $biblionumber, 'not available', 'Item lost', $location );
96 } elsif ( $item->{'wthdrawn'} ) {
97 return ( $biblionumber, 'not available', 'Item withdrawn', $location );
98 } elsif ( $item->{'damaged'} ) {
99 return ( $biblionumber, 'not available', 'Item damaged', $location );
100 } else {
101 return ( $biblionumber, 'available', undef, $location );
104 die Data::Dumper::Dumper($item);