mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Update index.php
add piechart on society categories
This commit is contained in:
parent
2b7c2a9040
commit
758b732391
|
|
@ -158,6 +158,58 @@ print $total;
|
|||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
if (! empty($conf->categorie->enabled))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$elementtype = 'societe';
|
||||
print '<br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
|
||||
print '<tr><td align="center">';
|
||||
$sql = "SELECT c.label, count(*) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
|
||||
$sql.= " WHERE c.type = 2";
|
||||
$sql.= " AND c.entity IN (".getEntity('category',1).")";
|
||||
$sql.= " GROUP BY c.label";
|
||||
$total=0;
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i=0;
|
||||
if (! empty($conf->use_javascript_ajax)
|
||||
{
|
||||
$dataseries=array();
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$dataseries[]=array('label'=>$obj->label,'data'=>round($obj->nb));
|
||||
$total+=$obj->nb;
|
||||
$i++;
|
||||
}
|
||||
$data=array('series'=>$dataseries);
|
||||
dol_print_graph('statscategclient',300,180,$data,1,'pie',0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr $bc[$var]><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
|
||||
$total+=$obj->nb;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">';
|
||||
print $total;
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
//print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
|
||||
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user