diff --git a/htdocs/comm/propal/stats/propalestats.class.php b/htdocs/comm/propal/stats/propalestats.class.php
index 717e8d5c3a6dffededda009f43d9590862052fff..0ab2f60ce319270a8992f70fc22a0d9d3874aee2 100644
--- a/htdocs/comm/propal/stats/propalestats.class.php
+++ b/htdocs/comm/propal/stats/propalestats.class.php
@@ -80,14 +80,10 @@ class PropaleStats extends Stats
 
 		$sql = "SELECT date_format(p.datep,'%m') as dm, count(*)";
 		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
-		$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
+		$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
 		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-		$sql .= " WHERE date_format(p.datep,'%Y') = $year AND p.fk_statut > 0";
-		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
-		if($user->societe_id)
-		{
-			$sql .= " AND p.fk_soc = ".$user->societe_id;
-		}
+		$sql .= " WHERE date_format(p.datep,'%Y') = ".$year;
+		$sql.= " AND ".$this->where;
 		$sql .= " GROUP BY dm DESC";
 
 		return $this->_getNbByMonth($year, $sql);
@@ -103,15 +99,10 @@ class PropaleStats extends Stats
 		 
 		$sql = "SELECT date_format(p.datep,'%Y') as dm, count(*)";
 		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
-		$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
 		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-		$sql .= " WHERE p.fk_statut > 0";
-		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
-		if($user->societe_id)
-		{
-			$sql .= " AND p.fk_soc = ".$user->societe_id;
-		}
-		$sql .= " GROUP BY dm DESC";
+		$sql.= " WHERE ".$this->where;
+		$sql.= " GROUP BY dm DESC";
 
 		return $this->_getNbByYear($sql);
 	}
@@ -125,15 +116,11 @@ class PropaleStats extends Stats
 		 
 		$sql = "SELECT date_format(p.datep,'%m') as dm, sum(p.total_ht)";
 		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
-		$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
 		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-		$sql .= " WHERE date_format(p.datep,'%Y') = $year AND p.fk_statut > 0";
-		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
-		if($user->societe_id)
-		{
-			$sql .= " AND p.fk_soc = ".$user->societe_id;
-		}
-		$sql .= " GROUP BY dm DESC";
+		$sql.= " WHERE date_format(p.datep,'%Y') = ".$year;
+		$sql.= " AND ".$this->where;
+		$sql.= " GROUP BY dm DESC";
 
 		return $this->_getAmountByMonth($year, $sql);
 	}
@@ -146,16 +133,12 @@ class PropaleStats extends Stats
 		global $user;
 		 
 		$sql = "SELECT date_format(p.datep,'%m') as dm, avg(p.total_ht)";
-		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
-		$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
-		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-		$sql .= " WHERE date_format(p.datep,'%Y') = $year AND p.fk_statut > 0";
-		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
-		if($user->societe_id)
-		{
-			$sql .= " AND p.fk_soc = ".$user->societe_id;
-		}
-		$sql .= " GROUP BY dm DESC";
+		if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", sc.fk_soc, sc.fk_user";
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
+		if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE date_format(p.datep,'%Y') = ".$year;
+		$sql.= " AND ".$this->where;
+		$sql.= " GROUP BY dm DESC";
 
 		return $this->_getAverageByMonth($year, $sql);
 	}
@@ -170,9 +153,9 @@ class PropaleStats extends Stats
 		global $user;
 		
 		$sql = "SELECT date_format(p.datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
-		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
-		$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
-		if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", sc.fk_soc, sc.fk_user";
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
+		if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
 		$sql.= " WHERE ".$this->where;
 		$sql.= " GROUP BY year DESC";
 
diff --git a/htdocs/commande/stats/commandestats.class.php b/htdocs/commande/stats/commandestats.class.php
index 590c2afa96c53ab949e4b270f210c421ebde0eff..89cf59f56e9bb9dd2c6519f64774b6a7a24deadd 100644
--- a/htdocs/commande/stats/commandestats.class.php
+++ b/htdocs/commande/stats/commandestats.class.php
@@ -15,128 +15,153 @@
  * 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.
- *
- * $Id$
- * $Source$
  */
 
 /**
-        \file       htdocs/commande/stats/commandestats.class.php
-        \ingroup    commandes
-        \brief      Fichier de la classe de gestion des stats des commandes
-        \version    $Revision$
-*/
-
+ *       \file       htdocs/commande/stats/commandestats.class.php
+ *       \ingroup    commandes
+ *       \brief      Fichier de la classe de gestion des stats des commandes
+ *       \version    $Id$
+ */
 include_once DOL_DOCUMENT_ROOT . "/stats.class.php";
