Bug 32336: (QA follow-up) Use $metadata->schema
[srvgit] / serials / lateissues-export.pl
index 0bd82a6..af83f2c 100755 (executable)
@@ -18,8 +18,7 @@
 use Modern::Perl;
 use CGI qw ( -utf8 );
 use C4::Auth;
-use C4::Serials;
-use C4::Acquisition;
+use C4::Serials qw( GetLateOrMissingIssues updateClaim );
 use C4::Output;
 use C4::Context;
 
@@ -27,7 +26,7 @@ use Koha::CsvProfiles;
 
 use Text::CSV_XS;
 
-my $query = new CGI;
+my $query = CGI->new;
 my $supplierid = $query->param('supplierid');
 my @serialids = $query->multi_param('serialid');
 my $op = $query->param('op') || q{};
@@ -36,10 +35,13 @@ my $csv_profile_id = $query->param('csv_profile');
 my $csv_profile = Koha::CsvProfiles->find( $csv_profile_id );
 die "There is no valid csv profile given" unless $csv_profile;
 
+my $delimiter = $csv_profile->csv_separator;
+$delimiter = "\t" if $delimiter eq "\\t";
+
 my $csv = Text::CSV_XS->new({
     'quote_char'  => '"',
     'escape_char' => '"',
-    'sep_char'    => $csv_profile->csv_separator,
+    'sep_char'    => $delimiter,
     'binary'      => 1
 });
 
@@ -57,7 +59,7 @@ while ( $content =~ /
     $header =~ s/^\s+|\s+$//g; # Trim whitespaces
     push @headers, $header;
 
-    $field =~ s/[^\.]*\.{1}//; # Remove the table name if exists.
+    $field =~ s/[^.]+\.//; # Remove the table name if exists.
     $field =~ s/^\s+|\s+$//g; # Trim whitespaces
     push @fields, $field;
 }
@@ -81,7 +83,7 @@ print $query->header(
     -attachment => "serials-claims.csv",
 );
 
-print join( $csv_profile->csv_separator, @headers ) . "\n";
+print join( $delimiter, @headers ) . "\n";
 
 for my $row ( @rows ) {
     $csv->combine(@$row);