Modif de la mise à jour, ajout control référence non nulle

This commit is contained in:
Rodolphe Quiedeville 2003-07-12 10:33:00 +00:00
parent c2a46b4d81
commit 725ae8340b

View File

@ -68,23 +68,31 @@ class Product
*/ */
Function update($id, $user) Function update($id, $user)
{ {
if (strlen(trim($this->ref)))
$sql = "UPDATE llx_product ";
$sql .= " SET label = '" . trim($this->libelle) ."'";
$sql .= ",ref = '" . trim($this->ref) ."'";
$sql .= ",price = " . $this->price ;
$sql .= ",tva_tx = " . $this->tva_tx ;
$sql .= ",description = '" . trim($this->description) ."'";
$sql .= " WHERE rowid = " . $id;
if ( $this->db->query($sql) )
{ {
return 1; $sql = "UPDATE llx_product ";
$sql .= " SET label = '" . trim($this->libelle) ."'";
$sql .= ",ref = '" . trim($this->ref) ."'";
$sql .= ",price = " . ereg_replace(",",".",$this->price);
$sql .= ",tva_tx = " . $this->tva_tx ;
$sql .= ",envente = " . $this->envente ;
$sql .= ",description = '" . trim($this->description) ."'";
$sql .= " WHERE rowid = " . $id;
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error() . ' in ' . $sql;
}
} }
else else
{ {
print $this->db->error() . ' in ' . $sql; $this->mesg_error = "Vous devez indiquer une référence";
return 0;
} }
} }
/* /*
@ -95,7 +103,7 @@ class Product
Function fetch ($id) Function fetch ($id)
{ {
$sql = "SELECT rowid, ref, label, description, price, tva_tx"; $sql = "SELECT rowid, ref, label, description, price, tva_tx, envente, nbvente";
$sql .= " FROM llx_product WHERE rowid = $id"; $sql .= " FROM llx_product WHERE rowid = $id";
$result = $this->db->query($sql) ; $result = $this->db->query($sql) ;
@ -106,10 +114,12 @@ class Product
$this->id = $result["rowid"]; $this->id = $result["rowid"];
$this->ref = $result["ref"]; $this->ref = $result["ref"];
$this->label = $result["label"]; $this->label = stripslashes($result["label"]);
$this->description = $result["description"]; $this->description = stripslashes($result["description"]);
$this->price = $result["price"]; $this->price = $result["price"];
$this->tva_tx = $result["tva_tx"]; $this->tva_tx = $result["tva_tx"];
$this->nbvente = $result["nbvente"];
$this->envente = $result["envente"];
} }
$this->db->free(); $this->db->free();
return $result; return $result;