[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2004 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: gain.class.php,v 1.8 2005/10/20 19:27:35 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/graph/gain.class.php,v $ 20 * 21 */ 22 23 require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/brouzouf.class.php"); 24 25 class GraphGain extends GraphBrouzouf{ 26 27 28 Function GraphGain($DB, $file) 29 { 30 $this->db = $DB; 31 $this->file = $file; 32 33 $this->client = 0; 34 $this->contrat = 0; 35 $this->ligne = 0; 36 $this->titre = "Gain (euros HT)"; 37 38 $this->barcolor = "blue"; 39 } 40 41 42 Function GraphDraw() 43 { 44 $num = 0; 45 46 $sql = "SELECT tf.date, sum(tf.gain), sum(tf.cout_vente), sum(tf.fourn_montant)"; 47 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as tf"; 48 49 if ($this->client == 0 && $this->contrat == 0 && $this->ligne == 0) 50 { 51 $sql .= " WHERE tf.fk_facture is not null"; 52 $sql .= " GROUP BY tf.date ASC"; 53 } 54 elseif ($this->client > 0 && $this->contrat == 0 && $this->ligne == 0) 55 { 56 $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s"; 57 $sql .= " WHERE tf.fk_facture is not null"; 58 $sql .= " AND s.rowid = tf.fk_ligne"; 59 $sql .= " AND s.fk_client_comm = ".$this->client; 60 $sql .= " GROUP BY tf.date ASC"; 61 } 62 elseif ($this->client == 0 && $this->contrat > 0 && $this->ligne == 0) 63 { 64 $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s"; 65 $sql .= " WHERE tf.fk_facture is not null"; 66 $sql .= " AND s.rowid = tf.fk_ligne"; 67 $sql .= " AND s.fk_contrat = ".$this->contrat; 68 $sql .= " GROUP BY tf.date ASC"; 69 } 70 elseif ($this->client == 0 && $this->contrat == 0 && $this->ligne > 0) 71 { 72 $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s"; 73 $sql .= " WHERE tf.fk_facture is not null"; 74 $sql .= " AND s.rowid = tf.fk_ligne"; 75 $sql .= " AND s.rowid = ".$this->ligne; 76 $sql .= " GROUP BY tf.date ASC"; 77 } 78 79 $resql = $this->db->query($sql); 80 81 if ($resql) 82 { 83 $num = $this->db->num_rows($resql); 84 $i = 0; 85 $labels = array(); 86 87 $this->total_gain = 0; 88 $this->total_ca = 0; 89 90 while ($i < $num) 91 { 92 $row = $this->db->fetch_row($resql); 93 94 $g[$i] = $row[1]; 95 96 $labels[$i] = substr($row[0],5,2); 97 98 $this->total_gain += $row[1]; 99 $this->total_ca += $row[2]; 100 $this->total_cout += $row[3]; 101 102 $i++; 103 } 104 105 $this->db->free($resql); 106 } 107 else 108 { 109 print $this->db->error() . ' ' . $sql; 110 } 111 112 if ($this->client > 0) 113 { 114 115 /* 116 * Comptage des remises exceptionnelles 117 * 118 */ 119 $sql = "SELECT sr.amount_ht"; 120 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as s"; 121 $sql .= " , ".MAIN_DB_PREFIX."telephonie_facture as tf"; 122 $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as sr"; 123 124 $sql .= " WHERE sr.fk_facture = tf.fk_facture"; 125 $sql .= " AND s.rowid = tf.fk_ligne"; 126 $sql .= " AND s.fk_client_comm = ".$this->client; 127 $sql .= " GROUP BY tf.fk_facture"; 128 129 $resql = $this->db->query($sql); 130 131 if ($resql) 132 { 133 $numr = $this->db->num_rows($resql); 134 $i = 0; 135 136 while ($i < $numr) 137 { 138 $row = $this->db->fetch_row($resql); 139 if ( $row[0] > 0) 140 { 141 $this->total_gain = ($this->total_gain - $row[0]); 142 } 143 $i++; 144 } 145 } 146 } 147 148 if ($this->show_console) 149 { 150 print $this->client . " " . $g[$i - 1]."\n"; 151 } 152 153 if ($num > 0) 154 { 155 $this->GraphMakeGraph($g, $labels); 156 } 157 } 158 159 } 160 ?>
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 |
![]() |