From 6b1b3718889f3674ac00eccbe3e0636a66f2c1a5 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 5 Mar 2024 14:52:16 +0000 Subject: [PATCH] Bug 36233: Use select2 to load vendors on invoice search This patch moves the dropdown to use select2 and avoids loading all vendors at page load. To test: 1 - Create some extra vendors in your system, ideally over 20 2 - Search for a vendor in acquisitions 3 - Click 'Invoices' 4 - Note the dropdown of all vendors 'Vendor:' in search bar on left 5 - The vendor you came from shoudl eb selected 6 - Apply patch 7 - Repeat 8 - Note only a partial list of vendors is loaded, confirm current vendor still selected 9 - Search in the dropdown and confirm vendors are returned 10 - Select a vendor and search 11 - confirm selection is retained Signed-off-by: Lisette Scheer Rebased-by: Victor Grousset/tuxayo Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer --- acqui/invoices.pl | 49 ++++++---------- .../prog/en/modules/acqui/invoices.tt | 56 ++++++++++++++++--- 2 files changed, 65 insertions(+), 40 deletions(-) diff --git a/acqui/invoices.pl b/acqui/invoices.pl index 5cf2e338aa..309060efff 100755 --- a/acqui/invoices.pl +++ b/acqui/invoices.pl @@ -105,22 +105,8 @@ $template->param( ); # Build suppliers list -my @suppliers = Koha::Acquisition::Booksellers->search( undef, { order_by => { -asc => 'name' } } )->as_list; -my $suppliers_loop = []; -my $suppliername; -foreach (@suppliers) { - my $selected = 0; - if ($supplierid && $supplierid == $_->id ) { - $selected = 1; - $suppliername = $_->name; - } - push @{$suppliers_loop}, - { - suppliername => $_->name, - booksellerid => $_->id, - selected => $selected, - }; -} +my $supplier; +$supplier = Koha::Acquisition::Booksellers->find($supplierid) if $supplierid; my $budgets = GetBudgets(); my @budgets_loop; @@ -140,24 +126,23 @@ for my $sub ( @{$invoices} ) { $template->{'VARS'}->{'budgets_loop'} = \@budgets_loop; $template->param( - openedinvoices => \@openedinvoices, - closedinvoices => \@closedinvoices, - do_search => ( $op and $op eq 'do_search' ) ? 1 : 0, - invoices => $invoices, - invoicenumber => $invoicenumber, - booksellerid => $supplierid, - suppliername => $suppliername, + openedinvoices => \@openedinvoices, + closedinvoices => \@closedinvoices, + do_search => ( $op and $op eq 'do_search' ) ? 1 : 0, + invoices => $invoices, + invoicenumber => $invoicenumber, + booksellerid => $supplierid, + supplier => $supplier, shipmentdatefrom => $shipmentdatefrom, shipmentdateto => $shipmentdateto, - billingdatefrom => $billingdatefrom, - billingdateto => $billingdateto, - isbneanissn => $isbneanissn, - title => $title, - author => $author, - publisher => $publisher, - publicationyear => $publicationyear, - branch => $branch, - suppliers_loop => $suppliers_loop, + billingdatefrom => $billingdatefrom, + billingdateto => $billingdateto, + isbneanissn => $isbneanissn, + title => $title, + author => $author, + publisher => $publisher, + publicationyear => $publicationyear, + branch => $branch, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt index b045a90264..7973d64217 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt @@ -317,14 +317,9 @@
  • - + [% IF ( supplier ) %] + [% END %]
  • @@ -425,6 +420,7 @@ [% Asset.js("js/acquisitions-menu.js") | $raw %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'select2.inc' %] [% END %] -- 2.39.5