mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Update index.php
add the categories pie graph on product too (and correct some bug)
This commit is contained in:
parent
769c793580
commit
b12e87abc3
|
|
@ -111,9 +111,10 @@ $sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy";
|
|||
$result = $db->query($sql);
|
||||
while ($objp = $db->fetch_object($result))
|
||||
{
|
||||
$status=1;
|
||||
$status=2;
|
||||
if (! $objp->tosell && ! $objp->tobuy) $status=0; // To sell OR to buy
|
||||
$prodser[$objp->fk_product_type][$status]+=$objp->total;
|
||||
if ((! $objp->tosell && $objp->tobuy) || ($objp->tosell && ! $objp->tobuy)) $status=1;
|
||||
$prodser[$objp->fk_product_type][$status]=$objp->total;
|
||||
}
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
|
@ -124,40 +125,105 @@ if (! empty($conf->product->enabled))
|
|||
$statProducts.= '<td><a href="liste.php?type=0&tosell=0&tobuy=0">'.$langs->trans("ProductsNotOnSell").'</a></td><td align="right">'.round($prodser[0][0]).'</td>';
|
||||
$statProducts.= "</tr>";
|
||||
$statProducts.= "<tr ".$bc[1].">";
|
||||
$statProducts.= '<td><a href="liste.php?type=0&tosell=1">'.$langs->trans("ProductsOnSell").'</a></td><td align="right">'.round($prodser[0][1]).'</td>';
|
||||
$statProducts.= '<td><a href="liste.php?type=0">'.$langs->trans("ProductsOnSell").'</a></td><td align="right">'.round($prodser[0][1]).'</td>';
|
||||
$statProducts.= "</tr>";
|
||||
$statProducts.= "<tr ".$bc[0].">";
|
||||
$statProducts.= '<td><a href="liste.php?type=0&tosell=1&tobuy=1">'.$langs->trans("ProductsOnSellAndOnBuy").'</a></td><td align="right">'.round($prodser[0][2]).'</td>';
|
||||
$statProducts.= "</tr>";
|
||||
|
||||
}
|
||||
if (! empty($conf->service->enabled))
|
||||
{
|
||||
$statServices = "<tr ".$bc[0].">";
|
||||
$statServices = "<tr ".$bc[1].">";
|
||||
$statServices.= '<td><a href="liste.php?type=1&tosell=0&tobuy=0">'.$langs->trans("ServicesNotOnSell").'</a></td><td align="right">'.round($prodser[1][0]).'</td>';
|
||||
$statServices.= "</tr>";
|
||||
$statServices.= "<tr ".$bc[1].">";
|
||||
$statServices.= '<td><a href="liste.php?type=1&tosell=1">'.$langs->trans("ServicesOnSell").'</a></td><td align="right">'.round($prodser[1][1]).'</td>';
|
||||
$statServices.= "<tr ".$bc[0].">";
|
||||
$statServices.= '<td><a href="liste.php?type=1">'.$langs->trans("ServicesOnSell").'</a></td><td align="right">'.round($prodser[1][1]).'</td>';
|
||||
$statServices.= "</tr>";
|
||||
$statServices.= "<tr ".$bc[1].">";
|
||||
$statServices.= '<td><a href="liste.php?type=1&tosell=1&tobuy=1">'.$langs->trans("ServicesOnSellAndOnBuy").'</a></td><td align="right">'.round($prodser[1][2]).'</td>';
|
||||
$statServices.= "</tr>";
|
||||
|
||||
}
|
||||
$total=0;
|
||||
if ($type == '0')
|
||||
{
|
||||
print $statProducts;
|
||||
$total=round($prodser[0][0])+round($prodser[0][1]);
|
||||
$total=round($prodser[0][0])+round($prodser[0][1])+round($prodser[0][2]);
|
||||
}
|
||||
else if ($type == '1')
|
||||
{
|
||||
print $statServices;
|
||||
$total=round($prodser[1][0])+round($prodser[1][1]);
|
||||
$total=round($prodser[1][0])+round($prodser[1][1])+round($prodser[1][2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $statProducts.$statServices;
|
||||
$total=round($prodser[1][0])+round($prodser[1][1])+round($prodser[0][0])+round($prodser[0][1]);
|
||||
$total=round($prodser[1][0])+round($prodser[1][1])+round($prodser[1][2])+round($prodser[0][0])+round($prodser[0][1])+round($prodser[0][2]);
|
||||
}
|
||||
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">';
|
||||
print $total;
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
|
||||
if (! empty($conf->categorie->enabled))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
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_product as cs";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
|
||||
$sql.= " WHERE c.type = 0";
|
||||
$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();
|
||||
$rest=0;
|
||||
$nbmax=10;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
if ($i < $nbmax)
|
||||
$dataseries[]=array('label'=>$obj->label,'data'=>round($obj->nb));
|
||||
else
|
||||
$rest+=$obj->nb;
|
||||
$total+=$obj->nb;
|
||||
$i++;
|
||||
}
|
||||
if ($i > $nbmax)
|
||||
$dataseries[]=array('label'=>$langs->trans("Other"),'data'=>round($rest));
|
||||
$data=array('series'=>$dataseries);
|
||||
dol_print_graph('statscategproduct',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 '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user