diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php
index bda972dbf6312653731ffe580d0eafe446b00526..6c96938e22ea1eaa0c2d3d3580fc4ef77f358115 100644
--- a/htdocs/admin/commande.php
+++ b/htdocs/admin/commande.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2003-2006 Rodolphe Quiedeville	<rodolphe@quiedeville.org>
- * Copyright (C) 2004-2007 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
  * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
  * Copyright (C) 2004      Andre Cianfarani     <acianfa@free.fr>
@@ -19,15 +19,13 @@
  * 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$
  */
 
 /**
    \file       htdocs/admin/commande.php
    \ingroup    commande
    \brief      Page d'administration-configuration du module Commande
-   \version    $Revision$
+   \version    $Id$
 */
 
 require("./pre.inc.php");
@@ -45,6 +43,14 @@ if (!$user->admin)
 /*
  * Actions
  */
+ 
+if ($_POST["action"] == 'updateMask')
+{
+	$maskconstorder=$_POST['maskconstorder'];
+	$maskorder=$_POST['maskorder'];
+	if ($maskconstorder)  dolibarr_set_const($db,$maskconstorder,$maskorder);
+}
+
 if ($_GET["action"] == 'specimen')
 {
   $modele=$_GET["module"];
@@ -198,6 +204,10 @@ if ($handle)
 
             $module = new $file;
 
+			// Show modules according to features level
+		    if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+		    if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+
             $var=!$var;
             print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
             print $module->info();
@@ -219,13 +229,24 @@ if ($handle)
             
             $commande=new Commande($db);
 
-			     // Info
-			     $htmltooltip='';
+			// Info
+			$htmltooltip='';
+			$htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>';
+			$facture->type=0;
 	        $nextval=$module->getNextValue($mysoc,$commande);
-	        if ($nextval != $langs->trans("NotAvailable"))
-	        {
-	            $htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval;
-	        }
+			if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
+			{
+				$htmltooltip.='<b>'.$langs->trans("NextValue").'</b>: ';
+		        if ($nextval)
+				{
+					$htmltooltip.=$nextval.'<br>';
+				}
+				else
+				{
+					$htmltooltip.=$langs->trans($module->error).'<br>';
+				}
+			}
+
 	    	print '<td align="center">';
 	    	print $html->textwithhelp('',$htmltooltip,1,0);
 	    	print '</td>';
@@ -402,9 +423,9 @@ print '<td align="right"><input type="submit" class="button" value="'.$langs->tr
 print '</tr>';
 print '</form>';
 
-
-
 print '</table>';
 
+print '<br>';
+
 llxFooter('$Date$ - $Revision$');
 ?>
diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index 74a9430381f1ae2209bc91464bfc5c43892dbbf9..e0b13c7c2a3343cb2538e941d093aa502377abcf 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2007 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005      Eric Seigne          <eric.seigne@ryxeo.com>
  * Copyright (C) 2005-2007 Regis Houssin        <regis@dolibarr.fr>
  *
@@ -304,6 +304,7 @@ while (($file = readdir($handle))!==false)
 					$htmltooltip.=$langs->trans($module->error);
 				}
 			}
+			
 	    	print '<td align="center">';
 	    	print $html->textwithhelp('',$htmltooltip,1,0);
 	    	print '</td>';
diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php
index a173148bf7101194be860246aa28053f0dbe8f5b..d1dbb5d5193aca4eecfea043be1091c1f6a30183 100644
--- a/htdocs/admin/propale.php
+++ b/htdocs/admin/propale.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2007 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
  * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
  * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
@@ -19,16 +19,13 @@
  * 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/admin/propale.php
 		\ingroup    propale
 		\brief      Page d'administration/configuration du module Propale
-		\version    $Revision$
+		\version    $Id$
 */
 
 require("./pre.inc.php");
@@ -48,6 +45,13 @@ if (!$user->admin)
  * Actions
  */
 
