Possibilite d'avoir un prix d'achat = 0

This commit is contained in:
Rodolphe Quiedeville 2006-12-02 14:13:57 +00:00
parent b5ebdb2040
commit 71645f76fc

View File

@ -87,62 +87,62 @@ if ($_GET["action"] == 'remove_fourn')
if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel")) if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
{ {
$product = new Product($db); $product = new Product($db);
if( $product->fetch($_GET["id"]) ) if( $product->fetch($_GET["id"]) )
{ {
$db->begin(); $db->begin();
$error=0; $error=0;
if ($_POST["ref_fourn"]) if ($_POST["ref_fourn"])
{ {
$ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]); $ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]);
if ($ret < 0) if ($ret < 0)
{ {
$error++; $error++;
$mesg='<div class="error">'.$product->error.'</div>'; $mesg='<div class="error">'.$product->error.'</div>';
} }
} }
else else
{ {
$error++; $error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Ref")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Ref")).'</div>';
} }
if ($_POST["qty"]) if ($_POST["qty"])
{ {
if ($_POST["price"] > 0) if ($_POST["price"] >= 0)
{ {
$ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user); $ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user);
if ($ret < 0) if ($ret < 0)
{ {
$error++; $error++;
$mesg='<div class="error">'.$product->error.'</div>'; $mesg='<div class="error">'.$product->error.'</div>';
if ($ret == -2) if ($ret == -2)
{ {
$mesg='<div class="error">'.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'</div>'; $mesg='<div class="error">'.$langs->trans("ProductHasAlreadyReferenceInThisSupplier").'</div>';
} }
} }
} }
else else
{ {
$error++; $error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Price")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Price")).'</div>';
} }
} }
else else
{ {
$error++; $error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Qty")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Qty")).'</div>';
} }
if (! $error) if (! $error)
{ {
$db->commit(); $db->commit();
}
else {
$db->rollback();
} }
else {
$db->rollback();
}
} }
} }
@ -215,44 +215,44 @@ if ($_GET["id"] || $_GET["ref"])
// Formulaire ajout prix // Formulaire ajout prix
if ($_GET["action"] == 'add_price' && $user->rights->produit->creer) if ($_GET["action"] == 'add_price' && $user->rights->produit->creer)
{ {
$langs->load("suppliers"); $langs->load("suppliers");
if ($_GET["id_fourn"]) { if ($_GET["id_fourn"]) {
print_fiche_titre($langs->trans("ChangeSupplierPrice")); print_fiche_titre($langs->trans("ChangeSupplierPrice"));
} else { } else {
print_fiche_titre($langs->trans("AddSupplierPrice")); print_fiche_titre($langs->trans("AddSupplierPrice"));
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">'; print '<form action="fournisseurs.php?id='.$product->id.'" method="post">';
print '<input type="hidden" name="action" value="updateprice">'; print '<input type="hidden" name="action" value="updateprice">';
if ($_GET["id_fourn"]) { if ($_GET["id_fourn"]) {
print '<input type="hidden" name="id_fourn" value="'.$_GET["id_fourn"].'">'; print '<input type="hidden" name="id_fourn" value="'.$_GET["id_fourn"].'">';
$product->fetch_fourn_data($_GET["id_fourn"]); $product->fetch_fourn_data($_GET["id_fourn"]);
print '<input type="hidden" name="ref_fourn" value="'.$product->ref_fourn.'">'; print '<input type="hidden" name="ref_fourn" value="'.$product->ref_fourn.'">';
} else { } else {
print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="3">';
$html=new Form($db); $html=new Form($db);
$html->select_societes('','id_fourn','fournisseur=1'); $html->select_societes('','id_fourn','fournisseur=1');
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">';
print '<input class="flat" name="ref_fourn" size="25" value="">'; print '<input class="flat" name="ref_fourn" size="25" value="">';
print '</td></tr>'; print '</td></tr>';
} }
print '<tr><td>'.$langs->trans("Qty").'</td>'; print '<tr><td>'.$langs->trans("Qty").'</td>';
$quantity = $_GET["qty"] ? $_GET["qty"] : "1"; $quantity = $_GET["qty"] ? $_GET["qty"] : "1";
print '<td><input class="flat" name="qty" size="5" value="'.$quantity.'"></td>'; print '<td><input class="flat" name="qty" size="5" value="'.$quantity.'"></td>';
print '<td>'.$langs->trans("Price").'</td>'; print '<td>'.$langs->trans("Price").'</td>';
print '<td><input class="flat" name="price" size="8" value="'.price($_GET["price"]).'"></td></tr>'; print '<td><input class="flat" name="price" size="8" value="'.price($_GET["price"]).'"></td></tr>';
print '<tr><td colspan="4" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">&nbsp;'; print '<tr><td colspan="4" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">&nbsp;';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</form>'; print '</form>';
print '</table>'; print '</table>';
} }
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */