From ad3f13881bd643001d2bd6f85c8d493956947e28 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Thu, 27 Oct 2011 02:10:23 +0200
Subject: [PATCH] Uniformize constructor Removed deprecated functions

---
 htdocs/core/boxes/box_fournisseurs.php   |  1 -
 htdocs/fourn/class/fournisseur.class.php | 73 +++++++-----------------
 htdocs/product/class/product.class.php   | 22 -------
 htdocs/product/fiche.php                 | 10 ----
 4 files changed, 21 insertions(+), 85 deletions(-)

diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php
index 5ca61023b71..e93f60a84c3 100644
--- a/htdocs/core/boxes/box_fournisseurs.php
+++ b/htdocs/core/boxes/box_fournisseurs.php
@@ -83,7 +83,6 @@ class box_fournisseurs extends ModeleBoxes {
                 $num = $db->num_rows($result);
 
                 $i = 0;
-    			//$supplierstatic=new Fournisseur($db);
                 while ($i < $num)
                 {
                     $objp = $db->fetch_object($result);
diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php
index 153d37e3581..8a3fb8bfd52 100644
--- a/htdocs/fourn/class/fournisseur.class.php
+++ b/htdocs/fourn/class/fournisseur.class.php
@@ -36,18 +36,15 @@ class Fournisseur extends Societe
 	var $db;
 
 	/**
-	 *    \brief  Constructeur de la classe
-	 *    \param  DB     handler acces base de donnees
-	 *    \param  id     id societe (0 par defaut)
+	 *	Constructor
+	 *
+	 *  @param	DoliDB	$db		Database handler
 	 */
-
-	function Fournisseur($DB, $id=0, $user=0)
+	function Fournisseur($db)
 	{
 		global $config;
 
-		$this->db = $DB;
-		$this->id = $id;
-		$this->user = $user;
+		$this->db = $db;
 		$this->client = 0;
 		$this->fournisseur = 0;
 		$this->effectif_id  = 0;
@@ -57,7 +54,12 @@ class Fournisseur extends Societe
 	}
 
 
-	function nb_open_commande()
+	/**
+	 * Return nb of orders
+	 *
+	 * @return 	int		Nb of orders
+	 */
+	function getNbOfOrders()
 	{
 		$sql = "SELECT rowid";
 		$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
@@ -137,44 +139,10 @@ class Fournisseur extends Societe
 	}
 
 
-	function ProductCommande($user, $fk_product)
-	{
-		include_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php");
-		include_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
-
-		$commf = new CommandeFournisseur($this->db);
-
-		$nbc = $this->nb_open_commande();
-
-		dol_syslog("Fournisseur::ProductCommande : nbc = ".$nbc);
-
-		if ($nbc == 0)
-		{
-			if ( $this->create_commande($user) == 0 )
-			{
-				$idc = $this->single_open_commande;
-			}
-		}
-		elseif ($nbc == 1)
-		{
-
-			$idc = $this->single_open_commande;
-		}
-
-		if ($idc > 0)
-		{
-			$prod = new ProductFournisseur($this->db);
-			$prod->fetch($fk_product);
-			//$prod->fetch_fourn_data($this->id);
-
-			$commf->fetch($idc);
-			$commf->addline("Toto",120,1,$prod->tva, $prod->id, 0, $prod->ref_fourn);
-		}
-	}
-
 	/**
-	 *      \brief      Charge indicateurs this->nb de tableau de bord
-	 *      \return     int         <0 si ko, >0 si ok
+	 * Load statistics indicators
+	 *
+	 * @return     int         <0 if KO, >0 if OK
 	 */
 	function load_state_board()
 	{
@@ -213,10 +181,11 @@ class Fournisseur extends Societe
 	}
 
 	/**
-	 *    	\brief      Create a supplier category
-	 *    	\param      user        User asking creation
-	 *		\param		name		Nom categorie
-	 *    	\return     int         <0 si ko, 0 si ok
+	 *  Create a supplier category
+	 *
+	 *  @param      user        User asking creation
+	 *	@param		name		Nom categorie
+	 *  @return     int         <0 if KO, 0 if OK
 	 */
 	function CreateCategory($user, $name)
 	{
@@ -240,9 +209,9 @@ class Fournisseur extends Societe
 	}
 
 	/**
-	 * Retourne la liste des fournisseurs
-	 *
+	 * 	Retourne la liste des fournisseurs
 	 *
+	 *	@return		array		Array of suppliers
 	 */
 	function ListArray()
 	{
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 6fb35027c98..3d200fef7e4 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1896,28 +1896,6 @@ class Product extends CommonObject
 		return $list;
 	}
 
-	/**
-	 *  Saisie une commande fournisseur
-	 *
-	 *	@param		user		Objet user de celui qui demande
-	 *	@return		int			<0 si ko, >0 si ok
-	 */
-	function fastappro($user)
-	{
-		include_once DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php";
-
-		$list = $this->list_suppliers();
-		if (count($list) > 0)
-		{
-			dol_syslog("Product::fastappro");
-			$fournisseur = new Fournisseur($this->db);
-			$fournisseur->fetch($this->fourn_appro_open);
-
-			$fournisseur->ProductCommande($user, $this->id);
-		}
-		return 1;
-	}
-
 	/**
 	 *  Recopie les prix d'un produit/service sur un autre
 	 *
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 9c71db624cd..73aef0952e2 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -115,16 +115,6 @@ if (empty($reshook))
         $action="";
     }
 
-    if ($action == 'fastappro')
-    {
-        $product = new Product($db);
-        $result=$product->fetch($id,$ref);
-        $result=$product->fastappro($user);
-        Header("Location: fiche.php?id=".$product->id);
-        exit;
-    }
-
-
     // Add a product or service
     if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer))
     {
-- 
GitLab