From 6bff67b1c75e2971844c78bd025268d349998e27 Mon Sep 17 00:00:00 2001 From: Blou Date: Thu, 20 Aug 2015 11:52:03 -0400 Subject: [PATCH] Bug 16123 - Display budget hierarchy in the budget dropdown menu used when placing a new order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When placing a new order, the budget dropdown will display the budget hierarchy. TEST PLAN : 1. Go to the Administration module 2. Add a new budget (ie : Budget 2016) 3. Add a fund to this budget (ie : Book) 4. Add a child fund (ie : Adult fiction) You will have this hierarchy : Budget 2016 |____ Book |_____ Adult fiction 5. Go to the Acquisition module 6. Select a vendor and create a new basket 7. Place an order 8. Check the budget dropdown menu BEFORE PATCH Book Adult fiction AFTER PATCH Book Adult fiction Dropbown menu is hierarchical as expected. Signed-off-by: Marc VĂ©ron --- C4/Budgets.pm | 5 +++-- acqui/neworderempty.pl | 4 +--- .../intranet-tmpl/prog/en/modules/acqui/neworderempty.tt | 12 +++++++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index d0c4400..a342fd7 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -545,7 +545,7 @@ sub GetBudgetHierarchy { my @sort = (); foreach my $first_parent (@first_parents) { - _add_budget_children(\@sort, $first_parent); + _add_budget_children(\@sort, $first_parent, 0); } foreach my $budget (@sort) { @@ -561,11 +561,12 @@ sub GetBudgetHierarchy { sub _add_budget_children { my $res = shift; my $budget = shift; + $budget->{budget_level} = shift; push @$res, $budget; my $children = $budget->{'children'} || []; return unless @$children; # break recursivity foreach my $child (@$children) { - _add_budget_children($res, $child); + _add_budget_children($res, $child, $budget->{budget_level} + 1); } } diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index da5acd5..03fe8d1 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -248,12 +248,10 @@ foreach my $r (@{$budgets}) { 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}, }; } -@{$budget_loop} = - sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop}; - if ($close) { $budget_id = $data->{'budget_id'}; $budget_name = $budget->{'budget_name'}; 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 805b1a6..8efd5f2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -500,12 +500,18 @@ $(document).ready(function() [% FOREACH budget_loo IN budget_loop %] [% IF ( budget_loo.b_sel ) %] [% active_count = 0 #select no other fund %] - -- 1.7.10.4