Fix: Detection si GD est installe et gestion erreur correct pour les PHP sans GD. Ajout des barres anne suivante-prcdente sur toutes les pages de stats
This commit is contained in:
parent
fee960d8ad
commit
c8d455fd4a
@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (c) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (c) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -25,14 +26,25 @@ class BarGraph extends Graph
|
||||
{
|
||||
var $db;
|
||||
var $errorstr;
|
||||
|
||||
|
||||
/**
|
||||
* Initialisation
|
||||
*
|
||||
* Retour: 0 si ko, 1 si ok
|
||||
*/
|
||||
|
||||
Function BarGraph($data=array())
|
||||
{
|
||||
Function BarGraph($data=array()) {
|
||||
|
||||
$modules_list = get_loaded_extensions();
|
||||
$isgdinstalled=0;
|
||||
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;
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT."/includes/phplot/phplot.php");
|
||||
@ -51,15 +63,18 @@ class BarGraph extends Graph
|
||||
|
||||
$this->PlotType = 'bars';
|
||||
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
|
||||
Function isGraphKo() {
|
||||
return $this->errorstr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dessine le graphique
|
||||
*
|
||||
*/
|
||||
Function draw($file, $data, $title='')
|
||||
{
|
||||
Function draw($file, $data, $title='') {
|
||||
$this->prepare($file, $data, $title);
|
||||
|
||||
if (substr($this->MaxValue,0,1) == 1)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -36,13 +37,16 @@ $data = $stats->getNbByMonthWithPrevYear($year);
|
||||
$filev = "/document/images/nbpropale2year-$year.png";
|
||||
|
||||
$px = new BarGraph($data);
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetLegend(array($year - 1, $year));
|
||||
$px->SetWidth(450);
|
||||
$px->SetHeight(280);
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetLegend(array($year - 1, $year));
|
||||
$px->SetWidth(450);
|
||||
$px->SetHeight(280);
|
||||
|
||||
$px->draw(DOL_DOCUMENT_ROOT.$filev, $data, $year);
|
||||
}
|
||||
|
||||
$px->draw(DOL_DOCUMENT_ROOT.$filev, $data, $year);
|
||||
|
||||
$sql = "SELECT count(*), date_format(datep,'%Y') as dm, sum(price) FROM ".MAIN_DB_PREFIX."propal WHERE fk_statut > 0 GROUP BY dm DESC ";
|
||||
if ($db->query($sql))
|
||||
{
|
||||
@ -51,7 +55,9 @@ if ($db->query($sql))
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr><td align="center">Année</td><td width="10%">Nb de proposition</td><td align="center">Somme des propositions</td>';
|
||||
print '<td align="center" valign="top" rowspan="'.($num + 1).'">';
|
||||
print 'Nombre de proposition par mois<br><img src="'.DOL_URL_ROOT.$filev.'" alt="Graphique nombre de commande">';
|
||||
print 'Nombre de proposition par mois<br>';
|
||||
if ($mesg) { print "$mesg"; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$filev.'" alt="Graphique nombre de commande">'; }
|
||||
print '</td></tr>';
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -24,36 +25,36 @@ require("./pre.inc.php");
|
||||
require("./propalestats.class.php");
|
||||
|
||||
llxHeader();
|
||||
$year = $_GET["year"];
|
||||
$mesg = '';
|
||||
|
||||
print_fiche_titre('Statistiques des propositions commerciales '.$year, $mesg);
|
||||
$year = isset($_GET["year"])?$_GET["year"]:date("Y",time());
|
||||
|
||||
print '<a href="month.php?year='.($year - 1).'">'.($year - 1).'</a> - ';
|
||||
print '<a href="month.php?year='.($year + 1).'">'.($year + 1).'</a>';
|
||||
$mesg = '<a href="month.php?year='.($year - 1).'">'.img_previous().'</a> ';
|
||||
$mesg.= "Année $year";
|
||||
$mesg.= ' <a href="month.php?year='.($year + 1).'">'.img_next().'</a>';
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
$stats = new PropaleStats($db);
|
||||
|
||||
print_fiche_titre('Statistiques des propositions commerciales', $mesg);
|
||||
|
||||
$dir = DOL_DOCUMENT_ROOT;
|
||||
|
||||
////////////////////////
|
||||
|
||||
$stats = new PropaleStats($db);
|
||||
$data = $stats->getNbByMonth($year);
|
||||
|
||||
$filev = "/document/images/propale$year.png";
|
||||
|
||||
$px = new BarGraph($data);
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(280);
|
||||
|
||||
$px->draw($dir.$filev, $data, $year);
|
||||
|
||||
/////
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(280);
|
||||
|
||||
$px->draw($dir.$filev, $data, $year);
|
||||
}
|
||||
|
||||
$res = $stats->getAmountByMonth($year);
|
||||
|
||||
@ -67,13 +68,15 @@ for ($i = 1 ; $i < 13 ; $i++)
|
||||
$file_amount = "/document/images/propalamount$year.png";
|
||||
|
||||
$px = new BarGraph($data);
|
||||
$px->SetYLabel("Montant");
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
|
||||
$px->draw($dir.$file_amount, $data, $year);
|
||||
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetYLabel("Montant");
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
|
||||
$px->draw($dir.$file_amount, $data, $year);
|
||||
}
|
||||
$res = $stats->getAverageByMonth($year);
|
||||
|
||||
$data = array();
|
||||
@ -83,26 +86,32 @@ for ($i = 1 ; $i < 13 ; $i++)
|
||||
$data[$i-1] = array(strftime("%b",mktime(12,12,12,$i,1,$year)), $res[$i]);
|
||||
}
|
||||
$file_avg = "/document/images/propalaverage$year.png";
|
||||
$px = new BarGraph($data);
|
||||
$px->SetYLabel("Montant moyen");
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
$px->draw($dir.$file_avg, $data, $year);
|
||||
|
||||
$px = new BarGraph($data);
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetYLabel("Montant moyen");
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
$px->draw($dir.$file_avg, $data, $year);
|
||||
}
|
||||
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr><td align="center">Nombre par mois</td>';
|
||||
print '<td align="center">';
|
||||
print '<img src="'.DOL_URL_ROOT.$filev.'">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$filev.'">'; }
|
||||
print '</td></tr>';
|
||||
print '<tr><td align="center">Sommes</td>';
|
||||
print '<td align="center">';
|
||||
print '<img src="'.DOL_URL_ROOT.$file_amount.'">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$file_amount.'">'; }
|
||||
print '</td></tr>';
|
||||
print '<tr><td align="center">Montant moyen</td>';
|
||||
print '<td align="center">';
|
||||
print '<img src="'.DOL_URL_ROOT.$file_avg.'">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$file_avg.'">'; }
|
||||
print '</td></tr></table>';
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (c) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -46,19 +47,23 @@ $data = $stats->getNbCommandeByMonthWithPrevYear($year);
|
||||
$filev = "/document/images/nbcommande2year.png";
|
||||
|
||||
$px = new BarGraph($data);
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetWidth(450);
|
||||
$px->SetHeight(280);
|
||||
$px->SetYLabel("Nombre de commande");
|
||||
$px->draw(DOL_DOCUMENT_ROOT.$filev, $data, $year);
|
||||
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetWidth(450);
|
||||
$px->SetHeight(280);
|
||||
$px->SetYLabel("Nombre de commande");
|
||||
$px->draw(DOL_DOCUMENT_ROOT.$filev, $data, $year);
|
||||
}
|
||||
$rows = $stats->getNbByYear();
|
||||
$num = sizeof($rows);
|
||||
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr><td align="center">Année</td><td width="10%">Nb de commande</td><td align="center">Somme des commandes</td>';
|
||||
print '<td align="center" valign="top" rowspan="'.($num + 1).'">';
|
||||
print 'Nombre de commande par mois<br><img src="'.DOL_URL_ROOT.$filev.'" alt="Graphique nombre de commande">';
|
||||
print 'Nombre de commande par mois<br>';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$filev.'" alt="Graphique nombre de commande">'; }
|
||||
print '</td></tr>';
|
||||
$i = 0;
|
||||
while (list($key, $value) = each ($rows))
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (c) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -34,36 +35,35 @@ if ($user->societe_id > 0)
|
||||
|
||||
llxHeader();
|
||||
|
||||
$mesg = '';
|
||||
$year = isset($_GET["year"])?$_GET["year"]:date("Y",time());
|
||||
|
||||
$mesg = '<a href="month.php?year='.($year - 1).'">'.img_previous().'</a> ';
|
||||
$mesg.= "Année $year";
|
||||
$mesg.= ' <a href="month.php?year='.($year + 1).'">'.img_next().'</a>';
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
$stats = new CommandeStats($db, $socidp);
|
||||
|
||||
$year = $_GET["year"];
|
||||
|
||||
print_fiche_titre('Statistiques commandes '.$year, $mesg);
|
||||
print_fiche_titre('Statistiques commandes', $mesg);
|
||||
|
||||
$dir = DOL_DOCUMENT_ROOT;
|
||||
|
||||
////////////////////////
|
||||
|
||||
$stats = new CommandeStats($db, $socidp);
|
||||
$data = $stats->getNbCommandeByMonth($year);
|
||||
|
||||
|
||||
$filev = "/document/images/commande$year.png";
|
||||
|
||||
$px = new BarGraph($data);
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(280);
|
||||
$px->SetYLabel("Nombre de commande");
|
||||
$px->draw($dir.$filev, $data, $year);
|
||||
|
||||
/////
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(280);
|
||||
$px->SetYLabel("Nombre de commande");
|
||||
$px->draw($dir.$filev, $data, $year);
|
||||
}
|
||||
|
||||
$res = $stats->getCommandeAmountByMonth($year);
|
||||
|
||||
@ -77,12 +77,14 @@ for ($i = 1 ; $i < 13 ; $i++)
|
||||
$file_amount = "/document/images/commandeamount.png";
|
||||
|
||||
$px = new BarGraph($data);
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
$px->SetYLabel("Montant des commande");
|
||||
$px->draw($dir.$file_amount, $data, $year);
|
||||
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
$px->SetYLabel("Montant des commande");
|
||||
$px->draw($dir.$file_amount, $data, $year);
|
||||
}
|
||||
$res = $stats->getCommandeAverageByMonth($year);
|
||||
|
||||
$data = array();
|
||||
@ -93,25 +95,30 @@ for ($i = 1 ; $i < 13 ; $i++)
|
||||
}
|
||||
$file_avg = "/document/images/commandeaverage.png";
|
||||
$px = new BarGraph($data);
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
$px->SetYLabel("Montant moyen des commande");
|
||||
$px->draw($dir.$file_avg, $data, $year);
|
||||
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
$px->SetYLabel("Montant moyen des commande");
|
||||
$px->draw($dir.$file_avg, $data, $year);
|
||||
}
|
||||
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr><td align="center">Nombre de commande par mois</td>';
|
||||
print '<td align="center">';
|
||||
print '<img src="'.DOL_URL_ROOT.$filev.'">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$filev.'">'; }
|
||||
print '</td></tr>';
|
||||
print '<tr><td align="center">Sommes des commandes</td>';
|
||||
print '<td align="center">';
|
||||
print '<img src="'.DOL_URL_ROOT.$file_amount.'">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$file_amount.'">'; }
|
||||
print '</td></tr>';
|
||||
print '<tr><td align="center">Montant moyen des commande</td>';
|
||||
print '<td align="center">';
|
||||
print '<img src="'.DOL_URL_ROOT.$file_avg.'">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$file_avg.'">'; }
|
||||
print '</td></tr></table>';
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (c) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -43,12 +44,14 @@ $data = $stats->getNbByMonthWithPrevYear($year);
|
||||
$filev = "/document/images/nbfacture2year-$year.png";
|
||||
|
||||
$px = new BarGraph($data);
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetLegend(array($year - 1, $year));
|
||||
$px->SetWidth(450);
|
||||
$px->SetHeight(280);
|
||||
|
||||
$px->draw(DOL_DOCUMENT_ROOT.$filev, $data, $year);
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetLegend(array($year - 1, $year));
|
||||
$px->SetWidth(450);
|
||||
$px->SetHeight(280);
|
||||
$px->draw(DOL_DOCUMENT_ROOT.$filev, $data, $year);
|
||||
}
|
||||
|
||||
$sql = "SELECT count(*), date_format(datef,'%Y') as dm, sum(total) FROM ".MAIN_DB_PREFIX."facture WHERE fk_statut > 0 ";
|
||||
if ($socidp)
|
||||
@ -63,7 +66,9 @@ if ($db->query($sql))
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr><td align="center">Année</td><td width="10%">Nb de facture</td><td align="center">Somme des factures</td>';
|
||||
print '<td align="center" valign="top" rowspan="'.($num + 1).'">';
|
||||
print 'Nombre de facture par mois<br><img src="'.DOL_URL_ROOT.$filev.'" alt="Graphique nombre de commande">';
|
||||
print 'Nombre de facture par mois<br>';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$filev.'" alt="Graphique nombre de commande">'; }
|
||||
print '</td></tr>';
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (c) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -21,6 +22,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
/*
|
||||
* Sécurité accés client
|
||||
*/
|
||||
@ -31,36 +33,36 @@ if ($user->societe_id > 0)
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
$year = $_GET["year"];
|
||||
$mesg = '';
|
||||
|
||||
print_fiche_titre('Statistiques des factures '.$year, $mesg);
|
||||
$year = isset($_GET["year"])?$_GET["year"]:date("Y",time());
|
||||
|
||||
print '<a href="month.php?year='.($year - 1).'">'.($year-1).'</a> - ';
|
||||
print '<a href="month.php?year='.($year + 1).'">'.($year + 1).'</a>';
|
||||
$mesg = '<a href="month.php?year='.($year - 1).'">'.img_previous().'</a> ';
|
||||
$mesg.= "Année $year";
|
||||
$mesg.= ' <a href="month.php?year='.($year + 1).'">'.img_next().'</a>';
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
$stats = new FactureStats($db, $socidp);
|
||||
|
||||
print_fiche_titre('Statistiques des factures '.$year, $mesg);
|
||||
|
||||
|
||||
$dir = DOL_DOCUMENT_ROOT;
|
||||
|
||||
////////////////////////
|
||||
|
||||
$stats = new FactureStats($db, $socidp);
|
||||
$data = $stats->getNbByMonth($year);
|
||||
|
||||
$filev = "/document/images/facture$year.png";
|
||||
|
||||
$px = new BarGraph($data);
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(280);
|
||||
|
||||
$px->draw($dir.$filev, $data, $year);
|
||||
|
||||
/////
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetMaxValue($px->GetMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(280);
|
||||
$px->draw($dir.$filev, $data, $year);
|
||||
}
|
||||
|
||||
$res = $stats->getAmountByMonth($year);
|
||||
|
||||
@ -74,13 +76,14 @@ for ($i = 1 ; $i < 13 ; $i++)
|
||||
$file_amount = "/document/images/factureamount$year.png";
|
||||
|
||||
$px = new BarGraph($data);
|
||||
$px->SetYLabel("Montant");
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
|
||||
$px->draw($dir.$file_amount, $data, $year);
|
||||
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetYLabel("Montant");
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
$px->draw($dir.$file_amount, $data, $year);
|
||||
}
|
||||
$res = $stats->getAverageByMonth($year);
|
||||
|
||||
$data = array();
|
||||
@ -91,25 +94,30 @@ for ($i = 1 ; $i < 13 ; $i++)
|
||||
}
|
||||
$file_avg = "/document/images/factureaverage$year.png";
|
||||
$px = new BarGraph($data);
|
||||
$px->SetYLabel("Montant moyen");
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
$px->draw($dir.$file_avg, $data, $year);
|
||||
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$px->SetYLabel("Montant moyen");
|
||||
$px->SetMaxValue($px->GetAmountMaxValue());
|
||||
$px->SetWidth(500);
|
||||
$px->SetHeight(250);
|
||||
$px->draw($dir.$file_avg, $data, $year);
|
||||
}
|
||||
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr><td align="center">Nombre par mois</td>';
|
||||
print '<td align="center">';
|
||||
print '<img src="'.DOL_URL_ROOT.$filev.'">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$filev.'">'; }
|
||||
print '</td></tr>';
|
||||
print '<tr><td align="center">Sommes</td>';
|
||||
print '<td align="center">';
|
||||
print '<img src="'.DOL_URL_ROOT.$file_amount.'">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$file_amount.'">'; }
|
||||
print '</td></tr>';
|
||||
print '<tr><td align="center">Montant moyen</td>';
|
||||
print '<td align="center">';
|
||||
print '<img src="'.DOL_URL_ROOT.$file_avg.'">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else { print '<img src="'.DOL_URL_ROOT.$file_avg.'">'; }
|
||||
print '</td></tr></table>';
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (c) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -49,20 +50,23 @@ if ($id)
|
||||
}
|
||||
}
|
||||
|
||||
$filev = $dir . "/vente12mois.png";
|
||||
$filenv = $dir . "/vendu12mois.png";
|
||||
|
||||
if (! file_exists($filev) or $action == 'recalcul')
|
||||
{
|
||||
$px = new BarGraph();
|
||||
$graph_data = $product->get_num_vente();
|
||||
$px->draw($filev, $graph_data);
|
||||
$px = new BarGraph();
|
||||
$graph_data = $product->get_nb_vente();
|
||||
$px->draw($filenv, $graph_data);
|
||||
$mesg = "Graphiques générés";
|
||||
}
|
||||
|
||||
$filenbvente = $dir . "/vente12mois.png";
|
||||
$filenbpiece = $dir . "/vendu12mois.png";
|
||||
|
||||
if (! file_exists($filenbvente) or $action == 'recalcul')
|
||||
{
|
||||
$px = new BarGraph();
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg) {
|
||||
$graph_data = $product->get_num_vente();
|
||||
$px->draw($filenbvente, $graph_data);
|
||||
$px = new BarGraph();
|
||||
$graph_data = $product->get_nb_vente();
|
||||
$px->draw($filenbpiece, $graph_data);
|
||||
$mesg = "Graphiques générés";
|
||||
}
|
||||
}
|
||||
|
||||
print_fiche_titre('Fiche produit : '.$product->ref, $mesg);
|
||||
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4"><tr>';
|
||||
@ -88,9 +92,17 @@ if ($id)
|
||||
print '<img src="'.DOL_URL_ROOT.'/document/produit/'.$product->id.'/vendu12mois.png" alt="Ventes sur les 12 derniers mois">';
|
||||
|
||||
print '</td></tr><tr>';
|
||||
print '<td>Généré le '.strftime("%d %b %Y %H:%M:%S",filemtime($filev)).'</td>';
|
||||
if (file_exists($filenbvente) && filemtime($filenbvente)) {
|
||||
print '<td>Généré le '.dolibarr_print_date(filemtime($filenbvente),"%d %b %Y %H:%M:%S").'</td>';
|
||||
} else {
|
||||
print '<td>Graphique non généré</td>';
|
||||
}
|
||||
print '<td align="center">[<a href="fiche.php?id='.$id.'&action=recalcul">Re-calculer</a>]</td>';
|
||||
print '<td>Généré le '.strftime("%d %b %Y %H:%M:%S",filemtime($filev)).'</td>';
|
||||
if (file_exists($filenbpiece) && filemtime($filenbpiece)) {
|
||||
print '<td>Généré le '.dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S").'</td>';
|
||||
} else {
|
||||
print '<td>Graphique non généré</td>';
|
||||
}
|
||||
print '<td align="center">[<a href="fiche.php?id='.$id.'&action=recalcul">Re-calculer</a>]</td>';
|
||||
print '</tr></table>';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user