From 788db35e9bdfed3ea68388e576e882d2922bfe4e Mon Sep 17 00:00:00 2001 From: Daniel Barker Date: Wed, 15 Jan 2014 09:57:19 +1300 Subject: [PATCH] Bug 8168 - Fixing header of non csv files This determines if the CSV header should be included or not and then generates it as needed using the delimiter specified in the delimiter system preference. TEST PLAN --------- 1. make some overdues books 2. run the overdue notices script without the -csv 3. check emails notice csv header is in the email 4. apply the patch 5. run the overdue notice again 6. check email notice csv header is absent Signed-off-by: Mark Tompsett Signed-off-by: Chris Cormack Signed-off-by: wajasu Signed-off-by: Jonathan Druart --- misc/cronjobs/overdue_notices.pl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 7745047..a489f1f 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -627,9 +627,16 @@ END_SQL print @output_chunks; } # Generate the content of the csv with headers - my $content = join(";", qw(title name surname address1 address2 zipcode city country email itemcount itemsinfo due_date issue_date)) . "\n"; + my $content; + if ( defined $csvfilename ) { + my $delimiter = C4::Context->preference('delimiter') // ';'; + $content = join($delimiter, qw(title name surname address1 address2 zipcode city country email itemcount itemsinfo due_date issue_date)) . "\n"; + } + else { + $content = ""; + } $content .= join( "\n", @output_chunks ); - + my $attachment = { filename => defined $csvfilename ? 'attachment.csv' : 'attachment.txt', type => 'text/plain', -- 1.7.10.4