diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 152dde9dee37c373d9d1a80911c13e3749e7e062..5541c726d642845da62ddb806ed12dbd52e7585b 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1414,7 +1414,11 @@ if (empty($reshook))
 						$model=$object->modelpdf;
 						$ret = $object->fetch($id); // Reload to get new records
 
-						$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
+						$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
+						if ($result < 0)
+						{
+							setEventMessages($object->error, $object->errors, 'errors');
+						}
 					}
 
 					unset($_POST['prod_entry_mode']);
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 0f90ba6d93527df1331e55845232125a03fe3a05..739135b9809ed340c61546a89a405172e8d79184 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -3504,7 +3504,7 @@ class Facture extends CommonInvoice
 	/**
 	 *  Create a document onto disk according to template module.
 	 *
-	 *	@param	string		$modele			Force template to use ('' to not force)
+	 *	@param	string		$modele			Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example.
 	 *	@param	Translate	$outputlangs	objet lang a utiliser pour traduction
 	 *  @param  int			$hidedetails    Hide details of lines
 	 *  @param  int			$hidedesc       Hide description
@@ -3532,22 +3532,24 @@ class Facture extends CommonInvoice
 
 		$modelpath = "core/modules/facture/doc/";
 
-		return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
+		$result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
+
+		return $result;
 	}
 
 	/**
 	 * Gets the smallest reference available for a new cycle
 	 *
 	 * @return int >= 1 if OK, -1 if error
-	 *
-	 *
 	 */
 	function newCycle()
 	{
-		$sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture';
+		$sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f';
+		$sql.= " WHERE f.entity in (".getEntity('facture').")";
 		$resql = $this->db->query($sql);
 		if ($resql) {
-			if ($resql->num_rows > 0) {
+			if ($resql->num_rows > 0)
+			{
 				$res = $this->db->fetch_array($resql);
 				$ref = $res['max(situation_cycle_ref)'];
 				$ref++;
@@ -3557,7 +3559,7 @@ class Facture extends CommonInvoice
 			$this->db->free($resql);
 			return $ref;
 		} else {
-			$this->error = $this->db->error();
+			$this->error = $this->db->lasterror();
 			dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR);
 			return -1;
 		}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 566f887ba523e73c4699551afbfdb9595761481b..77877a37cb2a9eb7bd23879d4d7b9044e74b910a 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -3406,13 +3406,13 @@ abstract class CommonObject
 	/**
 	 * Common function for all objects extending CommonObject for generating documents
 	 *
-	 * @param string $modelspath Relative folder where models are placed
-	 * @param string $modele Model to use
-	 * @param Translate $outputlangs Language to use
-	 * @param int $hidedetails 1 to hide details. 0 by default
-	 * @param int $hidedesc 1 to hide product description. 0 by default
-	 * @param int $hideref 1 to hide product reference. 0 by default
-	 * @return int 1 if OK -1 if not OK
+	 * @param 	string 		$modelspath 	Relative folder where generators are placed
+	 * @param 	string 		$modele 		Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example.
+	 * @param 	Translate 	$outputlangs 	Language to use
+	 * @param 	int 		$hidedetails 	1 to hide details. 0 by default
+	 * @param 	int 		$hidedesc 		1 to hide product description. 0 by default
+	 * @param 	int 		$hideref 		1 to hide product reference. 0 by default
+	 * @return 	int 						>0 if OK, <0 if KO
 	 */
 	protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref)
 	{
@@ -3426,7 +3426,7 @@ abstract class CommonObject
 		@set_time_limit(120);
 		error_reporting($err);
 
-		// If selected modele is a filename template (then $modele="modelname:filename")
+		// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
 		$tmp=explode(':',$modele,2);
 		if (! empty($tmp[1]))
 		{
@@ -3456,7 +3456,7 @@ abstract class CommonObject
 			if ($filefound) break;
 		}
 
-		// Charge le modele
+		// If generator was found
 		if ($filefound)
 		{
 			require_once $file;
@@ -3464,6 +3464,47 @@ abstract class CommonObject
 			$obj = new $classname($this->db);
 			//$obj->message = $message;
 
+			// If generator is ODT, we must have srctemplatepath defined, if not we set it.
+			if ($obj->type == 'odt' && empty($srctemplatepath))
+			{
+				$varfortemplatedir=$obj->scandir;
+				if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir))
+				{
+					$dirtoscan=$conf->global->$varfortemplatedir;
+
+					$listoffiles=array();
+
+					// Now we add first model found in directories scanned
+	                $listofdir=explode(',',$dirtoscan);
+	                foreach($listofdir as $key=>$tmpdir)
+	                {
+	                    $tmpdir=trim($tmpdir);
+	                    $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
+	                    if (! $tmpdir) { unset($listofdir[$key]); continue; }
+	                    if (is_dir($tmpdir))
+	                    {
+	                        $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0);
+	                        if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
+	                    }
+	                }
+
+	                if (count($listoffiles))
+	                {
+	                	foreach($listoffiles as $record)
+	                    {
+	                    	$srctemplatepath=$record['fullname'];
+	                    	break;
+	                    }
+	                }
+				}
+
+				if (empty($srctemplatepath))
+				{
+					$this->error='ErrorGenerationAskedForOdtTemplateWithNoSrcFileFound';
+					return -1;
+				}
+			}
+
 			// We save charset_output to restore it because write_file can change it if needed for
 			// output format that does not support UTF8.
 			$sav_charset_output=$outputlangs->charset_output;
@@ -3483,14 +3524,15 @@ abstract class CommonObject
 			else
 			{
 				$outputlangs->charset_output=$sav_charset_output;
-				dol_print_error($this->db,"Error generating document for ".__CLASS__.". Error: ".$obj->error);
+				dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
 				return -1;
 			}
 
 		}
 		else
 		{
-			dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file));
+			$this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file);
+			dol_print_error('',$this->error);
 			return -1;
 		}
 	}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 417c9284f6814cd39890be28ae16cf3386b3970f..7cf0e4ff91c34d8ea3a63f6f7455e7724463ec54 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -1649,7 +1649,7 @@ function isValidEmail($address, $acceptsupervisorkey=0)
 /**
  *  Return true if phone number syntax is ok
  *  TODO Decide what to do with this
- *  
+ *
  *  @param	string		$phone		phone (Ex: "0601010101")
  *  @return boolean     			true if phone syntax is OK, false if KO or empty string
  */
@@ -2474,10 +2474,11 @@ function info_admin($text, $infoonimgalt = 0, $nodiv=0)
  *
  *	@param	 	DoliDB	$db      	Database handler
  *	@param  	mixed	$error		String or array of errors strings to show
+ *  @param		array	$errors		Array of errors
  *	@return 	void
  *  @see    	dol_htmloutput_errors
  */
-function dol_print_error($db='',$error='')
+function dol_print_error($db='',$error='',$errors=null)
 {
 	global $conf,$langs,$argv;
 	global $dolibarr_main_prod;
@@ -2550,12 +2551,15 @@ function dol_print_error($db='',$error='')
 		$syslog.=", db_error=".$db->lasterror();
 	}
 
