From 9e1d4c978d5954c27cd016f636a03942ede6c406 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 4 May 2020 13:13:56 +0200 Subject: [PATCH] Bug 25266: Build the vendor list from the order list This patch is removing the use of GetBooksellersWithLateOrders and use the late order list to generate the vendors. Test plan: Create several vendors, several orders, close the baskets Also create vendors that do not have orders (or basket not closed) Go to the late orders page and confirm that the list of vendors is correctly filled, select one, you can see the "select all" link in the header of the table QA: that would be good to test this with production data and compare execution time. Signed-off-by: Katrin Fischer Signed-off-by: Alex Arnaud Signed-off-by: Jonathan Druart --- acqui/lateorders.pl | 32 +++++++++---------- .../prog/en/modules/acqui/lateorders.tt | 25 ++++++++------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl index 66ac704405..ff3ce70274 100755 --- a/acqui/lateorders.pl +++ b/acqui/lateorders.pl @@ -68,7 +68,7 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user( } ); -my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0 +my $booksellerid = $input->param('booksellerid'); my $delay = $input->param('delay') // 0; # Get the "date from" param if !defined is today @@ -133,23 +133,9 @@ push @parameters, $estimateddeliverydateto_dt ? $estimateddeliverydateto_dt->ymd() : undef; -my %supplierlist = GetBooksellersWithLateOrders(@parameters); - -my (@sloopy); # supplier loop -foreach( sort { $supplierlist{$a} cmp $supplierlist{$b} } keys %supplierlist ) { - push @sloopy, (($booksellerid and $booksellerid eq $_ ) ? - {id=>$_, name=>$supplierlist{$_}, selected=>1} : - {id=>$_, name=>$supplierlist{$_}} ) ; -} -$template->param(SUPPLIER_LOOP => \@sloopy); - -$template->param(Supplier=>$supplierlist{$booksellerid}) if ($booksellerid); -$template->param(booksellerid=>$booksellerid) if ($booksellerid); - -my $lateorders = Koha::Acquisition::Orders->filter_by_lates( +my @lateorders = Koha::Acquisition::Orders->filter_by_lates( { delay => $delay, - booksellerid => $booksellerid, ( $estimateddeliverydatefrom_dt ? ( estimated_from => $estimateddeliverydatefrom_dt ) @@ -160,14 +146,26 @@ my $lateorders = Koha::Acquisition::Orders->filter_by_lates( ? ( estimated_to => $estimateddeliverydateto_dt ) : () ) + }, +)->as_list; + +my $booksellers = Koha::Acquisition::Booksellers->search( + { + id => { + -in => map { $_->basket->booksellerid } @lateorders + }, } ); +@lateorders = grep { $_->basket->booksellerid eq $booksellerid } @lateorders if $booksellerid; + my $letters = GetLetters({ module => "claimacquisition" }); $template->param(ERROR_LOOP => \@errors) if (@errors); $template->param( - lateorders => $lateorders, + lateorders => \@lateorders, + booksellers => $booksellers, + bookseller_filter => ( $booksellerid ? $booksellers->find($booksellerid) : undef), delay => $delay, letters => $letters, estimateddeliverydatefrom => $estimateddeliverydatefrom, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt index 0851b2dc37..525016e305 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt @@ -21,7 +21,7 @@
-

[% IF ( Supplier ) %][% Supplier | html %] : [% END %]Late orders

+

[% IF bookseller_filter %][% bookseller_filter.name | html %] : [% END %]Late orders

[% IF error_claim %] @@ -36,11 +36,11 @@ [% IF info_claim %]
Email has been sent.
[% END %] -[% IF lateorders.count %] +[% IF lateorders.size %]
- + [% IF ( letters ) %]

+

  • + + [% FOREACH bookseller IN booksellers %] + [% IF bookseller.id == bookseller_filter.id %] + + [% ELSE %] + + [% END %] + [% END %] +