[ 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: commercial.ca.class.php,v 1.4 2005/12/01 15:03:52 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/commerciaux/commercial.ca.class.php,v $ 20 * 21 */ 22 23 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php"); 24 25 class GraphCommercialChiffreAffaire extends GraphBar { 26 27 Function GraphCommercialChiffreAffaire($DB, $file, $year=0) 28 { 29 $this->db = $DB; 30 $this->file = $file; 31 $this->year = $year; 32 $this->client = 0; 33 $this->titre = "Chiffre d'affaire"; 34 if ($this->year > 0) 35 { 36 $this->titre .= " ".$year; 37 } 38 $this->barcolor = "blue"; 39 $this->showframe = true; 40 } 41 42 Function GraphMakeGraph($commercial=0) 43 { 44 $num = 0; 45 46 if ($commercial > 0) 47 { 48 $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats"; 49 $sql .= " WHERE graph='commercial.ca.mensuel.".$commercial."'"; 50 if ($this->year > 0) 51 { 52 $sql .= " AND legend like '".$this->year."%'"; 53 } 54 $resql = $this->db->query($sql); 55 } 56 57 58 $sql = "SELECT date_format(f.date,'%Y%m'), sum(f.cout_vente)"; 59 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f"; 60 $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; 61 $sql .= " WHERE l.rowid = f.fk_ligne"; 62 $sql .= " AND l.fk_commercial_sign = ".$commercial; 63 if ($this->year > 0) 64 { 65 $sql .= " AND date_format(f.date,'%Y')='".$this->year."'"; 66 } 67 $sql .= " GROUP BY date_format(f.date,'%Y%m') ASC"; 68 69 $resql = $this->db->query($sql); 70 71 if ($resql) 72 { 73 $num = $this->db->num_rows($resql); 74 $i = 0; 75 $j = -1; 76 $datas = array(); 77 $labels = array(); 78 79 while ($i < $num) 80 { 81 $row = $this->db->fetch_row($resql); 82 83 $datas[$i] = $row[1]; 84 $labels[$i] = substr($row[0],-2); 85 86 if ($commercial > 0) 87 { 88 $sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats"; 89 $sqli .= " (graph,ord,legend,valeur)"; 90 $sqli .= " VALUES ('commercial.ca.mensuel.".$commercial."'"; 91 $sqli .= ",'$i','".$row[0]."','".$datas[$i]."');"; 92 $resqli = $this->db->query($sqli); 93 } 94 $i++; 95 } 96 97 $this->db->free($resql); 98 } 99 else 100 { 101 print $this->db->error() . ' ' . $sql; 102 } 103 104 if (sizeof($datas)) 105 { 106 $this->GraphDraw($this->file, $datas, $labels); 107 } 108 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 |
![]() |