Bug 8168: Fixing header of non CSV files for overdue notices

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 <mtompset@hotmail.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: wajasu <matted-34813@mypacks.net>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit a31210efd3)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Daniel Barker 2014-01-15 09:57:19 +13:00 committed by Fridolin Somers
parent 8dc1661d59
commit 48ee914631
1 changed files with 9 additions and 2 deletions

View File

@ -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',