diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 5267d6245c8..bc5b34ec909 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -51,6 +51,7 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer) $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; $id = $product->create($user); + Header("Location: fiche.php?id=$id"); } @@ -59,7 +60,7 @@ if ($_POST["action"] == 'update' && ( $user->rights->produit->modifier || $user->rights->produit->creer)) { $product = new Product($db); - if ($product->fetch($_GET["id"])) + if ($product->fetch($_POST["id"])) { $product->ref = $_POST["ref"]; @@ -73,26 +74,28 @@ if ($_POST["action"] == 'update' && $product->duration_unit = $_POST["duration_unit"]; if ($product->check()) - { - if ($product->update($_GET["id"], $user)) - { - $action = ''; - $mesg = 'Fiche mise à jour'; - } - else - { - $action = 're-edit'; - $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error; - } - } + { + if ($product->update($product->id, $user)) + { + $_GET["action"] = ''; + $mesg = 'Fiche mise à jour'; + } + else + { + $_GET["action"] = 're-edit'; + $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error; + } + } else - { - $action = 're-edit'; - $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error; - } + { + $_GET["action"] = 're-edit'; + $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error; + } } + Header("Location: fiche.php?id=".$product->id); } + if ($_POST["action"] == 'addinpropal') { $propal = New Propal($db); @@ -108,14 +111,14 @@ if ($_POST["action"] == 'addinpropal') $mesg = ucfirst($types[$type]) . ' ajouté à la proposition '; $mesg .= ''.$propal->ref.''; } - $action = ''; + $_GET["action"] = ''; } if ($_POST["action"] == 'addinfacture' && ( $user->rights->facture->modifier || $user->rights->facture->creer)) { $product = new Product($db); - $result = $product->fetch($id); + $result = $product->fetch($_GET["id"]); $facture = New Facture($db); @@ -124,7 +127,7 @@ if ($_POST["action"] == 'addinfacture' && addslashes($product->libelle), $product->price, $_POST["qty"], - $product->tva_tx, $id); + $product->tva_tx, $product->id); $action = ''; $mesg = 'Produit ajouté à la facture '; @@ -133,6 +136,7 @@ if ($_POST["action"] == 'addinfacture' && if ($_POST["action"] == 'add_fourn' && $_POST["cancel"] <> 'Annuler') { + $product = new Product($db); if( $product->fetch($_GET["id"]) ) { @@ -164,30 +168,36 @@ if ($_GET["action"] == 'remove_fourn') } } + if ($_POST["action"] == 'update_price' && $_POST["cancel"] <> 'Annuler' && ( $user->rights->produit->modifier || $user->rights->produit->creer)) { $product = new Product($db); - $result = $product->fetch($_GET["id"]); - $product->price = $_POST["price"]; - if ( $product->update_price($_GET["id"], $user) > 0 ) + $result = $product->fetch($_GET["id"]); + + $product->price = ereg_replace(" ","",$_POST["price"]); + + + if ( $product->update_price($product->id, $user) > 0 ) + { - $action = ''; + $_GET["action"] = ''; $mesg = 'Fiche mise à jour'; } else { - $action = 'edit_price'; + $_GET["action"] = 'edit_price'; $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error; } } -if ($cancel == 'Annuler') +if ($_POST["cancel"] == 'Annuler') { $action = ''; + Header("Location: fiche.php?id=".$_POST["id"]); } @@ -204,7 +214,8 @@ if ($_GET["action"] == 'create') { $nbligne=0; - print '
'; + + print "\n"; print "\n"; print ''."\n"; print '
Nouveau '.$types[$_GET["type"]].'

'."\n"; @@ -253,16 +264,18 @@ if ($_GET["action"] == 'create') } else { + if ($_GET["id"]) { if ($_GET["action"] <> 're-edit') - { - $product = new Product($db); - $result = $product->fetch($_GET["id"]); - } + { + $product = new Product($db); + $result = $product->fetch($_GET["id"]); + } if ( $result ) { + if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') { /* @@ -272,13 +285,15 @@ else // Zone recherche print ''; print ''; - print '
'; + print ''; + print ''; print 'Réf :  '; print '
'; print 'Libellé :  '; print '
'; print '
'; + $head[0][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; $head[0][1] = 'Fiche'; @@ -304,7 +319,6 @@ else } print ''; print 'Libellé'.$product->libelle.''; - print 'Prix de vente'.price($product->price).''; if ($product->type == 1) { $nblignefour=4; @@ -327,7 +341,7 @@ else $var=True; while ($i < $num) { - $objp = $db->fetch_object( $i); + $objp = $db->fetch_object($i); $var=!$var; print ""; print ''.$objp->nom.''; @@ -394,11 +408,12 @@ else print "
\n"; - if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer) + if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer) { print '
Nouveau prix
'; - print "
id\" method=\"post\">\n"; + print "\n"; print ''; + print ''; print ''; print ''; print '
Prix de vente
 '; @@ -414,8 +429,9 @@ else if ($_GET["action"] == 'ajout_fourn' && $user->rights->produit->creer) { print_titre ("Ajouter un fournisseur"); - print ''; + print ''; print ''; + print ''; print ''; print ''; print '
FournisseursRéférence
 '; @@ -450,9 +467,10 @@ else { print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, $mesg); - print "id\" method=\"post\">\n"; + + print "\n"; print ''; - + print ''; print ''; print "".''; print ''; @@ -572,7 +590,8 @@ print ""; -if ($id && $_GET["action"] == '' && $product->envente) + +if ($_GET["id"] && $_GET["action"] == '' && $product->envente) { $htmls = new Form($db); @@ -602,14 +621,15 @@ if ($id && $_GET["action"] == '' && $product->envente) $var=True; while ($i < $num) { - $objp = $db->fetch_object( $i); + $objp = $db->fetch_object($i); $var=!$var; print ""; print "\n"; print "\n"; print "\n"; - print ''; + print ''; print ''; + print ''; print '\n"; print "\n"; print "\n"; - print ''; + print ''; print ''; + print ''; print '
Référence
Libellé
propalid\">$objp->refidp\">$objp->nom". strftime("%d %B %Y",$objp->dp)."'; print ' Rem.'; print ' %'; @@ -679,8 +699,9 @@ if ($id && $_GET["action"] == '' && $product->envente) print "factureid\">$objp->facnumberidp\">$objp->nom". strftime("%d %B %Y",$objp->df)."'; print ' Rem.'; print ' %';