1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
| <?php
include ("jpgraph/src/jpgraph.php");
include ("jpgraph/src/jpgraph_bar.php");
include ("jpgraph/src/jpgraph_line.php");
define('MYSQL_HOST', 'localhost');
define('MYSQL_USER', 'root');
define('MYSQL_PASS', '');
define('MYSQL_DATABASE', 'asterisk');
$tableaucalls = array();
$tableautime = array();
$max = 0;
// **********************
// Extraction des données
// **********************
$sql =
'SELECT user as user ,
COUNT( * ) AS calls,
SUM(pause_sec+wait_sec+talk_sec+dispo_sec+dead_sec) as time
FROM vicidial_agent_log
WHERE lead_id IS NOT NULL
GROUP BY user '
;
$mysqlCnx = @mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die('Pb de connxion mysql');
@mysql_select_db(MYSQL_DATABASE) or die('Pb de sélection de la base');
$mysqlQuery = @mysql_query($sql, $mysqlCnx) or die('Pb de requête: ' . mysql_error());
// Initialisation des tableaux
for ($i=0;$i<=11;$i++) {
$tableaucalls[$i] = 0;
$tableautime[$i] = 0;
}
// Récupération des données
while ($row_type_user = mysql_fetch_array($mysqlQuery, MYSQL_ASSOC)) {
$tableaucalls[$row_type_user['user']-1] = $row_type_user['calls'];
$tableautime[$row_type_user['user']-1] = $row_type_user['time'];
// Récupérer le maximum des ventes
if ($max < $row_type_user['time']) $max = $row_type_user['time'];
}
//printf('<pre>%s</pre>', print_r($volume_Ventes2006,1));exit;
// *********************
// Création du graphique
// *********************
$graph = new Graph(1000,600);
$graph->SetScale("textlin");
$graph->SetMargin(50,40,20,40);
// Désactiver le cadre autour du graphique
$graph->SetFrame(false);
// Ajouter un onglet
$graph->tabtitle->Set("user , calls et time");
$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,10);
// Apparence des grilles
$graph->ygrid->SetFill(true,'#DDDDDD@0.5','#BBBBBB@0.5');
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->SetColor('gray');
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle('dashed');
$graph->xgrid->SetColor('gray');
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
$graph->xaxis->SetLabelAngle(45);
// *******************************
// Créer un graphique histogramme
// *******************************
$oHisto = new BarPlot($tableautime);
$oHisto->SetWidth(0.6);
$oHisto->value->Show();
$oHisto->value->SetFormat('%d');
// dégradé de rouge vers noir à gauche
// Pour chaque barre
$oHisto->SetFillGradient('#440000', '#FF9090', GRAD_LEFT_REFLECTION);
// Bordure autour de chaque histogramme
$oHisto->SetWeight(1);
// Ajouter au graphique
$graph->Add($oHisto);
// ***********************
// Graphique courbe rempli
// ***********************
$oCourbe = new LinePlot($tableaucalls);
// Couleur de remplissage avec transparence
$oCourbe->SetFillColor('skyblue@0.5');
// Couleur de la courbe
$oCourbe->SetColor('navy@0.7');
$oCourbe->SetBarCenter();
// Apparence des points
$oCourbe->mark->SetType(MARK_SQUARE);
$oCourbe->mark->SetColor('blue@0.5');
$oCourbe->mark->SetFillColor('lightblue');
$oCourbe->mark->SetSize(6);
// Affichage des valeurs
$oCourbe->value->Show();
$oCourbe->value->SetFormat('%d');
// Echelle des Y pour le nombre de ventes
$graph->SetYScale(0,'lin', 0, $max * 2);
$graph->xaxis->title->Set("USer/ID");
$graph->yaxis->title->Set("calls");
// Ajouter un axe Y supplémentaire
$graph->AddY(0,$oCourbe);
// Couleur de l'axe Y supplémentaire
$graph->ynaxis[0]->SetColor('red');
$graph->ynaxis[0]->title->Set("time");
// Envoyer au navigateur
$graph->Stroke();
?> |
Partager