From 918958923e764b24edd99ba7d1f747feb83d874d Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Sat, 22 Jul 2006 14:14:13 +0000
Subject: [PATCH] =?UTF-8?q?Am=E9lioration=20du=20module=20fckeditor:=20On?=
 =?UTF-8?q?=20peut=20choisir=20d'activer=20l'=E9dition=20WYSIWIG=20sur=20l?=
 =?UTF-8?q?es=20desc=20produit=20et=20sur=20les=20lignes=20details=20ind?=
 =?UTF-8?q?=E9pendamment.=20On=20peut=20aussi=20=E9diter=20les=20notes=20p?=
 =?UTF-8?q?roduits.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 htdocs/admin/fckeditor.php                    |  68 ++++++-----
 htdocs/comm/propal.php                        |   2 +-
 htdocs/comm/propal/note.php                   |   8 +-
 htdocs/commande/fiche.php                     |   2 +-
 htdocs/compta/facture.php                     |   2 +-
 .../modules/commande/pdf_einstein.modules.php | 108 ++++++++----------
 .../modules/facture/pdf_crabe.modules.php     |  19 ++-
 .../propale/pdf_propale_azur.modules.php      |  44 ++++---
 htdocs/langs/en_US/admin.lang                 |   5 +-
 htdocs/langs/fr_FR/admin.lang                 |   5 +-
 htdocs/product/fiche.php                      |  61 +++++++---
 11 files changed, 182 insertions(+), 142 deletions(-)

diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php
index 8fb68d93b16..1b6e8bc5134 100644
--- a/htdocs/admin/fckeditor.php
+++ b/htdocs/admin/fckeditor.php
@@ -38,6 +38,7 @@ if (!$user->admin)
 // Constante et traduction de la description du module
 $modules = array(
 'PRODUCTDESC'=>'FCKeditorForProductDescription',
+'DETAILS'=>'FCKeditorForDetails',
 'MAILING'=>'FCKeditorForMailing',
 ); 
 
@@ -45,18 +46,19 @@ foreach($modules as $const => $desc)
 {
 	if ($_GET["action"] == 'activate_'.strtolower($const))
 	{
-    dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1");
-    Header("Location: fckeditor.php");
-    exit;
-  }
-  else if ($_GET["action"] == 'disable_'.strtolower($const))
- {
-	  dolibarr_del_const($db, "FCKEDITOR_ENABLE_".$const);
-    Header("Location: fckeditor.php");
-    exit;
- }
+	    dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1");
+	    Header("Location: fckeditor.php");
+	    exit;
+	}
+	if ($_GET["action"] == 'disable_'.strtolower($const))
+	{
+		dolibarr_del_const($db, "FCKEDITOR_ENABLE_".$const);
+		Header("Location: fckeditor.php");
+		exit;
+	}
 }
 
+
 /*
  * Affiche page
  */
@@ -96,39 +98,35 @@ print "</tr>\n";
 foreach($modules as $const => $desc)
 {
 	$var=!$var;
-	print "<form method=\"post\" action=\"fckeditor.php\">";
-	print '<input type="hidden" name="action" value="'.strtolower($const).'">';
 	print "<tr ".$bc[$var].">";
 	print '<td>'.$langs->trans($desc).'</td>';
 	print '<td align="center" width="20">';
-	
+
 	$constante = FCKEDITOR_ENABLE_.$const;
 	$value = $conf->global->$constante;
-	
-	if($value == 1)
- {
-	 print img_tick();
- }
-
- print '</td>';
- print '<td align="center" width="100">';
-
- if($value == 0)
- {
-	 print '<a href="fckeditor.php?action=activate_'.strtolower($const).'">'.$langs->trans("Activate").'</a>';
- }
- else if($value == 1)
- {
-	 print '<a href="fckeditor.php?action=disable_'.strtolower($const).'">'.$langs->trans("Disable").'</a>';
- }
-  print '</form>';
+
+	print $value == 1 ? img_tick() : '&nbsp;';
+
+	print '</td>';
+	print '<td align="center" width="100">';
+
+	if($value == 0)
+	{
+		print '<a href="fckeditor.php?action=activate_'.strtolower($const).'">'.$langs->trans("Activate").'</a>';
+	}
+	else if($value == 1)
+	{
+		print '<a href="fckeditor.php?action=disable_'.strtolower($const).'">'.$langs->trans("Disable").'</a>';
+	}
+
+	print "</td>";
+	print '</tr>';
 }
 
