From 48efabc8a45aec5a7d591c991e6698797e05218e Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Wed, 15 Aug 2012 09:06:36 +0200
Subject: [PATCH] Fix: remove deprecated function and avoid warnings

---
 htdocs/core/modules/modProduct.class.php      |  7 +++++++
 htdocs/core/modules/modSociete.class.php      | 14 +++++++++++++
 .../product/mod_codeproduct_elephant.php      | 16 ++++++++-------
 .../societe/mod_codeclient_elephant.php       |  3 +--
 .../societe/mod_codecompta_aquarium.php       | 11 +++++-----
 .../societe/mod_codecompta_panicum.php        | 12 +++++++----
 htdocs/install/mysql/data/llx_const.sql       | 11 ++--------
 .../install/mysql/migration/3.2.0-3.3.0.sql   |  5 +++--
 htdocs/product/admin/product.php              | 10 +++++-----
 htdocs/product/fiche.php                      | 13 ++++++------
 htdocs/societe/admin/societe.php              | 20 ++++++++++---------
 .../canvas/actions_card_common.class.php      |  5 ++---
 htdocs/societe/soc.php                        | 10 ++++------
 13 files changed, 77 insertions(+), 60 deletions(-)

diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index 5f663f26a80..1f7b71ce30a 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -77,6 +77,13 @@ class modProduct extends DolibarrModules
 		$this->const = array();
 		$r=0;
 
+		$this->const[$r][0] = "PRODUCT_CODEPRODUCT_ADDON";
+		$this->const[$r][1] = "chaine";
+		$this->const[$r][2] = "mod_codeproduct_leopard";
+		$this->const[$r][3] = 'Module to control product codes';
+		$this->const[$r][4] = 0;
+		$r++;
+
 		$this->const[$r][0] = "MAIN_SEARCHFORM_PRODUITSERVICE";
 		$this->const[$r][1] = "yesno";
 		$this->const[$r][2] = "1";
diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php
index 73cd9bb303b..9cd60f23b7c 100644
--- a/htdocs/core/modules/modSociete.class.php
+++ b/htdocs/core/modules/modSociete.class.php
@@ -74,6 +74,20 @@ class modSociete extends DolibarrModules
 		// Constantes
 		$this->const = array();
 		$r=0;
+
+		$this->const[$r][0] = "SOCIETE_CODECLIENT_ADDON";
+		$this->const[$r][1] = "chaine";
+		$this->const[$r][2] = "mod_codeclient_leopard";
+		$this->const[$r][3] = 'Module to control third parties codes';
+		$this->const[$r][4] = 0;
+		$r++;
+
+		$this->const[$r][0] = "SOCIETE_CODECOMPTA_ADDON";
+		$this->const[$r][1] = "chaine";
+		$this->const[$r][2] = "mod_codecompta_panicum";
+		$this->const[$r][3] = 'Module to control third parties codes';
+		$this->const[$r][4] = 0;
+		$r++;
 
 		$this->const[$r][0] = "SOCIETE_FISCAL_MONTH_START";
 		$this->const[$r][1] = "chaine";
diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php
index 437e9e6f4e8..3c6075f942a 100644
--- a/htdocs/core/modules/product/mod_codeproduct_elephant.php
+++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php
@@ -69,11 +69,10 @@ class mod_codeproduct_elephant extends ModeleProductCode
 	function info($langs)
 	{
 		global $conf, $mc;
+		global $form;
 
 		$langs->load("products");
 
-		$form = new Form($this->db);
-
 		$disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled="disabled"' : '');
 
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
@@ -91,7 +90,7 @@ class mod_codeproduct_elephant extends ModeleProductCode
 
 		// Parametrage du prefix customers
 		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):</td>';
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT.'"'.$disabled.'>',$tooltip,1,1).'</td>';
+		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)?$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT:'').'"'.$disabled.'>',$tooltip,1,1).'</td>';
 
 		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
 
