Bug 29387: Stringify exceptions for other background job modules
[koha-ffzg.git] / reports / reserves_stats.pl
index 30ab062..cb63a6e 100755 (executable)
@@ -21,20 +21,18 @@ use Modern::Perl;
 
 use CGI qw ( -utf8 );
 
-use C4::Auth;
-use C4::Debug;
+use C4::Auth qw( get_template_and_user );
 use C4::Context;
-use C4::Koha;
-use C4::Output;
-use C4::Reports;
+use C4::Koha qw( GetAuthorisedValues );
+use C4::Output qw( output_html_with_http_headers );
+use C4::Reports qw( GetDelimiterChoices );
 use C4::Members;
 use Koha::AuthorisedValues;
-use Koha::DateUtils;
+use Koha::DateUtils qw( dt_from_string output_pref );
 use Koha::ItemTypes;
 use Koha::Libraries;
 use Koha::Patron::Categories;
-use List::MoreUtils qw/any/;
-use YAML::XS;
+use List::MoreUtils qw( any );
 
 =head1 NAME
 
@@ -46,7 +44,6 @@ Plugin that shows reserve stats
 
 =cut
 
-# my $debug = 1;       # override for now.
 my $input = CGI->new;
 my $fullreportname = "reports/reserves_stats.tt";
 my $do_it    = $input->param('do_it');
@@ -67,14 +64,13 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({
        query => $input,
        type => "intranet",
        flagsrequired => {reports => '*'},
-       debug => 0,
 });
 our $sep     = $input->param("sep") || '';
 $sep = "\t" if ($sep eq 'tabulation');
 $template->param(do_it => $do_it,
 );
 
-my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
 
 my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
 my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
@@ -218,7 +214,6 @@ sub calculate {
        my @sqlorparams;
        my @sqlor;
        my @sqlwhere;
-    ($debug) and print STDERR YAML::XS::Dump($filters_hashref);
        foreach my $filter (keys %$filters_hashref){
                my $string;
                my $stringfield=$filter;
@@ -251,7 +246,6 @@ sub calculate {
        $strcalc .= " WHERE ".join(" AND ",@sqlwhere) if (@sqlwhere);
        $strcalc .= " AND (".join(" OR ",@sqlor).")" if (@sqlor);
        $strcalc .= " GROUP BY line, col )";
-       ($debug) and print STDERR $strcalc;
        my $dbcalc = $dbh->prepare($strcalc);
        push @loopfilter, {crit=>'SQL =', sql=>1, filter=>$strcalc};
        @sqlparams=(@sqlparams,@sqlorparams);
@@ -287,7 +281,6 @@ sub calculate {
                my $total = 0;
                foreach my $row (@loopline) {
                        $total += $data->{$row}{$col}{calculation} if $data->{$row}{$col}{calculation};
-                       $debug and warn "value added ".$$data{$row}{$col}{calculation}. "for line ".$row;
                }
                push @loopfooter, {'totalcol' => $total};
                push @loopcol, {'coltitle' => $col,
@@ -332,7 +325,7 @@ sub display_value {
         }
     }
     elsif ( $crit =~ /category/ ) {
-        my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+        my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
         foreach my $patron_category ( @patron_categories ) {
             ( $value eq $patron_category->categorycode ) or next;
             $display_value = $patron_category->description and last;