Bug 5750: (MT #4095) add exact matching filter for categorycode and branchcode fields... github/bug_5750 origin/new/enh/bug_5750
authorStéphane Delaune <stephane.delaune@biblibre.com>
Mon, 14 Mar 2011 06:13:03 +0000 (07:13 +0100)
committerChris Cormack <chrisc@catalyst.net.nz>
Tue, 15 Mar 2011 09:07:50 +0000 (22:07 +1300)
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
No searching borrowers by categorycode or branchcode will only bring up
exact matches. Before searches for Staff (S) would also bring up
Students and Schools (SC, ST). Same for branchcodes.
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
members/member.pl

index df688d1..a2a79fa 100755 (executable)
@@ -99,14 +99,20 @@ my ($count,$results);
 
 my @searchpatron;
 push @searchpatron, $member if ($member);
-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);
- my $search_scope=($quicksearch?"field_start_with":"contain");
- ($results)=Search(\@searchpatron,\@orderby,undef,undef,["firstname","surname","email","othernames","cardnumber","userid"],$search_scope  ) if (@searchpatron);
-if ($results){
-       $count =scalar(@$results);
+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);
+my $search_scope = ( $quicksearch ? "field_start_with" : "start_with" );
+($results) = Search( \@searchpatron, \@orderby, undef, undef, [ "firstname", "surname", "othernames", "cardnumber", "userid" ], $search_scope ) if (@searchpatron);
+
+if ($results) {
+       for my $field ('categorycode','branchcode'){
+               next unless ($patron->{$field});
+               @$results = grep { $_->{$field} eq $patron->{$field} } @$results; 
+       }
+    $count = scalar(@$results);
 }
 my @resultsdata;
 $to=($count>$to?$to:$count);