diff --git a/ChangeLog b/ChangeLog
index c871d62e7bce097e390555f65f5b746439828645..6e17bee2e3975ee4f78ef439824fd7c69222d1aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -54,7 +54,7 @@ For users:
        or credit note invoice.
 - New: task #10885: Add a week view for calendar.
 - New: task #11018: Add a status "not applicable" on events.
-- New: Add country/region/town statistics for member module.
+- New: Add subscriptions/country/region/town statistics for member module.
 - New: Can define a proxy for external web access.
 - New: task #11003: checkbox on checks for deposit.
 - New: Add status into export. Add default language into export.
diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php
new file mode 100755
index 0000000000000000000000000000000000000000..81d77d1f2c9229e920055c0b12d8277881817274
--- /dev/null
+++ b/htdocs/adherents/class/adherentstats.class.php
@@ -0,0 +1,175 @@
+<?php
+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (c) 2005-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2009 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ *	\file       htdocs/adherents/class/adherentstats.class.php
+ *	\ingroup    member
+ *	\brief      Fichier de la classe de gestion des stats des adhérents
+ *	\version    $Id$
+ */
+
+include_once DOL_DOCUMENT_ROOT . "/core/class/stats.class.php";
+include_once DOL_DOCUMENT_ROOT . "/adherents/class/cotisation.class.php";
+
+
+/**
+ *	\class      AdherentStats
+ *	\brief      Classe permettant la gestion des stats des adherents
+ */
+class AdherentStats extends Stats
+{
+	var $db;
+
+    var $socid;
+    var $userid;
+
+    var $table_element;
+    var $from;
+    var $field;
+    var $where;
+
+
+	/**
+	 * Constructor
+	 *
+	 * @param 	$DB		   Database handler
+	 * @param 	$socid	   Id third party
+     * @param   $userid    Id user for filter
+	 * @return 	AdherentStats
+	 */
+	function AdherentStats($DB, $socid=0, $userid=0)
+	{
+		global $user, $conf;
+
+		$this->db = $DB;
+        $this->socid = $socid;
+        $this->userid = $userid;
+
+		$object=new Cotisation($this->db);
+
+		$this->from = MAIN_DB_PREFIX.$object->table_element." as p";
+		$this->from.= ", ".MAIN_DB_PREFIX."adherent as m";
+
+		$this->field='cotisation';
+
+		$this->where.= " m.statut != 0";
+		$this->where.= " AND p.fk_adherent = m.rowid AND m.entity = ".$conf->entity;
+		//if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
+		if($this->memberid)
+		{
+			$this->where .= " AND m.rowid = ".$this->memberid;
+		}
+        //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid;
+	}
+
+
+	/**
+	 * Renvoie le nombre de proposition par mois pour une annee donnee
+	 */
+	function getNbByMonth($year)
+	{
+		global $user;
+
+		$sql = "SELECT date_format(p.dateadh,'%m') as dm, count(*)";
+		$sql.= " FROM ".$this->from;
+		//if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE date_format(p.dateadh,'%Y') = ".$year;
+		$sql.= " AND ".$this->where;
+		$sql.= " GROUP BY dm";
+        $sql.= $this->db->order('dm','DESC');
+
+		return $this->_getNbByMonth($year, $sql);
+	}
+
+	/**
+	 * Renvoie le nombre de cotisation par annee
+	 *
+	 */
+	function getNbByYear()
+	{
+		global $user;
+
+		$sql = "SELECT date_format(p.dateadh,'%Y') as dm, count(*)";
+		$sql.= " FROM ".$this->from;
+		//if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE ".$this->where;
+		$sql.= " GROUP BY dm";
+        $sql.= $this->db->order('dm','DESC');
+
+		return $this->_getNbByYear($sql);
+	}
+	/**
+	 * Renvoie le nombre de cotisation par mois pour une annee donnee
+	 *
+	 */
+	function getAmountByMonth($year)
+	{
+		global $user;
+
+		$sql = "SELECT date_format(p.dateadh,'%m') as dm, sum(p.".$this->field.")";
+		$sql.= " FROM ".$this->from;
+		//if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE date_format(p.dateadh,'%Y') = ".$year;
+		$sql.= " AND ".$this->where;
+		$sql.= " GROUP BY dm";
+        $sql.= $this->db->order('dm','DESC');
+
+		return $this->_getAmountByMonth($year, $sql);
+	}
+	/**
+	 *
+	 *
+	 */
+	function getAverageByMonth($year)
+	{
+		global $user;
+
+		$sql = "SELECT date_format(p.dateadh,'%m') as dm, avg(p.".$this->field.")";
+		$sql.= " FROM ".$this->from;
+		//if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE date_format(p.dateadh,'%Y') = ".$year;
+		$sql.= " AND ".$this->where;
+		$sql.= " GROUP BY dm";
+        $sql.= $this->db->order('dm','DESC');
+
+		return $this->_getAverageByMonth($year, $sql);
+	}
+
+
+	/**
+	 *	\brief	Return nb, total and average
+	 *	\return	array	Array of values
+	 */
+	function getAllByYear()
+	{
+		global $user;
+
+		$sql = "SELECT date_format(p.dateadh,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
+		$sql.= " FROM ".$this->from;
+		//if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE ".$this->where;
+		$sql.= " GROUP BY year";
+        $sql.= $this->db->order('year','DESC');
+
+		return $this->_getAllByYear($sql);
+	}
+
+}
+?>
diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php
new file mode 100755
index 0000000000000000000000000000000000000000..25f9abcbd0215017c7011451c2d7e9e8170e9816
--- /dev/null
+++ b/htdocs/adherents/stats/geo.php
@@ -0,0 +1,280 @@
+<?php
+/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (c) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ *	    \file       htdocs/adherents/stats/index.php
+ *      \ingroup    member
+ *		\brief      Page des stats
+ *		\version    $Id$
+*/
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php");
+
+$graphwidth = 700;
+$mapratio = 0.5;
+$graphheight = round($graphwidth * $mapratio);
+
+$mode=GETPOST('mode')?GETPOST('mode'):'';
+
+
+// Security check
+if ($user->societe_id > 0)
+{
+  $action = '';
+  $socid = $user->societe_id;
+}
+if (! $user->rights->adherent->cotisation->lire)
+accessforbidden();
+
+$year = strftime("%Y", time());
+$startyear=$year-2;
+$endyear=$year;
+
+
+
+/*
+ * View
+ */
+
+
+llxHeader('','','','',0,0,array('http://www.google.com/jsapi'));
+
+$title=$langs->trans("Statistics");
+if ($mode == 'memberbycountry') $title=$langs->trans("MembersStatisticsByCountries");
+if ($mode == 'memberbystate') $title=$langs->trans("MembersStatisticsByState");
+if ($mode == 'memberbytown') $title=$langs->trans("MembersStatisticsByTown");
+
+print_fiche_titre($title, $mesg);
+
+create_exdir($dir);
+
+if ($mode)
+{
+	// Define sql
+	if ($mode == 'memberbycountry')
+	{
+		$label=$langs->trans("Country");
+        $tab='statscountry';
+
+		$data = array();
+		$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.libelle as label";
+		$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_pays as c on d.pays = c.rowid";
+		$sql.=" WHERE d.statut = 1";
+		$sql.=" GROUP BY c.libelle, c.code";
+		//print $sql;
+	}
+	if ($mode == 'memberbystate')
+	{
+        $label=$langs->trans("Country");
+	    $label2=$langs->trans("State");
+        $tab='statsstate';
+
+		$data = array();
+		$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, c.nom as label2";
+		$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.fk_departement = c.rowid";
+        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
+        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.pays = p.rowid";
+        $sql.=" WHERE d.statut = 1";
+		$sql.=" GROUP BY p.libelle, p.code, c.nom";
+		//print $sql;
+	}
+    if ($mode == 'memberbytown')
+    {
+        $label=$langs->trans("Country");
+        $label2=$langs->trans("Town");
+        $tab='statstown';
+
+        $data = array();
+        $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, d.ville as label2";
+        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
+        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.pays = p.rowid";
+        $sql.=" WHERE d.statut = 1";
+        $sql.=" GROUP BY p.libelle, p.code, d.ville";
+        //print $sql;
+    }
+
+	$langsen=new Translate('',$conf);
+    $langsen->setDefaultLang('en_US');
+    $langsen->load("dict");
+    //print $langsen->trans("Country"."FI");exit;
+
+	// Define $data array
+	dol_syslog("Count member sql=".$sql);
+	$resql=$db->query($sql);
+	if ($resql)
+	{
+		$num=$db->num_rows($resql);
+		$i=0;
+		while ($i < $num)
+		{
+			$obj=$db->fetch_object($resql);
+			if ($mode == 'memberbycountry')
+			{
+				$data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+							'code'=>$obj->code,
+							'nb'=>$obj->nb,
+							'lastdate'=>$db->jdate($obj->lastdate)
+				);
+			}
+			if ($mode == 'memberbystate')
+			{
+				$data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+				            'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
+							'nb'=>$obj->nb,
+							'lastdate'=>$db->jdate($obj->lastdate)
+				);
+			}
+            if ($mode == 'memberbytown')
+            {
+                $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+                            'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
+                            'nb'=>$obj->nb,
+                            'lastdate'=>$db->jdate($obj->lastdate)
+                );
+            }
+
+			$i++;
+		}
+		$db->free($resql);
+	}
+	else
+	{
+		dol_print_error($db);
+	}
+}
+
+
+$head = member_stats_prepare_head($adh);
+
+dol_fiche_head($head, $tab, $langs->trans("Statistics"), 0, 'user');
+
+
+// Print title
+if ($mode && ! sizeof($data))
+{
+	print $langs->trans("NoValidatedMemberYet").'<br>';
+	print '<br>';
+}
+else
+{
+	if ($mode == 'memberbycountry') print $langs->trans("MembersByCountryDesc").'<br>';
+	else if ($mode == 'memberbystate') print $langs->trans("MembersByStateDesc").'<br>';
+    else if ($mode == 'memberbytown') print $langs->trans("MembersByTownDesc").'<br>';
+	else
+	{
+		print $langs->trans("MembersStatisticsDesc").'<br>';
+		print '<br>';
+		print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbycountry">'.$langs->trans("MembersStatisticsByCountries").'</a><br>';
+		print '<br>';
+		print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbystate">'.$langs->trans("MembersStatisticsByState").'</a><br>';
+        print '<br>';
+        print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbytown">'.$langs->trans("MembersStatisticsByTown").'</a><br>';
+	}
+	print '<br>';
+}
+
+
+// Show graphics
+if ($mode == 'memberbycountry')
+{
+	// Assume we've already included the proper headers so just call our script inline
+	print "\n<script type='text/javascript'>\n";
+	print "google.load('visualization', '1', {'packages': ['geomap']});\n";
+	print "google.setOnLoadCallback(drawMap);\n";
+	print "function drawMap() {\n\tvar data = new google.visualization.DataTable();\n";
+
+	// Get the total number of rows
+	print "\tdata.addRows(".sizeof($data).");\n";
+	print "\tdata.addColumn('string', 'Country');\n";
+	print "\tdata.addColumn('number', 'Number');\n";
+
+	// loop and dump
+	$i=0;
+	foreach($data as $val)
+	{
+	    //$valcountry=ucfirst($val['code']);
+	    $valcountry=ucfirst($val['label_en']);
+        // fix case of uk
+	    if ($valcountry == 'Great Britain') { $valcountry = 'United Kingdom'; }
+	    print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n";
+	    print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n";
+	    // Google's Geomap only supports up to 400 entries
+	    if ($i >= 400){ break; }
+		$i++;
+	}
+
+	print "\tvar options = {};\n";
+    print "\toptions['dataMode'] = 'regions';\n";
+    print "\toptions['showZoomOut'] = false;\n";
+    //print "\toptions['zoomOutLabel'] = '".dol_escape_js($langs->transnoentitiesnoconv("Numbers"))."';\n";
+	print "\toptions['width'] = ".$graphwidth.";\n";
+	print "\toptions['height'] = ".$graphheight.";\n";
+	print "\tvar container = document.getElementById('".$mode."');\n";
+	print "\tvar geomap = new google.visualization.GeoMap(container);\n";
+	print "\tgeomap.draw(data, options);\n";
+	print "};\n";
+	print "</script>\n";
+
+	// print the div tag that will contain the map
+	print '<div align="center" id="'.$mode.'"></div>'."\n";
+	print '<br>';
+}
+
+if ($mode)
+{
+	// Print array
+	print '<table class="border" width="100%">';
+	print '<tr class="liste_titre">';
+	print '<td align="center">'.$label.'</td>';
+    if ($label2) print '<td align="center">'.$label2.'</td>';
+	print '<td align="center">'.$langs->trans("NbOfMembers").'</td>';
+	print '<td align="center">'.$langs->trans("LastMemberDate").'</td>';
+	print '</tr>';
+
+	$oldyear=0;
+	$var=true;
+	foreach ($data as $val)
+	{
+		$year = $val['year'];
+		$var=!$var;
+		print '<tr '.$bc[$var].'>';
+	    print '<td align="center">'.$val['label'].'</td>';
+        if ($label2) print '<td align="center">'.$val['label2'].'</td>';
+	    print '<td align="right">'.$val['nb'].'</td>';
+		print '<td align="right">'.dol_print_date($val['lastdate'],'dayhour').'</td>';
+		print '</tr>';
+		$oldyear=$year;
+	}
+
+	print '</table>';
+}
+
+
+dol_fiche_end();
+
+
+$db->close();
+
+llxFooter('$Date$ - $Revision$');
+?>
diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php
index 722b42f9412e4812354b157c925128d1d240d56a..ea49d7d16029e7cfc6a5702a898fb762d38defc8 100644
--- a/htdocs/adherents/stats/index.php
+++ b/htdocs/adherents/stats/index.php
@@ -1,6 +1,7 @@
 <?php
-/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (c) 2004-2009 Laurent Destailleur  <eldy@users.sourceforge.net>
+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2009 Regis Houssin        <regis@dolibarr.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,247 +21,210 @@
 /**
  *	    \file       htdocs/adherents/stats/index.php
  *      \ingroup    member
- *		\brief      Page des stats
+ *		\brief      Page of subscription members statistics
  *		\version    $Id$
-*/
+ */
 
 require("../../main.inc.php");
-require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
-require_once(DOL_DOCUMENT_ROOT."/commande/class/commandestats.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherentstats.class.php");
 require_once(DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php");
 
-$graphwidth = 700;
-$mapratio = 0.5;
-$graphheight = round($graphwidth * $mapratio);
-
-$mode=GETPOST('mode')?GETPOST('mode'):'';
-
+$WIDTH=500;
+$HEIGHT=200;
 
+$userid=GETPOST('userid'); if ($userid < 0) $userid=0;
+$socid=GETPOST('socid'); if ($socid < 0) $socid=0;
 // Security check
 if ($user->societe_id > 0)
 {
-  $action = '';
-  $socid = $user->societe_id;
+    $action = '';
+    $socid = $user->societe_id;
 }
-if (! $user->rights->adherent->cotisation->lire)
-accessforbidden();
 
 $year = strftime("%Y", time());
 $startyear=$year-2;
 $endyear=$year;
 
 
-
 /*
  * View
  */
 
+$form=new Form($db);
 
-llxHeader('','','','',0,0,array('http://www.google.com/jsapi'));
+$langs->load("propal");
 
-$title=$langs->trans("Statistics");
-if ($mode == 'memberbycountry') $title=$langs->trans("MembersStatisticsByCountries");
-if ($mode == 'memberbystate') $title=$langs->trans("MembersStatisticsByState");
-if ($mode == 'memberbytown') $title=$langs->trans("MembersStatisticsByTown");
+llxHeader();
 
-print_fiche_titre($title, $mesg);
+print_fiche_titre($langs->trans("SubscriptionsStatistics"), $mesg);
+
+$dir=$conf->adherent->dir_temp;
 
 create_exdir($dir);
 
-if ($mode)
+$stats = new AdherentStats($db, $socid, $userid);
+
+// Build graphic number of object
+$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
+//var_dump($data);
+// $data = array(array('Lib',val1,val2,val3),...)
+
+
+$filenamenb = $dir.'/subscriptionsnbinyear-'.$year.'.png';
+$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscriptionsnbinyear-'.$year.'.png';
+
+
+$px = new DolGraph();
+$mesg = $px->isGraphKo();
+if (! $mesg)
 {
-	// Define sql
-	if ($mode == 'memberbycountry')
-	{
-		$label=$langs->trans("Country");
-
-		$data = array();
-		$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.libelle as label";
-		$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_pays as c on d.pays = c.rowid";
-		$sql.=" WHERE d.statut = 1";
-		$sql.=" GROUP BY c.libelle, c.code";
-		//print $sql;
-	}
-	if ($mode == 'memberbystate')
-	{
-        $label=$langs->trans("Country");
-	    $label2=$langs->trans("State");
-
-		$data = array();
-		$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, c.nom as label2";
-		$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.fk_departement = c.rowid";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.pays = p.rowid";
-        $sql.=" WHERE d.statut = 1";
-		$sql.=" GROUP BY p.libelle, p.code, c.nom";
-		//print $sql;
-	}
-    if ($mode == 'memberbytown')
+    $px->SetData($data);
+    $px->SetPrecisionY(0);
+    $i=$startyear;
+    while ($i <= $endyear)
     {
-        $label=$langs->trans("Country");
-        $label2=$langs->trans("Town");
-
-        $data = array();
-        $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, d.ville as label2";
-        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.pays = p.rowid";
-        $sql.=" WHERE d.statut = 1";
-        $sql.=" GROUP BY p.libelle, p.code, d.ville";
-        //print $sql;
+        $legend[]=$i;
+        $i++;
     }
-
-	$langsen=new Translate('',$conf);
-    $langsen->setDefaultLang('en_US');
-    $langsen->load("dict");
-    //print $langsen->trans("Country"."FI");exit;
-
-	// Define $data array
-	dol_syslog("Count member sql=".$sql);
-	$resql=$db->query($sql);
-	if ($resql)
-	{
-		$num=$db->num_rows($resql);
-		$i=0;
-		while ($i < $num)
-		{
-			$obj=$db->fetch_object($resql);
-			if ($mode == 'memberbycountry')
-			{
-				$data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-							'code'=>$obj->code,
-							'nb'=>$obj->nb,
-							'lastdate'=>$db->jdate($obj->lastdate)
-				);
-			}
-			if ($mode == 'memberbystate')
-			{
-				$data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-				            'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
-							'nb'=>$obj->nb,
-							'lastdate'=>$db->jdate($obj->lastdate)
-				);
-			}
-            if ($mode == 'memberbytown')
-            {
-                $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
-                            'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
-                            'nb'=>$obj->nb,
-                            'lastdate'=>$db->jdate($obj->lastdate)
-                );
-            }
-
-			$i++;
-		}
-		$db->free($resql);
-	}
-	else
-	{
-		dol_print_error($db);
-	}
+    $px->SetLegend($legend);
+    $px->SetMaxValue($px->GetCeilMaxValue());
+    $px->SetMinValue(min(0,$px->GetFloorMinValue()));
+    $px->SetWidth($WIDTH);
+    $px->SetHeight($HEIGHT);
+    $px->SetYLabel($langs->trans("NbOfSubscriptions"));
+    $px->SetShading(3);
+    $px->SetHorizTickIncrement(1);
+    $px->SetPrecisionY(0);
+    $px->mode='depth';
+    $px->SetTitle($langs->trans("NbOfSubscriptions"));
+
+    $px->draw($filenamenb);
 }
 
-// Print title
-if ($mode && ! sizeof($data))
-{
-	print $langs->trans("NoValidatedMemberYet").'<br>';
-	print '<br>';
-}
-else
+// Build graphic amount of object
+$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
+//var_dump($data);
+// $data = array(array('Lib',val1,val2,val3),...)
+
+$filenameamount = $dir.'/subscriptionsamountinyear-'.$year.'.png';
+$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscriptionsamountinyear-'.$year.'.png';
+
+$px = new DolGraph();
+$mesg = $px->isGraphKo();
+if (! $mesg)
 {
-	if ($mode == 'memberbycountry') print $langs->trans("MembersByCountryDesc").'<br>';
-	else if ($mode == 'memberbystate') print $langs->trans("MembersByStateDesc").'<br>';
-    else if ($mode == 'memberbytown') print $langs->trans("MembersByTownDesc").'<br>';
-	else
-	{
-		print $langs->trans("MembersStatisticsDesc").'<br>';
-		print '<br>';
-		print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbycountry">'.$langs->trans("MembersStatisticsByCountries").'</a><br>';
-		print '<br>';
-		print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbystate">'.$langs->trans("MembersStatisticsByState").'</a><br>';
-        print '<br>';
-        print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbytown">'.$langs->trans("MembersStatisticsByTown").'</a><br>';
-	}
-	print '<br>';
+    $px->SetData($data);
+    $px->SetPrecisionY(0);
+    $i=$startyear;
+    while ($i <= $endyear)
+    {
+        $legend[]=$i;
+        $i++;
+    }
+    $px->SetLegend($legend);
+    $px->SetMaxValue($px->GetCeilMaxValue());
+    $px->SetMinValue(min(0,$px->GetFloorMinValue()));
+    $px->SetWidth($WIDTH);
+    $px->SetHeight($HEIGHT);
+    $px->SetYLabel($langs->trans("AmountOfSubscriptions"));
+    $px->SetShading(3);
+    $px->SetHorizTickIncrement(1);
+    $px->SetPrecisionY(0);
+    $px->mode='depth';
+    $px->SetTitle($langs->trans("AmountOfSubscriptions"));
+
+    $px->draw($filenameamount);
 }
 
 
