diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index e31c347605e091b48daeb2403b0c36b513540c0e..0c1fda4305aa0afb2ec0229be6a1e8f7e8830fa5 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -432,3 +432,4 @@ MergeThirdparties=Merge third parties ConfirmMergeThirdparties=Are you sure you want to merge this third party into the current one ? All linked objects (invoices, orders, ...) will be moved to current third party so you will be able to delete the duplicate one. ThirdpartiesMergeSuccess=Thirdparties have been merged ErrorThirdpartiesMerge=There was an error when deleting the thirdparties. Please check the log. Changes have been reverted. +NewCustomerSupplierCodeProposed=New customer or supplier proposed on duplicate code diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 012aaf374e28f8a93dd51fc042fcbcc2428e8e36..3c4343f322cbebb9ff0195421cbb64a325676851 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -437,7 +437,7 @@ if (empty($reshook)) if (empty($object->fournisseur)) $object->code_fournisseur=''; $result = $object->create($user); - if ($result >= 0) + if ($result >= 0) { if ($object->particulier) { @@ -505,6 +505,13 @@ if (empty($reshook)) } else { + + if($result == -3) { + $duplicate_code_error = true; + $object->code_fournisseur = null; + $object->code_client = null; + } + $error=$object->error; $errors=$object->errors; } @@ -794,8 +801,14 @@ else $object->particulier = $private; $object->prefix_comm = GETPOST('prefix_comm'); $object->client = GETPOST('client')?GETPOST('client'):$object->client; - $object->code_client = GETPOST('code_client', 'alpha'); - $object->fournisseur = GETPOST('fournisseur')?GETPOST('fournisseur'):$object->fournisseur; + + if(empty($duplicate_code_error)) { + $object->code_client = GETPOST('code_client', 'alpha'); + $object->fournisseur = GETPOST('fournisseur')?GETPOST('fournisseur'):$object->fournisseur; + } else { + setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'),'', 'warnings'); + } + $object->code_fournisseur = GETPOST('code_fournisseur', 'alpha'); $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); @@ -1000,7 +1013,7 @@ else print '<td width="25%">'.fieldLabel('CustomerCode','customer_code').'</td><td width="25%">'; print '<table class="nobordernopadding"><tr><td>'; - $tmpcode=$object->code_client; + $tmpcode=$object->code_client; if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0); print '<input type="text" name="code_client" id="customer_code" size="16" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">'; print '</td><td>';