From 0add29411946cce195cd241008fbfac05cf7aaa3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 10 Apr 2006 10:20:18 +0000 Subject: [PATCH] =?UTF-8?q?bugfix:=20modification=20de=20la=20fonction=20d?= =?UTF-8?q?e=20v=E9rification=20de=20l'utlisation=20d'un=20produit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/product.class.php | 72 ++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 11 deletions(-) diff --git a/htdocs/product.class.php b/htdocs/product.class.php index e37ff5a974b..b8c7440f10c 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -255,17 +255,67 @@ class Product */ function verif_prod_use($id) { - $sql = "SELECT COUNT(*)"; - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as p, ".MAIN_DB_PREFIX."commandedet as c"; - $sql.= ", ".MAIN_DB_PREFIX."facturedet as f, ".MAIN_DB_PREFIX."contratdet as ct"; - $sql.= " WHERE p.fk_product = ".$id." OR c.fk_product = ".$id." OR f.fk_product = ".$id." OR ct.fk_product = ".$id; - $resql = $this->db->query($sql); - if ($resql) - { - $row = $this->db->fetch_row($resql); - $nbuse = $row[0]; - } - if ($nbuse == 0) + $sqr = 0 + + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."propaldet"; + $sql.= " WHERE fk_product = ".$id; + + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + if ($num != 0) + { + $sqr++; + } + } + + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."facturedet"; + $sql.= " WHERE fk_product = ".$id; + + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + if ($num != 0) + { + $sqr++; + } + } + + + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."commandedet"; + $sql.= " WHERE fk_product = ".$id; + + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + if ($num != 0) + { + $sqr++; + } + } + + + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."contratdet"; + $sql.= " WHERE fk_product = ".$id; + + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + if ($num != 0) + { + $sqr++; + } + } + + if ($sqr == 0) { return 0; }