2
0
forked from Wavyzz/dolibarr

Qual: uniformize code to use function de set with and height for graphs

This commit is contained in:
Laurent Destailleur
2013-04-12 17:08:54 +02:00
parent 26653a42e4
commit 62893c2ae4
2 changed files with 18 additions and 18 deletions

View File

@@ -30,6 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$langs->load("banks");
$WIDTH=DolGraph::getDefaultGraphSizeForStats('width',768);
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height',200);
// Security check
if (isset($_GET["account"]) || isset($_GET["ref"]))
{
@@ -82,11 +85,7 @@ if ($result < 0)
}
else
{
// Definition de $width et $height
$width = 768;
$height = 200;
// Calcul de $min et $max
// Calcul $min and $max
$sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
@@ -239,8 +238,8 @@ else
$px1->SetMaxValue($px1->GetCeilMaxValue()<0?0:$px1->GetCeilMaxValue());
$px1->SetMinValue($px1->GetFloorMinValue()>0?0:$px1->GetFloorMinValue());
$px1->SetTitle($title);
$px1->SetWidth($width);
$px1->SetHeight($height);
$px1->SetWidth($WIDTH);
$px1->SetHeight($HEIGHT);
$px1->SetType(array('lines','lines'));
$px1->setBgColor('onglet');
$px1->setBgColorGrid(array(255,255,255));
@@ -369,8 +368,8 @@ else
$px2->SetMaxValue($px2->GetCeilMaxValue()<0?0:$px2->GetCeilMaxValue());
$px2->SetMinValue($px2->GetFloorMinValue()>0?0:$px2->GetFloorMinValue());
$px2->SetTitle($title);
$px2->SetWidth($width);
$px2->SetHeight($height);
$px2->SetWidth($WIDTH);
$px2->SetHeight($HEIGHT);
$px2->SetType(array('lines','lines'));
$px2->setBgColor('onglet');
$px2->setBgColorGrid(array(255,255,255));
@@ -478,8 +477,8 @@ else
$px3->SetMaxValue($px3->GetCeilMaxValue()<0?0:$px3->GetCeilMaxValue());
$px3->SetMinValue($px3->GetFloorMinValue()>0?0:$px3->GetFloorMinValue());
$px3->SetTitle($title);
$px3->SetWidth($width);
$px3->SetHeight($height);
$px3->SetWidth($WIDTH);
$px3->SetHeight($HEIGHT);
$px3->SetType(array('lines','lines'));
$px3->setBgColor('onglet');
$px3->setBgColorGrid(array(255,255,255));
@@ -605,8 +604,8 @@ else
$px4->SetMaxValue($px4->GetCeilMaxValue()<0?0:$px4->GetCeilMaxValue());
$px4->SetMinValue($px4->GetFloorMinValue()>0?0:$px4->GetFloorMinValue());
$px4->SetTitle($title);
$px4->SetWidth($width);
$px4->SetHeight($height);
$px4->SetWidth($WIDTH);
$px4->SetHeight($HEIGHT);
$px4->SetType(array('bars','bars'));
$px4->SetShading(3);
$px4->setBgColor('onglet');
@@ -714,8 +713,8 @@ else
$px5->SetMaxValue($px5->GetCeilMaxValue()<0?0:$px5->GetCeilMaxValue());
$px5->SetMinValue($px5->GetFloorMinValue()>0?0:$px5->GetFloorMinValue());
$px5->SetTitle($title);
$px5->SetWidth($width);
$px5->SetHeight($height);
$px5->SetWidth($WIDTH);
$px5->SetHeight($HEIGHT);
$px5->SetType(array('bars','bars'));
$px5->SetShading(3);
$px5->setBgColor('onglet');

View File

@@ -898,14 +898,15 @@ class DolGraph
* getDefaultGraphSizeForStats
*
* @param string $direction 'width' or 'height'
* @param string $defaultsize Value we want as default size
* @return int Value of width or height to use by default
*/
static function getDefaultGraphSizeForStats($direction)
static function getDefaultGraphSizeForStats($direction,$defaultsize='')
{
global $conf;
if ($direction == 'width') return ($conf->dol_optimize_smallscreen?'400':'500');
if ($direction == 'height') return ($conf->dol_optimize_smallscreen?'160':'200');
if ($direction == 'width') return ($conf->dol_optimize_smallscreen?'400':($defaultsize?$defaultsize:'500'));
if ($direction == 'height') return ($conf->dol_optimize_smallscreen?'160':($defaultsize?$defaultsize:'200'));
return 0;
}
}