Fix: Total sur stats propal
New: Les graph en bar ont 2 modes: bar cote a cote ou l'une derriere l'autre. New: Affichage de 3 ans au lieu de 2 sur graph stat propal
This commit is contained in:
parent
cd5f9ca0a1
commit
7a9363cd60
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2007 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
|
||||
@ -17,7 +17,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -41,7 +40,9 @@ print_fiche_titre($langs->trans("ProposalsStatistics"), $mesg);
|
||||
|
||||
$stats = new PropaleStats($db);
|
||||
$year = strftime("%Y", time());
|
||||
$data = $stats->getNbByMonthWithPrevYear($year);
|
||||
$startyear=$year-2;
|
||||
$endyear=$year;
|
||||
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
|
||||
|
||||
create_exdir($conf->propal->dir_temp);
|
||||
|
||||
@ -62,17 +63,24 @@ if (! $mesg)
|
||||
{
|
||||
$px->SetData($data);
|
||||
$px->SetPrecisionY(0);
|
||||
$px->SetLegend(array($year - 1, $year));
|
||||
$i=$startyear;
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px->SetLegend($legend);
|
||||
$px->SetMaxValue($px->GetCeilMaxValue());
|
||||
$px->SetWidth($WIDTH);
|
||||
$px->SetHeight($HEIGHT);
|
||||
$px->SetShading(3);
|
||||
$px->SetHorizTickIncrement(1);
|
||||
$px->SetPrecisionY(0);
|
||||
$px->mode='depth';
|
||||
$px->draw($filename);
|
||||
}
|
||||
|
||||
$sql = "SELECT count(*), date_format(p.datep,'%Y') as dm, sum(p.price)";
|
||||
$sql = "SELECT count(*) as nb, date_format(p.datep,'%Y') as dm, sum(p.total) as total_ttc";
|
||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
|
||||
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
@ -83,9 +91,10 @@ if($user->societe_id)
|
||||
$sql .= " AND p.fk_soc = ".$user->societe_id;
|
||||
}
|
||||
$sql.= " GROUP BY dm DESC ";
|
||||
if ($db->query($sql))
|
||||
$result=$db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="2">';
|
||||
print '<tr><td align="center">'.$langs->trans("Year").'</td><td width="10%" align="center">'.$langs->trans("NbOfProposals").'</td><td align="center">'.$langs->trans("AmountTotal").'</td>';
|
||||
@ -104,18 +113,18 @@ if ($db->query($sql))
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($i);
|
||||
$nbproduct = $row[0];
|
||||
$year = $row[1];
|
||||
$obj = $db->fetch_object($result);
|
||||
$nbproduct = $obj->nb;
|
||||
$year = $obj->dm;
|
||||
print "<tr>";
|
||||
print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td>';
|
||||
print '<td align="center">'.$nbproduct.'</td>';
|
||||
print '<td align="center">'.price($row[2]).'</td></tr>';
|
||||
print '<td align="center">'.price($obj->total_ttc).'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
$db->free();
|
||||
$db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -17,8 +17,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@ -47,6 +47,8 @@ class DolGraph
|
||||
{
|
||||
//! Type du graphique
|
||||
var $type='bars'; // bars, lines, ...
|
||||
var $mode='side'; // Mode bars graph: side, depth
|
||||
|
||||
//! Tableau de donnees
|
||||
var $data; // array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...)
|
||||
var $width=380;
|
||||
@ -146,7 +148,7 @@ class DolGraph
|
||||
// Definition de couleurs
|
||||
$bgcolor=new Color($this->bgcolor[0],$this->bgcolor[1],$this->bgcolor[2]);
|
||||
$colortrans=new Color(0,0,0,100);
|
||||
$colorsemitrans=new Color(255,255,255,50);
|
||||
$colorsemitrans=new Color(255,255,255,60);
|
||||
$colorgradient= new LinearGradient(new Color(235, 235, 235),new Color(255, 255, 255),0);
|
||||
|
||||
// Graph
|
||||
@ -163,7 +165,12 @@ class DolGraph
|
||||
|
||||
$group = new PlotGroup;
|
||||
//$group->setSpace(5, 5, 0, 0);
|
||||
$group->setPadding(strlen(max(abs($this->MaxValue),abs($this->MinValue)))*8+20, 10); // Width on left and right for Y axis values
|
||||
|
||||
$paddleft=50;
|
||||
$paddright=10;
|
||||
$strl=strlen(max(abs($this->MaxValue),abs($this->MinValue)));
|
||||
if ($strl > 6) $paddleft += ($strln * 4);
|
||||
$group->setPadding($paddleft, $paddright); // Width on left and right for Y axis values
|
||||
$group->legend->setSpace(0);
|
||||
$group->legend->setPadding(2,2,2,2);
|
||||
$group->legend->setPosition(NULL,0.1);
|
||||
@ -175,7 +182,7 @@ class DolGraph
|
||||
$legends=array();
|
||||
$i=0;
|
||||
$nblot=sizeof($this->data[0])-1;
|
||||
if (! $nblot) $end=1;
|
||||
|
||||
while ($i < $nblot)
|
||||
{
|
||||
$j=0;
|
||||
@ -201,18 +208,21 @@ class DolGraph
|
||||
//print "Lot de donnees $i<br>";
|
||||
//print_r($values);
|
||||
//print '<br>';
|
||||
|
||||
|
||||
$colorgrey=new Color(100,100,100);
|
||||
$color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20);
|
||||
$colorborder=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]);
|
||||
|
||||
//$plot = new BarPlot($newvalues,1,1,0);
|
||||
$plot = new BarPlot($newvalues, $i+1, $nblot);
|
||||
if ($this->mode == 'side') $plot = new BarPlot($newvalues, $i+1, $nblot);
|
||||
if ($this->mode == 'depth') $plot = new BarPlot($newvalues, 1, 1, ($nblot-$i-1)*5);
|
||||
|
||||
$plot->barBorder->setColor($colorborder);
|
||||
$plot->barBorder->setColor($colorgrey);
|
||||
$plot->setBarColor($color);
|
||||
|
||||
$plot->setBarPadding(0.1, 0.1);
|
||||
$plot->setBarSpace(5);
|
||||
if ($this->mode == 'side') $plot->setBarPadding(0.1, 0.1);
|
||||
if ($this->mode == 'depth') $plot->setBarPadding(0.1, 0.4);
|
||||
if ($this->mode == 'side') $plot->setBarSpace(5);
|
||||
if ($this->mode == 'depth') $plot->setBarSpace(2);
|
||||
|
||||
$plot->barShadow->setSize($this->SetShading);
|
||||
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
class Stats
|
||||
@ -29,24 +27,34 @@ class Stats
|
||||
$this->db = $DB;
|
||||
}
|
||||
|
||||
function getNbByMonthWithPrevYear($year)
|
||||
function getNbByMonthWithPrevYear($endyear,$startyear)
|
||||
{
|
||||
$data1 = $this->getNbByMonth($year - 1);
|
||||
$data2 = $this->getNbByMonth($year);
|
||||
$datay=array();
|
||||
|
||||
$year=$startyear;
|
||||
while($year <= $endyear)
|
||||
{
|
||||
$datay[$year] = $this->getNbByMonth($year);
|
||||
$year++;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
|
||||
for ($i = 0 ; $i < 12 ; $i++)
|
||||
{
|
||||
$data[$i] = array($data1[$i][0],
|
||||
$data1[$i][1],
|
||||
$data2[$i][1]);
|
||||
$data[$i][]=$datay[$endyear][$i][0];
|
||||
$year=$startyear;
|
||||
while($year <= $endyear)
|
||||
{
|
||||
$data[$i][]=$datay[$year][$i][1];
|
||||
$year++;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoie le nombre de proposition par mois pour une année donnée
|
||||
* \brief Renvoie le nombre de proposition par mois pour une annee donnee
|
||||
*
|
||||
*/
|
||||
function _getNbByMonth($year, $sql)
|
||||
@ -85,7 +93,7 @@ class Stats
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoie le nombre d'element par année
|
||||
* \brief Renvoie le nombre d'element par ann<EFBFBD>e
|
||||
*
|
||||
*/
|
||||
function _getNbByYear($sql)
|
||||
@ -111,7 +119,7 @@ class Stats
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoie le nombre d'element par mois pour une année donnée
|
||||
* \brief Renvoie le nombre d'element par mois pour une ann<EFBFBD>e donn<EFBFBD>e
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2007 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
|
||||
@ -17,7 +17,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -29,7 +28,7 @@
|
||||
|
||||
global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet;
|
||||
$theme_bordercolor = array(235,235,224);
|
||||
$theme_datacolor = array(array(120,130,150), array(160,160,180), array(190,190,220));
|
||||
$theme_datacolor = array(array(120,130,150), array(200,160,180), array(190,190,220));
|
||||
$theme_bgcolor = array(hexdec('F4'),hexdec('F4'),hexdec('F4'));
|
||||
$theme_bgcoloronglet = array(hexdec('DE'),hexdec('E7'),hexdec('EC'));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user