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

(-)a/C4/Budgets.pm (-6 / +9 lines)
Lines 395-401 sub GetBudgetName { Link Here
395
    return $sth->fetchrow_array;
395
    return $sth->fetchrow_array;
396
}
396
}
397
397
398
# -------------------------------------------------------------------
398
=head2 GetBudgetAuthCats
399
400
  my $auth_cats = &GetBudgetAuthCats($budget_period_id);
401
402
Return the list of authcat for a given budget_period_id
403
404
=cut
405
399
sub GetBudgetAuthCats  {
406
sub GetBudgetAuthCats  {
400
    my ($budget_period_id) = shift;
407
    my ($budget_period_id) = shift;
401
    # now, populate the auth_cats_loop used in the budget planning button
408
    # now, populate the auth_cats_loop used in the budget planning button
Lines 408-418 sub GetBudgetAuthCats { Link Here
408
        $authcats{$sort1_authcat}=1 if $sort1_authcat;
415
        $authcats{$sort1_authcat}=1 if $sort1_authcat;
409
        $authcats{$sort2_authcat}=1 if $sort2_authcat;
416
        $authcats{$sort2_authcat}=1 if $sort2_authcat;
410
    }
417
    }
411
    my @auth_cats_loop;
418
    return [ sort keys %authcats ];
412
    foreach (sort keys %authcats) {
413
        push @auth_cats_loop,{ authcat => $_ };
414
    }
415
    return \@auth_cats_loop;
416
}
419
}
417
420
418
# -------------------------------------------------------------------
421
# -------------------------------------------------------------------
(-)a/admin/aqplan.pl (-1 / +1 lines)
Lines 127-133 while ( my ($category) = $sth->fetchrow_array ) { Link Here
127
push( @category_list, 'MONTHS' );
127
push( @category_list, 'MONTHS' );
128
push( @category_list, 'ITEMTYPES' );
128
push( @category_list, 'ITEMTYPES' );
129
push( @category_list, 'BRANCHES' );
129
push( @category_list, 'BRANCHES' );
130
push( @category_list, $$_{'authcat'} ) foreach @$auth_cats_loop;
130
push( @category_list, $_ ) foreach @$auth_cats_loop;
131
131
132
#reorder the list
132
#reorder the list
133
@category_list = sort { $a cmp $b } @category_list;
133
@category_list = sort { $a cmp $b } @category_list;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-toolbar.inc (-2 / +2 lines)
Lines 48-54 Link Here
48
                        [% ELSE %]
48
                        [% ELSE %]
49
                        <li class="disabled">
49
                        <li class="disabled">
50
                        [% END %]
50
                        [% END %]
51
                        <a href="/cgi-bin/koha/admin/aqplan.pl?budget_period_id=[% budget_period_id %]&amp;authcat=[% auth_cats_loo.authcat %]">Plan by [% auth_cats_loo.authcat %]</a>
51
                        <a href="/cgi-bin/koha/admin/aqplan.pl?budget_period_id=[% budget_period_id %]&amp;authcat=[% auth_cats_loo %]">Plan by [% auth_cats_loo %]</a>
52
                        </li>
52
                        </li>
53
                    [% END %]
53
                    [% END %]
54
                </ul>
54
                </ul>
Lines 58-61 Link Here
58
        <div class="btn-group"><a class="btn btn-small" id="newrootbudget" href="/cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form"><i class="fa fa-plus"></i> New budget</a></div>
58
        <div class="btn-group"><a class="btn btn-small" id="newrootbudget" href="/cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form"><i class="fa fa-plus"></i> New budget</a></div>
59
    [% END %]
59
    [% END %]
60
60
61
</div>
61
</div>
(-)a/t/db_dependent/Budgets.t (-7 / +24 lines)
Lines 1-5 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
use Test::More tests => 133;
2
use Test::More tests => 134;
3
3
4
BEGIN {
4
BEGIN {
5
    use_ok('C4::Budgets')
5
    use_ok('C4::Budgets')
Lines 625-635 is( C4::Budgets::GetBudget($budget_id21)->{budget_owner_id}, Link Here
625
625
626
# Test GetBudgetAuthCats
626
# Test GetBudgetAuthCats
627
627
628
my $budgetPeriodId = 1;
628
my $budgetPeriodId = AddBudgetPeriod({
629
    budget_period_startdate   => '2008-01-01',
630
    budget_period_enddate     => '2008-12-31',
631
    budget_period_description => 'just another budget',
632
    budget_period_active      => 0,
633
});
629
634
630
my $bdgts = GetBudgets();
635
$budgets = GetBudgets();
631
my $i = 0;
636
my $i = 0;
632
for my $budget ( @{$bdgts} )
637
for my $budget ( @$budgets )
633
{
638
{
634
    $budget->{sort1_authcat} = "sort1_authcat_$i";
639
    $budget->{sort1_authcat} = "sort1_authcat_$i";
635
    $budget->{sort2_authcat} = "sort2_authcat_$i";
640
    $budget->{sort2_authcat} = "sort2_authcat_$i";
Lines 643-649 my $authCat = GetBudgetAuthCats($budgetPeriodId); Link Here
643
is( scalar @{$authCat}, $i * 2, "GetBudgetAuthCats returns only non-empty sorting categories (no empty authCat in db)" );
648
is( scalar @{$authCat}, $i * 2, "GetBudgetAuthCats returns only non-empty sorting categories (no empty authCat in db)" );
644
649
645
$i = 0;
650
$i = 0;
646
for my $budget ( @{$bdgts} )
651
for my $budget ( @$budgets )
652
{
653
    $budget->{sort1_authcat} = "sort_authcat_$i";
654
    $budget->{sort2_authcat} = "sort_authcat_$i";
655
    $budget->{budget_period_id} = $budgetPeriodId;
656
    ModBudget( $budget );
657
    $i++;
658
}
659
660
$authCat = GetBudgetAuthCats($budgetPeriodId);
661
is( scalar @$authCat, scalar @$budgets, "GetBudgetAuthCats returns distinct authCat" );
662
663
$i = 0;
664
for my $budget ( @$budgets )
647
{
665
{
648
    $budget->{sort1_authcat} = "sort1_authcat_$i";
666
    $budget->{sort1_authcat} = "sort1_authcat_$i";
649
    $budget->{sort2_authcat} = "";
667
    $budget->{sort2_authcat} = "";
Lines 657-663 $authCat = GetBudgetAuthCats($budgetPeriodId); Link Here
657
is( scalar @{$authCat}, $i, "GetBudgetAuthCats returns only non-empty sorting categories (empty sort2_authcat on all records)" );
675
is( scalar @{$authCat}, $i, "GetBudgetAuthCats returns only non-empty sorting categories (empty sort2_authcat on all records)" );
658
676
659
$i = 0;
677
$i = 0;
660
for my $budget ( @{$bdgts} )
678
for my $budget ( @$budgets )
661
{
679
{
662
    $budget->{sort1_authcat} = "";
680
    $budget->{sort1_authcat} = "";
663
    $budget->{sort2_authcat} = "";
681
    $budget->{sort2_authcat} = "";
664
- 

Return to bug 15009