diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index c948127312d..98f5508a105 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -84,7 +84,8 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREF $sql.= ' WHERE s.entity IN ('.getEntity('societe', 1).')'; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; - +if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible +//print $sql; $result = $db->query($sql); if ($result) { @@ -94,7 +95,7 @@ if ($result) if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; } if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found=1; $third['prospect']++; } if ($conf->fournisseur->enabled && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; } - + if ($conf->societe->enabled && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; } if ($found) $total++; } } @@ -102,13 +103,14 @@ else dol_print_error($db); print ''; print ''; -if ($conf->use_javascript_ajax && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0) >= 2)) +if ($conf->use_javascript_ajax && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2)) { print ''; @@ -153,10 +155,7 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREF $sql.= ' WHERE s.entity IN ('.getEntity('societe', 1).')'; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; -$sql.= " AND ("; -if (! empty($conf->societe->enabled)) $sql.=" s.client IN (1,2,3)"; -if (! empty($conf->fournisseur->enabled)) $sql.=" OR s.fournisseur IN (1)"; -$sql.= ")"; +if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur != 1 OR s.client != 0)"; $sql.= $db->order("s.tms","DESC"); $sql.= $db->plimit($max,0); diff --git a/htdocs/societe/societe.php b/htdocs/societe/societe.php index 49af8146ee7..3de7fe71666 100644 --- a/htdocs/societe/societe.php +++ b/htdocs/societe/societe.php @@ -184,10 +184,7 @@ if (dol_strlen($stcomm)) { $sql.= " AND s.fk_stcomm=".$stcomm; } -if (! $user->rights->societe->lire || ! $user->rights->fournisseur->lire) -{ - if (! $user->rights->fournisseur->lire) $sql.=" AND s.fournisseur != 1"; -} +if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible // Insert sale filter if ($search_sale) {
'.$langs->trans("Statistics").'
'; $dataseries=array(); - if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array('label'=>$langs->trans("Prospects"),'data'=>round($third['prospect'])); - if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array('label'=>$langs->trans("Customers"),'data'=>round($third['customer'])); + if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array('label'=>$langs->trans("Prospects"),'data'=>round($third['prospect'])); + if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array('label'=>$langs->trans("Customers"),'data'=>round($third['customer'])); if ($conf->fournisseur->enabled && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array('label'=>$langs->trans("Suppliers"),'data'=>round($third['supplier'])); + if ($conf->societe->enabled) $dataseries[]=array('label'=>$langs->trans("Others"),'data'=>round($third['other'])); $data=array('series'=>$dataseries); dol_print_graph('stats',300,180,$data,1,'pie',0); print '