diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php
index 9cf708b1510..8ff59740a3d 100644
--- a/htdocs/societe/index.php
+++ b/htdocs/societe/index.php
@@ -158,6 +158,58 @@ print $total;
print '';
print '';
+if (! empty($conf->categorie->enabled))
+{
+ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+ $elementtype = 'societe';
+ print '
';
+ print '
| '.$langs->trans("Categories").' | |
|---|---|
| '; + $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 ' | |
| '.$obj->label.' | '.$obj->nb.' |
| '.$langs->trans("Total").' | '; + print $total; + print ' |