-// Show graphics
-if ($mode == 'memberbycountry')
+$head = member_stats_prepare_head($adh);
+
+dol_fiche_head($head, 'statssubscription', $langs->trans("Statistics"), 0, 'user');
+
+
+print '<table class="notopnoleftnopadd" width="100%"><tr>';
+print '<td align="center" valign="top">';
+
+// Show filter box
+/*print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
+print '<table class="border" width="100%">';
+print '<tr><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
+print '<tr><td>'.$langs->trans("Member").'</td><td>';
+$filter='s.client in (1,2,3)';
+print $form->select_company($id,'memberid',$filter,1);
+print '</td></tr>';
+print '<tr><td>'.$langs->trans("User").'</td><td>';
+print $form->select_users($userid,'userid',1);
+print '</td></tr>';
+print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
+print '</table>';
+print '</form>';
+print '<br><br>';
+*/
+
+// Show array
+$data = $stats->getAllByYear();
+
+print '<table class="border" width="100%">';
+print '<tr height="24">';
+print '<td align="center">'.$langs->trans("Year").'</td>';
+print '<td align="center">'.$langs->trans("NbOfSubscriptions").'</td>';
+print '<td align="center">'.$langs->trans("AmountTotal").'</td>';
+print '<td align="center">'.$langs->trans("AmountAverage").'</td>';
+print '</tr>';
+
+$oldyear=0;
+foreach ($data as $val)
 {
-	// Assume we've already included the proper headers so just call our script inline
-	print "\n<script type='text/javascript'>\n";
-	print "google.load('visualization', '1', {'packages': ['geomap']});\n";
-	print "google.setOnLoadCallback(drawMap);\n";
-	print "function drawMap() {\n\tvar data = new google.visualization.DataTable();\n";
-
-	// Get the total number of rows
-	print "\tdata.addRows(".sizeof($data).");\n";
-	print "\tdata.addColumn('string', 'Country');\n";
-	print "\tdata.addColumn('number', 'Number');\n";
-
-	// loop and dump
-	$i=0;
-	foreach($data as $val)
-	{
-	    //$valcountry=ucfirst($val['code']);
-	    $valcountry=ucfirst($val['label_en']);
-        // fix case of uk
-	    if ($valcountry == 'Great Britain') { $valcountry = 'United Kingdom'; }
-	    print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n";
-	    print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n";
-	    // Google's Geomap only supports up to 400 entries
-	    if ($i >= 400){ break; }
-		$i++;
-	}
-
-	print "\tvar options = {};\n";
-    print "\toptions['dataMode'] = 'regions';\n";
-    print "\toptions['showZoomOut'] = false;\n";
-    //print "\toptions['zoomOutLabel'] = '".dol_escape_js($langs->transnoentitiesnoconv("Numbers"))."';\n";
-	print "\toptions['width'] = ".$graphwidth.";\n";
-	print "\toptions['height'] = ".$graphheight.";\n";
-	print "\tvar container = document.getElementById('".$mode."');\n";
-	print "\tvar geomap = new google.visualization.GeoMap(container);\n";
-	print "\tgeomap.draw(data, options);\n";
-	print "};\n";
-	print "</script>\n";
-
-	// print the div tag that will contain the map
-	print '<div align="center" id="'.$mode.'"></div>'."\n";
-	print '<br>';
+    $year = $val['year'];
+    print $avg;
+    while ($oldyear > $year+1)
+    {	// If we have empty year
+        $oldyear--;
+        print '<tr height="24">';
+        print '<td align="center">';
+        print '<a href="month.php?year='.$oldyear.'&amp;mode='.$mode.'">';
+        print $oldyear;
+        print '</a>';
+        print '</td>';
+        print '<td align="right">0</td>';
+        print '<td align="right">0</td>';
+        print '<td align="right">0</td>';
+        print '</tr>';
+    }
+    print '<tr height="24">';
+    print '<td align="center">';
+    //print '<a href="month.php?year='.$year.'">';
+    print $year;
+    //print '</a>';
+    print '</td>';
+    print '<td align="right">'.$val['nb'].'</td>';
+    print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
+    print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';
+    print '</tr>';
+    $oldyear=$year;
 }
 
