[ 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/groupes/ -> groupe.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: groupe.gain.class.php,v 1.1 2005/05/04 13:13:32 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/commerciaux/groupes/groupe.gain.class.php,v $
  20   *
  21   */
  22  
  23  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
  24  
  25  class GraphGroupeGain extends GraphBar {
  26  
  27    Function GraphGroupeGain($DB, $file)
  28    {
  29      $this->db = $DB;
  30      $this->file = $file;
  31  
  32      $this->client = 0;
  33      $this->titre = "Gain mensuel du groupe";
  34  
  35      $this->barcolor = "pink";
  36      $this->showframe = true;
  37    }
  38  
  39    Function GraphMakeGraph($groupe=0)
  40    {
  41      $num = 0;
  42  
  43      $sql = "SELECT nom";
  44      $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as u";
  45      $sql .= " WHERE u.rowid = ".$groupe;
  46  
  47      $resql = $this->db->query($sql);
  48  
  49      if ($resql)
  50        {
  51      $row = $this->db->fetch_row($resql);                    
  52      $nom = $row[0];    
  53      $this->db->free($resql);
  54        }
  55      else 
  56        {
  57      print $this->db->error() . ' ' . $sql;
  58        }                  
  59  
  60      $this->titre = "Gain mensuel : ".$nom;
  61  
  62      $sql = "SELECT date_format(f.date,'%Y%m'), sum(f.gain)";
  63      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f";
  64      $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
  65      $sql .= " , ".MAIN_DB_PREFIX."usergroup_user as ug";
  66      $sql .= " WHERE l.rowid = f.fk_ligne";
  67      $sql .= " AND ug.fk_user = l.fk_commercial_sign";
  68      $sql .= " AND ug.fk_usergroup = ".$groupe;
  69      $sql .= " GROUP BY date_format(f.date,'%Y%m') ASC";
  70  
  71      $resql = $this->db->query($sql);
  72  
  73      if ($resql)
  74        {
  75      $num = $this->db->num_rows($resql);
  76      $i = 0;
  77      $j = -1;
  78      $datas = array();
  79      $labels = array();
  80      
  81      while ($i < $num)
  82        {
  83          $row = $this->db->fetch_row($resql);    
  84                  
  85          $datas[$i] = $row[1];
  86          $labels[$i] = substr($row[0],-2)."/".substr($row[0],2,2);
  87  
  88          $i++;
  89        }
  90      
  91      $this->db->free($resql);
  92        }
  93      else 
  94        {
  95      print $this->db->error() . ' ' . $sql;
  96        }                  
  97  
  98      if (sizeof($datas))
  99        {
 100      $this->GraphDraw($this->file, $datas, $labels);
 101        }
 102  
 103    }
 104  }   
 105  ?>


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