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

(-)a/acqui/orderreceive.pl (-12 / +17 lines)
Lines 170-190 if ( $suggestion ) { Link Here
170
}
170
}
171
171
172
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
172
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
173
my $budget_loop = [];
173
my %budget_loops;
174
my $budgets = GetBudgetHierarchy( undef, undef, undef, 1 );
174
my $budgets = GetBudgetHierarchy( undef, undef, undef, 1 );
175
foreach my $r (@{$budgets}) {
175
foreach my $budget (@{$budgets}) {
176
    next unless (CanUserUseBudget($patron, $r, $userflags));
176
    next unless (CanUserUseBudget($patron, $budget, $userflags));
177
    push @{$budget_loop}, {
177
    unless ( defined $budget_loops{$budget->{budget_period_id}} ){
178
        b_id  => $r->{budget_id},
178
        $budget_loops{$budget->{budget_period_id}}->{description} = $budget->{budget_period_description};
179
        b_txt => $r->{budget_name},
179
        $budget_loops{$budget->{budget_period_id}}->{active} = $budget->{budget_period_active};
180
        b_sort1_authcat => $r->{'sort1_authcat'},
180
        $budget_loops{$budget->{budget_period_id}}->{funds} = [];
181
        b_sort2_authcat => $r->{'sort2_authcat'},
181
    }
182
        b_active => $r->{budget_period_active},
182
    push @{$budget_loops{$budget->{budget_period_id}}->{funds}}, {
183
        b_sel => ( $r->{budget_id} == $order->budget_id ) ? 1 : 0,
183
        b_id  => $budget->{budget_id},
184
        b_level => $r->{budget_level},
184
        b_txt => $budget->{budget_name},
185
        b_sort1_authcat => $budget->{'sort1_authcat'},
186
        b_sort2_authcat => $budget->{'sort2_authcat'},
187
        b_active => $budget->{budget_period_active},
188
        b_sel => ( $budget->{budget_id} == $order->budget_id ) ? 1 : 0,
189
        b_level => $budget->{budget_level},
185
    };
190
    };
186
}
191
}
187
$template->{'VARS'}->{'budget_loop'} = $budget_loop;
192
$template->{'VARS'}->{'budget_loops'} = \%budget_loops;
188
193
189
my $op = $input->param('op');
194
my $op = $input->param('op');
190
if ($op and $op eq 'edit'){
195
if ($op and $op eq 'edit'){
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-24 / +31 lines)
Lines 291-323 Link Here
291
            <label class="required" for="bookfund">Fund: </label>
291
            <label class="required" for="bookfund">Fund: </label>
292
            [% active_count = 0 %]
292
            [% active_count = 0 %]
293
            [% IF !ordernumber %]
293
            [% IF !ordernumber %]
294
                [% FOREACH budget_loo IN budget_loop %]
294
                [% FOREACH budget_period IN budget_loops.keys %]
295
                    [% active_count= active_count + budget_loo.b_active %]
295
                    [% FOREACH fund IN budget_loops.$budget_period.funds %]
296
                        [% active_count= active_count + fund.b_active %]
297
                    [% END %]
296
                [% END %]
298
                [% END %]
297
            [% END %]
299
            [% END %]
298
            <select class="select2" id="bookfund" name="bookfund">
300
            <select class="select2" id="bookfund" name="bookfund">
299
            [% FOREACH budget_loo IN budget_loop %]
301
            [% FOREACH budget_period_id IN budget_loops.keys %]
300
               [% level_indent_cnt = 0 %]
302
                [% SET budget_period = budget_loops.$budget_period_id %]
301
                [% level_indent = "" %]
303
                [% IF budget_period.active %]
302
                [% WHILE level_indent_cnt < budget_loo.b_level %]
304
                    <optgroup label="[% budget_period.description %]">
303
                    [% level_indent = level_indent _ " -- " %]
305
                [% ELSE %]
304
                    [% level_indent_cnt = level_indent_cnt +1 %]
306
                    <optgroup class="inactive_budget" label="[% budget_period.description %] (Inactive)">
305
                [% END %]
307
                [% END %]
308
                [% FOREACH budget_loo IN budget_period.funds %]
309
                   [% level_indent_cnt = 0 %]
310
                    [% level_indent = "" %]
311
                    [% WHILE level_indent_cnt < budget_loo.b_level %]
312
                        [% level_indent = level_indent _ " -- " %]
313
                        [% level_indent_cnt = level_indent_cnt +1 %]
314
                    [% END %]
306
315
307
                [% IF ( budget_loo.b_sel ) %]
316
                    [% IF ( budget_loo.b_sel ) %]
308
                    [% active_count = 0 #select no other fund %]
317
                        [% active_count = 0 #select no other fund %]
309
                    <option value="[% budget_loo.b_id | html %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]"
318
                        <option value="[% budget_loo.b_id | html %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">
310
                    >
319
                    [% ELSIF active_count==1 && budget_loo.b_active %]
311
                [% ELSIF active_count==1 && budget_loo.b_active %]
320
                        <option value="[% budget_loo.b_id | html %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">
312
                    <option value="[% budget_loo.b_id | html %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]"
321
                    [% ELSE %]
313
                    >
322
                        [% bdgclass=budget_loo.b_active? "": "inactive_budget" | html %]
314
                [% ELSE %]
323
                        <option value="[% budget_loo.b_id | html %]" class="[% bdgclass | html %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">
315
                    [% bdgclass=budget_loo.b_active? "": "b_inactive" | html %]
324
                    [% END %]
316
                    <option value="[% budget_loo.b_id | html %]" class="[% bdgclass | html %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]"
325
                        [% level_indent | html %][% budget_loo.b_txt | html %][% IF !budget_loo.b_active %] (inactive)[% END %]
317
                    >
326
                    </option>
318
                [% END %]
327
                [% END %]
319
                    [% level_indent | html %][% budget_loo.b_txt | html %][% IF !budget_loo.b_active %] (inactive)[% END %]
328
                </optgroup>
320
                </option>
321
            [% END %]
329
            [% END %]
322
            </select>
330
            </select>
323
            <span class="required">Required</span>
331
            <span class="required">Required</span>
Lines 555-568 Link Here
555
563
556
            //keep a copy of all budgets before removing the inactives
564
            //keep a copy of all budgets before removing the inactives
557
            disabledBudgetsCopy = $('#bookfund').html();
565
            disabledBudgetsCopy = $('#bookfund').html();
558
            $('#bookfund .b_inactive').remove();
566
            $('#bookfund .inactive_budget').remove();
559
567
560
            $('#showallbudgets').click(function() {
568
            $('#showallbudgets').click(function() {
561
                if ($(this).is(":checked")) {
569
                if ($(this).is(":checked")) {
562
                    $('#bookfund').html(disabledBudgetsCopy); //Puts back all the funds
570
                    $('#bookfund').html(disabledBudgetsCopy); //Puts back all the funds
563
                }
571
                }
564
                else {
572
                else {
565
                    $('#bookfund .b_inactive').remove();
573
                    $('#bookfund .inactive_budget').remove();
566
                }
574
                }
567
            });
575
            });
568
576
569
- 

Return to bug 31459