@@ -, +, @@ newemptyorder.tt 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(-) --- a/acqui/neworderempty.pl +++ a/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) { --- a/acqui/parcels.pl +++ a/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; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ a/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 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt @@ -158,12 +158,16 @@ --