From 2dc31fa613d75fe29843a90343e3cb470fb6e3c2 Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Thu, 11 Mar 2010 10:40:58 +0000
Subject: [PATCH] Fix: uniformise and clean code

---
 htdocs/commande/commande.class.php          |  2 --
 htdocs/compta/facture/facture-rec.class.php |  1 -
 htdocs/facture.class.php                    | 12 +++++-------
 htdocs/fichinter/fichinter.class.php        |  2 +-
 htdocs/fourn/fournisseur.commande.class.php |  4 ++--
 htdocs/fourn/fournisseur.facture.class.php  |  2 +-
 htdocs/lib/pdf.lib.php                      |  2 +-
 htdocs/projet/project.class.php             |  8 ++++----
 htdocs/propal.class.php                     |  4 ++--
 9 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php
index f0890567b3e..1dedf3dafd3 100644
--- a/htdocs/commande/commande.class.php
+++ b/htdocs/commande/commande.class.php
@@ -2248,7 +2248,6 @@ class Commande extends CommonObject
 			$line->total_ht=100;
 			$line->total_ttc=119.6;
 			$line->total_tva=19.6;
-			$line->produit_id=$prodids[$prodid];
 			$line->fk_product=$prodids[$prodid];
 
 			$this->lignes[$xnbp]=$line; // TODO: deprecated
@@ -2388,7 +2387,6 @@ class OrderLine
 			$this->remise           = $objp->remise;
 			$this->remise_percent   = $objp->remise_percent;
 			$this->fk_remise_except = $objp->fk_remise_except;
-			$this->produit_id       = $objp->fk_product;
 			$this->fk_product       = $objp->fk_product;
 			$this->product_type     = $objp->product_type;
 			$this->info_bits        = $objp->info_bits;
diff --git a/htdocs/compta/facture/facture-rec.class.php b/htdocs/compta/facture/facture-rec.class.php
index 0ada15496a2..96513d50b80 100644
--- a/htdocs/compta/facture/facture-rec.class.php
+++ b/htdocs/compta/facture/facture-rec.class.php
@@ -329,7 +329,6 @@ class FactureRec extends Facture
 				$faclig->tva_tx           = $objp->tva_tx;
 				$faclig->remise_percent   = $objp->remise_percent;
 				$faclig->fk_remise_except = $objp->fk_remise_except;
-				$faclig->produit_id       = $objp->fk_product;
 				$faclig->fk_product       = $objp->fk_product;
 				$faclig->date_start       = $objp->date_start;
 				$faclig->date_end         = $objp->date_end;
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 542515235b7..8c553b63d03 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -305,10 +305,10 @@ class Facture extends CommonObject
 			{
 				foreach ($_facrec->lignes as $i => $val)
 				{
-					if ($_facrec->lignes[$i]->produit_id)
+					if ($_facrec->lignes[$i]->fk_product)
 					{
-						$prod = new Product($this->db, $_facrec->lignes[$i]->produit_id);
-						$res=$prod->fetch($_facrec->lignes[$i]->produit_id);
+						$prod = new Product($this->db, $_facrec->lignes[$i]->fk_product);
+						$res=$prod->fetch($_facrec->lignes[$i]->fk_product);
 					}
 					$tva_tx = get_default_tva($mysoc,$soc,($prod->tva_tx?$prod->tva_tx:0));
 
@@ -318,7 +318,7 @@ class Facture extends CommonObject
 					$_facrec->lignes[$i]->subprice,
 					$_facrec->lignes[$i]->qty,
 					$tva_tx,
-					$_facrec->lignes[$i]->produit_id,
+					$_facrec->lignes[$i]->fk_product,
 					$_facrec->lignes[$i]->remise_percent,
 					'','',0,0,'','HT',0,
 					$_facrec->lignes[$i]->product_type
@@ -697,7 +697,6 @@ class Facture extends CommonObject
 				$faclig->tva_tx           = $objp->tva_tx;
 				$faclig->remise_percent   = $objp->remise_percent;
 				$faclig->fk_remise_except = $objp->fk_remise_except;
-				$faclig->produit_id       = $objp->fk_product;
 				$faclig->fk_product       = $objp->fk_product;
 				$faclig->date_start       = $this->db->jdate($objp->date_start);
 				$faclig->date_end         = $this->db->jdate($objp->date_end);
@@ -2789,7 +2788,7 @@ class Facture extends CommonObject
 			$ligne->total_ttc=107.64;	// 90 * 1.196
 			$ligne->total_tva=17.64;
 			$prodid = rand(1, $num_prods);
-			$ligne->produit_id=$prodids[$prodid];
+			$ligne->fk_product=$prodids[$prodid];
 			$this->lignes[$xnbp]=$ligne;
 			$xnbp++;
 		}
@@ -2933,7 +2932,6 @@ class FactureLigne
 			$this->tva_tx         = $objp->tva_tx;
 			$this->remise_percent = $objp->remise_percent;
 			$this->fk_remise_except = $objp->fk_remise_except;
-			$this->produit_id     = $objp->fk_product;	// Ne plus utiliser
 			$this->fk_product     = $objp->fk_product;
 			$this->product_type   = $objp->product_type;
 			$this->date_start     = $this->db->jdate($objp->date_start);
diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php
index 144aecfd790..58a476a7397 100644
--- a/htdocs/fichinter/fichinter.class.php
+++ b/htdocs/fichinter/fichinter.class.php
@@ -756,7 +756,7 @@ class Fichinter extends CommonObject
 			$ligne->price=100;
 			$ligne->tva_tx=19.6;
 			$prodid = rand(1, $num_prods);
-			$ligne->produit_id=$prodids[$prodid];
+			$ligne->fk_product=$prodids[$prodid];
 			$this->lignes[$xnbp]=$ligne;
 			$xnbp++;
 		}
diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php
index 48af7390db9..37f85cf5536 100644
--- a/htdocs/fourn/fournisseur.commande.class.php
+++ b/htdocs/fourn/fournisseur.commande.class.php
@@ -1445,7 +1445,7 @@ class CommandeFournisseur extends Commande
 			$ligne->tva_tx=19.6;
 			$ligne->ref_fourn='SUPPLIER_REF_'.$xnbp;
 			$prodid = rand(1, $num_prods);
-			$ligne->produit_id=$prodids[$prodid];
+			$ligne->fk_product=$prodids[$prodid];
 			$this->lignes[$xnbp]=$ligne;
 			$xnbp++;
 		}
@@ -1517,7 +1517,7 @@ class CommandeFournisseurLigne extends OrderLine
 			$this->tva_tx           = $objp->tva_tx;
 			$this->remise           = $objp->remise;
 			$this->remise_percent   = $objp->remise_percent;
-			$this->produit_id       = $objp->fk_product;
+			$this->fk_product       = $objp->fk_product;
 			$this->info_bits        = $objp->info_bits;
 			$this->total_ht         = $objp->total_ht;
 			$this->total_tva        = $objp->total_tva;
diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php
index b05f95cfd0d..bf8df957d79 100644
--- a/htdocs/fourn/fournisseur.facture.class.php
+++ b/htdocs/fourn/fournisseur.facture.class.php
@@ -1024,7 +1024,7 @@ class FactureFournisseur extends Facture
 			$ligne->price=100;
 			$ligne->tva_tx=19.6;
 			$prodid = rand(1, $num_prods);
-			$ligne->produit_id=$prodids[$prodid];
+			$ligne->fk_product=$prodids[$prodid];
 			$ligne->product_type=0;
 
 			$this->lignes[$xnbp]=$ligne;
diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php
index c3f5ac626ed..b6a5d3ca86a 100644
--- a/htdocs/lib/pdf.lib.php
+++ b/htdocs/lib/pdf.lib.php
@@ -239,7 +239,7 @@ function pdf_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli
 {
 	global $db, $conf, $langs;
 
-	$idprod=$line->fk_product; if (empty($idprod)) $idprod=$line->produit_id;
+	$idprod=$line->fk_product;
 	$label=$line->label; if (empty($label))  $label=$line->libelle;
 	$desc=$line->desc; if (empty($desc))   $desc=$line->description;
 	$ref_supplier=$line->ref_supplier; if (empty($ref_supplier))   $ref_supplier=$line->ref_fourn;	// TODO Not yeld saved for supplier invoices, only supplier orders
diff --git a/htdocs/projet/project.class.php b/htdocs/projet/project.class.php
index ba98207d772..cc50afd1558 100644
--- a/htdocs/projet/project.class.php
+++ b/htdocs/projet/project.class.php
@@ -663,11 +663,11 @@ class Project extends CommonObject
 		$xnbp = 0;
 		while ($xnbp < $nbp)
 		{
-			$ligne=new Task($this->db);
-			$ligne->desc=$langs->trans("Description")." ".$xnbp;
-			$ligne->qty=1;
+			$line=new Task($this->db);
+			$line->desc=$langs->trans("Description")." ".$xnbp;
+			$line->qty=1;
 			$prodid = rand(1, $num_prods);
-			$ligne->produit_id=$prodids[$prodid];
+			$line->fk_product=$prodids[$prodid];
 			$xnbp++;
 		}
 	}
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index 8dda65efae5..2c1ec1d9e73 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -1958,7 +1958,7 @@ class Propal extends CommonObject
 			$ligne->total_ttc=119.6;
 			$ligne->total_tva=19.6;
 			$prodid = rand(1, $num_prods);
-			$ligne->produit_id=$prodids[$prodid];
+			$ligne->fk_product=$prodids[$prodid];
 			$this->lignes[$xnbp]=$ligne;
 			$xnbp++;
 		}
@@ -2197,7 +2197,7 @@ class PropaleLigne
 			$this->remise         = $objp->remise;
 			$this->remise_percent = $objp->remise_percent;
 			$this->fk_remise_except = $objp->fk_remise_except;
-			$this->produit_id     = $objp->fk_product;
+			$this->fk_product     = $objp->fk_product;
 			$this->info_bits      = $objp->info_bits;
 
 			$this->total_ht       = $objp->total_ht;
-- 
GitLab