From ee7ac7f5c059190a9071547dcaaff7fe43c78495 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 20 Jul 2018 18:02:27 +1000 Subject: [PATCH] Bug 21098 - Add missing budget optgroups to parcels.tt and newemptyorder.tt I noticed that orderreceive.tt organizes funds by budget, but neworderempty.tt and parcels.tt do not. That is to say, when placing an order there is no organisation of funds in the drop-down menu, but there is when you recive an order, but not when you receive a shipment (ie choose a Shipping fund). This patch seeks to harmonize the user experience, so that users are always seeing funds organised by budget. _TEST PLAN_ 1. Add two budgets 2. Add one fund to each budget 3. Add a vendor 4. Add a basket 5. Add an order 5b. Note that you can now see funds grouped by budget 6. Close the basket 7. Receive the shipment 7b. Note that you can now see funds groups by budget 8. Receive the order 8b. Note that the organisation of funds is the same as the other two areas (even though the patch doesn't touch this one). --- acqui/neworderempty.pl | 41 +++++++++++++------- acqui/parcels.pl | 37 +++++++++++------- .../prog/en/modules/acqui/neworderempty.tt | 44 ++++++++++++---------- .../intranet-tmpl/prog/en/modules/acqui/parcels.tt | 14 ++++--- 4 files changed, 84 insertions(+), 52 deletions(-) diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 9ca2b5b05a..a30a5e7d54 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -318,21 +318,34 @@ my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; my $budget = GetBudget($budget_id); # build budget list my $budget_loop = []; -my $budgets = GetBudgetHierarchy; -foreach my $r (@{$budgets}) { - next unless (CanUserUseBudget($patron, $r, $userflags)); - if (!defined $r->{budget_amount} || $r->{budget_amount} <0) { - next; +my $periods = GetBudgetPeriods(); +foreach my $period (@$periods) { + my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'} ); + 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_sort1_authcat => $r->{'sort1_authcat'}, + b_sort2_authcat => $r->{'sort2_authcat'}, + b_active => $r->{budget_period_active}, + b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0, + b_level => $r->{budget_level}, + }; } - 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} == $budget_id ) ? 1 : 0, - b_level => $r->{budget_level}, - }; + + @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 + }; } if ($close) { diff --git a/acqui/parcels.pl b/acqui/parcels.pl index c0a330b479..85aecbd9ea 100755 --- a/acqui/parcels.pl +++ b/acqui/parcels.pl @@ -179,22 +179,31 @@ if ($count_parcels) { # build budget list my $budget_loop = []; -my $budgets = GetBudgetHierarchy; -foreach my $r (@{$budgets}) { - next unless (CanUserUseBudget($loggedinuser, $r, $flags)); - if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) { - next; +my $periods = GetBudgetPeriods(); +foreach my $period (@$periods) { + my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'} ); + my @funds; + foreach my $r (@{$budget_hierarchy}) { + next unless (CanUserUseBudget($loggedinuser, $r, $flags)); + if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) { + next; + } + push @funds, { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, + b_active => $r->{budget_period_active}, + }; } - push @{$budget_loop}, { - b_id => $r->{budget_id}, - b_txt => $r->{budget_name}, - b_active => $r->{budget_period_active}, - }; -} -@{$budget_loop} = - sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop}; + @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 + }; +} $template->param( orderby => $order, @@ -206,7 +215,7 @@ $template->param( shipmentdate_today => dt_from_string, booksellerid => $booksellerid, GST => C4::Context->preference('gist'), - budgets => $budget_loop, + budget_loop => $budget_loop, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index 33bc36a74e..3a10a05375 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -341,30 +341,36 @@ [% active_count = 0 %] [% IF !ordernumber %] - [% FOREACH budget_loo IN budget_loop %] - [% active_count= active_count + budget_loo.b_active %] + [% FOREACH period IN budget_loop %] + [% FOREACH fund IN period.funds %] + [% active_count= active_count + fund.b_active %] + [% END %] [% END %] [% END %] Required diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt index 8cade030b0..7f8a80b0ac 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt @@ -158,12 +158,16 @@ -- 2.13.7