+include_once DOL_DOCUMENT_ROOT . "/commande/commande.class.php";
 
 
 /**
-        \class      CommandeStats
-        \brief      Classe permettant la gestion des stats des commandes
-*/
-
+ *       \class      CommandeStats
+ *       \brief      Classe permettant la gestion des stats des commandes
+ */
 class CommandeStats extends Stats
 {
-  var $db ;
-
-  function CommandeStats($DB, $socid)
-    {
-      $this->db = $DB;
-      $this->socid = $socid;
-    }
-
-  /**
-   *    \brief      Renvoie le nombre de commande par mois pour une ann�e donn�e
-   *
-   */
-    function getNbByMonth($year)
-    {
-    	  global $conf;
-    	  global $user;
-    	  
-        $sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb";
-        $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
-        if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-        $sql .= " WHERE date_format(c.date_commande,'%Y') = $year AND c.fk_statut > 0";
-        if (!$user->rights->societe->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
-        if ($this->socid)
-        {
-            $sql .= " AND c.fk_soc = ".$this->socid;
-        }
-        $sql .= " GROUP BY dm";
-        $sql .= " ORDER BY dm DESC";
-
-        return $this->_getNbByMonth($year, $sql);
-    }
-
-  /**
-   * Renvoie le nombre de commande par ann�e
-   *
-   */
-  function getNbByYear()
-  {
-  	global $conf;
-    global $user;
-  	
-    $sql = "SELECT date_format(c.date_commande,'%Y') as dm, count(*), sum(c.total_ht)";
-    $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
-    if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-    $sql .= " WHERE c.fk_statut > 0";
-    if (!$user->rights->societe->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
-    if ($this->socid)
-    {
-	    $sql .= " AND c.fk_soc = ".$this->socid;
-    }
-    $sql .= " GROUP BY dm DESC";
-
-    return $this->_getNbByYear($sql);
-  }
-  
-  /**
-   * Renvoie le nombre de commande par mois pour une ann�e donn�e
-   *
-   */
-  function getAmountByMonth($year)
-  {
-  	global $conf;
-    global $user;
-  	
-    $sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.total_ht)";
-    $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
-    if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-    $sql .= " WHERE date_format(c.date_commande,'%Y') = $year AND c.fk_statut > 0";
-    if (!$user->rights->societe->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
-    if ($this->socid)
-    {
-	    $sql .= " AND c.fk_soc = ".$this->socid;
-    }
-    $sql .= " GROUP BY dm DESC";
-
-    return $this->_getAmountByMonth($year, $sql);
-  }
-  
-  /**
-   * Renvoie le nombre de commande par mois pour une ann�e donn�e
-   *
-   */
-  function getAverageByMonth($year)
-  {
-  	global $conf;
-    global $user;
-  	
-    $sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.total_ht)";
-    $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
-    if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-    $sql .= " WHERE date_format(c.date_commande,'%Y') = $year AND c.fk_statut > 0";
-    if (!$user->rights->societe->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
-    if ($this->socid)
-    {
-	    $sql .= " AND c.fk_soc = ".$this->socid;
-    }
-    $sql .= " GROUP BY dm DESC";
-
-    return $this->_getAverageByMonth($year, $sql);
-  }
+	var $db ;
+
+	var $socid;
+	var $where;
+
+	var $table_element;
+	var $field;
+
+	
+	/**
+	 * Constructor
+	 *
+	 * @param 	$DB		Database handler
+	 * @param 	$socid	Id third party
+	 * @return 	PropaleStats
+	 */
+	function CommandeStats($DB, $socid=0)
+	{
+		global $user;
+		
+		$this->db = $DB;
+		
+		$object=new Commande($this->db);
+		$this->table_element=$object->table_element;
+		$this->field='total_ht';
+		
+		$this->socid = $socid;
+		$this->where.= " c.fk_statut > 0";
+		if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
+		if($this->socid)
+		{
+			$this->where .= " AND c.fk_soc = ".$this->socid;
+		}
+		
+	}
+
+	/**
+	 *    \brief      Renvoie le nombre de commande par mois pour une ann�e donn�e
+	 *
+	 */
+	function getNbByMonth($year)
+	{
+		global $conf;
+		global $user;
+		 
+		$sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb";
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
+		if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE date_format(c.date_commande,'%Y') = ".$year;
+		$sql.= " AND ".$this->where;
+		$sql.= " GROUP BY dm DESC";
+
+		return $this->_getNbByMonth($year, $sql);
+	}
+
+	/**
+	 * Renvoie le nombre de commande par ann�e
+	 *
+	 */
+	function getNbByYear()
+	{
+		global $conf;
+		global $user;
+		 
+		$sql = "SELECT date_format(c.date_commande,'%Y') as dm, count(*), sum(c.".$this->field.")";
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
+		if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE ".$this->where;
+		$sql.= " GROUP BY dm DESC";
+
+		return $this->_getNbByYear($sql);
+	}
+
+	/**
+	 * Renvoie le nombre de commande par mois pour une ann�e donn�e
+	 *
+	 */
+	function getAmountByMonth($year)
+	{
+		global $conf;
+		global $user;
+		 
+		$sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.".$this->field.")";
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
+		if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE date_format(c.date_commande,'%Y') = ".$year;
+		$sql.= " AND ".$this->where;
+		$sql.= " GROUP BY dm DESC";
+
+		return $this->_getAmountByMonth($year, $sql);
+	}
+
+	/**
+	 * Renvoie le nombre de commande par mois pour une ann�e donn�e
+	 *
+	 */
+	function getAverageByMonth($year)
+	{
+		global $conf;
+		global $user;
+		 
+		$sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.".$this->field.")";
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
+		if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE date_format(c.date_commande,'%Y') = ".$year;
+		$sql.= " AND ".$this->where;
+		$sql.= " GROUP BY 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(c.date_commande,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
+		if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", sc.fk_soc, sc.fk_user";
+		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
+		if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE ".$this->where;
+		$sql.= " GROUP BY year DESC";
+
+		return $this->_getAllByYear($sql);
+	}	
 }
 
 ?>
diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php
index 3693f66f19963929b14876f6699abf92fadc5a84..b95f70023ab04afe548940bbbd6b5c5cd07a9d95 100644
--- a/htdocs/commande/stats/index.php
+++ b/htdocs/commande/stats/index.php
@@ -41,36 +41,39 @@ if ($user->societe_id > 0)
   $socid = $user->societe_id;
 }
 
+$year = strftime("%Y", time());
+$startyear=$year-2;
+$endyear=$year;
 
+/*
+ * View
+ */
+ 
 llxHeader();
 
 print_fiche_titre($langs->trans("OrdersStatistics"), $mesg);
 
+$dir=$conf->commande->dir_temp;
+
+create_exdir($dir);
+
 $stats = new CommandeStats($db, $socid);
-$year = strftime("%Y", time());
-$startyear=$year-2;
-$endyear=$year;
+
+// Build graphic number of object
 $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
+//var_dump($data);
+// $data = array(array('Lib',val1,val2,val3),...)
 
-// Cr�ation r�pertoire pour images g�n�r�es
-$dir=$conf->commande->dir_temp;
-if (! file_exists($dir))
-{
-    if (create_exdir($dir) < 0)
-    {
-        $mesg = $langs->trans("ErrorCanNotCreateDir",$dir);
-    }
-}
 
 if (!$user->rights->societe->client->voir || $user->societe_id)
 {
-	$filename = $conf->commande->dir_temp.'/nbcommande2year-'.$user->id.'-'.$year.'.png';
-	$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=nbcommande2year-'.$user->id.'-'.$year.'.png';
+	$filenamenb = $dir.'/ordersnbinyear-'.$user->id.'-'.$year.'.png';
+	$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$user->id.'-'.$year.'.png';
 }
 else
 {
-	$filename = $conf->commande->dir_temp.'/nbcommande2year-'.$year.'.png';
-	$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=nbcommande2year-'.$year.'.png';
+	$filenamenb = $dir.'/ordersnbinyear-'.$year.'.png';
+	$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$year.'.png';
 }
 
 $px = new DolGraph();
@@ -87,6 +90,7 @@ if (! $mesg)
 	}
     $px->SetLegend($legend);
     $px->SetMaxValue($px->GetCeilMaxValue());
+	$px->SetMinValue(min(0,$px->GetFloorMinValue()));
     $px->SetWidth($WIDTH);
     $px->SetHeight($HEIGHT);
     $px->SetYLabel($langs->trans("NbOfOrder"));
@@ -94,31 +98,109 @@ if (! $mesg)
 	$px->SetHorizTickIncrement(1);
 	$px->SetPrecisionY(0);
     $px->mode='depth';
