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

(-)a/acqui/neworderempty.pl (-14 / +27 lines)
Lines 320-340 my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; Link Here
320
my $budget =  GetBudget($budget_id);
320
my $budget =  GetBudget($budget_id);
321
# build budget list
321
# build budget list
322
my $budget_loop = [];
322
my $budget_loop = [];
323
my $budgets = GetBudgetHierarchy;
323
my $periods = GetBudgetPeriods();
324
foreach my $r (@{$budgets}) {
324
foreach my $period (@$periods) {
325
    next unless (CanUserUseBudget($patron, $r, $userflags));
325
    my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'} );
326
    if (!defined $r->{budget_amount} || $r->{budget_amount} <0) {
326
    my @funds;
327
        next;
327
    foreach my $r (@{$budget_hierarchy}) {
328
        next unless (CanUserUseBudget($patron, $r, $userflags));
329
        if (!defined $r->{budget_amount} || $r->{budget_amount} <0) {
330
            next;
331
        }
332
        push @funds, {
333
            b_id  => $r->{budget_id},
334
            b_txt => $r->{budget_name},
335
            b_sort1_authcat => $r->{'sort1_authcat'},
336
            b_sort2_authcat => $r->{'sort2_authcat'},
337
            b_active => $r->{budget_period_active},
338
            b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
339
            b_level => $r->{budget_level},
340
        };
328
    }
341
    }
329
    push @{$budget_loop}, {
342
330
        b_id  => $r->{budget_id},
343
    @funds = sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @funds;
331
        b_txt => $r->{budget_name},
344
332
        b_sort1_authcat => $r->{'sort1_authcat'},
345
    push @$budget_loop,
333
        b_sort2_authcat => $r->{'sort2_authcat'},
346
      {
334
        b_active => $r->{budget_period_active},
347
        'id'          => $period->{'budget_period_id'},
335
        b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
348
        'description' => $period->{'budget_period_description'},
336
        b_level => $r->{budget_level},
349
        'funds'       => \@funds
337
    };
350
      };
338
}
351
}
339
352
340
if ($close) {
353
if ($close) {
(-)a/acqui/parcels.pl (-15 / +24 lines)
Lines 179-201 if ($count_parcels) { Link Here
179
179
180
# build budget list
180
# build budget list
181
my $budget_loop = [];
181
my $budget_loop = [];
182
my $budgets = GetBudgetHierarchy;
182
my $periods = GetBudgetPeriods();
183
foreach my $r (@{$budgets}) {
183
foreach my $period (@$periods) {
184
    next unless (CanUserUseBudget($loggedinuser, $r, $flags));
184
    my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'} );
185
    if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
185
    my @funds;
186
        next;
186
    foreach my $r (@{$budget_hierarchy}) {
187
        next unless (CanUserUseBudget($loggedinuser, $r, $flags));
188
        if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
189
            next;
190
        }
191
        push @funds, {
192
            b_id  => $r->{budget_id},
193
            b_txt => $r->{budget_name},
194
            b_active => $r->{budget_period_active},
195
        };
187
    }
196
    }
188
    push @{$budget_loop}, {
197
    
189
        b_id  => $r->{budget_id},
198
    @funds = sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @funds;
190
        b_txt => $r->{budget_name},
199
191
        b_active => $r->{budget_period_active},
200
    push @$budget_loop,
192
    };
201
      {
202
        'id'          => $period->{'budget_period_id'},
203
        'description' => $period->{'budget_period_description'},
204
        'funds'       => \@funds
205
      };
193
}
206
}
194
207
195
@{$budget_loop} =
196
  sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop};
197
198
199
$template->param(
208
$template->param(
200
    orderby                  => $order,
209
    orderby                  => $order,
201
    filter                   => $code,
210
    filter                   => $code,
Lines 206-212 $template->param( Link Here
206
    shipmentdate_today       => dt_from_string,
215
    shipmentdate_today       => dt_from_string,
207
    booksellerid             => $booksellerid,
216
    booksellerid             => $booksellerid,
208
    GST                      => C4::Context->preference('gist'),
217
    GST                      => C4::Context->preference('gist'),
209
    budgets                  => $budget_loop,
218
    budget_loop              => $budget_loop,
210
);
219
);
211
220
212
output_html_with_http_headers $input, $cookie, $template->output;
221
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-19 / +25 lines)
Lines 327-356 Link Here
327
                <label class="required" for="budget_id">Fund: </label>
327
                <label class="required" for="budget_id">Fund: </label>
328
                [% active_count = 0 %]
328
                [% active_count = 0 %]
329
                [% IF !ordernumber %]
329
                [% IF !ordernumber %]
330
                    [% FOREACH budget_loo IN budget_loop %]
330
                    [% FOREACH period IN budget_loop %]
