diff --git a/htdocs/telephonie/script/graph-statistiques-commerciaux.php b/htdocs/telephonie/script/graph-statistiques-commerciaux.php index 6d3082b265c..e5f2842c14b 100644 --- a/htdocs/telephonie/script/graph-statistiques-commerciaux.php +++ b/htdocs/telephonie/script/graph-statistiques-commerciaux.php @@ -19,9 +19,7 @@ * $Source$ * * - * Generation des graphiques - * - * + * Generation des graphiques relatifs aux commerciaux * */ require ("../../master.inc.php"); @@ -48,6 +46,7 @@ $error = 0; $dirs[0] = DOL_DATA_ROOT."/graph/"; $dirs[1] = DOL_DATA_ROOT."/graph/telephonie/"; $dirs[2] = DOL_DATA_ROOT."/graph/telephonie/commercials/"; +$dirs[2] = DOL_DATA_ROOT."/graph/telephonie/distributeurs/"; $img_root = DOL_DATA_ROOT."/graph/telephonie/"; @@ -115,6 +114,29 @@ if ($resql) $i++; } } +/* + * Distributeurs + * + */ +$sql = "SELECT distinct fk_distributeur"; +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux"; + +$resql = $db->query($sql); +if ($resql) +{ + while ($row = $db->fetch_row($resql)) + { + /* Gain */ + + $dir = $img_root . "distributeurs/".$row[0]."/"; + _cdir($dir); + $file = $dir."gain.mensuel.png"; + if ($verbose) print "Graph : gain distributeur $file\n"; + $graph = new GraphDistributeurGain($db, $file); + $graph->width = 400; + $graph->GraphMakeGraph($row[0]); + } +} /* * Groupes * @@ -148,13 +170,10 @@ if ($resql) $graph->width = 400; $graph->GraphMakeGraph($row[0]); - $i++; } } - - /* * Contrats * @@ -209,4 +228,21 @@ if ($resql) $graph->GraphMakeGraph($value); } } + +function _cdir($dir) +{ + if (! file_exists($dir)) + { + umask(0); + if (! @mkdir($dir, 0755)) + { + print "Erreur: Le répertoire '$dir' n'existe pas et Dolibarr n'a pu le créer."; + } + else + { + //print $dir ." créé\n"; + } + } +} + ?>