Bug 16123 - Display budget hierarchy in the budget dropdown menu used when placing...
authorBlou <philippe.blouin@inlibro.com>
Thu, 20 Aug 2015 15:52:03 +0000 (11:52 -0400)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 28 Oct 2016 15:26:00 +0000 (15:26 +0000)
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 <veron@veron.ch>
Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Budgets.pm
acqui/neworderempty.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt

index b7b1233..cf2939f 100644 (file)
@@ -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);
     }
 }
 
index 99314ae..57a22e4 100755 (executable)
@@ -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'};
index a17ddc1..7aa4bcb 100644 (file)
@@ -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 %]
-                        <option value="[% budget_loo.b_id %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]">
+                        <option value="[% budget_loo.b_id %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]"
+                                style="[% IF ( budget_loo.b_level == 0 ) %]font-weight:bold;[% END %] padding-left:[% budget_loo.b_level %]em;"
+                        >
                     [% ELSIF active_count==1 && budget_loo.b_active %]
-                        <option value="[% budget_loo.b_id %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]">
+                        <option value="[% budget_loo.b_id %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]"
+                                style="[% IF ( budget_loo.b_level == 0 ) %]font-weight:bold;[% END %] padding-left:[% budget_loo.b_level %]em;"
+                        >
                     [% ELSE %]
                         [% bdgclass=budget_loo.b_active? "": "b_inactive" %]
-                        <option value="[% budget_loo.b_id %]" class="[% bdgclass %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]">
+                        <option value="[% budget_loo.b_id %]" class="[% bdgclass %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]"
+                                style="[% IF ( budget_loo.b_level == 0 ) %]font-weight:bold;[% END %] padding-left:[% budget_loo.b_level %]em;"
+                        >
                     [% END %]
                     [% budget_loo.b_txt %][% IF !budget_loo.b_active %] (inactive)[% END %]
                     </option>