[ 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: distributeur.gain.class.php,v 1.12 2005/11/16 12:44:42 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/distributeurs/distributeur.gain.class.php,v $ 20 * 21 */ 22 23 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php"); 24 25 class GraphDistributeurGain extends GraphBar { 26 27 Function GraphDistributeurGain($DB, $file) 28 { 29 $this->db = $DB; 30 $this->file = $file; 31 32 $this->client = 0; 33 $this->year = strftime("%Y",time()); 34 $this->titre = "Marges effectuées sur les lignes ".$this->year; 35 36 $this->barcolor = "pink"; 37 $this->showframe = true; 38 } 39 40 Function GraphMakeGraph($distributeur=0) 41 { 42 $num = 0; 43 $year = strftime("%Y",time()); 44 45 $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats"; 46 if ($distributeur > 0) 47 { 48 $sql .= " WHERE graph='distributeur.gain.mensuel.".$distributeur."';"; 49 } 50 else 51 { 52 $sql .= " WHERE graph='distributeur.gain.mensuel'"; 53 } 54 $resql = $this->db->query($sql); 55 56 57 if ($distributeur > 0) { 58 $sql = "SELECT date_format(f.date,'%Y%m'), sum(f.gain)"; 59 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f"; 60 $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; 61 $sql .= " , ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux as dc"; 62 $sql .= " WHERE l.rowid = f.fk_ligne"; 63 $sql .= " AND l.fk_commercial_sign = dc.fk_user"; 64 $sql .= " AND dc.fk_distributeur = ".$distributeur; 65 $sql .= " GROUP BY date_format(f.date,'%Y%m') ASC"; 66 } else { 67 $sql = "SELECT legend, sum(valeur)"; 68 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_stats"; 69 $sql .= " WHERE graph like 'distributeur.gain.mensuel.%'"; 70 $sql .= " GROUP BY legend ORDER BY ord ASC"; 71 } 72 73 $resql = $this->db->query($sql); 74 75 if ($resql) 76 { 77 $num = $this->db->num_rows($resql); 78 $i = 0; 79 $j = -1; 80 $datas = array(); 81 $gains = array(); 82 $labels = array(); 83 84 while ($i < $num) 85 { 86 $row = $this->db->fetch_row($resql); 87 88 $datas[$i] = $row[1]; 89 $gains[$row[0]] = $row[1]; 90 $labels[$i] = substr($row[0],-2)."/".substr($row[0],2,2); 91 92 $sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats"; 93 $sqli .= " (graph,ord,legend,valeur)"; 94 if ($distributeur > 0) { 95 $sqli .= " VALUES ('distributeur.gain.mensuel.".$distributeur."'"; 96 } 97 else { 98 $sqli .= " VALUES ('distributeur.gain.mensuel'"; 99 } 100 $sqli .= ",'$i','".$row[0]."','".$datas[$i]."');"; 101 102 $resqli = $this->db->query($sqli); 103 104 $i++; 105 } 106 107 $this->db->free($resql); 108 } 109 else 110 { 111 print $this->db->error() . ' ' . $sql; 112 } 113 114 $month = array(); 115 $month[1] = 'J'; 116 $month[2] = 'F'; 117 $month[3] = 'M'; 118 $month[4] = 'A'; 119 $month[5] = 'M'; 120 $month[6] = 'J'; 121 $month[7] = 'J'; 122 $month[8] = 'A'; 123 $month[9] = 'S'; 124 $month[10] = 'O'; 125 $month[11] = 'N'; 126 $month[12] = 'D'; 127 128 for ($i = 1 ; $i < 13 ; $i++) 129 { 130 $idx = $year.substr('0'.$i,-2); 131 $datas[$i-1] = $gains[$idx]; 132 $labels[$i-1] = $month[$i]; 133 } 134 135 if (sizeof($datas)) 136 { 137 $this->GraphDraw($this->file, $datas, $labels); 138 } 139 } 140 } 141 ?>
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 |
![]() |