3 # Copyright 2008-2009 BibLibre SARL
5 # This file is part of Koha.
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
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.
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.
34 This script fetches sort values for a given budget id. Currently it is used to dynamically fill
35 'Statistic 1' and 'Statistic 2' comboboxes in neworderempty page. Values retrieved depend on
36 categories of authorized values defined in funds configuration.
48 Sort number. 1 or 2 for the moment.
56 my $budget_id = $input->param('budget_id');
57 my $sort_nb = $input->param('sort');
58 die "sort parameter can only be 1 or 2" unless ($sort_nb == 1 || $sort_nb == 2);
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
61 { template_name
=> "acqui/ajax.tmpl",
65 flagsrequired
=> {acquisition
=> 'order_manage'},
71 my $name = 'sort'.$sort_nb;
72 my $authcat_field = 'sort'.$sort_nb.'_authcat';
74 my $budget = GetBudget
($budget_id);
76 if ( $budget && $budget->{$authcat_field} ) {
77 # with custom Asort* planning values
78 my $dropbox_values = GetAuthvalueDropbox
( $budget->{$authcat_field}, '' );
80 my @authorised_values;
84 foreach ( @
$dropbox_values) {
85 push @authorised_values, $_->{value
};
86 $authorised_lib{$_->{value
}} = $_->{label
};
87 $default_value = $_->{value
} if $_->{'default'};
90 $ret_html = CGI
::scrolling_list
(
91 -values => \
@authorised_values,
92 -labels
=> \
%authorised_lib,
93 -default => $default_value,
103 $ret_html = '<input type="text" size="20" name="'.$name.'" id="'.$name.'" />';
106 $template->param( 'return' => $ret_html );
107 output_html_with_http_headers
$input, $cookie, $template->output;