View | Details | Raw Unified | Return to bug 7308
Collapse All | Expand All

(-)a/C4/Budgets.pm (-7 / +4 lines)
Lines 589-604 sub GetBudgetHierarchy { Link Here
589
        $r->{'budget_spent'}       = GetBudgetSpent( $r->{'budget_id'} );
589
        $r->{'budget_spent'}       = GetBudgetSpent( $r->{'budget_id'} );
590
        $r->{budget_ordered} = GetBudgetOrdered( $r->{budget_id} );
590
        $r->{budget_ordered} = GetBudgetOrdered( $r->{budget_id} );
591
591
592
        $r->{'budget_amount_total'} =  $r->{'budget_amount'};
592
        $r->{budget_spent_sublevels} = 0;
593
593
        $r->{budget_ordered_sublevels} = 0;
594
        # foreach sub-levels
594
        # foreach sub-levels
595
        my $unalloc_count ;
596
597
		foreach my $sub (@subs_arr) {
595
		foreach my $sub (@subs_arr) {
598
			my $sub_budget = GetBudget($sub);
596
			my $sub_budget = GetBudget($sub);
599
597
            $r->{budget_spent_sublevels} += GetBudgetSpent( $sub_budget->{'budget_id'} );
600
			$r->{budget_spent_sublevel} +=    GetBudgetSpent( $sub_budget->{'budget_id'} );
598
            $r->{budget_ordered_sublevels} += GetBudgetOrdered($sub);
601
			$unalloc_count +=   $sub_budget->{'budget_amount'};
602
		}
599
		}
603
	}
600
	}
604
	return \@sort;
601
	return \@sort;
(-)a/admin/aqbudgets.pl (-28 / +24 lines)
Lines 277-290 if ($op eq 'add_form') { Link Here
277
    my $toggle = 0;
277
    my $toggle = 0;
278
    my @loop;
278
    my @loop;
279
    my $period_total = 0;
279
    my $period_total = 0;
280
    my ( $period_alloc_total, $base_spent_total, $base_ordered_total );
280
    my ($period_alloc_total, $spent_total, $ordered_total, $available_total) = (0,0,0,0);
281
281
282
	#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 ?
282
	#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 ?
283
283
284
    foreach my $budget (@budgets) {
284
    foreach my $budget (@budgets) {
285
        #Level and sublevels total spent
285
        #Level and sublevels total spent and ordered
286
        $budget->{'total_levels_spent'} = GetChildBudgetsSpent($budget->{"budget_id"});
286
        $budget->{total_spent} = $budget->{budget_spent_sublevels} + $budget->{budget_spent};
287
287
        $budget->{total_ordered} = $budget->{budget_ordered_sublevels} + $budget->{budget_ordered};
288
        # PERMISSIONS
288
        # PERMISSIONS
289
        unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
289
        unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
290
            $budget->{'budget_lock'} = 1;
290
            $budget->{'budget_lock'} = 1;
Lines 301-322 if ($op eq 'add_form') { Link Here
301
        }
301
        }
302
302
303
## TOTALS
303
## TOTALS
304
        $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'budget_spent'} - $budget->{budget_ordered};
305
        $budget->{'total_remaining'} = $budget->{'budget_amount'} - $budget->{'total_spent'} - $budget->{total_ordered};
304
        # adds to total  - only if budget is a 'top-level' budget
306
        # adds to total  - only if budget is a 'top-level' budget
305
        $period_alloc_total += $budget->{'budget_amount_total'} if $budget->{'depth'} == 0;
307
        if ($budget->{depth} == 0) {
306
        $base_spent_total += $budget->{'budget_spent'};
308
            $period_alloc_total += $budget->{'budget_amount'};
307
        $base_ordered_total += $budget->{budget_ordered};
309
            $spent_total += $budget->{total_spent};
308
        $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'total_levels_spent'};
310
            $ordered_total += $budget->{total_ordered};
311
            $available_total += $budget->{total_remaining};
312
        }
309
313
310
# if amount == 0 dont display...
314
# if amount == 0 dont display...
311
        delete $budget->{'budget_unalloc_sublevel'}
315
        delete $budget->{'budget_unalloc_sublevel'}
312
            if (!defined $budget->{'budget_unalloc_sublevel'}
316
            if (!defined $budget->{'budget_unalloc_sublevel'}
313
            or $budget->{'budget_unalloc_sublevel'} == 0);
317
            or $budget->{'budget_unalloc_sublevel'} == 0);
314
318
315
        $budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0;
319
		for (grep {/total_spent|budget_spent|total_ordered|budget_ordered|budget_amount/} keys %$budget){
316
        $budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0;
317
		for (grep {/total_levels_spent|budget_spent|budget_ordered|budget_amount|budget_remaining|budget_unalloc/} keys %$budget){
318
            $budget->{$_}               = $num->format_price( $budget->{$_} ) if defined($budget->{$_})
320
            $budget->{$_}               = $num->format_price( $budget->{$_} ) if defined($budget->{$_})
319
		}
321
		}
322
        for (qw/budget_remaining total_remaining/) {
323
            if (defined $budget->{$_}) {
324
                $budget->{$_.'_display'} = $num->format_price($budget->{$_});
325
            }
326
        }
320
327
321
        # Value of budget_spent equals 0 instead of undefined value
328
        # Value of budget_spent equals 0 instead of undefined value
322
        $budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"});
329
        $budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"});
Lines 345-366 if ($op eq 'add_form') { Link Here
345
        );
352
        );
346
    }
353
    }
347
354
348
    my $budget_period_total;
355
    my $budget_period_total = $period->{budget_period_total};
