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