-	if ($error)
+	if ($error || $errors)
 	{
 		$langs->load("errors");
 
-		if (is_array($error)) $errors=$error;
-		else $errors=array($error);
+		// Merge all into $errors array
+		if (is_array($error) && is_array($errors)) $errors=array_merge($error,$errors);
+		elseif (is_array($error)) $errors=$error;
+		elseif (is_array($errors)) $errors=array_merge(array($error),$errors);
+		else $errors=array_merge(array($error));
 
 		foreach($errors as $msg)
 		{
@@ -2564,7 +2568,7 @@ function dol_print_error($db='',$error='')
 			{
 				$out.="<b>".$langs->trans("Message").":</b> ".$msg."<br>\n" ;
 			}
-			else                            // Mode CLI
+			else                        // Mode CLI
 			{
 				$out.='> '.$langs->transnoentities("Message").":\n".$msg."\n" ;
 			}
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index 41cb4f7ab237f029a7d0120561267ba9be155855..f7da56da39c140e3f82ef0bfd8417e49df219208 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -58,6 +58,7 @@ $id=GETPOST('id', 'int');
 $ref=GETPOST('ref', 'alpha');
 $type=GETPOST('type','int');
 $action=(GETPOST('action','alpha') ? GETPOST('action','alpha') : 'view');
+$cancel=GETPOST('cancel');
 $confirm=GETPOST('confirm','alpha');
 $socid=GETPOST('socid','int');
 if (! empty($user->societe_id)) $socid=$user->societe_id;
@@ -98,6 +99,8 @@ $hookmanager->initHooks(array('productcard','globalcard'));
  * Actions
  */
 
+if ($cancel) $action = '';
+
 $createbarcode=empty($conf->barcode->enabled)?0:1;
 if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) $createbarcode=0;
 
@@ -520,121 +523,45 @@ if (empty($reshook))
     }
 
 
-    // Add product into proposal
-    if ($object->id > 0 && $action == 'addinpropal')
+    // Add product into object
+    if ($object->id > 0 && $action == 'addin')
     {
-        $propal = new Propal($db);
-        $result=$propal->fetch(GETPOST('propalid'));
-        if ($result <= 0)
-        {
-            dol_print_error($db,$propal->error);
-            exit;
-        }
-
-        $soc = new Societe($db);
-        $result=$soc->fetch($propal->socid);
-        if ($result <= 0)
-        {
-            dol_print_error($db,$soc->error);
-            exit;
-        }
-
-        $desc = $object->description;
-
-        $tva_tx = get_default_tva($mysoc, $soc, $object->id);
-        $localtax1_tx= get_localtax($tva_tx, 1, $soc);
-        $localtax2_tx= get_localtax($tva_tx, 2, $soc);
-
-        $pu_ht = $object->price;
-        $pu_ttc = $object->price_ttc;
-        $price_base_type = $object->price_base_type;
-
-        // If multiprice
-        if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
-        {
-            $pu_ht = $object->multiprices[$soc->price_level];
-            $pu_ttc = $object->multiprices_ttc[$soc->price_level];
-            $price_base_type = $object->multiprices_base_type[$soc->price_level];
-        }
-   		elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
-		{
-			require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
-
-			$prodcustprice = new Productcustomerprice($db);
-
-			$filter = array('t.fk_product' => $object->id,'t.fk_soc' => $soc->id);
-
-			$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
-			if ($result) {
-				if (count($prodcustprice->lines) > 0) {
-					$pu_ht = price($prodcustprice->lines [0]->price);
-					$pu_ttc = price($prodcustprice->lines [0]->price_ttc);
-					$price_base_type = $prodcustprice->lines [0]->price_base_type;
-					$prod->tva_tx = $prodcustprice->lines [0]->tva_tx;
-				}
-			}
-		}
-
-        // On reevalue prix selon taux tva car taux tva transaction peut etre different
-        // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
-        if ($tva_tx != $object->tva_tx)
+        if (GETPOST('propalid') > 0)
         {
-            if ($price_base_type != 'HT')
-            {
-                $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU');
-            }
-            else
-            {
-                $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU');
-            }
+        	$propal = new Propal($db);
+	        $result=$propal->fetch(GETPOST('propalid'));
+	        if ($result <= 0)
+	        {
+	            dol_print_error($db,$propal->error);
+	            exit;
+	        }
+	        $thirpdartyid = $propal->socid;
         }
-
-        $result = $propal->addline(
-            $desc,
-            $pu_ht,
-            GETPOST('qty'),
-            $tva_tx,
-            $localtax1_tx, // localtax1
-            $localtax2_tx, // localtax2
-            $object->id,
-            GETPOST('remise_percent'),
-            $price_base_type,
-            $pu_ttc,
-	        0,
-	        0,
-	        -1,
-	        0,
-	        0,
-	        0,
-	        0,
-	        '',
-	        '',
-	        '',
-	        0,
-	        $object->fk_unit
-        );
-        if ($result > 0)
+        elseif (GETPOST('commandeid') > 0)
         {
-            header("Location: ".DOL_URL_ROOT."/comm/propal.php?id=".$propal->id);
-            return;
+            $commande = new Commande($db);
+	        $result=$commande->fetch(GETPOST('commandeid'));
+	        if ($result <= 0)
+	        {
+	            dol_print_error($db,$commande->error);
+	            exit;
+	        }
+	        $thirpdartyid = $commande->socid;
         }
-
-        setEventMessage($langs->trans("ErrorUnknown").": $result", 'errors');
-    }
-
-    // Add product into order
-    if ($object->id > 0 && $action == 'addincommande')
-    {
-        $commande = new Commande($db);
-        $result=$commande->fetch(GETPOST('commandeid'));
-        if ($result <= 0)
+        elseif (GETPOST('factureid') > 0)
         {
-            dol_print_error($db,$commande->error);
-            exit;
+    	    $facture = new Facture($db);
+	        $result=$facture->fetch(GETPOST('factureid'));
+	        if ($result <= 0)
+	        {
+	            dol_print_error($db,$facture->error);
+	            exit;
+	        }
+	        $thirpdartyid = $facture->socid;
         }
 
         $soc = new Societe($db);
-        $result=$soc->fetch($commande->socid);
+        $result=$soc->fetch($thirpdartyid);
         if ($result <= 0)
         {
             dol_print_error($db,$soc->error);
@@ -647,7 +574,6 @@ if (empty($reshook))
         $localtax1_tx= get_localtax($tva_tx, 1, $soc);
         $localtax2_tx= get_localtax($tva_tx, 2, $soc);
 
-
         $pu_ht = $object->price;
         $pu_ttc = $object->price_ttc;
         $price_base_type = $object->price_base_type;
@@ -659,7 +585,7 @@ if (empty($reshook))
             $pu_ttc = $object->multiprices_ttc[$soc->price_level];
             $price_base_type = $object->multiprices_base_type[$soc->price_level];
         }
-    	elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
+   		elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
 		{
 			require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
 
@@ -677,6 +603,7 @@ if (empty($reshook))
 				}
 			}
 		}
+
         // On reevalue prix selon taux tva car taux tva transaction peut etre different
         // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
         if ($tva_tx != $object->tva_tx)
@@ -691,152 +618,116 @@ if (empty($reshook))
             }
         }
 
