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

(-)a/acqui/orderreceive.pl (-12 / +18 lines)
Lines 170-191 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
194
warn Data::Dumper::Dumper( \%budget_loops );
189
my $op = $input->param('op');
195
my $op = $input->param('op');
190
if ($op and $op eq 'edit'){
196
if ($op and $op eq 'edit'){
191
    $template->param(edit   =>   1);
197
    $template->param(edit   =>   1);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-24 / +31 lines)
Lines 288-320 Link Here
288
            <label class="required" for="bookfund">Fund: </label>
288
            <label class="required" for="bookfund">Fund: </label>
289
            [% active_count = 0 %]
289
            [% active_count = 0 %]
290
            [% IF !ordernumber %]
290
            [% IF !ordernumber %]
291
                [% FOREACH budget_loo IN budget_loop %]
291
                [% FOREACH budget_period IN budget_loops.keys %]
292
                    [% active_count= active_count + budget_loo.b_active %]
292
                    [% FOREACH fund IN budget_loops.$budget_period.funds %]
293
                        [% active_count= active_count + fund.b_active %]
294
                    [% END %]
293
                [% END %]
295
                [% END %]
294
            [% END %]
296
            [% END %]
295
            <select class="select2" id="bookfund" name="bookfund">
297
            <select class="select2" id="bookfund" name="bookfund">
296
            [% FOREACH budget_loo IN budget_loop %]
298
            [% FOREACH budget_period_id IN budget_loops.keys %]
297
               [% level_indent_cnt = 0 %]
299
                [% SET budget_period = budget_loops.$budget_period_id %]
298
                [% level_indent = "" %]
300
                [% IF budget_period.active %]
299
                [% WHILE level_indent_cnt < budget_loo.b_level %]
301
                    <optgroup label="[% budget_period.description %]">
300
                    [% level_indent = level_indent _ " -- " %]
302
                [% ELSE %]
301
                    [% level_indent_cnt = level_indent_cnt +1 %]
303
                    <optgroup class="inactive_budget" label="[% budget_period.description %] (Inactive)">
302
                [% END %]
304
                [% END %]
305
                [% FOREACH budget_loo IN budget_period.funds %]
306
                   [% level_indent_cnt = 0 %]
307
                    [% level_indent = "" %]
308
                    [% WHILE level_indent_cnt < budget_loo.b_level %]
309
                        [% level_indent = level_indent _ " -- " %]
310
                        [% level_indent_cnt = level_indent_cnt +1 %]
311
                    [% END %]
303
312
304
                [% IF ( budget_loo.b_sel ) %]
313
                    [% IF ( budget_loo.b_sel ) %]
305
                    [% active_count = 0 #select no other fund %]
314
                        [% active_count = 0 #select no other fund %]
306
                    <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 %]"
315
                        <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 %]">
307
                    >
316
                    [% ELSIF active_count==1 && budget_loo.b_active %]
308
                [% ELSIF active_count==1 && budget_loo.b_active %]
317
                        <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 %]">
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
                    [% ELSE %]
310
                    >
319
                        [% bdgclass=budget_loo.b_active? "": "inactive_budget" | html %]
311
                [% ELSE %]
320
                        <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 %]">
312
                    [% bdgclass=budget_loo.b_active? "": "b_inactive" | html %]
321
                    [% END %]
313
                    <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 %]"
322
                        [% level_indent | html %][% budget_loo.b_txt | html %][% IF !budget_loo.b_active %] (inactive)[% END %]
314
                    >
323
                    </option>
315
                [% END %]
324
                [% END %]
316
                    [% level_indent | html %][% budget_loo.b_txt | html %][% IF !budget_loo.b_active %] (inactive)[% END %]
325
                </optgroup>
317
                </option>
318
            [% END %]
326
            [% END %]
319
            </select>
327
            </select>
320
            <span class="required">Required</span>
328
            <span class="required">Required</span>
Lines 552-565 Link Here
552
560
553
            //keep a copy of all budgets before removing the inactives
561
            //keep a copy of all budgets before removing the inactives
554
            disabledBudgetsCopy = $('#bookfund').html();
562
            disabledBudgetsCopy = $('#bookfund').html();
555
            $('#bookfund .b_inactive').remove();
563
            $('#bookfund .inactive_budget').remove();
556
564
557
            $('#showallbudgets').click(function() {
565
            $('#showallbudgets').click(function() {
558
                if ($(this).is(":checked")) {
566
                if ($(this).is(":checked")) {
559
                    $('#bookfund').html(disabledBudgetsCopy); //Puts back all the funds
567
                    $('#bookfund').html(disabledBudgetsCopy); //Puts back all the funds
560
                }
568
                }
561
                else {
569
                else {
562
                    $('#bookfund .b_inactive').remove();
570
                    $('#bookfund .inactive_budget').remove();
563
                }
571
                }
564
            });
572
            });
565
573
566
- 

Return to bug 31459