Bug 14871: Extend the patrons search to search like %$term% (checkout tab)

The patrons search used by the checkout tab and the autocomplete is not
the same as the "search patrons" tab.
The main difference is the "contain" vs "start with".
So that if you have a patron with a patron with a surname "foo bar" and
you search for "foo bar", the autocomplete and the result of a search by
the checkout tab will search for "foo%" or "bar%" which won't return the
patron you are search for.

This patch replaces both autocomplete and checkout tab searches with a
"contain" search. The search will be "%foo%" or "%bar%".
Note that on big DB, this can cause unexpected results.

Test plan:
Create a patron with a surname "foo bar"
Search for "bar" using the checkout tab.
You should see the patron in the autocomplete result and the result page
after submitting the search form.

Followed test plan, works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2015-09-22 15:04:14 +01:00 committed by Tomas Cohen Arazi
parent e8232522a9
commit 4353cd1958
2 changed files with 3 additions and 2 deletions

View file

@ -250,6 +250,7 @@ if ($findborrower) {
my $results = C4::Utils::DataTables::Members::search(
{
searchmember => $findborrower,
searchtype => 'contain',
dt_params => $dt_params,
}
);

View file

@ -57,8 +57,8 @@ foreach my $p (@parts) {
push(
@params,
-or => [
surname => { -like => "$p%" },
firstname => { -like => "$p%" },
surname => { -like => "%$p%" },
firstname => { -like => "%$p%" },
cardnumber => { -like => "$p%" },
]
);