diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 18f5fe4db34d79475697e04d0f2210c2ad10d169..a38049ae10fc9b0921fad76b70a01518b1749d43 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -180,30 +180,12 @@ if ($filtre)
         $sql .= ' AND ' . trim($filt[0]) . ' = ' . trim($filt[1]);
     }
 }
-if ($search_ref)
-{
-    $sql .= natural_search('f.facnumber', $search_ref);
-}
-if ($search_refcustomer)
-{
-	$sql .= natural_search('f.ref_client', $search_refcustomer);
-}
-if ($search_societe)
-{
-    $sql .= natural_search('s.nom', $search_societe);
-}
-if ($search_montant_ht != '')
-{
-    $sql.= natural_search('f.total', $search_montant_ht, 1);
-}
-if ($search_montant_ttc != '')
-{
-    $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
-}
-if ($search_status != '')
-{
-	$sql.= " AND f.fk_statut = '".$db->escape($search_status)."'";
-}
+if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref);
+if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer);
+if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
+if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1);
+if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
+if ($search_status != '') $sql.= " AND f.fk_statut = '".$db->escape($search_status)."'";
 if ($month > 0)
 {
     if ($year > 0 && empty($day))
@@ -258,7 +240,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 	$nbtotalofrecords = $db->num_rows($result);
 }
 
-
 $sql.= $db->plimit($limit+1,$offset);
 //print $sql;
 
@@ -307,7 +288,7 @@ if ($resql)
     if ($moreforfilter)
     {
         print '<tr class="liste_titre">';
-        print '<td class="liste_titre" colspan="10">';
+        print '<td class="liste_titre" colspan="11">';
         print $moreforfilter;
         print '</td></tr>';
     }
@@ -323,6 +304,7 @@ if ($resql)
     print_liste_field_titre($langs->trans('AmountTTC'),$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder);
     print_liste_field_titre($langs->trans('Received'),$_SERVER['PHP_SELF'],'am','',$param,'align="right"',$sortfield,$sortorder);
     print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_statut,paye,am','',$param,'align="right"',$sortfield,$sortorder);
+    print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
     print "</tr>\n";
 
     // Filters lines
@@ -345,9 +327,10 @@ if ($resql)
     print '</td>';
     print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.$search_societe.'"></td>';
     print '<td class="liste_titre" align="right"><input class="flat" type="text" size="6" name="search_montant_ht" value="'.$search_montant_ht.'"></td>';
-    print '<td class="liste_titre" align="right">&nbsp;</td>';
+    print '<td class="liste_titre"></td>';
     print '<td class="liste_titre" align="right"><input class="flat" type="text" size="6" name="search_montant_ttc" value="'.$search_montant_ttc.'"></td>';
-    print '<td class="liste_titre" align="right">&nbsp;</td>';
+    print '<td class="liste_titre"></td>';
+    print '<td class="liste_titre"></td>';
     print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
 	print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
     print "</td></tr>\n";
@@ -439,7 +422,9 @@ if ($resql)
             print '<td align="right" class="nowrap">';
             print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$paiement,$objp->type);
             print "</td>";
-            //print "<td>&nbsp;</td>";
+
+            print "<td></td>";
+
             print "</tr>\n";
             $total_ht+=$objp->total_ht;
             $total_tva+=$objp->total_tva;
@@ -457,7 +442,8 @@ if ($resql)
             print '<td class="liste_total" align="right">'.price($total_tva,0,$langs).'</td>';
             print '<td class="liste_total" align="right">'.price($total_ttc,0,$langs).'</td>';
             print '<td class="liste_total" align="right">'.price($totalrecu,0,$langs).'</td>';
-            print '<td class="liste_total" align="center">&nbsp;</td>';
+            print '<td class="liste_total"></td>';
+            print '<td class="liste_total"></td>';
             print '</tr>';
         }
     }
diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php
index e8010229a8e364ac218b809e91857c22ed104439..d29f237c331d728fa2db4621346df8ae75f26ffb 100644
--- a/htdocs/compta/facture/mergepdftool.php
+++ b/htdocs/compta/facture/mergepdftool.php
@@ -654,13 +654,16 @@ if ($resql)
 	print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder);
 	print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
 	print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder);