-	$px->draw($filename);
+	$px->SetTitle($langs->trans("NumberOfOrdersByMonth"));
+	$px->draw($filenamenb);
 }      
-$rows = $stats->getNbByYear();
-$num = sizeof($rows);
+
+// Build graphic amount of object
+$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
+//var_dump($data);
+// $data = array(array('Lib',val1,val2,val3),...)
+
+if (!$user->rights->societe->client->voir || $user->societe_id)
+{
+	$filenameamount = $dir.'/ordersamountinyear-'.$user->id.'-'.$year.'.png';
+	$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$user->id.'-'.$year.'.png';
+}
+else
+{
+	$filenameamount = $dir.'/ordersamountinyear-'.$year.'.png';
+	$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$year.'.png';
+}
+
+$px = new DolGraph();
+$mesg = $px->isGraphKo();
+if (! $mesg)
+{
+	$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("AmountOfOrders"));
+	$px->SetShading(3);
+	$px->SetHorizTickIncrement(1);
+	$px->SetPrecisionY(0);
+	$px->mode='depth';
+	$px->SetTitle($langs->trans("AmountOfOrdersByMonthHT"));
+
+	$px->draw($filenameamount);
+}
+
+print '<table class="notopnoleftnopadd" width="100%"><tr>';
+print '<td align="center" valign="top">';
+
+// Show array
+$data = $stats->getAllByYear();
 
 print '<table class="border" width="100%">';
-print '<tr><td align="center">'.$langs->trans("Year").'</td><td width="10%" align="center">'.$langs->trans("NbOfOrders").'</td><td align="center">'.$langs->trans("AmountTotal").'</td>';
-print '<td align="center" valign="top" rowspan="'.($num + 1).'">';
-if ($px->isGraphKo()) { print '<font class="error">'.$px->isGraphKo().'</div>'; }
-else { print '<img src="'.$fileurl.'" alt="Nombre de commande par mois">'; }
-print '</td></tr>';
-$i = 0;
-while (list($key, $value) = each ($rows))
+print '<tr height="24">';
+print '<td align="center">'.$langs->trans("Year").'</td>';
+print '<td align="center">'.$langs->trans("NbOfOrders").'</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)
 {
-  $year = $value[0];
-  $nbproduct = $value[1];
-  $price = $value[2];
-  print "<tr>";
-  print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td align="center">'.$nbproduct.'</td><td align="center">'.price($price).'</td></tr>';
-  $i++;
+	$year = $val['year'];
+	print $avg;
+	while ($oldyear > $year+1)
+	{	// If we have empty year
+		$oldyear--;
+		print '<tr height="24">';
+		print '<td align="center"><a href="month.php?year='.$oldyear.'&amp;mode='.$mode.'">'.$oldyear.'</a></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"><a href="month.php?year='.$year.'">'.$year.'</a></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;
 }
 
 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("NbOfOrders").'" alt="'.$langs->trans("NbOfProposals").'">';
+	print "<br>\n";
+	print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountTotal").'" alt="'.$langs->trans("AmountTotal").'">';
+}
+print '</td></tr></table>';
+
+print '</td></tr></table>';
+
 $db->close();
 
 llxFooter('$Date$ - $Revision$');
diff --git a/htdocs/commande/stats/month.php b/htdocs/commande/stats/month.php
index 1d47197b39347c7b481fa534162a86be6e790b97..b120c0f189353cf95e376956e844113d4acb5622 100644
--- a/htdocs/commande/stats/month.php
+++ b/htdocs/commande/stats/month.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (c) 2004-2006 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (c) 2004-2008 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
@@ -18,57 +18,71 @@
  */
 
 /**
-	    \file       htdocs/commande/stats/month.php
-        \ingroup    commande
-		\brief      Page des stats commandes par mois
-		\version    $Id$
-*/
-
+ *	    \file       htdocs/commande/stats/month.php
+ *      \ingroup    commande
+ *		\brief      Page des stats commandes par mois
+ *		\version    $Id$
+ */
 require("./pre.inc.php");
 require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
 require_once(DOL_DOCUMENT_ROOT."/commande/stats/commandestats.class.php");
 require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
 
-// S�curit� acc�s client
+$GRAPHWIDTH=500;
+$GRAPHHEIGHT=200;
+
+// Check security access
 if ($user->societe_id > 0) 
 {
   $action = '';
   $socid = $user->societe_id;
 }
 
