| [ 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: expeditionstats.class.php,v 1.4 2004/10/19 20:43:24 opensides Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/expedition/stats/expeditionstats.class.php,v $ 20 * 21 */ 22 23 class ExpeditionStats 24 { 25 var $db ; 26 27 function ExpeditionStats($DB) 28 { 29 $this->db = $DB; 30 } 31 /** 32 * Renvoie le nombre de expedition par année 33 * 34 */ 35 function getNbExpeditionByYear() 36 { 37 $result = array(); 38 $sql = "SELECT date_format(date_expedition,'%Y') as dm, count(*) FROM ".MAIN_DB_PREFIX."expedition 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 expedition par mois pour une année donnée 56 * 57 */ 58 function getNbExpeditionByMonth($year) 59 { 60 $result = array(); 61 $sql = "SELECT date_format(date_expedition,'%m') as dm, count(*) FROM ".MAIN_DB_PREFIX."expedition"; 62 $sql .= " WHERE date_format(date_expedition,'%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 $data = array(); 85 86 for ($i = 1 ; $i < 13 ; $i++) 87 { 88 $data[$i-1] = array(strftime("%b",mktime(12,12,12,$i,1,$year)), $res[$i]); 89 } 90 91 return $data; 92 } 93 94 95 function getNbExpeditionByMonthWithPrevYear($year) 96 { 97 $data1 = $this->getNbExpeditionByMonth($year); 98 $data2 = $this->getNbExpeditionByMonth($year - 1); 99 100 $data = array(); 101 102 for ($i = 1 ; $i < 13 ; $i++) 103 { 104 $data[$i-1] = array(strftime("%b",mktime(12,12,12,$i,1,$year)), 105 $data1[$i][1], 106 $data2[$i][1]); 107 } 108 return $data; 109 } 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 |
|