-        $result =  $commande->addline(
-            $desc,
-            $pu_ht,
-            GETPOST('qty'),
-            $tva_tx,
-            $localtax1_tx, // localtax1
-            $localtax2_tx, // localtax2
-            $object->id,
-            GETPOST('remise_percent'),
-            '',
-            '',
-            $price_base_type,
-            $pu_ttc,
-	        '',
-	        '',
-	        0,
-	        -1,
-	        0,
-	        0,
-	        null,
-	        0,
-	        '',
-	        0,
-	        $object->fk_unit
-        );
-
-        if ($result > 0)
+        if (GETPOST('propalid') > 0)
         {
-            header("Location: ".DOL_URL_ROOT."/commande/card.php?id=".$commande->id);
-            exit;
-        }
-    }
-
-    // Add product into invoice
-    if ($object->id > 0 && $action == 'addinfacture' && $user->rights->facture->creer)
-    {
-        $facture = New Facture($db);
-        $result=$facture->fetch(GETPOST('factureid'));
-        if ($result <= 0)
-        {
-            dol_print_error($db,$facture->error);
-            exit;
-        }
+	        $result = $propal->addline(
+	            $desc,
+	            $pu_ht,
+	            GETPOST('qty'),
+	            $tva_tx,
+	            $localtax1_tx, // localtax1
+	            $localtax2_tx, // localtax2
+	            $object->id,
+	            GETPOST('remise_percent'),
+	            $price_base_type,
+	            $pu_ttc,
+		        0,
+		        0,
+		        -1,
+		        0,
+		        0,
+		        0,
+		        0,
+		        '',
+		        '',
+		        '',
+		        0,
+		        $object->fk_unit
+	        );
+	        if ($result > 0)
+	        {
+	            header("Location: ".DOL_URL_ROOT."/comm/propal.php?id=".$propal->id);
+	            return;
+	        }
 
-        $soc = new Societe($db);
-        $soc->fetch($facture->socid);
-        if ($result <= 0)
-        {
-            dol_print_error($db,$soc->error);
-            exit;
+        	setEventMessage($langs->trans("ErrorUnknown").": $result", 'errors');
         }
-
-        $desc = $object->description;
-
-        $tva_tx = get_default_tva($mysoc, $soc, $object->id);
-        $localtax1_tx= get_localtax($tva_tx, 1, $soc);
-        $localtax2_tx= get_localtax($tva_tx, 2, $soc);
-
-        $pu_ht = $object->price;
-        $pu_ttc = $object->price_ttc;
-        $price_base_type = $object->price_base_type;
-
-        // If multiprice
-        if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
+        elseif (GETPOST('commandeid') > 0)
         {
-            $pu_ht = $object->multiprices[$soc->price_level];
-            $pu_ttc = $object->multiprices_ttc[$soc->price_level];
-            $price_base_type = $object->multiprices_base_type[$soc->price_level];
+            $result =  $commande->addline(
+	            $desc,
+	            $pu_ht,
+	            GETPOST('qty'),
+	            $tva_tx,
+	            $localtax1_tx, // localtax1
+	            $localtax2_tx, // localtax2
+	            $object->id,
+	            GETPOST('remise_percent'),
+	            '',
+	            '',
+	            $price_base_type,
+	            $pu_ttc,
+		        '',
+		        '',
+		        0,
+		        -1,
+		        0,
+		        0,
+		        null,
+		        0,
+		        '',
+		        0,
+		        $object->fk_unit
+	        );
+
+	        if ($result > 0)
+	        {
+	            header("Location: ".DOL_URL_ROOT."/commande/card.php?id=".$commande->id);
+	            exit;
+	        }
         }
-    	elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
+		elseif (GETPOST('factureid') > 0)
 		{
-			require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
-
-			$prodcustprice = new Productcustomerprice($db);
-
-			$filter = array('t.fk_product' => $object->id,'t.fk_soc' => $soc->id);
-
-			$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
-			if ($result) {
-				if (count($prodcustprice->lines) > 0) {
-					$pu_ht = price($prodcustprice->lines [0]->price);
-					$pu_ttc = price($prodcustprice->lines [0]->price_ttc);
-					$price_base_type = $prodcustprice->lines [0]->price_base_type;
-					$prod->tva_tx = $prodcustprice->lines [0]->tva_tx;
-				}
-			}
+	        $result = $facture->addline(
+	            $desc,
+	            $pu_ht,
+	            GETPOST('qty'),
+	            $tva_tx,
+	            $localtax1_tx,
+	            $localtax2_tx,
+	            $object->id,
+	            GETPOST('remise_percent'),
+	            '',
+	            '',
+	            '',
+	            '',
+	            '',
+	            $price_base_type,
+	            $pu_ttc,
+		        Facture::TYPE_STANDARD,
+		        -1,
+		        0,
+		        '',
+		        0,
+		        0,
+		        null,
+		        0,
+		        '',
+		        0,
+		        100,
+		        '',
+		        $object->fk_unit
+	        );
+
+	        if ($result > 0)
+	        {
+	            header("Location: ".DOL_URL_ROOT."/compta/facture.php?facid=".$facture->id);
+	            exit;
+	        }
 		}
-        // On reevalue prix selon taux tva car taux tva transaction peut etre different
-        // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
-        if ($tva_tx != $object->tva_tx)
-        {
-            if ($price_base_type != 'HT')
-            {
-                $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU');
-            }
-            else
-            {
-                $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU');
-            }
-        }
-
-        $result = $facture->addline(
-            $desc,
-            $pu_ht,
-            GETPOST('qty'),
-            $tva_tx,
-            $localtax1_tx,
-            $localtax2_tx,
-            $object->id,
-            GETPOST('remise_percent'),
-            '',
-            '',
-            '',
-            '',
-            '',
-            $price_base_type,
-            $pu_ttc,
-	        Facture::TYPE_STANDARD,
-	        -1,
-	        0,
-	        '',
-	        0,
-	        0,
-	        null,
-	        0,
-	        '',
-	        0,
-	        100,
-	        '',
-	        $object->fk_unit
-        );
-
-        if ($result > 0)
-        {
-            header("Location: ".DOL_URL_ROOT."/compta/facture.php?facid=".$facture->id);
-            exit;
-        }
     }
 }
 
