From b5d6a1885ed4dcb650e7f9f23733b4ff9ad2b37b Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 22 Aug 2017 13:11:56 -0300 Subject: [PATCH] Bug 19130: (followup) Controller scripts should preserve behaviour This patch is a followup to making Koha::Acquisition::Booksellers->search work as any other Koha::Objects (DBIC) query instead of having a different behaviour hardcoded. To achieve it, this patch makes the controller scripts add wildcard/truncation chars as prefix and sufix for searches, and make the default sorting for results be by 'name', ascending. To test: - Just verify the behaviour remains unchanged by this patchset on the controller scripts (re. searching). Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- acqui/basketheader.pl | 5 ++++- acqui/booksellers.pl | 4 +++- acqui/invoices.pl | 2 +- acqui/transferorder.pl | 4 +++- serials/acqui-search-result.pl | 4 +++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl index 8cfde89cab..45e11e5c63 100755 --- a/acqui/basketheader.pl +++ b/acqui/basketheader.pl @@ -110,7 +110,10 @@ if ( $op eq 'add_form' ) { $template->param(contractloop => \@contractloop, basketcontractnumber => $basket->{'contractnumber'}); } - my @booksellers = Koha::Acquisition::Booksellers->search; + my @booksellers = Koha::Acquisition::Booksellers->search( + undef, + { order_by => { -asc => 'name' } } ); + $template->param( add_form => 1, basketname => $basket->{'basketname'}, basketnote => $basket->{'note'}, diff --git a/acqui/booksellers.pl b/acqui/booksellers.pl index de39f675e6..8a35b04bd0 100755 --- a/acqui/booksellers.pl +++ b/acqui/booksellers.pl @@ -85,7 +85,9 @@ my @suppliers; if ($booksellerid) { push @suppliers, scalar Koha::Acquisition::Booksellers->find( $booksellerid ); } else { - @suppliers = Koha::Acquisition::Booksellers->search({ name => $supplier }); + @suppliers = Koha::Acquisition::Booksellers->search( + { name => { -like => "%$supplier%" } }, + { order_by => { -asc => 'name' } } ); } my $supplier_count = @suppliers; diff --git a/acqui/invoices.pl b/acqui/invoices.pl index 2d117464c9..3c10e7a1ec 100755 --- a/acqui/invoices.pl +++ b/acqui/invoices.pl @@ -90,7 +90,7 @@ if ( $op and $op eq 'do_search' ) { } # Build suppliers list -my @suppliers = Koha::Acquisition::Booksellers->search; +my @suppliers = Koha::Acquisition::Booksellers->search( undef, { order_by => { -asc => 'name' } } ); my $suppliers_loop = []; my $suppliername; foreach (@suppliers) { diff --git a/acqui/transferorder.pl b/acqui/transferorder.pl index 219fb32f99..6eeafdb12e 100755 --- a/acqui/transferorder.pl +++ b/acqui/transferorder.pl @@ -117,7 +117,9 @@ if( $basketno && $ordernumber) { # Search for booksellers to transfer from/to $op = '' unless $op; if( $op eq "do_search" ) { - my @booksellers = Koha::Acquisition::Booksellers->search({ name => $query }); + my @booksellers = Koha::Acquisition::Booksellers->search( + { name => { -like => "%$query%" } }, + { order_by => { -asc => 'name' } } ); $template->param( query => $query, do_search => 1, diff --git a/serials/acqui-search-result.pl b/serials/acqui-search-result.pl index c159d294e8..5e57288e2d 100755 --- a/serials/acqui-search-result.pl +++ b/serials/acqui-search-result.pl @@ -62,7 +62,9 @@ my ($template, $loggedinuser, $cookie) }); my $supplier=$query->param('supplier'); -my @suppliers = Koha::Acquisition::Booksellers->search({ name => $supplier }); +my @suppliers = Koha::Acquisition::Booksellers->search( + { name => { -like => "%$supplier%" } }, + { order_by => { -asc => 'name' } } ); #build result page my $loop_suppliers = []; -- 2.39.5