@@ -99,7 +98,7 @@ class mod_codeproduct_elephant extends ModeleProductCode
 
 		// Parametrage du prefix suppliers
 		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("ServiceCodeModel").'):</td>';
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->PRODUCT_ELEPHANT_MASK_SERVICE.'"'.$disabled.'>',$tooltip,1,1).'</td>';
+		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.(! empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)?$conf->global->PRODUCT_ELEPHANT_MASK_SERVICE:'').'"'.$disabled.'>',$tooltip,1,1).'</td>';
 		$texte.= '</tr>';
 
 		$texte.= '</table>';
@@ -166,9 +165,12 @@ class mod_codeproduct_elephant extends ModeleProductCode
 
 		// Get Mask value
 		$mask = '';
-		if ($type==0) $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
-		if ($type==1) $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
-		if (! $mask)
+		if ($type == 0 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT))
+			$mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
+		else if ($type == 1 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE))
+			$mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
+
+		if (empty($mask))
 		{
 			$this->error='NotConfigured';
 			return '';
diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php
index a221a256e69..e0388366bb4 100644
--- a/htdocs/core/modules/societe/mod_codeclient_elephant.php
+++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php
@@ -69,11 +69,10 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
 	function info($langs)
 	{
 		global $conf, $mc;
+		global $form;
 
 		$langs->load("companies");
 
-		$form = new Form($this->db);
-
 		$disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled="disabled"' : '');
 
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php
index 7f8f14d5703..7fb6ca02cba 100644
--- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php
+++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php
@@ -60,11 +60,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
 	function info($langs)
 	{
 	    global $conf;
+	    global $form;
 
 		$langs->load("companies");
 
-		$form = new Form($this->db);
-
         $tooltip='';
 		$texte = '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
 		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -110,14 +109,14 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
 		$i = 0;
 		$this->db = $db;
 
-		dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".$societe->nom);
+		dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->nom)?$societe->nom:''));
 
 		// Regle gestion compte compta
 		$codetouse='';
 		if ($type == 'customer') $codetouse = $this->prefixcustomeraccountancycode;
 		if ($type == 'supplier') $codetouse = $this->prefixsupplieraccountancycode;
