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

(-)a/C4/Budgets.pm (-7 / +4 lines)
Lines 612-627 sub GetBudgetHierarchy { Link Here
612
        $r->{'budget_spent'}       = GetBudgetSpent( $r->{'budget_id'} );
612
        $r->{'budget_spent'}       = GetBudgetSpent( $r->{'budget_id'} );
613
        $r->{budget_ordered} = GetBudgetOrdered( $r->{budget_id} );
613
        $r->{budget_ordered} = GetBudgetOrdered( $r->{budget_id} );
614
614
615
        $r->{'budget_amount_total'} =  $r->{'budget_amount'};
615
        $r->{budget_spent_sublevels} = 0;
616
616
        $r->{budget_ordered_sublevels} = 0;
617
        # foreach sub-levels
617
        # foreach sub-levels
618
        my $unalloc_count ;
619
620
		foreach my $sub (@subs_arr) {
618
		foreach my $sub (@subs_arr) {
621
			my $sub_budget = GetBudget($sub);
619
			my $sub_budget = GetBudget($sub);
622
620
            $r->{budget_spent_sublevels} += GetBudgetSpent( $sub_budget->{'budget_id'} );
623
			$r->{budget_spent_sublevel} +=    GetBudgetSpent( $sub_budget->{'budget_id'} );
621
            $r->{budget_ordered_sublevels} += GetBudgetOrdered($sub);
624
			$unalloc_count +=   $sub_budget->{'budget_amount'};
625
		}
622
		}
626
	}
623
	}
627
	return \@sort;
624
	return \@sort;
(-)a/admin/aqbudgets.pl (-28 / +24 lines)
Lines 276-289 if ($op eq 'add_form') { Link Here
276
    my $toggle = 0;
276
    my $toggle = 0;
277
    my @loop;
277
    my @loop;
278
    my $period_total = 0;
278
    my $period_total = 0;
279
    my ( $period_alloc_total, $base_spent_total, $base_ordered_total );
279
    my ($period_alloc_total, $spent_total, $ordered_total, $available_total) = (0,0,0,0);
280
280
281
	#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 ?
281
	#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
282
283
    foreach my $budget (@budgets) {
283
    foreach my $budget (@budgets) {
284
        #Level and sublevels total spent
284
        #Level and sublevels total spent and ordered
285
        $budget->{'total_levels_spent'} = GetChildBudgetsSpent($budget->{"budget_id"});
285
        $budget->{total_spent} = $budget->{budget_spent_sublevels} + $budget->{budget_spent};
286
286
        $budget->{total_ordered} = $budget->{budget_ordered_sublevels} + $budget->{budget_ordered};
287
        # PERMISSIONS
287
        # PERMISSIONS
288
        unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
288
        unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
289
            $budget->{'budget_lock'} = 1;
289
            $budget->{'budget_lock'} = 1;
Lines 300-321 if ($op eq 'add_form') { Link Here
300
        }
300
        }
301
301
302
## TOTALS
302
## TOTALS
303
        $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'budget_spent'} - $budget->{budget_ordered};
304
        $budget->{'total_remaining'} = $budget->{'budget_amount'} - $budget->{'total_spent'} - $budget->{total_ordered};
303
        # adds to total  - only if budget is a 'top-level' budget
305
        # adds to total  - only if budget is a 'top-level' budget
304
        $period_alloc_total += $budget->{'budget_amount_total'} if $budget->{'depth'} == 0;
306
        if ($budget->{depth} == 0) {
305
        $base_spent_total += $budget->{'budget_spent'};
307
            $period_alloc_total += $budget->{'budget_amount'};
306
        $base_ordered_total += $budget->{budget_ordered};
308
            $spent_total += $budget->{total_spent};
307
        $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'total_levels_spent'};
309
            $ordered_total += $budget->{total_ordered};
310
            $available_total += $budget->{total_remaining};
311
        }
308
312
309
# if amount == 0 dont display...
313
# if amount == 0 dont display...
310
        delete $budget->{'budget_unalloc_sublevel'}
314
        delete $budget->{'budget_unalloc_sublevel'}
311
            if (!defined $budget->{'budget_unalloc_sublevel'}
315
            if (!defined $budget->{'budget_unalloc_sublevel'}
312
            or $budget->{'budget_unalloc_sublevel'} == 0);
316
            or $budget->{'budget_unalloc_sublevel'} == 0);
313
317
314
        $budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0;
318
        for (grep {/total_spent|budget_spent|total_ordered|budget_ordered|budget_amount/} keys %$budget){
315
        $budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0;
316
		for (grep {/total_levels_spent|budget_spent|budget_ordered|budget_amount|budget_remaining|budget_unalloc/} keys %$budget){
317
            $budget->{$_}               = $num->format_price( $budget->{$_} ) if defined($budget->{$_})
319
            $budget->{$_}               = $num->format_price( $budget->{$_} ) if defined($budget->{$_})
318
		}
320
		}
321
        for (qw/budget_remaining total_remaining/) {
322
            if (defined $budget->{$_}) {
323
                $budget->{$_.'_display'} = $num->format_price($budget->{$_});
324
            }
325
        }
319
326
320
        # Value of budget_spent equals 0 instead of undefined value
327
        # Value of budget_spent equals 0 instead of undefined value
321
        $budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"});
328
        $budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"});
Lines 344-365 if ($op eq 'add_form') { Link Here
344
        );
351
        );
345
    }
352
    }
346
353
347
    my $budget_period_total;
354
    my $budget_period_total = $period->{budget_period_total};
348
    if ( $period->{budget_period_total} ) {
349
        $budget_period_total =
350
          $num->format_price( $period->{budget_period_total} );
351
    }
