From e540dd5aef162ca37127d4390c120954f4954e70 Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Wed, 15 Jun 2011 19:53:37 +0000
Subject: [PATCH] Fix: uniformize code Fix: variable conflict

---
 htdocs/commande/class/commande.class.php     | 27 +++++++++++---------
 htdocs/expedition/class/expedition.class.php |  8 +++---
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 3eac7f242b1..37e1c73800b 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -569,12 +569,12 @@ class Commande extends CommonObject
 	}
 
 	/**
-	 *  	\brief		Create order
-	 *		\param		user 	Objet user that make creation
-	 * 		\return 	int		<0 if KO, >0 if OK
-	 *		\remarks	this->ref can be set or empty. If empty, we will use "(PROV)"
+	 *  	Create order
+	 *		@param		user 	Objet user that make creation
+	 * 		@return 	int		<0 if KO, >0 if OK
+	 *		remarks	this->ref can be set or empty. If empty, we will use "(PROV)"
 	 */
-	function create($user)
+	function create($user, $notrigger=0)
 	{
 		global $conf,$langs,$mysoc;
 		$error=0;
@@ -728,13 +728,16 @@ class Commande extends CommonObject
 							}
 						}
 					}
-
-					// Appel des triggers
-					include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
-					$interface=new Interfaces($this->db);
-					$result=$interface->run_triggers('ORDER_CREATE',$this,$user,$langs,$conf);
-					if ($result < 0) { $error++; $this->errors=$interface->errors; }
-					// Fin appel triggers
+					
+					if (! $notrigger)
+					{
+						// Appel des triggers
+						include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+						$interface=new Interfaces($this->db);
+						$result=$interface->run_triggers('ORDER_CREATE',$this,$user,$langs,$conf);
+						if ($result < 0) { $error++; $this->errors=$interface->errors; }
+						// Fin appel triggers
+					}
 
 					$this->db->commit();
 					return $this->id;
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 058e7c04a36..28d8100730c 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -443,18 +443,18 @@ class Expedition extends CommonObject
 		// Define new ref
 		if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref)))
 		{
-			$num = $this->getNextNumRef($soc);
+			$numref = $this->getNextNumRef($soc);
 		}
 		else
 		{
-			$num = "EXP".$this->id;
+			$numref = "EXP".$this->id;
 		}
 
 		$now=dol_now();
 
 		// Validate
 		$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
-		$sql.= " ref='".$num."'";
+		$sql.= " ref='".$numref."'";
 		$sql.= ", fk_statut = 1";
 		$sql.= ", date_valid = '".$this->db->idate($now)."'";
 		$sql.= ", fk_user_valid = ".$user->id;
@@ -542,7 +542,7 @@ class Expedition extends CommonObject
 		// Set new ref
 		if (! $error)
 		{
-			$this->ref = $num;
+			$this->ref = $numref;
 		}
 
 		if (! $error)
-- 
GitLab