-if (GETPOST("cancel") == $langs->trans("Cancel"))
-{
-    $action = '';
-    header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
-    exit;
-}
 
 
 /*
@@ -1815,42 +1706,23 @@ if ($object->id && ($action == '' || $action == 'view') && $object->status)
 
         $langs->load("propal");
 
-        $html .= '<tr class="liste_titre">';
-        $html .= '<td class="liste_titre">'.$langs->trans("AddToDraftProposals").'</td>';
-        $html .= '</tr><tr>';
-        $html .= '<td valign="top">';
-
         $var=true;
         $otherprop = $propal->liste_array(2,1,0);
-        $html .= '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
-        $html .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-        $html .= '<table class="nobordernopadding" width="100%">';
+
         if (is_array($otherprop) && count($otherprop))
         {
         	$var=!$var;
         	$html .= '<tr '.$bc[$var].'><td style="width: 200px;">';
-        	$html .= '<input type="hidden" name="action" value="addinpropal">';
-        	$html .= $langs->trans("Proposals").'</td><td colspan="2">';
+        	$html .= $langs->trans("AddToDraftProposals").'</td><td colspan="2">';
         	$html .= $form->selectarray("propalid", $otherprop, 0, 1);
         	$html .= '</td></tr>';
-        	$html .= '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Quantity").' ';
-        	$html .= '<input type="text" class="flat" name="qty" size="1" value="1"></td><td class="nowrap">'.$langs->trans("ReductionShort").'(%) ';
-        	$html .= '<input type="text" class="flat" name="remise_percent" size="1" value="0">';
-        	$html .= '</td><td align="right">';
-        	$html .= '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
-        	$html .= '</td></tr>';
         }
         else
-        {
+       {
         	$html .= "<tr ".$bc[!$var]."><td>";
         	$html .= $langs->trans("NoDraftProposals");
         	$html .= '</td></tr>';
         }
-        $html .= '</table>';
-        $html .= '</form>';
-
-        $html .= '</td>';
-        $html .= '</tr>';
     }
 
     // Commande
@@ -1860,30 +1732,15 @@ if ($object->id && ($action == '' || $action == 'view') && $object->status)
 
         $langs->load("orders");
 
-        $html .= '<tr class="liste_titre">';
-        $html .= '<td class="liste_titre">'.$langs->trans("AddToDraftOrders").'</td>';
-        $html .= '</tr><tr>';
-        $html .= '<td valign="top">';
-
         $var=true;
         $othercom = $commande->liste_array(2, 1, null);
-        $html .= '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
-        $html .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-        $html .= '<table class="nobordernopadding" width="100%">';
         if (is_array($othercom) && count($othercom))
         {
         	$var=!$var;
         	$html .= '<tr '.$bc[$var].'><td style="width: 200px;">';
-        	$html .= '<input type="hidden" name="action" value="addincommande">';
-        	$html .= $langs->trans("Orders").'</td><td colspan="2">';
+        	$html .= $langs->trans("AddToDraftOrders").'</td><td colspan="2">';
         	$html .= $form->selectarray("commandeid", $othercom, 0, 1);
         	$html .= '</td></tr>';
-        	$html .= '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Quantity").' ';
-        	$html .= '<input type="text" class="flat" name="qty" size="1" value="1"></td><td class="nowrap">'.$langs->trans("ReductionShort").'(%) ';
-        	$html .= '<input type="text" class="flat" name="remise_percent" size="1" value="0">';
-        	$html .= '</td><td align="right">';
-        	$html .= '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
-        	$html .= '</td></tr>';
         }
         else
 		{
@@ -1891,11 +1748,6 @@ if ($object->id && ($action == '' || $action == 'view') && $object->status)
         	$html .= $langs->trans("NoDraftOrders");
         	$html .= '</td></tr>';
         }
-        $html .= '</table>';
-        $html .= '</form>';
-
-        $html .= '</td>';
-        $html .= '</tr>';
     }
 
     // Factures
@@ -1905,30 +1757,15 @@ if ($object->id && ($action == '' || $action == 'view') && $object->status)
 
     	$langs->load("bills");
 
-    	$html .= '<tr class="liste_titre">';
-    	$html .= '<td class="liste_titre">'.$langs->trans("AddToDraftInvoices").'</td>';
-        $html .= '</tr><tr>';
-    	$html .= '<td valign="top">';
-
     	$var=true;
     	$otherinvoice = $invoice->liste_array(2, 1, null);
-    	$html .= '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
-    	$html .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-    	$html .= '<table class="nobordernopadding" width="100%">';
     	if (is_array($otherinvoice) && count($otherinvoice))
     	{
     		$var=!$var;
     		$html .= '<tr '.$bc[$var].'><td style="width: 200px;">';
-    		$html .= '<input type="hidden" name="action" value="addinfacture">';
-    		$html .= $langs->trans("Invoice").'</td><td colspan="2">';
+    		$html .= $langs->trans("AddToDraftInvoices").'</td><td colspan="2">';
     		$html .= $form->selectarray("factureid", $otherinvoice, 0, 1);
     		$html .= '</td></tr>';
-    		$html .= '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Quantity").' ';
-    		$html .= '<input type="text" class="flat" name="qty" size="1" value="1"></td><td class="nowrap">'.$langs->trans("ReductionShort").'(%) ';
-    		$html .= '<input type="text" class="flat" name="remise_percent" size="1" value="0">';
-    		$html .= '</td><td align="right">';
-    		$html .= '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
-    		$html .= '</td></tr>';
     	}
     	else
     	{
@@ -1936,20 +1773,31 @@ if ($object->id && ($action == '' || $action == 'view') && $object->status)
     		$html .= $langs->trans("NoDraftInvoices");
     		$html .= '</td></tr>';
     	}
-    	$html .= '</table>';
-    	$html .= '</form>';
-
-    	$html .= '</td>';
-    	$html .= '</tr>';
     }
 
     //If any text is going to be printed, then we show the table
     if (!empty($html))
     {
-        print '<table width="100%" class="noborder">';
+	    print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
+    	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    	print '<input type="hidden" name="action" value="addin">';
+
+	    print load_fiche_titre($langs->trans("Add"),'','');
+
+    	$html .= '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Quantity").' ';
+    	$html .= '<input type="text" class="flat" name="qty" size="1" value="1"></td><td class="nowrap">'.$langs->trans("ReductionShort").'(%) ';
+    	$html .= '<input type="text" class="flat" name="remise_percent" size="1" value="0">';
+    	$html .= '</td></tr>';
+
+    	print '<table width="100%" class="border">';
         print $html;
         print '</table>';
-        print '<br>';
+
+        print '<div class="center">';
+        print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
+        print '</div>';
+
+        print '</form>';
     }
 }
 
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 9d7a9215ef1502a1c604ad6ccf679fcfc4426f1c..abeb8fdf995aaff3bd8fd7a214eede2dc739f724 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -523,20 +523,20 @@ if ($id || $ref)
 				$param="&id=".$product->id;
 				print '<tr class="liste_titre">';
 				print_liste_field_titre($langs->trans("Suppliers"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
-				print '<td class="liste_titre">'.$langs->trans("SupplierRef").'</td>';
+				print_liste_field_titre($langs->trans("SupplierRef"));
 				if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) print_liste_field_titre($langs->trans("Availability"),$_SERVER["PHP_SELF"],"pfp.fk_availability","",$param,"",$sortfield,$sortorder);
 				print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"],"pfp.quantity","",$param,'align="right"',$sortfield,$sortorder);
-				print '<td class="liste_titre" align="right">'.$langs->trans("VATRate").'</td>';
-				print '<td class="liste_titre" align="right">'.$langs->trans("PriceQtyMinHT").'</td>';
+				print_liste_field_titre($langs->trans("VATRate"));
+				print_liste_field_titre($langs->trans("PriceQtyMinHT"));
 				print_liste_field_titre($langs->trans("UnitPriceHT"),$_SERVER["PHP_SELF"],"pfp.unitprice","",$param,'align="right"',$sortfield,$sortorder);
-				print '<td class="liste_titre" align="right">'.$langs->trans("DiscountQtyMin").'</td>';
+				print_liste_field_titre($langs->trans("DiscountQtyMin"));
 				print_liste_field_titre($langs->trans("NbDaysToDelivery"),$_SERVER["PHP_SELF"],"pfp.delivery_time_days","",$param,'align="right"',$sortfield,$sortorder);
 				// Charges ????
 				if ($conf->global->PRODUCT_CHARGES)
 				{
-					if (! empty($conf->margin->enabled)) print '<td align="right">'.$langs->trans("UnitCharges").'</td>';
+					if (! empty($conf->margin->enabled)) print_liste_field_titre($langs->trans("UnitCharges"));
 				}
-				print '<td class="liste_titre"></td>';
+				print_liste_field_titre('');
 				print "</tr>\n";
 
 				$product_fourn = new ProductFournisseur($db);
diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php
index 7cbd989820461871e6fe90d9c3f7678ce773ca22..2f0e903b8c5a5bd95db5f0c2a5e9a3730a9e991d 100644
--- a/htdocs/public/test/test_arrays.php
+++ b/htdocs/public/test/test_arrays.php
@@ -65,7 +65,7 @@ else
 
 <h1>
 This page is a sample of page using tables. It is designed to make test with<br>
-- css (edit page to change to test another css)<br>
+- css (add parameter &theme=newthem to test another theme or edit css of current theme)<br>
 - jmobile (add parameter dol_use_jmobile=1&dol_optimize_smallscreen=1 to enable view with jmobile)<br>
 - dataTables<br>
 - tablednd<br>
@@ -115,9 +115,13 @@ This page is a sample of page using tables. It is designed to make test with<br>
 
 
 
-<br><hr><br>Example 1 : Standard table => Use this if you need the drag and drop for lines<br>
+<br><hr><br>Example 1 : Standard table/thead/tbody/tr/th-td (no class pair/impair on td) => Use this if you need the drag and drop for lines<br>
 
 <?php
+include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+$productspecimen=new Product($db);
+$productspecimen->initAsSpecimen();
+
 $sortfield='aaa';
 $sortorder='ASC';
 $tasksarray=array(1,2,3);	// To force having several lines
@@ -130,14 +134,14 @@ if (! empty($conf->use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/aj
 <?php print getTitleFieldOfList($langs->trans('title2'),0,$_SERVER["PHP_SELF"],'bbb','','','align="right"',$sortfield,$sortorder); ?>
 <?php print getTitleFieldOfList($langs->trans('title3'),0,$_SERVER["PHP_SELF"],'ccc','','','align="center"',$sortfield,$sortorder); ?>
 </tr>
-<tr class="pair"><td class="pair">a1</td><td class="pair" align="right">b1</td><td class="tdlineupdown pair" align="left">c1</td></tr>
-<tr class="impair"><td class="impair">a2</td><td class="impair" align="right">b2</td><td class="tdlineupdown impair" align="left">c2</td></tr>
+<tr class="pair"><td><?php echo $productspecimen->getNomUrl(1); ?></td><td align="right">b1</td><td class="tdlineupdown" align="left">c1</td></tr>
+<tr class="impair"><td>a2</td><td align="right">b2</td><td class="tdlineupdown" align="left">c2</td></tr>
 </table>
 <br>
 
 
 
-<br><hr><br>Example 2 : Table using tags: table/thead/tbody/tr/td + dataTable => Use this for long result tables<br>
+<br><hr><br>Example 2 : Table using tags: table/thead/tbody/tr/th-td + dataTable => Use this for long result tables<br>
 
 
 
@@ -221,9 +225,11 @@ $('xxxth').replaceWith(
 <table id="idtableexample2" class="centpercent">
 	<thead>
     <tr class="liste_titre">
-        <th>snake</th>
-        <th><label><input type="checkbox" name="hidedetails" value="2"> A checkbox inside a cell</label></th>
-		<?php print getTitleFieldOfList($langs->trans('zzz'),1,$_SERVER["PHP_SELF"],'','','','align="center" class="tagtd"',$sortfield,$sortorder); ?>
+        <th>Column A</th>
+        <th><label><input type="checkbox" name="hidedetails" value="2"> A checkbox inside a title of Column B</label></th>
+		<?php
+		print getTitleFieldOfList($langs->trans('Column C'),1,$_SERVER["PHP_SELF"],'','','','align="center" class="tagtd"',$sortfield,$sortorder);
+		?>
     </tr>
     </thead>
     <tbody>
@@ -292,7 +298,7 @@ $('xxxth').replaceWith(
 <br>
 
 
-<br><hr><br>Example 3 : Table using tags: div.tagtable+div.tagtr+div or div.tagtable+div.tagtr+div.tagtd => Use this, but AVOID IT if possible, for tables that need to have a different form for each line (drag and drop of lines does not work for this case, also height of title can't be forced to a minimum)<br><br>
+<br><hr><br>Example 3 : Table using tags: div.tagtable+div.tagtr+div or div.tagtable+div.tagtr+div.tagtd => Use this for tables that need to have a different form for each line, but AVOID IT if possible (drag and drop of lines does not work for this case, also height of title can't be forced to a minimum)<br><br>
 
 
 <?php
@@ -302,23 +308,29 @@ $('xxxth').replaceWith(
 ?>
 <div class="tagtable centpercent" id="tablelines">
     <div class="tagtr liste_titre">
-        <div class="tagtd">line3<input type="hidden" name="cartitem" value="3"></div>
-        <div class="tagtd">dfsdf</div>
-        <div class="tagtd">ffdsfsd</div>
-        <div class="tagtd tdlineupdown">aaaa</div>
+        <div class="tagtd">Title A<input type="hidden" name="cartitem" value="3"></div>
+        <div class="tagtd">title B</div>
+        <div class="tagtd">title C</div>
+        <div class="tagtd">title D</div>
     </div>
-    <div class="impair tagtr">
+    <div class="pair tagtr">
         <div class="tagtd">line4<input type="hidden" name="cartitem" value="3"></div>
         <div class="tagtd">dfsdf</div>
         <div class="tagtd"><input name="count" value="4"></div>
         <div class="tagtd tdlineupdown">bbbb</div>
     </div>
-    <div class="pair tagtr">
+    <div class="impair tagtr">
         <div class="tagtd">line5<input type="hidden" name="cartitemb" value="3"></div>
         <div class="tagtd">dfsdf</div>
         <div class="tagtd"><input name="countb" value="4"></div>
         <div class="tagtd tdlineupdown">bbbb</div>
     </div>
+    <div class="pair tagtr">
+        <div class="tagtd">line6<input type="hidden" name="cartitem" value="3"></div>
+        <div class="tagtd">jghjgh</div>
+        <div class="tagtd">5</div>
+        <div class="tagtd tdlineupdown">lll</div>
+    </div>
 <!-- Using form into div make Firefox crazy (page loading does not end) -->
 <!--	<form class="liste_titre" method="POST" action="1.php">
         <div>line1<input type="hidden" name="cartitem" value="1"></div>
diff --git a/htdocs/theme/eldy/img/sort_asc.png b/htdocs/theme/eldy/img/sort_asc.png
index e327d952fa47a490b79b8b9c6d32854de82a0961..aca0f6eb77aa8b601a073daa9a94bfa9bd5cc7e8 100644
Binary files a/htdocs/theme/eldy/img/sort_asc.png and b/htdocs/theme/eldy/img/sort_asc.png differ
diff --git a/htdocs/theme/eldy/img/sort_asc_disabled.png b/htdocs/theme/eldy/img/sort_asc_disabled.png
index e327d952fa47a490b79b8b9c6d32854de82a0961..d87652c2cc3399cc047ef3ded122cbb59676b545 100644
Binary files a/htdocs/theme/eldy/img/sort_asc_disabled.png and b/htdocs/theme/eldy/img/sort_asc_disabled.png differ
diff --git a/htdocs/theme/eldy/img/sort_desc.png b/htdocs/theme/eldy/img/sort_desc.png
index db99fd9ad478bf432bb8491ed7e0e38dcb856030..57c1ad0fcb41a2dac762e6d46dc4556590002172 100644
Binary files a/htdocs/theme/eldy/img/sort_desc.png and b/htdocs/theme/eldy/img/sort_desc.png differ
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index f1598d3a87d2d5d9611b64866052b9428722b105..5a490f5aef5aab8a7183f0e7a8a285061dbd00d0 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -187,11 +187,6 @@ if ($tmpval <= 340) { $colortextbacktab='FFF'; }
 else { $colortextbacktab='111'; }
 
 
-$usecss3=true;
-if ($conf->browser->name == 'ie' && round($conf->browser->version,2) < 10) $usecss3=false;
-elseif ($conf->browser->name == 'iceweasel') $usecss3=false;
-elseif ($conf->browser->name == 'epiphany')  $usecss3=false;
-
 print '/*'."\n";
 print 'colred='.$colred.' colgreen='.$colgreen.' colblue='.$colblue."\n";
 print 'isred='.$isred.' isgreen='.$isgreen.' isblue='.$isblue."\n";
@@ -201,7 +196,6 @@ print 'colorbacklineimpairhover='.$colorbacklineimpairhover."\n";
 print 'colorbacklinepair1='.$colorbacklinepair1."\n";
 print 'colorbacklinepair2='.$colorbacklinepair2."\n";
 print 'colorbacklinepairhover='.$colorbacklinepairhover."\n";
-print 'usecss3='.$usecss3."\n";
 print 'dol_hide_topmenu='.$dol_hide_topmenu."\n";
 print 'dol_hide_leftmenu='.$dol_hide_leftmenu."\n";
 print 'dol_optimize_smallscreen='.$dol_optimize_smallscreen."\n";
@@ -249,7 +243,7 @@ textarea.cke_source:focus
 	box-shadow: none;
 }
 
-input, input.flat, textarea, textarea.flat, form.flat select, select.flat {
+input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select {
     font-size: <?php print $fontsize ?>px;
     font-family: <?php print $fontlist ?>;
     background: #FDFDFD;
@@ -570,17 +564,12 @@ div#tmenu_tooltip {
 	padding-<?php echo $right; ?>: 100px;
 	background: <?php echo $colorbackvmenu; ?>;
 	box-shadow: 0 0 6px rgba(0, 0, 0, .4) !important;
-    <?php if ($usecss3) { ?>
 	background-image: linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(128,128,128,.3) 100%);
 	background-image: -o-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(128,128,128,.3) 100%);
 	background-image: -moz-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(128,128,128,.3) 100%);
 	background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(128,128,128,.3) 100%);
 	background-image: -ms-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(128,128,128,.3) 100%);
 	background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, rgba(255,255,255,.3)), color-stop(1, rgba(128,128,128,.3)) );
-	<?php } else { ?>
-	background-image: rgb(<?php echo $colorbackhmenu1; ?>);
-    border-bottom: 1px solid #CCC;
-	<?php } ?>
 <?php } ?>
 }
 
@@ -642,17 +631,12 @@ ul.tmenu {	/* t r b l */
 ul.tmenu li {
 	background: rgb(<?php echo $colorbackhmenu1 ?>);
 
-    <?php if ($usecss3) { ?>
 	background-image: linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%);
 	background-image: -o-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%);
 	background-image: -moz-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%);
 	background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%);
 	background-image: -ms-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%);
 	background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, rgba(255,255,255,.3)), color-stop(1, rgba(0,0,0,.3)) );