+if ($_POST["action"] == 'updateMask')
+{
+	$maskconstpropal=$_POST['maskconstpropal'];
+	$maskpropal=$_POST['maskpropal'];
+	if ($maskconstpropal)  dolibarr_set_const($db,$maskconstpropal,$maskpropal);
+}
+
 if ($_GET["action"] == 'specimen')
 {
 	$modele=$_GET["module"];
@@ -231,6 +235,10 @@ if ($handle)
 
             $module = new $file;
 
+			// Show modules according to features level
+		    if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+		    if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+
             $var=!$var;
             print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
             print $module->info();
@@ -254,12 +262,22 @@ if ($handle)
 			     
 			// Info
 			$htmltooltip='';
-	        $htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>';
-			$nextval=$module->getNextValue($mysoc,$propale);
-	        if ($nextval != $langs->trans("NotAvailable"))
-	        {
-	            $htmltooltip.='<b>'.$langs->trans("NextValue").'</b>: '.$nextval;
-	        }
+			$htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>';
+			$facture->type=0;
+	        $nextval=$module->getNextValue($mysoc,$propale);
+			if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
+			{
+				$htmltooltip.='<b>'.$langs->trans("NextValue").'</b>: ';
+		        if ($nextval)
+				{
+					$htmltooltip.=$nextval.'<br>';
+				}
+				else
+				{
+					$htmltooltip.=$langs->trans($module->error).'<br>';
+				}
+			}
+
 	    	print '<td align="center">';
 	    	print $html->textwithhelp('',$htmltooltip,1,0);
 	    	print '</td>';
diff --git a/htdocs/includes/modules/commande/mod_commande_marbre.php b/htdocs/includes/modules/commande/mod_commande_marbre.php
index d6aeaca9a7f2775a624d087e0ee8e427e7394e5f..894fc73090c33c1bf1b84dd998cb5cf29b99fa85 100644
--- a/htdocs/includes/modules/commande/mod_commande_marbre.php
+++ b/htdocs/includes/modules/commande/mod_commande_marbre.php
@@ -16,16 +16,13 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  * or see http://www.gnu.org/
- *
- * $Id$
- * $Source$
  */
 
 /**
      	\file       htdocs/includes/modules/commande/mod_commande_marbre.php
 		\ingroup    commande
 		\brief      Fichier contenant la classe du mod�le de num�rotation de r�f�rence de commande Marbre
-		\version    $Revision$
+		\version    $Id$
 */
 
 require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php");
@@ -36,17 +33,11 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php
 
 class mod_commande_marbre extends ModeleNumRefCommandes
 {
+	var $version='dolibarr';		// 'development', 'experimental', 'dolibarr'
 	var $prefix='CO';
     var $error='';
-    
-	/*
-	 *   \brief      Constructeur
-   	 */
-  	function mod_commande_marbre()
-    {
-    	$this->nom = "Marbre";
-    }
-
+    var $nom='Marbre';
+	
     
     /**     \brief      Renvoi la description du modele de num�rotation
      *      \return     string      Texte descripif
@@ -92,10 +83,12 @@ class mod_commande_marbre extends ModeleNumRefCommandes
         return true;
     }
 
-    /**     \brief      Renvoi prochaine valeur attribu�e
-     *      \return     string      Valeur
-     */
-    function getNextValue()
+	/**		\brief      Return next value
+	*      	\param      objsoc      Objet third party
+	*		\param		commande	Object order
+	*      	\return     string      Value if OK, 0 if KO
+	*/
+    function getNextValue($objsoc=0,$commande)
     {
         global $db;
 
diff --git a/htdocs/includes/modules/commande/mod_commande_saphir.php b/htdocs/includes/modules/commande/mod_commande_saphir.php
index e9d401a945c3aa9772007078387664dd1be80e20..2ceecf8d434bc3e1c074bbd02b819db43164756b 100644
--- a/htdocs/includes/modules/commande/mod_commande_saphir.php
+++ b/htdocs/includes/modules/commande/mod_commande_saphir.php
@@ -17,103 +17,58 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  * or see http://www.gnu.org/
- *
- * $Id$
- * $Source$
- *
  */
 
 /**
 	\file       htdocs/includes/modules/commande/mod_commande_saphir.php
 	\ingroup    commande
 	\brief      Fichier contenant la classe du mod�le de num�rotation de r�f�rence de commande Saphir
-	\version    $Revision$
+	\version    $Id$
 */
 
 require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php");
 
+
 /**
 	\class      mod_commande_saphir
 	\brief      Classe du mod�le de num�rotation de r�f�rence de commande Saphir
 */
 class mod_commande_saphir extends ModeleNumRefCommandes
 {
-	var $prefix;
-	var $matrice;
-	var $numMatrice = Array();
-	var $yy;
-	var $mm;
-	var $numbitcounter;
-	var $searchLast;
-  var $searchLastWithNoYear;
-  var $searchLastWithPreviousYear;
+	var $version='dolibarr';		// 'development', 'experimental', 'dolibarr'
 	var $error = '';
-	
-	/**   \brief      Constructeur
-   */
-  function mod_commande_saphir()
-  {
-    $this->nom = "Saphir";
-  }
+	var $nom = 'Saphir';
 
+	
     /**     \brief      Renvoi la description du modele de num�rotation
      *      \return     string      Texte descripif
      */
-function info()
+	function info()
     {
     	global $conf,$langs;
 
-		  $langs->load("bills");
+		$langs->load("bills");
 		  
-		  $form = new Form($db);
+		$form = new Form($db);
     	
-      $texte = $langs->trans('SaphirNumRefModelDesc1')."<br>\n";
-      $texte.= '<table class="nobordernopadding" width="100%">';
-      
-      // Param�trage de la matrice
-      $texte.= '<tr><td>Matrice de disposition des objets (prefix,mois,ann�e,compteur...)</td>';
-      $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
-      $texte.= '<input type="hidden" name="action" value="updateMatrice">';
-      $texte.= '<td align="right"><input type="text" class="flat" size="30" name="matrice" value="'.$conf->global->COMMANDE_NUM_MATRICE.'"></td>';
-      $texte.= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
-      $texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("MatriceOrderDesc"),1,1).'</td>';
-      $texte.= '</tr></form>';
-      
-      // Param�trage du prefix des commandes
-      $texte.= '<tr><td>Pr�fix des commandes</td>';
-      $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
-      $texte.= '<input type="hidden" name="action" value="updatePrefix">';
-      $texte.= '<td align="right"><input type="text" class="flat" size="30" name="prefix" value="'.$conf->global->COMMANDE_NUM_PREFIX.'"></td>';
-      $texte.= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
-      $texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("PrefixOrderDesc"),1,1).'</td>';
-      $texte.= '</tr></form>';
-      
-      // On d�termine un offset sur le compteur
-      $texte.= '<tr><td>Appliquer un offset sur le compteur</td>';
-      $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
-      $texte.= '<input type="hidden" name="action" value="setOffset">';
-      $texte.= '<td align="right"><input type="text" class="flat" size="30" name="offset" value="'.$conf->global->COMMANDE_NUM_DELTA.'"></td>';
-      $texte.= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
-      $texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("OffsetDesc"),1,1).'</td>';
-      $texte.= '</tr></form>';
-   
-      // On d�fini si le compteur se remet � zero en debut d'ann�e
-      $texte.= '<tr><td>Le compteur se remet � z�ro en d�but d\'ann�e</td>';
-      $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
-      $texte.= '<input type="hidden" name="action" value="setNumRestart">';
-      $texte.= '<td align="right">';
-      $texte.= $form->selectyesno('numrestart',$conf->global->COMMANDE_NUM_RESTART_BEGIN_YEAR,1);
-      $texte.= '</td><td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
-      $texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("NumRestartDesc"),1,1).'</td>';
-      $texte.= '</tr></form>';
-      
-      // On affiche le debut d'ann�e fiscale
-      $texte.= '<tr><td>D�but d\'ann�e fiscale : '.monthArrayOrSelected($conf->global->SOCIETE_FISCAL_MONTH_START).'</td>';
-      $texte.= '</tr>';
-      
-      $texte.= '</table><br>';
+		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
+		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+		$texte.= '<input type="hidden" name="action" value="updateMask">';
+		$texte.= '<input type="hidden" name="maskconstpropal" value="COMMANDE_SAPHIR_MASK">';
+		$texte.= '<table class="nobordernopadding" width="100%">';
+		
+		// Parametrage du prefix des factures
+		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
+		$texte.= '<td align="right">'.$form->textwithhelp('<input type="text" class="flat" size="24" name="maskpropal" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">',$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"),$langs->transnoentities("Order")),1,1).'</td>';
+
+		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
+
+		$texte.= '</tr>';
+		
+		$texte.= '</table>';
+		$texte.= '</form>';
 
-      return $texte;
+		return $texte;
     }
 
     /**     \brief      Renvoi un exemple de num�rotation
@@ -121,119 +76,128 @@ function info()
      */
     function getExample()
     {
-    	global $conf,$langs;
+     	global $conf,$langs,$mysoc;
     	
-    	$numExample = '';
-      
-      //On construit la matrice
-      $buildResult = $this->buildMatrice();
+    	$numExample = $this->getNextValue($mysoc,$propalspecimen);
         
-      if ($buildResult == 1)
-      {
-      	// On r�cup�re le nombre de chiffres du compteur
-    	  $arg = '%0'.$this->numbitcounter.'s';
-        $num = sprintf($arg,$conf->global->COMMANDE_NUM_DELTA?$conf->global->COMMANDE_NUM_DELTA:1);
-      	
-      	//On construit le num�ro � partir de la matrice
-      	foreach($this->numMatrice as $objetMatrice)
-        {
-        	if ($objetMatrice == '-') $numExample .= $objetMatrice;
-        	if ($objetMatrice == '$prefix') $numExample .= $this->prefix;
-        	if ($objetMatrice == '$yy') $numExample .= $this->yy;
-        	if ($objetMatrice == '$mm') $numExample .= $this->mm;
-        	if ($objetMatrice == '$num') $numExample .= $num;
-        }
-    	}
-      else
-      {
-      	$numExample = $langs->trans('NotConfigured');
-      }
-      return $numExample;
+		if (! $numExample)
+		{
+			$numExample = $langs->trans('NotConfigured');
+		}
+		return $numExample;
     }
 
- /**		\brief      Renvoi prochaine valeur attribu�e
-	*      	\param      objsoc      Objet soci�t�
-	*      	\return     string      Valeur
+	/**		\brief      Return next value
+	*      	\param      objsoc      Objet third party
+	*		\param		commande	Object order
+	*      	\return     string      Value if OK, 0 if KO
 	*/
     function getNextValue($objsoc=0,$commande)
     {
-        global $db,$conf;
-        
-        //On construit la matrice
-        $buildResult = $this->buildMatrice($objsoc,$commande);
-        
-        if ($buildResult == 1)
-        {
-        	// On r�cup�re la valeur max (r�ponse imm�diate car champ ind�x�)
-          $posindice  = $this->numbitcounter;
-          $searchyy='';
-          $sql = "SELECT MAX(ref)";
-          $sql.= " FROM ".MAIN_DB_PREFIX."commande";
-          if ($conf->global->COMMANDE_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref REGEXP '^".$this->searchLast."'";
-          $resql=$db->query($sql);
-          if ($resql)
-          {
-            $row = $db->fetch_row($resql);
-            if ($row) $searchyy = substr($row[0],0,-$posindice);
-          }
-          if ($conf->global->COMMANDE_NUM_DELTA != '')
-          {
-        	  //on v�rifie si il y a une ann�e pr�c�dente
-            //pour �viter que le delta soit appliqu� de nouveau sur la nouvelle ann�e
-            $previousyy='';
-            $sql = "SELECT MAX(ref)";
-            $sql.= " FROM ".MAIN_DB_PREFIX."commande";
-            $sql.= " WHERE ref REGEXP '^".$this->searchLastWithPreviousYear."'";
-            $resql=$db->query($sql);
-            if ($resql)
-            {
-              $row = $db->fetch_row($resql);
-              if ($row) $previousyy = substr($row[0],0,-$posindice);
-            }
-          }
+		global $db,$conf;
 
-        // Si au moins un champ respectant le mod�le a �t� trouv�e
-        if (eregi('^'.$this->searchLastWithNoYear.'',$searchyy))
-        {
-            // Recherche rapide car restreint par un like sur champ index�
-            $sql = "SELECT MAX(0+SUBSTRING(ref,-".$posindice."))";
-            $sql.= " FROM ".MAIN_DB_PREFIX."commande";
-            $sql.= " WHERE ref REGEXP '^".$searchyy."'";
-            $resql=$db->query($sql);
-            if ($resql)
-            {
-                $row = $db->fetch_row($resql);
-                $max = $row[0];
-            }
-        }
-        else if ($conf->global->COMMANDE_NUM_DELTA != '' && !eregi('^'.$this->searchLastWithPreviousYear.'',$previousyy))
-        {
-        	// on applique le delta une seule fois
-        	$max=$conf->global->COMMANDE_NUM_DELTA?$conf->global->COMMANDE_NUM_DELTA-1:0;
-        }
-        else
-        {
-        	$max=0;
-        }
-    	  
-    	  // On applique le nombre de chiffres du compteur
-        $arg = '%0'.$this->numbitcounter.'s';
-        $num = sprintf($arg,$max+1);
-        $numFinal = '';
-        
-        foreach($this->numMatrice as $objetMatrice)
-        {
-        	if ($objetMatrice == '-') $numFinal .= $objetMatrice;
-        	if ($objetMatrice == '$prefix') $numFinal .= $this->prefix;
-        	if ($objetMatrice == '$yy') $numFinal .= $this->yy;
-        	if ($objetMatrice == '$mm') $numFinal .= $this->mm;
-        	if ($objetMatrice == '$num') $numFinal .= $num;
-        } 
-        
-        dolibarr_syslog("mod_commande_saphir::getNextValue return ".$numFinal);
-        return  $numFinal;
-    }
-  }
+		// On d�fini critere recherche compteur
+		$mask=$conf->global->COMMANDE_SAPHIR_MASK;
+		
+		if (! $mask) 
+		{
+			$this->error='NotConfigured';
+			return 0;
+		}
+
+		// Extract value for mask counter, mask raz and mask offset
+		if (! eregi('\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}',$mask,$reg)) return 'ErrorBadMask';
+		$masktri=$reg[1].$reg[2].$reg[3];
+		$maskcounter=$reg[1];
+		$maskraz=-1;
+		$maskoffset=0;
+		if (strlen($maskcounter) < 3) return 'CounterMustHaveMoreThan3Digits';
+	
+		$maskwithonlyymcode=$mask;
+		$maskwithonlyymcode=eregi_replace('\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}',$maskcounter,$maskwithonlyymcode);
+		$maskwithonlyymcode=eregi_replace('\{dd\}','dd',$maskwithonlyymcode);
+		$maskwithnocode=$maskwithonlyymcode;
+		$maskwithnocode=eregi_replace('\{yyyy\}','yyyy',$maskwithnocode);
+		$maskwithnocode=eregi_replace('\{yy\}','yy',$maskwithnocode);
+		$maskwithnocode=eregi_replace('\{y\}','y',$maskwithnocode);
+		$maskwithnocode=eregi_replace('\{mm\}','mm',$maskwithnocode);
+		//print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>";
+
+		// If an offset is asked
+		if (! empty($reg[2]) && eregi('^\+',$reg[2])) $maskoffset=eregi_replace('^\+','',$reg[2]);
+		if (! empty($reg[3]) && eregi('^\+',$reg[3])) $maskoffset=eregi_replace('^\+','',$reg[3]);
+
+		// If a restore to zero after a month is asked we check if there is already a value for this year.
+		if (! empty($reg[2]) && eregi('^@',$reg[2]))  $maskraz=eregi_replace('^@','',$reg[2]);
+		if (! empty($reg[3]) && eregi('^@',$reg[3])) $maskraz=eregi_replace('^@','',$reg[3]);
+		if ($maskraz >= 0)
+		{
+			if ($maskraz > 12) return 'ErrorBadMask';
+			if ($maskraz > 1 && ! eregi('^(.*)\{(y+)\}\{(m+)\}',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
+			if ($maskraz <= 1 && ! eregi('^(.*)\{(y+)\}',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazIfNoYearInMask';
+			//print "x".$maskwithonlyymcode." ".$maskraz;
+
+			// Define $yearcomp and $monthcomp (that will be use de filter request to search max number)
+			$monthcomp=$maskraz;
+			$yearoffset=0;
+			$yearcomp=0;
+			if (date("m") < $maskraz) { $yearoffset=-1; }	// If current month lower that month of return to zero, year is previous year
+			if (strlen($reg[2]) == 4) $yearcomp=sprintf("%04d",date("Y")+$yearoffset);
+			if (strlen($reg[2]) == 2) $yearcomp=sprintf("%02d",date("y")+$yearoffset);
+			if (strlen($reg[2]) == 1) $yearcomp=substr(date("y"),2,1)+$yearoffset;
+			
+			$sqlwhere='';
+			$sqlwhere.='SUBSTRING(facnumber, '.(strlen($reg[1])+1).', '.strlen($reg[2]).') >= '.$yearcomp;
+			if ($monthcomp > 1)	// Test useless if monthcomp = 1 (or 0 is same as 1)
+			{
+				$sqlwhere.=' AND SUBSTRING(facnumber, '.(strlen($reg[1])+strlen($reg[2])+1).', '.strlen($reg[3]).') >= '.$monthcomp;
+			}
+		}
+		//print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n";
+		
+		$posnumstart=strpos($maskwithnocode,$maskcounter);	// Pos of counter in final string (from 0 to ...)
+		if ($posnumstart < 0) return 'ErrorBadMask';
+		$sqlstring='SUBSTRING(facnumber, '.($posnumstart+1).', '.strlen($maskcounter).')';
+		//print "x".$sqlstring;
+		
+		// Get counter in database
+		$counter=0;
+		$sql = "SELECT MAX(".$sqlstring.") as val";
+		$sql.= " FROM ".MAIN_DB_PREFIX."commande";
+		$sql.= " WHERE ref not like '(%'";
+		if ($sqlwhere) $sql.=' AND '.$sqlwhere;
+		
+		//print $sql;
+		dolibarr_syslog("mod_commande_saphir::getNextValue sql=".$sql, LOG_DEBUG);
+		$resql=$db->query($sql);
+		if ($resql)
+		{
+			$obj = $db->fetch_object($resql);
+			$counter = $obj->val;
+		}
+		else dolibarr_print_error($db);
+		if (empty($counter) || eregi('[^0-9]',$counter)) $counter=$maskoffset;
+		$counter++;
+		
+		// Build numFinal
+		$numFinal = $mask;
+		
+		// We replace special codes
+		$numFinal = str_ireplace('{yyyy}',date("Y"),$numFinal);
+		$numFinal = str_ireplace('{yy}',date("y"),$numFinal);
+		$numFinal = str_ireplace('{y}' ,substr(date("y"),2,1),$numFinal);
+		$numFinal = str_ireplace('{mm}',date("m"),$numFinal);
+		$numFinal = str_ireplace('{dd}',date("d"),$numFinal);
+
+		// Now we replace the counter
+		$maskbefore='{'.$masktri.'}';
+		$maskafter=str_pad($counter,strlen($maskcounter),"0",STR_PAD_LEFT);
+		//print 'x'.$maskbefore.'-'.$maskafter.'y';
+		$numFinal = str_ireplace($maskbefore,$maskafter,$numFinal);
+		
+		dolibarr_syslog("mod_commande_saphir::getNextValue return ".$numFinal);
+		return  $numFinal;
+	}
     
   
     /**     \brief      Renvoie la r�f�rence de commande suivante non utilis�e
@@ -246,154 +210,6 @@ function info()
         return $this->getNextValue($objsoc,$commande);
     }
 
-  
- /**		\brief      Construction de la matrice de num�rotation
-	*     \param      objsoc      Objet soci�t�
-	*     \return     string      Valeur
-	*/
-    function buildMatrice($objsoc=0,$commande='')
-    {
-        global $conf;
-        
-        $this->prefix  = $conf->global->COMMANDE_NUM_PREFIX;
-        $this->matrice = $conf->global->COMMANDE_NUM_MATRICE;
-        $this->searchLast = '';
-        $this->searchLastWithNoYear = '';
-        $this->searchLastWithPreviousYear = '';
-        
-        if ($this->matrice != '')
-        {
-        	$resultatMatrice = Array();
-        	
-        	$matricePrefix   = "PREF|COM"; // PREF : prefix libre (ex: C pour commande), COM : prefix du client
-        	$matriceYear     = "[A]{2,4}"; // l'ann�e est sur 2 ou 4 chiffres
-        	$matriceMonth    = "[M]{2}"; // le mois est sur 2 chiffres
-        	$matriceCounter  = "[C]{1,}"; //le compteur a un nombre de chiffres libre
-        	$matriceTiret    = "[-]{1}"; // on recherche si il y a des tirets de s�paration
-        	
-        	$matriceSearch   = Array('prefix'=>$matricePrefix,
-        	                         'year'=>$matriceYear,
-        	                         'month'=>$matriceMonth,
-        	                         'counter'=>$matriceCounter
-        	                         );
-        	
-        	// on d�termine l'emplacement des tirets
-        	$resultTiret = preg_split('/'.$matriceTiret.'/',$this->matrice, -1, PREG_SPLIT_OFFSET_CAPTURE);
-        	
-        	$j = 0;
-        	$k = 0;
-        	
-        	// on d�termine les objets de la matrice
-        	for ($i = 0; $i < count($resultTiret); $i++)
-        	{
-        		foreach($resultTiret[$i] as $idResultTiret => $valueResultTiret)
-        		{
-        			// Ajout des tirets
-        		  if ($j != $resultTiret[$i][1])
-        		  {
-        		  	$this->numMatrice[$k] = '-';
-        		  	$this->searchLast .= '-';
-        		  	$this->searchLastWithNoYear .= '-';
-        		  	$this->searchLastWithPreviousYear .= '-';
-        		  	$j = $resultTiret[$i][1];
-        		  	$k++;
-        		  }
-        			foreach($matriceSearch as $idMatrice => $valueMatrice)
-        			{
-        			$resultCount = eregi(''.$valueMatrice.'',$valueResultTiret,$resultatMatrice);
-        			if ($resultCount)
-        			{
-        				// On r�cup�re le pr�fix utilis�
-        				if ($idMatrice == 'prefix')
-        				{
-        					if ($resultatMatrice[0] == 'COM')
-        					{
-        						if ($objsoc->prefix_comm)
-        						{
-        							$this->prefix = $objsoc->prefix_comm;
-        						}
-        						else
-        					  {
-        						  $this->prefix = 'COM';
-        					  }
-        					  $this->numMatrice[$k] = '$prefix';
-        					  $this->searchLast .= $this->prefix;
-        					  $this->searchLastWithNoYear .= $this->prefix;
-        					  $this->searchLastWithPreviousYear .= $this->prefix;
-        					  $k++;
-        					}
-        					else if ($resultatMatrice[0] == 'PREF')
-        				  {
-        					  $this->numMatrice[$k] = '$prefix';
-        					  $this->searchLast .= $this->prefix;
-        					  $this->searchLastWithNoYear .= $this->prefix;
-        					  $this->searchLastWithPreviousYear .= $this->prefix;
-        					  $k++;
-        					}
-        				}
-        				else if ($idMatrice == 'year')
-        				{
-        					// On r�cup�re le nombre de chiffres pour l'ann�e
-        					$numbityear = $resultCount;
-        					// On d�fini le mois du d�but d'ann�e fiscale
-        					$current_month = date("n");
-        					
-        					if (is_object($commande) && $commande->date)
-                  {
-        	          $create_month = strftime("%m",$commande->date);
-                  }
-                  else
-                  {
-        	          $create_month = $current_month;
-                  }
-
-                  // On change d'ann�e fiscal si besoin
-                  if($conf->global->SOCIETE_FISCAL_MONTH_START > 1 && $current_month >= $conf->global->SOCIETE_FISCAL_MONTH_START && $create_month >= $conf->global->SOCIETE_FISCAL_MONTH_START)
-                  {
-        	          $this->yy = substr(strftime("%Y",dolibarr_mktime(0,0,0,date("m"),date("d"),date("Y")+1)),$numbityear);
-                  }
-                  else
-                  {
-        	          $this->yy = substr(strftime("%Y",time()),$numbityear);
-                  }
-        					$this->numMatrice[$k] = '$yy';
-        					$this->searchLast .= $this->yy;
-        					for ($l = 1; $l <= $numbityear; $l++)
-        					{
-        						$this->searchLastWithNoYear .= '[0-9]';
-        					}
-        					$previousYear = substr(strftime("%Y",dolibarr_mktime(0,0,0,date("m"),date("d"),date("Y")-1)),$numbityear);
-        					$this->searchLastWithPreviousYear .= $previousYear;
-        					$k++;
-        				}
-        				else if ($idMatrice == 'month')
-        				{
-        					// On r�cup�re le mois si besoin
-        					$this->mm = strftime("%m",time());
-        					$this->numMatrice[$k] = '$mm';
-        					$this->searchLast .= '[0-9][0-9]';
-        					$this->searchLastWithNoYear .= '[0-9][0-9]';
-        					$this->searchLastWithPreviousYear .= '[0-9][0-9]';
-        					$k++;
-        				}
-        				else if ($idMatrice == 'counter')
-        				{
-        					// On r�cup�re le nombre de chiffres pour le compteur
-        					$this->numbitcounter = $resultCount;
-        					$this->numMatrice[$k] = '$num';
-        					$k++;
-        				}
-        			}
-        		}
-        	}
-        }
-        return 1;
-      }
-      else
-      {
-      	return -3;
-      }
-    }
 }    
 
 ?>
\ No newline at end of file
diff --git a/htdocs/includes/modules/facture/mercure/mercure.modules.php b/htdocs/includes/modules/facture/mercure/mercure.modules.php
index e97a84eedf902e5ce26f29e3e97c7974d2e46959..9c4b842d1824840ea4c65050e89a1fcc1704fc77 100644
--- a/htdocs/includes/modules/facture/mercure/mercure.modules.php
+++ b/htdocs/includes/modules/facture/mercure/mercure.modules.php
@@ -36,18 +36,9 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php")
 class mod_facture_mercure extends ModeleNumRefFactures
 {
 	var $version='dolibarr';		// 'development', 'experimental', 'dolibarr'
-	var $prefixinvoice;
-	var $prefixcreditnote;
-	var $matrice;
-	var $numMatrice = Array();
-	var $yy;
-	var $mm;
-	var $numbitcounter;
-	var $searchLast;
-	var $searchLastWithNoYear;
-	var $searchLastWithPreviousYear;
 	var $error = '';
 
+	
     /**     \brief      Renvoi la description du modele de numerotation
      *      \return     string      Texte descripif
      */
@@ -59,7 +50,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
 		
 		$form = new Form($db);
 		
-		$texte = $langs->trans('MercureNumRefModelDesc1')."<br>\n";
+		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
 		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
 		$texte.= '<input type="hidden" name="action" value="updateMask">';
 		$texte.= '<input type="hidden" name="maskconstinvoice" value="FACTURE_MERCURE_MASK_INVOICE">';
@@ -67,18 +58,16 @@ class mod_facture_mercure extends ModeleNumRefFactures
 		$texte.= '<table class="nobordernopadding" width="100%">';
 		
 		// Parametrage du prefix des factures
-		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')</td>';
-		//      $texte.= '<td align="right"><input type="text" class="flat" size="24" name="prefixfacture" value="'.$conf->global->FACTURE_NUM_PREFIX.'"></td>';
-		$texte.= '<td align="right">'.$form->textwithhelp('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->FACTURE_MERCURE_MASK_INVOICE.'">',$langs->trans("MercureMaskCodes"),1,1).'</td>';
+		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'):</td>';
+		$texte.= '<td align="right">'.$form->textwithhelp('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->FACTURE_MERCURE_MASK_INVOICE.'">',$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")),1,1).'</td>';
 
 		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
 
 		$texte.= '</tr>';
 		
 		// Parametrage du prefix des avoirs
-		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").')</td>';
-		//$texte.= '<td align="right"><input type="text" class="flat" size="24" name="prefixavoir" value="'.$conf->global->AVOIR_NUM_PREFIX.'"></td>';
-		$texte.= '<td align="right">'.$form->textwithhelp('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->FACTURE_MERCURE_MASK_CREDIT.'">',$langs->trans("MercureMaskCodes"),1,1).'</td>';
+		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
+		$texte.= '<td align="right">'.$form->textwithhelp('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->FACTURE_MERCURE_MASK_CREDIT.'">',$langs->trans("MercureMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")),1,1).'</td>';
 		$texte.= '</tr>';
 		
 		$texte.= '</table>';
@@ -94,7 +83,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
     {
     	global $conf,$langs,$mysoc;
     	
-    	$numExample = $this->getNextValue($mysoc,$facture);
+    	$numExample = $this->getNextValue($mysoc,$facturespecimen);
         
 		if (! $numExample)
 		{
@@ -230,5 +219,4 @@ class mod_facture_mercure extends ModeleNumRefFactures
     }
     
 }    
-
 ?>
\ No newline at end of file
diff --git a/htdocs/includes/modules/propale/mod_propale_saphir.php b/htdocs/includes/modules/propale/mod_propale_saphir.php
index 96ac0b776651f0e78bb82117ec492aa1fa1b3bc1..1231ba9094df8a322b38386215c31ddc7e0b086f 100644
--- a/htdocs/includes/modules/propale/mod_propale_saphir.php
+++ b/htdocs/includes/modules/propale/mod_propale_saphir.php
@@ -51,7 +51,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
 		  
 		$form = new Form($db);
     	
-		$texte = $langs->trans('SaphirNumRefModelDesc1')."<br>\n";
+		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
 		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
 		$texte.= '<input type="hidden" name="action" value="updateMask">';
 		$texte.= '<input type="hidden" name="maskconstpropal" value="PROPALE_SAPHIR_MASK">';
@@ -89,10 +89,10 @@ class mod_propale_saphir extends ModeleNumRefPropales
 
 	/**		\brief      Return next value
 	*      	\param      objsoc      Object third party
-	*      	\param      facture		Object invoice
+	*      	\param      propal		Object proposal
 	*      	\return     string      Value if OK, 0 if KO
 	*/
-	function getNextValue($objsoc,$facture)
+	function getNextValue($objsoc,$propal)
 	{
 		global $db,$conf;
 
@@ -163,14 +163,12 @@ class mod_propale_saphir extends ModeleNumRefPropales
 		// Get counter in database
 		$counter=0;
 		$sql = "SELECT MAX(".$sqlstring.") as val";
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture";
-		$sql.= " WHERE facnumber not like '(%'";
-		if ($facture->type == 2) $sql.= " AND type = 2";
-		else $sql.=" AND type != 2";
+		$sql.= " FROM ".MAIN_DB_PREFIX."propal";
+		$sql.= " WHERE ref not like '(%'";
 		if ($sqlwhere) $sql.=' AND '.$sqlwhere;
 		
 		//print $sql;
-		dolibarr_syslog("mod_facture_mercure::getNextValue sql=".$sql, LOG_DEBUG);
+		dolibarr_syslog("mod_propale_saphir::getNextValue sql=".$sql, LOG_DEBUG);
 		$resql=$db->query($sql);
 		if ($resql)
 		{
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index af28f6d76ca2bb0d6b57507256fb76986e6a5e30..61f32a858713b27640e3232bb307104252c57c16 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -186,6 +186,9 @@ SetupIsReadyForUse=Install is finished and Dolibarr is ready for use with new co
 CurrentVersion=Dolibarr current version
 CallUpdatePage=Go on page that update database structure and datas %s.
 LastStableVersion=Last stable version
+GenericMaskCodes=You may enter all mask of numbering.  In this mask, the following tags could be used:<br><b>{000000}</b> correspond to a number which will be incremented on each %s. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros at the left in order to have as many zeros as the mask. <br><b>{000000+000}</b> same as previous but a corresponding offset to the number to the right of + is applied beginning by first %s. <br><b>{000000@x}</b> same as previous but counter is reset to zero when month x is reached (x between 1 and 12). If this option is used, tag {yy} is required and also {mm} if x is 2 or higher. <br><b>{dd}</b> invoice day (01 � 31).<br><b>{mm}</b> invoice month (01 � 12).<br><b>{yy}</b> or <b>{yyyy}</b> or <b>{y}</b> year over 2 or 4 numbers of the invoice.<br>All other characters in the mask will remain intact.<br>Spaces are not allowed.<br><br><u>Example on the 99th %s of the third party TheCompany done 31/01/2007:</u><br><b>ABC{yy}{mm}-{000000}</b> will give <b>ABC0701-000099</b><br><b>{0000+100}-ZZZ/{dd}/XXX</b> will give <b>0199-ZZZ/31/XXX</b><br>
+GenericNumRefModelDesc=Return a customizable number according to a defined mask. 
+
 # Modules
 Module0Name=Users & groups
 Module0Desc=Users and groups management
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index b91b693e30543afd96d3d64024c4a77051d2e859..a2685d3b0d00bfb7568a90e9e62bf8ebf9a40436 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -341,10 +341,6 @@ PDFTourteauDescription=Invoice model Tourteau
 DefinedAndHasThisValue=Defined and value to
 IsNotDefined=undefined
 
-# mercure
-MercureNumRefModelDesc1=Return a customizable invoice number according to a defined mask. 
-MercureMaskCodes=You may enter all mask of numbering.  In this mask, the following tags could be used:<br><b>{000000}</b> correspond to a number which will be incremented on each invoice. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros at the left in order to have as many zeros as the mask. <br><b>{000000+000}</b> same as previous but a corresponding offset to the number to the right of + is applied beginning by first invoice. <br><b>{000000@x}</b> same as previous but counter is reset to zero when month x is reached (x between 1 and 12). If this option is used, tag {yy} is required and also {mm} if x is 2 or higher. <br><b>{dd}</b> invoice day (01 � 31).<br><b>{mm}</b> invoice month (01 � 12).<br><b>{yy}</b> or <b>{yyyy}</b> or <b>{y}</b> year over 2 or 4 numbers of the invoice.<br>All other characters in the mask will remain intact.<br>Spaces are not allowed.<br><br><u>Example on the 99th invoice of the third party TheCompany done 31/01/2007:</u><br><b>ABC{yy}{mm}-{000000}</b> will give <b>ABC0701-000099</b><br><b>{0000+100}-ZZZ/{dd}/XXX</b> will give <b>0199-ZZZ/31/XXX</b><br>
-# terre
 TerreNumRefModelDesc1=Return numero with format %syymm-nnnn for standard invoices and %syymm-nnnn for credit notes where yy is year, mm is month and nnnn is a sequence with no break and no return to 0
 TerreNumRefModelError=A bill starting with $syymm already exists and is not compatible with this model of sequence. Remove it or rename it to activate this module.
 
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 25daad40cd60e0e539fcc52b21ea4f59f4201ff2..b7acb57792ee9698a88bd78039ebd45841faadfe 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -185,6 +185,9 @@ SetupIsReadyForUse=L'installation est termin
 CurrentVersion=Version en cours de Dolibarr
 CallUpdatePage=Appeler la page de mise a jour de la structure et donn�es de la base %s.
 LastStableVersion=Derni�re version stable
+GenericMaskCodes=Vous pouvez saisir tout masque de num�rotation. Dans ce masque, les balises suivantes peuvent etre utilis�es:<br><b>{000000}</b> correspond a un num�ro qui sera incr�ment� � chaque %s. Mettre autant de z�ro que la longueur d�sir�e du compteur. Le compteur sera compl�t� par des 0 � gauche afin d'avoir autant de z�ro que dans le masque.<br><b>{000000+000}</b> idem pr�c�demment mais un offset correpondant au nombre � droite du + est appliqu� d�s la premiere %s.<br><b>{000000@x}</b> idem pr�c�demment mais le compteur est remis � zero le xeme mois de l'ann�e (x entre 1 et 12). Si cette option est utilis�e, la balise {yy} est aussi obligatoire ainsi que {mm} si x vaut 2 ou plus <br><b>{dd}</b> jour de la facture (01 � 31).<br><b>{mm}</b> jour de la facture (01 � 12).<br><b>{yy}</b> ou <b>{yyyy}</b> ou <b>{y}</b> annee sur 2 ou 4 chiffres de la facture.<br>Tout autre caract�re dans le masque sera laiss� inchang�.<br>Les espaces ne sont pas permis.<br><br><u>Exemple sur la 99eme %s du tiers LaCompanie faite le 31/03/2007:</u><br><b>ABC{yy}{mm}-{000000}</b> donnera <b>ABC0703-000099</b><br><b>{0000+100}-XXX/{dd}/YYY</b> donnera <b>0199-XXX/31/YYY</b><br>
+GenericNumRefModelDesc=Renvoie un num�ro personalisable selon un masque � d�finir.
+
 # Modules
 Module0Name=Utilisateurs & groupes
 Module0Desc=Gestion des utilisateurs et groupes
diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang
index 93f84e59d032907931241cf8d2df90f0ac52d18c..1c4aac2dc312d0b17ae8d6d647c0436f347618dd 100644
--- a/htdocs/langs/fr_FR/bills.lang
+++ b/htdocs/langs/fr_FR/bills.lang
@@ -340,10 +340,6 @@ PDFTourteauDescription=Mod
 DefinedAndHasThisValue=D�finie et vaut
 IsNotDefined=N'est pas d�finie
 
-# mercure
-MercureNumRefModelDesc1=Renvoie un num�ro de facture personalisable selon un masque � d�finir.
-MercureMaskCodes=Vous pouvez saisir tout masque de num�rotation. Dans ce masque, les balises suivantes peuvent etre utilis�es:<br><b>{000000}</b> correspond a un num�ro qui sera incr�ment� � chaque facture. Mettre autant de z�ro que la longueur d�sir�e du compteur. Le compteur sera compl�t� par des 0 � gauche afin d'avoir autant de z�ro que dans le masque.<br><b>{000000+000}</b> idem pr�c�demment mais un offset correpondant au nombre � droite du + est appliqu� d�s la premiere facture.<br><b>{000000@x}</b> idem pr�c�demment mais le compteur est remis � zero le xeme mois de l'ann�e (x entre 1 et 12). Si cette option est utilis�e, la balise {yy} est aussi obligatoire ainsi que {mm} si x vaut 2 ou plus <br><b>{dd}</b> jour de la facture (01 � 31).<br><b>{mm}</b> jour de la facture (01 � 12).<br><b>{yy}</b> ou <b>{yyyy}</b> ou <b>{y}</b> annee sur 2 ou 4 chiffres de la facture.<br>Tout autre caract�re dans le masque sera laiss� inchang�.<br>Les espaces ne sont pas permis.<br><br><u>Exemple sur la 99eme facture du tiers LaCompanie faite le 31/03/2007:</u><br><b>ABC{yy}{mm}-{000000}</b> donnera <b>ABC0703-000099</b><br><b>{0000+100}-XXX/{dd}/YYY</b> donnera <b>0199-XXX/31/YYY</b><br>
-# terre
 TerreNumRefModelDesc1=Renvoie le num�ro sous la forme %syymm-nnnn pour les factures et %syymm-nnnn pour les avoirs o� yy est l'ann�e, mm le mois et nnnn un compteur s�quentiel sans rupture et sans remise � 0
 TerreNumRefModelError=Une facture commen�ant par $syymm existe en base et est incompatible avec cette num�rotation. Supprimer la ou renommer la pour activer ce module.