-llxHeader();
-
 $year = isset($_GET["year"])?$_GET["year"]:date("Y",time());
 
-$mesg = '<a href="month.php?year='.($year - 1).'">'.img_previous().'</a> ';
-$mesg.= $langs->trans("Year")." $year";
-$mesg.= ' <a href="month.php?year='.($year + 1).'">'.img_next().'</a>';
+$mode='customer';
+if (isset($_GET["mode"])) $mode=$_GET["mode"];
+
 
-$WIDTH=500;
-$HEIGHT=200;
 
 /*
- *
- *
+ * View
  */
 
-print_fiche_titre($langs->trans("OrdersStatistics"), $mesg);
+llxHeader();
 
-$stats = new CommandeStats($db, $socid);
-$data = $stats->getNbByMonth($year);
+if ($mode == 'customer') 
+{
+	$title=$langs->trans("OrdersStatistics");
+	$dir=$conf->commande->dir_temp;
+}
+if ($mode == 'supplier') 
+{
+	$title=$langs->trans("OrdersStatisticsSuppliers");
+	$dir=$conf->fournisseur->commande->dir_temp;
+}
+
+$mesg = '<a href="month.php?year='.($year - 1).'&amp;mode='.$mode.'">'.img_previous().'</a> ';
+$mesg.= $langs->trans("Year")." $year";
+$mesg.= ' <a href="month.php?year='.($year + 1).'&amp;mode='.$mode.'">'.img_next().'</a>';
+print_fiche_titre($title, $mesg);
+
+create_exdir($dir);
 
-create_exdir($conf->commande->dir_temp);
+$stats = new CommandeStats($db, $socid, $mode);
 
 
+$data = $stats->getNbByMonth($year);
+
 if (!$user->rights->societe->client->voir || $user->societe_id)
 {
-	$filename = $conf->commande->dir_temp.'/commande-'.$user->id.'-'.$year.'.png';
-  $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commande-'.$user->id.'-'.$year.'.png';
+	$filename = $dir.'/ordersnb-'.$user->id.'-'.$year.'.png';
+  	$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnb-'.$user->id.'-'.$year.'.png';
 }
 else
 {
-	$filename = $conf->commande->dir_temp.'/commande'.$year.'.png';
-  $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commande'.$year.'.png';
+	$filename = $dir.'/ordersnb-'.$year.'.png';
+  	$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnb-'.$year.'.png';
 }
 
 $px = new DolGraph();
@@ -77,8 +91,9 @@ if (! $mesg)
 {
     $px->SetData($data);
     $px->SetMaxValue($px->GetCeilMaxValue());
-    $px->SetWidth($WIDTH);
-    $px->SetHeight($HEIGHT);
+    $px->SetMinValue($px->GetFloorMinValue());
+    $px->SetWidth($GRAPHWIDTH);
+    $px->SetHeight($GRAPHHEIGHT);
     $px->SetYLabel($langs->trans("NbOfOrders"));
     $px->SetShading(3);
 	$px->SetHorizTickIncrement(1);
@@ -86,24 +101,18 @@ if (! $mesg)
     $px->draw($filename);
 }
 
-$res = $stats->getAmountByMonth($year);
 
-$data = array();
-
-for ($i = 1 ; $i < 13 ; $i++)
-{
-  $data[$i-1] = array(ucfirst(substr(strftime("%b",dolibarr_mktime(12,12,12,$i,1,$year)),0,3)), $res[$i]);
-}
+$data = $stats->getAmountByMonth($year);
 
 if (!$user->rights->societe->client->voir || $user->societe_id)
 {
-	$filename_amount = $conf->commande->dir_temp.'/commandeamount-'.$user->id.'-'.$year.'.png';
-	$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeamount-'.$user->id.'-'.$year.'.png';
+	$filename_amount = $dir.'/ordersamount-'.$user->id.'-'.$year.'.png';
+	$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamount-'.$user->id.'-'.$year.'.png';
 }
 else
 {
-	$filename_amount = $conf->commande->dir_temp.'/commandeamount'.$year.'.png';
-	$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeamount'.$year.'.png';
+	$filename_amount = $dir.'/ordersamount-'.$year.'.png';
+	$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamount-'.$year.'.png';
 }
 
 $px = new DolGraph();
