Qual: Simplification des classes de graph. Correction pb sur titre et utilisation max de la zone pour le graph.
This commit is contained in:
parent
7df8cea411
commit
b1c6a1eab8
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (c) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (c) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (c) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (c) 2004-2005 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
|
||||||
@ -32,95 +32,72 @@ include_once(DOL_DOCUMENT_ROOT."/graph.class.php");
|
|||||||
/**
|
/**
|
||||||
\class BarGraph
|
\class BarGraph
|
||||||
\brief Classe permettant la gestion des graphs phplot
|
\brief Classe permettant la gestion des graphs phplot
|
||||||
|
\remarks Utilisation:
|
||||||
|
$px = new BarGraph();
|
||||||
|
$graph_data = array("1"=>10,"2"=>20);
|
||||||
|
$px->SetData($graph_data);
|
||||||
|
$px->SetTitle("title");
|
||||||
|
$px->SetLegend(array("Val1","Val2"));
|
||||||
|
$px->width = 380;
|
||||||
|
$px->height = 200;
|
||||||
|
$px->draw("fichier.png");
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class BarGraph extends Graph
|
class BarGraph extends Graph
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $errorstr;
|
var $error;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialisation
|
* \brief Initialisation graphe
|
||||||
* \return int Retour: 0 si ko, 1 si ok
|
* \return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function BarGraph($data=array()) {
|
function BarGraph()
|
||||||
|
{
|
||||||
|
// Test si module GD présent
|
||||||
|
$modules_list = get_loaded_extensions();
|
||||||
|
$isgdinstalled=0;
|
||||||
|
foreach ($modules_list as $module)
|
||||||
|
{
|
||||||
|
if ($module == 'gd') { $isgdinstalled=1; }
|
||||||
|
}
|
||||||
|
if (! $isgdinstalled) {
|
||||||
|
$this->error="Erreur: Le module GD pour php ne semble pas disponible. Il est requis pour générer les graphiques.";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
$modules_list = get_loaded_extensions();
|
// Défini propriétés de l'objet graphe
|
||||||
$isgdinstalled=0;
|
$this->data = $data; // En general data non defini qd on crée objet
|
||||||
foreach ($modules_list as $module)
|
|
||||||
{
|
|
||||||
if ($module == 'gd') { $isgdinstalled=1; }
|
|
||||||
}
|
|
||||||
if (! $isgdinstalled) {
|
|
||||||
$this->errorstr="Erreur: Le module GD pour php ne semble pas disponible. Il est requis pour générer les graphiques.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data = $data;
|
$this->bordercolor = array(235,235,224);
|
||||||
|
$this->datacolor = array(array(204,204,179), array(187,187,136), array(235,235,224));
|
||||||
|
$this->bgcolor = array(235,235,224);
|
||||||
|
|
||||||
$this->bgcolor = array(235,235,224);
|
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php";
|
||||||
//$this->bgcolor = array(235,235,200);
|
if (is_readable($color_file))
|
||||||
$this->bordercolor = array(235,235,224);
|
{
|
||||||
$this->datacolor = array(array(204,204,179),
|
include($color_file);
|
||||||
array(187,187,136),
|
$this->bgcolor = $theme_bgcolor;
|
||||||
array(235,235,224));
|
}
|
||||||
|
|
||||||
|
$this->precision_y = 0;
|
||||||
|
|
||||||
|
$this->width = 400;
|
||||||
|
$this->height = 200;
|
||||||
|
|
||||||
|
$this->PlotType = 'bars';
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php";
|
function isGraphKo()
|
||||||
if (is_readable($color_file))
|
{
|
||||||
{
|
return $this->error;
|
||||||
include($color_file);
|
}
|
||||||
$this->bgcolor = $theme_bgcolor;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->precision_y = 0;
|
|
||||||
|
|
||||||
$this->width = 400;
|
|
||||||
$this->height = 200;
|
|
||||||
|
|
||||||
$this->PlotType = 'bars';
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isGraphKo() {
|
|
||||||
return $this->errorstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Génère le fichier graphique sur le disque
|
|
||||||
* \param file Nom du fichier image
|
|
||||||
* \param data Tableau des données
|
|
||||||
* \param title Titre de l'image
|
|
||||||
*/
|
|
||||||
function draw($file, $data, $title='') {
|
|
||||||
$this->prepare($file, $data, $title);
|
|
||||||
|
|
||||||
if (substr($this->MaxValue,0,1) == 1)
|
|
||||||
{
|
|
||||||
$this->graph->SetNumVertTicks(10);
|
|
||||||
}
|
|
||||||
elseif (substr($this->MaxValue,0,1) == 2)
|
|
||||||
{
|
|
||||||
$this->graph->SetNumVertTicks(4);
|
|
||||||
}
|
|
||||||
elseif (substr($this->MaxValue,0,1) == 3)
|
|
||||||
{
|
|
||||||
$this->graph->SetNumVertTicks(6);
|
|
||||||
}
|
|
||||||
elseif (substr($this->MaxValue,0,1) == 4)
|
|
||||||
{
|
|
||||||
$this->graph->SetNumVertTicks(8);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->graph->SetNumVertTicks(substr($this->MaxValue,0,1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Génère le fichier $file
|
|
||||||
$this->graph->DrawGraph();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -44,14 +44,15 @@ if (! is_dir($conf->propal->dir_images)) { mkdir($conf->propal->dir_images); }
|
|||||||
$filename = $conf->propal->dir_images."/nbpropale2year-$year.png";
|
$filename = $conf->propal->dir_images."/nbpropale2year-$year.png";
|
||||||
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=nbpropale2year-'.$year.'.png';
|
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=nbpropale2year-'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
$px->SetMaxValue($px->GetMaxValue());
|
$px->SetData($data);
|
||||||
$px->SetLegend(array($year - 1, $year));
|
$px->SetLegend(array($year - 1, $year));
|
||||||
|
$px->SetMaxValue($px->GetMaxValue());
|
||||||
$px->SetWidth(450);
|
$px->SetWidth(450);
|
||||||
$px->SetHeight(280);
|
$px->SetHeight(280);
|
||||||
$px->draw($filename, $data, $year);
|
$px->draw($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT count(*), date_format(datep,'%Y') as dm, sum(price) FROM ".MAIN_DB_PREFIX."propal WHERE fk_statut > 0 GROUP BY dm DESC ";
|
$sql = "SELECT count(*), date_format(datep,'%Y') as dm, sum(price) FROM ".MAIN_DB_PREFIX."propal WHERE fk_statut > 0 GROUP BY dm DESC ";
|
||||||
|
|||||||
@ -57,13 +57,14 @@ if (! is_dir($conf->propal->dir_images)) { mkdir($conf->propal->dir_images); }
|
|||||||
$filename = $conf->propal->dir_images."/propale".$year.".png";
|
$filename = $conf->propal->dir_images."/propale".$year.".png";
|
||||||
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=propale'.$year.'.png';
|
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=propale'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetMaxValue($px->GetMaxValue());
|
$px->SetMaxValue($px->GetMaxValue());
|
||||||
$px->SetWidth($WIDTH);
|
$px->SetWidth($WIDTH);
|
||||||
$px->SetHeight($HEIGHT);
|
$px->SetHeight($HEIGHT);
|
||||||
$px->draw($filename, $data, $year);
|
$px->draw($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $stats->getAmountByMonth($year);
|
$res = $stats->getAmountByMonth($year);
|
||||||
@ -78,9 +79,10 @@ for ($i = 1 ; $i < 13 ; $i++)
|
|||||||
$filename_amount = $conf->propal->dir_images."/propaleamount".$year.".png";
|
$filename_amount = $conf->propal->dir_images."/propaleamount".$year.".png";
|
||||||
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=propaleamount'.$year.'.png';
|
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=propaleamount'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetYLabel($langs->trans("AmountTotal"));
|
$px->SetYLabel($langs->trans("AmountTotal"));
|
||||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||||
$px->SetWidth($WIDTH);
|
$px->SetWidth($WIDTH);
|
||||||
@ -98,14 +100,15 @@ for ($i = 1 ; $i < 13 ; $i++)
|
|||||||
$filename_avg = $conf->propal->dir_images."/propaleaverage".$year.".png";
|
$filename_avg = $conf->propal->dir_images."/propaleaverage".$year.".png";
|
||||||
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=propaleaverage'.$year.'.png';
|
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=propaleaverage'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetYLabel($langs->trans("AmountAverage"));
|
$px->SetYLabel($langs->trans("AmountAverage"));
|
||||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||||
$px->SetWidth($WIDTH);
|
$px->SetWidth($WIDTH);
|
||||||
$px->SetHeight($HEIGHT);
|
$px->SetHeight($HEIGHT);
|
||||||
$px->draw($filename_avg, $data, $year);
|
$px->draw($filename_avg);
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|||||||
@ -63,14 +63,15 @@ if (! is_dir($conf->commande->dir_images))
|
|||||||
$filename = $conf->commande->dir_images."/nbcommande2year-".$year.".png";
|
$filename = $conf->commande->dir_images."/nbcommande2year-".$year.".png";
|
||||||
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=nbcommande2year-'.$year.'.png';
|
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=nbcommande2year-'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetMaxValue($px->GetMaxValue());
|
$px->SetMaxValue($px->GetMaxValue());
|
||||||
$px->SetWidth(450);
|
$px->SetWidth(450);
|
||||||
$px->SetHeight(280);
|
$px->SetHeight(280);
|
||||||
$px->SetYLabel("Nombre de commande");
|
$px->SetYLabel("Nombre de commande");
|
||||||
$px->draw($filename, $data, $year);
|
$px->draw($filename);
|
||||||
}
|
}
|
||||||
$rows = $stats->getNbByYear();
|
$rows = $stats->getNbByYear();
|
||||||
$num = sizeof($rows);
|
$num = sizeof($rows);
|
||||||
|
|||||||
@ -67,14 +67,15 @@ if (! is_dir($conf->commande->dir_images)) { mkdir($conf->commande->dir_images);
|
|||||||
$filename = $conf->commande->dir_images."/commande".$year.".png";
|
$filename = $conf->commande->dir_images."/commande".$year.".png";
|
||||||
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commande'.$year.'.png';
|
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commande'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetMaxValue($px->GetMaxValue());
|
$px->SetMaxValue($px->GetMaxValue());
|
||||||
$px->SetWidth($WIDTH);
|
$px->SetWidth($WIDTH);
|
||||||
$px->SetHeight($HEIGHT);
|
$px->SetHeight($HEIGHT);
|
||||||
$px->SetYLabel("Nombre de commande");
|
$px->SetYLabel("Nombre de commande");
|
||||||
$px->draw($filename, $data, $year);
|
$px->draw($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $stats->getCommandeAmountByMonth($year);
|
$res = $stats->getCommandeAmountByMonth($year);
|
||||||
@ -89,14 +90,15 @@ for ($i = 1 ; $i < 13 ; $i++)
|
|||||||
$filename_amount = $conf->commande->dir_images."/commandeamount".$year.".png";
|
$filename_amount = $conf->commande->dir_images."/commandeamount".$year.".png";
|
||||||
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeamount'.$year.'.png';
|
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeamount'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||||
$px->SetWidth($WIDTH);
|
$px->SetWidth($WIDTH);
|
||||||
$px->SetHeight($HEIGHT);
|
$px->SetHeight($HEIGHT);
|
||||||
$px->SetYLabel($langs->trans("AmountTotal"));
|
$px->SetYLabel($langs->trans("AmountTotal"));
|
||||||
$px->draw($filename_amount, $data, $year);
|
$px->draw($filename_amount);
|
||||||
}
|
}
|
||||||
$res = $stats->getCommandeAverageByMonth($year);
|
$res = $stats->getCommandeAverageByMonth($year);
|
||||||
|
|
||||||
@ -110,14 +112,15 @@ for ($i = 1 ; $i < 13 ; $i++)
|
|||||||
$filename_avg = $conf->commande->dir_images."/commandeaverage".$year.".png";
|
$filename_avg = $conf->commande->dir_images."/commandeaverage".$year.".png";
|
||||||
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeaverage'.$year.'.png';
|
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeaverage'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||||
$px->SetWidth($WIDTH);
|
$px->SetWidth($WIDTH);
|
||||||
$px->SetHeight($HEIGHT);
|
$px->SetHeight($HEIGHT);
|
||||||
$px->SetYLabel($langs->trans("AmountAverage"));
|
$px->SetYLabel($langs->trans("AmountAverage"));
|
||||||
$px->draw($filename_avg, $data, $year);
|
$px->draw($filename_avg);
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|||||||
@ -56,14 +56,15 @@ if (! is_dir($conf->facture->dir_images)) { mkdir($conf->facture->dir_images); }
|
|||||||
$filename = $conf->facture->dir_images."/nbfacture2year-".$year.".png";
|
$filename = $conf->facture->dir_images."/nbfacture2year-".$year.".png";
|
||||||
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=nbfacture2year-'.$year.'.png';
|
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=nbfacture2year-'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetMaxValue($px->GetMaxValue());
|
$px->SetMaxValue($px->GetMaxValue());
|
||||||
$px->SetLegend(array($year - 1, $year));
|
$px->SetLegend(array($year - 1, $year));
|
||||||
$px->SetWidth($WIDTH);
|
$px->SetWidth($WIDTH);
|
||||||
$px->SetHeight($HEIGHT);
|
$px->SetHeight($HEIGHT);
|
||||||
$px->draw($filename, $data, $year);
|
$px->draw($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT count(*), date_format(datef,'%Y') as dm, sum(total) FROM ".MAIN_DB_PREFIX."facture WHERE fk_statut > 0 ";
|
$sql = "SELECT count(*), date_format(datef,'%Y') as dm, sum(total) FROM ".MAIN_DB_PREFIX."facture WHERE fk_statut > 0 ";
|
||||||
|
|||||||
@ -60,13 +60,14 @@ if (! is_dir($conf->facture->dir_images)) { mkdir($conf->facture->dir_images); }
|
|||||||
$filename = $conf->facture->dir_images."/facture".$year.".png";
|
$filename = $conf->facture->dir_images."/facture".$year.".png";
|
||||||
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=facture'.$year.'.png';
|
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=facture'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetMaxValue($px->GetMaxValue());
|
$px->SetMaxValue($px->GetMaxValue());
|
||||||
$px->SetWidth($GRAPHWIDTH);
|
$px->SetWidth($GRAPHWIDTH);
|
||||||
$px->SetHeight($GRAPHHEIGHT);
|
$px->SetHeight($GRAPHHEIGHT);
|
||||||
$px->draw($filename, $data, $year);
|
$px->draw($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $stats->getAmountByMonth($year);
|
$res = $stats->getAmountByMonth($year);
|
||||||
@ -81,14 +82,15 @@ for ($i = 1 ; $i < 13 ; $i++)
|
|||||||
$filename_amount = $conf->facture->dir_images."/factureamount".$year.".png";
|
$filename_amount = $conf->facture->dir_images."/factureamount".$year.".png";
|
||||||
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=factureamount'.$year.'.png';
|
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=factureamount'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetYLabel($langs->trans("AmountTotal"));
|
$px->SetYLabel($langs->trans("AmountTotal"));
|
||||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||||
$px->SetWidth($GRAPHWIDTH);
|
$px->SetWidth($GRAPHWIDTH);
|
||||||
$px->SetHeight($GRAPHHEIGHT);
|
$px->SetHeight($GRAPHHEIGHT);
|
||||||
$px->draw($filename_amount, $data, $year);
|
$px->draw($filename_amount);
|
||||||
}
|
}
|
||||||
$res = $stats->getAverageByMonth($year);
|
$res = $stats->getAverageByMonth($year);
|
||||||
|
|
||||||
@ -102,14 +104,14 @@ for ($i = 1 ; $i < 13 ; $i++)
|
|||||||
$filename_avg = $conf->facture->dir_images."/factureaverage".$year.".png";
|
$filename_avg = $conf->facture->dir_images."/factureaverage".$year.".png";
|
||||||
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=factureaverage'.$year.'.png';
|
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=factureaverage'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg) {
|
if (! $mesg) {
|
||||||
$px->SetYLabel($langs->trans("AmountAverage"));
|
$px->SetYLabel($langs->trans("AmountAverage"));
|
||||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||||
$px->SetWidth($GRAPHWIDTH);
|
$px->SetWidth($GRAPHWIDTH);
|
||||||
$px->SetHeight($GRAPHHEIGHT);
|
$px->SetHeight($GRAPHHEIGHT);
|
||||||
$px->draw($filename_avg, $data, $year);
|
$px->draw($filename_avg);
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|||||||
@ -46,11 +46,12 @@ if (! is_dir($conf->expedition->dir_images)) { mkdir($conf->expedition->dir_imag
|
|||||||
$filename = $conf->expedition->dir_images."/expedition".$year.".png";
|
$filename = $conf->expedition->dir_images."/expedition".$year.".png";
|
||||||
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=expeditionstats&file=expedition'.$year.'.png';
|
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=expeditionstats&file=expedition'.$year.'.png';
|
||||||
|
|
||||||
$px = new BarGraph($data);
|
$px = new BarGraph();
|
||||||
|
$px->SetData($data);
|
||||||
$px->SetMaxValue($px->GetMaxValue());
|
$px->SetMaxValue($px->GetMaxValue());
|
||||||
$px->SetWidth(600);
|
$px->SetWidth(600);
|
||||||
$px->SetHeight(280);
|
$px->SetHeight(280);
|
||||||
$px->draw($filename, $data, $_GET["year"]);
|
$px->draw($filename);
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
print '<tr><td align="center">Nombre d\'expédition par mois</td>';
|
print '<tr><td align="center">Nombre d\'expédition par mois</td>';
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (c) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (c) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
* Copyright (c) 2004-2005 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
|
||||||
@ -35,101 +36,137 @@ include_once(DOL_DOCUMENT_ROOT."/includes/phplot/phplot.php");
|
|||||||
|
|
||||||
class Graph
|
class Graph
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $errorstr;
|
var $errorstr;
|
||||||
|
|
||||||
/**
|
var $graph; // Objet PHPlot
|
||||||
* \brief Prépare le graphique
|
|
||||||
* \param file Nom du fichier image
|
|
||||||
* \param data Tableau des données
|
|
||||||
* \param title Titre de l'image
|
|
||||||
*/
|
|
||||||
function prepare($file, $data, $title='')
|
|
||||||
{
|
|
||||||
//Define the object
|
|
||||||
$this->graph = new PHPlot($this->width, $this->height);
|
|
||||||
$this->graph->SetIsInline(1);
|
|
||||||
|
|
||||||
$this->graph->SetPlotType( $this->PlotType );
|
|
||||||
|
|
||||||
if (isset($this->MaxValue))
|
/**
|
||||||
{
|
* \brief Génère le fichier graphique sur le disque
|
||||||
$nts = array();
|
* \param file Nom du fichier image
|
||||||
$this->MaxValue = $this->MaxValue + 1;
|
* \param data Tableau des données
|
||||||
$max = $this->MaxValue;
|
* \param title Titre de l'image
|
||||||
if (($max % 2) <> 0)
|
*/
|
||||||
{
|
function draw($file)
|
||||||
$this->MaxValue = $this->MaxValue + 1;
|
{
|
||||||
$max++;
|
// Prepare parametres
|
||||||
}
|
$this->prepare($file);
|
||||||
|
|
||||||
$this->graph->SetPlotAreaWorld(0,0,12,$this->MaxValue);
|
// Génère le fichier $file
|
||||||
|
$this->graph->DrawGraph();
|
||||||
|
}
|
||||||
|
|
||||||
$j = 0;
|
/**
|
||||||
for ($i = 1 ; $i < 11 ; $i++)
|
* \brief Prépare l'objet PHPlot
|
||||||
{
|
* \param file Nom du fichier image à générer
|
||||||
$res = $max % $i;
|
* \param data Tableau des données
|
||||||
$cal = $max / $i;
|
* \param title Titre de l'image
|
||||||
|
*/
|
||||||
|
function prepare($file)
|
||||||
|
{
|
||||||
|
// Define the object
|
||||||
|
$this->graph = new PHPlot($this->width, $this->height);
|
||||||
|
$this->graph->SetIsInline(1);
|
||||||
|
|
||||||
if ($res == 0 && $cal <= 11)
|
$this->graph->SetPlotType( $this->PlotType );
|
||||||
{
|
|
||||||
$nts[$j] = $cal;
|
|
||||||
$j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
//Set some data
|
||||||
rsort($nts);
|
$this->graph->SetDataValues($this->data);
|
||||||
|
|
||||||
$this->graph->SetNumVertTicks($nts[0]);
|
if (isset($this->MaxValue))
|
||||||
}
|
{
|
||||||
else
|
$nts = array();
|
||||||
{
|
$this->MaxValue = $this->MaxValue + 1;
|
||||||
$this->graph->SetPlotAreaPixels(60, 10, $this->width-10, $this->height - 30) ;
|
$max = $this->MaxValue;
|
||||||
}
|
if (($max % 2) <> 0)
|
||||||
|
{
|
||||||
|
$this->MaxValue = $this->MaxValue + 1;
|
||||||
|
$max++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->graph->SetBackgroundColor($this->bgcolor);
|
$this->graph->SetPlotAreaWorld(0,0,12,$this->MaxValue);
|
||||||
|
|
||||||
// TODO
|
$j = 0;
|
||||||
//$this->graph->SetPrecisionY($this->precision_Y);
|
for ($i = 1 ; $i < 11 ; $i++)
|
||||||
|
{
|
||||||
|
$res = $max % $i;
|
||||||
|
$cal = $max / $i;
|
||||||
|
|
||||||
$this->graph->SetDataColors($this->datacolor, $this->bordercolor);
|
if ($res == 0 && $cal <= 11)
|
||||||
|
{
|
||||||
|
$nts[$j] = $cal;
|
||||||
|
$j++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->graph->SetYGridLabelType("data");
|
}
|
||||||
|
rsort($nts);
|
||||||
|
|
||||||
$this->graph->SetOutputFile($file);
|
$this->graph->SetNumVertTicks($nts[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->graph->SetPlotAreaPixels(60, 10, $this->width-10, $this->height - 30) ;
|
||||||
|
}
|
||||||
|
|
||||||
//Set some data
|
$this->graph->SetBackgroundColor($this->bgcolor);
|
||||||
$this->graph->SetDataValues($data);
|
$this->graph->SetDataColors($this->datacolor, $this->bordercolor);
|
||||||
|
|
||||||
// $this->graph->SetVertTickIncrement(0);
|
// Define title
|
||||||
|
if (strlen($this->title)) $this->graph->SetTitle($this->title);
|
||||||
|
|
||||||
$this->graph->SetDrawYGrid(1);
|
// TODO
|
||||||
|
//$this->graph->SetPrecisionY($this->precision_Y);
|
||||||
|
// $this->graph->SetVertTickIncrement(0);
|
||||||
|
// $this->graph->SetSkipBottomTick(1);
|
||||||
|
|
||||||
//
|
$this->graph->SetVertTickPosition('plotleft');
|
||||||
if (strlen($title))
|
|
||||||
{
|
|
||||||
$this->graph->SetTitle = $title;
|
|
||||||
}
|
|
||||||
|
|
||||||
// $this->graph->SetSkipBottomTick(1);
|
$this->graph->SetYGridLabelType("data");
|
||||||
|
|
||||||
// Affiche les valeurs
|
$this->graph->SetDrawYGrid(1);
|
||||||
//$this->graph->SetDrawDataLabels('1');
|
|
||||||
//$this->graph->SetLabelScalePosition('1');
|
|
||||||
|
|
||||||
$this->graph->SetVertTickPosition('plotleft');
|
// Affiche les valeurs
|
||||||
|
//$this->graph->SetDrawDataLabels('1');
|
||||||
|
//$this->graph->SetLabelScalePosition('1');
|
||||||
|
|
||||||
$this->graph->SetMarginsPixels(100,50,10,30);
|
$this->graph->SetOutputFile($file);
|
||||||
|
|
||||||
if (isset($this->Legend))
|
// Défini position du graphe (et legende) au sein de l'image
|
||||||
{
|
if (isset($this->Legend))
|
||||||
$this->graph->SetLegend($this->Legend);
|
{
|
||||||
$this->graph->SetLegendWorld(12,$this->MaxValue);
|
$this->graph->SetMarginsPixels(60,100,10,30);
|
||||||
}
|
|
||||||
|
|
||||||
//Draw it
|
$this->graph->SetLegend($this->Legend);
|
||||||
// $this->graph->DrawGraph();
|
$this->graph->SetLegendWorld(13,$this->MaxValue);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->graph->SetMarginsPixels(60,10,10,30);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr($this->MaxValue,0,1) == 1)
|
||||||
|
{
|
||||||
|
$this->graph->SetNumVertTicks(10);
|
||||||
|
}
|
||||||
|
elseif (substr($this->MaxValue,0,1) == 2)
|
||||||
|
{
|
||||||
|
$this->graph->SetNumVertTicks(4);
|
||||||
|
}
|
||||||
|
elseif (substr($this->MaxValue,0,1) == 3)
|
||||||
|
{
|
||||||
|
$this->graph->SetNumVertTicks(6);
|
||||||
|
}
|
||||||
|
elseif (substr($this->MaxValue,0,1) == 4)
|
||||||
|
{
|
||||||
|
$this->graph->SetNumVertTicks(8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->graph->SetNumVertTicks(substr($this->MaxValue,0,1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function SetPrecisionY($which_prec)
|
function SetPrecisionY($which_prec)
|
||||||
{
|
{
|
||||||
@ -147,6 +184,16 @@ class Graph
|
|||||||
$this->width = $w;
|
$this->width = $w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SetTitle($title)
|
||||||
|
{
|
||||||
|
$this->title = $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetData($data)
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
function SetLegend($legend)
|
function SetLegend($legend)
|
||||||
{
|
{
|
||||||
$this->Legend = $legend;
|
$this->Legend = $legend;
|
||||||
|
|||||||
@ -88,20 +88,35 @@ if ($_GET["id"])
|
|||||||
$filenbvente = $dir . "/vente12mois.png";
|
$filenbvente = $dir . "/vente12mois.png";
|
||||||
$filenbpiece = $dir . "/vendu12mois.png";
|
$filenbpiece = $dir . "/vendu12mois.png";
|
||||||
|
|
||||||
|
$WIDTH=380;
|
||||||
|
$HEIGHT=200;
|
||||||
|
|
||||||
$px = new BarGraph();
|
$px = new BarGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg)
|
if (! $mesg)
|
||||||
{
|
{
|
||||||
$graph_data = $product->get_num_vente($socid);
|
$graph_data = $product->get_num_vente($socid);
|
||||||
$px->draw($filenbvente, $graph_data);
|
$px->SetData($graph_data);
|
||||||
|
$px->SetMaxValue($px->GetMaxValue());
|
||||||
|
$px->SetWidth($WIDTH);
|
||||||
|
$px->SetHeight($HEIGHT);
|
||||||
|
$px->draw($filenbvente);
|
||||||
|
|
||||||
$px = new BarGraph();
|
$px = new BarGraph();
|
||||||
$graph_data = $product->get_nb_vente($socid);
|
$graph_data = $product->get_nb_vente($socid);
|
||||||
$px->draw($filenbpiece, $graph_data);
|
$px->SetData($graph_data);
|
||||||
|
$px->SetMaxValue($px->GetMaxValue());
|
||||||
|
$px->SetWidth($WIDTH);
|
||||||
|
$px->SetHeight($HEIGHT);
|
||||||
|
$px->draw($filenbpiece);
|
||||||
|
|
||||||
$px = new BarGraph();
|
$px = new BarGraph();
|
||||||
$graph_data = $product->get_num_propal($socid);
|
$graph_data = $product->get_num_propal($socid);
|
||||||
$px->draw($filenbpropal, $graph_data);
|
$px->SetData($graph_data);
|
||||||
|
$px->SetMaxValue($px->GetMaxValue());
|
||||||
|
$px->SetWidth($WIDTH);
|
||||||
|
$px->SetHeight($HEIGHT);
|
||||||
|
$px->draw($filenbpropal);
|
||||||
|
|
||||||
$mesg = $langs->trans("ChartGenerated");
|
$mesg = $langs->trans("ChartGenerated");
|
||||||
}
|
}
|
||||||
@ -246,7 +261,9 @@ if ($_GET["id"])
|
|||||||
$file=$product->id.'/'.$img_propal_name;
|
$file=$product->id.'/'.$img_propal_name;
|
||||||
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Nombre de propales sur les 12 derniers mois">';
|
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Nombre de propales sur les 12 derniers mois">';
|
||||||
|
|
||||||
print '</td><td align="center" colspan="2">TODO AUTRE GRAPHIQUE';
|
print '</td><td align="center" colspan="2"> ';
|
||||||
|
|
||||||
|
// Place pour autre graphique
|
||||||
|
|
||||||
print '</td></tr><tr>';
|
print '</td></tr><tr>';
|
||||||
if (file_exists($filenbpropal) && filemtime($filenbpropal))
|
if (file_exists($filenbpropal) && filemtime($filenbpropal))
|
||||||
|
|||||||
@ -100,10 +100,11 @@ class Atome
|
|||||||
|
|
||||||
|
|
||||||
$bgraph = new BarGraph();
|
$bgraph = new BarGraph();
|
||||||
|
$bgraph->SetData($this->graph_values);
|
||||||
$bgraph->bgcolor = array(255,255,255);
|
$bgraph->bgcolor = array(255,255,255);
|
||||||
$bgraph->width = 600;
|
$bgraph->SetWidth(600);
|
||||||
$bgraph->height = 400;
|
$bgraph->SetHeight(400);
|
||||||
$bgraph->draw($filename, $this->graph_values);
|
$bgraph->draw($filename);
|
||||||
|
|
||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user