diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 8e73875aeb3..7b46e674004 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -87,62 +87,62 @@ if ($_GET["action"] == 'remove_fourn')
if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
- $product = new Product($db);
- if( $product->fetch($_GET["id"]) )
+ $product = new Product($db);
+ if( $product->fetch($_GET["id"]) )
{
- $db->begin();
-
- $error=0;
-
- if ($_POST["ref_fourn"])
+ $db->begin();
+
+ $error=0;
+
+ if ($_POST["ref_fourn"])
{
- $ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]);
- if ($ret < 0)
- {
- $error++;
- $mesg='
'.$product->error.'
';
- }
+ $ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]);
+ if ($ret < 0)
+ {
+ $error++;
+ $mesg=''.$product->error.'
';
+ }
}
- else
+ else
{
- $error++;
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->trans("Ref")).'
';
+ $error++;
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->trans("Ref")).'
';
}
-
- if ($_POST["qty"])
+
+ if ($_POST["qty"])
{
- if ($_POST["price"] > 0)
- {
- $ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
- if ($ret < 0)
- {
- $error++;
- $mesg=''.$product->error.'
';
- if ($ret == -2)
- {
- $mesg=''.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'
';
- }
- }
- }
+ if ($_POST["price"] >= 0)
+ {
+ $ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
+ if ($ret < 0)
+ {
+ $error++;
+ $mesg=''.$product->error.'
';
+ if ($ret == -2)
+ {
+ $mesg=''.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'
';
+ }
+ }
+ }
else
- {
- $error++;
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->trans("Price")).'
';
- }
+ {
+ $error++;
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->trans("Price")).'
';
+ }
}
- else
+ else
{
- $error++;
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->trans("Qty")).'
';
+ $error++;
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->trans("Qty")).'
';
}
-
- if (! $error)
+
+ if (! $error)
{
- $db->commit();
- }
- else {
- $db->rollback();
+ $db->commit();
}
+ else {
+ $db->rollback();
+ }
}
}
@@ -215,45 +215,45 @@ if ($_GET["id"] || $_GET["ref"])
// Formulaire ajout prix
- if ($_GET["action"] == 'add_price' && $user->rights->produit->creer)
- {
- $langs->load("suppliers");
-
- if ($_GET["id_fourn"]) {
- print_fiche_titre($langs->trans("ChangeSupplierPrice"));
- } else {
- print_fiche_titre($langs->trans("AddSupplierPrice"));
- }
- print '';
+ }
+
/* ************************************************************************** */
/* */
/* Barre d'action */