+}
+
+elsif ( $op eq 'close_confirmed' ) {
+ my $to_budget_period_id = $input->param('to_budget_period_id');
+ my $move_remaining_unspent = $input->param('move_remaining_unspent');
+ my $report = MoveOrders(
+ {
+ from_budget_period_id => $budget_period_id,
+ to_budget_period_id => $to_budget_period_id,
+ move_remaining_unspent => $move_remaining_unspent,
+ }
+ );
+
+ my $from_budget_period = GetBudgetPeriod($budget_period_id);
+ my $to_budget_period = GetBudgetPeriod($to_budget_period_id);
+ $template->param(
+ closed => 1,
+ budget_period_id => $from_budget_period->{budget_period_id},
+ budget_period_description => $from_budget_period->{budget_period_description},
+ from_budget_period => $from_budget_period,
+ to_budget_period => $to_budget_period,
+ report => $report,
+ );
+}
+
+# DEFAULT - DISPLAY AQPERIODS TABLE
+# -------------------------------------------------------------------
+# display the list of budget periods
+
+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,
+);