my $toggle = 0;
my @loop;
my $period_total = 0;
- my ( $period_alloc_total, $base_spent_total, $base_ordered_total );
+ my ($period_alloc_total, $spent_total, $ordered_total, $available_total) = (0,0,0,0);
#This Looks WEIRD to me : should budgets be filtered in such a way ppl who donot own it would not see the amount spent on the budget by others ?
foreach my $budget (@budgets) {
- #Level and sublevels total spent
- $budget->{'total_levels_spent'} = GetChildBudgetsSpent($budget->{"budget_id"});
-
+ #Level and sublevels total spent and ordered
+ $budget->{total_spent} = $budget->{budget_spent_sublevels} + $budget->{budget_spent};
+ $budget->{total_ordered} = $budget->{budget_ordered_sublevels} + $budget->{budget_ordered};
# PERMISSIONS
unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
$budget->{'budget_lock'} = 1;
}
## TOTALS
+ $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'budget_spent'} - $budget->{budget_ordered};
+ $budget->{'total_remaining'} = $budget->{'budget_amount'} - $budget->{'total_spent'} - $budget->{total_ordered};
# adds to total - only if budget is a 'top-level' budget
- $period_alloc_total += $budget->{'budget_amount_total'} if $budget->{'depth'} == 0;
- $base_spent_total += $budget->{'budget_spent'};
- $base_ordered_total += $budget->{budget_ordered};
- $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'total_levels_spent'};
+ if ($budget->{depth} == 0) {
+ $period_alloc_total += $budget->{'budget_amount'};
+ $spent_total += $budget->{total_spent};
+ $ordered_total += $budget->{total_ordered};
+ $available_total += $budget->{total_remaining};
+ }
# if amount == 0 dont display...
delete $budget->{'budget_unalloc_sublevel'}
if (!defined $budget->{'budget_unalloc_sublevel'}
or $budget->{'budget_unalloc_sublevel'} == 0);
- $budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0;
- $budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0;
- for (grep {/total_levels_spent|budget_spent|budget_ordered|budget_amount|budget_remaining|budget_unalloc/} keys %$budget){
+ for (grep {/total_spent|budget_spent|total_ordered|budget_ordered|budget_amount/} keys %$budget){
$budget->{$_} = $num->format_price( $budget->{$_} ) if defined($budget->{$_})
}
+ for (qw/budget_remaining total_remaining/) {
+ if (defined $budget->{$_}) {
+ $budget->{$_.'_display'} = $num->format_price($budget->{$_});
+ }
+ }
# Value of budget_spent equals 0 instead of undefined value
$budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"});
);
}
- my $budget_period_total;
- if ( $period->{budget_period_total} ) {
- $budget_period_total =
- $num->format_price( $period->{budget_period_total} );
- }
-
- if ($period_alloc_total) {
- $period_alloc_total = $num->format_price($period_alloc_total);
- }
-
- if ($base_spent_total) {
- $base_spent_total = $num->format_price($base_spent_total);
- }
+ my $budget_period_total = $period->{budget_period_total};
- if ($base_ordered_total) {
- $base_ordered_total = $num->format_price($base_ordered_total);
+ foreach ($budget_period_total, $period_alloc_total, $spent_total, $ordered_total, $available_total) {
+ $_ = $num->format_price($_);
}
$template->param(
budget => \@loop,
budget_period_total => $budget_period_total,
period_alloc_total => $period_alloc_total,
- base_spent_total => $base_spent_total,
- base_ordered_total => $base_ordered_total,
+ spent_total => $spent_total,
+ ordered_total => $ordered_total,
+ available_total => $available_total,
branchloop => \@branchloop2,
);
<tr>
<th>Fund code</th>
<th>Fund name</th>
- <th>Total<br />allocated</th>
<th>Base-level<br />allocated</th>
<th>Base-level<br />ordered</th>
+ <th>Total ordered</th>
<th>Base-level<br />spent</th>
- <th>Total sublevels<br />spent</th>
- <th>Base-level<br />remaining</th>
+ <th>Total spent</th>
+ <th>Base-level<br />available</th>
+ <th>Total available</th>
<th class="tooltipcontent"> </th>
<th>Actions</th>
</tr>
<tr>
<th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %] </th>
<th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
- <th nowrap="nowrap" class="data"> [% base_alloc_total %]</th>
- <th class="data">[% base_ordered_total %]</th>
- <th class="data">[% base_spent_total %]</th>
- <th class="data">[% base_spent_total %]</th>
- <th class="data">[% base_remaining_total %]</th>
+ <th></th>
+ <th class="data">[% ordered_total %]</th>
+ <th></th>
+ <th class="data">[% spent_total %]</th>
+ <th></th>
<th class="tooltipcontent"></th>
+ <th class="data">[% available_total %]</th>
<th></th>
</tr>
</tfoot>
<td>[% budge.budget_code_indent %]</td>
<td>[% budge.budget_name %]</td>
- <td class="data">[% budge.budget_amount_total %]</td>
<td class="data">[% budge.budget_amount %] </td>
<td class="data">[% budge.budget_ordered %]</td>
+ <td class="data">[% budge.total_ordered %]</td>
<td class="data">[% budge.budget_spent %] </td>
- <td class="data">[% budge.total_levels_spent %]</td>
- [% IF ( budge.remaining_pos ) %]
- <td class="data" style="color: green;">
- [% ELSIF ( budge.remaining_neg ) %]
- <td class="data" style="color: red;">
- [% ELSE %]
- <td class="data">
+ <td class="data">[% budge.total_spent %]</td>
+
+ [% BLOCK colorcellvalue %]
+ [% IF (value > 0) %]
+ <span style="color: green;">
+ [% ELSIF (value < 0) %]
+ <span style="color: red;">
+ [% ELSE %]
+ <span>
+ [% END %]
+ [% text %]
+ </span>
[% END %]
- [% budge.budget_remaining %] </td>
+ <td class="data">
+ [% INCLUDE colorcellvalue value=budge.budget_remaining text=budge.budget_remaining_display %]
+ </td>
+ <td class="data">
+ [% INCLUDE colorcellvalue value=budge.total_remaining text=budge.total_remaining_display %]
+ </td>
<td class="tooltipcontent">[% IF ( budge.budget_owner_id ) %]<strong>Owner: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budge.budget_owner_id %]">[% budge.budget_owner_name %]</a>[% END %]
[% IF ( budge.budget_branchcode ) %]<br /><strong>Library: </strong>[% budge.budget_branchcode %][% END %]