Use graph for stats on products/services
This commit is contained in:
parent
adc0d2a133
commit
6009601254
@ -29,10 +29,14 @@ ProductOrService=Product or Service
|
|||||||
ProductsAndServices=Products and Services
|
ProductsAndServices=Products and Services
|
||||||
ProductsOrServices=Products or Services
|
ProductsOrServices=Products or Services
|
||||||
ProductsPipeServices=Products | Services
|
ProductsPipeServices=Products | Services
|
||||||
|
ProductsOnSale=Products for sale
|
||||||
|
ProductsOnPurchase=Products for purchase
|
||||||
ProductsOnSaleOnly=Products for sale only
|
ProductsOnSaleOnly=Products for sale only
|
||||||
ProductsOnPurchaseOnly=Products for purchase only
|
ProductsOnPurchaseOnly=Products for purchase only
|
||||||
ProductsNotOnSell=Products not for sale and not for purchase
|
ProductsNotOnSell=Products not for sale and not for purchase
|
||||||
ProductsOnSellAndOnBuy=Products for sale and for purchase
|
ProductsOnSellAndOnBuy=Products for sale and for purchase
|
||||||
|
ProductsOnSale=Services for sale
|
||||||
|
ProductsOnPurchase=Services for purchase
|
||||||
ServicesOnSaleOnly=Services for sale only
|
ServicesOnSaleOnly=Services for sale only
|
||||||
ServicesOnPurchaseOnly=Services for purchase only
|
ServicesOnPurchaseOnly=Services for purchase only
|
||||||
ServicesNotOnSell=Services not for sale and not for purchase
|
ServicesNotOnSell=Services not for sale and not for purchase
|
||||||
|
|||||||
@ -130,68 +130,62 @@ $sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy";
|
|||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
while ($objp = $db->fetch_object($result))
|
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=0; // Not on sale, not on purchase
|
||||||
if ($objp->tosell && ! $objp->tobuy) $status=1; // On sale only
|
if ($objp->tosell && ! $objp->tobuy) $status=1; // On sale only
|
||||||
if (! $objp->tosell && $objp->tobuy) $status=2; // On purchase only
|
if (! $objp->tosell && $objp->tobuy) $status=2; // On purchase only
|
||||||
$prodser[$objp->fk_product_type][$status]=$objp->total;
|
$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 '<div class="div-table-responsive-no-min">';
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
||||||
|
print '<tr><td class="center" colspan="2">';
|
||||||
|
|
||||||
print '<div class="div-table-responsive-no-min">';
|
$SommeA=$prodser[0]['sell'];
|
||||||
print '<table class="noborder" width="100%">';
|
$SommeB=$prodser[0]['buy'];
|
||||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
$SommeC=$prodser[0]['none'];
|
||||||
if (! empty($conf->product->enabled))
|
$SommeD=$prodser[1]['sell'];
|
||||||
{
|
$SommeE=$prodser[1]['buy'];
|
||||||
$statProducts = '<tr class="oddeven">';
|
$SommeF=$prodser[1]['none'];
|
||||||
$statProducts.= '<td><a href="list.php?type=0&tosell=0&tobuy=0">'.$langs->trans("ProductsNotOnSell").'</a></td><td class="right">'.round($prodser[0][0]).'</td>';
|
$total=0;
|
||||||
$statProducts.= "</tr>";
|
$dataval=array();
|
||||||
$statProducts.= '<tr class="oddeven">';
|
$datalabels=array();
|
||||||
$statProducts.= '<td><a href="list.php?type=0">'.$langs->trans("ProductsOnSaleOnly").'</a></td><td class="right">'.round($prodser[0][1]).'</td>';
|
$i=0;
|
||||||
$statProducts.= "</tr>";
|
|
||||||
$statProducts.= '<tr class="oddeven">';
|
$total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF;
|
||||||
$statProducts.= '<td><a href="list.php?type=0">'.$langs->trans("ProductsOnPurchaseOnly").'</a></td><td class="right">'.round($prodser[0][2]).'</td>';
|
$dataseries=array();
|
||||||
$statProducts.= "</tr>";
|
$dataseries[]=array($langs->trans("ProductsOnSale"), round($SommeA));
|
||||||
$statProducts.= '<tr class="oddeven">';
|
$dataseries[]=array($langs->trans("ProductsOnPurchase"), round($SommeB));
|
||||||
$statProducts.= '<td><a href="list.php?type=0&tosell=1&tobuy=1">'.$langs->trans("ProductsOnSellAndOnBuy").'</a></td><td class="right">'.round($prodser[0][3]).'</td>';
|
$dataseries[]=array($langs->trans("ProductsNotOnSell"), round($SommeC));
|
||||||
$statProducts.= "</tr>";
|
$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 '</td></tr>';
|
||||||
|
print '</table>';
|
||||||
|
print '</div>';
|
||||||
}
|
}
|
||||||
if (! empty($conf->service->enabled))
|
|
||||||
{
|
|
||||||
$statServices = '<tr class="oddeven">';
|
|
||||||
$statServices.= '<td><a href="list.php?type=1&tosell=0&tobuy=0">'.$langs->trans("ServicesNotOnSell").'</a></td><td class="right">'.round($prodser[1][0]).'</td>';
|
|
||||||
$statServices.= "</tr>";
|
|
||||||
$statServices.= '<tr class="oddeven">';
|
|
||||||
$statServices.= '<td><a href="list.php?type=1">'.$langs->trans("ServicesOnSaleOnly").'</a></td><td class="right">'.round($prodser[1][1]).'</td>';
|
|
||||||
$statServices.= "</tr>";
|
|
||||||
$statServices.= '<tr class="oddeven">';
|
|
||||||
$statServices.= '<td><a href="list.php?type=1">'.$langs->trans("ServicesOnPurchaseOnly").'</a></td><td class="right">'.round($prodser[1][2]).'</td>';
|
|
||||||
$statServices.= "</tr>";
|
|
||||||
$statServices.= '<tr class="oddeven">';
|
|
||||||
$statServices.= '<td><a href="list.php?type=1&tosell=1&tobuy=1">'.$langs->trans("ServicesOnSellAndOnBuy").'</a></td><td class="right">'.round($prodser[1][3]).'</td>';
|
|
||||||
$statServices.= "</tr>";
|
|
||||||
}
|
|
||||||
$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 '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
|
|
||||||
print $total;
|
|
||||||
print '</td></tr>';
|
|
||||||
print '</table>';
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_PRODUCTS))
|
if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_PRODUCTS))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user