- $req = $dbh->prepare( "select categorycode, description from categories order by description");
- $req->execute;
- my %select_catcode;
- my @select_catcode;
- push @select_catcode,"";
- $select_catcode{""} = "";
- while (my ($catcode, $description) =$req->fetchrow) {
- push @select_catcode, $catcode;
- $select_catcode{$catcode} = $description
- }
- my $CGICatCode=CGI::scrolling_list( -name => 'Filter',
- -id => 'Filter',
- -values => \@select_catcode,
- -labels => \%select_catcode,
- -size => 1,
- -multiple => 0 );
-
- my @branches;
- my @select_branch;
- my %select_branches;
- my ($count2,@branches)=branches();
- push @select_branch,"";
- $select_branches{''}='';
- for (my $i=0;$i<$count2;$i++){
- push @select_branch, $branches[$i]->{'branchcode'};#
- $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
+ $template->param( CAT_LOOP => &catcode_aref);
+ my @branchloop;
+ foreach (sort {$branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}} keys %$branches) {
+ my $line = {branchcode => $_, branchname => $branches->{$_}->{branchname} || 'UNKNOWN'};
+ $line->{selected} = 'selected' if ($selected_branch and $selected_branch eq $_);
+ push @branchloop, $line;