moving NewBorrowerNumber sub to Members package

This commit is contained in:
tipaul 2005-09-05 19:27:21 +00:00
parent b897d55f23
commit 830ba65a20
2 changed files with 21 additions and 49 deletions

View File

@ -49,7 +49,7 @@ C4::Members - Perl Module containing convenience functions for member handling
@EXPORT = qw();
@EXPORT = qw(
&getmember &fixup_cardnumber &findguarantees &findguarantor &modmember &newmember &changepassword
&getmember &fixup_cardnumber &findguarantees &findguarantor &NewBorrowerNumber &modmember &newmember &changepassword
);
@ -306,31 +306,25 @@ sub findguarantor{
return($data);
}
# =item NewBorrowerNumber
#
# $num = &NewBorrowerNumber();
#
# Allocates a new, unused borrower number, and returns it.
#
# =cut
# #'
# # FIXME - This is identical to C4::Search::NewBorrowerNumber.
# # Pick one (preferably this one) and stick with it.
#
# # FIXME - Race condition: this function just says what the next unused
# # number is, but doesn't allocate it. Hence, two clients adding
# # patrons at the same time could get the same new borrower number and
# # clobber each other.
# # A better approach might be to set borrowernumber autoincrement and
#
# sub NewBorrowerNumber {
# my $dbh = C4::Context->dbh;
# my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
# $sth->execute;
# my $data=$sth->fetchrow_hashref;
# $sth->finish;
# $data->{'max(borrowernumber)'}++;
# return($data->{'max(borrowernumber)'});
# }
=item NewBorrowerNumber
$num = &NewBorrowerNumber();
Allocates a new, unused borrower number, and returns it.
=cut
#'
# FIXME - This is identical to C4::Circulation::Borrower::NewBorrowerNumber.
# Pick one and stick with it. Preferably use the other one. This function
# doesn't belong in C4::Search.
sub NewBorrowerNumber {
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$data->{'max(borrowernumber)'}++;
return($data->{'max(borrowernumber)'});
}
1;

View File

@ -66,28 +66,6 @@ on what is passed to it, it calls the appropriate search function.
&isbnsearch &getbranchname &getborrowercategory);
# make all your functions, whether exported or not;
=item NewBorrowerNumber
$num = &NewBorrowerNumber();
Allocates a new, unused borrower number, and returns it.
=cut
#'
# FIXME - This is identical to C4::Circulation::Borrower::NewBorrowerNumber.
# Pick one and stick with it. Preferably use the other one. This function
# doesn't belong in C4::Search.
sub NewBorrowerNumber {
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$data->{'max(borrowernumber)'}++;
return($data->{'max(borrowernumber)'});
}
=item catalogsearch
($count, @results) = &catalogsearch($env, $type, $search, $num, $offset);