ffzg/recall_notices.pl: added --interval and --dedup
[koha.git] / reports / acquisitions_stats.pl
index 9bb439f..d7dea6a 100755 (executable)
@@ -26,9 +26,10 @@ use C4::Reports;
 use C4::Output;
 use C4::Koha;
 use C4::Circulation;
-use C4::Branch;
 use C4::Biblio;
+use Koha::ItemTypes;
 use Koha::DateUtils;
+use Koha::Libraries;
 
 =head1 NAME
 
@@ -45,7 +46,7 @@ my $do_it          = $input->param('do_it');
 my $fullreportname = "reports/acquisitions_stats.tt";
 my $line           = $input->param("Line");
 my $column         = $input->param("Column");
-my @filters        = $input->param("Filter");
+my @filters        = $input->multi_param("Filter");
 $filters[0] = eval { output_pref( { dt => dt_from_string( $filters[0]), dateonly => 1, dateformat => 'iso' } ); }
     if ( $filters[0] );
 $filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); }
@@ -124,19 +125,6 @@ else {
     $req->execute;
     my $booksellers = $req->fetchall_arrayref({});
 
-    $req = $dbh->prepare("SELECT DISTINCTROW itemtype,description FROM itemtypes ORDER BY description");
-    $req->execute;
-    my @iselect;
-    my %iselect;
-    while ( my ( $value, $desc ) = $req->fetchrow ) {
-        push @iselect, $value;
-        $iselect{$value} = $desc;
-    }
-    my $ItemTypes = {
-        values  => \@iselect,
-        labels  => \%iselect,
-   };
-
     $req = $dbh->prepare("SELECT DISTINCTROW budget_code, budget_name FROM aqbudgets ORDER BY budget_name");
     $req->execute;
     my @bselect;
@@ -196,13 +184,9 @@ else {
 
     my $CGIsepChoice = GetDelimiterChoices;
 
-    my $branches = GetBranches;
-    my @branches;
-    foreach ( sort keys %$branches ) {
-        push @branches, $branches->{$_};
-    }
+    my @branches = Koha::Libraries->search({}, { order_by => 'branchname' });
 
-    my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode', '');
+    my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode');
     my $ccode_label;
     my $ccode_avlist;
     if($ccode_subfield_structure) {
@@ -210,9 +194,10 @@ else {
         $ccode_avlist = GetAuthorisedValues($ccode_subfield_structure->{authorised_value});
     }
 
+    my $itemtypes = Koha::ItemTypes->search_with_localization;
     $template->param(
         booksellers   => $booksellers,
-        ItemTypes     => $ItemTypes,
+        itemtypes     => $itemtypes, # FIXME Should use the TT plugin instead
         Budgets       => $Budgets,
         hassort1      => $hassort1,
         hassort2      => $hassort2,
@@ -295,7 +280,7 @@ sub calculate {
             } elsif ( $rodsp == 3 ) {
                 $field{$a} = "Year($a)";
             } else {
-                field{$a} = $a;
+                $field{$a} = $a;
             }
         }
         elsif ( $_ =~ /bookseller/ ) {