NEW Add chart of product statistics

This commit is contained in:
Laurent Destailleur 2015-11-07 16:25:14 +01:00
parent 57e162d7f8
commit 4e64230ac9
3 changed files with 130 additions and 39 deletions

View File

@ -1088,7 +1088,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
}
if (! empty($conf->propal->enabled))
{
$newmenu->add("/product/popuprop.php?leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire);
$newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire);
}
}
@ -1100,7 +1100,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire);
if (! empty($conf->propal->enabled))
{
$newmenu->add("/product/popuprop.php?leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire);
$newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire);
}
}

View File

@ -38,18 +38,16 @@ $type=GETPOST("type","int");
if (! empty($user->societe_id)) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page < 0) $page = 0;
if ($page == -1) { $page = 0; }
if (! $sortfield) $sortfield="c";
if (! $sortorder) $sortorder="DESC";
$conf->liste_limit = 3;
if ($page == -1) $page = 0;
$limit = $conf->liste_limit;
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
$staticproduct=new Product($db);
@ -69,7 +67,13 @@ if ($type == '0')
else if ($type == '1')
{
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
$title=$langs->trans("StatisticsOfServices");
//$title=$langs->trans("StatisticsOfServices");
$title=$langs->trans("Statistics");
}
else
{
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
//$title=$langs->trans("StatisticsOfProductsOrServices");
$title=$langs->trans("Statistics");
}
@ -80,24 +84,30 @@ print load_fiche_titre($title, $mesg,'title_products.png');
$param = '';
$title = $langs->trans("ListProductServiceByPopularity");
if ($type != '') {
$param = '&type='.$type;
if ($type == 1) {
$title = $langs->trans("ListServiceByPopularity");
} else {
$title = $langs->trans("ListProductByPopularity");
}
if ((string) $type == '1') {
$title = $langs->trans("ListServiceByPopularity");
}
if ((string) $type == '0') {
$title = $langs->trans("ListProductByPopularity");
}
if ($type != '') $param .= '&type='.$type;
$h=0;
$head = array();
$head[$h][0] = $_SERVER['PHP_SELF'];
$head[$h][1] = $title;
$head[$h][2] = 'product';
$head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php?id=all';
$head[$h][1] = $langs->trans("Chart");
$head[$h][2] = 'chart';
$h++;
dol_fiche_head($head,'product',$langs->trans("Statistics"));
$head[$h][0] = $_SERVER['PHP_SELF'];
$head[$h][1] = $title;
$head[$h][2] = 'popularityprop';
$h++;
dol_fiche_head($head,'popularityprop',$langs->trans("Statistics"));
@ -127,15 +137,15 @@ if ($result)
$num = $db->num_rows($result);
$i = 0;
print_barre_liste($title, $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num, $totalnboflines, '');
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $totalnboflines, '');
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans('Ref'), $_SERVER["PHP_SELF"], 'p.ref', '', '', '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('Type'), $_SERVER["PHP_SELF"], 'p.type', '', '', '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('Label'), $_SERVER["PHP_SELF"], 'p.label', '', '', '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('NbOfProposals'), $_SERVER["PHP_SELF"], 'c', '', '', 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('Ref'), $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('Type'), $_SERVER["PHP_SELF"], 'p.fk_product_type', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('Label'), $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans('NbOfProposals'), $_SERVER["PHP_SELF"], 'c', '', $param, 'align="right"', $sortfield, $sortorder);
print "</tr>\n";

View File

