From d6ee2fc379dd030705972391f2ea276f7d3323ed Mon Sep 17 00:00:00 2001 From: Laura_Escamilla Date: Tue, 20 May 2025 13:02:48 +0000 Subject: [PATCH] Bug 39427: Split the argument for both name fields to be searched --- C4/Utils/DataTables/VirtualShelves.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/C4/Utils/DataTables/VirtualShelves.pm b/C4/Utils/DataTables/VirtualShelves.pm index 4b578e4f70..80f18a61da 100644 --- a/C4/Utils/DataTables/VirtualShelves.pm +++ b/C4/Utils/DataTables/VirtualShelves.pm @@ -63,9 +63,19 @@ sub search { push @args, "%$shelfname%"; } if ( defined $owner and $owner ne '' ) { - push @where_strs, '( bo.firstname LIKE ? OR bo.surname LIKE ? )'; - push @args, "%$owner%", "%$owner%"; + my @name_parts = split ' ', $owner; + + if ( @name_parts == 2 ) { + push @where_strs, '( bo.firstname LIKE ? AND bo.surname LIKE ? )'; + push @args, "%$name_parts[0]%", "%$name_parts[1]%"; + + } else { + + push @where_strs, '(bo.firstname LIKE ? OR bo.surname LIKE ?)'; + push @args, "%$owner%", "%$owner%"; + } } + if ( defined $sortby and $sortby ne '' ) { push @where_strs, 'sortfield = ?'; push @args, $sortby; -- 2.39.5