331
                        [% active_count= active_count + budget_loo.b_active %]
331
                        [% FOREACH fund IN period.funds %]
332
                            [% active_count= active_count + fund.b_active %]
333
                        [% END %]
332
                    [% END %]
334
                    [% END %]
333
                [% END %]
335
                [% END %]
334
                <select id="budget_id" size="1" name="budget_id">
336
                <select id="budget_id" size="1" name="budget_id">
335
                    <option value="">Select a fund</option>
337
                    <option value="">Select a fund</option>
336
                [% FOREACH budget_loo IN budget_loop %]
338
                [% FOREACH period IN budget_loop %]
337
                    [% IF ( budget_loo.b_sel ) %]
339
                    <optgroup label="[% period.description %]">
338
                        [% active_count = 0 #select no other fund %]
340
                    [% FOREACH fund IN period.funds %]
339
                        <option value="[% budget_loo.b_id %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]"
341
                        [% IF ( fund.b_sel ) %]
340
                                style="padding-left:[% budget_loo.b_level %]em;"
342
                            [% active_count = 0 #select no other fund %]
341
                        >
343
                            <option value="[% fund.b_id %]" selected="selected" data-sort1-authcat="[% fund.b_sort1_authcat %]" data-sort2-authcat="[% fund.b_sort2_authcat %]"
342
                    [% ELSIF active_count==1 && budget_loo.b_active %]
344
                                    style="padding-left:[% fund.b_level %]em;"
343
                        <option value="[% budget_loo.b_id %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]"
345
                            >
344
                                style="padding-left:[% budget_loo.b_level %]em;"
346
                        [% ELSIF active_count==1 && fund.b_active %]
345
                        >
347
                            <option value="[% fund.b_id %]" selected="selected" data-sort1-authcat="[% fund.b_sort1_authcat %]" data-sort2-authcat="[% fund.b_sort2_authcat %]"
346
                    [% ELSE %]
348
                                    style="padding-left:[% fund.b_level %]em;"
347
                        [% bdgclass=budget_loo.b_active? "": "b_inactive" %]
349
                            >
348
                        <option value="[% budget_loo.b_id %]" class="[% bdgclass %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]"
350
                        [% ELSE %]
349
                                style="padding-left:[% budget_loo.b_level %]em;"
351
                            [% bdgclass=fund.b_active? "": "b_inactive" %]
350
                        >
352
                            <option value="[% fund.b_id %]" class="[% bdgclass %]" data-sort1-authcat="[% fund.b_sort1_authcat %]" data-sort2-authcat="[% fund.b_sort2_authcat %]"
353
                                    style="padding-left:[% fund.b_level %]em;"
354
                            >
355
                        [% END %]
356
                        [% fund.b_txt %][% IF !fund.b_active %] (inactive)[% END %]
357
                        </option>
351
                    [% END %]
358
                    [% END %]
352
                    [% budget_loo.b_txt %][% IF !budget_loo.b_active %] (inactive)[% END %]
359
                    </optgroup>
353
                    </option>
354
                [% END %]
360
                [% END %]
355
                </select>
361
                </select>
356
                <span class="required">Required</span>
362
                <span class="required">Required</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt (-6 / +9 lines)
Lines 154-165 Link Here
154
            <label for="shipmentcost_budgetid">Shipping fund: </label>
154
            <label for="shipmentcost_budgetid">Shipping fund: </label>
155
            <select id="shipmentcost_budgetid" name="shipmentcost_budgetid">
155
            <select id="shipmentcost_budgetid" name="shipmentcost_budgetid">
156
                <option value="">No fund</option>
156
                <option value="">No fund</option>
157
                [% FOREACH budget IN budgets %]
157
                [% FOREACH period IN budget_loop %]
158
                    [% IF ( budget.b_active ) %]
158
                <optgroup label="[% period.description %]">
159
                        <option value="[% budget.b_id %]">[% budget.b_txt %]</option>
159
                    [% FOREACH fund IN period.funds %]
160
                    [% ELSE %]
160
                        [% IF ( fund.b_active ) %]
161
                        <option value="[% budget.b_id %]" class="b_inactive">[% budget.b_txt %] (inactive)</option>
161
                            <option value="[% fund.b_id %]">[% fund.b_txt %]</option>
162
                        [% ELSE %]
163
                            <option value="[% fund.b_id %]" class="b_inactive">[% fund.b_txt %] (inactive)</option>
164
                        [% END %]
162
                    [% END %]
165
                    [% END %]
166
                </optgroup>
163
                [% END %]
167
                [% END %]
164
            </select>
168
            </select>
165
            <label for="showallfunds" style="float:none;width:auto;">&nbsp;Show inactive:</label>
169
            <label for="showallfunds" style="float:none;width:auto;">&nbsp;Show inactive:</label>
166
- 

Return to bug 21098