Lines 54-93
Sort number. 1 or 2 for the moment.
Link Here
|
54 |
my $input = new CGI; |
54 |
my $input = new CGI; |
55 |
|
55 |
|
56 |
my $budget_id = $input->param('budget_id'); |
56 |
my $budget_id = $input->param('budget_id'); |
57 |
my $sort_id = $input->param('sort'); |
57 |
my $sort_nb = $input->param('sort'); |
|
|
58 |
die "sort parameter can only be 1 or 2" unless ($sort_nb == 1 || $sort_nb == 2); |
58 |
|
59 |
|
59 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
60 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
60 |
{ template_name => "acqui/ajax.tmpl", |
61 |
{ template_name => "acqui/ajax.tmpl", |
61 |
query => $input, |
62 |
query => $input, |
62 |
type => "intranet", |
63 |
type => "intranet", |
63 |
authnotrequired => 0, |
64 |
authnotrequired => 0, |
64 |
flagsrequired => {editcatalogue => 'edit_catalogue'}, |
65 |
flagsrequired => {acquisition => 'order_manage'}, |
65 |
debug => 0, |
66 |
debug => 0, |
66 |
} |
67 |
} |
67 |
); |
68 |
); |
68 |
|
69 |
|
69 |
my $budget = GetBudget($budget_id); |
70 |
my $ret_html; |
70 |
my $dropbox_values = GetAuthvalueDropbox( $budget->{'sort'.$sort_id.'_authcat'}, '' ); |
71 |
my $name = 'sort'.$sort_nb; |
|
|
72 |
my $authcat_field = 'sort'.$sort_nb.'_authcat'; |
71 |
|
73 |
|
72 |
my @authorised_values; |
74 |
my $budget = GetBudget($budget_id); |
73 |
my %authorised_lib; |
|
|
74 |
|
75 |
|
75 |
foreach ( @$dropbox_values) { |
76 |
if ( $budget && $budget->{$authcat_field} ) { |
76 |
push @authorised_values, $_->{value}; |
77 |
# with custom Asort* planning values |
77 |
$authorised_lib{$_->{value}} = $_->{label}; |
78 |
my $dropbox_values = GetAuthvalueDropbox( $budget->{$authcat_field}, '' ); |
78 |
} |
|
|
79 |
|
79 |
|
80 |
my $budget_authvalue_dropbox = CGI::scrolling_list( |
80 |
my @authorised_values; |
81 |
-values => \@authorised_values, |
81 |
my %authorised_lib; |
82 |
-labels => \%authorised_lib, |
82 |
my $default_value; |
83 |
-default => $authorised_values[0], |
|
|
84 |
); |
85 |
|
83 |
|
|
|
84 |
foreach ( @$dropbox_values) { |
85 |
push @authorised_values, $_->{value}; |
86 |
$authorised_lib{$_->{value}} = $_->{label}; |
87 |
$default_value = $_->{value} if $_->{'default'}; |
88 |
} |
86 |
|
89 |
|
87 |
# strip off select tags |
90 |
$ret_html = CGI::scrolling_list( |
88 |
$budget_authvalue_dropbox =~ s/^\<select.*?\"\>//; |
91 |
-values => \@authorised_values, |
89 |
$budget_authvalue_dropbox =~ s/\<\/select\>$//; |
92 |
-labels => \%authorised_lib, |
90 |
chomp $budget_authvalue_dropbox; |
93 |
-default => $default_value, |
|
|
94 |
-override => 1, |
95 |
-size => 1, |
96 |
-multiple => 0, |
97 |
-name => $name, |
98 |
-id => $name, |
99 |
); |
100 |
|
101 |
} else { |
102 |
# free input |
103 |
$ret_html = '<input type="text" size="20" name="'.$name.'" id="'.$name.'" />'; |
104 |
} |
91 |
|
105 |
|
92 |
$template->param( return => $budget_authvalue_dropbox ); |
106 |
$template->param( 'return' => $ret_html ); |
93 |
output_html_with_http_headers $input, $cookie, $template->output; |
107 |
output_html_with_http_headers $input, $cookie, $template->output; |