-		if ($type == 'customer') $codetouse.= ($societe->code_client?$societe->code_client:'CUSTCODE');
-		if ($type == 'supplier') $codetouse.= ($societe->code_fournisseur?$societe->code_fournisseur:'SUPPCODE');
+		if ($type == 'customer') $codetouse.= (! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
+		if ($type == 'supplier') $codetouse.= (! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
 		$codetouse=strtoupper(preg_replace('/([^a-z0-9])/i','',$codetouse));
 
 		$is_dispo = $this->verif($db, $codetouse, $societe, $type);
@@ -154,7 +153,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
 		if ($type == 'customer') $sql.= "code_compta";
 		if ($type == 'supplier') $sql.= "code_compta_fournisseur";
 		$sql.= " = '".$this->db->escape($code)."'";
-		if ($societe->id > 0) $sql.= " AND rowid <> ".$societe->id;
+		if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id;
 
 		$resql=$db->query($sql);
 		if ($resql)
diff --git a/htdocs/core/modules/societe/mod_codecompta_panicum.php b/htdocs/core/modules/societe/mod_codecompta_panicum.php
index 3946b9d1569..d0df0b3cb51 100644
--- a/htdocs/core/modules/societe/mod_codecompta_panicum.php
+++ b/htdocs/core/modules/societe/mod_codecompta_panicum.php
@@ -77,10 +77,14 @@ class mod_codecompta_panicum extends ModeleAccountancyCode
 	 */
 	function get_code($db, $societe, $type='')
 	{
-		// Renvoie toujours ok
-		if ($type == 'supplier') $this->code = $societe->code_compta_fournisseur;
-	    else $this->code = $societe->code_compta;
-		return 0;
+		$this->code='';
+
+		if (is_object($societe)) {
+			if ($type == 'supplier') $this->code = (! empty($societe->code_compta_fournisseur)?$societe->code_compta_fournisseur:'');
+			else $this->code = (! empty($societe->code_compta)?$societe->code_compta:'');
+		}
+
+		return 0; // return ok
 	}
 }
 
diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql
index 8d7434e80a6..3b805222b4b 100644
--- a/htdocs/install/mysql/data/llx_const.sql
+++ b/htdocs/install/mysql/data/llx_const.sql
@@ -3,7 +3,7 @@
 -- Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
 -- Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
 -- Copyright (C) 2004      Guillaume Delecourt  <guillaume.delecourt@opensides.be>
--- Copyright (C) 2005-2011 Regis Houssin        <regis@dolibarr.fr>
+-- Copyright (C) 2005-2012 Regis Houssin        <regis@dolibarr.fr>
 -- Copyright (C) 2007 	   Patrick Raguin       <patrick.raguin@gmail.com>
 --
 -- This program is free software; you can redistribute it and/or modify
@@ -79,17 +79,10 @@ insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_TRA
 --
 -- Tiers
 --
-insert into llx_const (name, value, type, note, visible, entity) values('SOCIETE_NOLIST_COURRIER','1','yesno','Liste les fichiers du repertoire courrier',0,0);
-insert into llx_const (name, value, type, note, visible) values('SOCIETE_CODECLIENT_ADDON','mod_codeclient_leopard','yesno','Module to control third parties codes',0);
-insert into llx_const (name, value, type, note, visible) values('SOCIETE_CODECOMPTA_ADDON','mod_codecompta_panicum','yesno','Module to control third parties codes',0);
+insert into llx_const (name, value, type, note, visible, entity) values ('SOCIETE_NOLIST_COURRIER','1','yesno','Liste les fichiers du repertoire courrier',0,0);
 
 
 --
 -- Mail Mailing
 --
 insert into llx_const (name, value, type, note, visible) values ('MAILING_EMAIL_FROM','dolibarr@domain.com','chaine','EMail emmetteur pour les envois d emailings',0);
-
---
--- Product
---
-insert into llx_const (name, value, type, note, visible) values('PRODUCT_CODEPRODUCT_ADDON','mod_codeproduct_leopard','yesno','Module to control product codes',0);
\ No newline at end of file
diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
index fd93777605c..775447fc03f 100755
--- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
+++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
@@ -43,8 +43,8 @@ ALTER TABLE llx_mailing MODIFY COLUMN body mediumtext;
 ALTER TABLE llx_mailing ADD COLUMN extraparams varchar(255);
 
 
-ALTER TABLE llx_product MODIFY ref                       varchar(128)  NOT NULL;
-ALTER TABLE llx_product MODIFY ref_ext                   varchar(128);
+ALTER TABLE llx_product MODIFY ref varchar(128)  NOT NULL;
+ALTER TABLE llx_product MODIFY ref_ext varchar(128);
 
 ALTER TABLE llx_product_fournisseur_price DROP COLUMN fk_product_fournisseur;
 ALTER TABLE llx_product_fournisseur_price ADD charges DOUBLE( 24, 8 ) DEFAULT 0 AFTER unitprice;
@@ -68,3 +68,4 @@ ALTER TABLE llx_commande CHANGE fk_demand_reason fk_input_reason INT(11) NULL DE
 ALTER TABLE llx_propal CHANGE fk_demand_reason fk_input_reason INT(11) NULL DEFAULT NULL;
 ALTER TABLE llx_commande_fournisseur CHANGE fk_methode_commande fk_input_method INT(11) NULL DEFAULT 0;
 
+INSERT INTO llx_const (name, value, type, note, visible) values ('PRODUCT_CODEPRODUCT_ADDON','mod_codeproduct_leopard','yesno','Module to control product codes',0);
diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php
index 1ac75474ea3..b187f3e1705 100644
--- a/htdocs/product/admin/product.php
+++ b/htdocs/product/admin/product.php
@@ -229,7 +229,7 @@ foreach ($dirproduct as $dirroot)
     			print '<td>'.$modCodeProduct->info($langs).'</td>'."\n";
     			print '<td nowrap="nowrap">'.$modCodeProduct->getExample($langs).'</td>'."\n";
 
-    			if ($conf->global->PRODUCT_CODEPRODUCT_ADDON == "$file")
+    			if (! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) && $conf->global->PRODUCT_CODEPRODUCT_ADDON == $file)
     			{
     				print '<td align="center">'."\n";
     				print img_picto($langs->trans("Activated"),'switch_on');
@@ -295,7 +295,7 @@ print '</form>';
 
 
 // multiprix nombre de prix a proposer
-if($conf->global->PRODUIT_MULTIPRICES)
+if (! empty($conf->global->PRODUIT_MULTIPRICES))
 {
 	$var=!$var;
 	print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
@@ -331,7 +331,7 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="usesearchtoselectproduct">';
 print '<tr '.$bc[$var].'>';
 print '<td>'.$langs->trans("UseSearchToSelectProduct").'</td>';
-if (! $conf->use_javascript_ajax)
+if (empty($conf->use_javascript_ajax))
 {
 	print '<td nowrap="nowrap" align="right" colspan="2">';
 	print $langs->trans("NotAvailableWhenAjaxDisabled");
@@ -392,7 +392,7 @@ if (! empty($conf->global->MAIN_MULTILANGS))
 	print '<tr '.$bc[$var].'>';
 	print '<td>'.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").'</td>';
 	print '<td width="60" align="right">';
-	print $form->selectyesno("activate_viewProdTextsInThirdpartyLanguage",$conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE,1);
+	print $form->selectyesno("activate_viewProdTextsInThirdpartyLanguage", (! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)?$conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE:0), 1);
 	print '</td><td align="right">';
 	print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
 	print '</td>';
@@ -401,7 +401,7 @@ if (! empty($conf->global->MAIN_MULTILANGS))
 }
 
 
-if ($conf->global->PRODUCT_CANVAS_ABILITY)
+if (! empty($conf->global->PRODUCT_CANVAS_ABILITY))
 {
 	// Add canvas feature
 	$dir = DOL_DOCUMENT_ROOT . "/product/canvas/";
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 4aa49ee651a..82899baa08f 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -696,10 +696,9 @@ else
     {
         //WYSIWYG Editor
         require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
-		
+
 		// Load object modCodeProduct
-        $module=$conf->global->PRODUCT_CODEPRODUCT_ADDON;
-        if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined"));
+        $module=(! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON)?$conf->global->PRODUCT_CODEPRODUCT_ADDON:'mod_codeproduct_leopard');
         if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php')
         {
             $module = substr($module, 0, dol_strlen($module)-4);
@@ -711,7 +710,7 @@ else
         print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
         print '<input type="hidden" name="action" value="add">';
         print '<input type="hidden" name="type" value="'.$type.'">'."\n";
-		if ($modCodeProduct->code_auto) print '<input type="hidden" name="code_auto" value="1">';
+		if (! empty($modCodeProduct->code_auto)) print '<input type="hidden" name="code_auto" value="1">';
 
         if ($type==1) $title=$langs->trans("NewService");
         else $title=$langs->trans("NewProduct");
@@ -721,7 +720,7 @@ else
 
         print '<table class="border" width="100%">';
         print '<tr>';
-		if ($modCodeProduct->code_auto) $tmpcode=$modCodeProduct->getNextValue($object,$type);
+		if (! empty($modCodeProduct->code_auto)) $tmpcode=$modCodeProduct->getNextValue($object,$type);
         print '<td class="fieldrequired" width="20%">'.$langs->trans("Ref").'</td><td><input name="ref" size="40" maxlength="32" value="'.$tmpcode.'">';
         if ($_error)
         {
@@ -948,7 +947,7 @@ else
 
             // Description (used in invoice, propal...)
             print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">';
-            
+
             $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 90);
             $doleditor->Create();
 
@@ -1041,7 +1040,7 @@ else
 
             // Note
             print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="2">';
-            
+
             $doleditor = new DolEditor('note', $object->note, '', 200, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 8, 70);
             $doleditor->Create();
 
diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php
index 1fd342baeef..2029d112457 100644
--- a/htdocs/societe/admin/societe.php
+++ b/htdocs/societe/admin/societe.php
@@ -433,8 +433,10 @@ foreach ($dirsociete as $dirroot)
     			$module = new $classname($db);
 
 				$modulequalified=1;
-				if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
-				if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
+				if (! empty($module->version)) {
+					if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
+					else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
+				}
 
 				if ($modulequalified)
 				{
@@ -481,16 +483,16 @@ foreach ($dirsociete as $dirroot)
 					// Info
 					$htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
 					$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
-					if ($modele->type == 'pdf')
+					if ($module->type == 'pdf')
 					{
 						$htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
 					}
 					$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
-					$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraft").': '.yn($module->option_draft_watermark,1,1);
+					$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraft").': '.yn((! empty($module->option_draft_watermark)?$module->option_draft_watermark:''), 1, 1);
 
 
 					print '<td align="center" nowrap="nowrap">';
-					if ($modele->type == 'pdf')
+					if ($module->type == 'pdf')
 					{
 						$linkspec='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
 					}
@@ -547,16 +549,16 @@ while ($i < $nbofloop)
 	switch($i)
 	{
         case 0:
-        	$verif=(!$conf->global->SOCIETE_IDPROF1_UNIQUE?false:true);
+        	$verif=(empty($conf->global->SOCIETE_IDPROF1_UNIQUE)?false:true);
         	break;
         case 1:
-        	$verif=(!$conf->global->SOCIETE_IDPROF2_UNIQUE?false:true);
+        	$verif=(empty($conf->global->SOCIETE_IDPROF2_UNIQUE)?false:true);
         	break;
         case 2:
-        	$verif=(!$conf->global->SOCIETE_IDPROF3_UNIQUE?false:true);
+        	$verif=(empty($conf->global->SOCIETE_IDPROF3_UNIQUE)?false:true);
         	break;
         case 3:
-        	$verif=(!$conf->global->SOCIETE_IDPROF4_UNIQUE?false:true);
+        	$verif=(empty($conf->global->SOCIETE_IDPROF4_UNIQUE)?false:true);
         	break;
 	}
 
diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php
index 89fa329b577..73fc92d5878 100644
--- a/htdocs/societe/canvas/actions_card_common.class.php
+++ b/htdocs/societe/canvas/actions_card_common.class.php
@@ -425,8 +425,7 @@ abstract class ActionsCardCommon
 			}
 
             // Load object modCodeClient
-            $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
-            if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined"));
+            $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard');
             if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
             {
                 $module = substr($module, 0, dol_strlen($module)-4);
@@ -437,7 +436,7 @@ abstract class ActionsCardCommon
                 $res=dol_include_once($dirroot.$module.".php");
                 if ($res) break;
             }
-            $modCodeClient = new $module;
+            $modCodeClient = new $module($db);
             $this->tpl['auto_customercode'] = $modCodeClient->code_auto;
             // We verified if the tag prefix is used
             if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 63eafdbc72e..07b9a7954be 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -514,8 +514,7 @@ else
          */
 
         // Load object modCodeTiers
-        $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
-        if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined"));
+        $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard');
         if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
         {
             $module = substr($module, 0, dol_strlen($module)-4);
@@ -1003,8 +1002,7 @@ else
 
 
             // Load object modCodeTiers
-            $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
-            if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined"));
+            $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard');
             if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
             {
                 $module = substr($module, 0, dol_strlen($module)-4);
@@ -1015,7 +1013,7 @@ else
                 $res=dol_include_once($dirroot.$module.".php");
                 if ($res) break;
             }
-            $modCodeClient = new $module;
+            $modCodeClient = new $module($db);
             // We verified if the tag prefix is used
             if ($modCodeClient->code_auto)
             {
@@ -1033,7 +1031,7 @@ else
                 $res=dol_include_once($dirroot.$module.".php");
                 if ($res) break;
             }
-            $modCodeFournisseur = new $module;
+            $modCodeFournisseur = new $module($db);
             // On verifie si la balise prefix est utilisee
             if ($modCodeFournisseur->code_auto)
             {
-- 
GitLab