diff --git a/htdocs/product.class.php b/htdocs/product.class.php
index f64160367f8..c6f63f332b6 100644
--- a/htdocs/product.class.php
+++ b/htdocs/product.class.php
@@ -26,7 +26,7 @@ class Product
var $id ;
var $ref;
- var $libelle;
+ var $label;
var $description;
var $price;
var $tva_tx;
@@ -45,6 +45,28 @@ class Product
*
*
*/
+ Function check()
+ {
+ $err = 0;
+ if (strlen(trim($this->ref)) == 0)
+ $err++;
+
+ if (strlen(trim($this->label)) == 0)
+ $err++;
+
+ if ($err > 0)
+ {
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ /*
+ *
+ *
+ */
Function create($user)
{
if (strlen($this->price)==0)
@@ -136,7 +158,7 @@ class Product
if (strlen(trim($this->ref)))
{
$sql = "UPDATE llx_product ";
- $sql .= " SET label = '" . trim($this->libelle) ."'";
+ $sql .= " SET label = '" . trim($this->label) ."'";
$sql .= ",ref = '" . trim($this->ref) ."'";
$sql .= ",tva_tx = " . $this->tva_tx ;
$sql .= ",envente = " . $this->envente ;
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 9ab8f57f66a..8b380f417dd 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -98,18 +98,18 @@ if ($HTTP_POST_VARS["action"] == 'update' &&
$product = new Product($db);
if ($product->fetch($id))
{
+
+ $product->ref = $HTTP_POST_VARS["ref"];
+ $product->label = $HTTP_POST_VARS["libelle"];
+ $product->price = $HTTP_POST_VARS["price"];
+ $product->tva_tx = $HTTP_POST_VARS["tva_tx"];
+ $product->description = $HTTP_POST_VARS["desc"];
+ $product->envente = $HTTP_POST_VARS["statut"];
+ $product->duration_value = $HTTP_POST_VARS["duration_value"];
+ $product->duration_unit = $HTTP_POST_VARS["duration_unit"];
+
if ($product->check())
{
-
- $product->ref = $HTTP_POST_VARS["ref"];
- $product->libelle = $HTTP_POST_VARS["libelle"];
- $product->price = $HTTP_POST_VARS["price"];
- $product->tva_tx = $HTTP_POST_VARS["tva_tx"];
- $product->description = $HTTP_POST_VARS["desc"];
- $product->envente = $HTTP_POST_VARS["statut"];
- $product->duration_value = $HTTP_POST_VARS["duration_value"];
- $product->duration_unit = $HTTP_POST_VARS["duration_unit"];
-
if ( $product->update($id, $user))
{
$action = '';
@@ -117,13 +117,13 @@ if ($HTTP_POST_VARS["action"] == 'update' &&
}
else
{
- $action = 'edit';
+ $action = 're-edit';
$mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error;
}
}
else
{
- $action = 'edit';
+ $action = 're-edit';
$mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error;
}
}
@@ -195,8 +195,11 @@ else
{
if ($id)
{
- $product = new Product($db);
- $result = $product->fetch($id);
+ if ($action <> 're-edit')
+ {
+ $product = new Product($db);
+ $result = $product->fetch($id);
+ }
if ( $result )
{
@@ -283,7 +286,7 @@ else
- if ($action == 'edit' && $user->rights->produit->creer)
+ if (($action == 'edit' || $action == 're-edit') && $user->rights->produit->creer)
{
print '