From 2cc303739701222eb0be81135dea035e4a68fc5e Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 4 Oct 2004 20:19:08 +0000 Subject: [PATCH] adding getmember sub to the package (the Search.pm/borrdata should be removed, it has nothing to do here) --- C4/Members.pm | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/C4/Members.pm b/C4/Members.pm index 053b0f146d..e2fdff65ee 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -49,9 +49,51 @@ C4::Members - Perl Module containing convenience functions for member handling @EXPORT = qw(); @EXPORT = qw( - &fixup_cardnumber &findguarantees &modmember &newmember &changepassword + &getmember &fixup_cardnumber &findguarantees &modmember &newmember &changepassword ); + +=item getmember + + $borrower = &getmember($cardnumber, $borrowernumber); + +Looks up information about a patron (borrower) by either card number +or borrower number. If $borrowernumber is specified, C<&borrdata> +searches by borrower number; otherwise, it searches by card number. + +C<&getmember> returns a reference-to-hash whose keys are the fields of +the C table in the Koha database. + +=cut +#' +sub getmember { + my ($cardnumber,$bornum)=@_; + $cardnumber = uc $cardnumber; + my $dbh = C4::Context->dbh; + my $sth; + if ($bornum eq ''){ + $sth=$dbh->prepare("Select * from borrowers where cardnumber=?"); + $sth->execute($cardnumber); + } else { + $sth=$dbh->prepare("Select * from borrowers where borrowernumber=?"); + $sth->execute($bornum); + } + my $data=$sth->fetchrow_hashref; + $sth->finish; + if ($data) { + return($data); + } else { # try with firstname + if ($cardnumber) { + my $sth=$dbh->prepare("select * from borrowers where firstname=?"); + $sth->execute($cardnumber); + my $data=$sth->fetchrow_hashref; + $sth->finish; + return($data); + } + } + return undef; +} + sub modmember { my (%data) = @_; -- 2.39.5