@@ -, +, @@ --- admin/aqbudgetperiods.pl | 15 ++++++++++----- .../prog/en/modules/admin/aqbudgetperiods.tt | 8 ++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) --- a/admin/aqbudgetperiods.pl +++ a/admin/aqbudgetperiods.pl @@ -128,12 +128,17 @@ elsif ( $op eq 'add_validate' ) { elsif ( $op eq 'delete_confirm' ) { ## delete a budget period (preparation) my $dbh = C4::Context->dbh; - ## $total = number of records linked to the record that must be deleted + my $funds = GetBudgets({ budget_period_id => $budget_period_id }); + my $fund_count = scalar @$funds; + if ( $fund_count > 0 ) { + $template->param( funds_exist => 1 ); + } + + #$total = number of records linked to the record that must be deleted my $total = 0; my $data = GetBudgetPeriod( $budget_period_id); - $template->param( - %$data + %$data ); } @@ -278,8 +283,8 @@ 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; + my $funds = GetBudgets({ budget_period_id => $budgetperiod->{budget_period_id} }); + $budgetperiod->{count} = scalar @$funds; push( @period_inactive_loop, $budgetperiod ); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt @@ -231,7 +231,7 @@ [% END %] [% IF ( delete_confirm ) %] Budgets › - [% IF ( total ) %] + [% IF ( total || funds_exist ) %] Cannot delete budget '[% budget_period_description %]' [% ELSE %] Delete budget '[% budget_period_description %]'? @@ -407,10 +407,13 @@

Cannot delete budget

This record is used [% total %] times . Deletion is not possible.

+ [% ELSIF ( funds_exist ) %] +
+

Cannot delete budget

+

This budget has funds attached. You must delete all attached funds before you can delete this budget.

[% ELSE %]

Delete budget '[% budget_period_description %]'?

- [% END %] @@ -424,6 +427,7 @@
+ [% END %]
[% END %] --