[ 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/ -> contrats.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: contrats.class.php,v 1.2 2005/03/14 11:46:00 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/commerciaux/contrats.class.php,v $
  20   *
  21   */
  22  
  23  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/pie.class.php");
  24  
  25  class GraphCommerciauxContrats extends GraphPie {
  26  
  27    Function GraphCommerciauxContrats($DB, $file)
  28    {
  29      $this->db = $DB;
  30      $this->file = $file;
  31  
  32      $this->client = 0;
  33      $this->titre = "Nb de contrat signé par commercial";
  34  
  35      $this->barcolor = "yellow";
  36      $this->showframe = true;
  37    }
  38  
  39    Function GraphMakeGraph($type)
  40    {
  41      $num = 0;
  42  
  43      if ($type == 'suivi')
  44        {
  45      $this->titre = "Contrats suivis par commercial";
  46        }
  47      else
  48        {
  49      $this->titre = "Contrats signés par commercial";
  50        }
  51  
  52      $sql = "SELECT u.firstname, u.name, count(*) as cc";
  53      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat as c";
  54      $sql .= " , ".MAIN_DB_PREFIX."user as u";
  55      if ($type == 'suivi')
  56        {
  57      $sql .= " WHERE c.fk_commercial_suiv = u.rowid";
  58        }
  59      else
  60        {
  61      $sql .= " WHERE c.fk_commercial_sign = u.rowid";
  62        }
  63      $sql .= " GROUP BY u.rowid ORDER BY CC desc";
  64      
  65      $result = $this->db->query($sql);
  66      if ($result)
  67        {
  68      $num = $this->db->num_rows();
  69      $i = 0;
  70      $datas = array();
  71      $labels = array();
  72      
  73      while ($i < $num)
  74        {
  75          $row = $this->db->fetch_row();
  76          
  77          $labels[$i] = $row[0] . " ".$row[1];
  78          $datas[$i] = $row[2];
  79          
  80          $i++;
  81        }
  82      
  83      $this->db->free();
  84        }
  85      else 
  86        {
  87      print $this->db->error() . ' ' . $sql;
  88        }
  89      
  90      $this->GraphDraw($this->file, $datas, $labels);
  91    }
  92  }   
  93  ?>


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