- $template->param(
- period_loop => \@period_loop,
- pagination_bar => pagination_bar("aqbudgetperiods.pl",getnbpages(scalar(@$results),$pagesize),$page),
- );
+my $activepage = $input->param('apage') || 1;
+my $inactivepage = $input->param('ipage') || 1;
+# Get active budget periods
+my $results = GetBudgetPeriods(
+ { budget_period_active => 1 },
+ { -asc => 'budget_period_description' },
+);
+
+my @period_active_loop;
+
+foreach my $result ( @{$results} ) {
+ my $budgetperiod = $result;
+ $budgetperiod->{budget_active} = 1;
+ my $funds = GetBudgets({ budget_period_id => $budgetperiod->{budget_period_id} });
+ $budgetperiod->{count} = scalar @$funds;
+ push( @period_active_loop, $budgetperiod );
+}
+
+# Get inactive budget periods
+$results = GetBudgetPeriods(
+ { budget_period_active => 0 },
+ { -desc => 'budget_period_enddate' },
+);
+
+my @period_inactive_loop;
+foreach my $result ( @{$results} ) {
+ my $budgetperiod = $result;
+ $budgetperiod->{budget_active} = 1;
+ my $funds = GetBudgets({ budget_period_id => $budgetperiod->{budget_period_id} });
+ $budgetperiod->{count} = scalar @$funds;
+ push( @period_inactive_loop, $budgetperiod );
+}
+
+my $tab = $input->param('tab') ? $input->param('tab') - 1 : 0;
+$template->param(
+ period_active_loop => \@period_active_loop,
+ period_inactive_loop => \@period_inactive_loop,
+ tab => $tab,
+);