@@ -, +, @@ limited Test User User Test U Test Test U etc. --- circ/ysearch.pl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) --- a/circ/ysearch.pl +++ a/circ/ysearch.pl @@ -51,14 +51,23 @@ if ( C4::Context->preference("IndependentBranches") $limit_on_branch = 1; } +my @parts = split( / /, $query ); +my @params; +foreach my $p (@parts) { + push( + @params, + -or => [ + surname => { -like => "$p%" }, + firstname => { -like => "$p%" }, + cardnumber => { -like => "$p%" }, + ] + ); +} + +push( @params, { branchcode => C4::Context->userenv->{branch} } ) if $limit_on_branch; + my $borrowers_rs = Koha::Borrowers->search( - { -or => { - surname => { -like => "$query%" }, - firstname => { -like => "$query%" }, - cardnumber => { -like => "$query%" }, - ( $limit_on_branch ? { branchcode => C4::Context->userenv->{branch} } : () ), - }, - }, + { -and => \@params }, { # Get the first 10 results page => 1, --