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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
| <?php
include ("jpgraph/src/jpgraph.php");
include ("jpgraph/src/jpgraph_bar.php");
include ("jpgraph/src/jpgraph_line.php");
include('connexion.php');
$tableaucalls = array();
$tableautime = array();
$tableauuser = array();
$max = 0;
//formulaire
if(isset($_REQUEST['query_date']) && isset($_REQUEST['end_date']))
{
$query_date=$_REQUEST['query_date'];
$end_date=$_REQUEST['end_date'];
}
// **********************
// Extraction des données
// **********************
$sql =
"SELECT user as user ,
COUNT( * ) AS calls,
(SUM( pause_sec ) * 0.02 + SUM( wait_sec ) * 0.02 + SUM( dispo_sec ) * 0.02) as time
FROM vicidial_agent_log
WHERE lead_id IS NOT NULL
and event_time <= '".$query_date." 23:59:59' and event_time >='".$end_date." 00:00:00 '
GROUP BY user
HAVING calls > 0 ";
$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;
$tableauuser[$i]= 'user';
}*/
// Récupération des données
while ($row_type_user = mysql_fetch_array($mysqlQuery, MYSQL_ASSOC))
{
if ($row_type_user['calls'] + $row_type_user['time']!=0)
{
$tableaucalls[] = $row_type_user['calls'];
$tableautime[] = $row_type_user['time'];
$tableauuser[] = $row_type_user['user'];
}
//$row_type_user['user']-1
if ($max < $row_type_user['calls']) $max = $row_type_user['calls'];
}
mysql_close();
// *********************
// Création du graphique
// *********************
$graph = new Graph(600,500);
$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($tableauuser);
$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("timeAgent (min)");
// 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("calls");
// Envoyer au navigateur
$graph->Stroke();
?> |
Partager