diff --git a/htdocs/includes/modules/societe/mod_codeclient_tigre.php b/htdocs/includes/modules/societe/mod_codeclient_tigre.php index 6595961d8e6..d4717f1fd8d 100644 --- a/htdocs/includes/modules/societe/mod_codeclient_tigre.php +++ b/htdocs/includes/modules/societe/mod_codeclient_tigre.php @@ -249,7 +249,6 @@ class mod_codeclient_tigre extends ModeleThirdPartyCode else if (is_object($objsoc) && !$objsoc->prefix_comm && $maskElement[$i] == '{pre}') { $maskRebuild .= 'ABC'; - $this->searchcode .= '([0-9A-Z]{1,})'; $error++; $this->prefixIsRequired = 1; } @@ -309,6 +308,23 @@ class mod_codeclient_tigre extends ModeleThirdPartyCode return $maskRebuild; } + + /** + * \brief Vérifie si le mask utilise le préfix + * + */ + function verif_prefixIsUse() + { + global $conf; + + $mask = $conf->global->CODE_TIGRE_MASK_CUSTOMER; + if (eregi('{pre}',$mask)) return 1; + + $mask = $conf->global->CODE_TIGRE_MASK_SUPPLIER; + if (eregi('{pre}',$mask)) return 1; + + return 0; + } /** diff --git a/htdocs/soc.php b/htdocs/soc.php index aaa3563d255..6254805dcb0 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -113,6 +113,25 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) $soc->fournisseur_categorie = $_POST["fournisseur_categorie"]; $soc->commercial_id = $_POST["commercial_id"]; + + // On vérifie si un tiers devient client ou fournisseur pour l'obtention d'un code automatiqe + if ($soc->client && $soc->code_client == -1) + { + $soc->code_client = -1; + } + else + { + $soc->code_client = ''; + } + + if ($soc->fournisseur && $soc->code_fournisseur == -1) + { + $soc->code_fournisseur = -1; + } + else + { + $soc->code_fournisseur = ''; + } if ($_POST["action"] == 'add') { @@ -158,10 +177,6 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) $oldsoc=new Societe($db); $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 == -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 +361,8 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || print '
'; if ($modCodeClient->code_auto == 1) { - if ($soc->client == 1 || $soc->client == 2) print ''; + print ''; + print ''; print $langs->trans('AutomaticallyGenerated').' '; } else @@ -369,7 +385,8 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || print ''; print ''; // Client / Prospect
'; if ($modCodeFournisseur->code_auto == 1) { - if ($soc->fournisseur == 1) print ''; + print ''; + print ''; print $langs->trans('AutomaticallyGenerated').' '; } else @@ -660,7 +677,16 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') print '
'.$langs->trans('Name').'
'.$langs->trans("Prefix").''; - print ''; + // On ne permet pas la modification du préfix en mode de numérotation auto utilisant le prefix + if ($modCodeClient->verif_prefixIsUse() && $modCodeClient->code_auto) + { + print ''; + print $soc->prefix_comm; + } + else + { + print ''; + } print '