Bug 19130: (followup) Controller scripts should preserve behaviour
authorTomas Cohen Arazi <tomascohen@theke.io>
Tue, 22 Aug 2017 16:11:56 +0000 (13:11 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 25 Aug 2017 14:53:44 +0000 (11:53 -0300)
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 <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

acqui/basketheader.pl
acqui/booksellers.pl
acqui/invoices.pl
acqui/transferorder.pl
serials/acqui-search-result.pl

index 8cfde89..45e11e5 100755 (executable)
@@ -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'},
index de39f67..8a35b04 100755 (executable)
@@ -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;
index 2d11746..3c10e7a 100755 (executable)
@@ -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) {
index 219fb32..6eeafdb 100755 (executable)
@@ -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,
index c159d29..5e57288 100755 (executable)
@@ -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 = [];