Qual Uniformize grph generation code

Look: Add transparency
This commit is contained in:
Laurent Destailleur 2008-08-25 21:56:04 +00:00
parent b321b8a164
commit 27da67a76f
14 changed files with 619 additions and 516 deletions

View File

@ -210,6 +210,7 @@ if ($_GET["account"] || $_GET["ref"])
$px->SetHeight($height); $px->SetHeight($height);
$px->SetType('lines'); $px->SetType('lines');
$px->setBgColor('onglet'); $px->setBgColor('onglet');
$px->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1); $px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px->SetPrecisionY(0);
$px->draw($file); $px->draw($file);
@ -283,12 +284,12 @@ if ($_GET["account"] || $_GET["ref"])
$xday = substr($textdate,6,2); $xday = substr($textdate,6,2);
$i = 0; $i = 0;
while ($xyear == $year) while ($xyear == $year && $day <= $datetime)
{ {
$subtotal = $subtotal + (isset($amounts[$textdate]) ? $amounts[$textdate] : 0); $subtotal = $subtotal + (isset($amounts[$textdate]) ? $amounts[$textdate] : 0);
if ($day > $now) if ($day > $now)
{ {
$datas[$i] = ''; // Valeur sp<EFBFBD>ciale permettant de ne pas tracer le graph $datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph
} }
else else
{ {
@ -327,6 +328,8 @@ if ($_GET["account"] || $_GET["ref"])
$px->SetHeight($height); $px->SetHeight($height);
$px->SetType('lines'); $px->SetType('lines');
$px->setBgColor('onglet'); $px->setBgColor('onglet');
$px->setBgColorGrid(array(255,255,255));
$px->SetHideXGrid(true);
//$px->SetHorizTickIncrement(30.41); // 30.41 jours/mois en moyenne //$px->SetHorizTickIncrement(30.41); // 30.41 jours/mois en moyenne
$px->SetPrecisionY(0); $px->SetPrecisionY(0);
$px->draw($file); $px->draw($file);
@ -426,6 +429,7 @@ if ($_GET["account"] || $_GET["ref"])
$px->SetHeight($height); $px->SetHeight($height);
$px->SetType('lines'); $px->SetType('lines');
$px->setBgColor('onglet'); $px->setBgColor('onglet');
$px->setBgColorGrid(array(255,255,255));
$px->SetPrecisionY(0); $px->SetPrecisionY(0);
$px->draw($file); $px->draw($file);
@ -525,6 +529,7 @@ if ($_GET["account"] || $_GET["ref"])
$px->SetType('bars'); $px->SetType('bars');
$px->SetShading(3); $px->SetShading(3);
$px->setBgColor('onglet'); $px->setBgColor('onglet');
$px->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1); $px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px->SetPrecisionY(0);
$px->draw($file); $px->draw($file);
@ -620,6 +625,7 @@ if ($_GET["account"] || $_GET["ref"])
$px->SetType('bars'); $px->SetType('bars');
$px->SetShading(3); $px->SetShading(3);
$px->setBgColor('onglet'); $px->setBgColor('onglet');
$px->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1); $px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px->SetPrecisionY(0);
$px->draw($file); $px->draw($file);

View File

@ -18,28 +18,28 @@
*/ */
/** /**
\file htdocs/dolgraph.class.php \file htdocs/dolgraph.class.php
\brief Fichier de la classe mere de gestion des graph \brief Fichier de la classe mere de gestion des graph
\version $Id$ \version $Id$
\remarks Usage: \remarks Usage:
$graph_data = array(array('labelA',yA),array('labelB',yB)); $graph_data = array(array('labelA',yA),array('labelB',yB));
array(array('labelA',yA1,...,yAn),array('labelB',yB1,...yBn)); array(array('labelA',yA1,...,yAn),array('labelB',yB1,...yBn));
$px = new DolGraph(); $px = new DolGraph();
$px->SetData($graph_data); $px->SetData($graph_data);
$px->SetMaxValue($px->GetCeilMaxValue()); $px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()); $px->SetMinValue($px->GetFloorMinValue());
$px->SetTitle("title"); $px->SetTitle("title");
$px->SetLegend(array("Val1","Val2")); $px->SetLegend(array("Val1","Val2"));
$px->SetWidth(width); $px->SetWidth(width);
$px->SetHeight(height); $px->SetHeight(height);
$px->draw("file.png"); $px->draw("file.png");
*/ */
/** /**
\class Graph \class Graph
\brief Classe mere permettant la gestion des graph \brief Classe mere permettant la gestion des graph
*/ */
class DolGraph class DolGraph
{ {
@ -54,9 +54,16 @@ class DolGraph
var $MaxValue=0; var $MaxValue=0;
var $MinValue=0; var $MinValue=0;
var $SetShading=0; var $SetShading=0;
var $PrecisionY=-1; var $PrecisionY=-1;
var $SetHorizTickIncrement=-1;
var $horizTickIncrement=-1;
var $SetNumXTicks=-1; var $SetNumXTicks=-1;
var $labelInterval=-1;
var $hideXGrid=false;
var $hideYGrid=false;
var $Legend=array(); var $Legend=array();
var $LegendWidthMin=0; var $LegendWidthMin=0;
@ -67,6 +74,7 @@ class DolGraph
var $bordercolor; // array(R,G,B) var $bordercolor; // array(R,G,B)
var $bgcolor; // array(R,G,B) var $bgcolor; // array(R,G,B)
var $bgcolorgrid; // array(R,G,B)
var $datacolor; // array(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<br>";
//print_r($values);
//print '<br>';
$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) 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) function SetHorizTickIncrement($xi)
{ {
$this->SetHorizTickIncrement = $xi; $this->horizTickIncrement = $xi;
return true; return true;
} }
/** /**
\remarks Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * \remarks Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
*/ */
function SetNumXTicks($xt) function SetNumXTicks($xt)
{ {
@ -310,7 +147,33 @@ class DolGraph
return true; 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) function SetYLabel($label)
{ {
$this->YLabel = $label; $this->YLabel = $label;
@ -378,8 +241,19 @@ class DolGraph
unset($this->bgcolor); 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' * \param bg_color array(R,G,B) ou 'onglet' ou 'default'
*/ */
function SetBgColor($bg_color = array(255,255,255)) function SetBgColor($bg_color = array(255,255,255))
@ -388,14 +262,14 @@ class DolGraph
if (! is_array($bg_color)) if (! is_array($bg_color))
{ {
if ($bg_color == 'onglet') if ($bg_color == 'onglet')
{ {
//print 'ee'.join(',',$theme_bgcoloronglet); //print 'ee'.join(',',$theme_bgcoloronglet);
$this->bgcolor = $theme_bgcoloronglet; $this->bgcolor = $theme_bgcoloronglet;
} }
else else
{ {
$this->bgcolor = $theme_bgcolor; $this->bgcolor = $theme_bgcolor;
} }
} }
else 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() function ResetDataColor()
{ {
unset($this->datacolor); unset($this->datacolor);
@ -480,15 +379,203 @@ class DolGraph
return $res; 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<br>";
//print_r($values);
//print '<br>';
$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='') 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/BarPlot.class.php";
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/LinePlot.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->set($this->title);
$graph->title->setFont(new Tuffy(10)); $graph->title->setFont(new Tuffy(10));
@ -565,6 +652,10 @@ class DolGraph
$graph->draw($file); $graph->draw($file);
} }
/*
* Special function
* \TODO Replace by standard code
*/
function BarLineOneYearArtichow($file='', $barvalues, $linevalues, $legends='') function BarLineOneYearArtichow($file='', $barvalues, $linevalues, $legends='')
{ {
$ok = 0; $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/BarPlot.class.php";
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/LinePlot.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->set($this->title);
$graph->title->setFont(new Tuffy(10)); $graph->title->setFont(new Tuffy(10));
@ -661,6 +752,10 @@ class DolGraph
} }
} }
/*
* Special function
* \TODO Replace by standard code
*/
function BarAnnualArtichow($file='', $values='', $legends='') function BarAnnualArtichow($file='', $values='', $legends='')
{ {
require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/BarPlot.class.php"; require_once DOL_DOCUMENT_ROOT."/../external-libs/Artichow/BarPlot.class.php";

View File

@ -29,4 +29,5 @@ ErrorGenbarCodeNotfound=File not found (Bad path, wrong permissions or access de
ErrorFunctionNotAvailableInPHP=Function <b>%s</b> is required for this feature but is not available in this version/setup of PHP. ErrorFunctionNotAvailableInPHP=Function <b>%s</b> is required for this feature but is not available in this version/setup of PHP.
ErrorDirAlreadyExists=A directory with this name already exists. ErrorDirAlreadyExists=A directory with this name already exists.
WarningAllowUrlFopenMustBeOn=Parameter <b>allow_url_fopen</b> must be set to <b>on</b> in filer <b>php.ini</b> for having this module working completely. You must modify this file manually. WarningAllowUrlFopenMustBeOn=Parameter <b>allow_url_fopen</b> must be set to <b>on</b> in filer <b>php.ini</b> for having this module working completely. You must modify this file manually.
ErrorFieldCanNotContainSpecialCharacters=Field <b>%s</b> must not contains special characters. ErrorFieldCanNotContainSpecialCharacters=Field <b>%s</b> must not contains special characters.
WarningBuildScriptNotRunned=Script <b>%s</b> was not yet ran to build graphics.

View File

@ -30,3 +30,4 @@ ErrorFunctionNotAvailableInPHP=La fonction <b>%s</b> est requise pour cette fonc
ErrorDirAlreadyExists=Un répertoire portant ce nom existe déjà. ErrorDirAlreadyExists=Un répertoire portant ce nom existe déjà.
WarningAllowUrlFopenMustBeOn=Attention, le paramètre <b>allow_url_fopen</b> doit etre positionné à <b>on</b> dans le fichier <b>php.ini</b> pour que ce module soit pleinement opérationnel. Vous devez modifier ce fichier manuellement. WarningAllowUrlFopenMustBeOn=Attention, le paramètre <b>allow_url_fopen</b> doit etre positionné à <b>on</b> dans le fichier <b>php.ini</b> pour que ce module soit pleinement opérationnel. Vous devez modifier ce fichier manuellement.
ErrorFieldCanNotContainSpecialCharacters=Le champ <b>%s</b> ne peut contenir de caractères spéciaux. ErrorFieldCanNotContainSpecialCharacters=Le champ <b>%s</b> ne peut contenir de caractères spéciaux.
WarningBuildScriptNotRunned=Le script <b>%s</b> n'a pas encore été lancé pour générer les graphiques.

View File

@ -51,7 +51,7 @@ $mesg = '';
/* /*
* * View
*/ */
$html = new Form($db); $html = new Form($db);
@ -103,10 +103,11 @@ if ($_GET["id"] || $_GET["ref"])
print $product->getLibStatut(2); print $product->getLibStatut(2);
print '</td></tr>'; print '</td></tr>';
// Graphs additionels generes pas les cron
// Graphs additionels generes pas le script product-graph.php
$year = strftime('%Y',time()); $year = strftime('%Y',time());
$file = get_exdir($product->id, 3) . "ventes-".$year."-".$product->id.".png"; $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 '<tr><td>Ventes</td><td>'; print '<tr><td>Ventes</td><td>';
@ -118,9 +119,9 @@ if ($_GET["id"] || $_GET["ref"])
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<table width="100%">'; print '<table width="100%">';

View File

@ -18,11 +18,11 @@
*/ */
/** /**
\file htdocs/product/stock/fiche.php * \file htdocs/product/stock/fiche.php
\ingroup stock * \ingroup stock
\brief Page fiche de valorisation du stock dans l'entrepot * \brief Page fiche de valorisation du stock dans l'entrepot
\version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -31,105 +31,117 @@ $langs->load("stocks");
$langs->load("companies"); $langs->load("companies");
$mesg = ''; $mesg = '';
/*
* View
*/
llxHeader("","",$langs->trans("WarehouseCard")); llxHeader("","",$langs->trans("WarehouseCard"));
if ($_GET["id"]) if ($_GET["id"])
{ {
if ($mesg) print $mesg; if ($mesg) print $mesg;
$entrepot = new Entrepot($db);
$result = $entrepot->fetch($_GET["id"]);
if ($result < 0)
{
dolibarr_print_error($db);
}
/*
* Affichage fiche
*/
/* $entrepot = new Entrepot($db);
* Affichage onglets $result = $entrepot->fetch($_GET["id"]);
*/ if ($result < 0)
$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 '<table class="border" width="100%">';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$entrepot->libelle.'</td>';
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>';
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">';
print $entrepot->address;
print '</td></tr>';
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$entrepot->cp.'</td>';
print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->ville.'</td></tr>';
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
print $entrepot->pays;
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->getLibStatut(4).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
print $entrepot->nb_products();
print "</td></tr>";
print "</table>";
print '</div>';
/* ************************************************************************** */
/* */
/* Graph */
/* */
/* ************************************************************************** */
print "<div class=\"graph\">\n";
$year = strftime("%Y",time());
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.$year.'.png';
print '<img src="'.$url.'" alt="Valorisation du stock année '.($year).'">';
if (file_exists(DOL_DATA_ROOT.'/graph/entrepot/entrepot-'.$entrepot->id.'-'.($year-1).'.png'))
{ {
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.($year-1).'.png'; dolibarr_print_error($db);
print '<br /><img src="'.$url.'" alt="Valorisation du stock année '.($year-1).'">';
} }
print "</div>"; /*
* 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 '<table class="border" width="100%">';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$entrepot->libelle.'</td>';
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>';
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">';
print $entrepot->address;
print '</td></tr>';
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$entrepot->cp.'</td>';
print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->ville.'</td></tr>';
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
print $entrepot->pays;
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->getLibStatut(4).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
print $entrepot->nb_products();
print "</td></tr>";
print "</table>";
print '</div>';
/* ************************************************************************** */
/* */
/* Graph */
/* */
/* ************************************************************************** */
print "<div class=\"graph\">\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&amp;file=entrepot-'.$entrepot->id.'-'.$year.'.png';
print '<img src="'.$url.'" alt="Valorisation du stock année '.($year).'">';
if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year-1).'.png'))
{
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.($year-1).'.png';
print '<br /><img src="'.$url.'" alt="Valorisation du stock année '.($year-1).'">';
}
}
else
{
$langs->load("errors");
if ($user->admin) print info_admin($langs->trans("WarningBuildScriptNotRunned",'stock-graph.php'));
}
print "</div>";
} }
$db->close(); $db->close();

View File

@ -118,14 +118,14 @@ if ($result)
print '<br />'; print '<br />';
$file='entrepot-'.$year.'.png'; $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&amp;file='.$file; $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file='.$file;
print '<img src="'.$url.'" alt="Valorisation du stock année '.($year).'">'; print '<img src="'.$url.'" alt="Valorisation du stock année '.($year).'">';
} }
$file='entrepot-'.($year-1).'.png'; $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&amp;file='.$file; $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file='.$file;
print '<br /><img src="'.$url.'" alt="Valorisation du stock année '.($year-1).'">'; print '<br /><img src="'.$url.'" alt="Valorisation du stock année '.($year-1).'">';

