From 725ae8340bf0b4675bdaca0ff658311e5dae0c9f Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sat, 12 Jul 2003 10:33:00 +0000 Subject: [PATCH] =?UTF-8?q?Modif=20de=20la=20mise=20=E0=20jour,=20ajout=20?= =?UTF-8?q?control=20r=E9f=E9rence=20non=20nulle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/product.class.php3 | 42 ++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/htdocs/product.class.php3 b/htdocs/product.class.php3 index c79d31e9c25..eae971a0db4 100644 --- a/htdocs/product.class.php3 +++ b/htdocs/product.class.php3 @@ -68,23 +68,31 @@ class Product */ Function update($id, $user) { - - $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) ) + if (strlen(trim($this->ref))) { - 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 { - 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) { - $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"; $result = $this->db->query($sql) ; @@ -106,10 +114,12 @@ class Product $this->id = $result["rowid"]; $this->ref = $result["ref"]; - $this->label = $result["label"]; - $this->description = $result["description"]; + $this->label = stripslashes($result["label"]); + $this->description = stripslashes($result["description"]); $this->price = $result["price"]; $this->tva_tx = $result["tva_tx"]; + $this->nbvente = $result["nbvente"]; + $this->envente = $result["envente"]; } $this->db->free(); return $result;