diff --git a/htdocs/soc.php b/htdocs/soc.php index d29c65cd061..d519983b8bf 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -52,6 +52,7 @@ if ($_POST["action"] == 'add' or $_POST["action"] == 'update') $soc->siren = $_POST["siren"]; $soc->siret = $_POST["siret"]; $soc->ape = $_POST["ape"]; + $soc->prefix_comm = $_POST["prefix_comm"]; $soc->capital = $_POST["capital"]; $soc->tva_intra = $_POST["tva_intra_code"] . $_POST["tva_intra_num"]; $soc->forme_juridique_code = $_POST["forme_juridique_code"]; @@ -61,7 +62,16 @@ if ($_POST["action"] == 'add' or $_POST["action"] == 'update') if ($_POST["action"] == 'update') { - $soc->update($_GET["socid"]); + $result = $soc->update($_GET["socid"]); + if ($result == -1) + { + $soc->id = $_GET["socid"]; + // doublon sur le prefix comm + $no_reload = 1; + $mesg = "Erreur, le prefix '".$soc->prefix_comm."' existe déjà vous devez en choisir un autre"; + $_GET["action"]= "edit"; + } + } if ($_POST["action"] == 'add') { @@ -160,15 +170,21 @@ elseif ($_GET["action"] == 'edit') if ($_GET["socid"]) { - $soc = new Societe($db); - $soc->id = $_GET["socid"]; - $soc->fetch($_GET["socid"]); - + if ($no_reload <> 1) + { + $soc = new Societe($db); + $soc->id = $_GET["socid"]; + $soc->fetch($_GET["socid"]); + } + print $mesg; print '