Bug 29695: (follow-up) Remove C4::Reports::Guided::_get_column_defs
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 14 Dec 2021 14:57:13 +0000 (15:57 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 12 Apr 2022 09:40:16 +0000 (11:40 +0200)
Same as the previous patch but for the inventory.

Test plan:
Same as before but test the inventory tool

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
tools/inventory.pl

index 5be7d7f..6fe7e79 100755 (executable)
@@ -37,6 +37,7 @@ use C4::Charset qw( NormalizeString );
 
 use Koha::Biblios;
 use Koha::DateUtils qw( dt_from_string output_pref );
+use Koha::Database::Columns;
 use Koha::AuthorisedValues;
 use Koha::BiblioFrameworks;
 use Koha::ClassSources;
@@ -392,14 +393,7 @@ if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
         -attachment => 'inventory.csv',
     );
 
-    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->{$key} = $columns_def_hashref->{$initkey};
-    }
-
+    my $columns = Koha::Database::Columns->columns;
     my @translated_keys;
     for my $key (qw / biblioitems.title    biblio.author
                       items.barcode        items.itemnumber
@@ -408,7 +402,8 @@ if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
                       items.itemlost       items.damaged
                       items.withdrawn      items.stocknumber
                       / ) {
-       push @translated_keys, $columns_def_hashref->{$key};
+        my ( $table, $column ) = split '\.', $key;
+        push @translated_keys, NormalizeString($columns->{$table}->{$column} // '');
     }
     push @translated_keys, 'problem' if $uploadbarcodes;