From 2e04b0ad5dcd7455448bc430534adea2e6785a14 Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Wed, 13 Sep 2006 08:01:42 +0000
Subject: [PATCH] bugfix

---
 htdocs/admin/produit.php | 87 +++++++++++++++++++++-------------------
 1 file changed, 46 insertions(+), 41 deletions(-)

diff --git a/htdocs/admin/produit.php b/htdocs/admin/produit.php
index 8466eba8e34..5dc1d12a295 100644
--- a/htdocs/admin/produit.php
+++ b/htdocs/admin/produit.php
@@ -48,31 +48,34 @@ else if ($_POST["action"] == 'multiprix_num')
     Header("Location: produit.php");
     exit;
 }
-if ($_POST["action"] == 'multiprix' && $_POST["activate_multiprix"] == 1)
+if ($_POST["action"] == 'multiprix')
 {
-	$res=$db -> desc_table(MAIN_DB_PREFIX."product_price","price_level");
-	if(! $db -> fetch_row())
+	if ($_POST["activate_multiprix"] == 1)
 	{
-		// on ajoute le champ price_level dans la table societe
-		if(! $db -> add_field(MAIN_DB_PREFIX."societe","price_level",$field_desc))
-		{
-			dolibarr_print_error($db);
-			print "<script language='JavaScript'>setTimeout(\"document.location='./produit.php'\",5000);</script>";
-		}
-		// on cr�e la table societe_prices
-		else
-		{
-			$table = MAIN_DB_PREFIX."societe_prices";
-			$fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
-			$fields['fk_soc'] = array('type'=>'int','value'=>'11','null'=>'not null','default'=> '0');
-			$fields['tms'] = array('type'=>'timestamp','value'=>'14','null'=>'not null');
-			$fields['datec'] = array('type'=>'datetime','default'=> 'null');
-			$fields['fk_user_author'] = array('type'=>'int','value'=>'11','default'=> 'null');
-			$fields['price_level'] = array('type'=>'tinyint','value'=>'4','default'=> '1');
-			if(! $db -> create_table($table,$fields,"rowid","InnoDB"))
-			{
-				dolibarr_print_error($db);
-				print "<script language='JavaScript'>setTimeout(\"document.location='./produit.php'\",5000);</script>";
+		$res=$db -> desc_table(MAIN_DB_PREFIX."product_price","price_level");
+	  if(! $db -> fetch_row())
+	  {
+		  // on ajoute le champ price_level dans la table societe
+		  if(! $db -> add_field(MAIN_DB_PREFIX."societe","price_level",$field_desc))
+		  {
+			  dolibarr_print_error($db);
+			  print "<script language='JavaScript'>setTimeout(\"document.location='./produit.php'\",5000);</script>";
+		  }
+		  // on cr�e la table societe_prices
+		  else
+		  {
+			  $table = MAIN_DB_PREFIX."societe_prices";
+			  $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
+			  $fields['fk_soc'] = array('type'=>'int','value'=>'11','null'=>'not null','default'=> '0');
+			  $fields['tms'] = array('type'=>'timestamp','value'=>'14','null'=>'not null');
+			  $fields['datec'] = array('type'=>'datetime','default'=> 'null');
+			  $fields['fk_user_author'] = array('type'=>'int','value'=>'11','default'=> 'null');
+			  $fields['price_level'] = array('type'=>'tinyint','value'=>'4','default'=> '1');
+			  if(! $db -> create_table($table,$fields,"rowid","InnoDB"))
+			  {
+				  dolibarr_print_error($db);
+				  print "<script language='JavaScript'>setTimeout(\"document.location='./produit.php'\",5000);</script>";
+			  }
 			}
 			else
 			{
@@ -85,31 +88,33 @@ if ($_POST["action"] == 'multiprix' && $_POST["activate_multiprix"] == 1)
 	else
 	{
 			dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $_POST["activate_multiprix"]);
-			dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6");
 			Header("Location: produit.php");
 	}
     exit;
 }
-else if ($_POST["action"] == 'sousproduits' && $_POST["activate_sousproduits"] == 1)
+else if ($_POST["action"] == 'sousproduits')
 {
-  $res=$db -> desc_table(MAIN_DB_PREFIX."product_association");
-	if(! $db -> fetch_row())
-	{
-		$table = MAIN_DB_PREFIX."product_association";
-		$fields['fk_product_pere'] = array('type'=>'int','value'=>'11','null'=> 'not null','default'=> '0');
-		$fields['fk_product_fils'] = array('type'=>'int','value'=>'11','null'=> 'not null','default'=> '0');
-		$fields['qty'] = array('type'=>'double','default'=> 'null');
-		$keys['idx_product_association_fk_product_pere'] = "fk_product_pere" ;
-		$keys['idx_product_association_fk_product_fils'] = "fk_product_fils" ;
-		if(! $db -> create_table($table,$fields,"","InnoDB","","",$keys))
-		{
-			dolibarr_print_error($db);
-			print "<script language='JavaScript'>setTimeout(\"document.location='./produit.php'\",5000);</script>";
+  if ($_POST["activate_sousproduits"] == 1)
+  {
+  	$res=$db -> desc_table(MAIN_DB_PREFIX."product_association");
+	  if(! $db -> fetch_row())
+	  {
+		  $table = MAIN_DB_PREFIX."product_association";
+		  $fields['fk_product_pere'] = array('type'=>'int','value'=>'11','null'=> 'not null','default'=> '0');
+		  $fields['fk_product_fils'] = array('type'=>'int','value'=>'11','null'=> 'not null','default'=> '0');
+		  $fields['qty'] = array('type'=>'double','default'=> 'null');
+		  $keys['idx_product_association_fk_product_pere'] = "fk_product_pere" ;
+		  $keys['idx_product_association_fk_product_fils'] = "fk_product_fils" ;
+		  if(! $db -> create_table($table,$fields,"","InnoDB","","",$keys))
+		  {
+			  dolibarr_print_error($db);
+			  print "<script language='JavaScript'>setTimeout(\"document.location='./produit.php'\",5000);</script>";
+		  }
 		}
 		else
-		{
-			dolibarr_set_const($db, "PRODUIT_SOUSPRODUITS", $_POST["activate_sousproduits"]);
-			Header("Location: produit.php");
+	  {
+	    dolibarr_set_const($db, "PRODUIT_SOUSPRODUITS", $_POST["activate_sousproduits"]);
+		  Header("Location: produit.php");
 	  }
 	}
 	else
-- 
GitLab