New: Graph js librairie can accept colors and mix bar with plots.
This commit is contained in:
parent
993428e093
commit
66df4de8be
@ -154,7 +154,6 @@ if ($conf->use_javascript_ajax)
|
||||
$SommeD=0;
|
||||
$dataval=array();
|
||||
$datalabels=array();
|
||||
$dataseries=array();
|
||||
foreach ($AdherentType as $key => $adhtype)
|
||||
{
|
||||
$datalabels[]=$adhtype->getNomUrl(0,dol_size(16));
|
||||
@ -167,15 +166,18 @@ if ($conf->use_javascript_ajax)
|
||||
$SommeC+=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
|
||||
$SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
|
||||
}
|
||||
|
||||
/*
|
||||
$dataseries=array();
|
||||
$dataseries[]=array('label'=>$langs->trans("MembersStatusToValid"),'values'=> $dataval['draft']);
|
||||
$dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'values'=> $dataval['notuptodate']);
|
||||
$dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'values'=> $dataval['uptodate']);
|
||||
$dataseries[]=array('label'=>$langs->trans("MembersStatusResiliated"),'values'=> $dataval['resiliated']);
|
||||
$data=array('series'=>$dataseries,'xlabel'=>$datalabels);
|
||||
dol_print_graph('stats2',300,180,$data,1,'bar');
|
||||
$dataseries=array();
|
||||
$data=array('series'=>$dataseries,'seriestype'=>array('bar','bar','bar','bar'),'xlabel'=>$datalabels);
|
||||
dol_print_graph('stats2',300,180,$data,1,'barline');
|
||||
*/
|
||||
|
||||
$dataseries=array();
|
||||
$dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'values'=>array(round($SommeB)));
|
||||
$dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'values'=>array(round($SommeC)));
|
||||
$dataseries[]=array('label'=>$langs->trans("MembersStatusResiliated"),'values'=>array(round($SommeD)));
|
||||
|
||||
@ -62,7 +62,7 @@ class Propal extends CommonObject
|
||||
var $author;
|
||||
var $ref;
|
||||
var $ref_client;
|
||||
var $statut; // 0, 1, 2, 3, 4
|
||||
var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (billed)
|
||||
var $datec; // Date of creation
|
||||
var $datev; // Date of validation
|
||||
var $date; // Date of proposal
|
||||
@ -1994,9 +1994,9 @@ class Propal extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return label of status of proposal (draft, validated, ...)
|
||||
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
||||
* \return string Label
|
||||
* Return label of status of proposal (draft, validated, ...)
|
||||
* @param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
||||
* @return string Label
|
||||
*/
|
||||
function getLibStatut($mode=0)
|
||||
{
|
||||
@ -2004,10 +2004,10 @@ class Propal extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return label of a status (draft, validated, ...)
|
||||
* \param statut id statut
|
||||
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
||||
* \return string Label
|
||||
* Return label of a status (draft, validated, ...)
|
||||
* @param statut id statut
|
||||
* @param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
||||
* @return string Label
|
||||
*/
|
||||
function LibStatut($statut,$mode=1)
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -19,11 +19,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/comm/propal/stats/index.php
|
||||
\ingroup propale
|
||||
\brief Page des stats propositions commerciales
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/comm/propal/stats/index.php
|
||||
* \ingroup propale
|
||||
* \brief Page des stats propositions commerciales
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require("../../../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propalestats.class.php");
|
||||
@ -32,21 +32,24 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php");
|
||||
$WIDTH=500;
|
||||
$HEIGHT=200;
|
||||
|
||||
// S<EFBFBD>curit<EFBFBD> acc<63>s client
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$year = strftime("%Y", time());
|
||||
$startyear=$year-2;
|
||||
$endyear=$year;
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$langs->load("propal");
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_fiche_titre($langs->trans("ProposalsStatistics"), $mesg);
|
||||
@ -65,40 +68,40 @@ $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
|
||||
|
||||
if (!$user->rights->societe->client->voir || $user->societe_id)
|
||||
{
|
||||
$filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png';
|
||||
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png';
|
||||
$filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png';
|
||||
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filenamenb = $dir.'/proposalsnbinyear-'.$year.'.png';
|
||||
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png';
|
||||
$filenamenb = $dir.'/proposalsnbinyear-'.$year.'.png';
|
||||
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png';
|
||||
}
|
||||
|
||||
$px = new DolGraph();
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg)
|
||||
{
|
||||
$px->SetData($data);
|
||||
$px->SetPrecisionY(0);
|
||||
$i=$startyear;
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px->SetLegend($legend);
|
||||
$px->SetMaxValue($px->GetCeilMaxValue());
|
||||
$px->SetMinValue(min(0,$px->GetFloorMinValue()));
|
||||
$px->SetWidth($WIDTH);
|
||||
$px->SetHeight($HEIGHT);
|
||||
$px->SetYLabel($langs->trans("NbOfProposals"));
|
||||
$px->SetShading(3);
|
||||
$px->SetHorizTickIncrement(1);
|
||||
$px->SetPrecisionY(0);
|
||||
$px->mode='depth';
|
||||
$px->SetTitle($langs->trans("NumberOfProposalsByMonth"));
|
||||
$px->SetData($data);
|
||||
$px->SetPrecisionY(0);
|
||||
$i=$startyear;
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px->SetLegend($legend);
|
||||
$px->SetMaxValue($px->GetCeilMaxValue());
|
||||
$px->SetMinValue(min(0,$px->GetFloorMinValue()));
|
||||
$px->SetWidth($WIDTH);
|
||||
$px->SetHeight($HEIGHT);
|
||||
$px->SetYLabel($langs->trans("NbOfProposals"));
|
||||
$px->SetShading(3);
|
||||
$px->SetHorizTickIncrement(1);
|
||||
$px->SetPrecisionY(0);
|
||||
$px->mode='depth';
|
||||
$px->SetTitle($langs->trans("NumberOfProposalsByMonth"));
|
||||
|
||||
$px->draw($filenamenb);
|
||||
$px->draw($filenamenb);
|
||||
}
|
||||
|
||||
// Build graphic amount of object
|
||||
@ -108,40 +111,40 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
|
||||
|
||||
if (!$user->rights->societe->client->voir || $user->societe_id)
|
||||
{
|
||||
$filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
$filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filenameamount = $dir.'/proposalsamountinyear-'.$year.'.png';
|
||||
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png';
|
||||
$filenameamount = $dir.'/proposalsamountinyear-'.$year.'.png';
|
||||
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png';
|
||||
}
|
||||
|
||||
$px = new DolGraph();
|
||||
$mesg = $px->isGraphKo();
|
||||
if (! $mesg)
|
||||
{
|
||||
$px->SetData($data);
|
||||
$px->SetPrecisionY(0);
|
||||
$i=$startyear;
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px->SetLegend($legend);
|
||||
$px->SetMaxValue($px->GetCeilMaxValue());
|
||||
$px->SetMinValue(min(0,$px->GetFloorMinValue()));
|
||||
$px->SetWidth($WIDTH);
|
||||
$px->SetHeight($HEIGHT);
|
||||
$px->SetYLabel($langs->trans("AmountOfProposals"));
|
||||
$px->SetShading(3);
|
||||
$px->SetHorizTickIncrement(1);
|
||||
$px->SetPrecisionY(0);
|
||||
$px->mode='depth';
|
||||
$px->SetTitle($langs->trans("AmountOfProposalsByMonthHT"));
|
||||
$px->SetData($data);
|
||||
$px->SetPrecisionY(0);
|
||||
$i=$startyear;
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px->SetLegend($legend);
|
||||
$px->SetMaxValue($px->GetCeilMaxValue());
|
||||
$px->SetMinValue(min(0,$px->GetFloorMinValue()));
|
||||
$px->SetWidth($WIDTH);
|
||||
$px->SetHeight($HEIGHT);
|
||||
$px->SetYLabel($langs->trans("AmountOfProposals"));
|
||||
$px->SetShading(3);
|
||||
$px->SetHorizTickIncrement(1);
|
||||
$px->SetPrecisionY(0);
|
||||
$px->mode='depth';
|
||||
$px->SetTitle($langs->trans("AmountOfProposalsByMonthHT"));
|
||||
|
||||
$px->draw($filenameamount);
|
||||
$px->draw($filenameamount);
|
||||
}
|
||||
|
||||
print '<table class="notopnoleftnopadd" width="100%"><tr>';
|
||||
@ -161,25 +164,25 @@ print '</tr>';
|
||||
$oldyear=0;
|
||||
foreach ($data as $val)
|
||||
{
|
||||
$year = $val['year'];
|
||||
print $avg;
|
||||
while ($oldyear > $year+1)
|
||||
{ // If we have empty year
|
||||
$oldyear--;
|
||||
print '<tr height="24">';
|
||||
print '<td align="center"><a href="month.php?year='.$oldyear.'&mode='.$mode.'">'.$oldyear.'</a></td>';
|
||||
print '<td align="right">0</td>';
|
||||
print '<td align="right">0</td>';
|
||||
print '<td align="right">0</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '<tr height="24">';
|
||||
$year = $val['year'];
|
||||
print $avg;
|
||||
while ($oldyear > $year+1)
|
||||
{ // If we have empty year
|
||||
$oldyear--;
|
||||
print '<tr height="24">';
|
||||
print '<td align="center"><a href="month.php?year='.$oldyear.'&mode='.$mode.'">'.$oldyear.'</a></td>';
|
||||
print '<td align="right">0</td>';
|
||||
print '<td align="right">0</td>';
|
||||
print '<td align="right">0</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '<tr height="24">';
|
||||
print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td>';
|
||||
print '<td align="right">'.$val['nb'].'</td>';
|
||||
print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
|
||||
print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';
|
||||
print '</tr>';
|
||||
$oldyear=$year;
|
||||
print '<td align="right">'.$val['nb'].'</td>';
|
||||
print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
|
||||
print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';
|
||||
print '</tr>';
|
||||
$oldyear=$year;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
@ -192,9 +195,9 @@ print '<td align="center" valign="top">';
|
||||
print '<table class="border" width="100%"><tr valign="top"><td align="center">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else {
|
||||
print '<img src="'.$fileurlnb.'" title="'.$langs->trans("NbOfProposals").'" alt="'.$langs->trans("NbOfProposals").'">';
|
||||
print "<br>\n";
|
||||
print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountTotal").'" alt="'.$langs->trans("AmountTotal").'">';
|
||||
print '<img src="'.$fileurlnb.'" title="'.$langs->trans("NbOfProposals").'" alt="'.$langs->trans("NbOfProposals").'">';
|
||||
print "<br>\n";
|
||||
print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountTotal").'" alt="'.$langs->trans("AmountTotal").'">';
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
||||
@ -1267,8 +1267,11 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
||||
{
|
||||
if ($type == 'pie')
|
||||
{
|
||||
// data is array('series'=>array(0=>serie1,1=>serie2,...));
|
||||
// serie is array('label'=>'label', values=>array(0=>val))
|
||||
// data is array('series'=>array(serie1,serie2,...),
|
||||
// 'seriestype'=>array('bar','line',...),
|
||||
// 'seriescolor'=>array(0=>'#999999',1=>'#999999',...)
|
||||
// 'xlabel'=>array(0=>labelx1,1=>labelx2,...));
|
||||
// serieX is array('label'=>'label', values=>array(0=>val))
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
@ -1314,15 +1317,16 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
||||
interactive: true
|
||||
},
|
||||
';
|
||||
$i=0; $outputserie=0;
|
||||
if (sizeof($datacolor))
|
||||
{
|
||||
print 'colors: [';
|
||||
$j=0;
|
||||
foreach($datacolor as $val)
|
||||
{
|
||||
print '"'.$val.'"';
|
||||
if ($j < sizeof($datacolor)) print ',';
|
||||
$j++;
|
||||
if ($outputserie > 0) print ',';
|
||||
print '"'.(empty($data['seriescolor'][$i])?$val:$data['seriescolor'][$i]).'"';
|
||||
$outputserie++;
|
||||
$i++;
|
||||
}
|
||||
print '], ';
|
||||
}
|
||||
@ -1333,18 +1337,23 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
else if ($type == 'bar')
|
||||
else if ($type == 'barline')
|
||||
{
|
||||
// data is array('series'=>array(0=>serie1,1=>serie2,...),'xlabel'=>array(0=>label1,1=>label2,...));
|
||||
// serie is array('label'=>'label', values=>array(0=>val1,1=>val2,...))
|
||||
// data is array('series'=>array(serie1,serie2,...),
|
||||
// 'seriestype'=>array('bar','line',...),
|
||||
// 'seriescolor'=>array(0=>'#999999',1=>'#999999',...)
|
||||
// 'xlabel'=>array(0=>labelx1,1=>labelx2,...));
|
||||
// serieX is array('label'=>'label', values=>array(0=>y1,1=>y2,...)) with same nb of value than into xlabel
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
var data = [';
|
||||
$i=1;
|
||||
$i=1; $outputserie=0;
|
||||
foreach($data['series'] as $serie)
|
||||
{
|
||||
print '{label: \''.dol_escape_js($serie['label']).'\', data: [';
|
||||
if ($data['seriestype'][$i-1]=='line') { $i++; continue; };
|
||||
if ($outputserie > 0) print ',';
|
||||
print '{ bars: { stack: 0, show: true, barWidth: 0.9, align: \'center\' }, label: \''.dol_escape_js($serie['label']).'\', data: [';
|
||||
$j=1;
|
||||
foreach($serie['values'] as $val)
|
||||
{
|
||||
@ -1352,8 +1361,28 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
||||
if ($j < sizeof($serie['values'])) print ', ';
|
||||
$j++;
|
||||
}
|
||||
print ']}';
|
||||
if ($i < sizeof($data['series'])) print ',';
|
||||
print ']}'."\n";
|
||||
$outputserie++;
|
||||
$i++;
|
||||
}
|
||||
if ($outputserie) print ', ';
|
||||
//print '];
|
||||
//var datalines = [';
|
||||
$i=1; $outputserie=0;
|
||||
foreach($data['series'] as $serie)
|
||||
{
|
||||
if (empty($data['seriestype'][$i-1]) || $data['seriestype'][$i-1]=='bar') { $i++; continue; };
|
||||
if ($outputserie > 0) print ',';
|
||||
print '{ lines: { show: true }, label: \''.dol_escape_js($serie['label']).'\', data: [';
|
||||
$j=1;
|
||||
foreach($serie['values'] as $val)
|
||||
{
|
||||
print '['.$j.','.$val.']';
|
||||
if ($j < sizeof($serie['values'])) print ', ';
|
||||
$j++;
|
||||
}
|
||||
print ']}'."\n";
|
||||
$outputserie++;
|
||||
$i++;
|
||||
}
|
||||
print '];
|
||||
@ -1367,16 +1396,11 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
||||
}
|
||||
print '];
|
||||
|
||||
var stack = 0, bars = true, lines = false, steps = false;
|
||||
|
||||
function plotWithOptions() {
|
||||
jQuery.plot(jQuery("#'.$htmlid.'"), data,
|
||||
{
|
||||
series: {
|
||||
stack: stack,
|
||||
lines: { show: lines, fill: true, steps: steps },
|
||||
bars: { show: bars, barWidth: 0.9, align: \'center\' },
|
||||
shadowSize: 5
|
||||
stack: 0
|
||||
},
|
||||
zoom: {
|
||||
interactive: true
|
||||
@ -3674,13 +3698,13 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
|
||||
$ret='';
|
||||
$out='';
|
||||
$divstart=$divend='';
|
||||
|
||||
|
||||
if (isset($_SESSION['mesg']))
|
||||
{
|
||||
$mesgstring=$_SESSION['mesg'];
|
||||
unset($_SESSION['mesg']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($_SESSION['mesgarray']))
|
||||
{
|
||||
$mesgarray=$_SESSION['mesgarray'];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user