From 73d9557b13bcd7354436db6980fb23b6c9a124dc 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=utf8 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 Signed-off-by: Nicolas Legrand Signed-off-by: Katrin Fischer Signed-off-by: Kyle M Hall --- C4/Budgets.pm | 5 +++-- acqui/neworderempty.pl | 4 +--- .../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 b7b1233b67..cf2939ff0e 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -547,7 +547,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) { @@ -563,11 +563,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 99314ae10a..57a22e4312 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -229,12 +229,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 a17ddc1625..7aa4bcbc70 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -505,12 +505,18 @@ $(document).ready(function() [% FOREACH budget_loo IN budget_loop %] [% IF ( budget_loo.b_sel ) %] [% active_count = 0 #select no other fund %] - -- 2.39.5