+
+	$searchpitco='<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
+	$searchpitco.='<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Reset"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
 	if (empty($mode))
 	{
-		print_liste_field_titre($langs->trans("PDFMerge"),$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder);
+		print_liste_field_titre($searchpitco,$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder);
 	}
 	else
 	{
-		print_liste_field_titre($langs->trans("Remind"),$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder);
+		print_liste_field_titre($searchpitco,$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder);
 	}
 	print "</tr>\n";
 
@@ -695,9 +698,6 @@ if ($resql)
 	print $form->selectarray('filtre', $liststatus, $filter, 1);
 	print '</td>';
 	print '<td class="liste_titre" align="center">';
-	print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
-	print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
-	print '<br>';
 	if (empty($mode))
 	{
 		if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>';
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index fe32541a0fc7c308bcc69d1e9b6e6617f7d4d6cc..aaebcf697f33b1065aa0d047196da36488fee4a8 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -705,7 +705,7 @@ if (! GETPOST('action'))
         print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'dp','','','',$sortfield,$sortorder);
         print_liste_field_titre($langs->trans('Type'),$_SERVER["PHP_SELF"],'libelle','','','',$sortfield,$sortorder);
         print_liste_field_titre($langs->trans('Amount'),$_SERVER["PHP_SELF"],'fa_amount','','','align="right"',$sortfield,$sortorder);
-        print_liste_field_titre('');
+		print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
         print "</tr>\n";
 
         while ($i < min($num,$limit))
@@ -728,6 +728,6 @@ if (! GETPOST('action'))
     }
 }
 
-$db->close();
-
 llxFooter();
+
+$db->close();
diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php
index f2b6bcf1490fbfeabf741b3682bc29b9ec65a47c..d284a12863137ce49219050ea659cf8b7198f2ce 100644
--- a/htdocs/compta/paiement/list.php
+++ b/htdocs/compta/paiement/list.php
@@ -68,6 +68,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
 	$search_company="";
 }
 
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('paymentlist'));
+$extrafields = new ExtraFields($db);
+
+
+
 /*
  * 	View
  */
@@ -81,24 +87,37 @@ if (GETPOST("orphelins"))
     // Paiements lies a aucune facture (pour aide au diagnostic)
     $sql = "SELECT p.rowid, p.datep as dp, p.amount,";
     $sql.= " p.statut, p.num_paiement,";
-    //$sql.= " c.libelle as paiement_type";
     $sql.= " c.code as paiement_code";
+	// Add fields for extrafields
+	foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
+	// Add fields from hooks
+	$parameters=array();
+	$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
+	$sql.=$hookmanager->resPrint;
     $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p,";
     $sql.= " ".MAIN_DB_PREFIX."c_paiement as c)";
     $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
     $sql.= " WHERE p.fk_paiement = c.id";
     $sql.= " AND p.entity = ".$conf->entity;
     $sql.= " AND pf.fk_facture IS NULL";
+	// Add where from hooks
+	$parameters=array();
+	$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
+	$sql.=$hookmanager->resPrint;
 }
 else
 {
     $sql = "SELECT DISTINCT p.rowid, p.datep as dp, p.amount,"; // DISTINCT is to avoid duplicate when there is a link to sales representatives
     $sql.= " p.statut, p.num_paiement,";
-    //$sql.= " c.libelle as paiement_type,";
     $sql.= " c.code as paiement_code,";
     $sql.= " ba.rowid as bid, ba.label,";
     $sql.= " s.rowid as socid, s.nom as name";
-    //$sql.= " f.facnumber";
+	// Add fields for extrafields
+	foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
+	// Add fields from hooks
+	$parameters=array();
+	$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
+	$sql.=$hookmanager->resPrint;
     $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement as p)";
     $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
     $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