- print "</td>";
- print '</tr>';
- print '</table>';
+print '</table>';
+
 
 $db->close();
 
-llxFooter();
+llxFooter('$Date$ - $Revision$');
 ?>
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index fa28d089c1c..7c8c2a0d1e3 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1160,7 +1160,7 @@ if ($_GET['propalid'] > 0)
 					print '<br>';
 				}
 				// �diteur wysiwyg
-				if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
+				if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
         {
         	require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php");
         	$oFCKeditor = new FCKeditor('desc');
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index 2045b375c1d..eba39ad2379 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -119,10 +119,10 @@ if ($_GET['propalid'])
 	        print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'.$propal->ref_url.'</td></tr>';
 
             // Soci�t�
-            print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td></tr>';
+            print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
             
 			// Ligne info remises tiers
-            print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
+            print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
 			if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
 			else print $langs->trans("CompanyHasNoRelativeDiscount");
 			$absolute_discount=$societe->getCurrentDiscount();
@@ -133,14 +133,14 @@ if ($_GET['propalid'])
 			print '</td></tr>';
     
 			// Date
-            print '<tr><td>'.$langs->trans('Date').'</td><td>';
+            print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
             print dolibarr_print_date($propal->date,'%a %d %B %Y');
             print '</td>';
     		print '</tr>';
     		
     		// Date fin propal
             print '<tr>';
-            print '<td>'.$langs->trans('DateEndPropal').'</td><td>';
+            print '<td>'.$langs->trans('DateEndPropal').'</td><td colspan="3">';
             if ($propal->fin_validite)
             {
                 print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y');
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index f8bc418b3b6..d3f903ac721 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1353,7 +1353,7 @@ else
 							print '<br>';
 						}
 						// �diteur wysiwyg
-						if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
+						if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
 						{
 							require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php");
 							$oFCKeditor = new FCKeditor('eldesc');
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 21afb5dceea..327c95efbe7 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1896,7 +1896,7 @@ else
 							print '<br>';
 						}
 						// �diteur wysiwyg
-						if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
+						if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
 						{
 							require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php");
 							$oFCKeditor = new FCKeditor('desc');
diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php
index dd47005d39f..2a34bdce6bd 100644
--- a/htdocs/includes/modules/commande/pdf_einstein.modules.php
+++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php
@@ -40,6 +40,8 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php");
 
 class pdf_einstein extends ModelePDFCommandes
 {
+	var $emetteur;	// Objet societe qui emet
+
     
     /**
 			\brief      Constructeur
@@ -47,7 +49,7 @@ class pdf_einstein extends ModelePDFCommandes
     */
     function pdf_einstein($db)
     {
-        global $conf,$langs;
+        global $conf,$langs,$mysoc;
 
         $this->db = $db;
         $this->name = "einstein";
@@ -72,21 +74,9 @@ class pdf_einstein extends ModelePDFCommandes
     	if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') 
       		$this->franchise=1;
 
-        // Recupere code pays de l'emmetteur
-        $this->emetteur->code_pays=substr($langs->defaultlang,-2);    // Par defaut, si on trouve pas
-        $sql  = "SELECT code from ".MAIN_DB_PREFIX."c_pays";
-        $sql .= " WHERE rowid = '".$conf->global->MAIN_INFO_SOCIETE_PAYS."'";
-        $result=$this->db->query($sql);
-        if ($result) {
-            $obj = $this->db->fetch_object($result);
-            if ($obj->code) $this->emetteur->code_pays=$obj->code;
-        }
-        else {
-            dolibarr_print_error($this->db);
-        }
-        $this->db->free($result);
-
-        $this->tva=array();
+        // Recupere emmetteur
+        $this->emetteur=$mysoc;
+        if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'�tait pas d�fini
 
         // Defini position des colonnes
         $this->posxdesc=$this->marge_gauche+1;
@@ -96,6 +86,7 @@ class pdf_einstein extends ModelePDFCommandes
         $this->posxdiscount=162;
         $this->postotalht=177;
        
+        $this->tva=array();
         $this->atleastoneratenotnull=0;
         $this->atleastonediscount=0;
 	}
@@ -113,20 +104,6 @@ class pdf_einstein extends ModelePDFCommandes
     		\brief      Fonction g�n�rant la commande sur le disque
     		\param	    id	        Id de la commande � g�n�rer
     		\return	    int         1=ok, 0=ko
-            \remarks    Variables utilis�es
-    		\remarks    MAIN_INFO_SOCIETE_NOM
-    		\remarks    MAIN_INFO_ADRESSE
-    		\remarks    MAIN_INFO_CP
-    		\remarks    MAIN_INFO_VILLE
-    		\remarks    MAIN_INFO_TEL
-    		\remarks    MAIN_INFO_FAX
-    		\remarks    MAIN_INFO_WEB
-    		\remarks    MAIN_INFO_SIRET
-    		\remarks    MAIN_INFO_SIREN
-    		\remarks    MAIN_INFO_RCS
-    		\remarks    MAIN_INFO_CAPITAL
-    		\remarks    MAIN_INFO_TVAINTRA
-            \remarks    MAIN_INFO_LOGO
     */
     function write_pdf_file($com,$outputlangs='')
     {
@@ -218,11 +195,11 @@ class pdf_einstein extends ModelePDFCommandes
                     $curY = $nexY;
 
                     // Description de la ligne produit
-                    $libelleproduitservice=$com->lignes[$i]->libelle;
+                    $libelleproduitservice=_dol_htmlentities($com->lignes[$i]->libelle,0);
                     if ($com->lignes[$i]->desc&&$com->lignes[$i]->desc!=$com->lignes[$i]->libelle)
                     {
                         if ($libelleproduitservice) $libelleproduitservice.="\n";
-                        $libelleproduitservice.=$com->lignes[$i]->desc;
+                        $libelleproduitservice.=_dol_htmlentities($com->lignes[$i]->desc,$conf->global->FCKEDITOR_ENABLE_DETAILS);
                     }
                     // Si ligne associ�e � un code produit
                     if ($com->lignes[$i]->fk_product)
@@ -253,7 +230,7 @@ class pdf_einstein extends ModelePDFCommandes
 
                     $pdf->SetFont('Arial','', 9);   // Dans boucle pour g�rer multi-page
 
-                    if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
+                    if ($conf->fckeditor->enabled)
                     {
                     	$pdf->writeHTMLCell(108, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1);
                     }
@@ -662,7 +639,7 @@ class pdf_einstein extends ModelePDFCommandes
      */
     function _pagehead(&$pdf, $com, $showadress=1, $outputlangs)
     {
-        global $conf,$mysoc;
+        global $conf;
 
         $outputlangs->load("main");
         $outputlangs->load("bills");
@@ -677,8 +654,8 @@ class pdf_einstein extends ModelePDFCommandes
         $pdf->SetXY($this->marge_gauche,$posy);
 
 		// Logo
-        $logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
-        if ($mysoc->logo)
+        $logo=$conf->societe->dir_logos.'/'.$this->emetteur->logo;
+        if ($this->emetteur->logo)
         {
             if (is_readable($logo))
 			{
@@ -739,28 +716,28 @@ class pdf_einstein extends ModelePDFCommandes
 	        $pdf->SetTextColor(0,0,60);
 	        $pdf->SetFont('Arial','B',11);
 	        if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L');
-	        else $pdf->MultiCell(80, 4, $mysoc->nom, 0, 'L');
+	        else $pdf->MultiCell(80, 4, $this->emetteur->nom, 0, 'L');
 	
 	        // Caract�ristiques emetteur
 	        $carac_emetteur = '';
 	        if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE;
 	        else {
-	            $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->adresse;
-	            $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->cp.' '.$mysoc->ville;
+	            $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$this->emetteur->adresse;
+	            $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$this->emetteur->cp.' '.$this->emetteur->ville;
 	        }
 	        $carac_emetteur .= "\n";
 	        // Tel
 	        if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Phone").": ".FAC_PDF_TEL;
-	        elseif ($mysoc->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Phone").": ".$mysoc->tel;
+	        elseif ($this->emetteur->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Phone").": ".$this->emetteur->tel;
 	        // Fax
 	        if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Fax").": ".FAC_PDF_FAX;
-	        elseif ($mysoc->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Fax").": ".$mysoc->fax;
+	        elseif ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Fax").": ".$this->emetteur->fax;
 	        // EMail
 			if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Email").": ".FAC_PDF_MEL;
-	        elseif ($mysoc->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Email").": ".$mysoc->email;
+	        elseif ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Email").": ".$this->emetteur->email;
 	        // Web
 			if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Web").": ".FAC_PDF_WWW;
-	        elseif ($mysoc->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Web").": ".$mysoc->url;
+	        elseif ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->trans("Web").": ".$this->emetteur->url;
 	
 	        $pdf->SetFont('Arial','',9);
 	        $pdf->SetXY($this->marge_gauche+2,$posy+8);
@@ -812,36 +789,36 @@ class pdf_einstein extends ModelePDFCommandes
         
         // Premiere ligne d'info r�glementaires
         $ligne1="";
-        if ($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)
+        if ($this->emetteur->forme_juridique_code)
         {
-            $ligne1.=($ligne1?" - ":"").$html->forme_juridique_name($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE);
+            $ligne1.=($ligne1?" - ":"").$html->forme_juridique_name($this->emetteur->forme_juridique_code);
         }
-        if ($conf->global->MAIN_INFO_CAPITAL)
+        if ($this->emetteur->capital)
         {
-            $ligne1.=($ligne1?" - ":"").$outputlangs->trans("CapitalOf",$conf->global->MAIN_INFO_CAPITAL)." ".$outputlangs->trans("Currency".$conf->monnaie);
+            $ligne1.=($ligne1?" - ":"").$outputlangs->trans("CapitalOf",$this->emetteur->capital)." ".$outputlangs->trans("Currency".$conf->monnaie);
         }
-        if ($conf->global->MAIN_INFO_SIRET)
+        if ($this->emetteur->profid2)
         {
-            $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId2",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIRET;
+            $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId2",$this->emetteur->pays_code).": ".$this->emetteur->profid2;
         }
-        if ($conf->global->MAIN_INFO_SIREN && (! $conf->global->MAIN_INFO_SIRET || $this->emetteur->code_pays != 'FR'))
+        if ($this->emetteur->profid1 && (! $this->emetteur->profid2 || $this->emetteur->pays_code != 'FR'))
         {
-            $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId1",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIREN;
-        }
-        if ($conf->global->MAIN_INFO_APE)
-        {
-            $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId3",$this->emetteur->code_pays).": ".MAIN_INFO_APE;
+            $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId1",$this->emetteur->pays_code).": ".$this->emetteur->profid1;
         }
 
         // Deuxieme ligne d'info r�glementaires
         $ligne2="";
-        if ($conf->global->MAIN_INFO_RCS)
+        if ($this->emetteur->profid3)
+        {
+            $ligne2.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId3",$this->emetteur->pays_code).": ".$this->emetteur->profid3;
+        }
+        if ($this->emetteur->profid4)
         {
-            $ligne2.=($ligne2?" - ":"").$outputlangs->transcountry("ProfId4",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_RCS;
+            $ligne2.=($ligne2?" - ":"").$outputlangs->transcountry("ProfId4",$this->emetteur->pays_code).": ".$this->emetteur->profid4;
         }
-        if ($conf->global->MAIN_INFO_TVAINTRA != '')
+        if ($this->emetteur->tva_intra != '')
         {
-            $ligne2.=($ligne2?" - ":"").$outputlangs->trans("VATIntraShort").": ".$conf->global->MAIN_INFO_TVAINTRA;
+            $ligne2.=($ligne2?" - ":"").$outputlangs->trans("VATIntraShort").": ".$this->emetteur->tva_intra;
         }
 
         $pdf->SetFont('Arial','',8);
@@ -873,4 +850,17 @@ class pdf_einstein extends ModelePDFCommandes
 
 }
 
+// Cette fonction est appel�e pour coder ou non une chaine en html
+// selon qu'on compte l'afficher dans le PDF avec:
+// writeHTMLCell -> a besoin d'etre encod� en HTML
+// MutliCell -> ne doit pas etre encod� en HTML
+function _dol_htmlentities($stringtoencode,$isstringalreadyhtml)
+{
+	global $conf;
+	
+	if ($isstringalreadyhtml) return $stringtoencode;
+	if ($conf->fckeditor->enabled) return htmlentities($stringtoencode);
+	return $stringtoencode;
+}
+
 ?>
diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php
index 28a3ce29e9f..7a92caebe4b 100644
--- a/htdocs/includes/modules/facture/pdf_crabe.modules.php
+++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php
@@ -214,11 +214,11 @@ class pdf_crabe extends ModelePDFFactures
                     $curY = $nexY;
 
                     // Description de la ligne produit
-                    $libelleproduitservice=$fac->lignes[$i]->libelle;
+                    $libelleproduitservice=_dol_htmlentities($fac->lignes[$i]->libelle,0);
                     if ($fac->lignes[$i]->desc&&$fac->lignes[$i]->desc!=$fac->lignes[$i]->libelle)
                     {
                         if ($libelleproduitservice) $libelleproduitservice.="\n";
-                        $libelleproduitservice.=$fac->lignes[$i]->desc;
+                        $libelleproduitservice.=_dol_htmlentities($fac->lignes[$i]->desc,$conf->global->FCKEDITOR_ENABLE_DETAILS);
                     }
                     // Si ligne associ�e � un code produit
                     if ($fac->lignes[$i]->produit_id)
@@ -254,7 +254,7 @@ class pdf_crabe extends ModelePDFFactures
 
                     $pdf->SetFont('Arial','', 9);   // Dans boucle pour g�rer multi-page
 
-                    if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
+                    if ($conf->fckeditor->enabled)
                     {
                     	$pdf->writeHTMLCell(108, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1);
                     }
@@ -961,4 +961,17 @@ class pdf_crabe extends ModelePDFFactures
 
 }
 
+// Cette fonction est appel�e pour coder ou non une chaine en html
+// selon qu'on compte l'afficher dans le PDF avec:
+// writeHTMLCell -> a besoin d'etre encod� en HTML
+// MutliCell -> ne doit pas etre encod� en HTML
+function _dol_htmlentities($stringtoencode,$isstringalreadyhtml)
+{
+	global $conf;
+	
+	if ($isstringalreadyhtml) return $stringtoencode;
+	if ($conf->fckeditor->enabled) return htmlentities($stringtoencode);
+	return $stringtoencode;
+}
+
 ?>
diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
index 3f5d2f240f8..852530f6b1c 100644
--- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
@@ -213,18 +213,19 @@ class pdf_propale_azur extends ModelePDFPropales
 					$curY = $nexY;
 
 					// Description de la ligne produit
-					$libelleproduitservice=$propale->lignes[$i]->libelle;
-					if ($propale->lignes[$i]->desc&&$propale->lignes[$i]->desc!=$propale->lignes[$i]->libelle)
+					$libelleproduitservice=_dol_htmlentities($propale->lignes[$i]->libelle,0);
+					if ($propale->lignes[$i]->desc && $propale->lignes[$i]->desc!=$propale->lignes[$i]->libelle)
 					{
 						if ($libelleproduitservice) $libelleproduitservice.="\n";
-						$libelleproduitservice.=$propale->lignes[$i]->desc;
+						$libelleproduitservice.=_dol_htmlentities($propale->lignes[$i]->desc,$conf->global->FCKEDITOR_ENABLE_DETAILS);
 					}
 					// Si ligne associ�e � un code produit
 					if ($propale->lignes[$i]->fk_product)
 					{
 						$prodser = new Product($this->db);
-
 						$prodser->fetch($propale->lignes[$i]->fk_product);
+						
+						// On ajoute la ref
 						if ($prodser->ref)
 						{
 							$prefix_prodserv = "";
@@ -236,10 +237,10 @@ class pdf_propale_azur extends ModelePDFPropales
 							$libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice;
 						}
 
-						// Ajoute description du produit
+						// Ajoute description compl�te du produit
 						if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
 						{
-							if ($propale->lignes[$i]->product_desc&&$propale->lignes[$i]->product_desc!=$propale->lignes[$i]->libelle&&$propale->lignes[$i]->product_desc!=$propale->lignes[$i]->desc)
+							if ($propale->lignes[$i]->product_desc && $propale->lignes[$i]->product_desc!=$propale->lignes[$i]->libelle && $propale->lignes[$i]->product_desc!=$propale->lignes[$i]->desc)
 							{
 								if ($libelleproduitservice) $libelleproduitservice.="\n";
 								$libelleproduitservice.=$propale->lignes[$i]->product_desc;
@@ -254,15 +255,15 @@ class pdf_propale_azur extends ModelePDFPropales
 
 					$pdf->SetFont('Arial','', 9);   // Dans boucle pour g�rer multi-page
 
-					if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
-          {
-             $pdf->writeHTMLCell(108, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1);
-          }
-          else
-          {
-          	$pdf->SetXY ($this->posxdesc-1, $curY);
-          	$pdf->MultiCell(108, 4, $libelleproduitservice, 0, 'J');
-          }
+					if ($conf->fckeditor->enabled)
+					{
+						$pdf->writeHTMLCell(108, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1);
+					}
+					else
+					{
+						$pdf->SetXY ($this->posxdesc-1, $curY);
+						$pdf->MultiCell(108, 4, $libelleproduitservice, 0, 'J');
+					}
 
 					$nexY = $pdf->GetY();
 
@@ -867,4 +868,17 @@ class pdf_propale_azur extends ModelePDFPropales
 
 }
 
+// Cette fonction est appel�e pour coder ou non une chaine en html
+// selon qu'on compte l'afficher dans le PDF avec:
+// writeHTMLCell -> a besoin d'etre encod� en HTML
+// MutliCell -> ne doit pas etre encod� en HTML
+function _dol_htmlentities($stringtoencode,$isstringalreadyhtml)
+{
+	global $conf;
+	
+	if ($isstringalreadyhtml) return $stringtoencode;
+	if ($conf->fckeditor->enabled) return htmlentities($stringtoencode);
+	return $stringtoencode;
+}
+
 ?>
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 69b14ffe62e..a8c33e4991d 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -529,5 +529,6 @@ DeliveryOrderModel=Products deliveries receipt model
 DeliveriesOrderAbility=Products deliveries receipt ability
 ##### FCKeditor #####
 ActivateFCKeditor=Activate FCKeditor for:
-FCKeditorForProductDescription=Creation/edition of products/services description (in all modules)
-FCKeditorForMailing=Creation/edition mailings
\ No newline at end of file
+FCKeditorForProductDescription=WYSIWIG creation/edition of products/services description and note
+FCKeditorForDetails=WYSIWIG creation/edition of details lines for all entities (proposals, orders, invoices, etc...)
+FCKeditorForMailing=WYSIWIG creation/edition of mailings
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 6f14493d48b..0e8adc13581 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -529,5 +529,6 @@ DeliveryOrderModel=Mod
 DeliveriesOrderAbility=Prise en charge des bons de r�ception client
 ##### FCKeditor #####
 ActivateFCKeditor=Activer FCKeditor pour :
-FCKeditorForProductDescription=Cr�ation/�dition de la description des produits/services (dans tous les modules)
-FCKeditorForMailing=Cr�ation/�dition des mailings
\ No newline at end of file
+FCKeditorForProductDescription=Cr�ation/�dition WYSIWIG de la description et note des produits/services
+FCKeditorForDetails=Cr�ation/�dition WYSIWIG des lignes details des entit�s (commandes, propales, factures, etc...)
+FCKeditorForMailing=Cr�ation/�dition WYSIWIG des mailings
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 46f4182153f..8a51a1e0378 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -451,18 +451,19 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
     // Description
     print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
     
-    if ($conf->fckeditor->enabled)
-        {
-        	require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php");
-        	$oFCKeditor = new FCKeditor('desc');
-        	$oFCKeditor->Create() ;
-        }
-        else
-        {
-        	print '<textarea name="desc" rows="4" cols="50">';
-        }
+	if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
+	{
+		require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php");
+		$oFCKeditor = new FCKeditor('desc');
+		$oFCKeditor->Create() ;
+	}
+	else
+	{
+		print '<textarea name="desc" rows="4" cols="50">';
+		print '</textarea>';
+	}
         
-    print "</textarea></td></tr>";
+    print "</td></tr>";
 
     if ($_GET["type"] == 1)
     {
@@ -475,9 +476,19 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
     }
 
     // Note
-    print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>';
-    print '<textarea name="note" rows="8" cols="50">';
-    print "</textarea></td></tr>";
+    print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td>';
+	if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
+	{
+		require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php");
+		$oFCKeditor = new FCKeditor('note');
+		$oFCKeditor->Create() ;
+	}
+	else
+	{
+		print '<textarea name="note" rows="8" cols="50">';
+		print '</textarea>';
+	}
+    print "</td></tr>";
 
     print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
     print '</table>';
@@ -765,7 +776,7 @@ if ($_GET["id"] || $_GET["ref"])
         // Description
         print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">';
         print "\n";
-        if ($conf->fckeditor->enabled)
+        if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
         {
         	require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php");
         	$oFCKeditor = new FCKeditor('desc');
@@ -777,8 +788,8 @@ if ($_GET["id"] || $_GET["ref"])
         	print '<textarea name="desc" rows="4" cols="50">';
         	print $product->description;
         	print "</textarea>";
-        	print "</td></tr>";
         }
+       	print "</td></tr>";
         print "\n";
 
         if ($product->type == 1)
@@ -798,9 +809,21 @@ if ($_GET["id"] || $_GET["ref"])
 
         // Note
         print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="2">';
-        print '<textarea name="note" rows="8" cols="50">';
-        print $product->note;
-        print "</textarea></td></tr>";
+		if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
+        {
+        	require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php");
+        	$oFCKeditor = new FCKeditor('note');
+        	$oFCKeditor->Value		= $product->note;
+        	$oFCKeditor->Create() ;
+        }
+        else
+        {
+        	print '<textarea name="note" rows="8" cols="50">';
+        	print $product->description;
+        	print "</textarea>";
+        }
+		print "</td></tr>";
+        
         print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'">&nbsp;';
         print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
         print '</table>';
-- 
GitLab