From 9540dfb03d241676fe4e64cb5362d0e7c85378ad Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 6 Nov 2007 23:14:59 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20module=20num=E9rotation=20automatique?= =?UTF-8?q?=20tigre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/soc.php | 16 ++++++++-------- htdocs/societe.class.php | 9 +++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/soc.php b/htdocs/soc.php index f730ee53614..d4d99cf933f 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -159,8 +159,8 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) $result=$oldsoc->fetch($socid); // On vérifie si un tiers devient client ou fournisseur pour l'obtention d'un code automatiqe - if (!$soc->client && $soc->code_client == "automaticCode") $soc->code_client = ''; - if (!$soc->fournisseur && $soc->code_fournisseur == "automaticCode") $soc->code_fournisseur = ''; + if (!$soc->client && $soc->code_client == -1) $soc->code_client = ''; + if (!$soc->fournisseur && $soc->code_fournisseur == -1) $soc->code_fournisseur = ''; $result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable()); if ($result >= 0) @@ -346,7 +346,7 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || print '
'; if ($modCodeClient->code_auto == 1) { - if ($soc->client == 1 || $soc->client == 2) print ''; + if ($soc->client == 1 || $soc->client == 2) print ''; print $langs->trans('AutomaticallyGenerated').' '; } else @@ -369,7 +369,7 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || print '
'; if ($modCodeFournisseur->code_auto == 1) { - if ($soc->fournisseur == 1) print ''; + if ($soc->fournisseur == 1) print ''; print $langs->trans('AutomaticallyGenerated').' '; } else @@ -672,9 +672,9 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') print ''.$langs->trans('CustomerCode').''; print '
'; - if (!$soc->code_client && $modCodeClient->code_auto == 1) + if (((!$soc->client && !$soc->code_client)|| $soc->code_client == -1) && $modCodeClient->code_auto == 1) { - if (!$soc->client) print ''; + print ''; print $langs->trans('AutomaticallyGenerated').' '; } else if ($soc->codeclient_modifiable()) @@ -701,9 +701,9 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') print ''.$langs->trans('SupplierCode').''; print '
'; - if (!$soc->code_fournisseur && $modCodeFournisseur->code_auto == 1) + if (((!$soc->fournisseur && !$soc->code_fournisseur) || $soc->code_fournisseur == -1) && $modCodeFournisseur->code_auto == 1) { - if (!$soc->fournisseur) print ''; + print ''; print $langs->trans('AutomaticallyGenerated').' '; } else if ($soc->codefournisseur_modifiable()) diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 7b73c8b4d7d..c403815b516 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -115,6 +115,7 @@ class Societe $this->typent_id = 0; $this->effectif_id = 0; $this->forme_juridique_code = 0; + $this->prefixIsRequired = 0; return 1; } @@ -137,8 +138,8 @@ class Societe $this->db->begin(); // Pour code automatique - if ($this->code_client == "automaticCode") $this->get_codeclient($this->prefix_comm,0); - if ($this->code_fournisseur == "automaticCode") $this->get_codefournisseur($this->prefix_comm,1); + if ($this->code_client == -1) $this->get_codeclient($this->prefix_comm,0); + if ($this->code_fournisseur == -1) $this->get_codefournisseur($this->prefix_comm,1); $result = $this->verify(); @@ -331,8 +332,8 @@ class Societe $this->forme_juridique_code=trim($this->forme_juridique_code); // Pour code client/fournisseur automatique - if ($this->code_client == "automaticCode") $this->get_codeclient($this->prefix_comm,0); - if ($this->code_fournisseur == "automaticCode") $this->get_codefournisseur($this->prefix_comm,1); + if ($this->code_client == -1) $this->get_codeclient($this->prefix_comm,0); + if ($this->code_fournisseur == -1) $this->get_codefournisseur($this->prefix_comm,1); $result = $this->verify(); // Verifie que nom obligatoire et code client ok et unique