-if ($mode)
-{
-	// Print array
-	print '<table class="border" width="100%">';
-	print '<tr class="liste_titre">';
-	print '<td align="center">'.$label.'</td>';
-    if ($label2) print '<td align="center">'.$label2.'</td>';
-	print '<td align="center">'.$langs->trans("NbOfMembers").'</td>';
-	print '<td align="center">'.$langs->trans("LastMemberDate").'</td>';
-	print '</tr>';
-
-	$oldyear=0;
-	$var=true;
-	foreach ($data as $val)
-	{
-		$year = $val['year'];
-		$var=!$var;
-		print '<tr '.$bc[$var].'>';
-	    print '<td align="center">'.$val['label'].'</td>';
-        if ($label2) print '<td align="center">'.$val['label2'].'</td>';
-	    print '<td align="right">'.$val['nb'].'</td>';
-		print '<td align="right">'.dol_print_date($val['lastdate'],'dayhour').'</td>';
-		print '</tr>';
-		$oldyear=$year;
-	}
-
-	print '</table>';
+print '</table>';
+
+
+print '</td>';
+print '<td align="center" valign="top">';
+
+// Show graphs
+print '<table class="border" width="100%"><tr valign="top"><td align="center">';
+if ($mesg) { print $mesg; }
+else {
+    print '<img src="'.$fileurlnb.'" title="'.$langs->trans("NbOfSubscriptions").'" alt="'.$langs->trans("NbOfSubscriptions").'">';
+    print "<br>\n";
+    print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountTotal").'" alt="'.$langs->trans("AmountTotal").'">';
 }
+print '</td></tr></table>';
+
+print '</td></tr></table>';
+
+dol_fiche_end();
 
 $db->close();
 
diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php
index a08ec4ed2ab941895f10bd5c06337eff93784be8..c42adaf7c179bc9eb3450e0394289476b1a85a38 100644
--- a/htdocs/core/class/stats.class.php
+++ b/htdocs/core/class/stats.class.php
@@ -228,6 +228,7 @@ class Stats
 		$result = array();
 
 		dol_syslog("Stats::_getAmountByMonth sql=".$sql);
+
 		$resql=$this->db->query($sql);
 		if ($resql)
 		{
@@ -242,6 +243,7 @@ class Stats
 		  	}
 		  	$this->db->free($resql);
 		}
+        else dol_print_error($this->db);
 
 		for ($i = 1 ; $i < 13 ; $i++)
 		{
@@ -284,6 +286,7 @@ class Stats
 		  	}
 		  	$this->db->free($resql);
 		}
+        else dol_print_error($this->db);
 
 		for ($i = 1 ; $i < 13 ; $i++)
 		{
diff --git a/htdocs/includes/modules/modAdherent.class.php b/htdocs/includes/modules/modAdherent.class.php
index 2728ed77e733f21c22ece8c75c643e5a550b04bd..5cee76706be2b72a0a7b68f7d595d027a3e45b93 100644
--- a/htdocs/includes/modules/modAdherent.class.php
+++ b/htdocs/includes/modules/modAdherent.class.php
@@ -60,7 +60,7 @@ class modAdherent extends DolibarrModules
         $this->picto='user';
 
         // Data directories to create when module is enabled
-        $this->dirs = array("/adherents/temp");
+        $this->dirs = array("/adherent/temp");
 
         // Config pages
         //-------------
diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang
index a871519047e689f16eda917903b890fa25e1087c..cf0bb020a66e3667b646eed6947db29832c4df8d 100644
--- a/htdocs/langs/en_US/members.lang
+++ b/htdocs/langs/en_US/members.lang
@@ -178,4 +178,7 @@ Nature=Nature
 Public=Public
 Exports=Exports
 NewMemberbyWeb=New member added. Awaiting approval
-NewMemberForm=New member form
\ No newline at end of file
+NewMemberForm=New member form
+SubscriptionsStatistics=Statistics on subscriptions
+NbOfSubscriptions=Number of subscriptions
+AmountOfSubscriptions=Amount of subscriptions
diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang
index 6d4ee221c20a3630eb90b213b7aff3f5df918122..75a4406ea454748ef6339339f0637575fb68499d 100644
--- a/htdocs/langs/fr_FR/members.lang
+++ b/htdocs/langs/fr_FR/members.lang
@@ -179,4 +179,7 @@ Nature=Nature
 Public=Public
 Exports=Exports
 NewMemberbyWeb=Nouvel Adherent ajoute. En attente de validation
-NewMemberForm=Nouvel Adherent form
\ No newline at end of file
+NewMemberForm=Nouvel Adherent form
+SubscriptionsStatistics=Statistiques sur les cotisations
+NbOfSubscriptions=Nombre de cotisations
+AmountOfSubscriptions=Montant de cotisations
\ No newline at end of file
diff --git a/htdocs/lib/member.lib.php b/htdocs/lib/member.lib.php
index cefaf794f5742738df4aaed3467ce24bd0cb0493..df1310ef34e8a4d937b1f8d764f1df3265260332 100644
--- a/htdocs/lib/member.lib.php
+++ b/htdocs/lib/member.lib.php
@@ -25,6 +25,11 @@
  *		Ensemble de fonctions de base de dolibarr sous forme d'include
  */
 
+/**
+ *  Return array head with list of tabs to view object informations
+ *  @param      object          Member
+ *  @return     array           head
+ */
 function member_prepare_head($object)
 {
 	global $langs, $conf, $user;
@@ -88,4 +93,46 @@ function member_prepare_head($object)
 	return $head;
 }
 
+
+
+/**
+ *  Return array head with list of tabs to view object stats informations
+ *  @param      object          Member
+ *  @return     array           head
+ */
+function member_stats_prepare_head($object)
+{
+    global $langs, $conf, $user;
+
+    $h = 0;
+    $head = array();
+
+    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
+    $head[$h][1] = $langs->trans("Subscriptions");
+    $head[$h][2] = 'statssubscription';
+    $h++;
+
+    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
+    $head[$h][1] = $langs->trans("Country");
+    $head[$h][2] = 'statscountry';
+    $h++;
+
+    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
+    $head[$h][1] = $langs->trans("State");
+    $head[$h][2] = 'statsstate';
+    $h++;
+
+    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
+    $head[$h][1] = $langs->trans('Town');
+    $head[$h][2] = 'statstown';
+    $h++;
+
+    // Show more tabs from modules
+    // Entries must be declared in modules descriptor with line
+    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats');
+
+    return $head;
+}
 ?>
\ No newline at end of file
diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php
index 72f4bbf260e16ea0a2eabff8ec4e57c4e18c4294..f4c04f2bc219f18ac8763bfa1d4559119d943ef7 100644
--- a/htdocs/viewimage.php
+++ b/htdocs/viewimage.php
@@ -228,6 +228,16 @@ if ($modulepart)
         $original_file=$conf->deplacement->dir_temp.'/'.$original_file;
     }
 
+    // Wrapping pour les images des stats expeditions
+    elseif ($modulepart == 'memberstats')
+    {
+        if ($user->rights->adherent->lire)
+        {
+            $accessallowed=1;
+        }
+        $original_file=$conf->adherent->dir_temp.'/'.$original_file;
+    }
+
     // Wrapping pour les images des stats produits
     elseif (preg_match('/^productstats_/i',$modulepart))
     {