From 7540dda2eb5b2914ca7428e9a28e536d44d71980 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Fri, 15 Jan 2010 16:27:31 +0100 Subject: [PATCH] Bug Fixing Search By initials incorrect Adding a research scope : field_start_with Using this kind of research if searching by initial --- C4/SQLHelper.pm | 8 ++++++-- members/member.pl | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/C4/SQLHelper.pm b/C4/SQLHelper.pm index 08ba90f648..4db8c4960a 100644 --- a/C4/SQLHelper.pm +++ b/C4/SQLHelper.pm @@ -431,9 +431,13 @@ sub _Process_Operands{ push @tmpkeys,(" $field LIKE ? "); push @localvaluesextended,("\%$operand\%") ; } + if ($searchtype eq "field_start_with"){ + push @tmpkeys,("$field LIKE ?"); + push @localvaluesextended, ("$operand\%") ; + } if ($searchtype eq "start_with"){ - push @tmpkeys,(" $field LIKE ? ","$field LIKE ?"); - push @localvaluesextended, ("\% $operand\%","$operand\%") ; + push @tmpkeys,("$field LIKE ?","$field LIKE ?"); + push @localvaluesextended, ("$operand\%", " $operand\%") ; } push @values,@localvaluesextended; } diff --git a/members/member.pl b/members/member.pl index 2937706b65..1ae50f3bd8 100755 --- a/members/member.pl +++ b/members/member.pl @@ -103,7 +103,8 @@ push @searchpatron, $patron if (keys %$patron); my $from= ($startfrom-1)*$resultsperpage; my $to=$from+$resultsperpage; #($results)=Search(\@searchpatron,{surname=>1,firstname=>1},[$from,$to],undef,["firstname","surname","email","othernames"] ) if (@searchpatron); - ($results)=Search(\@searchpatron,\@orderby,undef,undef,["firstname","surname","email","othernames","cardnumber","userid"],"start_with" ) if (@searchpatron); + my $search_scope=($quicksearch?"field_start_with":"start_with"); + ($results)=Search(\@searchpatron,\@orderby,undef,undef,["firstname","surname","email","othernames","cardnumber","userid"],$search_scope ) if (@searchpatron); if ($results){ $count =scalar(@$results); } -- 2.39.5