From 830ba65a20c3948e7bcb3bf0e8dec1ee7b115d5a Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 5 Sep 2005 19:27:21 +0000 Subject: [PATCH] moving NewBorrowerNumber sub to Members package --- C4/Members.pm | 48 +++++++++++++++++++++--------------------------- C4/Search.pm | 22 ---------------------- 2 files changed, 21 insertions(+), 49 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 586e91b82a..aa5551da5a 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -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; diff --git a/C4/Search.pm b/C4/Search.pm index 69198edd9c..7cd16e3317 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -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); -- 2.39.5