View File

@ -253,21 +253,21 @@ if ($modulepart)
elseif ($modulepart == 'graph_stock') elseif ($modulepart == 'graph_stock')
{ {
$accessallowed=1; $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 // Wrapping pour les graph fournisseurs
elseif ($modulepart == 'graph_fourn') elseif ($modulepart == 'graph_fourn')
{ {
$accessallowed=1; $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 // Wrapping pour les graph des produits
elseif ($modulepart == 'graph_product') elseif ($modulepart == 'graph_product')
{ {
$accessallowed=1; $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 // Wrapping pour les code barre

View File

@ -1,7 +1,7 @@
#!/usr/bin/php #!/usr/bin/php
<?PHP <?PHP
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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 * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/ */
/** /**
\file scripts/banque/graph-solde.php \file scripts/banque/graph-solde.php
\ingroup banque \ingroup banque
\brief Script de génération des images des soldes des comptes \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"]); $path=eregi_replace('graph-solde.php','',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php"); 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; $error = 0;

View File

@ -1,6 +1,6 @@
<?PHP <?PHP
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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 * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/ */
/** /**
\file scripts/cron/facture-paye-stats.php \file scripts/cron/facture-paye-stats.php
\ingroup invoice \ingroup invoice
\brief Statistiques sur le statut paye des factures \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 // Test si mode CLI

View File

@ -1,6 +1,6 @@
<?PHP <?PHP
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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 * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/ */
/** /**
\file scripts/cron/fournisseur-calcul-ca_genere.php \file scripts/cron/fournisseur-calcul-ca_genere.php
\ingroup fournisseur \ingroup fournisseur
\brief Calcul le CA généré par chaque fournisseur et genere graph \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 // Test si mode CLI

View File

@ -18,10 +18,11 @@
*/ */
/** /**
\file scripts/cron/fournisseur-graph.php \file scripts/cron/fournisseur-graph.php
\ingroup fournisseur \ingroup fournisseur
\brief Script de génération graph fournisseur \brief Script de génération graph ca fournisseur depuis tables fournisseur_ca
\version $Id$ \deprecated Ces graph ne sont pas utilises.
\version $Id$
*/ */
// Test si mode CLI // Test si mode CLI
@ -39,7 +40,7 @@ $version='$Revision$';
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]); $path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php"); 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; $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 (!is_dir($dir) )
{ {
if (! create_exdir($dir,0755)) if (! create_exdir($dir,0755))

View File

@ -1,6 +1,6 @@
<?PHP <?PHP
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -18,28 +18,28 @@
*/ */
/** /**
\file scripts/cron/product-graph.php \file scripts/cron/product-graph.php
\ingroup product \ingroup product
\brief Crée les graphiques pour les produits \brief Crée les graphiques pour les produits
\version $Id$ \version $Id$
*/ */
// Test si mode CLI // Test si mode CLI
$sapi_type = php_sapi_name(); $sapi_type = php_sapi_name();
$script_file=__FILE__; $script_file=__FILE__;
if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1]; if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1];
if (substr($sapi_type, 0, 3) == 'cgi') { 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"; 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; exit;
} }
// Recupere env dolibarr // Recupere env dolibarr
$version='$Revision$'; $version='$Revision$';
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]); $path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php"); 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; $error=0;
@ -47,18 +47,18 @@ $verbose = 0;
for ($i = 1 ; $i < sizeof($argv) ; $i++) for ($i = 1 ; $i < sizeof($argv) ; $i++)
{ {
if ($argv[$i] == "-v") if ($argv[$i] == "-v")
{ {
$verbose = 1; $verbose = 1;
} }
if ($argv[$i] == "-vv") if ($argv[$i] == "-vv")
{ {
$verbose = 2; $verbose = 2;
} }
if ($argv[$i] == "-vvv") if ($argv[$i] == "-vvv")
{ {
$verbose = 3; $verbose = 3;
} }
} }
$now = time(); $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 (!is_dir($dir) )
{ {
if (! create_exdir($dir,0755)) if (! create_exdir($dir,0755))
{ {
die ("Can't create $dir\n"); die ("Can't create $dir\n");
} }
} }
/* /*
* *
@ -85,77 +85,76 @@ $resql = $db->query($sql) ;
$products = array(); $products = array();
if ($resql) if ($resql)
{ {
while ($row = $db->fetch_row($resql)) while ($row = $db->fetch_row($resql))
{ {
$fdir = $dir.'/'.get_exdir($row[0],3); $fdir = $dir.'/'.get_exdir($row[0],3);
if ($verbose) if ($verbose) print $fdir."\n";
print $fdir."\n"; create_exdir($fdir);
create_exdir($fdir);
$products[$row[0]] = $fdir; $products[$row[0]] = $fdir;
} }
$db->free($resql); $db->free($resql);
} }
else else
{ {
print $sql; print $sql;
} }
/* /*
* *
*/ */
foreach ( $products as $id => $fdir) foreach ( $products as $id => $fdir)
{ {
$num = array(); $num = array();
$ca = array(); $ca = array();
$legends = array(); $legends = array();
for ($i = 0 ; $i < 12 ; $i++) 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[$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]; $legends[($row[3] - 1)] = $row[0];
$num[($row[3] - 1)] = $row[1]; $num[($row[3] - 1)] = $row[1];
$ca[($row[3] - 1)] = $row[2]; $ca[($row[3] - 1)] = $row[2];
$i++; $i++;
}
$db->free($resql);
}
else
{
print $sql;
} }
$db->free($resql);
}
else
{
print $sql;
}
if ($i > 0) if ($i > 0)
{ {
$graph = new DolGraph(); $graph = new DolGraph();
$file = $fdir ."ventes-".$year."-".$id.".png";
$title = "Ventes";
$graph->SetTitle($title);
$graph->BarLineOneYearArtichow($file, $ca, $num, $legends);
if ($verbose) $file = $fdir ."ventes-".$year."-".$id.".png";
print "$file\n"; $title = "Ventes";
}
$graph->SetTitle($title);
$graph->BarLineOneYearArtichow($file, $ca, $num, $legends);
if ($verbose)
print "$file\n";
}
} }
/* /*
* Ventes annuelles * Ventes annuelles
@ -163,49 +162,49 @@ foreach ( $products as $id => $fdir)
*/ */
foreach ( $products as $id => $fdir) foreach ( $products as $id => $fdir)
{ {
$num = array(); $num = array();
$ca = array(); $ca = array();
$legends = array(); $legends = array();
$sql = "SELECT date_format(f.datef,'%Y'), sum(fd.qty), sum(fd.total_ht)"; $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 .= " FROM ".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " WHERE f.rowid = fd.fk_facture"; $sql .= " WHERE f.rowid = fd.fk_facture";
$sql .= " AND fd.fk_product ='".$id."'"; $sql .= " AND fd.fk_product ='".$id."'";
$sql .= " GROUP BY date_format(f.datef,'%Y')"; $sql .= " GROUP BY date_format(f.datef,'%Y')";
$sql .= " ORDER BY date_format(f.datef,'%Y') ASC ;"; $sql .= " ORDER BY date_format(f.datef,'%Y') ASC ;";
$resql = $db->query($sql) ; $resql = $db->query($sql) ;
if ($resql) if ($resql)
{
$i = 0;
while ($row = $db->fetch_row($resql))
{ {
$i = 0;
while ($row = $db->fetch_row($resql))
{
$legends[$i] = $row[0]; $legends[$i] = $row[0];
$num[$i] = $row[1]; $num[$i] = $row[1];
$ca[$i] = $row[2]; $ca[$i] = $row[2];
$i++; $i++;
}
$db->free($resql);
}
else
{
print $sql;
} }
$db->free($resql);
}
else
{
print $sql;
}
if ($i > 0) if ($i > 0)
{ {
$graph = new DolGraph(); $graph = new DolGraph();
$file = $fdir ."ventes-".$id.".png"; $file = $fdir ."ventes-".$id.".png";
$title = "Ventes"; $title = "Ventes";
$graph->SetTitle($title); $graph->SetTitle($title);
$graph->BarLineAnnualArtichow($file, $ca, $num, $legends); $graph->BarLineAnnualArtichow($file, $ca, $num, $legends);
if ($verbose) if ($verbose)
print "$file\n"; print "$file\n";
} }
} }

