[ 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/stats/ -> ProcessGraphLignes.class.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: ProcessGraphLignes.class.php,v 1.7 2005/10/19 08:50:34 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/ProcessGraphLignes.class.php,v $
  20   *
  21   *
  22   * Generation des graphiques clients
  23   *
  24   *
  25   */
  26  require  ("../../master.inc.php");
  27  
  28  require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php");
  29  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/ca.class.php");
  30  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/gain.class.php");
  31  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/appelsdureemoyenne.class.php");
  32  
  33  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbmensuel.class.php");
  34  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbminutes.class.php");
  35  
  36  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/heureappel.class.php");
  37  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/joursemaine.class.php");
  38  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camoyen.class.php");
  39  
  40  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camenbert.class.php");
  41  
  42  /*
  43   * Process
  44   *
  45   */
  46  
  47  class ProcessGraphLignes
  48  {
  49    var $ident;
  50    
  51    function ProcessGraphLignes( $db)
  52    {
  53      global $conf;
  54  
  55      $this->ident = $ident;
  56      $this->cpc = $cpc;
  57  
  58      $this->db = $db;
  59      $this->labels = array();
  60      $this->nbminutes = array();
  61      $this->nbcomm = array();
  62      $this->duree_moyenne = array();
  63      $this->vente = array();
  64      $this->gain = array();
  65    }
  66    
  67    function go($ligne)
  68    {
  69      dolibarr_syslog("Deb ligne ".$ligne);
  70  
  71      $this->ligne = $ligne;
  72      $this->GetDatas();
  73  
  74      $error = 0;
  75  
  76      /* Chiffre d'affaire */
  77      
  78      $img_root = DOL_DATA_ROOT."/graph/".substr($ligne,-1)."/telephonie/ligne/";
  79  
  80      $file = $img_root . $ligne."/graphca.png";
  81  
  82      $graphx = new GraphBar ($this->db, $file);
  83      $graphx->ligne = $ligne;
  84      $graphx->width = 360;
  85      $graphx->titre = "Chiffre d'affaire (euros HT)";
  86      $graphx->barcolor = "blue";
  87      $graphx->show_console = 0 ;
  88      $graphx->GraphDraw($file, $this->vente, $this->labels);
  89  
  90  
  91      /* Gain */
  92  
  93      $file = $img_root . $ligne."/graphgain.png";
  94      
  95      $graphx = new GraphBar ($this->db, $file);
  96      $graphx->ligne = $ligne;
  97      $graphx->width = 360;
  98      $graphx->titre = "Gain (euros HT)";
  99      $graphx->barcolor = "green";
 100      $graphx->show_console = 0 ;
 101      $graphx->GraphDraw($file, $this->gain, $this->labels);
 102  
 103      /* Duree moyenne des appels */
 104      
 105      $file = $img_root . $ligne."/graphappelsdureemoyenne.png";
 106      
 107      $graphx = new GraphBar ($this->db, $file);
 108      $graphx->ligne = $ligne;
 109      $graphx->width = 360;
 110      $graphx->titre = "Durée moyenne";
 111      $graphx->barcolor = "orange";
 112      $graphx->show_console = 0 ;
 113      $graphx->GraphDraw($file, $this->duree_moyenne, $this->labels);
 114  
 115      /* Nb de communication */
 116      
 117      $file = $img_root . $ligne."/nb-comm-mensuel.png";
 118  
 119      $graphx = new GraphBar ($this->db, $file);
 120      $graphx->ligne = $ligne;
 121      $graphx->width = 360;
 122      $graphx->titre = "Nombre de communications";
 123      $graphx->show_console = 0 ;
 124      $graphx->GraphDraw($file, $this->nbcomm, $this->labels);
 125  
 126      /* Nb de minutes */
 127      
 128      $file = $img_root . $ligne."/nb-minutes-mensuel.png";
 129      
 130      $graphx = new GraphBar ($this->db, $file);
 131      $graphx->ligne = $ligne;
 132      $graphx->width = 360;
 133      $graphx->show_console = 0 ;
 134      $graphx->titre = "Nombre de minutes";
 135      $graphx->barcolor = "bisque2";
 136      $graphx->GraphDraw($file, $this->nbminutes, $this->labels);    
 137    }
 138  
 139    Function GetDatas()
 140    {
 141      $sql = "SELECT date_format(td.date,'%m'), sum(duree), count(*), sum(cout_vente), sum(fourn_montant)";
 142      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td";
 143      $sql .= " WHERE td.fk_ligne = ".$this->ligne;
 144      $sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";
 145      
 146      if ($this->db->query($sql))
 147        {
 148      $num = $this->db->num_rows();
 149      $i = 0;
 150          
 151      while ($i < $num)
 152        {
 153          $row = $this->db->fetch_row();    
 154          
 155          $this->labels[$i] = $row[0];
 156  
 157          $this->nbminutes[$i] = ceil($row[1] / 60);
 158          $this->nbcomm[$i] = $row[2];
 159          $this->duree_moyenne[$i] = ($this->nbminutes[$i] / $this->nbcomm[$i]);
 160          $this->vente[$i] = $row[3];
 161          $this->gain[$i] = ($row[3] - $row[4]);
 162          
 163          $i++;
 164        }    
 165      $this->db->free();
 166        }
 167      else 
 168        {
 169      dolibarr_syslog("Error");
 170        }
 171    }
 172  }
 173  ?>


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