From 758b732391eb2c7e86fb59aefd34a12effb83f3c Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Sun, 20 Apr 2014 12:04:42 +0200 Subject: [PATCH] Update index.php add piechart on society categories --- htdocs/societe/index.php | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 9cf708b151053..8ff59740a3d40 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -158,6 +158,58 @@ print ''; print ''; +if (! empty($conf->categorie->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $elementtype = 'societe'; + print '
'; + print ''; + print ''; + print ''; + $total+=$obj->nb; + $i++; + } + } + } + print ''; + 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 '
'; +} //print ''; print '
';