diff --git a/htdocs/client.class.php b/htdocs/client.class.php index 6676e5f1573..487728a6009 100644 --- a/htdocs/client.class.php +++ b/htdocs/client.class.php @@ -90,13 +90,16 @@ class Client extends Societe */ function load_state_board() { - global $conf; + global $conf, $user; $this->nb=array(); $sql = "SELECT count(s.idp) as nb, s.client"; + if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client in (1,2)"; + if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY s.client"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/fourn/fournisseur.class.php b/htdocs/fourn/fournisseur.class.php index 721afaf68f7..dd3e9c4ff65 100644 --- a/htdocs/fourn/fournisseur.class.php +++ b/htdocs/fourn/fournisseur.class.php @@ -172,13 +172,16 @@ class Fournisseur extends Societe */ function load_state_board() { - global $conf; + global $conf, $user; $this->nb=array(); $sql = "SELECT count(s.idp) as nb"; + if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; + if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id; $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 02f866ca061..f8a04335fd9 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2005-2006 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1941,13 +1942,23 @@ function get_each_prod() */ function load_state_board() { - global $conf; + global $conf, $user; $this->nb=array(); $sql = "SELECT count(p.rowid) as nb"; $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 ca"; + } $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 = ca.rowid AND ca.visible = 1"; + } $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/service.class.php b/htdocs/service.class.php index 1a9c3339162..fb28eabcf36 100644 --- a/htdocs/service.class.php +++ b/htdocs/service.class.php @@ -200,13 +200,23 @@ class Service */ function load_state_board() { - global $conf; + global $conf, $user; $this->nb=array(); $sql = "SELECT count(p.rowid) as nb"; $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 ca"; + } $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 = ca.rowid AND ca.visible = 1"; + } $resql=$this->db->query($sql); if ($resql) {