diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 2768b7a24f2..0386eabc03c 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -181,6 +181,8 @@ class Societe extends CommonObject
$this->error = $langs->trans("ErrorBadEMail",$this->email);
return -1;
}
+ if (empty($this->client)) $this->client=0;
+ if (empty($this->fournisseur)) $this->fournisseur=0;
$this->db->begin();
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 157d75f7f5a..0b17186f0fb 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -558,11 +558,12 @@ else
/*
* Company Fact creation mode
*/
- if ($_GET["type"]=='f') { $soc->fournisseur=1; }
+ //if ($_GET["type"]=='cp') { $soc->client=3; }
+ if ($_GET["type"]!='f') $soc->client=3;
if ($_GET["type"]=='c') { $soc->client=1; }
- if ($_GET["type"]=='p') { $soc->client=2; }
- if ($_GET["type"]=='cp') { $soc->client=3; }
- if ($_REQUEST["private"]==1) { $soc->particulier=1; }
+ if ($_GET["type"]=='p') { $soc->client=2; }
+ if ($conf->fournisseur->enabled && ($_GET["type"]=='f' || $_GET["type"]=='')) { $soc->fournisseur=1; }
+ if ($_REQUEST["private"]==1) { $soc->particulier=1; }
$soc->nom=$_POST["nom"];
$soc->prenom=$_POST["prenom"];
@@ -717,37 +718,39 @@ else
print '';
- // Supplier
- print '
';
- print '| '.$langs->trans('Supplier').' | ';
- print $form->selectyesno("fournisseur",$soc->fournisseur,1);
- print ' | ';
- print ''.$langs->trans('SupplierCode').' | ';
- print '';
-
- print ' |
';
-
- // Category
- if ($soc->fournisseur)
+ if ($conf->fournisseur->enabled)
{
- $load = $soc->LoadSupplierCateg();
- if ( $load == 0)
- {
- if (sizeof($soc->SupplierCategories) > 0)
- {
- print '';
- print '| '.$langs->trans('SupplierCategory').' | ';
- print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,$_POST["fournisseur_categorie"],1);
- print ' |
';
- }
- }
+ // Supplier
+ print '';
+ print '| '.$langs->trans('Supplier').' | ';
+ print $form->selectyesno("fournisseur",$soc->fournisseur,1);
+ print ' | ';
+ print ''.$langs->trans('SupplierCode').' | ';
+ print '';
+ print ' |
';
+
+ // Category
+ if ($soc->fournisseur)
+ {
+ $load = $soc->LoadSupplierCateg();
+ if ( $load == 0)
+ {
+ if (sizeof($soc->SupplierCategories) > 0)
+ {
+ print '';
+ print '| '.$langs->trans('SupplierCategory').' | ';
+ print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,$_POST["fournisseur_categorie"],1);
+ print ' |
';
+ }
+ }
+ }
}
// Barcode