diff --git a/ChangeLog b/ChangeLog
index 44e0d349c39..2a6f3dc64f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -66,6 +66,7 @@ For developers:
- New: Removed artichow deprecated libraries.
- New: A page can force reload of css style sheet
- New: A module can add import description for import wizard, even for tables with foreign keys.
+- New: Can add tabs on statistics views.
- Qual: Add a lot of more PHPUnit tests.
- Qual: Data structure for supplier prices is simpler.
- Qual: Removed no more used external libraries.
diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php
index 8f590c64778..db16872b767 100644
--- a/htdocs/comm/propal/stats/index.php
+++ b/htdocs/comm/propal/stats/index.php
@@ -216,6 +216,8 @@ $head[$h][1] = $langs->trans("ByMonthYear");
$head[$h][2] = 'byyear';
$h++;
+complete_head_from_modules($conf,$langs,$object,$head,$h,'propal_stats');
+
dol_fiche_head($head,'byyear',$langs->trans("Statistics"));
diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php
index 73e14650a8c..fa1ff9f65a9 100644
--- a/htdocs/commande/stats/index.php
+++ b/htdocs/commande/stats/index.php
@@ -225,13 +225,19 @@ foreach($data as $val) {
}
if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
+
$h=0;
$head = array();
-$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php';
+$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php?mode='.$mode;
$head[$h][1] = $langs->trans("ByMonthYear");
$head[$h][2] = 'byyear';
$h++;
+if ($mode == 'customer') $type='order_stats';
+if ($mode == 'supplier') $type='supplier_order_stats';
+
+complete_head_from_modules($conf,$langs,$object,$head,$h,$type);
+
dol_fiche_head($head,'byyear',$langs->trans("Statistics"));
print '
';
diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php
index 54604b5c400..6a6a8d1016a 100755
--- a/htdocs/compta/deplacement/stats/index.php
+++ b/htdocs/compta/deplacement/stats/index.php
@@ -196,11 +196,13 @@ if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
$h=0;
$head = array();
-$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php';
+$head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/stats/index.php';
$head[$h][1] = $langs->trans("ByMonthYear");
$head[$h][2] = 'byyear';
$h++;
+complete_head_from_modules($conf,$langs,$object,$head,$h,'trip_stats');
+
dol_fiche_head($head,'byyear',$langs->trans("Statistics"));
print '';
diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php
index 8ad50193924..3092ad970f3 100644
--- a/htdocs/compta/facture/stats/index.php
+++ b/htdocs/compta/facture/stats/index.php
@@ -207,11 +207,16 @@ if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
$h=0;
$head = array();
-$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php';
+$head[$h][0] = DOL_URL_ROOT . '/compta/facture/stats/index.php?mode='.$mode;
$head[$h][1] = $langs->trans("ByMonthYear");
$head[$h][2] = 'byyear';
$h++;
+if ($mode == 'customer') $type='invoice_stats';
+if ($mode == 'supplier') $type='supplier_invoice_stats';
+
+complete_head_from_modules($conf,$langs,$object,$head,$h,$type);
+
dol_fiche_head($head,'byyear',$langs->trans("Statistics"));
print '';
diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php
index a179811b1fb..8d2ed89267d 100644
--- a/htdocs/compta/stats/index.php
+++ b/htdocs/compta/stats/index.php
@@ -26,7 +26,7 @@ require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/report.lib.php");
-$year_start=isset($_GET["year_start"])?$_GET["year_start"]:$_POST["year_start"];
+$year_start=GETPOST("year_start");
$year_current = strftime("%Y",time());
$nbofyear=4;
if (! $year_start) {
diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php
index 590231c9003..d42b1892dc4 100644
--- a/htdocs/expedition/stats/index.php
+++ b/htdocs/expedition/stats/index.php
@@ -37,15 +37,17 @@ llxHeader();
print_fiche_titre($langs->trans("StatisticsOfSendings"), $mesg);
+// TODO USe code similar to commande/stats/index.php instead of this one.
+
print '';
print '| '.$langs->trans("Year").' | ';
print ''.$langs->trans("NbOfSendings").' |
';
-$sql = "SELECT count(*), date_format(date_expedition,'%Y') as dm";
+$sql = "SELECT count(*) as nb, date_format(date_expedition,'%Y') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE fk_statut > 0";
$sql.= " AND entity = ".$conf->entity;
-$sql.= " GROUP BY dm DESC ";
+$sql.= " GROUP BY dm DESC";
$resql=$db->query($sql);
if ($resql)
@@ -62,7 +64,7 @@ if ($resql)
$i++;
}
}
-$db->free();
+$db->free($resql);
print '
';
print '
';