Fixing a bug where a cgi object wasnt being passed, in the reports dictionary
[koha_fer] / reports / catalogue_stats.pl
index 16e3b50..3ac0216 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 
-# $Id$
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -26,7 +25,6 @@ use C4::Context;
 use C4::Branch; # GetBranches
 use C4::Output;
 use C4::Koha;
-use C4::Interface::CGI::Output;
 use C4::Circulation;
 
 =head1 NAME
@@ -35,8 +33,7 @@ plugin that shows a stats on borrowers
 
 =head1 DESCRIPTION
 
-
-=over2
+=over 2
 
 =cut
 
@@ -174,7 +171,7 @@ if ($do_it) {
 #      warn "highlightLOC ".$hglghtLOC;
        
        
-       $req = $dbh->prepare("select distinctrow itemtype from biblioitems order by itemtype");
+       $req = $dbh->prepare("select itemtype from itemtypes order by itemtype");
        $req->execute;
        undef @select;
        push @select,"";
@@ -216,12 +213,15 @@ if ($do_it) {
                                -size     => 1,
                                -multiple => 0 );
        
-       $req = $dbh->prepare("select distinctrow holdingbranch from items order by holdingbranch");
+       $req = $dbh->prepare("select distinctrow location from items order by location");
        $req->execute;
        undef @select;
        push @select,"";
+       while (my ($value) =$req->fetchrow) {
+               push @select, $value;
+       }
        my $CGIlocation=CGI::scrolling_list( -name     => 'Filter',
-                               -id => 'holdingbranch',
+                               -id => 'location',
                                -values   => \@select,
                                -size     => 1,
                                -multiple => 0 );
@@ -332,8 +332,8 @@ sub calculate {
        $linefilter[0] = @$filters[7] if ($line =~ /publishercode/ ) ;
        $linefilter[0] = @$filters[8] if ($line =~ /publicationyear/ ) ;
        $linefilter[1] = @$filters[9] if ($line =~ /publicationyear/ ) ;
-       @linefilter[0] = @$filters[10] if ($line =~ /items.homebranch/ ) ;
-       @linefilter[0] = @$filters[11] if ($line =~ /items.holdingbranch/ ) ;
+       $linefilter[0] = @$filters[10] if ($line =~ /items.homebranch/ ) ;
+       $linefilter[0] = @$filters[11] if ($line =~ /items.location/ ) ;
 # 
        my @colfilter ;
        $colfilter[0] = @$filters[0] if ($column =~ /dewey/ )  ;
@@ -346,8 +346,8 @@ sub calculate {
        $colfilter[0] = @$filters[7] if ($column =~ /publishercode/ ) ;
        $colfilter[0] = @$filters[8] if ($column =~ /publicationyear/ ) ;
        $colfilter[1] = @$filters[9] if ($column =~ /publicationyear/ ) ;
-       @colfilter[0] = @$filters[10] if ($column =~ /items.homebranch/ ) ;
-       @colfilter[0] = @$filters[11] if ($column =~ /items.holdingbranch/ ) ;
+       $colfilter[0] = @$filters[10] if ($column =~ /items.homebranch/ ) ;
+       $colfilter[0] = @$filters[11] if ($column =~ /items.location/ ) ;
 
 # 1st, loop rows.
        my $linefield;
@@ -506,7 +506,7 @@ sub calculate {
        }
        if (@$filters[11]){
                @$filters[11]=~ s/\*/%/g;
-               $strcalc .= " AND items.holdingbranch like '" . @$filters[11] ."'" if ( @$filters[11] );
+               $strcalc .= " AND items.location like '" . @$filters[11] ."'" if ( @$filters[11] );
        }
        
        $strcalc .= " group by $linefield, $colfield order by $linefield,$colfield";