@@ -127,6 +146,10 @@ else
     if ($search_paymenttype != "")  $sql .=" AND c.code='".$db->escape($search_paymenttype)."'";
     if ($search_amount)      		$sql .=" AND p.amount='".$db->escape(price2num($search_amount))."'";
     if ($search_company)     		$sql .= natural_search('s.nom', $search_company);
+	// Add where from hooks
+	$parameters=array();
+	$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
+	$sql.=$hookmanager->resPrint;
 }
 $sql.= $db->order($sortfield,$sortorder);
 $sql.= $db->plimit($limit+1, $offset);
@@ -157,11 +180,13 @@ if ($resql)
     print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$paramlist,"",$sortfield,$sortorder);
     print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"p.amount","",$paramlist,'align="right"',$sortfield,$sortorder);
     //print_liste_field_titre($langs->trans("Invoices"),"","","",$paramlist,'align="left"',$sortfield,$sortorder);
-    if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
-    {
-        print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut","",$paramlist,'align="right"',$sortfield,$sortorder);
-    }
-    print_liste_field_titre('');
+
+	$parameters=array();
+    $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters);    // Note that $action and $object may have been modified by hook
+	print $hookmanager->resPrint;
+
+    if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut","",$paramlist,'align="right"',$sortfield,$sortorder);
+    print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
 	print "</tr>\n";
 
     // Lines for filters fields
@@ -199,7 +224,7 @@ if ($resql)
         $var=!$var;
         print "<tr ".$bc[$var].">";
 
-        print '<td width="40">';
+        print '<td>';
         $paymentstatic->id=$objp->rowid;
         $paymentstatic->ref=$objp->rowid;
         print $paymentstatic->getNomUrl(1);
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index b2e1992f0f92e0d39bf3da3918ea418fba940afc..7f2640fad4a48f8c0f5031fd3c8489eeed3f4bc2 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -1194,6 +1194,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
 				$newmenu->add("/projet/index.php?leftmenu=projects", $langs->trans("Projects"), 0, $user->rights->projet->lire && $user->rights->projet->lire, '', $mainmenu, 'projects');
 				$newmenu->add("/projet/card.php?leftmenu=projects&action=create", $langs->trans("NewProject"), 1, $user->rights->projet->creer && $user->rights->projet->creer);
 				$newmenu->add("/projet/list.php?leftmenu=projects", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->lire);
