[ 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: commandes.week.class.php,v 1.10 2005/03/22 09:52:12 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/lignes/commandes.week.class.php,v $ 20 * 21 */ 22 23 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/baracc.class.php"); 24 25 class GraphLignesCommandesWeek extends GraphBarAcc { 26 27 Function GraphLignesCommandesWeek($DB, $file) 28 { 29 $this->db = $DB; 30 $this->file = $file; 31 32 $this->client = 0; 33 $this->titre = "Commandes Lignes par semaine"; 34 35 $this->barcolor = "blue"; 36 $this->showframe = true; 37 } 38 39 Function GraphMakeGraph($commercial=0) 40 { 41 $num = 0; 42 43 $labels = array(); 44 45 $sql = "SELECT date_format(date_commande,'%y%v'), count(*)"; 46 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne"; 47 $sql .= " WHERE date_commande IS NOT NULL "; 48 49 if ($commercial > 0) 50 { 51 $sql .= " AND fk_commercial = ".$commercial; 52 } 53 54 $sql .= " GROUP BY date_format(date_commande,'%y%v') ASC"; 55 56 57 if ($this->db->query($sql)) 58 { 59 $num = $this->db->num_rows(); 60 61 $i = 0; 62 $datas = array(); 63 64 while ($i < $num) 65 { 66 $row = $this->db->fetch_row(); 67 $datas[$row[0]] = $row[1]; 68 array_push($labels, $row[0]); 69 $i++; 70 } 71 72 $this->db->free(); 73 } 74 else 75 { 76 dolibarr_syslog($this->db->error()); 77 } 78 79 /* Lignes rejetées */ 80 $sql = "SELECT date_format(date_commande,'%y%v'), count(*)"; 81 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne"; 82 $sql .= " WHERE date_commande IS NOT NULL "; 83 $sql .= " AND statut = 7"; 84 85 if ($commercial > 0) 86 { 87 $sql .= " AND fk_commercial = ".$commercial; 88 } 89 90 $sql .= " GROUP BY date_format(date_commande,'%y%v') ASC"; 91 92 if ($this->db->query($sql)) 93 { 94 $num = $this->db->num_rows(); 95 $i = 0; 96 $datas_rej = array(); 97 98 while ($i < $num) 99 { 100 $row = $this->db->fetch_row(); 101 102 $datas_rej[$row[0]] = $row[1]; 103 array_push($labels, $row[0]); 104 $i++; 105 } 106 107 $this->db->free(); 108 } 109 else 110 { 111 dolibarr_syslog($this->db->error()); 112 } 113 114 /* == */ 115 116 $datas_new = array(); 117 $labels_new = array(); 118 $j = 0 ; 119 120 $max = max($labels); 121 $week = $max; 122 $year = substr($week,0,2); 123 $smwee = substr($max, -2); 124 125 for ($i = 0 ; $i < 18 ; $i++) 126 { 127 128 $datas_new[$i] = $datas[$year.$smwee] - $datas_rej[$year.$smwee]; 129 $datas_new_rej[$i] = $datas_rej[$year.$smwee]; 130 $labels_new[$i] = ceil($smwee); 131 132 if (($smwee - 1) == 0) 133 { 134 $smwee = strftime("%V",mktime(12,0,2,12,31,"20".substr("00".($year - 1), -2))); 135 136 if ($smwee == '01') 137 { 138 $smwee = 52; 139 } 140 141 $year = substr("00".($year - 1), -2); 142 } 143 else 144 { 145 $smwee = substr("00".($smwee -1), -2); 146 } 147 } 148 149 $datas_new = array_reverse($datas_new); 150 $datas_new_rej = array_reverse($datas_new_rej); 151 $labels_new = array_reverse($labels_new); 152 153 $this->LabelAngle = 0; 154 155 /* 156 * Insertion Base 157 * 158 */ 159 $type = "commandes.hebdomadaire"; 160 $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats"; 161 $sql .= " WHERE graph = '".$type."'"; 162 $this->db->query($sql); 163 164 for ($i = 0 ; $i < sizeof($datas_new) ; $i++) 165 { 166 167 $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats"; 168 $sql .= " (graph, ord, valeur) VALUES ("; 169 $sql .= "'".$type."'"; 170 $sql .= ",'".$labels_new[$i]."'"; 171 $sql .= ",'".$datas_new[$i]."');"; 172 if (! $this->db->query($sql)) 173 { 174 print $this->db->error(); 175 } 176 } 177 /* 178 * 179 * 180 */ 181 182 $this->GraphDraw($this->file, $datas_new, $labels_new, $datas_new_rej); 183 } 184 } 185 ?>
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 |
![]() |