[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/telephonie/stats/graph/ -> ca.class.php (source)

   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: ca.class.php,v 1.6 2005/10/20 19:27:13 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/graph/ca.class.php,v $
  20   *
  21   */
  22  
  23  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/brouzouf.class.php");
  24  
  25  class GraphCa extends GraphBrouzouf
  26  {
  27  
  28    Function GraphCa($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 = "Chiffre d'affaire (euros HT)";
  37  
  38      $this->barcolor = "green";
  39    }
  40  
  41  
  42    Function GraphDraw()
  43    {
  44      $sql = "SELECT tf.date, sum(tf.gain), sum(tf.cout_vente), sum(tf.fourn_montant)";
  45      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as tf";   
  46  
  47      if ($this->client == 0 && $this->contrat == 0 && $this->ligne == 0)
  48        {
  49      $sql .= " WHERE tf.fk_facture is not null";    
  50        }
  51      elseif ($this->client > 0 && $this->contrat == 0 && $this->ligne == 0)
  52        {
  53      $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s";   
  54      $sql .= " WHERE fk_facture is not null";
  55      $sql .= " AND s.rowid = tf.fk_ligne";
  56      $sql .= " AND s.fk_client_comm = ".$this->client;
  57        }
  58      elseif ($this->client == 0 && $this->contrat > 0 && $this->ligne == 0)
  59        {
  60  
  61      $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s";   
  62      $sql .= " WHERE tf.fk_facture is not null";
  63      $sql .= " AND s.rowid = tf.fk_ligne";
  64      $sql .= " AND s.fk_contrat = ".$this->contrat;
  65        }
  66      elseif ($this->client == 0 && $this->contrat == 0 && $this->ligne > 0)
  67        {
  68      $sql .= " WHERE tf.fk_facture is not null";
  69      $sql .= " AND tf.fk_ligne = ".$this->ligne;
  70        }
  71  
  72      $sql .= " GROUP BY tf.date ASC";
  73  
  74      if ($this->db->query($sql))
  75        {
  76      $num = $this->db->num_rows();
  77      $i = 0;
  78  
  79      $labels = array();
  80      $cf = array();
  81      $cv = array();
  82      $gg = array();
  83      
  84      while ($i < $num)
  85        {
  86          $row = $this->db->fetch_row($i);    
  87          
  88          $cf[$i] = $row[3];
  89          $cv[$i] = $row[2];
  90          $g[$i]  = $row[1];
  91          $labels[$i] = substr($row[0],5,2);
  92          
  93          $i++;
  94        }
  95      
  96      $this->db->free();
  97        }
  98      else 
  99        {
 100      print $this->db->error() . ' ' . $sql;
 101        }
 102      
 103  
 104      if ($this->show_console)
 105        {
 106      print $this->client . " " . $cv[$i - 1]."\n";
 107        }    
 108  
 109      if ($num > 0)
 110        {
 111      $this->GraphMakeGraph($cv, $labels);
 112        }
 113    }
 114  
 115  }   
 116  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics