diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 5e96d038314da91705193d5de8e8c24f433fdb40..1bdf4e75e5db5842f6e86b5a2a5db41ef1d88c2d 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -207,8 +207,9 @@ if ($id > 0)
 
 	dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"),0,'company');
 
-
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+	$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+	
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
         
 	print '<div class="fichecenter"><div class="fichehalfleft">';
 
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 31a7a5eec6a75ca4b00e0a18fc68d505de7d72dc..347d77e84dd15705dd573d2b9933ba5bc95ff0f1 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -1427,7 +1427,7 @@ else
             {
                 $total = 0;
 
-                print '<tr class="liste_titre">';
+                print '<tr class="liste_titre'.($cursorline?' liste_titre_add':'').'">';
                 print '<td>'.$langs->trans("ServiceNb",$cursorline).'</td>';
                 print '<td width="50" align="center">'.$langs->trans("VAT").'</td>';
                 print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>';
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 5731ba7c63d948054cd2e77d42494cd9ad48d77d..3e7d02ed67a6c5f0eb28a0c57f04389e738e4741 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4211,7 +4211,9 @@ abstract class CommonObject
     						$object = new $InfoFieldList[0]($this->db);
     						if ($value)
     						{
-    							$res=$object->fetch(0,$value);
+    							if (is_numeric($value)) $res=$object->fetch($value);
+								else $res=$object->fetch('',$value);
+								
     							if ($res > 0) $this->array_options[$key]=$object->id;
     							else
     							{
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index da1980279361eef64d9e6ff62f78183acc339b85..b035095b1a78dd0c82a4c5612a0fff0b26f766fb 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1133,7 +1133,7 @@ class Form
         $resql=$this->db->query($sql);
         if ($resql)
         {
-            print '<select class="flat" name="'.$htmlname.'">';
+            print '<select class="flat maxwidthonsmartphone" name="'.$htmlname.'">';
             $num = $this->db->num_rows($resql);
 
             $qualifiedlines=$num;
diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php
index dd4096c525786b0220176d7a3731a74256f795e0..2724d64f17f05f265b4f7b5915108cd3e4d0a125 100644
--- a/htdocs/core/class/utils.class.php
+++ b/htdocs/core/class/utils.class.php
@@ -168,7 +168,7 @@ class Utils
 
 		// Check type parameter
 		if ($type == 'auto') $type = $db->type;
-		if (! in_array($type, array('pgsql', 'mysql', 'mysqli')))
+		if (! in_array($type, array('pgsql', 'mysql', 'mysqli','mysqlnobin')))
 		{
 		    $langs->load("errors");
 		    $this->error=$langs->transnoentitiesnoconv("ErrorBadValueForParameter", $type, "Basetype");
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index 0ab255c6f99907bf5666c47feedcc9526373f301..62866e31ea17a7104dad97c1182a269376bca413 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -56,7 +56,7 @@ if (in_array($object->element,array('propal', 'supplier_proposal','facture','fac
 $nolinesbefore=(count($this->lines) == 0);
 if ($nolinesbefore) {
 ?>
-<tr class="liste_titre nodrag nodrop">
+<tr class="liste_titre<?php echo (($nolinesbefore || $object->element=='contrat')?'':' liste_titre_add') ?> nodrag nodrop">
 	<td class="linecoldescription" <?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
 	<div id="add"></div><span class="hideonsmartphone"><?php echo $langs->trans('AddNewLine'); ?></span><?php // echo $langs->trans("FreeZone"); ?>
 	</td>
diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php
index 39f0009fbf48f83f13929545d3977c5a51495868..195dff26029f99d3ee808fbdd03be9f5c9d8f3a2 100644
--- a/htdocs/fourn/card.php
+++ b/htdocs/fourn/card.php
@@ -132,7 +132,9 @@ if ($object->id > 0)
 
 	dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"),0,'company');
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+	$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+	
+	dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
         
 	print '<div class="fichecenter"><div class="fichehalfleft">';
 
diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php
index d731c4b6200534fa6eb1ad354f0c08c525180929..d184845cb766090336357ac6683b3f21c3a4b1d0 100644
--- a/htdocs/fourn/commande/list.php
+++ b/htdocs/fourn/commande/list.php
@@ -130,8 +130,8 @@ if (empty($user->socid)) $fieldstosearchall["cf.note_private"]="NotePrivate";
 $checkedtypetiers=0;
 $arrayfields=array(
     'cf.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
-    'cf.ref_supplier'=>array('label'=>$langs->trans("RefOrderSupplier"), 'checked'=>1, 'enabled'=>$conf->global->SUPPLIER_ORDER_HIDE_REF_SUPPLIER),
-    'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'enabled'=>$conf->global->PROJECT_SHOW_REF_INTO_LISTS),
+    'cf.ref_supplier'=>array('label'=>$langs->trans("RefOrderSupplier"), 'checked'=>1, 'enabled'=>1),
+    'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>1),
     'u.login'=>array('label'=>$langs->trans("AuthorRequest"), 'checked'=>1),
     's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
     's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
index a747164e04c29621ce1dd041dd0c77d60d88af4b..9e1fe2498342b3bd48706a86982a7548f64c2511 100644
--- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
+++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
@@ -61,6 +61,10 @@ CREATE TABLE llx_product_lot (
 
 ALTER TABLE llx_product_lot ADD UNIQUE INDEX uk_product_lot(fk_product, batch);
 
+-- VPGSQL8.2 ALTER TABLE llx_product_lot ALTER COLUMN entity SET DEFAULT 1;
+ALTER TABLE llx_product_lot MODIFY COLUMN entity integer DEFAULT 1;
+UPDATE llx_product_lot SET entity = 1 WHERE entity IS NULL;
+
 DROP TABLE llx_stock_serial; 
 
 ALTER TABLE llx_product ADD COLUMN note_public text;
diff --git a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql
index 74661088751e140a7cb500c370aefa82acd1c8b0..545807c8aedb87c50079e40bf7523f2012dbb6de 100644
--- a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql
+++ b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql
@@ -23,5 +23,5 @@ CREATE TABLE llx_multicurrency_rate
 	date_sync datetime DEFAULT NULL,  
 	rate double NOT NULL DEFAULT 0, 
 	fk_multicurrency integer NOT NULL,
-	entity integer DEFAULT 1,
-) ENGINE=innodb;
\ No newline at end of file
+	entity integer DEFAULT 1
+) ENGINE=innodb;
diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php
index 1d4d1f8f0ca78b2b83ca49e531627b0fedeb23ad..4797f0985e0ecca6acb85dc2c8ab25d85caf8f2f 100644
--- a/htdocs/margin/tabs/thirdpartyMargins.php
+++ b/htdocs/margin/tabs/thirdpartyMargins.php
@@ -91,7 +91,9 @@ if ($socid > 0)
 
     dol_fiche_head($head, 'margin', $langs->trans("ThirdParty"),0,'company');
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+    
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
     
     print '<div class="fichecenter">';
     
diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php
index 26ee7fe567c0641f22a7dc6e8975d70f84c214fa..dc0acb48d9681f4a9dd137689dd49592348bc5c7 100644
--- a/htdocs/opensurvey/card.php
+++ b/htdocs/opensurvey/card.php
@@ -48,8 +48,8 @@ $object=new Opensurveysondage($db);
 $result=$object->fetch(0, $numsondage);
 if ($result <= 0)
 {
-	dol_print_error($db,$object->error);
-	exit;
+    dol_print_error($db,$object->error);
+    exit;
 }
 
 $expiredate=dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear'));
@@ -206,7 +206,6 @@ foreach ($toutsujet as $value)
 $toutsujet=str_replace("@","<br>",$toutsujet);
 $toutsujet=str_replace("°","'",$toutsujet);
 
-
 print '<form name="updatesurvey" action="'.$_SERVER["PHP_SELF"].'?id='.$numsondage.'" method="POST">'."\n";
 print '<input type="hidden" name="action" value="update">';
 
@@ -444,8 +443,6 @@ if ($object->allow_comments) {
 
 print '</form>';
 
-print '<br>';
-
-llxFooterSurvey();
+llxFooter();
 
 $db->close();
diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php
index 02952f4bf7524f6e4f561a783f3dc0fc9419c443..5ad27731d88de937afa5911529b6cd76f35b3903 100644
--- a/htdocs/opensurvey/class/opensurveysondage.class.php
+++ b/htdocs/opensurvey/class/opensurveysondage.class.php
@@ -228,8 +228,7 @@ class Opensurveysondage extends CommonObject
                 $obj = $this->db->fetch_object($resql);
 
 				$this->id_sondage = $obj->id_sondage;
-				//For compatibility
-				$this->ref = $this->id_sondage;
+				$this->ref = $this->id_sondage;             //For compatibility
 
 				$this->commentaires = $obj->description;	// deprecated
 				$this->description = $obj->description;
diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php
index 834f17b8b2c6ae82e307c0bf5308003cf95cea08..6f242a00544c2bbe84f6ae29877c86d21e010ab4 100644
--- a/htdocs/public/opensurvey/studs.php
+++ b/htdocs/public/opensurvey/studs.php
@@ -41,7 +41,6 @@ if (GETPOST('sondage'))
 
 $object=new Opensurveysondage($db);
 $result=$object->fetch(0,$numsondage);
-if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
 
 $nblignes=$object->fetch_lines();
 
@@ -241,6 +240,16 @@ $arrayofjs=array();
 $arrayofcss=array('/opensurvey/css/style.css');
 llxHeaderSurvey($object->titre, "", 0, 0, $arrayofjs, $arrayofcss);
 
+if (empty($object->ref))     // For survey, id is a hex string
+{
+    $langs->load("errors");
+    print $langs->trans("ErrorRecordNotFound");
+
+    llxFooterSurvey();
+
+    $db->close();
+    exit;
+}
 
 // Define format of choices
 $toutsujet=explode(",",$object->sujet);
diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php
index 7d68e06726536f00c885775e5c055ea7642f9f9e..4a46a5ed934139741876613e68d9b014909b163f 100644
--- a/htdocs/societe/agenda.php
+++ b/htdocs/societe/agenda.php
@@ -81,7 +81,9 @@ if ($socid)
 
 	dol_fiche_head($head, 'agenda', $langs->trans("ThirdParty"),0,'company');
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+	
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
         
     print '<div class="fichecenter">';
     
diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php
index e0f5ab7ec91a4c219bcbef4be5ee12b17c3abcef..dd8802779b8f6ee1251cab0f86bd832815592a3c 100644
--- a/htdocs/societe/commerciaux.php
+++ b/htdocs/societe/commerciaux.php
@@ -114,7 +114,9 @@ if (! empty($socid))
 
 	dol_fiche_head($head, 'salesrepresentative', $langs->trans("ThirdParty"),0,'company');
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+	
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
         
 	print '<div class="fichecenter">';
 
diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php
index eb912548caa44b55862309aefa742d266d599e17..da3792d089759b1563cbcd42bc0da4210ffeef91 100644
--- a/htdocs/societe/consumption.php
+++ b/htdocs/societe/consumption.php
@@ -114,7 +114,9 @@ if (empty($socid))
 $head = societe_prepare_head($object);
 dol_fiche_head($head, 'consumption', $langs->trans("ThirdParty"),0,'company');
 
-dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+
+dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
 
 print '<div class="fichecenter">';
 
diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php
index 4ad8abc9a4307032011d5003e5203493066f345f..e64c9c49656b7bcf9d8ce3ab560a7743c7459085 100644
--- a/htdocs/societe/document.php
+++ b/htdocs/societe/document.php
@@ -109,7 +109,9 @@ if ($object->id)
 		$totalsize+=$file['size'];
 	}
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+	
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
         
     print '<div class="fichecenter">';
     
diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php
index 27eb643bc160fb9181de7d5487e4c81851ce7745..e88f94e4287b4958c764712da6e1295ca0fb7986 100644
--- a/htdocs/societe/note.php
+++ b/htdocs/societe/note.php
@@ -73,7 +73,9 @@ if ($id > 0)
 
     dol_fiche_head($head, 'note', $langs->trans("ThirdParty"),0,'company');
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+    
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
 
     $cssclass='titlefield';
     //if ($action == 'editnote_public') $cssclass='titlefieldcreate';
diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php
index b3617a12b2798111ee96b8bbc32befd8076254b8..bc754d8e9a439c9ff477743bf04efe1bdd368396 100644
--- a/htdocs/societe/notify/card.php
+++ b/htdocs/societe/notify/card.php
@@ -155,7 +155,9 @@ if ($result > 0)
 
     dol_fiche_head($head, 'notify', $langs->trans("ThirdParty"),0,'company');
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+    
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
         
     print '<div class="fichecenter">';
     
diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php
index 4c98860341774bec2d9658c85e626e2ef3a36b79..9236fc35f6f0bf39af524bb166647c8f9dbbf922 100644
--- a/htdocs/societe/price.php
+++ b/htdocs/societe/price.php
@@ -151,7 +151,9 @@ $head = societe_prepare_head($object);
 
 dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), 0, 'company');
 
-dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+
+dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
     
 print '<div class="fichecenter">';
 
diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php
index f99bd517975dc5727b7c0b9cfa1d16f9cd5833dc..fe206dd4cc5b88979b391ec771f79053737316ae 100644
--- a/htdocs/societe/project.php
+++ b/htdocs/societe/project.php
@@ -81,7 +81,9 @@ if ($socid)
 
 	dol_fiche_head($head, 'project', $langs->trans("ThirdParty"),0,'company');
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+	
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
         
     print '<div class="fichecenter">';
     
diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php
index 1adc9611213707e17f1a09bd74133232e137361d..810984a4a408312c1cf374cd809a1b04eac81651 100644
--- a/htdocs/societe/rib.php
+++ b/htdocs/societe/rib.php
@@ -285,7 +285,9 @@ if ($socid && $action != 'edit' && $action != "create")
         print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $account->getRibLabel()), "confirm_delete", '', 0, 1);
     }
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
 
     print '<div class="fichecenter">';
 
@@ -486,7 +488,9 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
 {
 	dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
 
     print '<div class="fichecenter">';
 
@@ -588,7 +592,9 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
 {
 	dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
 
-    dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+    $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
 
     print '<div class="fichecenter">';
 
diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php
index 69298f263e83b1a363021d5daad47d6493e78fc3..4ed1852da8042519be10809bdd7df5ffbba09801 100644
--- a/htdocs/societe/societecontact.php
+++ b/htdocs/societe/societecontact.php
@@ -149,7 +149,9 @@ if ($id > 0 || ! empty($ref))
 		print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 
-        dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
+        $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
+		
+        dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
             
     	print '<div class="fichecenter">';