- #reorder the list
- @category_list = sort {$a cmp $b} @category_list;
- my $tab_list = CGI::scrolling_list(-name=>'searchfield',
- -id=>'searchfield',
- -values=> \@category_list,
- -default=>"",
- -size=>1,
- -multiple=>0,
- );
- if (!$searchfield) {
- $searchfield=$category_list[0];
- }
- my ($results) = AuthorizedValuesForCategory($searchfield);
- my $count = scalar(@$results);
- my @loop_data = ();
- # builds value list
- my $dbh = C4::Context->dbh;
- $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 = ?");
- for (my $i=0; $i < $count; $i++){
- $sth->execute( $results->[$i]{id} );
- my @selected_branches;
- while ( my $branch = $sth->fetchrow_hashref ) {
- push @selected_branches, $branch;
- }
- my %row_data; # get a fresh hash for the row data
- $row_data{category} = $results->[$i]{'category'};
- $row_data{authorised_value} = $results->[$i]{'authorised_value'};
- $row_data{lib} = $results->[$i]{'lib'};
- $row_data{lib_opac} = $results->[$i]{'lib_opac'};
- $row_data{imageurl} = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} );
- $row_data{edit} = "$script_name?op=add_form&id=".$results->[$i]{'id'}."&offset=$offset";
- $row_data{delete} = "$script_name?op=delete_confirm&searchfield=$searchfield&id=".$results->[$i]{'id'}."&offset=$offset";
- $row_data{branches} = \@selected_branches;
- push(@loop_data, \%row_data);
- }