From b11bd00e9a24b7b5668a877a3fe7213d00b2de96 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Apr 2014 15:17:39 +0200 Subject: [PATCH] Fix: Removed blank lines at beginning of email when contact not defined --- htdocs/core/class/html.formmail.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b2c91087916..9539fe130a7 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -43,7 +43,7 @@ class FormMail var $replytomail; var $toname; var $tomail; - + var $withsubstit; // Show substitution array var $withfrom; var $withto; // Show recipient emails @@ -555,7 +555,7 @@ class FormMail { $defaultmessage=""; - // TODO A partir du type, proposer liste de messages dans table llx_models + // TODO A partir du type, proposer liste de messages dans table llx_c_email_template if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } @@ -595,8 +595,15 @@ class FormMail $defaultmessage = dol_nl2br($defaultmessage); } - $defaultmessage=make_substitutions($defaultmessage,$this->substit); + if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; + else + { + $defaultmessage=make_substitutions($defaultmessage,$this->substit); + // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) + $defaultmessage=preg_replace("/^(
)+/","",$defaultmessage); + $defaultmessage=preg_replace("/^\n+/","",$defaultmessage); + } $out.= ''; $out.= ''.$langs->trans("MailText").'';