- $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 = GetBranches;
-my @branchloop;
-foreach my $thisbranch (keys %$branches) {
- # my $selected = 1 if $thisbranch eq $branch;
- my %row =(value => $thisbranch,
-# selected => $selected,
- branchname => $branches->{$thisbranch}->{'branchname'},
- );
- push @branchloop, \%row;
-}
-
- $req = $dbh->prepare( "select distinctrow sort1 from borrowers order by sort1");
- $req->execute;
- my @select_sort1;
- push @select_sort1,"";
- my $hassort1;
- while (my ($value) =$req->fetchrow) {
- if ($value) {
- $hassort1=1;
- push @select_sort1, $value;
- }
+ $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;