[ Index ] |
|
Code source de Dolibarr 2.0.1 |
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: facturestats.class.php,v 1.7 2005/09/02 22:03:20 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/facture/stats/facturestats.class.php,v $ 21 * 22 */ 23 24 /** 25 \file htdocs/compta/facture/stats/facturestats.class.php 26 \ingroup factures 27 \brief Fichier de la classe de gestion des stats des factures 28 \version $Revision: 1.7 $ 29 */ 30 31 include_once DOL_DOCUMENT_ROOT . "/stats.class.php"; 32 33 34 /** 35 \class FactureStats 36 \brief Classe permettant la gestion des stats des factures 37 */ 38 39 class FactureStats extends Stats 40 { 41 var $db ; 42 43 function FactureStats($DB, $socidp=0) 44 { 45 $this->db = $DB; 46 $this->socidp = $socidp; 47 } 48 49 50 /** 51 * Renvoie le nombre de facture par mois pour une année donnée 52 * 53 */ 54 function getNbByMonth($year) 55 { 56 $sql = "SELECT date_format(datef,'%m') as dm, count(*) FROM ".MAIN_DB_PREFIX."facture"; 57 $sql .= " WHERE date_format(datef,'%Y') = $year AND fk_statut > 0"; 58 if ($this->socidp) 59 { 60 $sql .= " AND fk_soc = ".$this->socidp; 61 } 62 $sql .= " GROUP BY dm DESC"; 63 64 return $this->_getNbByMonth($year, $sql); 65 } 66 67 68 /** 69 * Renvoie le nombre de facture par année 70 * 71 */ 72 function getNbByYear() 73 { 74 $sql = "SELECT date_format(datef,'%Y') as dm, count(*) FROM ".MAIN_DB_PREFIX."facture GROUP BY dm DESC WHERE fk_statut > 0"; 75 76 return $this->_getNbByYear($sql); 77 } 78 79 /** 80 * Renvoie le nombre de facture par mois pour une année donnée 81 * 82 */ 83 function getAmountByMonth($year) 84 { 85 $sql = "SELECT date_format(datef,'%m') as dm, sum(total) FROM ".MAIN_DB_PREFIX."facture"; 86 $sql .= " WHERE date_format(datef,'%Y') = $year AND fk_statut > 0"; 87 if ($this->socidp) 88 { 89 $sql .= " AND fk_soc = ".$this->socidp; 90 } 91 $sql .= " GROUP BY dm DESC"; 92 93 return $this->_getAmountByMonth($year, $sql); 94 } 95 /** 96 * 97 * 98 */ 99 function getAverageByMonth($year) 100 { 101 $sql = "SELECT date_format(datef,'%m') as dm, avg(total) FROM ".MAIN_DB_PREFIX."facture"; 102 $sql .= " WHERE date_format(datef,'%Y') = $year AND fk_statut > 0"; 103 if ($this->socidp) 104 { 105 $sql .= " AND fk_soc = ".$this->socidp; 106 } 107 $sql .= " GROUP BY dm DESC"; 108 109 return $this->_getAverageByMonth($year, $sql); 110 } 111 } 112 113 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |