[ 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/tools/ -> graph-conso-jour.php (source)

   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-conso-jour.php,v 1.4 2005/12/07 11:52:01 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/tools/graph-conso-jour.php,v $
  20   *
  21   * Generation de graphiques
  22   *
  23   */
  24  require  ("../../../master.inc.php");
  25  
  26  $verbose = 0;
  27  
  28  
  29  require_once (DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
  30  require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php");
  31  require_once (DOL_DOCUMENT_ROOT."/telephonie/telephonie-tarif.class.php");
  32  require_once (DOL_DOCUMENT_ROOT."/telephonie/communication.class.php");
  33  
  34  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
  35  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/baraccumul.class.php");
  36  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camenbert.class.php");
  37  
  38  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/ca.class.php");
  39  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/gain.class.php");
  40  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/heureappel.class.php");
  41  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/joursemaine.class.php");
  42  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camoyen.class.php");
  43  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/appelsdureemoyenne.class.php");
  44  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbmensuel.class.php");
  45  
  46  $error = 0;
  47  
  48  $img_root = DOL_DATA_ROOT."/graph/telephonie";
  49  
  50  
  51  $colors = array();
  52  $colors[10] = 'yellow';
  53  $colors[11] = 'red';
  54  $months = array(10,11);
  55  
  56  $data = array();
  57  $moydata = array();
  58  
  59  print "$month\n";
  60  $sql = "SELECT date_format(date,'%d'), sum(duree)";
  61  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details";
  62  $sql .= " WHERE date >= '2005-10-01'";
  63  $sql .= " GROUP BY date_format(date,'%Y%m%d') ASC ;";
  64  
  65  $resql = $db->query($sql);
  66  $total = 0;
  67  if ($resql)
  68  {
  69    $num = $db->num_rows($resql);
  70    $i = 0;
  71    
  72    while ($row = $db->fetch_row($resql))
  73      {
  74        $data[$i] = ($row[1]/60000);
  75        $total = $total + $data[$i];
  76        $labels[$i] = $row[0];
  77        $moydata[$i] = $total / ($i+1);
  78        $i++;
  79      }
  80  }
  81  else
  82  {
  83    print $db->error();
  84  }
  85  
  86  $file = "/tmp/conso-jour.png";
  87  
  88  $graph = new Graph(800, 400,"auto");    
  89  $graph->SetScale("textlin");
  90  $graph->yaxis->scale->SetGrace(20);
  91  $graph->SetFrame(true);
  92  $graph->img->SetMargin(50,20,20,35);
  93  $graph->xaxis->scale->SetGrace(20);
  94  
  95  $graph->title->Set("Nb minutes en kilos");
  96  $graph->xaxis->SetTickLabels($labels);    
  97  
  98  $b2plot = new LinePlot($data);    
  99  $b2plot->SetWeight(2);
 100  $b2plot->SetColor("red");
 101  $graph->Add($b2plot);
 102  
 103  $lineplot = new LinePlot($moydata);    
 104  $lineplot->SetColor("blue");
 105  $graph->Add($lineplot);
 106  
 107  $graph->img->SetImgFormat("png");
 108  $graph->Stroke($file);
 109  ?>


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