+				$newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire && $user->rights->projet->lire);
 
 				if (empty($conf->global->PROJECT_HIDE_TASKS))
 				{
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index aadd66038535a150661cf3ef1be4fd19f09194a9..de6f0fe05760e8b701428b51b007538686e11940 100644
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -158,3 +158,5 @@ AssignTask=Assign
 ProjectOverview=Overview
 ManageTasks=Use projects to follow tasks and time
 ManageOpportunitiesStatus=Use projects to follow leads/opportinuties
+ProjectNbProjectByMonth=Nb of created projects by month
+ProjectsStatistics=Statistics on projects/leads 
\ No newline at end of file
diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php
new file mode 100644
index 0000000000000000000000000000000000000000..27335777db12598b01a3589007b0df2b6145a756
--- /dev/null
+++ b/htdocs/projet/class/projectstats.class.php
@@ -0,0 +1,327 @@
+<?php
+/* Lead
+ * Copyright (C) 2014-2015 Florian HENRY <florian.henry@open-concept.pro>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
+include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
+
+
+class ProjectStats extends Stats
+{
+	protected $db;
+	private $project;
+	public $userid;
+	public $socid;
+	public $year;
+	function __construct($db) {
+		global $conf, $user;
+
+		$this->db = $db;
+
+		require_once 'project.class.php';
+
+		$this->project = new Project($this->db);
+	}
+
+
+	/**
+	 * Return all leads grouped by status
+	 *
+	 * @param int $limit Limit results
+	 * @return array|int
+	 * @throws Exception
+	 */
+	function getAllProjectByStatus($limit = 5)
+	{
+		global $conf, $user, $langs;
+
+		$datay = array ();
+
+		$sql = "SELECT";
+		$sql .= " count(DISTINCT t.rowid), t.fk_opp_status";
+		$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
+		$sql .= $this->buildWhere();
+		$sql .= " GROUP BY t.fk_opp_status";
+
+		$result = array ();
+		$res = array ();
+
+		dol_syslog(get_class($this) . '::' . __METHOD__ . "", LOG_DEBUG);
+		$resql = $this->db->query($sql);
+		if ($resql) {
+			$num = $this->db->num_rows($resql);
+			$i = 0;
+			$other = 0;
+			while ( $i < $num ) {
+				$row = $this->db->fetch_row($resql);
+				if ($i < $limit || $num == $limit)
+					$result[$i] = array (
+							$this->projet->status[$row[1]] . '(' . $row[0] . ')',
+							$row[0]
+					);
+				else
+					$other += $row[1];
+				$i ++;
+			}
+			if ($num > $limit)
+				$result[$i] = array (
+						$langs->transnoentitiesnoconv("Other"),
+						$other
+				);
+			$this->db->free($resql);
+		} else {
+			$this->error = "Error " . $this->db->lasterror();
+			dol_syslog(get_class($this) . '::' . __METHOD__ . ' ' . $this->error, LOG_ERR);
+			return - 1;
+		}
+
+		return $result;
+	}
+
+	/**
+	 * Return count, and sum of products
+	 *
+	 * @return array of values
+	 */
+	function getAllByYear()
+	{
+		global $conf, $user, $langs;
+
+		$datay = array ();
+
+		$sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb, SUM(t.opp_amount) as total, AVG(t.opp_amount) as avg";
+		$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
+		if (! $user->rights->societe->client->voir && ! $user->societe_id)
+			$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
+		$sql .= $this->buildWhere();
+		$sql .= " GROUP BY year";
+		$sql .= $this->db->order('year', 'DESC');
+
+		return $this->_getAllByYear($sql);
+	}
+	/**
+	 *
+	 * @return string
+	 */
+	public function buildWhere() {
+		$sqlwhere_str = '';
+		$sqlwhere = array ();
+
+		$sqlwhere[] = ' t.entity IN (' . getEntity('project') . ')';
+
+		if (! empty($this->userid))
+			$sqlwhere[] = ' t.fk_user_resp=' . $this->userid;
+		if (! empty($this->socid))
+			$sqlwhere[] = ' t.fk_soc=' . $this->socid;
+		if (! empty($this->year) && empty($this->yearmonth))
+			$sqlwhere[] = " date_format(t.datec,'%Y')='" . $this->year . "'";
+		if (! empty($this->yearmonth))
+			$sqlwhere[] = " t.datec BETWEEN '" . $this->db->idate(dol_get_first_day($this->yearmonth)) . "' AND '" . $this->db->idate(dol_get_last_day($this->yearmonth)) . "'";
+
+		if (! empty($this->status))
+			$sqlwhere[] = " t.fk_opp_status IN (" . $this->status . ")";
+
+		if (count($sqlwhere) > 0) {
+			$sqlwhere_str = ' WHERE ' . implode(' AND ', $sqlwhere);
+		}
+
+		return $sqlwhere_str;
+	}
+
+	/**
+	 * Return Project number by month for a year
+	 *
+	 * @param int $year scan
+	 * @return array of values
+	 */
+	function getNbByMonth($year) {
+		global $user;
+
+		$this->yearmonth = $year;
+
+		$sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(*) as nb";
+		$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
+		if (! $user->rights->societe->client->voir && ! $user->societe_id)
+			$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
+		$sql .= $this->buildWhere();
+		$sql .= " GROUP BY dm";
+		$sql .= $this->db->order('dm', 'DESC');
+
+		$this->yearmonth=0;
+
+		$res = $this->_getNbByMonth($year, $sql);
+		// var_dump($res);print '<br>';
+		return $res;
+	}
+
+	/**
+	 * Return the Project amount by month for a year
+	 *
+	 * @param int $year scan
+	 * @return array with amount by month
+	 */
+	function getAmountByMonth($year) {
+		global $user;
+
+		$this->yearmonth = $year;
+
+		$sql = "SELECT date_format(t.datec,'%m') as dm, SUM(t.opp_amount)";
+		$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
+		if (! $user->rights->societe->client->voir && ! $user->societe_id)
+			$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
+		$sql .= $this->buildWhere();
+		$sql .= " GROUP BY dm";
+		$sql .= $this->db->order('dm', 'DESC');
+		$this->yearmonth=0;
+
+		$res = $this->_getAmountByMonth($year, $sql);
+		// var_dump($res);print '<br>';
+		return $res;
+	}
+
+	/**
+	 * Return amount of elements by month for several years
+	 *
+	 * @param int $endyear		End year
+	 * @param int $startyear	Start year
+	 * @param int $cachedelay accept for cache file (0=No read, no save of cache, -1=No read but save)
+	 * @return array of values
+	 */
+	function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0)
+	{
+		global $conf, $user, $langs;
+
+		if ($startyear > $endyear) return - 1;
+
+		$datay = array();
+
+		// Search into cache
+		if (! empty($cachedelay))
+		{
+			include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
+			include_once DOL_DOCUMENT_ROOT . '/core/lib/json.lib.php';
+		}
+
+		$newpathofdestfile = $conf->user->dir_temp . '/' . get_class($this) . '_' . __FUNCTION__ . '_' . (empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix . '_') . $langs->defaultlang . '_user' . $user->id . '.cache';
+		$newmask = '0644';
+
+		$nowgmt = dol_now();
+
+		$foundintocache = 0;
+		if ($cachedelay > 0) {
+			$filedate = dol_filemtime($newpathofdestfile);
+			if ($filedate >= ($nowgmt - $cachedelay)) {
+				$foundintocache = 1;
+
+				$this->_lastfetchdate[get_class($this) . '_' . __FUNCTION__] = $filedate;
+			} else {
+				dol_syslog(get_class($this) . '::' . __FUNCTION__ . " cache file " . $newpathofdestfile . " is not found or older than now - cachedelay (" . $nowgmt . " - " . $cachedelay . ") so we can't use it.");
+			}
+		}
+
+		// Load file into $data
+		if ($foundintocache) // Cache file found and is not too old
+		{
+			dol_syslog(get_class($this) . '::' . __FUNCTION__ . " read data from cache file " . $newpathofdestfile . " " . $filedate . ".");
+			$data = dol_json_decode(file_get_contents($newpathofdestfile), true);
+		} else {
+			$year = $startyear;
+			while ( $year <= $endyear ) {
+				$datay[$year] = $this->getTransformRateByMonth($year);
+				$year ++;
+			}
+
+			$data = array ();
+			// $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
+			for($i = 0; $i < 12; $i ++) {
+				$data[$i][] = $datay[$endyear][$i][0]; // set label
+				$year = $startyear;
+				while ( $year <= $endyear ) {
+					$data[$i][] = $datay[$year][$i][1]; // set yval for x=i
+					$year ++;
+				}
+			}
+		}
+
+		// Save cache file
+		if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == - 1)) {
+			dol_syslog(get_class($this) . '::' . __FUNCTION__ . " save cache file " . $newpathofdestfile . " onto disk.");
+			if (! dol_is_dir($conf->user->dir_temp))
+				dol_mkdir($conf->user->dir_temp);
+			$fp = fopen($newpathofdestfile, 'w');
+			fwrite($fp, dol_json_encode($data));
+			fclose($fp);
+			if (! empty($conf->global->MAIN_UMASK))
+				$newmask = $conf->global->MAIN_UMASK;
+			@chmod($newpathofdestfile, octdec($newmask));
+
+			$this->_lastfetchdate[get_class($this) . '_' . __FUNCTION__] = $nowgmt;
+		}
+
+		return $data;
+	}
+
+	/**
+	 * Return the Project transformation rate by month for a year
+	 *
+	 * @param int $year scan
+	 * @return array with amount by month
+	 */
+	function getTransformRateByMonth($year) {
+		global $user;
+
+		$this->yearmonth = $year;
+
+		$sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)";
+		$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
+		if (! $user->rights->societe->client->voir && ! $user->societe_id)
+			$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
+		$sql .= $this->buildWhere();
+		$sql .= " GROUP BY dm";
+		$sql .= $this->db->order('dm', 'DESC');
+
+		$res_total = $this->_getNbByMonth($year, $sql);
+
+		$this->status=6;
+
+		$sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)";
+		$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
+		if (! $user->rights->societe->client->voir && ! $user->societe_id)
+			$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
+		$sql .= $this->buildWhere();
+		$sql .= " GROUP BY dm";
+		$sql .= $this->db->order('dm', 'DESC');
+
+		$this->status=0;
+		$this->yearmonth=0;
+
+		$res_only_wined = $this->_getNbByMonth($year, $sql);
+
+		$res=array();
+
+		foreach($res_total as $key=>$total_row) {
+			//var_dump($total_row);
+			if (!empty($total_row[1])) {
+				$res[$key]=array($total_row[0],(100*$res_only_wined[$key][1])/$total_row[1]);
+			} else {
+				$res[$key]=array($total_row[0],0);
+			}
+
+		}
+		// var_dump($res);print '<br>';
+		return $res;
+	}
+}
\ No newline at end of file
diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php
new file mode 100644
index 0000000000000000000000000000000000000000..fdb272ed70eb1ff7de0b98618db8d226523b8ed9
--- /dev/null
+++ b/htdocs/projet/stats/index.php
@@ -0,0 +1,367 @@
+<?php
+/* Lead
+ * Copyright (C) 2014-2015 Florian HENRY <florian.henry@open-concept.pro>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/projet/class/projectstats.class.php';
+
+// Security check
+if (! $user->rights->projet->lire)
+	accessforbidden();
+
+
+$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
+$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
+
+$userid=GETPOST('userid','int');
+$socid=GETPOST('socid','int');
+// Security check
+if ($user->societe_id > 0)
+{
+	$action = '';
+	$socid = $user->societe_id;
+}
+$nowyear=strftime("%Y", dol_now());
+$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
+//$startyear=$year-2;
+$startyear=$year-1;
+$endyear=$year;
+
+$langs->load('projects');
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+
+$includeuserlist=array();
+
+
+llxHeader('', $langs->trans('Projects'));
+
+$title=$langs->trans("ProjectsStatistics");
+$dir=$conf->projet->dir_output.'/temp';
+
+print_fiche_titre($title,'','title_project.png');
+
+dol_mkdir($dir);
+
+
+$stats_project= new ProjectStats($db);
+if (!empty($userid) && $userid!=-1) $stats_project->userid=$userid;
+if (!empty($socid)  && $socid!=-1) $stats_project->socid=$socid;
+if (!empty($year)) $stats_project->year=$year;
+
+
+
+if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+{
+	$data1 = $stats_project->getAllProjectByStatus();
+	if (!is_array($data1) && $data1<0) {
+		setEventMessages($stats_project->error, null, 'errors');
+	}
+	if (empty($data1))
+	{
+		$showpointvalue=0;
+		$nocolor=1;
+		$data1=array(array(0=>$langs->trans("None"),1=>1));
+	}
+
+	$filenamenb = $conf->project->dir_output . "/stats/projectbystatus.png";
+	$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&amp;file=projectbystatus.png';
+	$px = new DolGraph();
+	$mesg = $px->isGraphKo();
+	if (empty($mesg)) {
+		$i=0;$tot=count($data1);$legend=array();
+		while ($i <= $tot)
+		{
+			$data1[$i][0]=$data1[$i][0];	// Required to avoid error "Could not draw pie with labels contained inside canvas"
+			$legend[]=$data1[$i][0];
+			$i++;
+		}
+		$px->SetData($data1);
+		unset($data1);
+
+		if ($nocolor)
+			$px->SetDataColor(array (
+					array (
+							220,
+							220,
+							220
+					)
+			));
+			$px->SetPrecisionY(0);
+			$px->SetLegend($legend);
+			$px->setShowLegend(0);
+			$px->setShowPointValue($showpointvalue);
+			$px->setShowPercent(1);
+			$px->SetMaxValue($px->GetCeilMaxValue());
+			$px->SetWidth(300);
+			$px->SetHeight(300);
+			$px->SetShading(3);
+			$px->SetHorizTickIncrement(1);
+			$px->SetCssPrefix("cssboxes");
+			$px->SetType(array (
+					'pie'
+			));
+			$px->SetTitle($langs->trans('ProjectNbProjectByStatus'));
+			$result=$px->draw($filenamenb, $fileurlnb);
+			if ($result<0) {
+				setEventMessages($px->error, null, 'errors');
+			}
+	} else {
+		setEventMessages(null, $mesgs, 'errors');
+	}
+}
+
+
+// Build graphic number of object
+// $data = array(array('Lib',val1,val2,val3),...)
+$data = $stats_project->getNbByMonthWithPrevYear($endyear,$startyear);
+//var_dump($data);
+
+$filenamenb = $conf->project->dir_output . "/stats/projectnbprevyear-".$year.".png";
+$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&amp;file=projectnbprevyear-'.$year.'.png';
+
+$px1 = new DolGraph();
+$mesg = $px1->isGraphKo();
+if (! $mesg)
+{
+	$px1->SetData($data);
+	$px1->SetPrecisionY(0);
+	$i=$startyear;$legend=array();
+	while ($i <= $endyear)
+	{
+		$legend[]=$i;
+		$i++;
+	}
+	$px1->SetLegend($legend);
+	$px1->SetMaxValue($px1->GetCeilMaxValue());
+	$px1->SetWidth($WIDTH);
+	$px1->SetHeight($HEIGHT);
+	$px1->SetYLabel($langs->trans("ProjectNbProject"));
+	$px1->SetShading(3);
+	$px1->SetHorizTickIncrement(1);
+	$px1->SetPrecisionY(0);
+	$px1->mode='depth';
+	$px1->SetTitle($langs->trans("ProjectNbProjectByMonth"));
+
+	$px1->draw($filenamenb,$fileurlnb);
+}
+
+
+if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+{
+	// Build graphic amount of object
+	$data = $stats_project->getAmountByMonthWithPrevYear($endyear,$startyear);
+	//var_dump($data);
+	// $data = array(array('Lib',val1,val2,val3),...)
+
+	$filenamenb = $conf->project->dir_output . "/stats/projectamountprevyear-".$year.".png";
+	$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&amp;file=projectamountprevyear-'.$year.'.png';
+
+	$px2 = new DolGraph();
+	$mesg = $px2->isGraphKo();
+	if (! $mesg)
+	{
+		$px2->SetData($data);
+		$i=$startyear;$legend=array();
+		while ($i <= $endyear)
+		{
+			$legend[]=$i;
+			$i++;
+		}
+		$px2->SetLegend($legend);
+		$px2->SetMaxValue($px2->GetCeilMaxValue());
+		$px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
+		$px2->SetWidth($WIDTH);
+		$px2->SetHeight($HEIGHT);
+		$px2->SetYLabel($langs->trans("ProjectAmountOfProject"));
+		$px2->SetShading(3);
+		$px2->SetHorizTickIncrement(1);
+		$px2->SetPrecisionY(0);
+		$px2->mode='depth';
+		$px2->SetTitle($langs->trans("ProjectAmountOfProjectsByMonth"));
+
+		$px2->draw($filenamenb,$fileurlnb);
+	}
+}
+
+if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+{
+	// Build graphic with transformation rate
+	$data = $stats_project->getTransformRateByMonthWithPrevYear($endyear,$startyear);
+	//var_dump($data);
+	// $data = array(array('Lib',val1,val2,val3),...)
+
+	$filenamenb = $conf->project->dir_output . "/stats/projecttransrateprevyear-".$year.".png";
+	$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=projectstats&amp;file=projecttransrateprevyear-'.$year.'.png';
+
+	$px3 = new DolGraph();
+	$mesg = $px3->isGraphKo();
+	if (! $mesg)
+	{
+		$px3->SetData($data);
+		$i=$startyear;$legend=array();
+		while ($i <= $endyear)
+		{
+			$legend[]=$i;
+			$i++;
+		}
+		$px3->SetLegend($legend);
+		$px3->SetMaxValue($px3->GetCeilMaxValue());
+		$px3->SetMinValue(min(0,$px3->GetFloorMinValue()));
+		$px3->SetWidth($WIDTH);
+		$px3->SetHeight($HEIGHT);
+		$px3->SetYLabel($langs->trans("ProjectTransRateOfProject"));
+		$px3->SetShading(3);
+		$px3->SetHorizTickIncrement(1);
+		$px3->SetPrecisionY(0);
+		$px3->mode='depth';
+		$px3->SetTitle($langs->trans("ProjectTransRateOfProjectsByMonth"));
+
+		$px3->draw($filenamenb,$fileurlnb);
+	}
+}
+
+
+// Show array
+$stats_project->year=0;
+$data_all_year = $stats_project->getAllByYear();
+if (!empty($year)) $stats_project->year=$year;
+$arrayyears=array();
+foreach($data_all_year as $val) {
+	$arrayyears[$val['year']]=$val['year'];
+}
+if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
+
+
+$h=0;
+$head = array();
+$head[$h][0] = DOL_URL_ROOT . '/projet/stats/index.php?mode='.$mode;
+$head[$h][1] = $langs->trans("ByMonthYear");
+$head[$h][2] = 'byyear';
+$h++;
+
+complete_head_from_modules($conf,$langs,null,$head,$h,$type);
+
+dol_fiche_head($head,'byyear',$langs->trans("Statistics"), 0, '');
+
+
+print '<div class="fichecenter"><div class="fichethirdleft">';
+
+print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
+print '<table class="border" width="100%">';
+print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
+// Company
+print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
+if ($mode == 'customer') $filter='s.client in (1,2,3)';
+if ($mode == 'supplier') $filter='s.fournisseur = 1';
+print $form->select_company($socid,'socid',$filter,1);
+print '</td></tr>';
+// User
+/*print '<tr><td>'.$langs->trans("ProjectCommercial").'</td><td>';
+print $form->select_dolusers($userid, 'userid', 1, array(),0,$includeuserlist);
+print '</td></tr>';*/
+// Year
+print '<tr><td>'.$langs->trans("Year").'</td><td>';
+if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
+if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
+arsort($arrayyears);
+print $form->selectarray('year',$arrayyears,$year,0);
+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>';
+
+print '<table class="border" width="100%">';
+print '<tr height="24">';
+print '<td align="center">'.$langs->trans("Year").'</td>';
+print '<td align="center">'.$langs->trans("NbOfProjects").'</td>';
+if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+{
+	print '<td align="center">'.$langs->trans("AmountTotal").'</td>';
+	print '<td align="center">'.$langs->trans("AmountAverage").'</td>';
+}
+print '</tr>';
+
+$oldyear=0;
+foreach ($data_all_year as $val)
+{
+	$year = $val['year'];
+	while ($year && $oldyear > $year+1)
+	{	// If we have empty year
+		$oldyear--;
+		print '<tr height="24">';
+		print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&amp;mode='.$mode.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$oldyear.'</a></td>';
+		if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+		{
+			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="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$year.'</a></td>';
+	print '<td align="right">'.$val['nb'].'</td>';
+	if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+	{
+		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 '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
+
+$stringtoshow.= '<table class="border" width="100%"><tr valign="top"><td align="center">';
+if ($mesg) { print $mesg; }
+else {
+	if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+	{
+		$stringtoshow.= $px->show();
+		$stringtoshow.= "<br>\n";
+	}
+	$stringtoshow.= $px1->show();
+	$stringtoshow.= "<br>\n";
+	if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
+	{
+		$stringtoshow.= $px2->show();
+		$stringtoshow.= "<br>\n";
+		$stringtoshow.= $px3->show();
+	}
+}
+$stringtoshow.= '</td></tr></table>';
+
+print $stringtoshow;
+
+
+print '</div></div></div>';
+print '<div style="clear:both"></div>';
+
+
+llxFooter();
+$db->close();