diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index ff5c98d425e..326f133ecbb 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1041,7 +1041,7 @@ if (empty($reshook))
$desc = $prod->description;
}
- $desc = dol_concatdesc($desc, $product_desc);
+ $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->CHANGE_ORDER_CONCAT_DESCRIPTION));
// Add dimensions into product description
/*if (empty($conf->global->MAIN_PRODUCT_DISABLE_AUTOADD_DIM))
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 611ff8368b9..400970f8eba 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -868,7 +868,7 @@ if (empty($reshook))
$desc = $prod->description;
}
- $desc = dol_concatdesc($desc, $product_desc);
+ $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->CHANGE_ORDER_CONCAT_DESCRIPTION));
// Add custom code and origin country into description
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) {
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 63b6283ed04..c803046724e 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -133,7 +133,6 @@ if ($user->societe_id) $socid = $user->societe_id;
$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft);
-
/*
* Actions
*/
@@ -1916,7 +1915,7 @@ if (empty($reshook))
$desc = $prod->description;
}
- $desc = dol_concatdesc($desc, $product_desc);
+ $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->CHANGE_ORDER_CONCAT_DESCRIPTION));
// Add custom code and origin country into description
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) {
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index a2c287ebe9a..6ab3544a385 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -540,7 +540,7 @@ if (empty($reshook))
}
$desc=$prod->description;
- $desc=dol_concatdesc($desc,$product_desc);
+ $desc=dol_concatdesc($desc,$product_desc, '', !empty($conf->global->CHANGE_ORDER_CONCAT_DESCRIPTION));
$fk_unit = $prod->fk_unit;
}
else
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 6ec0afa493d..4739cc12954 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5747,22 +5747,31 @@ function dol_textishtml($msg,$option=0)
* 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 bool $forxml false=Use
instead of \n if html content detected, true=Use
instead of \n if html content detected
- * @return string Text 1 + new line + Text2
+ * @param string $text1 Text 1
+ * @param string $text2 Text 2
+ * @param bool $forxml false=Use
instead of \n if html content detected, true=Use
instead of \n if html content detected
+ * @param bool $invert invert order of description lines if CONF CHANGE_ORDER_CONCAT_DESCRIPTION is active
+ * @return string Text 1 + new line + Text2
* @see dol_textishtml
*/
-function dol_concatdesc($text1,$text2,$forxml=false)
+function dol_concatdesc($text1,$text2,$forxml=false, $invert=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;
+ if (!empty($invert))
+ {
+ $tmp = $text1;
+ $text1 = $text2;
+ $text2 = $tmp;
+ }
+
+ $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;
}
+
/**
* Return array of possible common substitutions. This includes several families like: 'system', 'mycompany', 'object', 'objectamount', 'date', 'user'
*
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index d7715a21ceb..d0ba9e83656 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -404,7 +404,7 @@ if (empty($reshook))
$desc = $productsupplier->desc_supplier;
} else $desc = $productsupplier->description;
- if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
+ if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->CHANGE_ORDER_CONCAT_DESCRIPTION));
$type = $productsupplier->type;
$price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT');
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 86a28454269..5f3c51a6e38 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -1223,7 +1223,7 @@ if (empty($reshook))
$desc = $productsupplier->desc_supplier;
} else $desc = $productsupplier->description;
- if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
+ if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->CHANGE_ORDER_CONCAT_DESCRIPTION));
$type = $productsupplier->type;
$price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT');
diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php
index b1133616eeb..55bdddec096 100644
--- a/htdocs/supplier_proposal/card.php
+++ b/htdocs/supplier_proposal/card.php
@@ -630,7 +630,7 @@ if (empty($reshook))
$desc = $productsupplier->desc_supplier;
} else $desc = $productsupplier->description;
- if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
+ if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->CHANGE_ORDER_CONCAT_DESCRIPTION));
$pu_ht = $productsupplier->fourn_pu;