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

(-)a/C4/Budgets.pm (-54 / +54 lines)
Lines 35-44 BEGIN { Link Here
35
        &GetBudgetByOrderNumber
35
        &GetBudgetByOrderNumber
36
        &GetBudgetByCode
36
        &GetBudgetByCode
37
        &GetBudgets
37
        &GetBudgets
38
        &GetActiveBudgets
38
        &BudgetsByActivity
39
        &GetBudgetReport
40
        &GetBudgetsReport
39
        &GetBudgetsReport
41
        &GetActiveBudgetsReport
40
        &GetBudgetReport
42
        &GetBudgetHierarchy
41
        &GetBudgetHierarchy
43
	    &AddBudget
42
	    &AddBudget
44
        &ModBudget
43
        &ModBudget
Lines 443-448 sub GetBudgetPeriod { Link Here
443
}
442
}
444
443
445
# -------------------------------------------------------------------
444
# -------------------------------------------------------------------
445
=head2 GetBudgetPeriodDescription
446
447
       $description = GetBudgetPeriodDescription($budget_id);
448
449
    Return value: hashref
450
451
    Returns the budget period description for a given budget id.
452
453
    Description is fetched from aqbudgetperiods, id is compared aqbudgets. (INNER JOIN on budget_period_id)
454
455
=cut
446
sub GetBudgetPeriodDescription {
456
sub GetBudgetPeriodDescription {
447
    my ($budget_id) = @_;
457
    my ($budget_id) = @_;
448
    my $dbh = C4::Context->dbh;
458
    my $dbh = C4::Context->dbh;
Lines 630-635 sub DelBudget { Link Here
630
}
640
}
631
641
632
642
643
# -------------------------------------------------------------------
633
=head2 GetBudget
644
=head2 GetBudget
634
645
635
  &GetBudget($budget_id);
646
  &GetBudget($budget_id);
Lines 638-644 get a specific budget Link Here
638
649
639
=cut
650
=cut
640
651
641
# -------------------------------------------------------------------
642
sub GetBudget {
652
sub GetBudget {
643
    my ( $budget_id ) = @_;
653
    my ( $budget_id ) = @_;
644
    my $dbh = C4::Context->dbh;
654
    my $dbh = C4::Context->dbh;
Lines 653-658 sub GetBudget { Link Here
653
    return $result;
663
    return $result;
654
}
664
}
655
665
666
# -------------------------------------------------------------------
667
656
=head2 GetBudgetByOrderNumber
668
=head2 GetBudgetByOrderNumber
657
669
658
  &GetBudgetByOrderNumber($ordernumber);
670
  &GetBudgetByOrderNumber($ordernumber);
Lines 661-667 get a specific budget by order number Link Here
661
673
662
=cut
674
=cut
663
675
664
# -------------------------------------------------------------------
665
sub GetBudgetByOrderNumber {
676
sub GetBudgetByOrderNumber {
666
    my ( $ordernumber ) = @_;
677
    my ( $ordernumber ) = @_;
667
    my $dbh = C4::Context->dbh;
678
    my $dbh = C4::Context->dbh;
Lines 679-687 sub GetBudgetByOrderNumber { Link Here
679
690
680
=head2 GetBudgetReport
691
=head2 GetBudgetReport
681
692
682
  &GetBudgetReport();
693
  &GetBudgetReport( [$budget_id] );
694
695
Get all orders for a specific budget, without cancelled orders.
683
696
684
Get one specific budget for reports without cancelled baskets.
697
Returns an array of hashrefs.
685
698
686
=cut
699
=cut
687
700
Lines 689-733 Get one specific budget for reports without cancelled baskets. Link Here
689
sub GetBudgetReport {
702
sub GetBudgetReport {
690
    my ( $budget_id ) = @_;
703
    my ( $budget_id ) = @_;
691
    my $dbh = C4::Context->dbh;
704
    my $dbh = C4::Context->dbh;
692
    my $query = "
705
    my $query = '
693
        SELECT o.*, b.budget_name
706
        SELECT o.*, b.budget_name
694
        FROM   aqbudgets b
707
        FROM   aqbudgets b
695
        INNER JOIN aqorders o
708
        INNER JOIN aqorders o
696
        ON b.budget_id = o.budget_id
709
        ON b.budget_id = o.budget_id
697
        WHERE  b.budget_id=?
710
        WHERE  b.budget_id=?
698
        AND (o.datecancellationprinted IS NULL OR o.datecancellationprinted='0000-00-00')
711
        AND (o.orderstatus != "cancelled")
699
        ORDER BY b.budget_name
712
        ORDER BY b.budget_name';
700
        ";
713
701
    my $sth = $dbh->prepare($query);
714
    my $sth = $dbh->prepare($query);
702
    $sth->execute( $budget_id );
715
    $sth->execute( $budget_id );
703
    my @results = ();
704
    while ( my $data = $sth->fetchrow_hashref ) {
705
        push( @results, $data );
706
    }
707
    return @results;
708
}
709
710
=head2 GetBudgetsReport
711
712
  &GetBudgetsReport();
713
714
Get all budgets for reports without cancelled baskets.
715
716
716
=cut
717
718
# --------------------------------------------------------------------
719
sub GetBudgetsReport {
720
    my $dbh = C4::Context->dbh;
721
    my $query = "
722
        SELECT o.*, b.budget_name
723
        FROM   aqbudgets b
724
        INNER JOIN aqorders o
725
        ON b.budget_id = o.budget_id
726
        WHERE (o.datecancellationprinted IS NULL OR o.datecancellationprinted='0000-00-00')
727
        ORDER BY b.budget_name
728
        ";
729
    my $sth = $dbh->prepare($query);
730
    $sth->execute;
731
    my @results = ();
717
    my @results = ();
732
    while ( my $data = $sth->fetchrow_hashref ) {
718
    while ( my $data = $sth->fetchrow_hashref ) {
733
        push( @results, $data );
719
        push( @results, $data );
Lines 735-745 sub GetBudgetsReport { Link Here
735
    return @results;
721
    return @results;
736
}
722
}
737
723
738
=head2 GetActiveBudgets
724
=head2 GetBudgetsByActivity
739
725
740
  &GetActiveBudgets( $budget_period_active );
726
  &GetBudgetsByActivity( $budget_period_active );
741
727
742
Get all active budgets or all inactive budgets, depending of the value
728
Get all active or inactive budgets, depending of the value
743
of the parameter.
729
of the parameter.
744
730
745
1 = active
731
1 = active
Lines 748-754 of the parameter. Link Here
748
=cut
734
=cut
749
735
750
# --------------------------------------------------------------------
736
# --------------------------------------------------------------------
751
sub GetActiveBudgets {
737
sub GetBudgetsByActivity {
752
    my ( $budget_period_active ) = @_;
738
    my ( $budget_period_active ) = @_;
753
    my $dbh = C4::Context->dbh;
739
    my $dbh = C4::Context->dbh;
754
    my $query = "
740
    my $query = "
Lines 766-796 sub GetActiveBudgets { Link Here
766
    }
752
    }
767
    return @results;
753
    return @results;
768
}
754
}
755
# --------------------------------------------------------------------
756
=head2 GetBudgetsReport
757
758
  &GetBudgetsReport( [$activity] );
769
759
770
=head2 GetActiveBudgetsReport
760
Get all but cancelled orders for all funds.
771
761
772
  &GetActiveBudgetsReport();
762
If the optionnal activity parameter is passed, returns orders for active/inactive budgets only.
773
763
774
Get all active budgets for reports without cancelled baskets.
764
active = 1
765
inactive = 0
766
767
Returns an array of hashrefs.
775
768
776
=cut
769
=cut
777
770
778
# --------------------------------------------------------------------
771
sub GetBudgetsReport {
779
sub GetActiveBudgetsReport {
772
    my ($activity) = @_;
780
    my $dbh = C4::Context->dbh;
773
    my $dbh = C4::Context->dbh;
781
    my $query = "
774
    my $query = '
782
        SELECT o.*, b.budget_name
775
        SELECT o.*, b.budget_name
783
        FROM   aqbudgetperiods bp
776
        FROM   aqbudgetperiods bp
784
        INNER JOIN aqbudgets b
777
        INNER JOIN aqbudgets b
785
        ON bp.budget_period_id = b.budget_period_id
778
        ON bp.budget_period_id = b.budget_period_id
786
        INNER JOIN aqorders o
779
        INNER JOIN aqorders o
787
        ON b.budget_id = o.budget_id
780
        ON b.budget_id = o.budget_id ';
788
        WHERE  bp.budget_period_active=1
781
    if($activity ne ''){
789
        AND (o.datecancellationprinted IS NULL OR o.datecancellationprinted='0000-00-00')
782
        $query .= 'WHERE  bp.budget_period_active=? ';
790
        ORDER BY b.budget_name
783
    }
791
        ";
784
    $query .= 'AND (o.orderstatus != "cancelled")
785
               ORDER BY b.budget_name';
786
792
    my $sth = $dbh->prepare($query);
787
    my $sth = $dbh->prepare($query);
793
    $sth->execute;
788
    if($activity ne ''){
789
        $sth->execute($activity);
790
    }
791
    else{
792
        $sth->execute;
793
    }
794
    my @results = ();
794
    my @results = ();
795
    while ( my $data = $sth->fetchrow_hashref ) {
795
    while ( my $data = $sth->fetchrow_hashref ) {
796
        push( @results, $data );
796
        push( @results, $data );
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/reports/orders_by_budget.tt (+1 lines)
Line 0 Link Here
1
Fund[% sep %]Basket[% sep %]Basket by[% sep %]biblionumber[% sep %]Title[% sep %]Currency[% sep %]Vendor Price[% sep %]RRP[% sep %]Budgeted Cost[% sep %]Quantity[% sep %]Total RRP[% sep %]Total Cost[% sep %]Entry Date[% sep %]Date Received[% sep %]Notes
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/csv/orders_by_budget.tt (+12 lines)
Line 0 Link Here
1
[% INCLUDE csv_headers/reports/orders_by_budget.tt %]
2
[%- FOREACH row IN rows %]
3
    [%- FOREACH field IN row;
4
       field;
5
       sep IF !loop.last;
6
    END %]
7
[% END -%]
8
TOTAL
9
[%- FOREACH field IN totalrow;
10
    field;
11
    sep IF !loop.last;
12
END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/orders_by_budget.tt (-16 / +26 lines)
Lines 1-12 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Reports &rsaquo; Orders by budget</title>
2
<title>Koha &rsaquo; Reports &rsaquo; Orders by fund</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
4
</head>
5
<body>
5
<body>
6
[% INCLUDE 'header.inc' %]
6
[% INCLUDE 'header.inc' %]
7
[% INCLUDE 'cat-search.inc' %]
7
[% INCLUDE 'cat-search.inc' %]
8
8
9
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>[% IF ( get_orders ) %] &rsaquo; <a href="/cgi-bin/koha/reports/orders_by_budget.pl">Orders by budget</a> &rsaquo; Results[% ELSE %] &rsaquo; Orders by budget[% END %]</div>
9
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>[% IF ( get_orders ) %] &rsaquo; <a href="/cgi-bin/koha/reports/orders_by_budget.pl">Orders by fund</a> &rsaquo; Results[% ELSE %] &rsaquo; Orders by fund[% END %]</div>
10
10
11
<div id="doc3" class="yui-t2">
11
<div id="doc3" class="yui-t2">
12
12
Lines 14-22 Link Here
14
    <div id="yui-main">
14
    <div id="yui-main">
15
    <div class="yui-b">
15
    <div class="yui-b">
16
[% IF ( current_budget_name ) %]
16
[% IF ( current_budget_name ) %]
17
<h1>Orders for budget '[% current_budget_name %]'</h1>
17
<h1>Orders for fund '[% current_budget_name %]'</h1>
18
[% ELSE %]
18
[% ELSE %]
19
<h1>Orders by budget</h1>
19
<h1>Orders by fund</h1>
20
[% END %]
20
[% END %]
21
21
22
[% IF ( get_orders ) %]
22
[% IF ( get_orders ) %]
Lines 31-49 Link Here
31
31
32
    [% IF ( ordersloop ) %]<table>
32
    [% IF ( ordersloop ) %]<table>
33
    <tr>
33
    <tr>
34
        <th>Budget</th>
34
        <th>Fund</th>
35
        <th>Basket</th>
35
        <th>Basket</th>
36
    <th>Basket by</th>
36
        <th>Basket By</th>
37
        <th>Title</th>
37
        <th>Title</th>
38
        <th>Currency</th>
38
        <th>Currency</th>
39
        <th>Vendor Price</th>
39
        <th>Vendor Price</th>
40
        <th>RRP</th>
40
        <th>RRP</th>
41
        <th>Budgeted cost</th>
41
        <th>Budgeted Cost</th>
42
        <th>Quantity</th>
42
        <th>Quantity</th>
43
        <th>Total RRP</th>
43
        <th>Total RRP</th>
44
        <th>Total cost</th>
44
        <th>Total Cost</th>
45
        <th>Entry date</th>
45
        <th>Entry Date</th>
46
        <th>Date received</th>
46
        <th>Date Received</th>
47
        <th>Notes</th>
47
        <th>Notes</th>
48
    </tr>
48
    </tr>
49
     [% FOREACH ordersloo IN ordersloop %]
49
     [% FOREACH ordersloo IN ordersloop %]
Lines 78-88 Link Here
78
    [% ELSE %]
78
    [% ELSE %]
79
79
80
    <form name="f" action="/cgi-bin/koha/reports/orders_by_budget.pl" method="post">
80
    <form name="f" action="/cgi-bin/koha/reports/orders_by_budget.pl" method="post">
81
<fieldset class="rows"><ol>
81
<fieldset class="rows">
82
    <legend>Filters</legend>
82
    <legend>Filters</legend>
83
    <li><label for="budgetfilter">Budget: </label><select name="budgetfilter" id="budgetfilter">
83
    <ol><li><label for="budgetfilter">Fund (Budget): </label><select name="budgetfilter" id="budgetfilter">
84
        <option value="">All budgets</option>
84
        <option value="">All funds</option>
85
        <option value="activebudgets">All active budgets</option>
85
        <option value="activebudgets">All active funds</option>
86
            [% FOREACH budgetsloo IN budgetsloop %]
86
            [% FOREACH budgetsloo IN budgetsloop %]
87
                [% IF ( budgetsloo.selected ) %]<option value="[% budgetsloo.value %]" selected="selected">[% budgetsloo.description %] [% budgetsloo.period %]</option>
87
                [% IF ( budgetsloo.selected ) %]<option value="[% budgetsloo.value %]" selected="selected">[% budgetsloo.description %] [% budgetsloo.period %]</option>
88
        [% ELSE %]
88
        [% ELSE %]
Lines 96-103 Link Here
96
    <legend>Output</legend>
96
    <legend>Output</legend>
97
<ol><li><label for="outputscreen">To screen into the browser: </label><input type="radio" checked="checked" name="output" id="outputscreen" value="screen" /> </li>
97
<ol><li><label for="outputscreen">To screen into the browser: </label><input type="radio" checked="checked" name="output" id="outputscreen" value="screen" /> </li>
98
<li><label for="outputfile">To a file:</label>      <input type="radio" name="output" value="file" id="outputfile" /> <label class="inline" for="basename">Named: </label><input type="text" name="basename" id="basename" value="Export" /> <label class="inline" for="MIME">Into an application
98
<li><label for="outputfile">To a file:</label>      <input type="radio" name="output" value="file" id="outputfile" /> <label class="inline" for="basename">Named: </label><input type="text" name="basename" id="basename" value="Export" /> <label class="inline" for="MIME">Into an application
99
    </label>[% CGIextChoice %]
99
    </label>
100
    [% CGIsepChoice %]</li></ol>
100
    <select id='MIME' name='MIME' size='1'>
101
    [% FOREACH outputFormatloo IN outputFormatloop %]
102
        <option value="[% outputFormatloo %]">[% outputFormatloo %]</option>
103
    [% END %]
104
    </select>
105
    <select id='sep' name='sep' size='1'>
106
    [% FOREACH delimiterloo IN delimiterloop %]
107
        <option value="[% delimiterloo %]">[% delimiterloo %]</option>
108
    [% END %]
109
    </select>
110
    </li></ol>
101
    </fieldset>
111
    </fieldset>
102
112
103
<fieldset class="action">    <input type="submit" value="Submit" />
113
<fieldset class="action">    <input type="submit" value="Submit" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt (-1 / +1 lines)
Lines 61-67 Link Here
61
    <h2>Other</h2>
61
    <h2>Other</h2>
62
    <ul>
62
    <ul>
63
        <li><a href="/cgi-bin/koha/reports/itemslost.pl">Items lost</a></li>
63
        <li><a href="/cgi-bin/koha/reports/itemslost.pl">Items lost</a></li>
64
                <li><a href="/cgi-bin/koha/reports/orders_by_budget.pl">Orders by budget</a></li>
64
                <li><a href="/cgi-bin/koha/reports/orders_by_budget.pl">Orders by fund</a></li>
65
        <li><a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by itemtype</a></li>
65
        <li><a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by itemtype</a></li>
66
        <li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
66
        <li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
67
                <li><a href="http://schema.koha-community.org/" target="blank">Koha database schema</a></li>
67
                <li><a href="http://schema.koha-community.org/" target="blank">Koha database schema</a></li>
(-)a/reports/orders_by_budget.pl (-57 / +40 lines)
Lines 74-80 if ( $get_orders ) { Link Here
74
    else {
74
    else {
75
        if ($budgetfilter eq 'activebudgets') {
75
        if ($budgetfilter eq 'activebudgets') {
76
           # If all active budgets's option was selected, get the orders of all active budgets
76
           # If all active budgets's option was selected, get the orders of all active budgets
77
           my @active_budgets = C4::Budgets::GetActiveBudgetsReport();
77
           my @active_budgets = C4::Budgets::GetBudgetsReport(1);
78
           foreach my $active_budget (@active_budgets)
78
           foreach my $active_budget (@active_budgets)
79
           {
79
           {
80
               push(@orders, $active_budget);
80
               push(@orders, $active_budget);
Lines 142-157 if ( $get_orders ) { Link Here
142
    else {
142
    else {
143
        my $basename = $params->{"basename"};
143
        my $basename = $params->{"basename"};
144
        my $sep = $params->{"sep"};
144
        my $sep = $params->{"sep"};
145
        $sep = "\t" if ($sep == 'tabulation');
145
        $sep = "\t" if ($sep eq 'tabulation');
146
146
147
        print $query->header(
147
        print $query->header(
148
            -type       => 'application/vnd.sun.xml.calc',
148
           -type       => 'application/vnd.sun.xml.calc',
149
            -encoding    => 'utf-8',
149
           -encoding    => 'utf-8',
150
            -attachment => "$basename.csv",
150
           -attachment => "$basename.csv",
151
            -name       => "$basename.csv"
151
           -name       => "$basename.csv"
152
        );
152
        );
153
153
154
        binmode STDOUT, ":encoding(UTF-8)";
154
        #binmode STDOUT, ":encoding(UTF-8)";
155
155
156
        # Surrounds a string with double-quotes and escape the double-quotes inside
156
        # Surrounds a string with double-quotes and escape the double-quotes inside
157
        sub _surround {
157
        sub _surround {
Lines 159-225 if ( $get_orders ) { Link Here
159
            $string =~ s/"/""/g;
159
            $string =~ s/"/""/g;
160
            return "\"$string\"";
160
            return "\"$string\"";
161
        }
161
        }
162
162
        my @rows;
163
        # Create the CSV file
164
        print '"Budget"' . $sep;
165
        print '"Basket"' . $sep;
166
        print '"Basket by"' . $sep;
167
        print '"biblionumber"' . $sep;
168
        print '"Title"' . $sep;
169
        print '"Currency"' . $sep;
170
        print '"Vendor Price"' . $sep;
171
        print '"RRP"' . $sep;
172
        print '"Budgeted cost"' . $sep;
173
        print '"Quantity"' . $sep;
174
        print '"Total RRP"' . $sep;
175
        print '"Total cost"' . $sep;
176
        print '"Entry date"' . $sep;
177
        print '"Date received"' . $sep;
178
        print '"Notes"' . "\n";
179
180
        foreach my $order (@orders) {
163
        foreach my $order (@orders) {
181
            print _surround($order->{'budget_name'}) . $sep;
164
            my @row;
182
            print _surround($order->{'basketno'}) . $sep;
165
            push(@row, _surround($order->{'budget_name'}));
183
            print _surround($order->{'authorisedbyname'}) . $sep;
166
            push(@row, _surround($order->{'basketno'}));
184
            print _surround($order->{'biblionumber'}) . $sep;
167
            push(@row, _surround($order->{'authorisedbyname'}));
185
            print _surround($order->{'title'}) . $sep;
168
            push(@row, _surround($order->{'biblionumber'}));
186
            print _surround($order->{'currency'}) . $sep;
169
            push(@row, _surround($order->{'title'}));
187
            print _surround($order->{'listprice'}) . $sep;
170
            push(@row, _surround($order->{'currency'}));
188
            print _surround($order->{'rrp'}) . $sep;
171
            push(@row, _surround($order->{'listprice'}));
189
            print _surround($order->{'ecost'}) . $sep;
172
            push(@row, _surround($order->{'rrp'}));
190
            print _surround($order->{'quantity'}) . $sep;
173
            push(@row, _surround($order->{'ecost'}));
191
            print _surround($order->{'total_rrp'}) . $sep;
174
            push(@row, _surround($order->{'quantity'}));
192
            print _surround($order->{'total_ecost'}) . $sep;
175
            push(@row, _surround($order->{'total_rrp'}));
193
            print _surround($order->{'entrydate'}) . $sep;
176
            push(@row, _surround($order->{'total_ecost'}));
194
            print _surround($order->{'datereceived'}) . $sep;
177
            push(@row, _surround($order->{'entrydate'}));
195
            print _surround($order->{'notes'}) . "\n";
178
            push(@row, _surround($order->{'datereceived'}));
179
            push(@row, _surround($order->{'notes'}));
180
            push(@rows, \@row);
196
        }
181
        }
197
182
198
        print '"TOTAL"'. ($sep x 8);
183
        my @totalrow;
199
        print _surround($total_quantity) . $sep;
184
        for(1..9){push(@totalrow, "")};
200
        print _surround($total_rrp) . $sep;
185
        push(@totalrow, _surround($total_quantity));
201
        print _surround($total_ecost);
186
        push(@totalrow, _surround($total_rrp));
187
        push(@totalrow, _surround($total_ecost));
188
189
        my $csvTemplate = C4::Templates::gettemplate('reports/csv/orders_by_budget.tt', 'intranet', $query);
190
        $csvTemplate->param(sep => $sep, rows => \@rows, totalrow => \@totalrow);
191
        print $csvTemplate->output;
202
192
203
        exit(0);
193
        exit(0);
204
    }
194
    }
205
}
195
}
206
else {
196
else {
207
    # Set file export choices
197
    # Set file export choices
208
    my $CGIextChoice = CGI::scrolling_list(
198
    my @outputFormats = ('CSV');
209
        -name     => 'MIME',
199
    my @CSVdelimiters = qw(; tabulation , \\ / #);
210
        -id       => 'MIME',
211
        -values   => ['CSV'], # FIXME translation
212
        -size     => 1,
213
        -multiple => 0
214
    );
215
216
    my $CGIsepChoice = GetDelimiterChoices;
217
200
218
    # getting all budgets
201
    # getting all budgets
219
    # active budgets
202
    # active budgets
220
    my @active_budgets = C4::Budgets::GetActiveBudgets(1);
203
    my @active_budgets = C4::Budgets::GetBudgetsByActivity(1);
221
    # non active budgets
204
    # non active budgets
222
    my @non_active_budgets = C4::Budgets::GetActiveBudgets(0);
205
    my @non_active_budgets = C4::Budgets::GetBudgetsByActivity(0);
223
    my @budgetsloop;
206
    my @budgetsloop;
224
    foreach my $thisbudget ( sort {$a->{budget_name} cmp $b->{budget_name}} @active_budgets ) {
207
    foreach my $thisbudget ( sort {$a->{budget_name} cmp $b->{budget_name}} @active_budgets ) {
225
        my $budget_period_desc = C4::Budgets::GetBudgetPeriodDescription($thisbudget->{budget_id});
208
        my $budget_period_desc = C4::Budgets::GetBudgetPeriodDescription($thisbudget->{budget_id});
Lines 241-248 else { Link Here
241
    }
224
    }
242
225
243
    $template->param(   budgetsloop   => \@budgetsloop,
226
    $template->param(   budgetsloop   => \@budgetsloop,
244
        CGIextChoice => $CGIextChoice,
227
        outputFormatloop => \@outputFormats,
245
        CGIsepChoice => $CGIsepChoice,
228
        delimiterloop => \@CSVdelimiters
246
    );
229
    );
247
}
230
}
248
231
(-)a/t/db_dependent/Acquisition.t (-4 / +4 lines)
Lines 940-949 my @report = GetBudgetReport($budget->{budget_id}); Link Here
940
ok(@report == 3, "GetBudgetReport OK");
940
ok(@report == 3, "GetBudgetReport OK");
941
941
942
my $all_count = scalar GetBudgetsReport();
942
my $all_count = scalar GetBudgetsReport();
943
ok($all_count >= 3, "GetBudgetsReport OK");
943
ok($all_count >= 3, "GetBudgetReport OK");
944
944
945
my $active_count = scalar GetActiveBudgetsReport();
945
my $active_count = scalar GetBudgetsReport(1);
946
ok($active_count >= 3, "GetActiveBudgetsReport OK");
946
ok($active_count >= 3, "GetBudgetsReport(1) OK");
947
947
948
# Deactivate budget period
948
# Deactivate budget period
949
my $budgetperiod=GetBudgetPeriod($bpid);
949
my $budgetperiod=GetBudgetPeriod($bpid);
Lines 951-956 $$budgetperiod{budget_period_active}=0; Link Here
951
ModBudgetPeriod($budgetperiod);
951
ModBudgetPeriod($budgetperiod);
952
952
953
ok($all_count == scalar GetBudgetsReport(), "GetBudgetReport returns inactive budget period acquisitions.");
953
ok($all_count == scalar GetBudgetsReport(), "GetBudgetReport returns inactive budget period acquisitions.");
954
ok($active_count >= scalar GetActiveBudgetsReport(), "GetBudgetReport doesn't return inactive budget period acquisitions.");
954
ok($active_count >= scalar GetBudgetsReport(1), "GetBudgetReport doesn't return inactive budget period acquisitions.");
955
955
956
$dbh->rollback;
956
$dbh->rollback;
(-)a/t/db_dependent/Budgets.t (-3 / +2 lines)
Lines 492-498 ok($budgets->[0]->{budget_name} lt $budgets->[1]->{budget_name}, 'default sort o Link Here
492
ok(GetBudgetPeriodDescription($budget_id)->{budget_period_description} eq "MAPERI",
492
ok(GetBudgetPeriodDescription($budget_id)->{budget_period_description} eq "MAPERI",
493
    "GetBudgetPeriodDescription OK");
493
    "GetBudgetPeriodDescription OK");
494
494
495
ok(GetActiveBudgets(1) > 0,
495
ok(GetBudgetsByActivity(1) > 0,
496
    "GetActiveBudgets can return active budgets");
496
    "GetActiveBudgets can return active budgets");
497
497
498
# Deactivate budget period
498
# Deactivate budget period
Lines 500-506 $budgetperiod=GetBudgetPeriod($bpid); Link Here
500
$$budgetperiod{budget_period_active}=0;
500
$$budgetperiod{budget_period_active}=0;
501
ModBudgetPeriod($budgetperiod);
501
ModBudgetPeriod($budgetperiod);
502
502
503
ok(GetActiveBudgets(0) > 0,
503
ok(GetBudgetsByActivity(0) > 0,
504
    "GetActiveBudgets can return inactive budgets");
504
    "GetActiveBudgets can return inactive budgets");
505
my $del_status;
505
my $del_status;
506
ok($del_status=DelBudget($budget_id),
506
ok($del_status=DelBudget($budget_id),
507
- 

Return to bug 11371