From 1ebc1bdece9ac6722b475adc8098a969d824b55e Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Mon, 15 Dec 2008 22:07:07 +0000
Subject: [PATCH] Fix: UTF8 support in public notes

---
 .../modules/commande/pdf_einstein.modules.php |  4 +-
 .../modules/facture/pdf_crabe.modules.php     |  4 +-
 .../modules/facture/pdf_huitre.modules.php    |  2 +-
 .../propale/pdf_propale_azur.modules.php      |  4 +-
 .../propale/pdf_propale_jaune.modules.php     | 37 ++++++++++++++++---
 .../pdf/pdf_muscadet.modules.php              |  4 +-
 6 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php
index a27d9c55237..81fef271146 100644
--- a/htdocs/includes/modules/commande/pdf_einstein.modules.php
+++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php
@@ -203,13 +203,13 @@ class pdf_einstein extends ModelePDFCommandes
 				$tab_height_newpage = 180;
 
 				// Affiche notes
-				if ($com->note_public)
+				if (! empty($com->note_public))
 				{
 					$tab_top = 88;
 
 					$pdf->SetFont('Arial','', 9);   // Dans boucle pour g�rer multi-page
 					$pdf->SetXY ($this->posxdesc-1, $tab_top);
-					$pdf->MultiCell(190, 3, $com->note_public, 0, 'J');
+					$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($com->note_public), 0, 'J');
 					$nexY = $pdf->GetY();
 					$height_note=$nexY-$tab_top;
 
diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php
index 185ecc93e7c..94b310a2bdd 100644
--- a/htdocs/includes/modules/facture/pdf_crabe.modules.php
+++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php
@@ -206,13 +206,13 @@ class pdf_crabe extends ModelePDFFactures
 				$tab_height_newpage = 180;
 
 				// Affiche notes
-				if ($fac->note_public)
+				if (! empty($fac->note_public))
 				{
 					$tab_top = 88;
 
 					$pdf->SetFont('Arial','', 9);   // Dans boucle pour gerer multi-page
 					$pdf->SetXY ($this->posxdesc-1, $tab_top);
-					$pdf->MultiCell(190, 3, $fac->note_public, 0, 'J');
+					$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($fac->note_public), 0, 'J');
 					$nexY = $pdf->GetY();
 					$height_note=$nexY-$tab_top;
 
diff --git a/htdocs/includes/modules/facture/pdf_huitre.modules.php b/htdocs/includes/modules/facture/pdf_huitre.modules.php
index 97055910593..ee21611b450 100644
--- a/htdocs/includes/modules/facture/pdf_huitre.modules.php
+++ b/htdocs/includes/modules/facture/pdf_huitre.modules.php
@@ -239,7 +239,7 @@ class pdf_huitre extends ModelePDFFactures
 				 *
 				 */
 
