diff --git a/htdocs/product/stats/index.php b/htdocs/product/stats/index.php index 4e7aef8a110..ea17190ee0c 100644 --- a/htdocs/product/stats/index.php +++ b/htdocs/product/stats/index.php @@ -39,14 +39,38 @@ $mesg = ''; * * */ -$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."product WHERE fk_product_type = 0"; +$sql = "SELECT count(*)"; +$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; +if ($conf->categorie->enabled && !$user->rights->categorie->voir) +{ + $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; + $sql .= ", ".MAIN_DB_PREFIX."categorie as c"; +} +$sql .= " WHERE p.fk_product_type = 0"; +if ($conf->categorie->enabled && !$user->rights->categorie->voir) +{ + $sql .= " AND cp.fk_product = p.rowid"; + $sql .= " AND cp.fk_categorie = c.rowid AND c.visible = 1"; +} if ($db->query($sql)) { $row = $db->fetch_row(0); $nbproduct = $row[0]; } $db->free(); -$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."product WHERE envente = 0 AND fk_product_type = 0"; +$sql = "SELECT count(*)"; +$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; +if ($conf->categorie->enabled && !$user->rights->categorie->voir) +{ + $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; + $sql .= ", ".MAIN_DB_PREFIX."categorie as c"; +} +$sql .= " WHERE p.envente = 0 AND p.fk_product_type = 0"; +if ($conf->categorie->enabled && !$user->rights->categorie->voir) +{ + $sql .= " AND cp.fk_product = p.rowid"; + $sql .= " AND cp.fk_categorie = c.rowid AND c.visible = 1"; +} if ($db->query($sql)) { $row = $db->fetch_row(0); @@ -72,14 +96,39 @@ print "