From 200ebfae58f5a0bae63ffe8380dbadee7d746124 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 | 39 +++++++++++-------- .../prog/en/modules/acqui/neworderempty.tt | 44 ++++++++++++---------- .../intranet-tmpl/prog/en/modules/acqui/parcels.tt | 14 ++++--- 4 files changed, 85 insertions(+), 53 deletions(-) diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 6326eaf39b..3e3dca719c 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -320,21 +320,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..1cfc8f7f9f 100755 --- a/acqui/parcels.pl +++ b/acqui/parcels.pl @@ -179,23 +179,32 @@ 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}, - }; + + @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 + }; } -@{$budget_loop} = - sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop}; - - $template->param( orderby => $order, filter => $code, @@ -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 1a10af9f2c..2f64f6d495 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -327,30 +327,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 ee0ecd04fe..1fba4a663a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt @@ -154,12 +154,16 @@ -- 2.13.6