-				if ( $fac->note_public)
+				if (! empty($fac->note_public))
 				{
 					$pdf->SetFont('Arial','',7);
 					$pdf->SetXY(10, 211);
diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
index c353b26db69..5a34a5a8a28 100644
--- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
@@ -206,7 +206,7 @@ class pdf_propale_azur extends ModelePDFPropales
 				$tab_height_middlepage = 190;
 
 				// Affiche notes
-				if ($propale->note_public)
+				if (! empty($propale->note_public))
 				{
 					$tab_top = 88;
 
@@ -232,7 +232,7 @@ class pdf_propale_azur extends ModelePDFPropales
 				$curY = $tab_top + 8;
 				$nexY = $tab_top + 8;
 
-				// Boucle sur les lignes
+				// Loop on each lines
 				for ($i = 0 ; $i < $nblignes ; $i++)
 				{
 					$curY = $nexY;
diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
index 6eabb8c48e0..3f43bf39b16 100644
--- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
@@ -84,7 +84,7 @@ class pdf_propale_jaune extends ModelePDFPropales
 
 
 	/**
-	 *	\brief      Fonction g�n�rant la propale sur le disque
+	 *	\brief      Fonction generant la propale sur le disque
 	 *	\param	    propale			Objet propal
 	 *	\param		outputlangs		Lang object for output language
 	 *	\return	    int     		1=ok, 0=ko
@@ -117,7 +117,7 @@ class pdf_propale_jaune extends ModelePDFPropales
 				$ret=$propale->fetch($id);
 			}
 
-			// D�finition de $dir et $file
+			// Definition de $dir et $file
 			if ($propale->specimen)
 			{
 				$dir = $conf->propal->dir_output;
@@ -189,20 +189,47 @@ class pdf_propale_jaune extends ModelePDFPropales
 				$nexY = $pdf->GetY();
 				$nblignes = sizeof($propale->lignes);
 
+				// Loop on each lines
 				for ($i = 0 ; $i < $nblignes ; $i++)
 				{
 					$curY = $nexY;
 
+					// Description de la ligne produit
+					$libelleproduitservice=dol_htmlentitiesbr($propale->lignes[$i]->libelle,1);
+					if ($propale->lignes[$i]->desc && $propale->lignes[$i]->desc!=$propale->lignes[$i]->libelle)
+					{
+						if ($libelleproduitservice) $libelleproduitservice.="<br>";
+
+						if ($propale->lignes[$i]->desc == '(CREDIT_NOTE)' && $propale->lignes[$i]->fk_remise_except)
+						{
+							$discount=new DiscountAbsolute($this->db);
+							$discount->fetch($propale->lignes[$i]->fk_remise_except);
+							$libelleproduitservice=dol_htmlentitiesbr($langs->trans("DiscountFromCreditNote",$discount->ref_facture_source),1);
+						}
+						else
+						{
+							$libelleproduitservice.=dol_htmlentitiesbr($propale->lignes[$i]->desc,1);
+						}
+					}
+					if ($propale->lignes[$i]->date_start && $propale->lignes[$i]->date_end)
+					{
+						// Affichage dur�e si il y en a une
+						$libelleproduitservice.="<br>".dol_htmlentitiesbr("(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($propale->lignes[$i]->date_start,'',false,$outputlangs)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($propale->lignes[$i]->date_end,'',false,$outputlangs).")",1);
+					}
+
+					
 					$pdf->SetXY (30, $curY );
-					$pdf->MultiCell(102, 5, $outputlangs->convToOutputCharset($propale->lignes[$i]->desc), 0, 'J', 0);
+					$pdf->MultiCell(102, 5, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 'J', 0);
 
 					$nexY = $pdf->GetY();
 
+					$ref=dol_htmlentitiesbr($propale->lignes[$i]->ref);
+					
 					$pdf->SetXY (10, $curY );
-					$pdf->MultiCell(20, 5, $outputlangs->convToOutputCharset($propale->lignes[$i]->ref), 0, 'C', 0);
+					$pdf->MultiCell(20, 5, $outputlangs->convToOutputCharset($ref), 0, 'C', 0);
 
 					$pdf->SetXY (132, $curY );
-					$pdf->MultiCell(12, 5, $propale->lignes[$i]->tva_tx, 0, 'C', 0);
+					$pdf->MultiCell(12, 5, vatrate($propale->lignes[$i]->tva_tx,0,$propale->lignes[$i]->info_bits), 0, 'C', 0);
 
 					$pdf->SetXY (144, $curY );
 					$pdf->MultiCell(10, 5, $propale->lignes[$i]->qty, 0, 'C', 0);
diff --git a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php
index cb09527cc8b..2239cd973dd 100644
--- a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php
+++ b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php
@@ -207,13 +207,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 				$tab_height_newpage = 180;
 
 				// Affiche notes
-				if ($com->note_public)
+				if (! empty($com->note_public))
 				{
 					$tab_top = 88;
 
 					$pdf->SetFont('Arial','', 9);   // Dans boucle pour g�rer multi-page
 					$pdf->SetXY ($this->posxdesc-1, $tab_top);
-					$pdf->MultiCell(190, 3, $com->note_public, 0, 'J');
+					$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($com->note_public), 0, 'J');
 					$nexY = $pdf->GetY();
 					$height_note=$nexY-$tab_top;
 
-- 
GitLab