mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 09:38:23 +01:00
Support stack bars for flot graphs
This commit is contained in:
@@ -137,15 +137,49 @@ print '</td></tr>';
|
||||
print "</table></form>";
|
||||
|
||||
|
||||
print '</td><td class="notopnoleftnoright" valign="top">';
|
||||
|
||||
|
||||
$var=true;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").'</td></tr>';
|
||||
print '<tr><td align="center">';
|
||||
|
||||
$SommeA=0;
|
||||
$SommeB=0;
|
||||
$SommeC=0;
|
||||
$SommeD=0;
|
||||
$dataval=array();
|
||||
$datalabels=array();
|
||||
foreach ($AdherentType as $key => $adhtype)
|
||||
{
|
||||
$datalabels[]=$adhtype->getNomUrl(0,dol_size(16));
|
||||
$dataval['draft'][]=isset($MemberToValidate[$key])?$MemberToValidate[$key]:0;
|
||||
$dataval['notuptodate'][]=isset($MembersValidated[$key])?$MembersValidated[$key]-$MemberUpToDate[$key]:0;
|
||||
$dataval['uptodate'][]=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
|
||||
$dataval['resiliated'][]=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
|
||||
$SommeA+=isset($MemberToValidate[$key])?$MemberToValidate[$key]:0;
|
||||
$SommeB+=isset($MembersValidated[$key])?$MembersValidated[$key]-$MemberUpToDate[$key]:0;
|
||||
$SommeC+=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
|
||||
$SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
|
||||
}
|
||||
/*
|
||||
$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('stats',300,180,$data,1,'bar');
|
||||
*/
|
||||
$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)));
|
||||
$dataseries[]=array('label'=>$langs->trans("MembersStatusToValid"),'values'=>array(round($SommeA)));
|
||||
$data=array('series'=>$dataseries);
|
||||
dol_print_graph('stats',300,180,$data,1,'pie');
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '</td><td class="notopnoleftnoright" valign="top">';
|
||||
|
||||
|
||||
$var=true;
|
||||
|
||||
// Summary of members by type
|
||||
print '<table class="noborder" width="100%">';
|
||||
@@ -167,10 +201,6 @@ foreach ($AdherentType as $key => $adhtype)
|
||||
print '<td align="right">'.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,gmmktime(),3).'</td>';
|
||||
print '<td align="right">'.(isset($MembersResiliated[$key]) && $MembersResiliated[$key]> 0 ?$MembersResiliated[$key]:'').' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'</td>';
|
||||
print "</tr>\n";
|
||||
$SommeA+=isset($MemberToValidate[$key])?$MemberToValidate[$key]:0;
|
||||
$SommeB+=isset($MembersValidated[$key])?$MembersValidated[$key]-$MemberUpToDate[$key]:0;
|
||||
$SommeC+=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
|
||||
$SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
|
||||
}
|
||||
print '<tr class="liste_total">';
|
||||
print '<td class="liste_total">'.$langs->trans("Total").'</td>';
|
||||
|
||||
@@ -1234,7 +1234,8 @@ function dolibarr_trunc($string,$size=40,$trunc='right',$stringencoding='')
|
||||
* @param width Width in pixel
|
||||
* @param height Height in pixel
|
||||
* @param data Data array
|
||||
* @param type Type of graph
|
||||
* @param showlegend Show legend
|
||||
* @param type Type of graph (pie, bar, line)
|
||||
*/
|
||||
function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
||||
{
|
||||
@@ -1264,20 +1265,24 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
||||
{
|
||||
if ($type == 'pie')
|
||||
{
|
||||
print '<script type="text/javascript">
|
||||
// data is array('series'=>array(0=>serie1,1=>serie2,...));
|
||||
// serie is array('label'=>'label', values=>array(0=>val))
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
var data = ['."\n";
|
||||
$i=0;
|
||||
foreach($data as $serie)
|
||||
foreach($data['series'] as $serie)
|
||||
{
|
||||
//print '{ label: "'.($showlegend?$serie['values'][0]:$serie['label'].'<br>'.$serie['values'][0]).'", data: '.$serie['values'][0].' }';
|
||||
print '{ label: "'.($showlegend?$serie['label'].'<br>'.$serie['values'][0]:$serie['label'].'<br>'.$serie['values'][0]).'", data: '.$serie['values'][0].' }';
|
||||
if ($i < sizeof($serie)) print ',';
|
||||
print '{ label: "'.dol_escape_js($serie['label']).'", data: '.$serie['values'][0].' }';
|
||||
if ($i < sizeof($data['series'])) print ',';
|
||||
print "\n";
|
||||
$i++;
|
||||
}
|
||||
print '];
|
||||
|
||||
function plotWithOptions() {
|
||||
jQuery.plot(jQuery("#'.$htmlid.'"), data,
|
||||
{
|
||||
series: {pie: {
|
||||
@@ -1286,10 +1291,12 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
||||
label: {
|
||||
show: true,
|
||||
radius: 3/4,
|
||||
formatter: function(label, series){
|
||||
return \'<div style="font-size:8pt;text-align:center;padding:2px;color:white;">\'+label
|
||||
/* +\'<br/>\'+Math.round(series.percent)*/
|
||||
+\'</div>\';
|
||||
formatter: function(label, series) {
|
||||
var percent=Math.round(series.percent);
|
||||
var number=series.data[0][1];
|
||||
return \'<div style="font-size:8pt;text-align:center;padding:2px;color:white;">\'+'.($showlegend?'number':'label+\'<br/>\'+number');
|
||||
if (! empty($showpercent)) print '+\'<br/>\'+percent';
|
||||
print '+\'</div>\';
|
||||
},
|
||||
background: {
|
||||
opacity: 0.5,
|
||||
@@ -1312,9 +1319,77 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
||||
}
|
||||
print 'legend: {show: '.($showlegend?'true':'false').'}
|
||||
});
|
||||
}
|
||||
plotWithOptions();
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
else if ($type == 'bar')
|
||||
{
|
||||
// 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,...))
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
var data = [';
|
||||
$i=1;
|
||||
foreach($data['series'] as $serie)
|
||||
{
|
||||
print '{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 ']}';
|
||||
if ($i < sizeof($data['series'])) print ',';
|
||||
$i++;
|
||||
}
|
||||
print '];
|
||||
var dataticks = [';
|
||||
$i=1;
|
||||
foreach($data['xlabel'] as $label)
|
||||
{
|
||||
print '['.$i.',\''.$label.'\']';
|
||||
if ($i < sizeof($data['xlabel'])) print ',';
|
||||
$i++;
|
||||
}
|
||||
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\' }
|
||||
},
|
||||
';
|
||||
if (sizeof($datacolor))
|
||||
{
|
||||
print 'colors: [';
|
||||
$j=0;
|
||||
foreach($datacolor as $val)
|
||||
{
|
||||
print '"'.$val.'"';
|
||||
if ($j < sizeof($datacolor)) print ',';
|
||||
$j++;
|
||||
}
|
||||
print '], ';
|
||||
}
|
||||
print 'legend: {show: '.($showlegend?'true':'false').'},
|
||||
xaxis: {ticks: dataticks},
|
||||
});
|
||||
}
|
||||
plotWithOptions();
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
else print 'BadValueForPArameterType';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,10 +103,11 @@ print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").'</
|
||||
if ($conf->use_javascript_ajax && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0) >= 2))
|
||||
{
|
||||
print '<tr><td align="center">';
|
||||
$data=array();
|
||||
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $data[]=array('label'=>$langs->trans("Prospects"),'values'=>array(round($third['prospect'])));
|
||||
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $data[]=array('label'=>$langs->trans("Customers"),'values'=>array(round($third['customer'])));
|
||||
if ($conf->fournisseur->enabled) $data[]=array('label'=>$langs->trans("Suppliers"),'values'=>array(round($third['supplier'])));
|
||||
$dataseries=array();
|
||||
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $dataseries[]=array('label'=>$langs->trans("Prospects"),'values'=>array(round($third['prospect'])));
|
||||
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $dataseries[]=array('label'=>$langs->trans("Customers"),'values'=>array(round($third['customer'])));
|
||||
if ($conf->fournisseur->enabled) $dataseries[]=array('label'=>$langs->trans("Suppliers"),'values'=>array(round($third['supplier'])));
|
||||
$data=array('series'=>$dataseries);
|
||||
dol_print_graph('stats',300,180,$data,0,'pie');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user