diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang
index 73e672284de..15159599842 100644
--- a/htdocs/langs/en_US/products.lang
+++ b/htdocs/langs/en_US/products.lang
@@ -29,10 +29,14 @@ ProductOrService=Product or Service
ProductsAndServices=Products and Services
ProductsOrServices=Products or Services
ProductsPipeServices=Products | Services
+ProductsOnSale=Products for sale
+ProductsOnPurchase=Products for purchase
ProductsOnSaleOnly=Products for sale only
ProductsOnPurchaseOnly=Products for purchase only
ProductsNotOnSell=Products not for sale and not for purchase
ProductsOnSellAndOnBuy=Products for sale and for purchase
+ProductsOnSale=Services for sale
+ProductsOnPurchase=Services for purchase
ServicesOnSaleOnly=Services for sale only
ServicesOnPurchaseOnly=Services for purchase only
ServicesNotOnSell=Services not for sale and not for purchase
diff --git a/htdocs/product/index.php b/htdocs/product/index.php
index fdbbfd6661f..23e5a315be0 100644
--- a/htdocs/product/index.php
+++ b/htdocs/product/index.php
@@ -130,68 +130,62 @@ $sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy";
$result = $db->query($sql);
while ($objp = $db->fetch_object($result))
{
- $status=3;
+ $status=3; // On sale + On purchase
if (! $objp->tosell && ! $objp->tobuy) $status=0; // Not on sale, not on purchase
if ($objp->tosell && ! $objp->tobuy) $status=1; // On sale only
if (! $objp->tosell && $objp->tobuy) $status=2; // On purchase only
$prodser[$objp->fk_product_type][$status]=$objp->total;
+ if ((! empty($conf->product->enabled) && empty($objp->fk_product_type))
+ || (! empty($conf->product->enabled) && ! empty($objp->fk_product_type)))
+ {
+ if ($objp->tosell) $prodser[$objp->fk_product_type]['sell']+=$objp->total;
+ if ($objp->tobuy) $prodser[$objp->fk_product_type]['buy']+=$objp->total;
+ if (! $objp->tosell && ! $objp->tobuy) $prodser[$objp->fk_product_type]['none']+=$objp->total;
+ }
}
+if ($conf->use_javascript_ajax)
+{
+ print '
';
+ print '
';
+ print '| '.$langs->trans("Statistics").' |
';
+ print '';
-print '';
-print ' ';
-print '| '.$langs->trans("Statistics").' | ';
-if (! empty($conf->product->enabled))
-{
- $statProducts = '';
- $statProducts.= '| '.$langs->trans("ProductsNotOnSell").' | '.round($prodser[0][0]).' | ';
- $statProducts.= " ";
- $statProducts.= '';
- $statProducts.= '| '.$langs->trans("ProductsOnSaleOnly").' | '.round($prodser[0][1]).' | ';
- $statProducts.= " ";
- $statProducts.= '';
- $statProducts.= '| '.$langs->trans("ProductsOnPurchaseOnly").' | '.round($prodser[0][2]).' | ';
- $statProducts.= " ";
- $statProducts.= '';
- $statProducts.= '| '.$langs->trans("ProductsOnSellAndOnBuy").' | '.round($prodser[0][3]).' | ';
- $statProducts.= " ";
+ $SommeA=$prodser[0]['sell'];
+ $SommeB=$prodser[0]['buy'];
+ $SommeC=$prodser[0]['none'];
+ $SommeD=$prodser[1]['sell'];
+ $SommeE=$prodser[1]['buy'];
+ $SommeF=$prodser[1]['none'];
+ $total=0;
+ $dataval=array();
+ $datalabels=array();
+ $i=0;
+
+ $total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF;
+ $dataseries=array();
+ $dataseries[]=array($langs->trans("ProductsOnSale"), round($SommeA));
+ $dataseries[]=array($langs->trans("ProductsOnPurchase"), round($SommeB));
+ $dataseries[]=array($langs->trans("ProductsNotOnSell"), round($SommeC));
+ $dataseries[]=array($langs->trans("ServicesOnSale"), round($SommeD));
+ $dataseries[]=array($langs->trans("ServicesOnPurchase"), round($SommeE));
+ $dataseries[]=array($langs->trans("ServicesNotOnSell"), round($SommeF));
+
+ include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
+ $dolgraph = new DolGraph();
+ $dolgraph->SetData($dataseries);
+ $dolgraph->setShowLegend(1);
+ $dolgraph->setShowPercent(0);
+ $dolgraph->SetType(array('pie'));
+ $dolgraph->setWidth('100%');
+ $dolgraph->draw('idgraphstatus');
+ print $dolgraph->show($total?0:1);
+
+ print '';
+ print ' ';
+ print ' ';
}
-if (! empty($conf->service->enabled))
-{
- $statServices = ' |
';
- $statServices.= '| '.$langs->trans("ServicesNotOnSell").' | '.round($prodser[1][0]).' | ';
- $statServices.= "
";
- $statServices.= '';
- $statServices.= '| '.$langs->trans("ServicesOnSaleOnly").' | '.round($prodser[1][1]).' | ';
- $statServices.= "
";
- $statServices.= '';
- $statServices.= '| '.$langs->trans("ServicesOnPurchaseOnly").' | '.round($prodser[1][2]).' | ';
- $statServices.= "
";
- $statServices.= '';
- $statServices.= '| '.$langs->trans("ServicesOnSellAndOnBuy").' | '.round($prodser[1][3]).' | ';
- $statServices.= "
";
-}
-$total=0;
-if ($type == '0')
-{
- print $statProducts;
- $total=round($prodser[0][0])+round($prodser[0][1])+round($prodser[0][2])+round($prodser[0][3]);
-}
-elseif ($type == '1')
-{
- print $statServices;
- $total=round($prodser[1][0])+round($prodser[1][1])+round($prodser[1][2])+round($prodser[1][3]);
-}
-else
-{
- print $statProducts.$statServices;
- $total=round($prodser[0][0])+round($prodser[0][1])+round($prodser[0][2])+round($prodser[0][3])+round($prodser[1][0])+round($prodser[1][1])+round($prodser[1][2])+round($prodser[1][3]); //Calcul du Total des Produits et Services
-}
-print '| '.$langs->trans("Total").' | ';
-print $total;
-print ' |
';
-print '
';
-print '
';
+
if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_PRODUCTS))
{