[ 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/ -> camoyen.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: camoyen.class.php,v 1.2 2005/02/14 15:45:42 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/graph/camoyen.class.php,v $
  20   *
  21   */
  22  
  23  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/brouzouf.class.php");
  24  
  25  class GraphCaMoyen extends GraphBrouzouf
  26  {
  27  
  28    Function GraphCaMoyen($DB, $file)
  29    {
  30      $this->db = $DB;
  31      $this->file = $file;
  32  
  33      $this->show_console = 0;
  34  
  35      $this->client = 0;
  36      $this->titre = "Chiffre d'affaire moyen par client (euros HT)";
  37  
  38      $this->barcolor = "yellow";
  39    }
  40  
  41  
  42    Function GraphDraw()
  43    {
  44      $ligne = new LigneTel($this->db);
  45          
  46      $sql = "SELECT date, sum(gain), sum(cout_vente), sum(fourn_montant)";
  47      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture";   
  48      $sql .= " WHERE fk_facture is not null";    
  49      $sql .= " GROUP BY date ASC";
  50      
  51      if ($this->db->query($sql))
  52        {
  53      $num1 = $this->db->num_rows();
  54      $i = 0;
  55      $labels = array();
  56      $cf = array();
  57      $cv = array();
  58      $gg = array();
  59      
  60      while ($i < $num1)
  61        {
  62          $row = $this->db->fetch_row();
  63  
  64          $g[$i]  = $row[1];        
  65          $cv[$i] = $row[2];
  66          $cf[$i] = $row[3];
  67  
  68          $labels[$i] = substr($row[0],5,2)."/".substr($row[0],2,2);
  69          
  70          $i++;
  71        }
  72      
  73      $this->db->free();
  74        }
  75      else 
  76        {
  77      print $this->db->error() . ' ' . $sql;
  78        }
  79      
  80      $sql = "SELECT f.date, count(l.fk_client_comm)";
  81      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f";   
  82      $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";   
  83      $sql .= " WHERE f.fk_facture is not null";
  84      $sql .= " AND l.rowid = f.fk_ligne";
  85      $sql .= " GROUP BY f.date ASC";
  86      
  87      if ($this->db->query($sql))
  88        {
  89      $num2 = $this->db->num_rows();
  90      $i = 0;
  91  
  92      $nbc = array();
  93      
  94      while ($i < $num2)
  95        {
  96          $row = $this->db->fetch_row();
  97  
  98          $nbc[$i]  = $row[1];        
  99          
 100          $i++;
 101        }
 102      
 103      $this->db->free();
 104        }
 105      else 
 106        {
 107      print $this->db->error() . ' ' . $sql;
 108        }
 109  
 110  
 111      if ($this->show_console)
 112        {
 113      print $this->client . " " . $cv[$i - 1]."\n";
 114        }
 115  
 116  
 117  
 118      for ($j = 0 ; $j < sizeof($nbc) ; $j++)
 119        {
 120      $camoy[$j] = $cv[$j] / $nbc[$j];
 121  
 122      if ($this->show_console)
 123        {
 124          print $labels[$j] . "\t" . $nbc[$j] ."\t" . price($cv[$j]) ."\t\t" . price($camoy[$j]) ."\n";
 125        }
 126        }
 127  
 128  
 129      if (($num1 * $num2) > 0)
 130        {
 131      $this->GraphMakeGraph($camoy, $labels);
 132        }
 133    }
 134  
 135  }   
 136  ?>


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