352
353
    if ($period_alloc_total) {
354
        $period_alloc_total = $num->format_price($period_alloc_total);
355
    }
356
357
    if ($base_spent_total) {
358
        $base_spent_total = $num->format_price($base_spent_total);
359
    }
360
355
361
    if ($base_ordered_total) {
356
    foreach ($budget_period_total, $period_alloc_total, $spent_total, $ordered_total, $available_total) {
362
        $base_ordered_total = $num->format_price($base_ordered_total);
357
        $_ = $num->format_price($_);
363
    }
358
    }
364
359
365
    $template->param(
360
    $template->param(
Lines 367-374 if ($op eq 'add_form') { Link Here
367
        budget                 => \@loop,
362
        budget                 => \@loop,
368
        budget_period_total    => $budget_period_total,
363
        budget_period_total    => $budget_period_total,
369
        period_alloc_total     => $period_alloc_total,
364
        period_alloc_total     => $period_alloc_total,
370
        base_spent_total       => $base_spent_total,
365
        spent_total            => $spent_total,
371
        base_ordered_total     => $base_ordered_total,
366
        ordered_total          => $ordered_total,
367
        available_total        => $available_total,
372
        branchloop             => \@branchloop2,
368
        branchloop             => \@branchloop2,
373
    );
369
    );
374
370
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-18 / +29 lines)
Lines 245-256 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
245
        <tr>
245
        <tr>
246
            <th>Fund code</th>
246
            <th>Fund code</th>
247
            <th>Fund name</th>
247
            <th>Fund name</th>
248
            <th>Total<br />allocated</th>
249
            <th>Base-level<br />allocated</th>
248
            <th>Base-level<br />allocated</th>
250
            <th>Base-level<br />ordered</th>
249
            <th>Base-level<br />ordered</th>
250
            <th>Total ordered</th>
251
            <th>Base-level<br />spent</th>
251
            <th>Base-level<br />spent</th>
252
            <th>Total sublevels<br />spent</th>
252
            <th>Total spent</th>
253
            <th>Base-level<br />remaining</th>
253
            <th>Base-level<br />available</th>
254
            <th>Total available</th>
254
            <th class="tooltipcontent">&nbsp;</th>
255
            <th class="tooltipcontent">&nbsp;</th>
255
            <th>Actions</th>
256
            <th>Actions</th>
256
        </tr>
257
        </tr>
Lines 259-270 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
259
    <tr>
260
    <tr>
260
    <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %]  </th>
261
    <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %]  </th>
261
    <th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
262
    <th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
262
    <th nowrap="nowrap"  class="data"> [% base_alloc_total %]</th>
263
    <th></th>
263
    <th class="data">[% base_ordered_total %]</th>
264
    <th class="data">[% ordered_total %]</th>
264
    <th class="data">[% base_spent_total %]</th>
265
    <th></th>
265
    <th class="data">[% base_spent_total %]</th>
266
    <th class="data">[% spent_total %]</th>
266
    <th class="data">[% base_remaining_total %]</th>
267
    <th></th>
267
    <th class="tooltipcontent"></th>
268
    <th class="tooltipcontent"></th>
269
    <th class="data">[% available_total %]</th>
268
    <th></th>
270
    <th></th>
269
    </tr>
271
    </tr>
270
    </tfoot>
272
    </tfoot>
Lines 278-296 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
278
280
279
    <td>[% budge.budget_code_indent %]</td>
281
    <td>[% budge.budget_code_indent %]</td>
280
    <td>[% budge.budget_name %]</td>
282
    <td>[% budge.budget_name %]</td>
281
    <td class="data">[% budge.budget_amount_total %]</td>
282
    <td class="data">[% budge.budget_amount %] </td>
283
    <td class="data">[% budge.budget_amount %] </td>
283
    <td class="data">[% budge.budget_ordered %]</td>
284
    <td class="data">[% budge.budget_ordered %]</td>
285
    <td class="data">[% budge.total_ordered %]</td>
284
    <td class="data">[% budge.budget_spent %] </td>
286
    <td class="data">[% budge.budget_spent %] </td>
285
    <td class="data">[% budge.total_levels_spent %]</td>
287
    <td class="data">[% budge.total_spent %]</td>
286
    [% IF ( budge.remaining_pos ) %]
288
287
        <td class="data" style="color: green;">
289
    [% BLOCK colorcellvalue %]
288
    [% ELSIF ( budge.remaining_neg ) %] 
290
        [% IF (value > 0) %]
289
        <td class="data" style="color: red;">
291
            <span style="color: green;">
290
    [% ELSE %]
292
        [% ELSIF (value < 0) %]
291
        <td class="data">
293
            <span style="color: red;">
294
        [% ELSE %]
295
            <span>
296
        [% END %]
297
            [% text %]
298
        </span>
292
    [% END %]
299
    [% END %]
293
            [% budge.budget_remaining %] </td>
300
    <td class="data">
301
        [% INCLUDE colorcellvalue value=budge.budget_remaining text=budge.budget_remaining_display %]
302
    </td>
303
    <td class="data">
304
        [% INCLUDE colorcellvalue value=budge.total_remaining text=budge.total_remaining_display %]
305
    </td>
294
306
295
    <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 %]
307
    <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 %]
296
        [% IF ( budge.budget_branchcode ) %]<br /><strong>Library: </strong>[% budge.budget_branchcode %][% END %]
308
        [% IF ( budge.budget_branchcode ) %]<br /><strong>Library: </strong>[% budge.budget_branchcode %][% END %]
297
- 

Return to bug 7308