From 692d770af1f550c377b34f3703f411ba4428153b Mon Sep 17 00:00:00 2001
From: Sophie Meynieux <sophie.meynieux@biblibre.com>
Date: Fri, 2 Aug 2013 15:48:27 +0200
Subject: [PATCH] Bug 9372 : Replaces carriage return with <br /> in printed
 html files for overdues.

For pdf generation, html files need explicit <br /> html tags. With this patch, carriage return are replaced by <br /> when letters are written into html files.

Test plan :
- Ensure you've got at least one reader with overdue triggering notice
- Ensure that your notice template got html checked
- Run misc/cronjobs/overdue_notices.pl -v -n -html <dirname>
  and misc/cronjobs/printoverdues.sh <dirname>

Without patch, the content of the letter is all on one line in pdf file
With the patch, pdf file is correctly formated

- remove your reader email
- Run misc/cronjobs/overdue_notices.pl -v -html <dirname>
  and misc/cronjobs/printoverdues.sh <dirname>

Without patch, the content of pdf file is all on one line
with the patch, pdf file is correctly formated.

- restore reader email
- run misc/cronjobs/overdue_notice.pl -v -html <dirname>

Verify that the a message has been generated in message_queue table
With or without patch, the message is the same
---
 misc/cronjobs/overdue_notices.pl |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl
index 5f285c0..44658f4 100755
--- a/misc/cronjobs/overdue_notices.pl
+++ b/misc/cronjobs/overdue_notices.pl
@@ -761,7 +761,10 @@ sub prepare_letter_for_printing {
         }
     } elsif ( exists $params->{'outputformat'} && $params->{'outputformat'} eq 'html' ) {
       $return = "<pre>\n";
-      $return .= "$params->{'letter'}->{'content'}\n";
+      my $content = $params->{'letter'}->{'content'};
+      $content=~s/\n/<br \/>/g;
+      $content=~s/\r//g;
+      $return .= "$content\n";
       $return .= "\n</pre>\n";
     } else {
         $return .= "$params->{'letter'}->{'content'}\n";
-- 
1.7.10.4