-	<?php } else { ?>
-	background-image: rgb(<?php echo $colorbackhmenu1; ?>);
-    border-bottom: 1px solid #CCC;
-	<?php } ?>
 }
 li.tmenu, li.tmenusel {
 	<?php print $minwidthtmenu?'min-width: '.$minwidthtmenu.'px;':''; ?>
@@ -1034,18 +1018,12 @@ div.blockvmenupair, div.blockvmenuimpair, div.blockvmenubookmarks
     padding-bottom: 3px;
     margin: 1px 0px 8px 2px;
 
-<?php if ($usecss3) { ?>
-
     background-image: -o-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu2; ?>) 0px, rgb(<?php echo $colorbackvmenu1; ?>) 3px);
     background-image: -moz-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu2; ?>) 0px, rgb(<?php echo $colorbackvmenu1; ?>) 3px);
     background-image: -webkit-linear-gradient(right, rgb(<?php echo $colorbackvmenu2; ?>) 0px, rgb(<?php echo $colorbackvmenu1; ?>) 3px);
     background-image: -ms-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu2; ?>) 0px, rgb(<?php echo $colorbackvmenu1; ?>) 3px);
     background-image: linear-gradient(bottom, rgb(<?php echo $colorbackvmenu2; ?>) 0px, rgb(<?php echo $colorbackvmenu1; ?>) 3px);
 
