[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * $Id: graph-statistiques-tempsreels.php,v 1.8 2005/12/08 15:24:13 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/graph-statistiques-tempsreels.php,v $ 20 * 21 * Generation de graphiques 22 * 23 */ 24 require ("../../master.inc.php"); 25 $verbose = 0; 26 require_once (DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"); 27 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php"); 28 29 $error = 0; 30 31 $img_root = DOL_DATA_ROOT."/graph/telephonie"; 32 33 $month = strftime("%m",time()); 34 $year = strftime("%Y",time()); 35 36 $sql = "SELECT distinct ligne"; 37 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_import_cdr"; 38 39 $resql = $db->query($sql); 40 41 if ($resql) 42 { 43 while ($row = $db->fetch_row($resql)) 44 { 45 $ligne = new LigneTel($db); 46 $ligne->fetch($row[0]); 47 48 $data = array(); 49 50 $sqla = "SELECT date, sum(duree)"; 51 $sqla .= " FROM ".MAIN_DB_PREFIX."telephonie_import_cdr"; 52 $sqla .= " WHERE ligne = '".$ligne->numero."'"; 53 $sqla .= " GROUP BY date ASC;"; 54 55 $resqla = $db->query($sqla); 56 57 if ($resqla) 58 { 59 while ($rowa = $db->fetch_row($resqla)) 60 { 61 $jour = (substr($rowa[0],0,2) * 1); 62 $data[$jour] = ($rowa[1]/60); 63 } 64 } 65 $total = 0; 66 $datas = array(); 67 $moydatas = array(); 68 for ($i = 0 ; $i < 31 ; $i++) 69 { 70 $j = $i + 1; 71 $datas[$i] = 0; 72 $moydatas[$i] = 0; 73 if ($data[$j]) 74 $datas[$i] = $data[$j]; 75 76 $total = $total + $datas[$i]; 77 $moydatas[$i] = $total / $j; 78 79 $labels[$i] = $j; 80 if (strftime('%u',mktime(12,12,12,$month,$j,$year)) == 6) 81 { 82 $labels[$i] = '(S'; 83 } 84 if (strftime('%u',mktime(12,12,12,$month,$j,$year)) == 7) 85 { 86 $labels[$i] = 'D)'; 87 } 88 } 89 90 $img_root = DOL_DATA_ROOT."/graph/".substr($ligne->id,-1)."/telephonie/ligne/"; 91 92 $file = $img_root . $ligne->id."/conso.png"; 93 //print $ligne->id . " ".$ligne->numero."\n"; 94 $graph = new Graph(800, 400,"auto"); 95 $graph->SetScale("textlin"); 96 $graph->yaxis->scale->SetGrace(20); 97 $graph->SetFrame(true); 98 $graph->img->SetMargin(50,20,20,35); 99 $graph->xaxis->scale->SetGrace(20); 100 101 $graph->title->Set("Consommation en cours (en minutes)"); 102 $graph->xaxis->SetTickLabels($labels); 103 104 $b2plot = new LinePlot($datas); 105 $b2plot->SetWeight(2); 106 $b2plot->SetColor("red"); 107 $b2plot->SetLegend("réel"); 108 $graph->Add($b2plot); 109 110 $lineplot = new LinePlot($moydatas); 111 $lineplot->SetColor("blue"); 112 $lineplot->SetLegend("moyenne"); 113 $graph->Add($lineplot); 114 115 $graph->img->SetImgFormat("png"); 116 117 $graph->legend->Pos(0.08,0.08,"left","top"); 118 119 $graph->Stroke($file); 120 } 121 } 122 else 123 { 124 print $db->error(); 125 } 126 127 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |