Lines 237-248
exit 0;
Link Here
|
237 |
|
237 |
|
238 |
sub default_form { |
238 |
sub default_form { |
239 |
# build categories list |
239 |
# build categories list |
240 |
my $sth = $dbh->prepare("select distinct category from authorised_values"); |
240 |
my $category_list = C4::Koha::GetAuthorisedValueCategories(); |
241 |
$sth->execute; |
241 |
my @category_list = @{$category_list}; |
242 |
my @category_list; |
|
|
243 |
my %categories; # a hash, to check that some hardcoded categories exist. |
242 |
my %categories; # a hash, to check that some hardcoded categories exist. |
244 |
while ( my ($category) = $sth->fetchrow_array ) { |
243 |
for my $category ( @category_list ) { |
245 |
push( @category_list, $category ); |
|
|
246 |
$categories{$category} = 1; |
244 |
$categories{$category} = 1; |
247 |
} |
245 |
} |
248 |
|
246 |
|
Lines 252-274
sub default_form {
Link Here
|
252 |
} |
250 |
} |
253 |
|
251 |
|
254 |
#reorder the list |
252 |
#reorder the list |
255 |
@category_list = sort {$a cmp $b} @category_list; |
253 |
@category_list = sort {lc($a) cmp lc($b)} @category_list; |
256 |
my $tab_list = CGI::scrolling_list(-name=>'searchfield', |
|
|
257 |
-id=>'searchfield', |
258 |
-values=> \@category_list, |
259 |
-default=>"", |
260 |
-size=>1, |
261 |
-multiple=>0, |
262 |
); |
263 |
if (!$searchfield) { |
254 |
if (!$searchfield) { |
264 |
$searchfield=$category_list[0]; |
255 |
$searchfield=$category_list[0]; |
265 |
} |
256 |
} |
|
|
257 |
my $tab_list = { |
258 |
values => \@category_list, |
259 |
default => $searchfield, |
260 |
}; |
266 |
my ($results) = AuthorizedValuesForCategory($searchfield); |
261 |
my ($results) = AuthorizedValuesForCategory($searchfield); |
267 |
my $count = scalar(@$results); |
262 |
my $count = scalar(@$results); |
268 |
my @loop_data = (); |
263 |
my @loop_data = (); |
269 |
# builds value list |
264 |
# builds value list |
270 |
my $dbh = C4::Context->dbh; |
265 |
my $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM authorised_values_branches AS avb, branches AS b WHERE avb.branchcode = b.branchcode AND avb.av_id = ?"); |
271 |
$sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM authorised_values_branches AS avb, branches AS b WHERE avb.branchcode = b.branchcode AND avb.av_id = ?"); |
|
|
272 |
for (my $i=0; $i < $count; $i++){ |
266 |
for (my $i=0; $i < $count; $i++){ |
273 |
$sth->execute( $results->[$i]{id} ); |
267 |
$sth->execute( $results->[$i]{id} ); |
274 |
my @selected_branches; |
268 |
my @selected_branches; |
Lines 287-294
sub default_form {
Link Here
|
287 |
push(@loop_data, \%row_data); |
281 |
push(@loop_data, \%row_data); |
288 |
} |
282 |
} |
289 |
|
283 |
|
290 |
$template->param( loop => \@loop_data, |
284 |
$template->param( |
291 |
tab_list => $tab_list, |
285 |
loop => \@loop_data, |
292 |
category => $searchfield ); |
286 |
tab_list => $tab_list, |
|
|
287 |
category => $searchfield, |
288 |
); |
293 |
} |
289 |
} |
294 |
|
290 |
|