[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/telephonie/script/ -> graph-statistiques-fournisseurs.php (source)

   1  <?PHP
   2  /* Copyright (C) 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-fournisseurs.php,v 1.6 2005/10/18 10:29:24 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/graph-statistiques-fournisseurs.php,v $
  20   *
  21   *
  22   * Generation des graphiques sur les founisseurs
  23   *
  24   *
  25   *
  26   */
  27  print strftime("%H:%M:%S",time())."\n";
  28  require  ("../../master.inc.php");
  29  
  30  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
  31  
  32  $img_root = DOL_DATA_ROOT."/graph/telephonie/";
  33  
  34  $Tfourn = array();
  35  $sql = "SELECT rowid, nom";
  36  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_fournisseur";
  37  $resql = $db->query($sql);
  38  
  39  if ($resql)
  40  {
  41    while ($row = $db->fetch_row($resql))
  42      {
  43        $Tfourn[$row[0]] = $row[1];
  44      }
  45  }
  46  
  47  $sql = "SELECT distinct date_format(date, '%m%Y')";
  48  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details";
  49  
  50  $resql = $db->query($sql);
  51  
  52  if ($resql)
  53  {
  54    $Tdate = array();
  55    $Tlegends = array();
  56    while ($row = $db->fetch_row($resql))
  57      {
  58        array_push($Tdate, $row[0]);
  59        array_push($Tlegends, substr($row[0],0,2));
  60      }
  61  }
  62  
  63  $sql = "SELECT fk_fournisseur, date_format(date, '%m%Y'), duree, numero";
  64  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details";
  65  
  66  $resql = $db->query($sql);
  67  
  68  if ($resql)
  69  {
  70    $Ttotal = array();
  71    $Tglobal = array();
  72    $Tinter = array();
  73    $Tnatio = array();
  74    $Tmobil = array();
  75  
  76    $num = $db->num_rows($resql);
  77    $i = 0;
  78  
  79    while ($i < $num)
  80      {
  81        $row = $db->fetch_row($resql);
  82  
  83        if (substr($row[3],0,2) == '00')
  84      {
  85        $Tinter[$row[0]][$row[1]] += $row[2];
  86      }
  87        elseif (substr($row[3],0,2) == '06')
  88      {
  89        $Tmobil[$row[0]][$row[1]] += $row[2];
  90      }
  91        else
  92      {
  93        $Tnatio[$row[0]][$row[1]] += $row[2];
  94      }
  95  
  96        $Ttotal[$row[0]][$row[1]] += $row[2];
  97        $Tglobal[$row[1]] += $row[2];
  98        $i++;
  99      }
 100  }
 101  $titres = array();
 102  $titres["inter"] = "internationales";
 103  $titres["natio"] = "nationales";
 104  $titres["mobil"] = "mobiles";
 105  
 106  $graphs = array("inter","natio","mobil");
 107  $colors = array("yellow","red","blue","pink","orange","green");
 108  foreach($graphs as $graph)
 109  {
 110    $datas = array();
 111    $globals = array();
 112  
 113    $tab = "T".$graph;
 114    foreach ($$tab as $key => $value)
 115      {
 116        $j = 0;
 117        foreach($Tdate as $date)
 118      {
 119        $datas[$key][$j] = ($value[$date]/60000);
 120        $j++;
 121      }
 122        
 123      }
 124    $file = $img_root . "communications/fourn_".$graph.".png";
 125  
 126    $ObjectGraph = new Graph(640,320,"auto");    
 127    $ObjectGraph->SetScale("textlin");
 128    $ObjectGraph->yaxis->scale->SetGrace(20);
 129    $ObjectGraph->xaxis->scale->SetGrace(20);  
 130    $ObjectGraph->img->SetMargin(40,20,20,40);
 131    $ObjectGraph->legend->Pos(0.10,0.12,"left","top");
 132    $i=0;
 133    $plots = array();
 134    foreach ($$tab as $key => $value)
 135      {
 136        $bplot = new BarPlot($datas[$key]);
 137        $bplot->SetFillColor($colors[$i]);
 138        $bplot->SetLegend($Tfourn[$key]);
 139        array_push($plots, $bplot);
 140        $i++;
 141      }
 142     
 143    $gbplot = new GroupBarPlot($plots);
 144  
 145    $ObjectGraph->Add($gbplot);
 146    
 147    $ObjectGraph->title->Set("Nombre de minutes ".$titres[$graph]." par fournisseurs (en milliers)");
 148    $ObjectGraph->xaxis->SetTickLabels($Tlegends);
 149    
 150    $ObjectGraph->img->SetImgFormat("png");
 151    $ObjectGraph->Stroke($file);
 152  }
 153  
 154  /*
 155   * Sum
 156   */
 157  $j = 0;
 158  foreach($Tdate as $date)
 159  {
 160    $globals[$j] = ($Tglobal[$date]/60000);
 161    $j++;
 162  }
 163  
 164  $file = $img_root . "communications/duree.png";
 165  
 166  $ObjectGraph = new Graph(640,200,"auto");
 167  $ObjectGraph->SetScale("textlin");
 168  $ObjectGraph->yaxis->scale->SetGrace(20);
 169  $ObjectGraph->xaxis->scale->SetGrace(20);  
 170  $ObjectGraph->img->SetMargin(40,20,20,40);
 171  
 172  $i=0;
 173  $plots = array();
 174  
 175  $bplot = new BarPlot($globals);
 176  $bplot->SetFillColor("green");
 177  
 178  array_push($plots, $bplot);
 179  
 180  $gbplot = new GroupBarPlot($plots);
 181  
 182  $ObjectGraph->Add($gbplot);
 183  
 184  $ObjectGraph->title->Set("Nombre de minutes (en milliers)");
 185  $ObjectGraph->xaxis->SetTickLabels($Tlegends);
 186  
 187  $ObjectGraph->img->SetImgFormat("png");
 188  $ObjectGraph->Stroke($file);
 189  
 190  
 191  print strftime("%H:%M:%S",time())."\n";
 192  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics