diff --git a/htdocs/telephonie/contrat/index.php b/htdocs/telephonie/contrat/index.php index cccd7a32357..c0d6c71c157 100644 --- a/htdocs/telephonie/contrat/index.php +++ b/htdocs/telephonie/contrat/index.php @@ -61,10 +61,11 @@ print '
'; $sql = "SELECT distinct statut, count(*) as cc"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat as l"; -if ($user->rights->telephonie->ligne->lire_restreint) -{ - $sql .= " WHERE l.fk_commercial_suiv = ".$user->id; -} +$sql .= ",".MAIN_DB_PREFIX."societe_perms as sp"; +$sql .= " WHERE l.fk_client_comm = sp.fk_soc"; +$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1"; + + $sql .= " GROUP BY statut"; if ($db->query($sql)) diff --git a/htdocs/telephonie/contrat/stats.php b/htdocs/telephonie/contrat/stats.php index 7102cd23eb7..884f054768e 100644 --- a/htdocs/telephonie/contrat/stats.php +++ b/htdocs/telephonie/contrat/stats.php @@ -117,7 +117,8 @@ if ($_GET["id"]) print ''; $file = $img_root.$contrat->id."/graphgain.png"; - if (file_exists($file)) + + if (file_exists($file) && $user->rights->telephonie->ligne->gain) { print 'CA Mensuel'; }