[ 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/ -> stats.class.php (source)

   1  <?php
   2  /* Copyright (C) 2003 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: stats.class.php,v 1.4 2005/07/16 14:57:49 eldy Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/stats.class.php,v $
  20   *
  21   */
  22  
  23  class Stats 
  24  {
  25    var $db ;
  26  
  27    function Stats($DB)
  28      {
  29        $this->db = $DB;
  30      }
  31  
  32    function getNbByMonthWithPrevYear($year)
  33    {
  34      $data1 = $this->getNbByMonth($year - 1);
  35      $data2 = $this->getNbByMonth($year);
  36  
  37      $data = array();
  38  
  39      for ($i = 0 ; $i < 12 ; $i++)
  40        {
  41      $data[$i] = array($data1[$i][0], 
  42                $data1[$i][1],
  43                $data2[$i][1]);
  44        }
  45      return $data;
  46    }
  47      
  48    /**
  49     * \brief  Renvoie le nombre de proposition par mois pour une année donnée
  50     *
  51     */
  52      function _getNbByMonth($year, $sql)
  53      {
  54          $result = array();
  55      
  56          $resql=$this->db->query($sql);
  57          if ($resql)
  58          {
  59              $num = $this->db->num_rows($resql);
  60              $i = 0;
  61              while ($i < $num)
  62              {
  63                  $row = $this->db->fetch_row($resql);
  64                  $j = $row[0] * 1;
  65                  $result[$j] = $row[1];
  66                  $i++;
  67              }
  68              $this->db->free($resql);
  69          }
  70      
  71          for ($i = 1 ; $i < 13 ; $i++)
  72          {
  73              $res[$i] = $result[$i] + 0;
  74          }
  75      
  76          $data = array();
  77      
  78          for ($i = 1 ; $i < 13 ; $i++)
  79          {
  80              $data[$i-1] = array(ucfirst(substr(strftime("%b",mktime(12,12,12,$i,1,$year)),0,3)), $res[$i]);
  81          }
  82      
  83          return $data;
  84      }
  85  
  86  
  87    /**
  88     * \brief  Renvoie le nombre d'element par année
  89     *
  90     */
  91      function _getNbByYear($sql)
  92      {
  93          $result = array();
  94      
  95          if ($this->db->query($sql))
  96          {
  97              $num = $this->db->num_rows();
  98              $i = 0;
  99              while ($i < $num)
 100              {
 101                  $row = $this->db->fetch_row($i);
 102                  $result[$i] = $row;
 103                  $i++;
 104              }
 105              $this->db->free();
 106          }
 107          else {
 108              dolibarr_print_error($this->db);
 109          }
 110          return $result;
 111      }
 112  
 113    /**
 114     * \brief  Renvoie le nombre d'element par mois pour une année donnée
 115     *
 116     */
 117       
 118    function _getAmountByMonth($year, $sql)
 119    {
 120      $result = array();
 121  
 122      if ($this->db->query($sql))
 123        {
 124      $num = $this->db->num_rows();
 125      $i = 0;
 126      while ($i < $num)
 127        {
 128          $row = $this->db->fetch_row($i);
 129          $j = $row[0] * 1;
 130          $result[$j] = $row[1];
 131          $i++;
 132        }
 133      $this->db->free();
 134        }
 135      
 136      for ($i = 1 ; $i < 13 ; $i++)
 137        {
 138      $res[$i] = $result[$i] + 0;
 139        }
 140  
 141      return $res;
 142    }
 143    /**
 144     * 
 145     *
 146     */
 147    function _getAverageByMonth($year, $sql)
 148    {
 149      $result = array();
 150  
 151      if ($this->db->query($sql))
 152        {
 153      $num = $this->db->num_rows();
 154      $i = 0;
 155      while ($i < $num)
 156        {
 157          $row = $this->db->fetch_row($i);
 158          $j = $row[0] * 1;
 159          $result[$j] = $row[1];
 160          $i++;
 161        }
 162      $this->db->free();
 163        }
 164      
 165      for ($i = 1 ; $i < 13 ; $i++)
 166        {
 167      $res[$i] = $result[$i] + 0;
 168        }
 169  
 170      return $res;
 171    }
 172  }
 173  
 174  ?>


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