[ 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/graph/ -> comm.nbmensuel.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: comm.nbmensuel.class.php,v 1.6 2005/08/09 14:12:06 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/graph/comm.nbmensuel.class.php,v $
  20   *
  21   */
  22  
  23  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
  24  
  25  class GraphCommNbMensuel extends GraphBar{
  26  
  27  
  28    Function GraphCommNbMensuel($DB, $file)
  29    {
  30      $this->name = "comm.nbmensuel";
  31      $this->db = $DB;
  32      $this->file = $file;
  33      $this->showframe = true;
  34      $this->client = 0;
  35      $this->contrat = 0;
  36      $this->ligne = 0;
  37      $this->titre = "Nombre de communications par mois";
  38  
  39      $this->barcolor = "bisque3";
  40  
  41      $this->datas = array();
  42      $this->labels = array();
  43    }
  44  
  45    Function Graph($datas='', $labels='')
  46    {    
  47      $this->GetDatas();
  48  
  49      $this->width = 360;
  50  
  51      if (sizeof($this->datas))
  52        {
  53      $this->GraphDraw($this->file, $this->datas, $this->labels);
  54        }
  55    }
  56  
  57    Function GetDatas()
  58    {
  59      $sql = "SELECT date_format(td.date,'%Y%m'), count(*)";
  60      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td";
  61  
  62      if ($this->client == 0 && $this->contrat == 0 && $this->ligne == 0)
  63        {
  64  
  65      $sql .= " GROUP BY date_format(td.date, '%Y%m') ASC";
  66        }
  67      elseif ($this->client > 0 && $this->contrat == 0 && $this->ligne == 0)
  68        {
  69  
  70      $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s";   
  71  
  72      $sql .= " WHERE td.ligne = s.ligne";
  73      $sql .= " AND s.fk_client_comm = ".$this->client;
  74  
  75      $sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";
  76        }    
  77      elseif ($this->client == 0 && $this->contrat > 0 && $this->ligne == 0)
  78        {
  79      $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s";   
  80  
  81      $sql .= " WHERE td.ligne = s.ligne";
  82      $sql .= " AND s.fk_contrat = ".$this->contrat;
  83  
  84      $sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";
  85        }
  86      elseif ($this->client == 0 && $this->contrat == 0 && $this->ligne > 0)
  87        {
  88      $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s";   
  89  
  90      $sql .= " WHERE td.ligne = s.ligne";
  91      $sql .= " AND s.rowid = ".$this->ligne;
  92  
  93      $sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";
  94        }
  95  
  96      if ($this->db->query($sql))
  97        {
  98      $num = $this->db->num_rows();
  99      $i = 0;
 100          
 101      while ($i < $num)
 102        {
 103          $row = $this->db->fetch_row();    
 104          
 105          $this->labels[$i] = substr($row[0],4,2);
 106          $this->datas[$i] = $row[1];
 107          
 108          $i++;
 109        }    
 110      $this->db->free();
 111        }
 112      else 
 113        {
 114      dolibarr_syslog("Error");
 115        }
 116    }
 117  }  
 118  ?>


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