Bug 17196 - DBRev 16.12.00.004
[koha.git] / admin / aqbudgets.pl
index 0d18131..483ff8f 100755 (executable)
@@ -26,11 +26,10 @@ use List::Util qw/min/;
 
 use Koha::Database;
 use C4::Auth qw/get_user_subpermissions/;
-use C4::Branch; # GetBranches
 use C4::Auth;
 use C4::Acquisition;
 use C4::Budgets;
-use C4::Members;  # calls GetSortDetails()
+use C4::Members;
 use C4::Context;
 use C4::Output;
 use C4::Koha;
@@ -69,7 +68,7 @@ if (not defined $template->{VARS}->{'CAN_user_acquisition_budget_add_del'}
 
 # get only the columns of aqbudgets in budget_hash
 my @columns = Koha::Database->new()->schema->source('Aqbudget')->columns;
-my $budget_hash = { map { join(' ',@columns) =~ /$_/ ? ( $_ => $input->param($_) )  : () } keys( %{$input->Vars()}) } ;
+my $budget_hash = { map { join(' ',@columns) =~ /$_/ ? ( $_ => scalar $input->param($_) )  : () } keys( %{$input->Vars()}) } ;
 
 my $budget_id                 = $input->param('budget_id');
 my $budget_period_id          = $input->param('budget_period_id');
@@ -96,12 +95,11 @@ my $user_branchcode     = $user->{'branchcode'};
 $template->param(
     show_mine   => $show_mine,
     op  => $op,
+    selected_branchcode => $filter_budgetbranch,
 );
 
 my $budget;
 
-my $branchloop = C4::Branch::GetBranchesLoop($filter_budgetbranch);
-
 $template->param(auth_cats_loop => GetBudgetAuthCats( $budget_period_id ))
     if $budget_period_id;
 
@@ -142,36 +140,11 @@ if ($op eq 'add_form') {
     }
     $budget_parent = GetBudget($budget_parent_id);
 
-    # build branches select
-    my $branches = GetBranches;
-    my @branchloop_select;
-    foreach my $thisbranch ( sort keys %$branches ) {
-        my %row = (
-            value      => $thisbranch,
-            branchname => $branches->{$thisbranch}->{'branchname'},
-        );
-        $row{selected} = 1 if $budget and $thisbranch eq $budget->{'budget_branchcode'};
-        push @branchloop_select, \%row;
-    }
-    
-    # populates the YUI planning button
-    my $categories = GetAuthorisedValueCategories();
-    my @auth_cats_loop1 = ();
-    foreach my $category (@$categories) {
-        my $entry = { category => $category,
-                        selected => ( $budget and $budget->{sort1_authcat} eq $category ? 1 : 0 ),
-                    };
-        push @auth_cats_loop1, $entry;
-    }
-    my @auth_cats_loop2 = ();
-    foreach my $category (@$categories) {
-        my $entry = { category => $category,
-                        selected => ( $budget and $budget->{sort2_authcat} eq $category ? 1 : 0 ),
-                    };
-        push @auth_cats_loop2, $entry;
-    }
-    $template->param(authorised_value_categories1 => \@auth_cats_loop1);
-    $template->param(authorised_value_categories2 => \@auth_cats_loop2);
+    # populates the planning button
+    $template->param(
+        sort1_auth => $budget->{sort1_authcat},
+        sort2_auth => $budget->{sort2_authcat},
+    );
 
     if($budget->{'budget_permission'}){
         my $budget_permission = "budget_perm_".$budget->{'budget_permission'};
@@ -201,7 +174,6 @@ if ($op eq 'add_form') {
         budget_has_children => BudgetHasChildren( $budget->{budget_id} ),
         budget_parent_id                 => $budget_parent->{'budget_id'},
         budget_parent_name               => $budget_parent->{'budget_name'},
-        branchloop_select         => \@branchloop_select,
                %$period,
                %$budget,
     );
@@ -259,7 +231,6 @@ if ($op eq 'add_form') {
 }
 
 if ( $op eq 'list' ) {
-    my $branches = GetBranches();
     $template->param(
         budget_id => $budget_id,
         %$period,
@@ -343,7 +314,6 @@ if ( $op eq 'list' ) {
         spent_total            => $spent_total,
         ordered_total          => $ordered_total,
         available_total        => $available_total,
-        branchloop             => $branchloop,
         filter_budgetname      => $filter_budgetname,
     );