';
}
if ($shownb) $stringtoshow.=$px1->show();
diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php
index 182639da994..d27d4385d8f 100644
--- a/htdocs/core/boxes/box_graph_propales_permonth.php
+++ b/htdocs/core/boxes/box_graph_propales_permonth.php
@@ -74,10 +74,10 @@ class box_graph_propales_permonth extends ModeleBoxes
'text' => $text,
'limit'=> dol_strlen($text),
'graph'=> 1,
- 'sublink'=>$_SERVER["PHP_SELF"].'?action='.$refreshaction,
- 'subtext'=>$langs->trans("Refresh"),
- 'subpicto'=>'refresh.png',
- 'target'=>'none'
+ 'sublink'=>'',
+ 'subtext'=>$langs->trans("Filter"),
+ 'subpicto'=>'filter.png',
+ 'target'=>'none' // Set '' to get target="_blank"
);
if ($user->rights->commande->lire)
@@ -88,11 +88,11 @@ class box_graph_propales_permonth extends ModeleBoxes
$shownb=(! empty($conf->global->PROPAL_BOX_GRAPH_SHOW_NB));
$showtot=(! isset($conf->global->PROPAL_BOX_GRAPH_SHOW_TOT) || ! empty($conf->global->PROPAL_BOX_GRAPH_SHOW_TOT));
$nowarray=dol_getdate(dol_now(),true);
- $endyear=$nowarray['year'];
+ $endyear=(GETPOST('param'.$this->boxcode.'year')?GETPOST('param'.$this->boxcode.'year','int'):$nowarray['year']);
$startyear=$endyear-1;
$mode='customer';
$userid=0;
- $WIDTH='256';
+ $WIDTH=($shownb && $showtot)?'256':'320';
$HEIGHT='192';
$stats = new PropaleStats($this->db, 0, $mode, ($userid>0?$userid:0));
@@ -101,7 +101,8 @@ class box_graph_propales_permonth extends ModeleBoxes
if ($shownb)
{
$data1 = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action')==$refreshaction?-1:(3600*24)));
-
+ $datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars');
+
$filenamenb = $dir."/propalsnbinyear-".$year.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=propalsnbinyear-'.$year.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstatssupplier&file=propalsnbinyear-'.$year.'.png';
@@ -110,6 +111,7 @@ class box_graph_propales_permonth extends ModeleBoxes
$mesg = $px1->isGraphKo();
if (! $mesg)
{
+ $px1->SetType($datatype1);
$px1->SetData($data1);
unset($data1);
$px1->SetPrecisionY(0);
@@ -139,7 +141,9 @@ class box_graph_propales_permonth extends ModeleBoxes
if ($showtot)
{
$data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(GETPOST('action')==$refreshaction?-1:(3600*24)));
-
+ $datatype2 = array_pad(array(), ($endyear-$startyear+1), 'bars');
+ //$datatype2 = array('lines','bars');
+
$filenamenb = $dir."/propalsamountinyear-".$year.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=propalsamountinyear-'.$year.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstatssupplier&file=propalsamountinyear-'.$year.'.png';
@@ -148,6 +152,7 @@ class box_graph_propales_permonth extends ModeleBoxes
$mesg = $px2->isGraphKo();
if (! $mesg)
{
+ $px2->SetType($datatype2);
$px2->SetData($data2);
unset($data2);
$px2->SetPrecisionY(0);
@@ -175,9 +180,23 @@ class box_graph_propales_permonth extends ModeleBoxes
if (! $mesg)
{
+ $stringtoshow='';
+ $stringtoshow.='';
+ $stringtoshow.='
';
if ($shownb && $showtot)
{
- $stringtoshow ='
';
+ $stringtoshow.='
';
$stringtoshow.='
';
}
if ($shownb) $stringtoshow.=$px1->show();
diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php
index 10ea413740a..2d83e26a870 100644
--- a/htdocs/core/boxes/modules_boxes.php
+++ b/htdocs/core/boxes/modules_boxes.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2005-2012 Regis Houssin
+/* Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
*
* 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
@@ -135,13 +135,13 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty"
print "\n\n\n";
print ''."\n";
- if (! empty($head['text']) || ! empty($head['sublink']) || $nblines)
+ if (! empty($head['text']) || ! empty($head['sublink']) || ! empty($head['subpicto']) || $nblines)
{
print '
'."\n";
}
// Show box title
- if (! empty($head['text']) || ! empty($head['sublink']))
+ if (! empty($head['text']) || ! empty($head['sublink']) || ! empty($head['subpicto']))
{
//print ''."\n";
//print '
\n";
-// print "
\n";
+ //print "
\n";
+ //print "
\n";
}
// Show box lines
@@ -251,13 +251,13 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty"
}
}
- if (! empty($head['text']) || ! empty($head['sublink']) || $nblines)
+ if (! empty($head['text']) || ! empty($head['sublink']) || ! empty($head['subpicto']) || $nblines)
{
print "\n";
}
// If invisible box with no contents
- if (empty($head['text']) && empty($head['sublink']) && ! $nblines) print "
\n";
+ if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && ! $nblines) print "
\n";
print "\n";
print "\n\n";
diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php
index 5dd7fb735e9..b604ae4f8f0 100644
--- a/htdocs/core/class/dolgraph.class.php
+++ b/htdocs/core/class/dolgraph.class.php
@@ -43,7 +43,7 @@
class DolGraph
{
//! Type of graph
- var $type=array('bars'); // bars, lines, ...
+ var $type=array(); // Array with type of each series. Example: array('bars', 'lines', ...)
var $mode='side'; // Mode bars graph: side, depth
private $_library='jflot'; // Graphic library to use (jflot, artichow)
@@ -578,8 +578,9 @@ class DolGraph
// Create graph
$classname='';
- if ($this->type[0] == 'bars') $classname='BarPlot'; // Only first type of type is supported by artichow
- if ($this->type[0] == 'lines') $classname='LinePlot';
+ if (! isset($this->type[0]) || $this->type[0] == 'bars') $classname='BarPlot'; // Only one type (first one) is supported by artichow
+ else if ($this->type[0] == 'lines') $classname='LinePlot';
+ else $classname='TypeUnknown';
include_once ARTICHOW_PATH.$classname.'.class.php';
// Definition de couleurs
diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php
index 819ca4c5350..24e4ffa8980 100644
--- a/htdocs/core/class/stats.class.php
+++ b/htdocs/core/class/stats.class.php
@@ -76,7 +76,7 @@ abstract class Stats
dol_syslog(get_class($this).'_'.__FUNCTION__." cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
}
}
-
+
// Load file into $data
if ($foundintocache) // Cache file found and is not too old
{
@@ -184,14 +184,14 @@ abstract class Stats
}
$data = array();
-
+ // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
for ($i = 0 ; $i < 12 ; $i++)
{
- $data[$i][]=$datay[$endyear][$i][0];
+ $data[$i][]=$datay[$endyear][$i][0]; // set label
$year=$startyear;
while($year <= $endyear)
{
- $data[$i][]=$datay[$year][$i][1];
+ $data[$i][]=$datay[$year][$i][1]; // set yval for x=i
$year++;
}
}