aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2015-11-18 15:35:51 +0000
committerDave Arter <davea@mysociety.org>2015-11-18 15:35:51 +0000
commit8fad976f9b12cc36e317d01aee3cd4b20270f512 (patch)
tree3c42a79ad2ffff4050ad1d88ef448c3f6fdf8edc /perllib
parentb334c3bd8043385efb1c882755f8ad207ebc8bb9 (diff)
[Zurich] Generate the CSV header the same way as normal rows
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm30
1 files changed, 29 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 018d42a5f..bda5310fc 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -1117,9 +1117,37 @@ sub admin_stats {
]
}
);
- my $body = "Report ID,Created,Sent to Agency,Last Updated,E,N,Category,Status,Closure Status,UserID,External Body,Time Spent,Title,Detail,Media URL,Interface Used,Council Response\n";
+ my @fields = (
+ 'Report ID',
+ 'Created',
+ 'Sent to Agency',
+ 'Last Updated',
+ 'E',
+ 'N',
+ 'Category',
+ 'Status',
+ 'Closure Status',
+ 'UserID',
+ 'External Body',
+ 'Time Spent',
+ 'Title',
+ 'Detail',
+ 'Media URL',
+ 'Interface Used',
+ 'Council Response'
+ );
+
+ my $body = "";
require Text::CSV;
my $csv = Text::CSV->new({ binary => 1 });
+
+ if ($csv->combine(@fields)) {
+ $body .= $csv->string . "\n";
+ }
+ else {
+ $body .= sprintf "{{error emitting CSV line: %s}}\n", $csv->error_diag;
+ }
+
while ( my $report = $problems->next ) {
my $external_body;
my $body_name = "";