@ -62,14 +62,38 @@ $form = new Form($db);
if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
{
$object = new Product($db);
if (! empty($id) || ! empty($ref))
if (GETPOST('id') == 'all')
{
$result = $object->fetch($id,$ref);
llxHeader("",$langs->trans("CardProduct".$object->type));
llxHeader("",$langs->trans("ProductStatistics"));
$type = GETPOST('type');
$helpurl='';
if ($type == '0')
{
$helpurl='EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
//$title=$langs->trans("StatisticsOfProducts");
$title=$langs->trans("Statistics");
}
else if ($type == '1')
{
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
//$title=$langs->trans("StatisticsOfServices");
$title=$langs->trans("Statistics");
}
else
{
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
//$title=$langs->trans("StatisticsOfProductsOrServices");
$title=$langs->trans("Statistics");
}
print load_fiche_titre($title, $mesg,'title_products.png');
}
else
{
llxHeader("",$langs->trans("ProductStatistics"));
$result = $object->fetch($id,$ref);
llxHeader("",$langs->trans("CardProduct".$object->type));
}
@ -85,14 +109,70 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
dol_fiche_end();
}
if ($result)
if (GETPOST('id') == 'all')
{
$h=0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php?id=all';
$head[$h][1] = $langs->trans("Chart");
$head[$h][2] = 'chart';
$h++;
$title = $langs->trans("ListProductServiceByPopularity");
if ((string) $type == '1') {
$title = $langs->trans("ListServiceByPopularity");
}
if ((string) $type == '0') {
$title = $langs->trans("ListProductByPopularity");
}
$head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != ''?'?type='.$type:'');
$head[$h][1] = $title;
$head[$h][2] = 'popularityprop';
$h++;
dol_fiche_head($head,'chart',$langs->trans("Statistics"));
}
if ($result || GETPOST('id') == 'all')
{
if (GETPOST('id') == 'all')
{
// Choice of type of product
if (! empty($conf->dol_use_jmobile)) print "\n".'<div class="fichecenter"><div class="nowrap">'."\n";
if ((string) $type != '0') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).'&type=0">';
else print img_picto('','tick').' ';
print $langs->trans("Products");
if ((string) $type != '0') print '</a>';
if (! empty($conf->dol_use_jmobile)) print '</div>'."\n".'<div class="nowrap">'."\n";
else print ' &nbsp; / &nbsp; ';
if ((string) $type != '1') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).'&type=1">';
else print img_picto('','tick').' ';
print $langs->trans("Services");
if ((string) $type != '1') print '</a>';
if (! empty($conf->dol_use_jmobile)) print '</div>'."\n".'<div class="nowrap">'."\n";
else print ' &nbsp; / &nbsp; ';
if ((string) $type == '0' || (string) $type == '1') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).'">';
else print img_picto('','tick').' ';
print $langs->trans("ProductsAndServices");
if ((string) $type == '0' || (string) $type == '1') print '</a>';
if (! empty($conf->dol_use_jmobile)) print '</div></div>';
else print '<br>';
print '<br>';
}
// Choice of stats
if (! empty($conf->dol_use_jmobile)) print "\n".'<div class="fichecenter"><div class="nowrap">'."\n";
if ($mode == 'bynumber') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).'&mode=byunit">';
if ($mode == 'bynumber') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).($type != '' ? '&type='.$type:'').'&mode=byunit">';
else print img_picto('','tick').' ';
print $langs->trans("StatsByNumberOfUnits");
if ($mode == 'bynumber') print '</a>';
@ -100,7 +180,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
if (! empty($conf->dol_use_jmobile)) print '</div>'."\n".'<div class="nowrap">'."\n";
else print ' &nbsp; / &nbsp; ';
if ($mode == 'byunit') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).'&mode=bynumber">';
if ($mode == 'byunit') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).($type != '' ? '&type='.$type:'').'&mode=bynumber">';
else print img_picto('','tick').' ';
print $langs->trans("StatsByNumberOfEntities");
if ($mode == 'byunit') print '</a>';
@ -255,10 +335,11 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
print "\n".'</div></div></div>';
print '<div class="clear"><div class="fichecenter"><br></div></div>'."\n";
}
print '<div class="tabsAction">';
print '</div>';
}
if (GETPOST('id') == 'all')
{
dol_fiche_end();
}
}
else