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

(-)a/C4/Budgets.pm (-74 / +19 lines)
Lines 50-59 BEGIN { Link Here
50
        &AddBudgetPeriod
50
        &AddBudgetPeriod
51
	    &DelBudgetPeriod
51
	    &DelBudgetPeriod
52
52
53
	    &GetBudgetPeriodsDropbox
54
        &GetBudgetSortDropbox
55
        &GetAuthvalueDropbox
53
        &GetAuthvalueDropbox
56
        &GetBudgetPermDropbox
57
54
58
        &ModBudgetPlan
55
        &ModBudgetPlan
59
56
Lines 335-358 sub GetBudgetOrdered { Link Here
335
}
332
}
336
333
337
# -------------------------------------------------------------------
334
# -------------------------------------------------------------------
338
sub GetBudgetPermDropbox {
339
	my ($perm) = @_;
340
	my %labels;
341
	$labels{'0'} = 'None';
342
	$labels{'1'} = 'Owner';
343
	$labels{'2'} = 'Library';
344
	my $radio = CGI::scrolling_list(
345
		-id       => 'budget_permission',
346
		-name      => 'budget_permission',
347
		-values    => [ '0', '1', '2' ],
348
		-default   => $perm,
349
		-labels    => \%labels,
350
		-size    => 1,
351
	);
352
	return $radio;
353
}
354
355
# -------------------------------------------------------------------
356
sub GetBudgetAuthCats  {
335
sub GetBudgetAuthCats  {
357
    my ($budget_period_id) = shift;
336
    my ($budget_period_id) = shift;
358
    # now, populate the auth_cats_loop used in the budget planning button
337
    # now, populate the auth_cats_loop used in the budget planning button
Lines 374-434 sub GetBudgetAuthCats { Link Here
374
353
375
# -------------------------------------------------------------------
354
# -------------------------------------------------------------------
376
sub GetAuthvalueDropbox {
355
sub GetAuthvalueDropbox {
377
	my ( $name, $authcat, $default ) = @_;
356
    my ( $authcat, $default ) = @_;
378
	my @authorised_values;
357
    my $dbh = C4::Context->dbh;
379
	my %authorised_lib;
358
    my $sth = $dbh->prepare(
380
	my $value;
359
        'SELECT authorised_value,lib FROM authorised_values
381
	my $dbh = C4::Context->dbh;
360
        WHERE category = ? ORDER BY lib'
382
	my $sth = $dbh->prepare(
383
		"SELECT authorised_value,lib
384
            FROM authorised_values
385
            WHERE category = ?
386
            ORDER BY  lib"
387
	);
388
	$sth->execute( $authcat );
389
390
	push @authorised_values, '';
391
	while (my ($value, $lib) = $sth->fetchrow_array) {
392
		push @authorised_values, $value;
393
		$authorised_lib{$value} = $lib;
394
	}
395
396
    return 0 if keys(%authorised_lib) == 0;
397
398
    my $budget_authvalue_dropbox = CGI::scrolling_list(
399
        -values   => \@authorised_values,
400
        -labels   => \%authorised_lib,
401
        -default  => $default,
402
        -override => 1,
403
        -size     => 1,
404
        -multiple => 0,
405
        -name     => $name,
406
        -id       => $name,
407
    );
361
    );
362
    $sth->execute( $authcat );
363
    my $option_list = [];
364
    my @authorised_values = ( q{} );
365
    while (my ($value, $lib) = $sth->fetchrow_array) {
366
        push @{$option_list}, {
367
            value => $value,
368
            label => $lib,
369
            default => ($default eq $value),
370
        };
371
    }
408
372
409
    return $budget_authvalue_dropbox
373
    if ( @{$option_list} ) {
410
}
374
        return $option_list;
411
375
    }
412
# -------------------------------------------------------------------
376
    return;
413
sub GetBudgetPeriodsDropbox {
414
    my ($budget_period_id) = @_;
415
	my %labels;
416
	my @values;
417
	my ($active, $periods) = GetBudgetPeriods();
418
	foreach my $r (@$periods) {
419
		$labels{"$r->{budget_period_id}"} = $r->{budget_period_description};
420
		push @values, $r->{budget_period_id};
421
	}
422
423
	# if no buget_id is passed then its an add
424
	my $budget_period_dropbox = CGI::scrolling_list(
425
		-name    => 'budget_period_id',
426
		-values  => \@values,
427
		-default => $budget_period_id ? $budget_period_id :  $active,
428
		-size    => 1,
429
		-labels  => \%labels,
430
	);
431
	return $budget_period_dropbox;
432
}
377
}
433
378
434
# -------------------------------------------------------------------
379
# -------------------------------------------------------------------
(-)a/acqui/addorderiso2709.pl (-6 / +6 lines)
Lines 281-292 $template->param( budget_loop => $budget_loop,); Link Here
281
my $CGIsort1;
281
my $CGIsort1;
282
if ($budget) {    # its a mod ..
282
if ($budget) {    # its a mod ..
283
    if ( defined $budget->{'sort1_authcat'} ) {    # with custom  Asort* planning values
283
    if ( defined $budget->{'sort1_authcat'} ) {    # with custom  Asort* planning values
284
        $CGIsort1 = GetAuthvalueDropbox( 'sort1', $budget->{'sort1_authcat'}, $data->{'sort1'} );
284
        $CGIsort1 = GetAuthvalueDropbox(  $budget->{'sort1_authcat'}, $data->{'sort1'} );
285
    }
285
    }
286
} elsif ( scalar(@$budgets) ) {
286
} elsif ( scalar(@$budgets) ) {
287
    $CGIsort1 = GetAuthvalueDropbox( 'sort1', @$budgets[0]->{'sort1_authcat'}, '' );
287
    $CGIsort1 = GetAuthvalueDropbox(  @$budgets[0]->{'sort1_authcat'}, '' );
288
} else {
288
} else {
289
    $CGIsort1 = GetAuthvalueDropbox( 'sort1', '', '' );
289
    $CGIsort1 = GetAuthvalueDropbox(  '', '' );
290
}
290
}
291
291
292
# if CGIsort is successfully fetched, the use it
292
# if CGIsort is successfully fetched, the use it
Lines 300-311 if ($CGIsort1) { Link Here
300
my $CGIsort2;
300
my $CGIsort2;
301
if ($budget) {
301
if ($budget) {
302
    if ( defined $budget->{'sort2_authcat'} ) {
302
    if ( defined $budget->{'sort2_authcat'} ) {
303
        $CGIsort2 = GetAuthvalueDropbox( 'sort2', $budget->{'sort2_authcat'}, $data->{'sort2'} );
303
        $CGIsort2 = GetAuthvalueDropbox(  $budget->{'sort2_authcat'}, $data->{'sort2'} );
304
    }
304
    }
305
} elsif ( scalar(@$budgets) ) {
305
} elsif ( scalar(@$budgets) ) {
306
    $CGIsort2 = GetAuthvalueDropbox( 'sort2', @$budgets[0]->{sort2_authcat}, '' );
306
    $CGIsort2 = GetAuthvalueDropbox(  @$budgets[0]->{sort2_authcat}, '' );
307
} else {
307
} else {
308
    $CGIsort2 = GetAuthvalueDropbox( 'sort2', '', '' );
308
    $CGIsort2 = GetAuthvalueDropbox( '', '' );
309
}
309
}
310
310
311
if ($CGIsort2) {
311
if ($CGIsort2) {
(-)a/acqui/fetch_sort_dropbox.pl (-65 lines)
Lines 1-65 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2008-2009 BibLibre SARL
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
#use warnings; FIXME - Bug 2505
22
use CGI;
23
use C4::Context;
24
use C4::Output;
25
use C4::Auth;
26
use C4::Budgets;
27
28
=head1 NAME
29
30
fetch_sort_dropbox
31
32
=cut
33
34
my $input = new CGI;
35
36
my $budget_id = $input->param('budget_id');
37
my $sort_id   = $input->param('sort');
38
39
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
40
    {   template_name   => "acqui/ajax.tmpl", # FIXME: REMOVE TMPL DEP?
41
        query           => $input,
42
        type            => "intranet",
43
        authnotrequired => 0,
44
        flagsrequired => {editcatalogue => 'edit_catalogue'},
45
        debug => 0,
46
    }
47
);
48
49
my $sort_dropbox;
50
my $budget = GetBudget($budget_id);
51
52
if ( $sort_id == 1 ) {
53
    $sort_dropbox = GetAuthvalueDropbox( 'sort1', $budget->{'sort1_authcat'}, '' );
54
} elsif ( $sort_id == 2 ) {
55
    $sort_dropbox = GetAuthvalueDropbox( 'sort2', $budget->{'sort2_authcat'}, '' );
56
}
57
58
#strip off select tags ;/
59
$sort_dropbox =~ s/^\<select.*?\"\>//;
60
$sort_dropbox =~ s/\<\/select\>$//;
61
chomp $sort_dropbox;
62
63
$template->param( return => $sort_dropbox );
64
output_html_with_http_headers $input, $cookie, $template->output;
65
1;
(-)a/acqui/neworderempty.pl (-8 / +8 lines)
Lines 283-294 if ($close) { Link Here
283
my $CGIsort1;
283
my $CGIsort1;
284
if ($budget) {    # its a mod ..
284
if ($budget) {    # its a mod ..
285
    if ( defined $budget->{'sort1_authcat'} ) {    # with custom  Asort* planning values
285
    if ( defined $budget->{'sort1_authcat'} ) {    # with custom  Asort* planning values
286
        $CGIsort1 = GetAuthvalueDropbox( 'sort1', $budget->{'sort1_authcat'}, $data->{'sort1'} );
286
        $CGIsort1 = GetAuthvalueDropbox( $budget->{'sort1_authcat'}, $data->{'sort1'} );
287
    }
287
    }
288
} elsif(scalar(@$budgets)){
288
} elsif(@{$budgets}){
289
    $CGIsort1 = GetAuthvalueDropbox( 'sort1', @$budgets[0]->{'sort1_authcat'}, '' );
289
    $CGIsort1 = GetAuthvalueDropbox(  @$budgets[0]->{'sort1_authcat'}, '' );
290
}else{
290
}else{
291
    $CGIsort1 = GetAuthvalueDropbox( 'sort1','', '' );
291
    $CGIsort1 = GetAuthvalueDropbox( '', '' );
292
}
292
}
293
293
294
# if CGIsort is successfully fetched, the use it
294
# if CGIsort is successfully fetched, the use it
Lines 302-313 if ($CGIsort1) { Link Here
302
my $CGIsort2;
302
my $CGIsort2;
303
if ($budget) {
303
if ($budget) {
304
    if ( defined $budget->{'sort2_authcat'} ) {
304
    if ( defined $budget->{'sort2_authcat'} ) {
305
        $CGIsort2 = GetAuthvalueDropbox( 'sort2', $budget->{'sort2_authcat'}, $data->{'sort2'} );
305
        $CGIsort2 = GetAuthvalueDropbox(  $budget->{'sort2_authcat'}, $data->{'sort2'} );
306
    }
306
    }
307
} elsif(scalar(@$budgets)) {
307
} elsif(@{$budgets}) {
308
    $CGIsort2 = GetAuthvalueDropbox( 'sort2', @$budgets[0]->{sort2_authcat}, '' );
308
    $CGIsort2 = GetAuthvalueDropbox(  @$budgets[0]->{sort2_authcat}, '' );
309
}else{
309
}else{
310
    $CGIsort2 = GetAuthvalueDropbox( 'sort2','', '' );
310
    $CGIsort2 = GetAuthvalueDropbox( '', '' );
311
}
311
}
312
312
313
if ($CGIsort2) {
313
if ($CGIsort2) {
(-)a/admin/aqbudgetperiods.pl (-2 lines)
Lines 188-197 elsif ( $op eq 'delete_confirmed' ) { Link Here
188
        $budgetperiod->{budget_active} = 1;
188
        $budgetperiod->{budget_active} = 1;
189
        push( @period_loop, $budgetperiod );
189
        push( @period_loop, $budgetperiod );
190
    }
190
    }
191
    my $budget_period_dropbox = GetBudgetPeriodsDropbox();
192
191
193
    $template->param(
192
    $template->param(
194
        budget_period_dropbox => $budget_period_dropbox,
195
        period_loop           => \@period_loop,
193
        period_loop           => \@period_loop,
196
		pagination_bar		  => pagination_bar("aqbudgetperiods.pl",getnbpages(scalar(@$results),$pagesize),$page),
194
		pagination_bar		  => pagination_bar("aqbudgetperiods.pl",getnbpages(scalar(@$results),$pagesize),$page),
197
    );
195
    );
(-)a/admin/aqbudgets.pl (-3 lines)
Lines 73-79 my $script_name = "/cgi-bin/koha/admin/aqbudgets.pl"; Link Here
73
my $budget_hash               = $input->Vars;
73
my $budget_hash               = $input->Vars;
74
my $budget_id                 = $$budget_hash{budget_id};
74
my $budget_id                 = $$budget_hash{budget_id};
75
my $budget_permission         = $input->param('budget_permission');
75
my $budget_permission         = $input->param('budget_permission');
76
my $budget_period_dropbox     = $input->param('budget_period_dropbox');
77
my $filter_budgetbranch       = $input->param('filter_budgetbranch');
76
my $filter_budgetbranch       = $input->param('filter_budgetbranch');
78
#filtering non budget keys
77
#filtering non budget keys
79
delete $$budget_hash{$_} foreach grep {/filter|^op$|show/} keys %$budget_hash;
78
delete $$budget_hash{$_} foreach grep {/filter|^op$|show/} keys %$budget_hash;
Lines 225-233 if ($op eq 'add_form') { Link Here
225
        }
224
        }
226
    }
225
    }
227
    my $branches = GetBranches();
226
    my $branches = GetBranches();
228
    my $budget_period_dropbox = GetBudgetPeriodsDropbox($$period{budget_period_id} );
229
    $template->param(
227
    $template->param(
230
        budget_period_dropbox     => $budget_period_dropbox,
231
        budget_id                 => $budget_id,
228
        budget_id                 => $budget_id,
232
        %$period,
229
        %$period,
233
    );
230
    );
(-)a/admin/aqplan.pl (-2 lines)
Lines 74-87 my $budget_period_startdate = $period->{'budget_period_startdate'}; Link Here
74
my $budget_period_enddate     = $period->{'budget_period_enddate'};
74
my $budget_period_enddate     = $period->{'budget_period_enddate'};
75
my $budget_period_locked      = $period->{'budget_period_locked'};
75
my $budget_period_locked      = $period->{'budget_period_locked'};
76
my $budget_period_description = $period->{'budget_period_description'};
76
my $budget_period_description = $period->{'budget_period_description'};
77
my $budget_period_dropbox     = GetBudgetPeriodsDropbox($budget_period_id );
78
77
79
78
80
$template->param(
79
$template->param(
81
    budget_period_id          => $budget_period_id,
80
    budget_period_id          => $budget_period_id,
82
    budget_period_locked      => $budget_period_locked,
81
    budget_period_locked      => $budget_period_locked,
83
    budget_period_description => $budget_period_description,
82
    budget_period_description => $budget_period_description,
84
    budget_period_dropbox     => $budget_period_dropbox,
85
    auth_cats_loop            => $auth_cats_loop,
83
    auth_cats_loop            => $auth_cats_loop,
86
);
84
);
87
85
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt (-7 / +22 lines)
Lines 184-204 Link Here
184
                        <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
184
                        <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
185
                            <label for="sort1">Planning value1: </label>
185
                            <label for="sort1">Planning value1: </label>
186
186
187
                            [% IF ( CGIsort1 ) %]
187
                            [% IF CGIsort1 %]
188
                                [% CGIsort1 %]
188
                                <select id="sort1" size="1" name="sort1">
189
                                [% FOREACH sort_opt IN CGIsort1 %]
190
                                    [% IF sort_opt.default %]
191
                                        <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
192
                                    [% ELSE %]
193
                                        <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
194
                                    [% END %]
195
                                [% END %]
196
                                </select>
189
                            [% ELSE %]
197
                            [% ELSE %]
190
191
                                <input type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
198
                                <input type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
192
                            [% END %]
199
                            [% END %]
193
                        </li>
200
                        </li>
194
                        <li>
201
                        <li>
195
                            <label for="sort2">Planning value2: </label>
202
                            <label for="sort2">Planning value2: </label>
196
203
197
                            [% IF ( CGIsort2 ) %]
204
                        [% IF CGIsort2 %]
198
                                [% CGIsort2 %]
205
                            <select id="sort2" size="1" name="sort1">
199
                            [% ELSE %]
206
                            [% FOREACH sort_opt IN CGIsort2 %]
200
                                <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
207
                                [% IF sort_opt.default %]
208
                                    <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
209
                                [% ELSE %]
210
                                    <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
211
                                [% END %]
201
                            [% END %]
212
                            [% END %]
213
                            </select>
214
                        [% ELSE %]
215
                             <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
216
                        [% END %]
202
                        </li>
217
                        </li>
203
                        <li>
218
                        <li>
204
                            
219
                            
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-5 / +20 lines)
Lines 429-436 $(document).ready(function() Link Here
429
            <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
429
            <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
430
                <label for="sort1">Statistic 1: </label>
430
                <label for="sort1">Statistic 1: </label>
431
431
432
                [% IF ( CGIsort1 ) %]
432
                [% IF CGIsort1 %]
433
                    [% CGIsort1 %]
433
                    <select id="sort1" size="1" name="sort1">
434
                    [% FOREACH sort_opt IN CGIsort1 %]
435
                       [% IF sort_opt.default %]
436
                          <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
437
                        [% ELSE %]
438
                          <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
439
                        [% END %]
440
                    [% END %]
441
                    </select>
434
                [% ELSE %]
442
                [% ELSE %]
435
443
436
                    <input type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
444
                    <input type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
Lines 439-446 $(document).ready(function() Link Here
439
            <li>
447
            <li>
440
                <label for="sort2">Statistic 2: </label>
448
                <label for="sort2">Statistic 2: </label>
441
449
442
                [% IF ( CGIsort2 ) %]
450
                [% IF CGIsort2 %]
443
                    [% CGIsort2 %]
451
                    <select id="sort2" size="1" name="sort1">
452
                    [% FOREACH sort_opt IN CGIsort2 %]
453
                       [% IF sort_opt.default %]
454
                          <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
455
                        [% ELSE %]
456
                          <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
457
                        [% END %]
458
                    [% END %]
459
                    </select>
444
                [% ELSE %]
460
                [% ELSE %]
445
                    <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
461
                    <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
446
                [% END %]
462
                [% END %]
447
- 

Return to bug 6181