-<?php } else { ?>
-    background-position:top;
-    background-repeat:repeat-x;
-<?php } ?>
     border-left: 1px solid #AAA;
     border-right: 1px solid #BBB;
     border-bottom: 1px solid #BBB;
@@ -1070,13 +1048,11 @@ div.blockvmenusearch
     margin: 1px 0px 8px 2px;
 	background: #E3E6E8;
 
-<?php if ($usecss3) { ?>
     background-image: -o-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
     background-image: -moz-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
     background-image: -webkit-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
     background-image: -ms-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
     background-image: linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
-<?php } ?>
 
     border-left: 1px solid #AAA;
     border-right: 1px solid #CCC;
@@ -1153,13 +1129,12 @@ td.photo {
 /* ============================================================================== */
 
 .largebutton {
-<?php if ($usecss3) { ?>
     background-image: -o-linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important;
     background-image: -moz-linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important;
     background-image: -webkit-linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important;
     background-image: -ms-linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important;
     background-image: linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important;
-<?php } ?>
+
     background: #FFF;
     background-repeat: repeat-x !important;
 	border: 1px solid #CCC !important;
@@ -1409,23 +1384,14 @@ div.tabBar {
     border-left: 1px solid #AAA;
     border-top: 1px solid #BBB;
 	width: auto;
-/*
-<?php if ($usecss3) { ?>
-	background-image: -o-linear-gradient(bottom, rgba(<?php echo $colorbacktabcard1; ?>, 0.5) 25%, rgba(<?php echo $colorbacktabcard2; ?>, 0.5) 100%);
-	background-image: -moz-linear-gradient(bottom, rgba(<?php echo $colorbacktabcard1; ?>, 0.5) 25%, rgba(<?php echo $colorbacktabcard2; ?>, 0.5) 100%);
-	background-image: -webkit-linear-gradient(bottom, rgba(<?php echo $colorbacktabcard1; ?>, 0.5) 25%, rgba(<?php echo $colorbacktabcard2; ?>, 0.5) 100%);
-	background-image: -ms-linear-gradient(bottom, rgba(<?php echo $colorbacktabcard1; ?>, 0.5) 25%, rgba(<?php echo $colorbacktabcard2; ?>, 0.5) 100%);
-	background-image: linear-gradient(bottom, rgba(<?php echo $colorbacktabcard1; ?>, 0.5) 25%, rgba(<?php echo $colorbacktabcard2; ?>, 0.5) 100%);
-<?php } else { ?>
-	background: rgb(<?php echo $colorbacktabcard1; ?>);
-<?php } ?>
-*/
+
 	background: rgb(<?php echo $colorbacktabcard1; ?>);
-<?php if (empty($dol_optimize_smallscreen)) { ?>
+
+	<?php if (empty($dol_optimize_smallscreen)) { ?>
     -moz-box-shadow: 3px 3px 4px #DDD;
     -webkit-box-shadow: 3px 3px 4px #DDD;
     box-shadow: 3px 3px 4px #DDD;
-<?php } ?>
+	<?php } ?>
 }
 
 div.tabsAction {
@@ -1460,28 +1426,6 @@ a.tab:link, a.tab:visited, a.tab:hover, a.tab#active {
 	-webkit-border-radius:6px 6px 0px 0px;
 	border-radius:6px 6px 0px 0px;
 
-/*
-	-moz-box-shadow: 0 -1px 4px rgba(0,0,0,.1);
-	-webkit-box-shadow: 0 -1px 4px rgba(0,0,0,.1);
-	box-shadow: 0 -1px 4px rgba(0,0,0,.1);
-*/
-
-	border-bottom: none;
-/*
-	border-right: 1px solid #BBB;
-	border-left: 1px solid #BBB;
-	border-top: 1px solid #CCC;
-*/
-/*
-<?php if ($usecss3) { ?>
-    background-image: -o-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 35%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
-    background-image: -moz-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 35%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
-    background-image: -webkit-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 35%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
-    background-image: -ms-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 35%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
-    background-image: linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 35%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
-<?php } ?>
-	background-image: none !important;
-*/
 	background: rgb(<?php echo $colorbackvmenu2; ?>);
 
 	border-right: 1px solid #BBB;
@@ -1492,14 +1436,6 @@ a.tab:link, a.tab:visited, a.tab:hover, a.tab#active {
 }
 
 .tabactive {
-/*
-<?php if ($usecss3) { ?>
-	background: rgba(<?php echo $colorbacktabcard2; ?>, 0.5)  url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/nav-overlay3.png',1); ?>) 50% 0 repeat-x;
-<?php } else { ?>
-	background: rgb(<?php echo $colorbacktabactive; ?>)  url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/nav-overlay3.png',1); ?>) 50% 0 repeat-x;
-<?php } ?>
-*/
-	/*background-image: none !important; */
 	color: #<?php echo $colortextbacktab; ?> !important;
 	background: rgb(<?php echo $colorbacktabcard1; ?>) !important;
 	-moz-box-shadow: 0 -1px 4px rgba(0,0,0,.1);
@@ -1899,53 +1835,28 @@ table.liste td {
 }
 */
 
-.impair:hover, td.nohover {
-<?php if ($colorbacklineimpairhover) { if ($usecss3) { ?>
-	background: rgb(<?php echo $colorbacklineimpairhover; ?>);
+
+.odd:hover, .impair:hover, .even:hover, .pair:hover, .even:hover, .pair:hover, table.dataTable tr.even:hover, table.dataTable tr.odd:hover
+{
+<?php if ($colorbacklinepairhover) { if ($colorbacklinepairhover > 0) { ?>
+	background: rgb(<?php echo $colorbacklinepairhover; ?>) !important;
 <?php } else { ?>
-	background: #fafafa;
+	background: rgba(0, 0, 0, 0.05) !important;
 <?php } } ?>
-	border: 0px;
 }
 
-.impair, .nohover .impair:hover, tr.impair td.nohover {
-<?php if ($usecss3) { ?>
-	background: linear-gradient(bottom, rgb(<?php echo $colorbacklineimpair1; ?>) 85%, rgb(<?php echo $colorbacklineimpair2; ?>) 100%);
-	background: -o-linear-gradient(bottom, rgb(<?php echo $colorbacklineimpair1; ?>) 85%, rgb(<?php echo $colorbacklineimpair2; ?>) 100%);
-	background: -moz-linear-gradient(bottom, rgb(<?php echo $colorbacklineimpair1; ?>) 85%, rgb(<?php echo $colorbacklineimpair2; ?>) 100%);
-	background: -webkit-linear-gradient(bottom, rgb(<?php echo $colorbacklineimpair1; ?>) 85%, rgb(<?php echo $colorbacklineimpair2; ?>) 100%);
-	background: -ms-linear-gradient(bottom, rgb(<?php echo $colorbacklineimpair1; ?>) 85%, rgb(<?php echo $colorbacklineimpair2; ?>) 100%);
-<?php } else { ?>
-	background: #eaeaea;
-<?php } ?>
+.odd, .impair, .nohover .odd:hover, .nohover .impair:hover, tr.odd td.nohover, tr.impair td.nohover {
 	font-family: <?php print $fontlist ?>;
 	border: 0px;
 	margin-bottom: 1px;
 	color: #202020;
 	min-height: 18px; /* seems to not be used */
-}
 
-.pair:hover {
-<?php if ($colorbacklinepairhover) { if ($usecss3) { ?>
-	background: rgb(<?php echo $colorbacklinepairhover; ?>);
-<?php } else { ?>
-	background: #fafafa;
-<?php } }?>
-	border: 0px;
+	background: #ffffff;
 }
 
-.pair, .nohover .pair:hover, tr.pair td.nohover {
-/*
-<?php if ($usecss3) { ?>
-	background: linear-gradient(bottom, rgb(<?php echo $colorbacklinepair1; ?>) 85%, rgb(<?php echo $colorbacklinepair2; ?>) 100%);
-	background: -o-linear-gradient(bottom, rgb(<?php echo $colorbacklinepair1; ?>) 85%, rgb(<?php echo $colorbacklinepair2; ?>) 100%);
-	background: -moz-linear-gradient(bottom, rgb(<?php echo $colorbacklinepair1; ?>) 85%, rgb(<?php echo $colorbacklinepair2; ?>) 100%);
-	background: -webkit-linear-gradient(bottom, rgb(<?php echo $colorbacklinepair1; ?>) 85%, rgb(<?php echo $colorbacklinepair2; ?>) 100%);
-	background: -ms-linear-gradient(bottom, rgb(<?php echo $colorbacklinepair1; ?>) 85%, rgb(<?php echo $colorbacklinepair2; ?>) 100%);
-<?php } else { ?>
-	background: #ffffff;
-<?php } ?>
-*/
+
+.even, .pair, .nohover .even:hover, .nohover .pair:hover, tr.even td.nohover, tr.pair td.nohover {
 	font-family: <?php print $fontlist ?>;
 	border: 0px;
 	margin-bottom: 1px;
@@ -1953,11 +1864,17 @@ table.liste td {
 
 	background-color: #f9f9f9;
 }
-tr.pair td, tr.impair td, form.impair div.tagtd, form.pair div.tagtd {
-    padding: 5px 2px;
+table.dataTable tr.odd {
+	background-color: #f9f9f9 !important;
+}
+table.dataTable td {
+    padding: 5px 2px 5px 3px !important;
+}
+tr.even td, tr.pair td, tr.odd td, tr.impair td, form.odd div.tagtd, form.impair div.tagtd, form.pair div.tagtd, div.impair div.tagtd, div.pair div.tagtd, div.liste_titre div.tagtd {
+    padding: 5px 2px 5px 3px;
     border-bottom: 1px solid #ddd;
 }
-tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td {
+tr.even td .nobordernopadding tr td, tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td, tr.odd td .nobordernopadding tr td {
     border-bottom: 0px !important;
 }
 td.nobottom, td.nobottom {
@@ -1977,14 +1894,14 @@ div.liste_titre, tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.list
 {
     background: rgb(<?php echo $colorbacktitle1; ?>);
     background-repeat: repeat-x;
-	<?php if ($usecss3) { ?>
+
 	background-image: -o-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);
 	background-image: -moz-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);
 	background-image: -webkit-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);
 	background-image: -ms-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);
 	background-image: linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);
     font-weight: bold;
-	<?php } ?>
+
     color: #<?php echo $colortexttitle; ?>;
     font-family: <?php print $fontlist ?>;
     border-bottom: 1px solid #FDFFFF;
@@ -2097,14 +2014,14 @@ tr.box_titre {
     height: 26px;
     background: rgb(<?php echo $colorbacktitle1; ?>);
     background-repeat: repeat-x;
-	<?php if ($usecss3) { ?>
+
 	background-image: linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%);
 	background-image: -o-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%);
 	background-image: -moz-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%);
 	background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%);
 	background-image: -ms-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%);
 	background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, rgba(255,255,255,.3)), color-stop(1, rgba(0,0,0,.3)) );
-	<?php } ?>
+
     color: #<?php echo $colortexttitle; ?>;
 	text-shadow: 1px 0px 1px #<?php echo $colorshadowtitle; ?>;
     font-family: <?php print $fontlist ?>, sans-serif;
@@ -2118,30 +2035,17 @@ tr.box_titre td.boxclose {
 }
 
 tr.box_impair {
-<?php if ($usecss3) { ?>
     background: -o-linear-gradient(bottom, rgb(<?php echo $colorbacklineimpair1; ?>) 85%, rgb(<?php echo $colorbacklineimpair2; ?>) 100%);
     background: -moz-linear-gradient(bottom, rgb(<?php echo $colorbacklineimpair1; ?>) 85%, rgb(<?php echo $colorbacklineimpair2; ?>) 100%);
     background: -webkit-linear-gradient(bottom, rgb(<?php echo $colorbacklineimpair1; ?>) 85%, rgb(<?php echo $colorbacklineimpair2; ?>) 100%);
     background: -ms-linear-gradient(bottom, rgb(<?php echo $colorbacklineimpair1; ?>) 85%, rgb(<?php echo $colorbacklineimpair2; ?>) 100%);
     background: linear-gradient(bottom, rgb(<?php echo $colorbacklineimpair1; ?>) 85%, rgb(<?php echo $colorbacklineimpair2; ?>) 100%);
-<?php } else { ?>
-	background: #eaeaea;
-<?php } ?>
+
     font-family: <?php print $fontlist ?>;
 }
 
 
 tr.box_pair {
-/*<?php if ($usecss3) { ?>
-    background: -o-linear-gradient(bottom, rgb(<?php echo $colorbacklinepair1; ?>) 85%, rgb(<?php echo $colorbacklinepair2; ?>) 100%);
-    background: -moz-linear-gradient(bottom, rgb(<?php echo $colorbacklinepair1; ?>) 85%, rgb(<?php echo $colorbacklinepair2; ?>) 100%);
-    background: -webkit-linear-gradient(bottom, rgb(<?php echo $colorbacklinepair1; ?>) 85%, rgb(<?php echo $colorbacklinepair2; ?>) 100%);
-    background: -ms-linear-gradient(bottom, rgb(<?php echo $colorbacklinepair1; ?>) 85%, rgb(<?php echo $colorbacklinepair2; ?>) 100%);
-    background: linear-gradient(bottom, rgb(<?php echo $colorbacklinepair1; ?>) 85%, rgb(<?php echo $colorbacklinepair2; ?>) 100%);
-<?php } else { ?>
-	background: #ffffff;
-<?php } ?>
-*/
     font-family: <?php print $fontlist ?>;
 
 	background-color: #f9f9f9;
@@ -2997,11 +2901,13 @@ div.dolEventError h1, div.dolEventError h2 {
 /* ============================================================================== */
 /*  Datatable                                                                     */
 /* ============================================================================== */
-
-.sorting_asc  { background: url('<?php echo dol_buildpath('/theme/'.$theme.'/img/sort_asc.png',1); ?>') no-repeat center right; }
-.sorting_desc { background: url('<?php echo dol_buildpath('/theme/'.$theme.'/img/sort_desc.png',1); ?>') no-repeat center right; }
-.sorting_asc_disabled  { background: url('<?php echo dol_buildpath('/theme/'.$theme.'/img/sort_asc_disabled',1); ?>') no-repeat center right; }
-.sorting_desc_disabled { background: url('<?php echo dol_buildpath('/theme/'.$theme.'/img/sort_desc_disabled',1); ?>') no-repeat center right; }
+table.dataTable tr.odd td.sorting_1, table.dataTable tr.even td.sorting_1 {
+  background: none !important;
+}
+.sorting_asc  { background: url('<?php echo dol_buildpath('/theme/'.$theme.'/img/sort_asc.png',1); ?>') no-repeat center right !important; }
+.sorting_desc { background: url('<?php echo dol_buildpath('/theme/'.$theme.'/img/sort_desc.png',1); ?>') no-repeat center right !important; }
+.sorting_asc_disabled  { background: url('<?php echo dol_buildpath('/theme/'.$theme.'/img/sort_asc_disabled.png',1); ?>') no-repeat center right !important; }
+.sorting_desc_disabled { background: url('<?php echo dol_buildpath('/theme/'.$theme.'/img/sort_desc_disabled.png',1); ?>') no-repeat center right !important; }
 .paginate_disabled_previous:hover, .paginate_enabled_previous:hover, .paginate_disabled_next:hover, .paginate_enabled_next:hover
 {
 	font-weight: normal;
@@ -3195,14 +3101,14 @@ ul.ulmenu {
 	border: 1px solid #5f5f7a !important;
     background: rgb(<?php echo $colorbacktitle1; ?>);
     background-repeat: repeat-x;
-	<?php if ($usecss3) { ?>
+
 	background-image: -o-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);
 	background-image: -moz-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);
 	background-image: -webkit-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);
 	background-image: -ms-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);
 	background-image: linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);
     font-weight: bold;
-	<?php } ?>
+
     color: #<?php echo $colortexttitle; ?> !important;
 }
 .alilevel0 {