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


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