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
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.
28 use C4
::Reserves
qw(GetReservesFromBorrowernumber CanBookBeReserved);
30 use C4
::Branch qw
/GetBranchName/;
31 use Digest
::MD5
qw(md5_base64);
33 use vars
qw($VERSION @ISA @EXPORT);
37 # set the version for version checking
42 &BorrowerExists &Availability
48 C4::ILS-DI::Utility - ILS-DI Utilities
54 Checks, for a given userid and password, if the borrower exists.
56 if ( BorrowerExists($userid, $password) ) {
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;
73 Returns, for an itemnumber, an array containing availability information.
75 my ($biblionumber, $status, $msg, $location) = Availability($id);
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 );
101 return ( $biblionumber, 'available', undef, $location );
104 die Data
::Dumper
::Dumper
($item);