[ Index ] |
|
Code source de Dolibarr 2.0.1 |
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: commandestats.class.php,v 1.5 2004/10/20 20:06:50 opensides Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/stats/commandestats.class.php,v $ 20 * 21 */ 22 23 class CommandeStats 24 { 25 var $db ; 26 27 function CommandeStats($DB) 28 { 29 $this->db = $DB; 30 } 31 /** 32 * Renvoie le nombre de commande par année 33 * 34 */ 35 function getNbCommandeByYear() 36 { 37 $result = array(); 38 $sql = "SELECT date_format(date_commande,'%Y') as dm, count(*) FROM ".MAIN_DB_PREFIX."commande GROUP BY dm DESC WHERE fk_statut > 0"; 39 if ($this->db->query($sql)) 40 { 41 $num = $this->db->num_rows(); 42 $i = 0; 43 while ($i < $num) 44 { 45 $row = $this->db->fetch_row($i); 46 $result[$i] = $row; 47 48 $i++; 49 } 50 $this->db->free(); 51 } 52 return $result; 53 } 54 /** 55 * Renvoie le nombre de commande par mois pour une année donnée 56 * 57 */ 58 function getNbCommandeByMonth($year) 59 { 60 $result = array(); 61 $sql = "SELECT date_format(date_commande,'%m') as dm, count(*) FROM ".MAIN_DB_PREFIX."commande"; 62 $sql .= " WHERE date_format(date_commande,'%Y') = $year AND fk_statut > 0"; 63 $sql .= " GROUP BY dm DESC"; 64 65 if ($this->db->query($sql)) 66 { 67 $num = $this->db->num_rows(); 68 $i = 0; 69 while ($i < $num) 70 { 71 $row = $this->db->fetch_row($i); 72 $j = $row[0] * 1; 73 $result[$j] = $row[1]; 74 $i++; 75 } 76 $this->db->free(); 77 } 78 79 for ($i = 1 ; $i < 13 ; $i++) 80 { 81 $res[$i] = $result[$i] + 0; 82 } 83 84 return $res; 85 } 86 /** 87 * Renvoie le nombre de commande par mois pour une année donnée 88 * 89 */ 90 function getCommandeAmountByMonth($year) 91 { 92 $result = array(); 93 $sql = "SELECT date_format(date_commande,'%m') as dm, sum(total_ht) FROM ".MAIN_DB_PREFIX."commande"; 94 $sql .= " WHERE date_format(date_commande,'%Y') = $year AND fk_statut > 0"; 95 $sql .= " GROUP BY dm DESC"; 96 97 if ($this->db->query($sql)) 98 { 99 $num = $this->db->num_rows(); 100 $i = 0; 101 while ($i < $num) 102 { 103 $row = $this->db->fetch_row($i); 104 $j = $row[0] * 1; 105 $result[$j] = $row[1]; 106 $i++; 107 } 108 $this->db->free(); 109 } 110 111 for ($i = 1 ; $i < 13 ; $i++) 112 { 113 $res[$i] = $result[$i] + 0; 114 } 115 116 return $res; 117 } 118 /** 119 * Renvoie le nombre de commande par mois pour une année donnée 120 * 121 */ 122 function getCommandeAverageByMonth($year) 123 { 124 $result = array(); 125 $sql = "SELECT date_format(date_commande,'%m') as dm, avg(total_ht) FROM ".MAIN_DB_PREFIX."commande"; 126 $sql .= " WHERE date_format(date_commande,'%Y') = $year AND fk_statut > 0"; 127 $sql .= " GROUP BY dm DESC"; 128 129 if ($this->db->query($sql)) 130 { 131 $num = $this->db->num_rows(); 132 $i = 0; 133 while ($i < $num) 134 { 135 $row = $this->db->fetch_row($i); 136 $j = $row[0] * 1; 137 $result[$j] = $row[1]; 138 $i++; 139 } 140 $this->db->free(); 141 } 142 143 for ($i = 1 ; $i < 13 ; $i++) 144 { 145 $res[$i] = $result[$i] + 0; 146 } 147 148 return $res; 149 } 150 } 151 152 ?>
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 |
![]() |