View File

@ -39,10 +39,16 @@ $version='$Revision$';
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]); $path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php"); require_once($path."../../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
/*
* Main
*/
$error=0; $error=0;
$verbose = 0;
$verbose = 0;
for ($i = 1 ; $i < sizeof($argv) ; $i++) for ($i = 1 ; $i < sizeof($argv) ; $i++)
{ {
if ($argv[$i] == "-v") 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); $result=create_exdir($dir);
@ -83,9 +89,6 @@ else
dolibarr_print_error($db,$sql); dolibarr_print_error($db,$sql);
} }
/*
*
*/
$now = time(); $now = time();
$year = strftime('%Y',$now); $year = strftime('%Y',$now);
$day = strftime('%j', $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 = "SELECT date_format(date_calcul,'%j'), valo_pmp, fk_entrepot";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot_valorisation as e"; $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) foreach ($entrepots as $key => $ent)
{ {
$file = $dir ."/entrepot-".$key."-".$year.".png"; $file = $dir ."/entrepot-".$key."-".$year.".png";
@ -167,12 +172,12 @@ foreach ($entrepots as $key => $ent)
if ($verbose) if ($verbose)
print "$file\n"; print "$file\n";
} }
/* /*
* Graph cumulatif * For all warehouses
*
*/ */
$file = DOL_DATA_ROOT."/graph/entrepot/entrepot-".$year.".png"; $file = $dir."/entrepot-".$year.".png";
$title = "Valorisation PMP du stock global (euros HT) sur l'année ".$year; $title = "Valorisation PMP (Prix Moyen Pondéré) du stock global (euros HT) sur l'année ".$year;
if ($total[$key] > 0) if ($total[$key] > 0)
graph_datas($file, $title, $values[0], $legends); graph_datas($file, $title, $values[0], $legends);
@ -180,7 +185,8 @@ if ($total[$key] > 0)
if ($verbose) if ($verbose)
print "$file\n"; print "$file\n";
/** \brief Build graph /** \brief Build graph
* \param file File * \param file File
* \param title Title * \param title Title
@ -189,44 +195,28 @@ if ($verbose)
*/ */
function graph_datas($file, $title, $values, $legends) function graph_datas($file, $title, $values, $legends)
{ {
$width=800;
$graph = new Graph(800, 250); $height=230;
$graph->title->set($title);
$graph->title->setFont(new Tuffy(10)); $newvalues=array();
foreach ($values as $abs=>$ord)
$graph->border->hide(); {
$newvalues[]=array($legends[$abs],$ord);
$color = new Color(244,244,244); }
$graph->setAntiAliasing(TRUE); $px = new DolGraph();
$graph->setBackgroundColor( $color ); $px->SetData($newvalues);
//$px->SetLegend('');
//$plot->yAxis->title->set("euros"); $px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue());
$plot = new LinePlot($values); $px->SetTitle($title);
$plot->setSize(1, 0.96); $px->SetWidth($width);
$plot->setCenter(0.5, 0.52); $px->SetHeight($height);
$px->SetType('lines');
// Change line color $px->setBgColor('default');
$plot->setColor(new Color(0, 0, 150, 20)); $px->setBgColorGrid(array(255,255,255));
$px->SetHideXGrid(true);
// Set line background gradient $px->SetLabelInterval(31);
$plot->setFillGradient( $px->draw($file);
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);
} }
?> ?>