From b5cc17953f3d0eadd997f761dec4a34e804de96f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Sep 2005 18:22:18 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Echec=20g=E9n=E9ration=20images=20car=20?= =?UTF-8?q?r=E9pertoire=20inexistant.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/rapport/Atome.class.php | 182 ++++++++++++++++++--------------- htdocs/rapport/index.php | 2 +- 2 files changed, 98 insertions(+), 86 deletions(-) diff --git a/htdocs/rapport/Atome.class.php b/htdocs/rapport/Atome.class.php index e7f6f637b1d..cd742637a89 100644 --- a/htdocs/rapport/Atome.class.php +++ b/htdocs/rapport/Atome.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2005 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,96 +18,107 @@ * * $Id$ * $Source$ - * */ +/** + \file htdocs/rapport/Atome.class.php + \brief Fichier de la classe mère Atome de génération de rapports +*/ + include_once DOL_DOCUMENT_ROOT.'/bargraph.class.php'; + +/** + \class Atome + \brief Classe mère des classes de génération des images de rapports +*/ + class Atome { - var $id; - var $db; - var $name; - var $periode; - var $graph_values; - /** - * Initialisation de la classe - * - */ + var $id; + var $db; + var $name; + var $periode; + var $graph_values; + + /** + * Initialisation de la classe + * + */ + function AtomeInitialize($periode, $name, $daystart) + { + $this->year = strftime("%Y", $daystart); + $this->month = strftime("%m", $daystart); + $this->periode = $periode; + $this->name = $name; + } + + /** + * + * + */ + function BarGraph() + { + $dir = DOL_DATA_ROOT.'/rapport/images/'; + if (! is_dir($dir)) create_exdir($dir); - function AtomeInitialize($periode, $name, $daystart) - { - $this->year = strftime("%Y", $daystart); - $this->month = strftime("%m", $daystart); - $this->periode = $periode; - $this->name = $name; - } - /** - * - * - * - */ - function BarGraph() - { - $filename = DOL_DOCUMENT_ROOT.'/document/'; - - $this->graph_values = array(); - - if ($this->periode == 'year') - { - $filename .= $this->name.$this->year.'.png'; - - for ($i = 0 ; $i < 12 ; $i++) - { - $index = $this->year . substr('00'.($i+1),-2); - $value = 0; - if ($this->datas[$index]) - { - $value = $this->datas[$index]; - } - - $libelle = ucfirst(strftime("%b", mktime(12,0,0,($i+1),1,2004))); - - $this->graph_values[$i] = array($libelle, $value); - } - } - - if ($this->periode == 'month') - { - $filename .= $this->name.$this->year.$this->month.'.png'; - - $datex = mktime(12,0,0,$this->month, 1, $this->year); - $i = 0; - while (strftime("%Y%m", $datex) == $this->year.$this->month) - { - - $index = $this->year . $this->month . substr('00'.($i+1),-2); - $value = 0; - if ($this->datas[$index]) - { - $value = $this->datas[$index]; - } - - $libelle = ($i+1); - - $this->graph_values[$i] = array($libelle, $value); - - $i++; - $datex = $datex + 86400; - } - } - - // var_dump($this->graph_values); - - - $bgraph = new BarGraph(); - $bgraph->SetData($this->graph_values); - $bgraph->bgcolor = array(255,255,255); - $bgraph->SetWidth(600); - $bgraph->SetHeight(400); - $bgraph->draw($filename); - - return $filename; - } -} + $this->graph_values = array(); + + if ($this->periode == 'year') + { + $filename = $dir . $this->name.$this->year.'.png'; + + for ($i = 0 ; $i < 12 ; $i++) + { + $index = $this->year . substr('00'.($i+1),-2); + $value = 0; + if ($this->datas[$index]) + { + $value = $this->datas[$index]; + } + + $libelle = ucfirst(strftime("%b", mktime(12,0,0,($i+1),1,2004))); + + $this->graph_values[$i] = array($libelle, $value); + } + } + + if ($this->periode == 'month') + { + $filename = $dir . $this->name.$this->year.$this->month.'.png'; + + $datex = mktime(12,0,0,$this->month, 1, $this->year); + $i = 0; + while (strftime("%Y%m", $datex) == $this->year.$this->month) + { + + $index = $this->year . $this->month . substr('00'.($i+1),-2); + $value = 0; + if ($this->datas[$index]) + { + $value = $this->datas[$index]; + } + + $libelle = ($i+1); + + $this->graph_values[$i] = array($libelle, $value); + + $i++; + $datex = $datex + 86400; + } + } + + // var_dump($this->graph_values); + + + $bgraph = new BarGraph(); + $bgraph->SetData($this->graph_values); + $bgraph->bgcolor = array(255,255,255); + $bgraph->SetWidth(600); + $bgraph->SetHeight(400); + $bgraph->draw($filename); + + return $filename; + } + } ?> diff --git a/htdocs/rapport/index.php b/htdocs/rapport/index.php index f79f0ea5f24..83255b62328 100644 --- a/htdocs/rapport/index.php +++ b/htdocs/rapport/index.php @@ -87,7 +87,7 @@ print $img."
"; $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?>