The BornameSearch function now uses the $type parameter
Single and advanced search methods implemented.
Advanced is the old version.
Single only looks for $member% in surnames.
This commit is contained in:
plugz 2003-06-19 16:14:30 +00:00
parent c41524ac2a
commit 94ac73b0d3

View file

@ -1721,7 +1721,9 @@ sub itemnodata {
Looks up patrons (borrowers) by name. Looks up patrons (borrowers) by name.
C<$env> and C<$type> are ignored. C<$env> is ignored.
BUGFIX 499: C<$type> is now used to determine
C<$searchstring> is a space-separated list of search terms. Each term C<$searchstring> is a space-separated list of search terms. Each term
must match the beginning a borrower's surname, first name, or other must match the beginning a borrower's surname, first name, or other
@ -1741,9 +1743,17 @@ sub BornameSearch {
my $dbh = C4::Context->dbh; my $dbh = C4::Context->dbh;
$searchstring=~ s/\,//g; $searchstring=~ s/\,//g;
$searchstring=~ s/\'/\\\'/g; $searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring); my $query = ""; my $count; my @data;
my $count=@data;
my $query="Select * from borrowers if($type eq "simple") # simple search for one letter only
{
$query="Select * from borrowers where surname like \"$searchstring%\" order by surname,firstname";
}
else # advanced search looking in surname, firstname and othernames
{
@data=split(' ',$searchstring);
$count=@data;
$query="Select * from borrowers
where ((surname like \"$data[0]%\" or surname like \"% $data[0]%\" where ((surname like \"$data[0]%\" or surname like \"% $data[0]%\"
or firstname like \"$data[0]%\" or firstname like \"% $data[0]%\" or firstname like \"$data[0]%\" or firstname like \"% $data[0]%\"
or othernames like \"$data[0]%\" or othernames like \"% $data[0]%\") or othernames like \"$data[0]%\" or othernames like \"% $data[0]%\")
@ -1757,14 +1767,14 @@ sub BornameSearch {
$query=$query.") or cardnumber = \"$searchstring\" $query=$query.") or cardnumber = \"$searchstring\"
order by surname,firstname"; order by surname,firstname";
# FIXME - .= <<EOT; # FIXME - .= <<EOT;
# print $query,"\n"; }
my $sth=$dbh->prepare($query); my $sth=$dbh->prepare($query);
$sth->execute; $sth->execute;
my @results; my @results;
my $cnt=0; my $cnt=$sth->rows;
while (my $data=$sth->fetchrow_hashref){ while (my $data=$sth->fetchrow_hashref){
push(@results,$data); push(@results,$data);
$cnt ++;
} }
# $sth->execute; # $sth->execute;
$sth->finish; $sth->finish;