349
    if ( $period->{budget_period_total} ) {
350
        $budget_period_total =
351
          $num->format_price( $period->{budget_period_total} );
352
    }
353
354
    if ($period_alloc_total) {
355
        $period_alloc_total = $num->format_price($period_alloc_total);
356
    }
357
358
    if ($base_spent_total) {
359
        $base_spent_total = $num->format_price($base_spent_total);
360
    }
361
356
362
    if ($base_ordered_total) {
357
    foreach ($budget_period_total, $period_alloc_total, $spent_total, $ordered_total, $available_total) {
363
        $base_ordered_total = $num->format_price($base_ordered_total);
358
        $_ = $num->format_price($_);
364
    }
359
    }
365
360
366
    $template->param(
361
    $template->param(
Lines 368-375 if ($op eq 'add_form') { Link Here
368
        budget                 => \@loop,
363
        budget                 => \@loop,
369
        budget_period_total    => $budget_period_total,
364
        budget_period_total    => $budget_period_total,
370
        period_alloc_total     => $period_alloc_total,
365
        period_alloc_total     => $period_alloc_total,
371
        base_spent_total       => $base_spent_total,
366
        spent_total            => $spent_total,
372
        base_ordered_total     => $base_ordered_total,
367
        ordered_total          => $ordered_total,
368
        available_total        => $available_total,
373
        branchloop             => \@branchloop2,
369
        branchloop             => \@branchloop2,
374
    );
370
    );
375
371
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-18 / +29 lines)
Lines 226-237 Link Here
226
        <tr>
226
        <tr>
227
            <th>Fund code</th>
227
            <th>Fund code</th>
228
            <th>Fund name</th>
228
            <th>Fund name</th>
229
            <th>Total<br />allocated</th>
230
            <th>Base-level<br />allocated</th>
229
            <th>Base-level<br />allocated</th>
231
            <th>Base-level<br />ordered</th>
230
            <th>Base-level<br />ordered</th>
231
            <th>Total ordered</th>
232
            <th>Base-level<br />spent</th>
232
            <th>Base-level<br />spent</th>
233
            <th>Total sublevels<br />spent</th>
233
            <th>Total spent</th>
234
            <th>Base-level<br />remaining</th>
234
            <th>Base-level<br />available</th>
235
            <th>Total available</th>
235
            <th class="tooltipcontent">&nbsp;</th>
236
            <th class="tooltipcontent">&nbsp;</th>
236
            <th>Actions</th>
237
            <th>Actions</th>
237
        </tr>
238
        </tr>
Lines 240-251 Link Here
240
    <tr>
241
    <tr>
241
    <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %]  </th>
242
    <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %]  </th>
242
    <th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
243
    <th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
243
    <th nowrap="nowrap"  class="data"> [% base_alloc_total %]</th>
244
    <th></th>
244
    <th class="data">[% base_ordered_total %]</th>
245
    <th class="data">[% ordered_total %]</th>
245
    <th class="data">[% base_spent_total %]</th>
246
    <th></th>
246
    <th class="data">[% base_spent_total %]</th>
247
    <th class="data">[% spent_total %]</th>
247
    <th class="data">[% base_remaining_total %]</th>
248
    <th></th>
248
    <th class="tooltipcontent"></th>
249
    <th class="tooltipcontent"></th>
250
    <th class="data">[% available_total %]</th>
249
    <th></th>
251
    <th></th>
250
    </tr>
252
    </tr>
251
    </tfoot>
253
    </tfoot>
Lines 260-278 Link Here
260
262
261
    <td>[% budge.budget_code_indent %]</td>
263
    <td>[% budge.budget_code_indent %]</td>
262
    <td>[% budge.budget_name %]</td>
264
    <td>[% budge.budget_name %]</td>
263
    <td class="data">[% budge.budget_amount_total %]</td>
264
    <td class="data">[% budge.budget_amount %] </td>
265
    <td class="data">[% budge.budget_amount %] </td>
265
    <td class="data">[% budge.budget_ordered %]</td>
266
    <td class="data">[% budge.budget_ordered %]</td>
267
    <td class="data">[% budge.total_ordered %]</td>
266
    <td class="data">[% budge.budget_spent %] </td>
268
    <td class="data">[% budge.budget_spent %] </td>
267
    <td class="data">[% budge.total_levels_spent %]</td>
269
    <td class="data">[% budge.total_spent %]</td>
268
    [% IF ( budge.remaining_pos ) %]
270
269
        <td class="data" style="color: green;">
271
    [% BLOCK colorcellvalue %]
270
    [% ELSIF ( budge.remaining_neg ) %] 
272
        [% IF (value > 0) %]
271
        <td class="data" style="color: red;">
273
            <span style="color: green;">
272
    [% ELSE %]
274
        [% ELSIF (value < 0) %]
273
        <td class="data">
275
            <span style="color: red;">
276
        [% ELSE %]
277
            <span>
278
        [% END %]
279
            [% text %]
280
        </span>
274
    [% END %]
281
    [% END %]
275
            [% budge.budget_remaining %] </td>
282
    <td class="data">
283
        [% INCLUDE colorcellvalue value=budge.budget_remaining text=budge.budget_remaining_display %]
284
    </td>
285
    <td class="data">
286
        [% INCLUDE colorcellvalue value=budge.total_remaining text=budge.total_remaining_display %]
287
    </td>
276
288
277
    <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 %]
289
    <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 %]
278
        [% IF ( budge.budget_branchcode ) %]<br /><strong>Library: </strong>[% budge.budget_branchcode %][% END %]
290
        [% IF ( budge.budget_branchcode ) %]<br /><strong>Library: </strong>[% budge.budget_branchcode %][% END %]
279
- 

Return to bug 7308