From 2f81defde46f5a06eebb87ef5fc0e8e12eb43ffc Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 3 Apr 2006 07:58:58 +0000 Subject: [PATCH] =?UTF-8?q?Modification:=20les=20produits=20ne=20faisant?= =?UTF-8?q?=20pas=20partie=20d'une=20cat=E9gorie=20seront=20visible?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/product/index.php | 14 ++++++------- htdocs/product/popuprop.php | 7 +++---- htdocs/product/stats/index.php | 28 +++++++++++-------------- htdocs/product/stock/entrepot.class.php | 7 +++---- htdocs/product/stock/fiche.php | 7 +++---- htdocs/product/stock/mouvement.php | 7 +++---- 6 files changed, 30 insertions(+), 40 deletions(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index f7dcc5756b0..12e1c1e4e88 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -77,10 +77,9 @@ $sql = "SELECT count(*), p.fk_product_type, p.envente"; $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 cp.fk_product = p.rowid"; - $sql .= " AND cp.fk_categorie = c.rowid AND c.visible = 1"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; + $sql.= " WHERE IFNULL(c.visible,1)=1"; } $sql .= " GROUP BY p.fk_product_type, p.envente"; $result=$db->query($sql); @@ -130,10 +129,9 @@ $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.envente"; $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 cp.fk_product = p.rowid"; - $sql .= " AND cp.fk_categorie = c.rowid AND c.visible = 1"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; + $sql.= " WHERE IFNULL(c.visible,1)=1"; } $sql.= " ORDER BY p.datec DESC "; $sql.= $db->plimit($max,0); diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index f598e4cfb8a..9bcefd43d7e 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -72,14 +72,13 @@ $sql = "SELECT p.rowid, p.label, p.ref, fk_product_type, count(*) as c"; $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".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.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; } $sql .= " WHERE p.rowid = pd.fk_product"; 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"; + $sql.= ' AND IFNULL(c.visible,1)=1'; } $sql .= " group by (p.rowid)"; $sql .= " ORDER BY $sortfield $sortorder "; diff --git a/htdocs/product/stats/index.php b/htdocs/product/stats/index.php index d9bdfb939f3..33f08d7b6ea 100644 --- a/htdocs/product/stats/index.php +++ b/htdocs/product/stats/index.php @@ -44,14 +44,13 @@ $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.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; } $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"; + $sql.= ' AND IFNULL(c.visible,1)=1'; } if ($db->query($sql)) { @@ -63,14 +62,13 @@ $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.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; } $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"; + $sql.= ' AND IFNULL(c.visible,1)=1'; } if ($db->query($sql)) { @@ -101,14 +99,13 @@ $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.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; } $sql .= " WHERE p.fk_product_type = 1"; 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"; + $sql.= ' AND IFNULL(c.visible,1)=1'; } if ($db->query($sql)) { @@ -120,14 +117,13 @@ $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.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; } $sql .= " WHERE p.envente = 0 AND p.fk_product_type = 1"; 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"; + $sql.= ' AND IFNULL(c.visible,1)=1'; } if ($db->query($sql)) diff --git a/htdocs/product/stock/entrepot.class.php b/htdocs/product/stock/entrepot.class.php index f2b513249b1..af084f5972c 100644 --- a/htdocs/product/stock/entrepot.class.php +++ b/htdocs/product/stock/entrepot.class.php @@ -287,14 +287,13 @@ class Entrepot $sql .= " FROM llx_product_stock as ps"; if ($conf->categorie->enabled && !$user->rights->categorie->voir) { - $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; - $sql .= ", ".MAIN_DB_PREFIX."categorie as c"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; } $sql .= " WHERE ps.fk_entrepot = ".$this->id; if ($conf->categorie->enabled && !$user->rights->categorie->voir) { - $sql .= " AND cp.fk_product = ps.fk_product"; - $sql .= " AND cp.fk_categorie = c.rowid AND c.visible = 1"; + $sql.= ' AND IFNULL(c.visible,1)=1'; } $result = $this->db->query($sql) ; diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index c1bf3352a9d..ceed64bbc2a 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -278,15 +278,14 @@ else $sql .= " FROM ".MAIN_DB_PREFIX."product_stock ps, ".MAIN_DB_PREFIX."product 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.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; } $sql .= " WHERE ps.fk_product = p.rowid "; $sql .= " AND ps.reel >0 AND ps.fk_entrepot = ".$entrepot->id; 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"; + $sql.= ' AND IFNULL(c.visible,1)=1'; } //$sql .= $db->plimit($limit + 1 ,$offset); diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 9c4c1cd3d38..3cd3252dc5e 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -51,14 +51,13 @@ $sql = "SELECT p.rowid, p.label as produit, s.label as stock, m.value, ".$db->pd $sql .= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."entrepot as s, ".MAIN_DB_PREFIX."stock_mouvement as m"; if ($conf->categorie->enabled && !$user->rights->categorie->voir) { - $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; - $sql .= ", ".MAIN_DB_PREFIX."categorie as c"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; } $sql .= " WHERE m.fk_product = p.rowid AND m.fk_entrepot = s.rowid"; 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"; + $sql.= ' AND IFNULL(c.visible,1)=1'; } $sql .= " ORDER BY $sortfield $sortorder "; $sql .= $db->plimit($limit + 1 ,$offset);