From 69e2d1e9c0945e5f0a1fa41c5020dfc6c5ec3157 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=utf8 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 Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 24e7703aef42b2e9e7900dc36eb5c8f1d3f73e4f) Signed-off-by: Lucas Gass (cherry picked from commit 382e80b7377f2f000b4ae94f4526b608ed80fe71) Signed-off-by: Arthur Suzuki --- 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 f1cac81271..27b4f2dcdf 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 0f84cb4384..ed34073bb9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -280,20 +280,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 %])
  • @@ -427,6 +450,7 @@ [% INCLUDE 'calendar.inc' %] [% Asset.js("js/additem.js") | $raw %] [% Asset.js("js/cataloging.js") | $raw %] + [% INCLUDE 'select2.inc' %]