@@ -111,11 +120,12 @@ $mesg = $px->isGraphKo();
 if (! $mesg)
 {
     $px->SetData($data);
-    $px->SetMaxValue($px->GetCeilMaxValue());
-    $px->SetWidth($WIDTH);
-    $px->SetHeight($HEIGHT);
     $px->SetYLabel($langs->trans("AmountTotal"));
-    $px->SetShading(5);
+    $px->SetMaxValue($px->GetCeilMaxValue());
+    $px->SetMinValue($px->GetFloorMinValue());
+    $px->SetWidth($GRAPHWIDTH);
+    $px->SetHeight($GRAPHHEIGHT);
+    $px->SetShading(3);
 	$px->SetHorizTickIncrement(1);
 	$px->SetPrecisionY(0);
     $px->draw($filename_amount);
@@ -131,13 +141,13 @@ for ($i = 1 ; $i < 13 ; $i++)
 
 if (!$user->rights->societe->client->voir || $user->societe_id)
 {
-	$filename_avg = $conf->commande->dir_temp.'/commandeaverage-'.$user->id.'-'.$year.'.png';
-	$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeaverage-'.$user->id.'-'.$year.'.png';
+	$filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png';
+	$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png';
 }
 else
 {
-	$filename_avg = $conf->commande->dir_temp.'/commandeaverage'.$year.'.png';
-	$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeaverage'.$year.'.png';
+	$filename_avg = $dir.'/ordersaverage-'.$year.'.png';
+	$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png';
 }
 
 $px = new DolGraph();
@@ -145,11 +155,12 @@ $mesg = $px->isGraphKo();
 if (! $mesg)
 {
     $px->SetData($data);
-    $px->SetMaxValue($px->GetCeilMaxValue());
-    $px->SetWidth($WIDTH);
-    $px->SetHeight($HEIGHT);
     $px->SetYLabel($langs->trans("AmountAverage"));
-    $px->SetShading(5);
+    $px->SetMaxValue($px->GetCeilMaxValue());
+    $px->SetMinValue($px->GetFloorMinValue());
+    $px->SetWidth($GRAPHWIDTH);
+    $px->SetHeight($GRAPHHEIGHT);
+    $px->SetShading(3);
 	$px->SetHorizTickIncrement(1);
 	$px->SetPrecisionY(0);
     $px->draw($filename_avg);
diff --git a/htdocs/compta/facture/stats/month.php b/htdocs/compta/facture/stats/month.php
index dae0963bde00feaf5303ee87bacf4f427e3b8c9e..e0874eae705c0586b2e6d534c11ed7bf8b7b8382 100644
--- a/htdocs/compta/facture/stats/month.php
+++ b/htdocs/compta/facture/stats/month.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (c) 2004-2006 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (c) 2004-2008 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
@@ -136,7 +136,6 @@ $mesg = $px->isGraphKo();
 if (! $mesg)
 {
     $px->SetData($data);
-	$px->SetPrecisionY(0);
     $px->SetYLabel($langs->trans("AmountAverage"));
     $px->SetMaxValue($px->GetCeilMaxValue());
     $px->SetMinValue($px->GetFloorMinValue());
diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang
index 6f9122cf0467df4c6d146358681fbdb09afe3eb2..2c2883d3a45f811920ed0338cf592b6c84d48b11 100755
--- a/htdocs/langs/en_US/orders.lang
+++ b/htdocs/langs/en_US/orders.lang
@@ -69,6 +69,7 @@ AllOrders=All orders
 NbOfOrders=Number of orders
 OrdersStatistics=Orders' statistics
 NumberOfOrdersByMonth=Number of orders by month
+AmountOfOrdersByMonthHT=amount of orders by month (net of tax)
 ListOfOrders=List of orders
 CloseOrder=Close order
 ConfirmCloseOrder=Are you sure you want to close this order ? Once an order is closed, it can only be billed.
diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang
index b59c74ae46ab43f6143f80c8846f8d35d8d1ba26..e4a4205fe453ee7a89faeec9466c0e4fc36f3e3b 100755
--- a/htdocs/langs/fr_FR/orders.lang
+++ b/htdocs/langs/fr_FR/orders.lang
@@ -69,6 +69,7 @@ AllOrders=Toutes les commandes
 NbOfOrders=Nombre de commandes
 OrdersStatistics=Statistiques des commandes
 NumberOfOrdersByMonth=Nombre de commandes par mois
+AmountOfOrdersByMonthHT=Montant total de commandes par mois (HT)
 ListOfOrders=Liste des commandes
 CloseOrder=Cloturer commande
 ConfirmCloseOrder=�tes-vous sur de vouloir cloturer cette commande ? Une fois une commande clotur�e, elle doit �tre factur�e.