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

   1  <?php
   2  /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (c) 2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: propalestats.class.php,v 1.7 2005/09/02 22:04:09 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/propal/stats/propalestats.class.php,v $
  21   *
  22   */
  23  
  24  /**
  25          \file       htdocs/comm/propal/stats/propalestats.class.php
  26          \ingroup    propales
  27          \brief      Fichier de la classe de gestion des stats des propales
  28          \version    $Revision: 1.7 $
  29  */
  30  
  31  include_once DOL_DOCUMENT_ROOT . "/stats.class.php";
  32  
  33  
  34  /**
  35          \class      PropaleStats
  36          \brief      Classe permettant la gestion des stats des propales
  37  */
  38  
  39  class PropaleStats extends Stats
  40  {
  41    var $db ;
  42  
  43    function PropaleStats($DB)
  44      {
  45        $this->db = $DB;
  46      }
  47  
  48  
  49    /**
  50     * Renvoie le nombre de proposition par mois pour une année donnée
  51     *
  52     */
  53    function getNbByMonth($year)
  54    {
  55      $sql = "SELECT date_format(datep,'%m') as dm, count(*)  FROM ".MAIN_DB_PREFIX."propal";
  56      $sql .= " WHERE date_format(datep,'%Y') = $year AND fk_statut > 0";
  57      $sql .= " GROUP BY dm DESC";
  58      
  59      return $this->_getNbByMonth($year, $sql);
  60    }
  61  
  62    /**
  63     * Renvoie le nombre de propale par année
  64     *
  65     */
  66    function getNbByYear()
  67    {
  68      $sql = "SELECT date_format(datep,'%Y') as dm, count(*) FROM ".MAIN_DB_PREFIX."propal GROUP BY dm DESC WHERE fk_statut > 0";
  69  
  70      return $this->_getNbByYear($sql);
  71    }
  72    /**
  73     * Renvoie le nombre de propale par mois pour une année donnée
  74     *
  75     */
  76    function getAmountByMonth($year)
  77    {
  78      $sql = "SELECT date_format(datep,'%m') as dm, sum(price)  FROM ".MAIN_DB_PREFIX."propal";
  79      $sql .= " WHERE date_format(datep,'%Y') = $year AND fk_statut > 0";
  80      $sql .= " GROUP BY dm DESC";
  81  
  82      return $this->_getAmountByMonth($year, $sql);
  83    }
  84    /**
  85     * 
  86     *
  87     */
  88    function getAverageByMonth($year)
  89    {
  90      $sql = "SELECT date_format(datep,'%m') as dm, avg(price)  FROM ".MAIN_DB_PREFIX."propal";
  91      $sql .= " WHERE date_format(datep,'%Y') = $year AND fk_statut > 0";
  92      $sql .= " GROUP BY dm DESC";
  93  
  94      return $this->_getAverageByMonth($year, $sql);
  95    }
  96  }
  97  
  98  ?>


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