From a72d9621ae5ffe8fdca6179aa64ee403c43fce4b Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 5 Jun 2003 17:03:31 +0000 Subject: [PATCH] removing searchborrower from circ2.pm. Already exists in Search.pm this fixes bug #439 and improve consistency. --- C4/Circulation/Circ2.pm | 50 +------------------------------- C4/Context.pm | 1 - C4/Search.pm | 63 +++++++++++++++++++++-------------------- circ/circulation.pl | 2 +- member.pl | 1 - 5 files changed, 34 insertions(+), 83 deletions(-) diff --git a/C4/Circulation/Circ2.pm b/C4/Circulation/Circ2.pm index a37751d86d..bf6780704b 100755 --- a/C4/Circulation/Circ2.pm +++ b/C4/Circulation/Circ2.pm @@ -61,7 +61,7 @@ returns, as well as general information about the library. @ISA = qw(Exporter); @EXPORT = qw(&getpatroninformation - ¤tissues &getissues &getiteminformation &findborrower + ¤tissues &getissues &getiteminformation &issuebook &returnbook &find_reserves &transferbook &decode &calc_charges); @@ -301,54 +301,6 @@ sub getiteminformation { return($iteminformation); } -=item findborrower - - $borrowers = &findborrower($env, $key); - print $borrowers->[0]{surname}; - -Looks up patrons and returns information about them. - -C<$env> is ignored. - -C<$key> is either a card number or a string. C<&findborrower> tries to -look it up as a card number first. If that fails, C<&findborrower> -looks up all patrons whose surname begins with C<$key>. - -C<$borrowers> is a reference-to-array. Each element is a -reference-to-hash whose keys are the fields of the borrowers table in -the Koha database. - -=cut -#' -# If you really want to throw a monkey wrench into the works, change -# your last name to "V10000008" :-) - -# FIXME - This is different from &C4::Borrower::findborrower, but I -# think that one's obsolete. -sub findborrower { -# returns an array of borrower hash references, given a cardnumber or a partial -# surname - my ($env, $key) = @_; - my $dbh = C4::Context->dbh; - my @borrowers; - my $sth=$dbh->prepare("select * from borrowers where cardnumber=?"); - $sth->execute($key); - if ($sth->rows) { - my ($borrower)=$sth->fetchrow_hashref; - push (@borrowers, $borrower); - } else { - $sth->finish; - $sth=$dbh->prepare("select * from borrowers where surname like ?"); - $sth->execute($key."%"); - while (my $borrower = $sth->fetchrow_hashref) { - push (@borrowers, $borrower); - } - } - $sth->finish; - return(\@borrowers); -} - - =item transferbook ($dotransfer, $messages, $iteminformation) = diff --git a/C4/Context.pm b/C4/Context.pm index 28946d06e8..2d9e9e24a3 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -365,7 +365,6 @@ sub _new_dbh my $db_host = $context->{"config"}{"hostname"}; my $db_user = $context->{"config"}{"user"}; my $db_passwd = $context->{"config"}{"pass"}; - return DBI->connect("DBI:$db_driver:$db_name:$db_host", $db_user, $db_passwd); } diff --git a/C4/Search.pm b/C4/Search.pm index 16eab9479c..1551974e44 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1737,37 +1737,38 @@ C<$count> is the number of elements in C<$borrowers>. #used by member enquiries from the intranet #called by member.pl sub BornameSearch { - my ($env,$searchstring,$type)=@_; - my $dbh = C4::Context->dbh; - $searchstring=~ s/\'/\\\'/g; - my @data=split(' ',$searchstring); - my $count=@data; - my $query="Select * from borrowers - where ((surname like \"$data[0]%\" or surname like \"% $data[0]%\" - or firstname like \"$data[0]%\" or firstname like \"% $data[0]%\" - or othernames like \"$data[0]%\" or othernames like \"% $data[0]%\") - "; - for (my $i=1;$i<$count;$i++){ - $query=$query." and (surname like \"$data[$i]%\" or surname like \"% $data[$i]%\" - or firstname like \"$data[$i]%\" or firstname like \"% $data[$i]%\" - or othernames like \"$data[$i]%\" or othernames like \"% $data[$i]%\")"; - # FIXME - .= <prepare($query); - $sth->execute; - my @results; - my $cnt=0; - while (my $data=$sth->fetchrow_hashref){ - push(@results,$data); - $cnt ++; - } -# $sth->execute; - $sth->finish; - return ($cnt,\@results); + my ($env,$searchstring,$type)=@_; + my $dbh = C4::Context->dbh; + $searchstring=~ s/\,//g; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $query="Select * from borrowers + where ((surname like \"$data[0]%\" or surname like \"% $data[0]%\" + or firstname like \"$data[0]%\" or firstname like \"% $data[0]%\" + or othernames like \"$data[0]%\" or othernames like \"% $data[0]%\") + "; + for (my $i=1;$i<$count;$i++){ + $query=$query." and (surname like \"$data[$i]%\" or surname like \"% $data[$i]%\" + or firstname like \"$data[$i]%\" or firstname like \"% $data[$i]%\" + or othernames like \"$data[$i]%\" or othernames like \"% $data[$i]%\")"; + # FIXME - .= <prepare($query); + $sth->execute; + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + # $sth->execute; + $sth->finish; + return ($cnt,\@results); } =item borrdata diff --git a/circ/circulation.pl b/circ/circulation.pl index e04728743f..e284307ba9 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -83,7 +83,7 @@ my $borrowerslist; # if there is a list of find borrowers.... my $findborrower = $query->param('findborrower'); if ($findborrower) { - my ($borrowers, $flags) = findborrower(\%env, $findborrower); + my ($count,$borrowers)=BornameSearch(\%env,$findborrower,'web'); my @borrowers=@$borrowers; if ($#borrowers == -1) { $query->param('findborrower', ''); diff --git a/member.pl b/member.pl index 6baa3a39fd..67193073e5 100755 --- a/member.pl +++ b/member.pl @@ -50,7 +50,6 @@ my ($template, $loggedinuser, $cookie) }); my $member=$input->param('member'); -$member=~ s/\,//g; my $env; my ($count,$results)=BornameSearch($env,$member,'web'); -- 2.39.5