Make message more clear
This commit is contained in:
parent
0e1fc52054
commit
4b8786fda6
@ -18,22 +18,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file scripts/cron/stock-graph.php
|
\file scripts/cron/stock-graph.php
|
||||||
\ingroup stock
|
\ingroup stock
|
||||||
\brief Créé le graph de valorisation du stock
|
\brief Créé le graph de valorisation du stock
|
||||||
\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"]);
|
||||||
@ -51,18 +51,18 @@ $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")
|
||||||
{
|
{
|
||||||
$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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,16 +77,16 @@ $resql = $db->query($sql) ;
|
|||||||
$entrepots = array();
|
$entrepots = array();
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($row = $db->fetch_row($resql))
|
while ($row = $db->fetch_row($resql))
|
||||||
{
|
{
|
||||||
$entrepots[$row[0]] = $row[0];
|
$entrepots[$row[0]] = $row[0];
|
||||||
}
|
}
|
||||||
$db->free($resql);
|
$db->free($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($db,$sql);
|
dolibarr_print_error($db,$sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$now = time();
|
$now = time();
|
||||||
@ -94,12 +94,13 @@ $year = strftime('%Y',$now);
|
|||||||
$day = strftime('%j', $now);
|
$day = strftime('%j', $now);
|
||||||
for ($i = 0 ; $i < strftime('%j',$now) ; $i++)
|
for ($i = 0 ; $i < strftime('%j',$now) ; $i++)
|
||||||
{
|
{
|
||||||
foreach ($entrepots as $key => $ent)
|
foreach ($entrepots as $key => $ent)
|
||||||
{
|
{
|
||||||
$values[$key][$i] = 0;
|
$values[$key][$i] = 0;
|
||||||
}
|
}
|
||||||
$values[0][$i] = 0;
|
$values[0][$i] = 0;
|
||||||
$legends[$i] = strftime('%b',dolibarr_mktime(12,0,0,1,1,2006) + ($i * 3600 * 24));
|
$legends[$i] = strftime('%b',dolibarr_mktime(12,0,0,1,1,2006) + ($i * 3600 * 24));
|
||||||
|
//print $legends[$i].strftime('%j',$now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -114,45 +115,45 @@ $resql = $db->query($sql) ;
|
|||||||
|
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$last_day = 0;
|
$last_day = 0;
|
||||||
while ($row = $db->fetch_row($resql))
|
while ($row = $db->fetch_row($resql))
|
||||||
{
|
|
||||||
if ($last_day > 0)
|
|
||||||
{
|
{
|
||||||
for ($j = $last_day + 1 ; $j < $row[0] ; $j++)
|
if ($last_day > 0)
|
||||||
{
|
|
||||||
foreach ($entrepots as $key => $ent)
|
|
||||||
{
|
{
|
||||||
$values[$key][$j] = $values[$key][$last_day];
|
for ($j = $last_day + 1 ; $j < $row[0] ; $j++)
|
||||||
|
{
|
||||||
|
foreach ($entrepots as $key => $ent)
|
||||||
|
{
|
||||||
|
$values[$key][$j] = $values[$key][$last_day];
|
||||||
|
}
|
||||||
|
$values[0][$j] = $values[0][$last_day];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$values[0][$j] = $values[0][$last_day];
|
$last_day = $row[0];
|
||||||
}
|
|
||||||
|
$max_day = $row[0];
|
||||||
|
$values[$row[2]][$row[0]] = $row[1];
|
||||||
|
$values[0][$row[0]] += $row[1];
|
||||||
|
|
||||||
|
$total[$row[2]] += abs($row[1]);
|
||||||
|
$total[0] += abs($row[1]);
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
$last_day = $row[0];
|
$db->free($resql);
|
||||||
|
|
||||||
$max_day = $row[0];
|
|
||||||
$values[$row[2]][$row[0]] = $row[1];
|
|
||||||
$values[0][$row[0]] += $row[1];
|
|
||||||
|
|
||||||
$total[$row[2]] += abs($row[1]);
|
|
||||||
$total[0] += abs($row[1]);
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$db->free($resql);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($db,$sql);
|
dolibarr_print_error($db,$sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = $max_day + 1 ; $i < ($day + 1) ; $i++)
|
for ($i = $max_day + 1 ; $i < ($day + 1) ; $i++)
|
||||||
{
|
{
|
||||||
foreach ($entrepots as $key => $ent)
|
foreach ($entrepots as $key => $ent)
|
||||||
{
|
{
|
||||||
$values[$key][$i] = $values[$key][$max_day];
|
$values[$key][$i] = $values[$key][$max_day];
|
||||||
}
|
}
|
||||||
$values[0][$i] = $values[0][$max_day];
|
$values[0][$i] = $values[0][$max_day];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,14 +164,14 @@ for ($i = $max_day + 1 ; $i < ($day + 1) ; $i++)
|
|||||||
*/
|
*/
|
||||||
foreach ($entrepots as $key => $ent)
|
foreach ($entrepots as $key => $ent)
|
||||||
{
|
{
|
||||||
$file = $dir ."/entrepot-".$key."-".$year.".png";
|
$file = $dir ."/entrepot-".$key."-".$year.".png";
|
||||||
$title = "Valorisation PMP du stock de l'entrepôt (euros HT) sur l'année ".$year;
|
$title = "Valorisation PMP du stock de l'entrepôt (euros HT) sur l'année ".$year;
|
||||||
|
|
||||||
if ($total[$key] > 0)
|
if ($total[$key] > 0)
|
||||||
graph_datas($file, $title, $values[$key], $legends);
|
graph_datas($file, $title, $values[$key], $legends);
|
||||||
|
|
||||||
if ($verbose)
|
if ($verbose)
|
||||||
print "$file\n";
|
print "$file\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -180,41 +181,43 @@ $file = $dir."/entrepot-".$year.".png";
|
|||||||
$title = "Valorisation PMP (Prix Moyen Pondéré) 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);
|
||||||
|
|
||||||
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
|
||||||
* \param values Value
|
* \param values Value
|
||||||
* \param legends Legend
|
* \param legends Legend
|
||||||
*/
|
*/
|
||||||
function graph_datas($file, $title, $values, $legends)
|
function graph_datas($file, $title, $values, $legends)
|
||||||
{
|
{
|
||||||
$width=800;
|
$width=800;
|
||||||
$height=230;
|
$height=230;
|
||||||
|
|
||||||
|
print "Build graph ".$file."\n";
|
||||||
|
|
||||||
$newvalues=array();
|
$newvalues=array();
|
||||||
foreach ($values as $abs=>$ord)
|
foreach ($values as $abs=>$ord)
|
||||||
{
|
{
|
||||||
$newvalues[]=array($legends[$abs],$ord);
|
$newvalues[]=array($legends[$abs],$ord);
|
||||||
}
|
}
|
||||||
|
|
||||||
$px = new DolGraph();
|
$px = new DolGraph();
|
||||||
$px->SetData($newvalues);
|
$px->SetData($newvalues);
|
||||||
//$px->SetLegend('');
|
//$px->SetLegend('');
|
||||||
$px->SetMaxValue($px->GetCeilMaxValue());
|
$px->SetMaxValue($px->GetCeilMaxValue());
|
||||||
$px->SetMinValue($px->GetFloorMinValue());
|
$px->SetMinValue($px->GetFloorMinValue());
|
||||||
$px->SetTitle($title);
|
$px->SetTitle($title);
|
||||||
$px->SetWidth($width);
|
$px->SetWidth($width);
|
||||||
$px->SetHeight($height);
|
$px->SetHeight($height);
|
||||||
$px->SetType('lines');
|
$px->SetType('lines');
|
||||||
$px->setBgColor('default');
|
$px->setBgColor('default');
|
||||||
$px->setBgColorGrid(array(255,255,255));
|
$px->setBgColorGrid(array(255,255,255));
|
||||||
$px->SetHideXGrid(true);
|
$px->SetHideXGrid(true);
|
||||||
$px->SetLabelInterval(31);
|
$px->SetLabelInterval(31);
|
||||||
$px->draw($file);
|
$px->draw($file);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user