From 059eb132e0d9da96c1c123709241097537018698 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 25 Aug 2022 11:26:33 +0000 Subject: [PATCH] Bug 31459: Use the same dropdown as when adding orders to a basket MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Current order receive code loops over each budget period and gets the hierarchy, this is slow when systems have many budgets. Additionally, the list includes inactive items by default We can switch to a single call, and add consistency by adopting the same dropdown as used when placing an order To test: 1 - Add some budgets with funds - ensure you have at least one inactive budget and fund 2 - Place an order, observe the fund selection menu 3 - Close basket, receive order, observe the fund menu 4 - Apply patch 5 - Cancel receipt 6 - Receive again 7 - Observe fund menu, confirm it matches the order placing menu 8 - Confirm inactive are not displayed by default, but are when button is checked Signed-off-by: Joonas Kylmälä Signed-off-by: Katrin Fischer https://bugs.koha-community.org/show_bug.cgi?id=31559 --- acqui/orderreceive.pl | 46 +++++--------- .../prog/en/modules/acqui/orderreceive.tt | 62 +++++++++++++++---- 2 files changed, 64 insertions(+), 44 deletions(-) diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index c690dca55f..43b9c109f7 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -170,39 +170,21 @@ if ( $suggestion ) { } my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; -my @budget_loop; -my $periods = GetBudgetPeriods( ); -foreach my $period (@$periods) { - if ($period->{'budget_period_id'} == $budget->{'budget_period_id'}) { - $template->{'VARS'}->{'budget_period_description'} = $period->{'budget_period_description'}; - } - next if $period->{'budget_period_locked'} || !$period->{'budget_period_description'}; - my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'}, undef, undef, 1 ); - my @funds; - foreach my $r ( @{$budget_hierarchy} ) { - next unless ( CanUserUseBudget( $patron, $r, $userflags ) ); - if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) { - next; - } - push @funds, - { - b_id => $r->{budget_id}, - b_txt => $r->{budget_name}, - b_sel => ( $r->{budget_id} == $order->budget_id ) ? 1 : 0, - }; - } - - @funds = sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @funds; - - push @budget_loop, - { - 'id' => $period->{'budget_period_id'}, - 'description' => $period->{'budget_period_description'}, - 'funds' => \@funds - }; +my $budget_loop = []; +my $budgets = GetBudgetHierarchy( undef, undef, undef, 1 ); +foreach my $r (@{$budgets}) { + next unless (CanUserUseBudget($patron, $r, $userflags)); + push @{$budget_loop}, { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, + b_sort1_authcat => $r->{'sort1_authcat'}, + b_sort2_authcat => $r->{'sort2_authcat'}, + b_active => $r->{budget_period_active}, + b_sel => ( $r->{budget_id} == $order->budget_id ) ? 1 : 0, + b_level => $r->{budget_level}, + }; } - -$template->{'VARS'}->{'budget_loop'} = \@budget_loop; +$template->{'VARS'}->{'budget_loop'} = $budget_loop; my $op = $input->param('op'); if ($op and $op eq 'edit'){ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 54cc5ea818..5626ecbb9d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -287,20 +287,43 @@
[% INCLUDE 'date-format.inc' %]
-
  • + [% FOREACH budget_loo IN budget_loop %] + [% level_indent_cnt = 0 %] + [% level_indent = "" %] + [% WHILE level_indent_cnt < budget_loo.b_level %] + [% level_indent = level_indent _ " -- " %] + [% level_indent_cnt = level_indent_cnt +1 %] + [% END %] + + [% IF ( budget_loo.b_sel ) %] + [% active_count = 0 #select no other fund %] + [% END %] -
  • + + Required + + +
  • (Current: [% budget_period_description | html %] - [% bookfund | html %])
  • @@ -434,6 +457,7 @@ [% INCLUDE 'calendar.inc' %] [% Asset.js("js/additem.js") | $raw %] [% Asset.js("js/cataloging.js") | $raw %] + [% INCLUDE 'select2.inc' %]