[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2005 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: clientsmoyenne.week.class.php,v 1.2 2005/02/22 08:31:54 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/clients/clientsmoyenne.week.class.php,v $ 20 * 21 */ 22 23 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/line.class.php"); 24 25 class GraphClientsMoyenneWeek extends GraphLine { 26 27 Function GraphClientsMoyenneWeek($DB, $file) 28 { 29 $this->db = $DB; 30 $this->file = $file; 31 32 $this->client = 0; 33 $this->titre = "Nouveaux clients par semaine (moyenne)"; 34 35 $this->barcolor = "yellow"; 36 $this->showframe = true; 37 $this->LabelInterval = 1; 38 } 39 40 Function GraphMakeGraph($commercial=0) 41 { 42 $num = 0; 43 44 $sql = "SELECT fk_client_comm, date_format(date_commande,'%x%v')"; 45 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne"; 46 $sql .= " WHERE date_commande IS NOT NULL "; 47 48 if ($commercial > 0) 49 { 50 $sql .= " AND fk_commercial = ".$commercial; 51 } 52 53 $sql .= " ORDER BY date_format(date_commande,'%x%v') ASC"; 54 55 $result = $this->db->query($sql); 56 57 if ($result) 58 { 59 $num = $this->db->num_rows(); 60 61 $i = 0; 62 $j = 0; 63 $datas = array(); 64 $labels = array(); 65 $oldweek = 0; 66 $clients = array(); 67 68 while ($i < $num) 69 { 70 $row = $this->db->fetch_row(); 71 72 if ($oldweek == 0) 73 { 74 $oldweek = $row[1]; 75 array_push($clients, $row[0]); 76 77 $datas[$j] = 1; 78 $labels[$j] = $row[1]; 79 } 80 else 81 { 82 83 if ($row[1] == $labels[$j]) 84 { 85 if (! in_array($row[0], $clients)) 86 { 87 array_push($clients, $row[0]); 88 $datas[$j]++; 89 } 90 } 91 else 92 { 93 $j++; 94 if (! in_array($row[0], $clients)) 95 { 96 array_push($clients, $row[0]); 97 $datas[$j] = 1; 98 } 99 else 100 { 101 $datas[$j] = 0; 102 } 103 104 $labels[$j] = $row[1]; 105 } 106 107 } 108 109 $i++; 110 } 111 112 $this->db->free(); 113 } 114 else 115 { 116 print $this->db->error() . ' ' . $sql; 117 } 118 119 $datas_new = array(); 120 $labels_new = array(); 121 $j = 0 ; 122 123 $datas_new[0] = $datas[0]; 124 $labels_new[0] = ceil(substr($labels[0],-2)); 125 126 for ($i = 1 ; $i < sizeof($labels) ; $i++) 127 { 128 if (substr($labels[$i], -2) - substr($labels[$i-1], -2) > 1) 129 { 130 for ($k = 1 ; $k < ($labels[$i] - $labels[$i-1]) ; $k++) 131 { 132 $datas_new[$i+$j] = 0; 133 $labels_new[$i+$j] = ceil(substr($labels[$i-1], -2) + $k) ; // suppression du 0 134 135 $j++; 136 } 137 } 138 139 $datas_new[$i+$j] = $datas[$i]; 140 $labels_new[$i+$j] = ceil(substr($labels[$i], - 2)); 141 } 142 143 $nbel = sizeof($datas_new); 144 145 $moys = array(); 146 $moys[0] = $datas_new[0]; 147 $sum = $moys[0]; 148 149 for ($i = 1 ; $i < $nbel ; $i++) 150 { 151 $sum = $sum + $datas_new[$i]; 152 153 $moys[$i] = ($sum / ($i+1)); 154 } 155 156 for ($i = 0 ; $i < ($nbel - 18) ; $i++) 157 { 158 array_shift($datas_new); 159 array_shift($labels_new); 160 array_shift($moys); 161 } 162 163 if (sizeof($moys) > 1) 164 { 165 $this->GraphDraw($this->file, $moys, $labels_new); 166 } 167 } 168 } 169 ?>
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 |
![]() |