diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index dd98284194d..3b0e03faef6 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -52,10 +52,24 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer) $product->duration_value = $_POST["duration_value"]; $product->duration_unit = $_POST["duration_unit"]; $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; + + $e_product = $product; $id = $product->create($user); - Header("Location: fiche.php?id=$id"); + if ($id > 0) + { + Header("Location: fiche.php?id=$id"); + } + else + { + if ($id == -3) + { + $_error = 1; + $_GET["action"] = "create"; + $_GET["type"] = $_POST["type"]; + } + } } if ($_POST["action"] == 'update' && @@ -206,21 +220,32 @@ llxHeader("","","Fiche produit"); */ if ($_GET["action"] == 'create') { + $html = new Form($db); $nbligne=0; - + $product = new Product($db); + if ($_error == 1) + { + $product = $e_product; + } - print "
\n"; - print "\n"; + print ''; + print ''; print ''."\n"; print '
Nouveau '.$types[$_GET["type"]].'

'."\n"; print ''; print ''; - print ''; - print "".''; - print "".''; - print "".''; + print ''; + print ''; + print ''; print '
Référence
Libellé
Prix de vente
Taux TVA'; - $html = new Form($db); + print 'Référence'; + if ($_error == 1) + { + print "Cette référence existe déjà"; + } + print '
Libellé
Prix de vente
Taux TVA'; + + print $html->select_tva("tva_tx"); print '
Statut'; @@ -279,7 +304,7 @@ else print ''; print ''; print '
'; - print ''; + print ''; print $langs->trans("Ref").':  '; print '
'; print 'Libellé :  ';