[ 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/ -> ProcessGraphContrats.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: ProcessGraphContrats.class.php,v 1.7 2005/11/10 08:51:36 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/ProcessGraphContrats.class.php,v $
  20   *
  21   *
  22   * Generation des graphiques clients
  23   *
  24   *
  25   */
  26  require  ("../../master.inc.php");
  27  
  28  require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php");
  29  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/ca.class.php");
  30  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/gain.class.php");
  31  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/appelsdureemoyenne.class.php");
  32  
  33  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbmensuel.class.php");
  34  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbminutes.class.php");
  35  
  36  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/heureappel.class.php");
  37  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/joursemaine.class.php");
  38  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camoyen.class.php");
  39  
  40  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camenbert.class.php");
  41  
  42  /*
  43   * Process
  44   *
  45   */
  46  
  47  class ProcessGraphContrats
  48  {
  49    var $ident;
  50    
  51    function ProcessGraphContrats( $ident , $cpc)
  52    {
  53      global $conf;
  54      
  55      $this->ident = $ident;
  56      $this->cpc = $cpc;
  57      $this->db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,1);
  58    }
  59    
  60    function go($contrat_id = 0, $verbose)
  61    {
  62      if ($contrat_id == 0)
  63        {
  64      $min = $this->ident * $this->cpc;
  65      $max = ($this->ident + 1 ) * $this->cpc;
  66        }
  67      else
  68        {
  69      $min = $contrat_id;
  70      $max = $contrat_id;
  71        }
  72  
  73      dolibarr_syslog("Deb contrat ".$this->ident . " ($min - $max)");
  74      $error = 0;
  75  
  76      /*
  77       * Lecture des contrats
  78       *
  79       */
  80      $sql = "SELECT c.rowid";
  81      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat as c";
  82  
  83      if ($contrat_id == 0)
  84        {
  85      $sql .= " WHERE c.rowid >= ".$min;
  86      $sql .= " AND c.rowid < ".$max;
  87        }
  88      else
  89        {
  90      $sql .= " WHERE c.rowid = ".$min;
  91        }
  92      
  93      if ($this->db->query($sql))
  94        {
  95      $contrats = array();
  96      
  97      $num = $this->db->num_rows();
  98      $i = 0;
  99      
 100      while ($i < $num)
 101        {
 102          $obj = $this->db->fetch_object();    
 103          
 104          $contrats[$i] = $obj->rowid;
 105          $i++;
 106        }
 107        }
 108  
 109      if (sizeof($contrats))
 110        {
 111      foreach ($contrats as $contrat)
 112        {
 113          /* Chiffre d'affaire */
 114          
 115          $img_root = DOL_DATA_ROOT."/graph/".substr($contrat,-1)."/telephonie/contrat/";
 116  
 117          $file = $img_root . $contrat."/graphca.png";
 118          $graphca = new GraphCa($this->db, $file);
 119          $graphca->contrat = $contrat;
 120          $graphca->GraphDraw();
 121  
 122          /* Gain */
 123  
 124          $file = $img_root . $contrat."/graphgain.png";
 125  
 126          $graphgain = new GraphGain ($this->db, $file);
 127          $graphgain->contrat = $contrat;
 128          $graphgain->show_console = 0 ;
 129          $graphgain->GraphDraw();
 130  
 131          /* Duree moyenne des appels */
 132  
 133          $file = $img_root . $contrat."/graphappelsdureemoyenne.png";
 134          
 135          $graphduree = new GraphAppelsDureeMoyenne ($this->db, $file);
 136          $graphduree->contrat = $contrat;
 137          $graphduree->show_console = 0 ;
 138          $graphduree->Graph();
 139          
 140          /* Nb de communication */
 141  
 142          $file = $img_root . $contrat."/nb-comm-mensuel.png";
 143          
 144          $graphx = new GraphCommNbMensuel ($this->db, $file);
 145          $graphx->contrat = $contrat;
 146          $graphx->show_console = 0 ;
 147          $graphx->Graph();
 148  
 149          /* Nb de minutes */
 150  
 151          $file = $img_root . $contrat."/nb-minutes-mensuel.png";
 152          
 153          $graphx = new GraphCommNbMinutes ($this->db, $file);
 154          $graphx->contrat = $contrat;
 155          $graphx->show_console = 0 ;
 156          $graphx->Graph();
 157        }       
 158        }
 159  
 160      dolibarr_syslog("Fin contrat ".$this->ident);
 161    }
 162  }
 163  ?>


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