Bug 11650: multiplicated authorities after link_bibs_to_authorities.pl
[koha_fer] / tools / inventory.pl
index dbd73ac..f79f9d6 100755 (executable)
@@ -151,7 +151,7 @@ my @errorloop;
 if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) {
     my $dbh = C4::Context->dbh;
     my $date = dt_from_string( $input->param('setdate') );
-    $date = output_pref( $date, 'iso' );
+    $date = output_pref ( { dt => $date, dateformat => 'iso' } );
 
     my $strsth  = "select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =?";
     my $qonloan = $dbh->prepare($strsth);
@@ -204,9 +204,11 @@ if ( $markseen or $op ) {
 # If "compare barcodes list to results" has been checked, we want to alert for missing items
 if ( $compareinv2barcd ) {
     # set "missing" flags for all items with a datelastseen (dls) before the choosen datelastseen (cdls)
-    my $dls = output_pref( dt_from_string( $datelastseen ), 'iso' );
+    my $dls = output_pref( { dt => dt_from_string( $datelastseen ),
+                             dateformat => 'iso' } );
     foreach my $item ( @$inventorylist ) {
-        my $cdls = output_pref( dt_from_string( $_->{datelastseen} ), 'iso' );
+        my $cdls = output_pref( { dt => dt_from_string( $_->{datelastseen} ),
+                                  dateformat => 'iso' } );
         if ( $cdls lt $dls ) {
             $item->{problem} = 'missingitem';
             # We have to push a copy of the item, not the reference
@@ -291,16 +293,17 @@ if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
     eval {use Text::CSV};
     my $csv = Text::CSV->new or
             die Text::CSV->error_diag ();
+    binmode STDOUT, ":encoding(UTF-8)";
     print $input->header(
         -type       => 'text/csv',
         -attachment => 'inventory.csv',
     );
 
-    my $columns_def_hashref = C4::Reports::Guided::_get_column_defs();
+    my $columns_def_hashref = C4::Reports::Guided::_get_column_defs($input);
     foreach my $key ( keys %$columns_def_hashref ) {
         my $initkey = $key;
         $key =~ s/[^\.]*\.//;
-        $columns_def_hashref->{$initkey}=NormalizeString($columns_def_hashref->{$initkey});
+        $columns_def_hashref->{$initkey}=NormalizeString($columns_def_hashref->{$initkey} // '');
         $columns_def_hashref->{$key} = $columns_def_hashref->{$initkey};
     }