[ 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/distributeurs/ -> distributeur.commission.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: distributeur.commission.class.php,v 1.6 2005/11/16 12:43:48 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/distributeurs/distributeur.commission.class.php,v $
  20   *
  21   */
  22  
  23  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
  24  
  25  class GraphDistributeurCommission extends GraphBar {
  26  
  27    Function GraphDistributeurCommission($DB, $file)
  28    {
  29      $this->db = $DB;
  30      $this->file = $file;
  31      $this->year = strftime("%Y",time());
  32      $this->client = 0;
  33      $this->titre = "Commissions mensuelles reversées ".$this->year;
  34  
  35      $this->barcolor = "orange";
  36      $this->showframe = true;
  37    }
  38  
  39    Function GraphMakeGraph($distributeur=0)
  40    {
  41      $num = 0;
  42      $this->no_xaxis_title=1;
  43      $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats";
  44      if ($distributeur > 0) {
  45        $sql .= " WHERE graph='distributeur.commission.mensuel.".$distributeur."';";
  46      } else {
  47        $sql .= " WHERE graph='distributeur.commission.mensuel';";
  48      }
  49  
  50      $resql = $this->db->query($sql);
  51  
  52  
  53      if ($distributeur > 0) {
  54        $sql = "SELECT date, montant";
  55        $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission";
  56        $sql .= " WHERE fk_distributeur = ".$distributeur;
  57        $sql .= " ORDER BY date ASC";
  58      } else {
  59        $sql = "SELECT legend, sum(valeur)";
  60        $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_stats";
  61        $sql .= " WHERE graph like 'distributeur.commission.mensuel.%'";
  62        $sql .= " GROUP BY legend ORDER BY ord ASC";
  63      }
  64  
  65      $resql = $this->db->query($sql);
  66  
  67      if ($resql)
  68        {
  69      $num = $this->db->num_rows($resql);
  70      $i = 0;
  71      $j = -1;
  72      $datas = array();
  73      $labels = array();
  74      
  75      while ($i < $num)
  76        {
  77          $row = $this->db->fetch_row($resql);    
  78                  
  79          $datas[$i] = $row[1];
  80          $comms[$row[0]] = $row[1];
  81          $labels[$i] = substr($row[0],-2)."/".substr($row[0],2,2);
  82          
  83          $sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats";
  84          $sqli .= " (graph,ord,legend,valeur)";
  85          if ($distributeur > 0) {
  86            $sqli .= " VALUES ('distributeur.commission.mensuel.".$distributeur."'";
  87          } else {
  88            $sqli .= " VALUES ('distributeur.commission.mensuel'";
  89          }
  90          $sqli .= ",'$i','".$row[0]."','".$datas[$i]."');";
  91          $resqli = $this->db->query($sqli);
  92  
  93          $i++;
  94        }    
  95      $this->db->free($resql);
  96        }
  97      else 
  98        {
  99      print $this->db->error() . ' ' . $sql;
 100        }                  
 101      $month = array();
 102      $month[1] = 'J';
 103      $month[2] = 'F';
 104      $month[3] = 'M';
 105      $month[4] = 'A';
 106      $month[5] = 'M';
 107      $month[6] = 'J';
 108      $month[7] = 'J';
 109      $month[8] = 'A';
 110      $month[9] = 'S';
 111      $month[10] = 'O';
 112      $month[11] = 'N';
 113      $month[12] = 'D';
 114  
 115      for ($i = 1 ; $i < 13 ; $i++)
 116        {
 117      $idx = $this->year.substr('0'.$i,-2);
 118      $datas[$i-1] = $comms[$idx];
 119      $labels[$i-1] = $month[$i];
 120        }
 121  
 122      if (sizeof($datas))
 123        {
 124      $this->GraphDraw($this->file, $datas, $labels);
 125        }
 126    }
 127  }   
 128  ?>


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