diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 099d65f7f95..6d31fbc52f6 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -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); } } diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index c8da665dd98..aad606627cb 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -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ó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ó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 ''; print ""; - 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 "\n"; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 4203705cfee..33390e51a70 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -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ódulo_Productos'; + //$title=$langs->trans("StatisticsOfProducts"); + $title=$langs->trans("Statistics"); + } + else if ($type == '1') + { + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfServices"); + $title=$langs->trans("Statistics"); + } + else + { + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Mó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".'
'."\n"; + + if ((string) $type != '0') print 'id).'&type=0">'; + else print img_picto('','tick').' '; + print $langs->trans("Products"); + if ((string) $type != '0') print ''; + + if (! empty($conf->dol_use_jmobile)) print '
'."\n".'
'."\n"; + else print '   /   '; + + if ((string) $type != '1') print 'id).'&type=1">'; + else print img_picto('','tick').' '; + print $langs->trans("Services"); + if ((string) $type != '1') print ''; + + if (! empty($conf->dol_use_jmobile)) print '
'."\n".'
'."\n"; + else print '   /   '; + + if ((string) $type == '0' || (string) $type == '1') print 'id).'">'; + else print img_picto('','tick').' '; + print $langs->trans("ProductsAndServices"); + if ((string) $type == '0' || (string) $type == '1') print ''; + + if (! empty($conf->dol_use_jmobile)) print '
'; + else print '
'; + print '
'; + } + // Choice of stats if (! empty($conf->dol_use_jmobile)) print "\n".'
'."\n"; - if ($mode == 'bynumber') print 'id).'&mode=byunit">'; + if ($mode == 'bynumber') print 'id).($type != '' ? '&type='.$type:'').'&mode=byunit">'; else print img_picto('','tick').' '; print $langs->trans("StatsByNumberOfUnits"); if ($mode == 'bynumber') print ''; @@ -100,7 +180,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') if (! empty($conf->dol_use_jmobile)) print '
'."\n".'
'."\n"; else print '   /   '; - if ($mode == 'byunit') print 'id).'&mode=bynumber">'; + if ($mode == 'byunit') print 'id).($type != '' ? '&type='.$type:'').'&mode=bynumber">'; else print img_picto('','tick').' '; print $langs->trans("StatsByNumberOfEntities"); if ($mode == 'byunit') print ''; @@ -255,10 +335,11 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') print "\n".'
'; print '

'."\n"; } - - print '
'; - print '
'; - + } + + if (GETPOST('id') == 'all') + { + dol_fiche_end(); } } else