Bug 29859: Use iterator instead of as_list
[srvgit] / admin / aqbudgets.pl
index 5aeb8b9..4ed48d4 100755 (executable)
 use Modern::Perl;
 
 use CGI qw ( -utf8 );
-use List::Util qw/min/;
 
 use Koha::Database;
-use C4::Auth qw/get_user_subpermissions/;
-use C4::Auth;
-use C4::Acquisition;
-use C4::Budgets;
+use C4::Auth qw( get_template_and_user );
+use C4::Budgets qw(
+    AddBudget
+    BudgetHasChildren
+    CanUserModifyBudget
+    CanUserUseBudget
+    DelBudget
+    GetBudget
+    GetBudgetAuthCats
+    GetBudgetHierarchy
+    GetBudgetPeriod
+    GetBudgetPeriods
+    GetBudgetUsers
+    ModBudget
+    ModBudgetUsers
+);
 use C4::Context;
-use C4::Output;
-use C4::Koha;
-use C4::Debug;
+use C4::Output qw( output_html_with_http_headers output_and_exit );
 use Koha::Acquisition::Currencies;
 use Koha::Patrons;
 
-my $input = new CGI;
+my $input = CGI->new;
 my $dbh     = C4::Context->dbh;
 
 my ($template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user(
     {   template_name   => "admin/aqbudgets.tt",
         query           => $input,
         type            => "intranet",
-        authnotrequired => 0,
         flagsrequired   => { acquisition => 'budget_manage' },
-        debug           => 0,
     }
 );
 
@@ -89,9 +96,6 @@ if ( $budget_period_id ) {
 
 # ------- get periods stuff ------------------
 
-# USED FOR PERMISSION COMPARISON LATER
-my $borrower_id         = $template->{VARS}->{'USER_INFO'}->{'borrowernumber'};
-
 $template->param(
     show_mine   => $show_mine,
     op  => $op,
@@ -118,6 +122,8 @@ if ($op eq 'add_form') {
         }
         $dropbox_disabled = BudgetHasChildren($budget_id);
         $budget->{budget_owner} = Koha::Patrons->find( $budget->{budget_owner_id} );
+    } elsif ( $period->{budget_period_locked} ) {
+        output_and_exit( $input, $cookie, $template, 'budget_is_locked' );
     }
 
     # build budget hierarchy
@@ -235,7 +241,7 @@ if ( $op eq 'list' ) {
     );
 
     my @budgets = @{
-        GetBudgetHierarchy( $$period{budget_period_id}, undef, ( $show_mine ? $borrower_id : 0 ))
+        GetBudgetHierarchy( $$period{budget_period_id}, undef, ( $show_mine ? $borrowernumber : 0 ))
     };
 
     my $period_total = 0;