diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php
index 4a1eae6b1d7..eef574ad600 100644
--- a/htdocs/compta/bank/graph.php
+++ b/htdocs/compta/bank/graph.php
@@ -210,6 +210,7 @@ if ($_GET["account"] || $_GET["ref"])
$px->SetHeight($height);
$px->SetType('lines');
$px->setBgColor('onglet');
+ $px->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->draw($file);
@@ -283,12 +284,12 @@ if ($_GET["account"] || $_GET["ref"])
$xday = substr($textdate,6,2);
$i = 0;
- while ($xyear == $year)
+ while ($xyear == $year && $day <= $datetime)
{
$subtotal = $subtotal + (isset($amounts[$textdate]) ? $amounts[$textdate] : 0);
if ($day > $now)
{
- $datas[$i] = ''; // Valeur sp�ciale permettant de ne pas tracer le graph
+ $datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph
}
else
{
@@ -327,6 +328,8 @@ if ($_GET["account"] || $_GET["ref"])
$px->SetHeight($height);
$px->SetType('lines');
$px->setBgColor('onglet');
+ $px->setBgColorGrid(array(255,255,255));
+ $px->SetHideXGrid(true);
//$px->SetHorizTickIncrement(30.41); // 30.41 jours/mois en moyenne
$px->SetPrecisionY(0);
$px->draw($file);
@@ -426,6 +429,7 @@ if ($_GET["account"] || $_GET["ref"])
$px->SetHeight($height);
$px->SetType('lines');
$px->setBgColor('onglet');
+ $px->setBgColorGrid(array(255,255,255));
$px->SetPrecisionY(0);
$px->draw($file);
@@ -525,6 +529,7 @@ if ($_GET["account"] || $_GET["ref"])
$px->SetType('bars');
$px->SetShading(3);
$px->setBgColor('onglet');
+ $px->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->draw($file);
@@ -620,6 +625,7 @@ if ($_GET["account"] || $_GET["ref"])
$px->SetType('bars');
$px->SetShading(3);
$px->setBgColor('onglet');
+ $px->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->draw($file);
diff --git a/htdocs/core/dolgraph.class.php b/htdocs/core/dolgraph.class.php
index 861a0a3ad45..1e309c0fb29 100644
--- a/htdocs/core/dolgraph.class.php
+++ b/htdocs/core/dolgraph.class.php
@@ -18,28 +18,28 @@
*/
/**
- \file htdocs/dolgraph.class.php
- \brief Fichier de la classe mere de gestion des graph
- \version $Id$
- \remarks Usage:
- $graph_data = array(array('labelA',yA),array('labelB',yB));
- array(array('labelA',yA1,...,yAn),array('labelB',yB1,...yBn));
- $px = new DolGraph();
- $px->SetData($graph_data);
- $px->SetMaxValue($px->GetCeilMaxValue());
- $px->SetMinValue($px->GetFloorMinValue());
- $px->SetTitle("title");
- $px->SetLegend(array("Val1","Val2"));
- $px->SetWidth(width);
- $px->SetHeight(height);
- $px->draw("file.png");
-*/
+ \file htdocs/dolgraph.class.php
+ \brief Fichier de la classe mere de gestion des graph
+ \version $Id$
+ \remarks Usage:
+ $graph_data = array(array('labelA',yA),array('labelB',yB));
+ array(array('labelA',yA1,...,yAn),array('labelB',yB1,...yBn));
+ $px = new DolGraph();
+ $px->SetData($graph_data);
+ $px->SetMaxValue($px->GetCeilMaxValue());
+ $px->SetMinValue($px->GetFloorMinValue());
+ $px->SetTitle("title");
+ $px->SetLegend(array("Val1","Val2"));
+ $px->SetWidth(width);
+ $px->SetHeight(height);
+ $px->draw("file.png");
+ */
/**
- \class Graph
- \brief Classe mere permettant la gestion des graph
-*/
+ \class Graph
+ \brief Classe mere permettant la gestion des graph
+ */
class DolGraph
{
@@ -54,9 +54,16 @@ class DolGraph
var $MaxValue=0;
var $MinValue=0;
var $SetShading=0;
+
var $PrecisionY=-1;
- var $SetHorizTickIncrement=-1;
+
+ var $horizTickIncrement=-1;
var $SetNumXTicks=-1;
+ var $labelInterval=-1;
+
+ var $hideXGrid=false;
+ var $hideYGrid=false;
+
var $Legend=array();
var $LegendWidthMin=0;
@@ -67,6 +74,7 @@ class DolGraph
var $bordercolor; // array(R,G,B)
var $bgcolor; // array(R,G,B)
+ var $bgcolorgrid; // array(R,G,B)
var $datacolor; // array(array(R,G,B),...)
@@ -113,177 +121,6 @@ class DolGraph
}
- function isGraphKo()
- {
- return $this->error;
- }
-
- /**
- * \brief Genere le fichier graphique sur le disque
- * \param file Nom du fichier image
- */
- function draw($file)
- {
- if (! is_array($this->data) || sizeof($this->data) < 1)
- {
- $this->error="Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
- dolibarr_syslog("DolGraph::draw ".$this->error, LOG_ERR);
- return -1;
- }
- $call = "draw_".$this->library;
- $this->$call($file);
- }
-
-
- /**
- * \brief Generation graph a partir de la lib Artichow
- * \param file Nom fichier a generer
- */
- function draw_artichow($file)
- {
- dolibarr_syslog("DolGraph.class::draw_artichow this->type=".$this->type);
-
- if (! defined('SHADOW_RIGHT_TOP')) define('SHADOW_RIGHT_TOP',3);
- if (! defined('LEGEND_BACKGROUND')) define('LEGEND_BACKGROUND',2);
- if (! defined('LEGEND_LINE')) define('LEGEND_LINE',1);
-
- // Create graph
- $class='';
- if ($this->type == 'bars') $class='BarPlot';
- if ($this->type == 'lines') $class='LinePlot';
- include_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/".$class.".class.php";
-
- // Definition de couleurs
- $bgcolor=new Color($this->bgcolor[0],$this->bgcolor[1],$this->bgcolor[2]);
- $colortrans=new Color(0,0,0,100);
- $colorsemitrans=new Color(255,255,255,60);
- $colorgradient= new LinearGradient(new Color(235, 235, 235),new Color(255, 255, 255),0);
-
- // Graph
- $graph = new Graph($this->width, $this->height);
- $graph->border->hide();
- $graph->setAntiAliasing(true);
- if (isset($this->title))
- {
- $graph->title->set($this->title);
- $graph->title->setFont(new Tuffy(10));
- }
- // $graph->setBackgroundColor($bgcolor);
- $graph->setBackgroundGradient($colorgradient);
-
- $group = new PlotGroup;
- //$group->setSpace(5, 5, 0, 0);
-
- $paddleft=50;
- $paddright=10;
- $strl=strlen(max(abs($this->MaxValue),abs($this->MinValue)));
- if ($strl > 6) $paddleft += ($strln * 4);
- $group->setPadding($paddleft, $paddright); // Width on left and right for Y axis values
- $group->legend->setSpace(0);
- $group->legend->setPadding(2,2,2,2);
- $group->legend->setPosition(NULL,0.1);
- $group->legend->setBackgroundColor($colorsemitrans);
- $group->grid->setBackgroundColor($colortrans);
-
-
- // On boucle sur chaque lot de donnees
- $legends=array();
- $i=0;
- $nblot=sizeof($this->data[0])-1;
-
- while ($i < $nblot)
- {
- $j=0;
- $values=array();
- foreach($this->data as $key => $valarray)
- {
- $legends[$j] = $valarray[0];
- $values[$j] = $valarray[$i+1];
- $j++;
- }
-
- // Artichow ne gere pas les valeurs inconnues
- // Donc si inconnu, on la fixe a null
- $newvalues=array();
- foreach($values as $val)
- {
- $newvalues[]=(is_numeric($val) ? $val : null);
- }
-
-
- if ($this->type == 'bars')
- {
- //print "Lot de donnees $i
";
- //print_r($values);
- //print '
';
-
- $colorgrey=new Color(100,100,100);
- $color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20);
- $colorborder=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]);
-
- if ($this->mode == 'side') $plot = new BarPlot($newvalues, $i+1, $nblot);
- if ($this->mode == 'depth') $plot = new BarPlot($newvalues, 1, 1, ($nblot-$i-1)*5);
-
- $plot->barBorder->setColor($colorgrey);
- $plot->setBarColor($color);
-
- if ($this->mode == 'side') $plot->setBarPadding(0.1, 0.1);
- if ($this->mode == 'depth') $plot->setBarPadding(0.1, 0.4);
- if ($this->mode == 'side') $plot->setBarSpace(5);
- if ($this->mode == 'depth') $plot->setBarSpace(2);
-
- $plot->barShadow->setSize($this->SetShading);
- $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
- $plot->barShadow->setColor(new Color(160, 160, 160, 50));
- $plot->barShadow->smooth(TRUE);
- //$plot->setSize(1, 0.96);
- //$plot->setCenter(0.5, 0.52);
-
- // Le mode automatique est plus efficace
- $plot->SetYMax($this->MaxValue);
- $plot->SetYMin($this->MinValue);
- }
-
- if ($this->type == 'lines')
- {
- $color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20);
-
- $plot = new LinePlot($newvalues);
- //$plot->setSize(1, 0.96);
- //$plot->setCenter(0.5, 0.52);
-
- $plot->setColor($color);
- $plot->setThickness(2);
-
- // Le mode automatique est plus efficace
- $plot->SetYMax($this->MaxValue);
- $plot->SetYMin($this->MinValue);
- //$plot->setYAxis(0);
- //$plot->hideLine(true);
- }
-
- //$plot->reduce(80); // Evite temps d'affichage trop long et nombre de ticks absisce satures
-
- if (sizeof($this->Legend))
- {
- if ($this->type == 'bars') $group->legend->add($plot, $this->Legend[$i], LEGEND_BACKGROUND);
- if ($this->type == 'lines') $group->legend->add($plot, $this->Legend[$i], LEGEND_LINE);
- }
- $group->add($plot);
-
- $i++;
- }
-
- $group->axis->bottom->setLabelText($legends);
- $group->axis->bottom->label->setFont(new Tuffy(7));
-
- $graph->add($group);
-
- // Generate file
- $graph->draw($file);
- }
-
-
/**
*/
function SetPrecisionY($which_prec)
@@ -293,16 +130,16 @@ class DolGraph
}
/**
- \remarks Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
+ * \remarks Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
*/
function SetHorizTickIncrement($xi)
{
- $this->SetHorizTickIncrement = $xi;
+ $this->horizTickIncrement = $xi;
return true;
}
/**
- \remarks Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
+ * \remarks Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
*/
function SetNumXTicks($xt)
{
@@ -310,7 +147,33 @@ class DolGraph
return true;
}
+ /**
+ * \brief Set label interval to reduce number of labels
+ */
+ function SetLabelInterval($x)
+ {
+ $this->labelInterval = $x;
+ return true;
+ }
+
+ /**
+ * \brief Hide X grid
+ */
+ function SetHideXGrid($bool)
+ {
+ $this->hideXGrid = $bool;
+ return true;
+ }
+ /**
+ * \brief Hide Y grid
+ */
+ function SetHideYGrid($bool)
+ {
+ $this->hideYGrid = $bool;
+ return true;
+ }
+
function SetYLabel($label)
{
$this->YLabel = $label;
@@ -378,8 +241,19 @@ class DolGraph
unset($this->bgcolor);
}
+ function ResetBgColorGrid()
+ {
+ unset($this->bgcolorgrid);
+ }
+
+ function isGraphKo()
+ {
+ return $this->error;
+ }
+
+
/**
- * \brief Definie la couleur de fond du graphique
+ * \brief Definie la couleur de fond de l'image complete
* \param bg_color array(R,G,B) ou 'onglet' ou 'default'
*/
function SetBgColor($bg_color = array(255,255,255))
@@ -388,14 +262,14 @@ class DolGraph
if (! is_array($bg_color))
{
if ($bg_color == 'onglet')
- {
- //print 'ee'.join(',',$theme_bgcoloronglet);
- $this->bgcolor = $theme_bgcoloronglet;
- }
- else
- {
- $this->bgcolor = $theme_bgcolor;
- }
+ {
+ //print 'ee'.join(',',$theme_bgcoloronglet);
+ $this->bgcolor = $theme_bgcoloronglet;
+ }
+ else
+ {
+ $this->bgcolor = $theme_bgcolor;
+ }
}
else
{
@@ -403,6 +277,31 @@ class DolGraph
}
}
+ /**
+ * \brief Definie la couleur de fond de la grille
+ * \param bg_colorgrid array(R,G,B) ou 'onglet' ou 'default'
+ */
+ function SetBgColorGrid($bg_colorgrid = array(255,255,255))
+ {
+ global $theme_bgcolor,$theme_bgcoloronglet;
+ if (! is_array($bg_colorgrid))
+ {
+ if ($bg_colorgrid == 'onglet')
+ {
+ //print 'ee'.join(',',$theme_bgcoloronglet);
+ $this->bgcolorgrid = $theme_bgcoloronglet;
+ }
+ else
+ {
+ $this->bgcolorgrid = $theme_bgcolor;
+ }
+ }
+ else
+ {
+ $this->bgcolorgrid = $bg_colorgrid;
+ }
+ }
+
function ResetDataColor()
{
unset($this->datacolor);
@@ -480,15 +379,203 @@ class DolGraph
return $res;
}
-
-
-
+ /**
+ * \brief Genere le fichier graphique sur le disque
+ * \param file Nom du fichier image
+ */
+ function draw($file)
+ {
+ if (! is_array($this->data) || sizeof($this->data) < 1)
+ {
+ $this->error="Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
+ dolibarr_syslog("DolGraph::draw ".$this->error, LOG_ERR);
+ return -1;
+ }
+ $call = "draw_".$this->library;
+ $this->$call($file);
+ }
+
+
+ /**
+ * \brief Generation graph a partir de la lib Artichow
+ * \param file Nom fichier a generer
+ */
+ function draw_artichow($file)
+ {
+ dolibarr_syslog("DolGraph.class::draw_artichow this->type=".$this->type);
+
+ if (! defined('SHADOW_RIGHT_TOP')) define('SHADOW_RIGHT_TOP',3);
+ if (! defined('LEGEND_BACKGROUND')) define('LEGEND_BACKGROUND',2);
+ if (! defined('LEGEND_LINE')) define('LEGEND_LINE',1);
+
+ // Create graph
+ $class='';
+ if ($this->type == 'bars') $class='BarPlot';
+ if ($this->type == 'lines') $class='LinePlot';
+ include_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/".$class.".class.php";
+
+ // Definition de couleurs
+ $bgcolor=new Color($this->bgcolor[0],$this->bgcolor[1],$this->bgcolor[2]);
+ $bgcolorgrid=new Color($this->bgcolorgrid[0],$this->bgcolorgrid[1],$this->bgcolorgrid[2]);
+ $colortrans=new Color(0,0,0,100);
+ $colorsemitrans=new Color(255,255,255,60);
+ $colorgradient= new LinearGradient(new Color(235, 235, 235),new Color(255, 255, 255),0);
+ $colorwhite=new Color(255,255,255);
+
+ // Graph
+ $graph = new Graph($this->width, $this->height);
+ $graph->border->hide();
+ $graph->setAntiAliasing(true);
+ if (isset($this->title))
+ {
+ $graph->title->set($this->title);
+ $graph->title->setFont(new Tuffy(10));
+ }
+
+ if (is_array($this->bgcolor)) $graph->setBackgroundColor($bgcolor);
+ else $graph->setBackgroundGradient($colorgradient);
+
+ $group = new PlotGroup;
+ //$group->setSpace(5, 5, 0, 0);
+
+ $paddleft=50;
+ $paddright=10;
+ $strl=strlen(max(abs($this->MaxValue),abs($this->MinValue)));
+ if ($strl > 6) $paddleft += ($strln * 4);
+ $group->setPadding($paddleft, $paddright); // Width on left and right for Y axis values
+ $group->legend->setSpace(0);
+ $group->legend->setPadding(2,2,2,2);
+ $group->legend->setPosition(NULL,0.1);
+ $group->legend->setBackgroundColor($colorsemitrans);
+
+ if (is_array($this->bgcolorgrid)) $group->grid->setBackgroundColor($bgcolorgrid);
+ else $group->grid->setBackgroundColor($colortrans);
+
+ if ($this->hideXGrid) $group->grid->hideVertical(true);
+ if ($this->hideYGrid) $group->grid->hideHorizontal(true);
+
+ // On boucle sur chaque lot de donnees
+ $legends=array();
+ $i=0;
+ $nblot=sizeof($this->data[0])-1;
+
+ while ($i < $nblot)
+ {
+ $j=0;
+ $values=array();
+ foreach($this->data as $key => $valarray)
+ {
+ $legends[$j] = $valarray[0];
+ $values[$j] = $valarray[$i+1];
+ $j++;
+ }
+
+ // Artichow ne gere pas les valeurs inconnues
+ // Donc si inconnu, on la fixe a null
+ $newvalues=array();
+ foreach($values as $val)
+ {
+ $newvalues[]=(is_numeric($val) ? $val : null);
+ }
+
+
+ if ($this->type == 'bars')
+ {
+ //print "Lot de donnees $i
";
+ //print_r($values);
+ //print '
';
+
+ $color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20);
+ $colorbis=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),50);
+
+ $colorgrey=new Color(100,100,100);
+ $colorborder=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]);
+
+ if ($this->mode == 'side') $plot = new BarPlot($newvalues, $i+1, $nblot);
+ if ($this->mode == 'depth') $plot = new BarPlot($newvalues, 1, 1, ($nblot-$i-1)*5);
+
+ $plot->barBorder->setColor($colorgrey);
+ //$plot->setBarColor($color);
+ $plot->setBarGradient( new LinearGradient($colorbis, $color, 90) );
+
+ if ($this->mode == 'side') $plot->setBarPadding(0.1, 0.1);
+ if ($this->mode == 'depth') $plot->setBarPadding(0.1, 0.4);
+ if ($this->mode == 'side') $plot->setBarSpace(5);
+ if ($this->mode == 'depth') $plot->setBarSpace(2);
+
+ $plot->barShadow->setSize($this->SetShading);
+ $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
+ $plot->barShadow->setColor(new Color(160, 160, 160, 50));
+ $plot->barShadow->smooth(TRUE);
+ //$plot->setSize(1, 0.96);
+ //$plot->setCenter(0.5, 0.52);
+
+ // Le mode automatique est plus efficace
+ $plot->SetYMax($this->MaxValue);
+ $plot->SetYMin($this->MinValue);
+ }
+
+ if ($this->type == 'lines')
+ {
+ $color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20);
+ $colorbis=new Color(min($this->datacolor[$i][0]+20,255),min($this->datacolor[$i][1]+20,255),min($this->datacolor[$i][2]+20,255),60);
+ $colorter=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),90);
+
+ $plot = new LinePlot($newvalues);
+ //$plot->setSize(1, 0.96);
+ //$plot->setCenter(0.5, 0.52);
+
+ $plot->setColor($color);
+ $plot->setThickness(1);
+
+ // Set line background gradient
+ $plot->setFillGradient( new LinearGradient($colorter, $colorbis, 90) );
+
+ $plot->xAxis->setLabelText($legends);
+
+ // Le mode automatique est plus efficace
+ $plot->SetYMax($this->MaxValue);
+ $plot->SetYMin($this->MinValue);
+ //$plot->setYAxis(0);
+ //$plot->hideLine(true);
+ }
+
+ //$plot->reduce(80); // Evite temps d'affichage trop long et nombre de ticks absisce satures
+
+ if (sizeof($this->Legend))
+ {
+ if ($this->type == 'bars') $group->legend->add($plot, $this->Legend[$i], LEGEND_BACKGROUND);
+ if ($this->type == 'lines') $group->legend->add($plot, $this->Legend[$i], LEGEND_LINE);
+ }
+ $group->add($plot);
+
+ $i++;
+ }
+
+ $group->axis->bottom->setLabelText($legends);
+ $group->axis->bottom->label->setFont(new Tuffy(7));
+
+ //print $group->axis->bottom->getLabelNumber();
+ if ($this->labelInterval > 0) $group->axis->bottom->setLabelInterval($this->labelInterval);
+
+ $graph->add($group);
+
+ // Generate file
+ $graph->draw($file);
+ }
+
+
+
+ /*
+ * Special function
+ * \TODO Replace by standard code
+ */
function BarLineAnnualArtichow($file='', $barvalues, $linevalues, $legends='')
{
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/BarPlot.class.php";
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/LinePlot.class.php";
- $graph = new Graph(240, 220);
+ $graph = new Graph(240, 200);
$graph->title->set($this->title);
$graph->title->setFont(new Tuffy(10));
@@ -565,6 +652,10 @@ class DolGraph
$graph->draw($file);
}
+ /*
+ * Special function
+ * \TODO Replace by standard code
+ */
function BarLineOneYearArtichow($file='', $barvalues, $linevalues, $legends='')
{
$ok = 0;
@@ -583,7 +674,7 @@ class DolGraph
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/BarPlot.class.php";
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/LinePlot.class.php";
- $graph = new Graph(540, 220);
+ $graph = new Graph(540, 200);
$graph->title->set($this->title);
$graph->title->setFont(new Tuffy(10));
@@ -661,6 +752,10 @@ class DolGraph
}
}
+ /*
+ * Special function
+ * \TODO Replace by standard code
+ */
function BarAnnualArtichow($file='', $values='', $legends='')
{
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/BarPlot.class.php";
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index 1a4ebf77235..2b7d5fb8d56 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -29,4 +29,5 @@ ErrorGenbarCodeNotfound=File not found (Bad path, wrong permissions or access de
ErrorFunctionNotAvailableInPHP=Function %s is required for this feature but is not available in this version/setup of PHP.
ErrorDirAlreadyExists=A directory with this name already exists.
WarningAllowUrlFopenMustBeOn=Parameter allow_url_fopen must be set to on in filer php.ini for having this module working completely. You must modify this file manually.
-ErrorFieldCanNotContainSpecialCharacters=Field %s must not contains special characters.
\ No newline at end of file
+ErrorFieldCanNotContainSpecialCharacters=Field %s must not contains special characters.
+WarningBuildScriptNotRunned=Script %s was not yet ran to build graphics.
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang
index 256e9230b44..c0fd11d99eb 100644
--- a/htdocs/langs/fr_FR/errors.lang
+++ b/htdocs/langs/fr_FR/errors.lang
@@ -30,3 +30,4 @@ ErrorFunctionNotAvailableInPHP=La fonction %s est requise pour cette fonc
ErrorDirAlreadyExists=Un répertoire portant ce nom existe déjà.
WarningAllowUrlFopenMustBeOn=Attention, le paramètre allow_url_fopen doit etre positionné à on dans le fichier php.ini pour que ce module soit pleinement opérationnel. Vous devez modifier ce fichier manuellement.
ErrorFieldCanNotContainSpecialCharacters=Le champ %s ne peut contenir de caractères spéciaux.
+WarningBuildScriptNotRunned=Le script %s n'a pas encore été lancé pour générer les graphiques.
\ No newline at end of file
diff --git a/htdocs/product/stats/fiche.php b/htdocs/product/stats/fiche.php
index 875da6b1927..a77cbda2610 100644
--- a/htdocs/product/stats/fiche.php
+++ b/htdocs/product/stats/fiche.php
@@ -51,7 +51,7 @@ $mesg = '';
/*
- *
+ * View
*/
$html = new Form($db);
@@ -103,10 +103,11 @@ if ($_GET["id"] || $_GET["ref"])
print $product->getLibStatut(2);
print '';
- // Graphs additionels generes pas les cron
+
+ // Graphs additionels generes pas le script product-graph.php
$year = strftime('%Y',time());
$file = get_exdir($product->id, 3) . "ventes-".$year."-".$product->id.".png";
- if (file_exists (DOL_DATA_ROOT.'/graph/product/'.$file) )
+ if (file_exists (DOL_DATA_ROOT.'/product/temp/'.$file) )
{
print '
| Ventes | ';
@@ -118,9 +119,9 @@ if ($_GET["id"] || $_GET["ref"])
print ' |
';
}
+
print '';
print '';
-
print '';
diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php
index 1d8be40d8f2..3fa84aa4828 100644
--- a/htdocs/product/stock/fiche-valo.php
+++ b/htdocs/product/stock/fiche-valo.php
@@ -18,11 +18,11 @@
*/
/**
- \file htdocs/product/stock/fiche.php
- \ingroup stock
- \brief Page fiche de valorisation du stock dans l'entrepot
- \version $Id$
-*/
+ * \file htdocs/product/stock/fiche.php
+ * \ingroup stock
+ * \brief Page fiche de valorisation du stock dans l'entrepot
+ * \version $Id$
+ */
require("./pre.inc.php");
@@ -31,105 +31,117 @@ $langs->load("stocks");
$langs->load("companies");
$mesg = '';
+
+
+/*
+ * View
+ */
+
llxHeader("","",$langs->trans("WarehouseCard"));
if ($_GET["id"])
{
- if ($mesg) print $mesg;
-
- $entrepot = new Entrepot($db);
- $result = $entrepot->fetch($_GET["id"]);
- if ($result < 0)
- {
- dolibarr_print_error($db);
- }
-
- /*
- * Affichage fiche
- */
+ if ($mesg) print $mesg;
- /*
- * Affichage onglets
- */
- $h = 0;
-
- $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id;
- $head[$h][1] = $langs->trans("WarehouseCard");
- $h++;
-
- $head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id;
- $head[$h][1] = $langs->trans("StockMovements");
- $h++;
-
- $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$entrepot->id;
- $head[$h][1] = $langs->trans("EnhancedValue");
- $hselected=$h;
- $h++;
-
- if ($conf->global->STOCK_USE_WAREHOUSE_BY_USER)
- {
- // Add the constant STOCK_USE_WAREHOUSE_BY_USER in cont table to use this feature.
- // Should not be enabled by defaut because does not work yet correctly because
- // there is no way to add values in the table llx_user_entrepot
- $head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$entrepot->id;
- $head[$h][1] = $langs->trans("Users");
- $h++;
- }
- $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id;
- $head[$h][1] = $langs->trans("Info");
- $h++;
-
- dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle);
-
- print '';
-
- // Ref
- print '| '.$langs->trans("Ref").' | '.$entrepot->libelle.' | ';
-
- print '
| '.$langs->trans("LocationSummary").' | '.$entrepot->lieu.' |
';
-
- // Description
- print '| '.$langs->trans("Description").' | '.nl2br($entrepot->description).' |
';
-
- print '| '.$langs->trans('Address').' | ';
- print $entrepot->address;
- print ' |
';
-
- print '| '.$langs->trans('Zip').' | '.$entrepot->cp.' | ';
- print ''.$langs->trans('Town').' | '.$entrepot->ville.' |
';
-
- print '| '.$langs->trans('Country').' | ';
- print $entrepot->pays;
- print ' |
';
-
- // Statut
- print '| '.$langs->trans("Status").' | '.$entrepot->getLibStatut(4).' |
';
-
- print '| '.$langs->trans("NumberOfProducts").' | ';
- print $entrepot->nb_products();
- print " |
";
- print "
";
- print '';
-
-
- /* ************************************************************************** */
- /* */
- /* Graph */
- /* */
- /* ************************************************************************** */
-
- print "\n";
- $year = strftime("%Y",time());
- $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file=entrepot-'.$entrepot->id.'-'.$year.'.png';
- print '

';
-
- if (file_exists(DOL_DATA_ROOT.'/graph/entrepot/entrepot-'.$entrepot->id.'-'.($year-1).'.png'))
+ $entrepot = new Entrepot($db);
+ $result = $entrepot->fetch($_GET["id"]);
+ if ($result < 0)
{
- $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file=entrepot-'.$entrepot->id.'-'.($year-1).'.png';
- print '

';
+ dolibarr_print_error($db);
}
- print "
";
+ /*
+ * Affichage onglets
+ */
+ $h = 0;
+
+ $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id;
+ $head[$h][1] = $langs->trans("WarehouseCard");
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id;
+ $head[$h][1] = $langs->trans("StockMovements");
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$entrepot->id;
+ $head[$h][1] = $langs->trans("EnhancedValue");
+ $hselected=$h;
+ $h++;
+
+ if ($conf->global->STOCK_USE_WAREHOUSE_BY_USER)
+ {
+ // Add the constant STOCK_USE_WAREHOUSE_BY_USER in cont table to use this feature.
+ // Should not be enabled by defaut because does not work yet correctly because
+ // there is no way to add values in the table llx_user_entrepot
+ $head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$entrepot->id;
+ $head[$h][1] = $langs->trans("Users");
+ $h++;
+ }
+
+ $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id;
+ $head[$h][1] = $langs->trans("Info");
+ $h++;
+
+ dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle);
+
+ print '';
+
+ // Ref
+ print '| '.$langs->trans("Ref").' | '.$entrepot->libelle.' | ';
+
+ print '
| '.$langs->trans("LocationSummary").' | '.$entrepot->lieu.' |
';
+
+ // Description
+ print '| '.$langs->trans("Description").' | '.nl2br($entrepot->description).' |
';
+
+ print '| '.$langs->trans('Address').' | ';
+ print $entrepot->address;
+ print ' |
';
+
+ print '| '.$langs->trans('Zip').' | '.$entrepot->cp.' | ';
+ print ''.$langs->trans('Town').' | '.$entrepot->ville.' |
';
+
+ print '| '.$langs->trans('Country').' | ';
+ print $entrepot->pays;
+ print ' |
';
+
+ // Statut
+ print '| '.$langs->trans("Status").' | '.$entrepot->getLibStatut(4).' |
';
+
+ print '| '.$langs->trans("NumberOfProducts").' | ';
+ print $entrepot->nb_products();
+ print " |
";
+ print "
";
+ print '';
+
+
+ /* ************************************************************************** */
+ /* */
+ /* Graph */
+ /* */
+ /* ************************************************************************** */
+
+ print "\n";
+ $year = strftime("%Y",time());
+
+ if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year).'.png'))
+ {
+ $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file=entrepot-'.$entrepot->id.'-'.$year.'.png';
+ print '

';
+
+ if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year-1).'.png'))
+ {
+ $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file=entrepot-'.$entrepot->id.'-'.($year-1).'.png';
+ print '

';
+ }
+ }
+ else
+ {
+ $langs->load("errors");
+ if ($user->admin) print info_admin($langs->trans("WarningBuildScriptNotRunned",'stock-graph.php'));
+ }
+
+ print "
";
}
$db->close();
diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php
index 4c90f755d9b..399345e3e28 100644
--- a/htdocs/product/stock/valo.php
+++ b/htdocs/product/stock/valo.php
@@ -118,14 +118,14 @@ if ($result)
print '
';
$file='entrepot-'.$year.'.png';
- if (file_exists(DOL_DATA_ROOT.'/graph/entrepot/'.$file))
+ if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/'.$file))
{
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file;
print '
';
}
$file='entrepot-'.($year-1).'.png';
- if (file_exists(DOL_DATA_ROOT.'/graph/entrepot/'.$file))
+ if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/'.$file))
{
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file;
print '
';
diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php
index 0b730874e98..463e315a894 100644
--- a/htdocs/viewimage.php
+++ b/htdocs/viewimage.php
@@ -253,21 +253,21 @@ if ($modulepart)
elseif ($modulepart == 'graph_stock')
{
$accessallowed=1;
- $original_file=DOL_DATA_ROOT.'/graph/entrepot/'.$original_file;
+ $original_file=DOL_DATA_ROOT.'/entrepot/temp/'.$original_file;
}
// Wrapping pour les graph fournisseurs
elseif ($modulepart == 'graph_fourn')
{
$accessallowed=1;
- $original_file=DOL_DATA_ROOT.'/graph/fournisseur/'.$original_file;
+ $original_file=DOL_DATA_ROOT.'/fournisseur/temp/'.$original_file;
}
// Wrapping pour les graph des produits
elseif ($modulepart == 'graph_product')
{
$accessallowed=1;
- $original_file=DOL_DATA_ROOT.'/graph/product/'.$original_file;
+ $original_file=DOL_DATA_ROOT.'/product/temp/'.$original_file;
}
// Wrapping pour les code barre
diff --git a/scripts/banque/graph-solde.php b/scripts/banque/graph-solde.php
index 0210e87d5a4..81f687b3d4d 100644
--- a/scripts/banque/graph-solde.php
+++ b/scripts/banque/graph-solde.php
@@ -1,7 +1,7 @@
#!/usr/bin/php
- * Copyright (C) 2006 Laurent Destailleur
+/* Copyright (C) 2005 Rodolphe Quiedeville
+ * Copyright (C) 2006-2008 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
@@ -16,15 +16,14 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- * $Source$
*/
/**
- \file scripts/banque/graph-solde.php
- \ingroup banque
- \brief Script de génération des images des soldes des comptes
+ \file scripts/banque/graph-solde.php
+ \ingroup banque
+ \brief Script de génération des images des soldes des comptes
+ \deprecated Ce script n'est pas utilise.
+ \version $Id$
*/
@@ -39,7 +38,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
$path=eregi_replace('graph-solde.php','',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php");
-require_once($path."../../htdocs/core/dolgraph.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
$error = 0;
diff --git a/scripts/cron/facture-paye-stats.php b/scripts/cron/facture-paye-stats.php
index 220d98ee5e9..b22c06d493c 100644
--- a/scripts/cron/facture-paye-stats.php
+++ b/scripts/cron/facture-paye-stats.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2007 Laurent Destailleur
+/* Copyright (C) 2006 Rodolphe Quiedeville
+ * Copyright (C) 2007-2008 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
@@ -15,15 +15,14 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- * $Source$
*/
/**
- \file scripts/cron/facture-paye-stats.php
- \ingroup invoice
- \brief Statistiques sur le statut paye des factures
+ \file scripts/cron/facture-paye-stats.php
+ \ingroup invoice
+ \brief Script de mise a jour de la table facture_stats de statistiques
+ \deprecated Ce script et ces tables ne sont pas utilisees.
+ \version $Id$
*/
// Test si mode CLI
diff --git a/scripts/cron/fournisseur-calcul-ca_genere.php b/scripts/cron/fournisseur-calcul-ca_genere.php
index 25b27623fe3..c038921e5cd 100644
--- a/scripts/cron/fournisseur-calcul-ca_genere.php
+++ b/scripts/cron/fournisseur-calcul-ca_genere.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2007 Laurent Destailleur
+/* Copyright (C) 2006 Rodolphe Quiedeville
+ * Copyright (C) 2007-2008 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
@@ -15,15 +15,14 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- * $Source$
*/
/**
- \file scripts/cron/fournisseur-calcul-ca_genere.php
- \ingroup fournisseur
- \brief Calcul le CA généré par chaque fournisseur et genere graph
+ \file scripts/cron/fournisseur-calcul-ca_genere.php
+ \ingroup fournisseur
+ \brief Calcul le CA généré par chaque fournisseur et met a jour les tables fournisseur_ca et produit_ca
+ \deprecated Ce script et ces tables ne sont pas utilisees.
+ \version $Id$
*/
// Test si mode CLI
diff --git a/scripts/cron/fournisseur-graph.php b/scripts/cron/fournisseur-graph.php
index 793461598f5..9061616bcf6 100644
--- a/scripts/cron/fournisseur-graph.php
+++ b/scripts/cron/fournisseur-graph.php
@@ -18,10 +18,11 @@
*/
/**
- \file scripts/cron/fournisseur-graph.php
- \ingroup fournisseur
- \brief Script de génération graph fournisseur
- \version $Id$
+ \file scripts/cron/fournisseur-graph.php
+ \ingroup fournisseur
+ \brief Script de génération graph ca fournisseur depuis tables fournisseur_ca
+ \deprecated Ces graph ne sont pas utilises.
+ \version $Id$
*/
// Test si mode CLI
@@ -39,7 +40,7 @@ $version='$Revision$';
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php");
-require_once (DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
$error=0;
@@ -63,7 +64,7 @@ for ($i = 1 ; $i < sizeof($argv) ; $i++)
/*
*
*/
-$dir = DOL_DATA_ROOT."/graph/fournisseur";
+$dir = DOL_DATA_ROOT."/fournisseur/temp";
if (!is_dir($dir) )
{
if (! create_exdir($dir,0755))
diff --git a/scripts/cron/product-graph.php b/scripts/cron/product-graph.php
index 9ae93a2d3df..d7326a2edc0 100644
--- a/scripts/cron/product-graph.php
+++ b/scripts/cron/product-graph.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2007 Laurent Destailleur
+/* Copyright (C) 2006 Rodolphe Quiedeville
+ * Copyright (C) 2007-2008 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
@@ -18,28 +18,28 @@
*/
/**
- \file scripts/cron/product-graph.php
- \ingroup product
- \brief Crée les graphiques pour les produits
- \version $Id$
-*/
-
+ \file scripts/cron/product-graph.php
+ \ingroup product
+ \brief Crée les graphiques pour les produits
+ \version $Id$
+ */
+
// Test si mode CLI
$sapi_type = php_sapi_name();
-$script_file=__FILE__;
+$script_file=__FILE__;
if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1];
if (substr($sapi_type, 0, 3) == 'cgi') {
- echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
- exit;
+ echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
+ exit;
}
-
+
// Recupere env dolibarr
$version='$Revision$';
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php");
-require_once (DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
$error=0;
@@ -47,18 +47,18 @@ $verbose = 0;
for ($i = 1 ; $i < sizeof($argv) ; $i++)
{
- if ($argv[$i] == "-v")
- {
- $verbose = 1;
- }
- if ($argv[$i] == "-vv")
- {
- $verbose = 2;
- }
- if ($argv[$i] == "-vvv")
- {
- $verbose = 3;
- }
+ if ($argv[$i] == "-v")
+ {
+ $verbose = 1;
+ }
+ if ($argv[$i] == "-vv")
+ {
+ $verbose = 2;
+ }
+ if ($argv[$i] == "-vvv")
+ {
+ $verbose = 3;
+ }
}
$now = time();
@@ -67,13 +67,13 @@ $year = strftime('%Y',$now);
/*
*
*/
-$dir = DOL_DATA_ROOT."/graph/product";
+$dir = DOL_DATA_ROOT."/product/temp";
if (!is_dir($dir) )
{
- if (! create_exdir($dir,0755))
- {
- die ("Can't create $dir\n");
- }
+ if (! create_exdir($dir,0755))
+ {
+ die ("Can't create $dir\n");
+ }
}
/*
*
@@ -85,77 +85,76 @@ $resql = $db->query($sql) ;
$products = array();
if ($resql)
{
- while ($row = $db->fetch_row($resql))
- {
- $fdir = $dir.'/'.get_exdir($row[0],3);
+ while ($row = $db->fetch_row($resql))
+ {
+ $fdir = $dir.'/'.get_exdir($row[0],3);
- if ($verbose)
- print $fdir."\n";
- create_exdir($fdir);
+ if ($verbose) print $fdir."\n";
+ create_exdir($fdir);
- $products[$row[0]] = $fdir;
- }
- $db->free($resql);
+ $products[$row[0]] = $fdir;
+ }
+ $db->free($resql);
}
else
{
- print $sql;
+ print $sql;
}
/*
*
*/
foreach ( $products as $id => $fdir)
{
- $num = array();
- $ca = array();
- $legends = array();
+ $num = array();
+ $ca = array();
+ $legends = array();
- for ($i = 0 ; $i < 12 ; $i++)
- {
- $legends[$i] = strftime('%b',mktime(1,1,1,($i+1),1, $year) );
- $num[$i] = 0;
- $ca[$i] = 0;
- }
-
- $sql = "SELECT date_format(f.datef,'%b'), sum(fd.qty), sum(fd.total_ht), date_format(f.datef,'%m')";
- $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as fd";
- $sql .= " WHERE f.rowid = fd.fk_facture AND date_format(f.datef,'%Y')='".$year."'";
- $sql .= " AND fd.fk_product ='".$id."'";
- $sql .= " GROUP BY date_format(f.datef,'%b')";
- $sql .= " ORDER BY date_format(f.datef,'%m') ASC ;";
-
- $resql = $db->query($sql) ;
-
- if ($resql)
- {
- $i = 0;
- while ($row = $db->fetch_row($resql))
+ for ($i = 0 ; $i < 12 ; $i++)
{
+ $legends[$i] = strftime('%b',mktime(1,1,1,($i+1),1, $year) );
+ $num[$i] = 0;
+ $ca[$i] = 0;
+ }
+
+ $sql = "SELECT date_format(f.datef,'%b'), sum(fd.qty), sum(fd.total_ht), date_format(f.datef,'%m')";
+ $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as fd";
+ $sql .= " WHERE f.rowid = fd.fk_facture AND date_format(f.datef,'%Y')='".$year."'";
+ $sql .= " AND fd.fk_product ='".$id."'";
+ $sql .= " GROUP BY date_format(f.datef,'%b')";
+ $sql .= " ORDER BY date_format(f.datef,'%m') ASC ;";
+
+ $resql = $db->query($sql) ;
+
+ if ($resql)
+ {
+ $i = 0;
+ while ($row = $db->fetch_row($resql))
+ {
$legends[($row[3] - 1)] = $row[0];
$num[($row[3] - 1)] = $row[1];
- $ca[($row[3] - 1)] = $row[2];
+ $ca[($row[3] - 1)] = $row[2];
$i++;
+ }
+ $db->free($resql);
+ }
+ else
+ {
+ print $sql;
}
- $db->free($resql);
- }
- else
- {
- print $sql;
- }
- if ($i > 0)
- {
- $graph = new DolGraph();
-
- $file = $fdir ."ventes-".$year."-".$id.".png";
- $title = "Ventes";
-
- $graph->SetTitle($title);
- $graph->BarLineOneYearArtichow($file, $ca, $num, $legends);
+ if ($i > 0)
+ {
+ $graph = new DolGraph();
- if ($verbose)
- print "$file\n";
- }
+ $file = $fdir ."ventes-".$year."-".$id.".png";
+ $title = "Ventes";
+
+ $graph->SetTitle($title);
+ $graph->BarLineOneYearArtichow($file, $ca, $num, $legends);
+
+ if ($verbose)
+ print "$file\n";
+ }
}
/*
* Ventes annuelles
@@ -163,49 +162,49 @@ foreach ( $products as $id => $fdir)
*/
foreach ( $products as $id => $fdir)
{
- $num = array();
- $ca = array();
- $legends = array();
- $sql = "SELECT date_format(f.datef,'%Y'), sum(fd.qty), sum(fd.total_ht)";
- $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as fd";
- $sql .= " WHERE f.rowid = fd.fk_facture";
- $sql .= " AND fd.fk_product ='".$id."'";
- $sql .= " GROUP BY date_format(f.datef,'%Y')";
- $sql .= " ORDER BY date_format(f.datef,'%Y') ASC ;";
+ $num = array();
+ $ca = array();
+ $legends = array();
+ $sql = "SELECT date_format(f.datef,'%Y'), sum(fd.qty), sum(fd.total_ht)";
+ $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as fd";
+ $sql .= " WHERE f.rowid = fd.fk_facture";
+ $sql .= " AND fd.fk_product ='".$id."'";
+ $sql .= " GROUP BY date_format(f.datef,'%Y')";
+ $sql .= " ORDER BY date_format(f.datef,'%Y') ASC ;";
- $resql = $db->query($sql) ;
-
- if ($resql)
- {
- $i = 0;
- while ($row = $db->fetch_row($resql))
+ $resql = $db->query($sql) ;
+
+ if ($resql)
{
+ $i = 0;
+ while ($row = $db->fetch_row($resql))
+ {
$legends[$i] = $row[0];
$num[$i] = $row[1];
$ca[$i] = $row[2];
-
+
$i++;
+ }
+ $db->free($resql);
+ }
+ else
+ {
+ print $sql;
}
- $db->free($resql);
- }
- else
- {
- print $sql;
- }
- if ($i > 0)
- {
- $graph = new DolGraph();
-
- $file = $fdir ."ventes-".$id.".png";
- $title = "Ventes";
-
- $graph->SetTitle($title);
- $graph->BarLineAnnualArtichow($file, $ca, $num, $legends);
-
- if ($verbose)
- print "$file\n";
- }
+ if ($i > 0)
+ {
+ $graph = new DolGraph();
+
+ $file = $fdir ."ventes-".$id.".png";
+ $title = "Ventes";
+
+ $graph->SetTitle($title);
+ $graph->BarLineAnnualArtichow($file, $ca, $num, $legends);
+
+ if ($verbose)
+ print "$file\n";
+ }
}
diff --git a/scripts/cron/stock-graph.php b/scripts/cron/stock-graph.php
index 693dd968854..b309138852a 100644
--- a/scripts/cron/stock-graph.php
+++ b/scripts/cron/stock-graph.php
@@ -39,10 +39,16 @@ $version='$Revision$';
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
+
+
+/*
+ * Main
+ */
$error=0;
-$verbose = 0;
+$verbose = 0;
for ($i = 1 ; $i < sizeof($argv) ; $i++)
{
if ($argv[$i] == "-v")
@@ -60,7 +66,7 @@ for ($i = 1 ; $i < sizeof($argv) ; $i++)
}
-$dir = DOL_DATA_ROOT."/graph/entrepot";
+$dir = DOL_DATA_ROOT."/entrepot/temp";
$result=create_exdir($dir);
@@ -83,9 +89,6 @@ else
dolibarr_print_error($db,$sql);
}
-/*
- *
- */
$now = time();
$year = strftime('%Y',$now);
$day = strftime('%j', $now);
@@ -100,7 +103,7 @@ for ($i = 0 ; $i < strftime('%j',$now) ; $i++)
}
/*
- *
+ * Read values
*/
$sql = "SELECT date_format(date_calcul,'%j'), valo_pmp, fk_entrepot";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot_valorisation as e";
@@ -153,9 +156,11 @@ for ($i = $max_day + 1 ; $i < ($day + 1) ; $i++)
}
+// PMP = (quantités en stock x pmp ancien + nouvelles quantités x prix d'acquisition)/ (anciennes quantités + nouvelles quantités)
-require_once(DOL_DOCUMENT_ROOT."/../external-libs/Artichow/LinePlot.class.php");
-
+/*
+ * For each warehouse
+ */
foreach ($entrepots as $key => $ent)
{
$file = $dir ."/entrepot-".$key."-".$year.".png";
@@ -167,12 +172,12 @@ foreach ($entrepots as $key => $ent)
if ($verbose)
print "$file\n";
}
+
/*
- * Graph cumulatif
- *
+ * For all warehouses
*/
-$file = DOL_DATA_ROOT."/graph/entrepot/entrepot-".$year.".png";
-$title = "Valorisation PMP du stock global (euros HT) sur l'année ".$year;
+$file = $dir."/entrepot-".$year.".png";
+$title = "Valorisation PMP (Prix Moyen Pondéré) du stock global (euros HT) sur l'année ".$year;
if ($total[$key] > 0)
graph_datas($file, $title, $values[0], $legends);
@@ -180,7 +185,8 @@ if ($total[$key] > 0)
if ($verbose)
print "$file\n";
-
+
+
/** \brief Build graph
* \param file File
* \param title Title
@@ -189,44 +195,28 @@ if ($verbose)
*/
function graph_datas($file, $title, $values, $legends)
{
-
- $graph = new Graph(800, 250);
- $graph->title->set($title);
- $graph->title->setFont(new Tuffy(10));
-
- $graph->border->hide();
-
- $color = new Color(244,244,244);
-
- $graph->setAntiAliasing(TRUE);
- $graph->setBackgroundColor( $color );
-
- //$plot->yAxis->title->set("euros");
-
- $plot = new LinePlot($values);
- $plot->setSize(1, 0.96);
- $plot->setCenter(0.5, 0.52);
-
- // Change line color
- $plot->setColor(new Color(0, 0, 150, 20));
-
- // Set line background gradient
- $plot->setFillGradient(
- new LinearGradient(
- new Color(150, 150, 210),
- new Color(230, 230, 255),
- 90
- )
- );
-
- $plot->xAxis->setLabelText($legends);
- $plot->xAxis->label->setFont(new Tuffy(7));
-
- $plot->grid->hideVertical(TRUE);
- $plot->xAxis->setLabelInterval(31);
-
- $graph->add($plot);
-
- $graph->draw($file);
+ $width=800;
+ $height=230;
+
+ $newvalues=array();
+ foreach ($values as $abs=>$ord)
+ {
+ $newvalues[]=array($legends[$abs],$ord);
+ }
+
+ $px = new DolGraph();
+ $px->SetData($newvalues);
+ //$px->SetLegend('');
+ $px->SetMaxValue($px->GetCeilMaxValue());
+ $px->SetMinValue($px->GetFloorMinValue());
+ $px->SetTitle($title);
+ $px->SetWidth($width);
+ $px->SetHeight($height);
+ $px->SetType('lines');
+ $px->setBgColor('default');
+ $px->setBgColorGrid(array(255,255,255));
+ $px->SetHideXGrid(true);
+ $px->SetLabelInterval(31);
+ $px->draw($file);
}
?>