[ 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/rapport/ -> Atome.class.php (source)

   1  <?php
   2  /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: Atome.class.php,v 1.5 2005/09/03 18:22:18 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/rapport/Atome.class.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/rapport/Atome.class.php
  25          \brief      Fichier de la classe mère Atome de génération de rapports
  26  */
  27  
  28  include_once DOL_DOCUMENT_ROOT.'/bargraph.class.php';
  29  
  30  
  31  /**
  32          \class      Atome
  33          \brief      Classe mère des classes de génération des images de rapports
  34  */
  35  
  36  class Atome
  37  {
  38      var $id;
  39      var $db;
  40      var $name;
  41      var $periode;
  42      var $graph_values;
  43      
  44      /**
  45       * Initialisation de la classe
  46       *
  47       */
  48      function AtomeInitialize($periode, $name, $daystart)
  49      {
  50          $this->year = strftime("%Y", $daystart);
  51          $this->month = strftime("%m", $daystart);
  52          $this->periode = $periode;
  53          $this->name = $name;
  54      }
  55      
  56      /**
  57       * 
  58       *
  59       */
  60      function BarGraph()
  61      {
  62          $dir = DOL_DATA_ROOT.'/rapport/images/';
  63          if (! is_dir($dir)) create_exdir($dir);
  64  
  65          $this->graph_values = array();
  66      
  67          if ($this->periode == 'year')
  68          {
  69              $filename = $dir . $this->name.$this->year.'.png';
  70      
  71              for ($i = 0 ; $i < 12 ; $i++)
  72              {
  73                  $index = $this->year . substr('00'.($i+1),-2);
  74                  $value = 0;
  75                  if ($this->datas[$index])
  76                  {
  77                      $value = $this->datas[$index];
  78                  }
  79      
  80                  $libelle = ucfirst(strftime("%b", mktime(12,0,0,($i+1),1,2004)));
  81      
  82                  $this->graph_values[$i] = array($libelle, $value);
  83              }
  84          }
  85      
  86          if ($this->periode == 'month')
  87          {
  88              $filename = $dir . $this->name.$this->year.$this->month.'.png';
  89      
  90              $datex = mktime(12,0,0,$this->month, 1, $this->year);
  91              $i = 0;
  92              while (strftime("%Y%m", $datex) == $this->year.$this->month)
  93              {
  94      
  95                  $index = $this->year . $this->month . substr('00'.($i+1),-2);
  96                  $value = 0;
  97                  if ($this->datas[$index])
  98                  {
  99                      $value = $this->datas[$index];
 100                  }
 101      
 102                  $libelle = ($i+1);
 103      
 104                  $this->graph_values[$i] = array($libelle, $value);
 105      
 106                  $i++;
 107                  $datex = $datex + 86400;
 108              }
 109          }
 110      
 111          // var_dump($this->graph_values);
 112      
 113      
 114          $bgraph = new BarGraph();
 115          $bgraph->SetData($this->graph_values);
 116          $bgraph->bgcolor = array(255,255,255);
 117          $bgraph->SetWidth(600);
 118          $bgraph->SetHeight(400);
 119          $bgraph->draw($filename);
 120      
 121          return $filename;
 122      }
 123      }
 124  ?>


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