diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index d30f466df27..7dd553b0046 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -714,6 +714,8 @@ else if ($action == "addline" && $user->rights->propal->creer)
}
}
+ $desc='';
+
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
@@ -734,8 +736,7 @@ else if ($action == "addline" && $user->rights->propal->creer)
$desc = $prod->description;
}
- $desc.= ($desc && ! empty($product_desc)) ? ((dol_textishtml($desc) || dol_textishtml($product_desc))?"
\n":"\n") : "";
- $desc.= $product_desc;
+ $desc=dol_concatdesc($desc,$product_desc);
}
$type = $prod->type;
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index c186f05df5a..2d348b131e8 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -618,6 +618,8 @@ else if ($action == 'addline' && $user->rights->commande->creer)
}
}
+ $desc='';
+
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
@@ -638,8 +640,7 @@ else if ($action == 'addline' && $user->rights->commande->creer)
$desc = $prod->description;
}
- $desc.= ($desc && ! empty($product_desc)) ? ((dol_textishtml($desc) || dol_textishtml($product_desc))?"
\n":"\n") : "";
- $desc.= $product_desc;
+ $desc=dol_concatdesc($desc,$product_desc);
}
$type = $prod->type;
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 0c6e0e6c9b9..f6a326d4a67 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1049,6 +1049,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
}
}
+ $desc='';
+
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
@@ -1069,8 +1071,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
$desc = $prod->description;
}
- $desc.= ($desc && ! empty($product_desc)) ? ((dol_textishtml($desc) || dol_textishtml($product_desc))?"
\n":"\n") : "";
- $desc.= $product_desc;
+ $desc=dol_concatdesc($desc,$product_desc);
}
if (! empty($prod->customcode) || ! empty($prod->country_code))
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 74f7279d537..5826e248b13 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3367,11 +3367,12 @@ function dol_microtime_float()
}
/**
- * Return if a text is a html content
+ * Return if a text is a html content
*
- * @param string $msg Content to check
- * @param int $option 0=Full detection, 1=Fast check
- * @return boolean true/false
+ * @param string $msg Content to check
+ * @param int $option 0=Full detection, 1=Fast check
+ * @return boolean true/false
+ * @see dol_concatdesc
*/
function dol_textishtml($msg,$option=0)
{
@@ -3402,6 +3403,28 @@ function dol_textishtml($msg,$option=0)
}
}
+/**
+ * Concat 2 descriptions (second one after first one)
+ * text1 html + text2 html => text1 + '
' + text2
+ * text1 html + text2 txt => text1 + '
' + dol_nl2br(text2)
+ * text1 txt + text2 html => dol_nl2br(text1) + '
' + text2
+ * text1 txt + text2 txt => text1 + '\n' + text2
+ *
+ * @param string $text1 Text 1
+ * @param string $text2 Text 2
+ * @param string $forxml false=Use
, true=Use
+ * @return string Text 1 + new line + Text2
+ * @see dol_textishtml
+ */
+function dol_concatdesc($text1,$text2,$forxml=false)
+{
+ $ret='';
+ $ret.= (! dol_textishtml($text1) && dol_textishtml($text2))?dol_nl2br($text1, 0, $forxml):$text1;
+ $ret.= (! empty($text1) && ! empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2))?($forxml?"
\n":"
\n") : "\n") : "";
+ $ret.= (dol_textishtml($text1) && ! dol_textishtml($text2))?dol_nl2br($text2, 0, $forxml):$text2;
+ return $ret;
+}
+
/**
* Make substition into a string
* There is two type of substitions: