[ 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/commerciaux/ -> commercial.gain.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: commercial.gain.class.php,v 1.6 2005/12/01 15:11:57 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/commerciaux/commercial.gain.class.php,v $
  20   *
  21   */
  22  
  23  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
  24  
  25  class GraphCommercialGain extends GraphBar {
  26  
  27    Function GraphCommercialGain($DB, $file, $year=0)
  28    {
  29      $this->db = $DB;
  30      $this->file = $file;
  31      $this->year = $year;
  32      $this->client = 0;
  33      $this->titre = "Marge mensuelle";
  34      if ($this->year > 0)
  35        {
  36      $this->titre .= " ".$this->year;
  37        }
  38      $this->barcolor = "pink";
  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.gain.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      $sql = "SELECT date_format(f.date,'%Y%m'), sum(f.gain)";
  58      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f";
  59      $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
  60      $sql .= " WHERE l.rowid = f.fk_ligne";
  61      $sql .= " AND l.fk_commercial_sign = ".$commercial;
  62      if ($this->year > 0)
  63        {
  64      $sql .= " AND date_format(f.date,'%Y')='".$this->year."'";
  65        }
  66      $sql .= " GROUP BY date_format(f.date,'%Y%m') ASC";
  67  
  68      $resql = $this->db->query($sql);
  69  
  70      if ($resql)
  71        {
  72      $num = $this->db->num_rows($resql);
  73      $i = 0;
  74      $j = -1;
  75      $datas = array();
  76      $labels = array();
  77      
  78      while ($i < $num)
  79        {
  80          $row = $this->db->fetch_row($resql);    
  81                  
  82          $datas[$i] = $row[1];
  83          $labels[$i] = substr($row[0],-2);
  84  
  85          if ($commercial > 0)
  86            {
  87          $sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats";
  88          $sqli .= " (graph,ord,legend,valeur)";
  89          $sqli .= " VALUES ('commercial.gain.mensuel.".$commercial."'";
  90          $sqli .= ",'$i','".$row[0]."','".$datas[$i]."');";
  91          $resqli = $this->db->query($sqli);
  92            }
  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  ?>


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