diff --git a/ChangeLog b/ChangeLog
index 98339d3874abcc8df439a2dd20f6608ac454302a..eb82166af8b258fa4b6e4e6a18a2b74211dca09a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,6 +43,12 @@ Dolibarr better:
 - All fields "fk_societe" were renamed into "fk_soc".
 - Method select_PriceBaseType and load_PriceBaseType were merged into selectPriceBaseType
 
+
+***** ChangeLog for 3.7.2 compared to 3.7.1 *****
+FIX [ bug #2855 ] Wrong translation key in localtax report page
+FIX [ bug #1852 ] JS error when editing a customer order line
+FIX [ bug #2900 ] Courtesy title is not stored in create thirdparty form
+
 ***** ChangeLog for 3.7.1 compared to 3.7.* *****
 FIX Bug in the new photo system
 FIX Error management
@@ -297,6 +303,7 @@ Dolibarr better:
 - Fix: [ bug #2545 ] Missing object_margin.png in Amarok theme
 - Fix: [ bug #2542 ] Contracts store localtax preferences
 - Fix: Bad permission assignments for stock movements actions
+- Fix: [ bug #2891 ] Category hooks do not work
 
 ***** ChangeLog for 3.6.2 compared to 3.6.1 *****
 - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.
@@ -471,6 +478,10 @@ Fix: [ bug #2577 ] Incorrect invoice status in "Linked objects" page of a projec
 Fix: [ bug #2576 ] Unable to edit a dictionary entry that has # in its ref
 Fix: [ bug #2758 ] Product::update sets product note to "null" when $prod->note is null
 Fix: [ bug #2757 ] Deleting product category photo gives "Forbidden access" error
+Fix: [ bug #2976 ] "Report" tab is the current tab but it is not marked as selected by the UI
+Fix: [ bug #2861 ] Undefined variable $res when migrating
+Fix: [ bug #2837 ] Product list table column header does not match column body
+Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order
 
 ***** ChangeLog for 3.5.6 compared to 3.5.5 *****
 Fix: Avoid missing class error for fetch_thirdparty method #1973
diff --git a/htdocs/cashdesk/facturation_dhtml.php b/htdocs/cashdesk/facturation_dhtml.php
index e481fcbecf63635263d67ea6c6dff4744af7829e..8d4ebf8af31c282c5693f558d7a7119e688158c7 100644
--- a/htdocs/cashdesk/facturation_dhtml.php
+++ b/htdocs/cashdesk/facturation_dhtml.php
@@ -1,6 +1,7 @@
 <?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
- * Copyright (C) 2008-2009 Laurent Destailleur   <eldy@uers.sourceforge.net>
+/* Copyright (C) 2007-2008 	Jeremie Ollivier 	<jeremie.o@laposte.net>
+ * Copyright (C) 2008-2009 	Laurent Destailleur <eldy@uers.sourceforge.net>
+ * Copyright (C) 2015		Regis Houssin		<regis.houssin@capnetworks.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -41,8 +42,10 @@ require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
 //header("Content-type: text/html; charset=UTF-8");
 header("Content-type: text/html; charset=".$conf->file->character_set_client);
 
+$search = GETPOST("code", "alpha");
+
 // Search from criteria
-if (dol_strlen($_GET["code"]) >= 0)	// If search criteria is on char length at least
+if (dol_strlen($search) >= 0)	// If search criteria is on char length at least
 {
 	$sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx";
 	if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
@@ -54,11 +57,15 @@ if (dol_strlen($_GET["code"]) >= 0)	// If search criteria is on char length at l
 	// Add criteria on ref/label
 	if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE))
 	{
-		$sql.= " AND (p.ref LIKE '".$_GET['code']."%' OR p.label LIKE '".$_GET['code']."%')";
+		$sql.= " AND (p.ref LIKE '".$db->escape($search)."%' OR p.label LIKE '".$db->escape($search)."%'";
+		if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$db->escape($search)."%'";
+		$sql.= ")";
 	}
 	else
 	{
-		$sql.= " AND (p.ref LIKE '%".$_GET['code']."%' OR p.label LIKE '%".$_GET['code']."%')";
+		$sql.= " AND (p.ref LIKE '%".$db->escape($search)."%' OR p.label LIKE '%".$db->escape($search)."%'";
+		if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '%".$db->escape($search)."%'";
+		$sql.= ")";
 	}
 	$sql.= " ORDER BY label";
 
diff --git a/htdocs/cashdesk/javascript/dhtml.js b/htdocs/cashdesk/javascript/dhtml.js
index caf0cd94abd1e0a1ea96a58d85cee395ae68e2ee..a2af98d65a8701da21864f78735b98e2efe76c51 100644
--- a/htdocs/cashdesk/javascript/dhtml.js
+++ b/htdocs/cashdesk/javascript/dhtml.js
@@ -1,5 +1,6 @@
 
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
+/* Copyright (C) 2007-2008	Jeremie Ollivier	<jeremie.o@laposte.net>
+ * Copyright (C) 2015		Regis Houssin		<regis.houssin@capnetworks.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -59,8 +60,8 @@ function afficheDonnees(aId, aTexte) {
 
 
 // aCible : id du bloc de destination; aCode : argument a passer a la page php chargee du traitement et de l'affichage
-function verifResultat(aCible, aCode) {
-	if (aCode != '') {
+function verifResultat(aCible, aCode, iLimit = 1) {
+	if (aCode != '' && aCode.length >= iLimit) {
 
 		if (texte = file ('facturation_dhtml.php?code='+escape(aCode))) {
 
diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php
index b004314f66c74cb48b75962ac352362487abb420..b9335e804469ef965f32c4fa876a8be3bcecf0c5 100644
--- a/htdocs/cashdesk/tpl/facturation1.tpl.php
+++ b/htdocs/cashdesk/tpl/facturation1.tpl.php
@@ -2,6 +2,7 @@
 /* Copyright (C) 2007-2008	Jeremie Ollivier	<jeremie.o@laposte.net>
  * Copyright (C) 2011		Laurent Destailleur	<eldy@users.sourceforge.net>
  * Copyright (C) 2011		Juanjo Menent		<jmenent@2byte.es>
+ * Copyright (C) 2015		Regis Houssin		<regis.houssin@capnetworks.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -43,8 +44,8 @@ $langs->load("cashdesk");
 			<!-- Affichage de la reference et de la designation -->
 			<td><input class="texte_ref" type="text" id ="txtRef" name="txtRef" value="<?php echo $obj_facturation->ref() ?>"
 				onchange="javascript: setSource('REF');"
-				onkeyup="javascript: verifResultat('resultats_dhtml', this.value);"
-				onfocus="javascript: this.select(); verifResultat('resultats_dhtml', this.value);"
+				onkeyup="javascript: verifResultat('resultats_dhtml', this.value, <?php echo (isset($conf->global->BARCODE_USE_SEARCH_TO_SELECT) ? (int) $conf->global->BARCODE_USE_SEARCH_TO_SELECT : 1) ?>);"
+				onfocus="javascript: this.select(); verifResultat('resultats_dhtml', this.value, <?php echo (isset($conf->global->BARCODE_USE_SEARCH_TO_SELECT) ? (int) $conf->global->BARCODE_USE_SEARCH_TO_SELECT : 1) ?>);"
 				onBlur="javascript: document.getElementById('resultats_dhtml').innerHTML = '';"/>
 			</td>
 			<td class="select_design">
diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php
index 7ba04331454127b95ad360f011d44b16331a249c..814badf95a769fc5dbbe6b96d3fac12ad8162f16 100644
--- a/htdocs/categories/card.php
+++ b/htdocs/categories/card.php
@@ -65,6 +65,10 @@ $object = new Categorie($db);
 $extrafields = new ExtraFields($db);
 $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
 
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('categorycard'));
+
+
 /*
  *	Actions
  */
diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php
index c3acb807e01a7ae9df5fa7d29d5f1669f1f3f411..a10823e609808a92ed0f754ebce2dd58e9b0312f 100644
--- a/htdocs/categories/edit.php
+++ b/htdocs/categories/edit.php
@@ -56,6 +56,9 @@ $object = new Categorie($db);
 $extrafields = new ExtraFields($db);
 $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
 
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('categorycard'));
+
 /*
  * Actions
  */
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 36e6f53ecc3901ed5c6e06494bd0d614c0207851..87d6dc57d6301a683a99dfdac2530070c4bcfd92 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -64,6 +64,9 @@ $type=$object->type;
 $extrafields = new ExtraFields($db);
 $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
 
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('categorycard'));
+
 /*
  *	Actions
  */
diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php
index 08a76512cf49bb72ca6e2d8389159ef90deb636a..d81390a0205ac722ca1c9b1cb200ea87576d8ac2 100644
--- a/htdocs/compta/bank/virement.php
+++ b/htdocs/compta/bank/virement.php
@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2009 Regis Houssin        <regis.houssin@capnetworks.com>
+ * Copyright (C) 2005-2015 Regis Houssin        <regis.houssin@capnetworks.com>
  * Copyright (C) 2012	   Juanjo Menent        <jmenent@2byte.es>
  * Copyright (C) 2015      Jean-François Ferry	<jfefe@aternatik.fr>
  * Copyright (C) 2015      Marcos García        <marcosgdf@gmail.com>
@@ -177,7 +177,7 @@ $form->select_comptes($account_to,'account_to',0,'',1);
 print "</td>\n";
 
 print "<td>";
-$form->select_date($dateo,'','','','','add');
+$form->select_date((! empty($dateo)?$dateo:''),'','','','','add');
 print "</td>\n";
 print '<td><input name="label" class="flat" type="text" size="40" value="'.$label.'"></td>';
 print '<td><input name="amount" class="flat" type="text" size="8" value="'.$amount.'"></td>';
diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php
index 90d6cbe8599cda83449fcee00e6adb6d9bd11cfe..31eaf4375c3c75c91decc88fd9c902443c11e358 100644
--- a/htdocs/compta/localtax/clients.php
+++ b/htdocs/compta/localtax/clients.php
@@ -109,7 +109,7 @@ $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
 if ($conf->global->$calc==0 || $conf->global->$calc==1)	// Calculate on invoice for goods and services
 {
     $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code);
-    $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec");
+    $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
     $calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
     $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
     if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php
index 612014ac74133086f848a55d59a091de7717a273..7396c6251658863a18eb5f4be4715c51e6a21b1c 100644
--- a/htdocs/compta/localtax/quadri_detail.php
+++ b/htdocs/compta/localtax/quadri_detail.php
@@ -129,7 +129,7 @@ $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
 if ($conf->global->$calc==0 || $conf->global->$calc==1)	// Calculate on invoice for goods and services
 {
     $nom=$langs->trans($local==1?"LT1ReportByQuartersInDueDebtMode":"LT2ReportByQuartersInDueDebtMode");
-    $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec");
+    $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
     $calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
     $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
     $prevyear=$year_start; $prevquarter=$q;
@@ -161,7 +161,7 @@ if ($conf->global->$calc==0 || $conf->global->$calc==1)	// Calculate on invoice
 if ($conf->global->$calc==2) 	// Invoice for goods, payment for services
 {
     $nom=$langs->trans($local==1?"LT1ReportByQuartersInInputOutputMode":"LT2ReportByQuartersInInputOutputMode");
-    $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec");
+    $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
     $calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
     $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
     $prevyear=$year_start; $prevquarter=$q;
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 48bbe2ace8daf116d0759e854a636aac4d2d1307..8d5d3196f227a896f13b018f2ac266223236a0e4 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -218,7 +218,7 @@ function dol_shutdown()
 	global $conf,$user,$langs,$db;
 	$disconnectdone=false; $depth=0;
 	if (is_object($db) && ! empty($db->connected)) { $depth=$db->transaction_opened; $disconnectdone=$db->close(); }
-	dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth)?' (Warn: db disconnection forced, transaction depth was '.$depth.')':''), (($disconnectdone && $depth)?LOG_WARNING:LOG_DEBUG));
+	dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth)?' (Warn: db disconnection forced, transaction depth was '.$depth.')':''), (($disconnectdone && $depth)?LOG_WARNING:LOG_INFO));
 }
 
 
diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php
index 4fcb087ba184507da9d074a9b534c070a6463883..681f6e7a913c70aacb2e4bb82fbac01ddb1a11bc 100644
--- a/htdocs/core/lib/report.lib.php
+++ b/htdocs/core/lib/report.lib.php
@@ -39,7 +39,7 @@
 */
 function report_header($nom,$variante,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='')
 {
-	global $langs, $hselected;
+	global $langs;
 
 	if (empty($hselected)) $hselected='report';
 	
@@ -50,7 +50,7 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat
 	$head[$h][1] = $langs->trans("Report");
 	$head[$h][2] = 'report';
 
-	dol_fiche_head($head, $hselected);
+	dol_fiche_head($head, 'report');
 
 	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
 	foreach($moreparam as $key => $value)
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index 9c6cfd2e1bea015808b072649ace0f61371a852f..db55be8754c536d6429f7f6e557add5bc82f1a74 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -215,7 +215,7 @@ else {
 	<?php } ?>
 
 	<td class="nobottom" align="right"><?php
-	if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">0';
+	if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate(0, true);
 	else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer);
 	?>
 	</td>
diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php
index d64ef7a2b3e2c2e74f838d7e929352b783100a08..51ded55f1c778286d9d1ad9953d94cc0afec934c 100644
--- a/htdocs/core/tpl/objectline_edit.tpl.php
+++ b/htdocs/core/tpl/objectline_edit.tpl.php
@@ -292,10 +292,10 @@ if (! empty($conf->margin->enabled))
 		{
 		?>
 			$('#savelinebutton').click(function (e) {
-				return checkEditLine(e, "marginRate");
+				return checkEditLine(e, "np_marginRate");
 			});
 			$("input[name='np_marginRate']:first").blur(function(e) {
-				return checkEditLine(e, "marginRate");
+				return checkEditLine(e, "np_marginRate");
 			});
 		<?php
 		}
@@ -303,10 +303,10 @@ if (! empty($conf->margin->enabled))
 		{
 		?>
 			$('#savelinebutton').click(function (e) {
-				return checkEditLine(e, "markRate");
+				return checkEditLine(e, "np_markRate");
 			});
 			$("input[name='np_markRate']:first").blur(function(e) {
-				return checkEditLine(e, "markRate");
+				return checkEditLine(e, "np_markRate");
 			});
 		<?php
 		}
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index bb574a68b778455bdf8143d42d9b37c92e762316..03f776ce6d5e9da50397378a25c6da9496197090 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -539,7 +539,7 @@ if (! defined('NOLOGIN'))
     {
         // We are already into an authenticated session
         $login=$_SESSION["dol_login"];
-        dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login);
+        dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login, LOG_DEBUG);
 
         $resultFetchUser=$user->fetch('',$login);
         if ($resultFetchUser <= 0)
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index beb01758aad0a25e817472763786f83539e431e3..08c391c11c4e00051ab4f97168ed211dab8cbecb 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -10,7 +10,7 @@
  * Copyright (C) 2012-2013	Cédric Salvador			<csalvador@gpcsolutions.fr>
  * Copyright (C) 2011-2014	Alexandre Spangaro		<alexandre.spangaro@gmail.com>
  * Copyright (C) 2014		Cédric Gross			<c.gross@kreiz-it.fr>
- * Copyright (C) 2014		Ferran Marcet			<fmarcet@2byte.es>
+ * Copyright (C) 2014-2015	Ferran Marcet			<fmarcet@2byte.es>
  * Copyright (C) 2015       Jean-François Ferry     <jfefe@aternatik.fr>
  * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
@@ -790,8 +790,13 @@ else
 		if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM))
 		{
 			$module=strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM);
-        	$result=dol_include_once('/core/modules/barcode/'.$module.'.php');
-        	if ($result > 0)
+			$dirbarcode=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']);
+            foreach ($dirbarcode as $dirroot)
+            {
+                $res=dol_include_once($dirroot.$module.'.php');
+                if ($res) break;
+            }
+        	if ($res > 0)
         	{
 				$modBarCodeProduct =new $module();
         	}
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index 71e51e23c52f2aa02b723d4216209abc03a1c530..3c68f2617329fe201919fc255e2a3bcbc6930c1c 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -50,8 +50,8 @@ $sall=GETPOST("sall");
 $type=GETPOST("type","int");
 $search_sale = GETPOST("search_sale");
 $search_categ = GETPOST("search_categ",'int');
-$tosell = GETPOST("tosell");
-$tobuy = GETPOST("tobuy");
+$tosell = GETPOST("tosell", 'int');
+$tobuy = GETPOST("tobuy", 'int');
 $fourn_id = GETPOST("fourn_id",'int');
 $catid = GETPOST('catid','int');
 
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index d29df98ff316d9fc8bb83332d3644cd7773670dc..1e454ca724b38629d5df88e08e7ca85925ef8382 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -830,9 +830,8 @@ $sql .= " " . MAIN_DB_PREFIX . "user as u";
 $sql .= " WHERE fk_product = " . $object->id;
 $sql .= " AND p.entity IN (" . getEntity('productprice', 1) . ")";
 $sql .= " AND p.fk_user_author = u.rowid";
-if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES))
-	$sql .= " AND p.price_level = " . $soc->price_level;
-$sql .= " ORDER BY p.date_price DESC, p.price_level ASC";
+if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES)) $sql .= " AND p.price_level = " . $soc->price_level;
+$sql .= " ORDER BY p.date_price DESC, p.price_level ASC, p.rowid DESC";
 // $sql .= $db->plimit();
 
 $result = $db->query($sql);
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 70ec2a08a49f1c62cf0225c91373afdc7c72b809..e4098332e64b179c4dc4fc4c638ecf0bdb8db6c6 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -243,7 +243,7 @@ if (empty($reshook))
             $object->particulier       = GETPOST("private");
 
             $object->name              = dolGetFirstLastname(GETPOST('firstname','alpha'),GETPOST('name','alpha'));
-            $object->civility_id       = GETPOST('civility_id', 'int');
+            $object->civility_id       = GETPOST('civility_id');	// Note: cibility id is a code, not an int
             // Add non official properties
             $object->name_bis          = GETPOST('name','alpha');
             $object->firstname         = GETPOST('firstname','alpha');