installer: added (in some cases back) module deps
[koha_fer] / reports / catalogue_out.pl
index 39f0c68..5df3d42 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 
-# $Id$
 
 # Copyright 2000-2002 Katipo Communications
 #
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
-use C4::Auth;
 use CGI;
+use C4::Auth;
 use C4::Context;
-use HTML::Template;
-use C4::Search;
+use C4::Branch; # GetBranches
 use C4::Output;
 use C4::Koha;
-use C4::Interface::CGI::Output;
-use C4::Circulation::Circ2;
+use C4::Circulation;
 use Date::Manip;
 
 =head1 NAME
@@ -37,8 +34,7 @@ plugin that shows a stats on borrowers
 
 =head1 DESCRIPTION
 
-
-=over2
+=over 2
 
 =cut
 
@@ -58,13 +54,10 @@ my ($template, $borrowernumber, $cookie)
                                query => $input,
                                type => "intranet",
                                authnotrequired => 0,
-                               flagsrequired => {editcatalogue => 1},
+                               flagsrequired => {reports => 1},
                                debug => 1,
                                });
 $template->param(do_it => $do_it,
-               intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
-               intranetstylesheet => C4::Context->preference("intranetstylesheet"),
-               IntranetNav => C4::Context->preference("IntranetNav"),
                );
 if ($do_it) {
 # Displaying results
@@ -77,6 +70,7 @@ if ($do_it) {
        } else {
 # Printing to a csv file
                print $input->header(-type => 'application/vnd.sun.xml.calc',
+                                     -encoding    => 'utf-8',
                        -attachment=>"$basename.csv",
                        -filename=>"$basename.csv" );
                my $cols = @$results[0]->{loopcol};
@@ -137,7 +131,7 @@ if ($do_it) {
                                -size     => 1,
                                -multiple => 0 );
        #doctype
-       my $itemtypes = getitemtypes;
+       my $itemtypes = GetItemTypes;
        my @itemtypeloop;
        foreach my $thisitemtype (keys %$itemtypes) {
 #                      my $selected = 1 if $thisbranch eq $branch;
@@ -149,7 +143,7 @@ if ($do_it) {
        }
                
        #branch
-       my $branches = getallbranches;
+       my $branches = GetBranches;
        my @branchloop;
        foreach my $thisbranch (keys %$branches) {
 #                      my $selected = 1 if $thisbranch eq $branch;
@@ -277,20 +271,17 @@ sub calculate {
        $strcalc .= " AND biblioitems.itemtype like '" . @$filters[1] ."'" if ( @$filters[1] );
        
        $strcalc .= " group by items.itemnumber";
-       $strcalc .= ", $colfield" if ($column);
+       $strcalc .= ", $colfield"          if ($column);
        $strcalc .= " order by $colfield " if ($colfield);
-       my $max;
-       if (@loopcol) {
-               $max = $line*@loopcol;
-       } else { $max=$line;}
-       $strcalc .= " LIMIT 0,$max" if ($line);
+       my $max = (@loopcol) ? $line*@loopcol : $line ;
+       $strcalc .= " LIMIT 0,$max"        if ($line);
        warn "SQL :". $strcalc;
        
        my $dbcalc = $dbh->prepare($strcalc);
        $dbcalc->execute;
 #      warn "filling table";
        my $previous_col;
-       my $i=1;
+       $i=1;
        while (my  @data = $dbcalc->fetchrow) {
                my ($barcode,$title,$bibnum,$author, $col )=@data;
                $col = "zzEMPTY" if ($col eq undef);
@@ -306,7 +297,7 @@ sub calculate {
        
        push @loopcol,{coltitle => "Global"} if not($column);
        
-       my $max =(($line)?$line:@table);
+       $max =(($line)?$line:@table);
        for ($i=1; $i<$max;$i++) {
                my @loopcell;
                #@loopcol ensures the order for columns is common with column titles