Bug Fixing Search By initials incorrect
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Fri, 15 Jan 2010 15:27:31 +0000 (16:27 +0100)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Thu, 28 Jan 2010 14:11:55 +0000 (15:11 +0100)
Adding a research scope : field_start_with
Using this kind of research if searching by initial

C4/SQLHelper.pm
members/member.pl

index 08ba90f..4db8c49 100644 (file)
@@ -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;
        }
index 2937706..1ae50f3 100755 (executable)
@@ -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);
 }