diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php
index e38097e4e3ad09e8036c03c3d2e613f8e11e33e4..81488bdb1d668bcf90ee68afbbcb0e5fa27ff68f 100644
--- a/htdocs/commande/class/commandestats.class.php
+++ b/htdocs/commande/class/commandestats.class.php
@@ -81,7 +81,8 @@ class CommandeStats extends Stats
 			$this->where.= " c.fk_statut > 2";    // Only approved & ordered
 		}
 		//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
-		$this->where.= " AND c.entity = ".$conf->entity;
+		$this->where.= ' AND c.entity IN ('.getEntity('commande', 1).')';
+		
 		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)
 		{
diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php
index 57c970b9fc8cfb1acc3bb342a51451a1a3a12fec..deaa386da9d33d50da3bbe5bfa5bce6bdde5c6a9 100644
--- a/htdocs/expensereport/class/expensereportstats.class.php
+++ b/htdocs/expensereport/class/expensereportstats.class.php
@@ -56,14 +56,17 @@ class ExpenseReportStats extends Stats
         $this->userid = $userid;
 
 		$object=new ExpenseReport($this->db);
-		$this->from = MAIN_DB_PREFIX.$object->table_element;
+		$this->from = MAIN_DB_PREFIX.$object->table_element." as e";
 		$this->field='total_ht';
 
-		$this->where = " fk_statut > 0 and date_valid > '2000-01-01'";
+		$this->where = " e.fk_statut > 0";
+		//$this->where.= " AND e.date_valid > '2000-01-01'";    // To filter only approved
+		$this->where.= ' AND e.entity IN ('.getEntity('expensereport', 1).')';
+		
 		//$this->where.= " AND entity = ".$conf->entity;
 		if ($this->socid)
 		{
-			$this->where.=" AND fk_soc = ".$this->socid;
+			$this->where.=" AND e.fk_soc = ".$this->socid;
 		}
 
 		// Only me and subordinates
@@ -71,10 +74,10 @@ class ExpenseReportStats extends Stats
 		{
 			$childids = $user->getAllChildIds();
 			$childids[]=$user->id;
-			$this->where.=" AND fk_user_author IN (".(join(',',$childids)).")";
+			$this->where.=" AND e.fk_user_author IN (".(join(',',$childids)).")";
 		}
 
-		if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid;
+		if ($this->userid > 0) $this->where.=' AND e.fk_user_author = '.$this->userid;
 	}
 
 
@@ -102,9 +105,9 @@ class ExpenseReportStats extends Stats
 	 */
 	function getNbByMonth($year)
 	{
-		$sql = "SELECT MONTH(date_valid) as dm, count(*)";
+		$sql = "SELECT MONTH(e.date_valid) as dm, count(*)";
 		$sql.= " FROM ".$this->from;
-		$sql.= " WHERE YEAR(date_valid) = ".$year;
+		$sql.= " WHERE YEAR(e.date_valid) = ".$year;
 		$sql.= " AND ".$this->where;
 		$sql.= " GROUP BY dm";
         $sql.= $this->db->order('dm','DESC');
@@ -123,9 +126,9 @@ class ExpenseReportStats extends Stats
 	 */
 	function getAmountByMonth($year)
 	{
-		$sql = "SELECT date_format(date_valid,'%m') as dm, sum(".$this->field.")";
+		$sql = "SELECT date_format(e.date_valid,'%m') as dm, sum(".$this->field.")";
 		$sql.= " FROM ".$this->from;
-		$sql.= " WHERE date_format(date_valid,'%Y') = '".$year."'";
+		$sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'";
 		$sql.= " AND ".$this->where;
 		$sql.= " GROUP BY dm";
 		$sql.= $this->db->order('dm','DESC');
@@ -143,9 +146,9 @@ class ExpenseReportStats extends Stats
 	 */
 	function getAverageByMonth($year)
 	{
-		$sql = "SELECT date_format(date_valid,'%m') as dm, avg(".$this->field.")";
+		$sql = "SELECT date_format(e.date_valid,'%m') as dm, avg(".$this->field.")";
 		$sql.= " FROM ".$this->from;
-		$sql.= " WHERE date_format(date_valid,'%Y') = '".$year."'";
+		$sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'";
 		$sql.= " AND ".$this->where;
 		$sql.= " GROUP BY dm";
         $sql.= $this->db->order('dm','DESC');
@@ -160,7 +163,7 @@ class ExpenseReportStats extends Stats
 	 */
 	function getAllByYear()
 	{
-		$sql = "SELECT date_format(date_valid,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
+		$sql = "SELECT date_format(e.date_valid,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
 		$sql.= " FROM ".$this->from;
 		$sql.= " WHERE ".$this->where;
 		$sql.= " GROUP BY year";