diff --git a/README-FR.md b/README-FR.md
index b3ce951c9752dd860b48b07e35d02f38e1f450c2..55065d5d15fa95ea0ab554c29ceea51f3b6a29be 100644
--- a/README-FR.md
+++ b/README-FR.md
@@ -3,7 +3,7 @@
 Dolibarr ERP & CRM est un logiciel moderne pour gérer votre activité (société, association, auto-entrepreneurs, artisans). 
 Il est simple d'utilisation et modulaire, vous permettant de n'activez que les fonctions dont vous avez besoin (contacts, fournisseurs, factures, commandes, stocks, agenda, ...).
  
-![ScreenShot](http://www.dolibarr.org/images/dolibarr_screenshot1_640x480.png)
+![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_640x480.png)
 
 
 
@@ -23,7 +23,7 @@ Ubuntu) ou DoliRpm (la version tout-en-un de Dolibarr pour Fedora, Redhat,
 OpenSuse, Mandriva ou Mageia).
 
 Vous pouvez les télécharger depuis la rubrique *download* du portail officiel: 
-http://www.dolibarr.org/
+https://www.dolibarr.org/
 
 Si vous avez déjà installé un serveur Web avec PHP et une base de donnée (Mysql),
 vous pouvez installer Dolibarr avec cette version de la manière suivante:
@@ -139,13 +139,13 @@ Suivez le projet Dolibarr project sur les réseaux francophones
 
 - Facebook: <https://www.facebook.com/dolibarr.fr>
 - Google+: <https://plus.google.com/+DolibarrFrance>
-- Twitter: <http://www.twitter.com/dolibarr_france>
+- Twitter: <https://www.twitter.com/dolibarr_france>
 
 ou sur les réseaux anglophones
 
 - [Facebook](https://www.facebook.com/dolibarr)
 - [Google+](https://plus.google.com/+DolibarrOrg)
-- [Twitter](http://www.twitter.com/dolibarr)
+- [Twitter](https://www.twitter.com/dolibarr)
 - [LinkedIn](https://www.linkedin.com/company/association-dolibarr)
 - [YouTube](https://www.youtube.com/user/DolibarrERPCRM)
 - [GitHub](https://github.com/Dolibarr/dolibarr)
diff --git a/README.md b/README.md
index 28e06f8fa2ba84b04c92154e7a5779a9857fefef..3eb0941568a5546cc7849f94d03d43cacf0676b5 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ You can freely use, study, modify or distribute it according to its Free Softwar
 
 You can use it as a standalone application or as a web application to be able to access it from the Internet or a LAN.
 
-![ScreenShot](http://www.dolibarr.org/images/dolibarr_screenshot1_640x400.png)
+![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_640x400.png)
 
 ## LICENSE
 
@@ -24,7 +24,7 @@ Other licenses apply for some included dependencies. See [COPYRIGHT](https://git
 
 ### Download
 
-Releases can be downloaded from [official website](http://www.dolibarr.org/).
+Releases can be downloaded from [official website](https://www.dolibarr.org/).
 
 ### Simple setup
 
@@ -133,7 +133,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
 
 ### Extending
 
-Dolibarr can be extended with a lot of other external modules from third party developers available at the [DoliStore](http://www.dolistore.com).
+Dolibarr can be extended with a lot of other external modules from third party developers available at the [DoliStore](https://www.dolistore.com).
 
 ## FUTURE
 
@@ -165,7 +165,7 @@ Follow Dolibarr project on:
 
 - [Facebook](https://www.facebook.com/dolibarr)
 - [Google+](https://plus.google.com/+DolibarrOrg)
-- [Twitter](http://www.twitter.com/dolibarr)
+- [Twitter](https://www.twitter.com/dolibarr)
 - [LinkedIn](https://www.linkedin.com/company/association-dolibarr)
 - [YouTube](https://www.youtube.com/user/DolibarrERPCRM)
 - [GitHub](https://github.com/Dolibarr/dolibarr)
diff --git a/htdocs/commande/class/api_deprecated_commande.class.php b/htdocs/commande/class/api_deprecated_commande.class.php
index 2a8caf5321e049fd83bd41ee212ae623e0022fc9..b36ea27f6ccd11baad9dc912825df3ab0278a31d 100644
--- a/htdocs/commande/class/api_deprecated_commande.class.php
+++ b/htdocs/commande/class/api_deprecated_commande.class.php
@@ -160,6 +160,7 @@ class CommandeApi extends DolibarrApi
         
         if ($result)
         {
+        	$i=0;
             $num = $db->num_rows($result);
             while ($i < $num)
             {
diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php
index 4bbb3def84333825265f2718dec52b6966570df2..f9767c74695ed5cbc6b90c7fe80e779b641baaca 100644
--- a/htdocs/commande/orderstoinvoice.php
+++ b/htdocs/commande/orderstoinvoice.php
@@ -665,7 +665,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
 
 			print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 			print '<td class="nobordernopadding nowrap">';
-			print $generic_commande->getNomUrl(1,$objp->fk_statut);
+			print $generic_commande->getNomUrl(1,0);
 			print '</td>';
 
 			print '<td width="20" class="nobordernopadding nowrap">';
diff --git a/htdocs/compta/facture/class/api_deprecated_invoice.class.php b/htdocs/compta/facture/class/api_deprecated_invoice.class.php
index 826cc7371a41167d455ff380a4c3951d0d0cf8ab..353a48b79efb8e9eeb238e8596634d4ace5645ab 100644
--- a/htdocs/compta/facture/class/api_deprecated_invoice.class.php
+++ b/htdocs/compta/facture/class/api_deprecated_invoice.class.php
@@ -158,6 +158,7 @@ class InvoiceApi extends DolibarrApi
         $result = $db->query($sql);
         if ($result)
         {
+            $i=0;
             $num = $db->num_rows($result);
             while ($i < $num)
             {
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 8e87f11b844fabae27f9b4811eaeba82ae8af696..e3c0faff35e7031114b9d91edbac730a9d960520 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -366,7 +366,7 @@ $sql.=$hookmanager->resPrint;
 
 if (! $sall)
 {
-    $sql.= ' GROUP BY f.rowid, f.facnumber, ref_client, f.type, f.note_private, f.note_public, f.increment, f.total, f.tva, f.total_ttc,';
+    $sql.= ' GROUP BY f.rowid, f.facnumber, ref_client, f.type, f.note_private, f.note_public, f.increment, fk_mode_reglement, f.total, f.tva, f.total_ttc,';
     $sql.= ' f.datef, f.date_lim_reglement,';
     $sql.= ' f.paye, f.fk_statut,';
     $sql.= ' f.datec, f.tms,';
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 78752bdba0332c483c30a9e840665f5c95519d2c..48a10861a9eb4d2c1713d1757b42a94e029b013d 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -474,13 +474,16 @@ class Contact extends CommonObject
 	 *
 	 *  @param      int			$id         Id of contact
 	 *  @param      User		$user		User asking to change alert or birthday
+	 *  @param      int		    $notrigger	0=no, 1=yes
      *  @return     int         			<0 if KO, >=0 if OK
 	 */
-	function update_perso($id, $user=null)
+	function update_perso($id, $user=null, $notrigger=0)
 	{
 	    $error=0;
 	    $result=false;
 
+	    $this->db->begin();
+	    
 		// Mis a jour contact
 		$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET";
 		$sql.= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null");
@@ -531,6 +534,26 @@ class Contact extends CommonObject
 			}
 		}
 
+		if (! $error && ! $notrigger)
+		{
+		    // Call trigger
+		    $result=$this->call_trigger('CONTACT_MODIFY',$user);
+		    if ($result < 0) { $error++; }
+		    // End call triggers
+		}
+		
+		if (! $error)
+		{
+		    $this->db->commit();
+		    return 1;
+		}
+		else
+		{
+		    dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR);
+		    $this->db->rollback();
+		    return -$error;
+		}
+		
 		return $result;
 	}
 
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index da70bc3e007324c853c17090a7f734ca85104552..5feafcbb6b3144972f006899b9ac905f32d6dea3 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -135,11 +135,9 @@ $object->fetch($id, $user);
 
 $head = contact_prepare_head($object);
 
-dol_fiche_head($head, 'perso', $title, 0, 'contact');
-
 if ($action == 'edit')
 {
-	/*
+    /*
 	 * Fiche en mode edition
 	 */
 
@@ -148,6 +146,8 @@ if ($action == 'edit')
     print '<input type="hidden" name="action" value="update">';
     print '<input type="hidden" name="id" value="'.$object->id.'">';
 
+    dol_fiche_head($head, 'perso', $title, 0, 'contact');
+    
     print '<table class="border" width="100%">';
 
     // Ref
@@ -213,8 +213,10 @@ if ($action == 'edit')
     }
     print '</tr>';
 
-    print "</table><br>";
+    print "</table>";
 
+    dol_fiche_end();
+    
     print '<div class="center">';
     print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
     print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
@@ -227,6 +229,8 @@ else
 {
     // View mode
     
+    dol_fiche_head($head, 'perso', $title, 0, 'contact');
+    
     $linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php">'.$langs->trans("BackToList").'</a>';
     
     dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '');
@@ -285,16 +289,17 @@ else
     }
     else
     {
-        print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3">'.$langs->trans("Unknown")."</td>";
+        print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3"></td>';
     }
     print "</tr>";
 
     print "</table>";
 
     print '</div>';
+
+    dol_fiche_end();
 }
 
-dol_fiche_end();
 
 if ($action != 'edit')
 {
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index 8e81c63c0ee367b797cf2b84525f7f01c77da852..cd0c934ead2610fff5a17218d3d0b8c818cba66e 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -172,7 +172,7 @@ if ($sall) {
     $sql .= natural_search(array_keys($fieldstosearchall), $sall);
 }
 if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user;
-$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.date_contrat, c.statut, c.ref_supplier, s.nom, s.rowid";
+$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, s.nom, s.rowid";
 $totalnboflines=0;
 $result=$db->query($sql);
 if ($result)
diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php
index a4ee48f256b9a3a9c452abf82e46cf67fff8a3c8..4fb973160d47b1452c29237b2caff8b9f98ccce9 100644
--- a/htdocs/core/class/dolgraph.class.php
+++ b/htdocs/core/class/dolgraph.class.php
@@ -65,7 +65,7 @@ class DolGraph
 	var $bgcolorgrid=array(255,255,255);			// array(R,G,B)
 	var $datacolor;				// array(array(R,G,B),...)
 
-	private $_stringtoshow;      // To store string to output graph into HTML page
+	private $stringtoshow;      // To store string to output graph into HTML page
 
 
 	/**
diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js
index da350162c1b035d4c60d32f59bb637065d10fcd5..ea0e07827677cafa31a268f1a3ac359a928fd945 100644
--- a/htdocs/core/js/timesheet.js
+++ b/htdocs/core/js/timesheet.js
@@ -163,8 +163,11 @@ function updateTotal(days,mode)
                 }
             }
         }
-        document.getElementById('totalDay['+days+']').innerHTML = pad(total.getHours())+':'+pad(total.getMinutes());
-        //addText(,total.getHours()+':'+total.getMinutes());
+        if (document.getElementById('totalDay['+days+']'))	// May be null if no task records to output (nbline is also 0 in this case)
+        {
+        	document.getElementById('totalDay['+days+']').innerHTML = pad(total.getHours())+':'+pad(total.getMinutes());
+        	//addText(,total.getHours()+':'+total.getMinutes());
+        }
     }
     else
     {
@@ -204,7 +207,10 @@ function updateTotal(days,mode)
                 }
             }
         }
-        document.getElementById('totalDay['+days+']').innerHTML = total;
+        if (document.getElementById('totalDay['+days+']'))	// May be null if no task records to output (nbline is also 0 in this case)
+        {
+        	document.getElementById('totalDay['+days+']').innerHTML = total;
+        }
     }
     
 }
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 87c87804ee624fc0ba5a05e459d80cb1fdf551af..1d14bb2c86fac3baddd142df984894e97578fac6 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -333,7 +333,7 @@ function dol_include_once($relpath, $classname='')
  *	Return path of url or filesystem. Return alternate root if exists
  *
  * 	@param	string	$path		Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile
- *  @param	int		$type		0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path)
+ *  @param	int		$type		0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file)
  *  @return string				Full filesystem path (if mode=0), Full url path (if mode=1)
  */
 function dol_buildpath($path, $type=0)
@@ -364,6 +364,8 @@ function dol_buildpath($path, $type=0)
 		$res='';
 		if ($type == 1) $res = DOL_URL_ROOT.'/'.$path;			// Standard value
 		if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path;		// Standard value
+		if ($type == 3) $res = DOL_URL_ROOT.'/'.$path;
+		
 		foreach ($conf->file->dol_document_root as $key => $dirroot)	// ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
 		{
 			if ($key == 'main') continue;
@@ -379,7 +381,18 @@ function dol_buildpath($path, $type=0)
 					}
 					if ($type == 2)
 					{
-						$res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
+					    $res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
+					}
+					if ($type == 3)
+					{
+					    global $dolibarr_main_url_root;
+					    
+					    // Define $urlwithroot
+					    $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
+					    $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
+					    //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
+					    					
+					    $res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':$urlwithroot).$conf->file->dol_url_root[$key].'/'.$path;
 					}
 					break;
 				}
@@ -1044,7 +1057,7 @@ function dol_format_address($object,$withcountry=0,$sep="\n",$outputlangs='')
 	else                                        		// Other: title firstname name \n address lines \n zip town \n country
 	{
 		$ret .= $object->zip ? (($ret ? $sep : '' ).$object->zip) : '';
-		$ret .= ($object->town?(($object->zip?' ':$sep).$object->town):'');
+		$ret .= ($object->town?(($object->zip?' ':($ret ? $sep : '' )).$object->town):'');
 		if ($object->state && in_array($object->country_code,$countriesusingstate))
 		{
 			$ret.=($ret?", ":'').$object->state;
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 9f2078a39495bc8dd620ec8b710af5afa9688efe..163f6e8bdb700ee6094251a11485f411b6f4d054 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -2160,7 +2160,7 @@ else
 	            // Make payments
 	            if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0  && $user->societe_id == 0)
 	            {
-	                print '<a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create &amp;accountid='.$object->fk_account.'">'.$langs->trans('DoPayment').'</a>';	// must use facid because id is for payment id not invoice
+	                print '<a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create'.($object->fk_account>0?'&amp;accountid='.$object->fk_account:'').'">'.$langs->trans('DoPayment').'</a>';	// must use facid because id is for payment id not invoice
 	            }
 	
 	            // Classify paid
diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index 4883a3c4f2844d36b4a12b6825f97bcde00a6dc6..4e6795fd4fad9f9a2b6e67bb6bf711b758ad11c7 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -386,15 +386,15 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
 				/*
 	             * Autres factures impayees
 	             */
-	            $sql = 'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc, f.multicurrency_total_ttc, f.datef as df';
-	            $sql.= ', SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am';
+	            $sql = 'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc, f.multicurrency_total_ttc, f.datef as df,';
+	            $sql.= ' SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am';
 	            $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
 	            $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
 	            $sql.= " WHERE f.entity = ".$conf->entity;
 	            $sql.= ' AND f.fk_soc = '.$object->socid;
 	            $sql.= ' AND f.paye = 0';
 	            $sql.= ' AND f.fk_statut = 1';  // Statut=0 => non validee, Statut=2 => annulee
-	            $sql.= ' GROUP BY f.rowid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc, f.datef';
+	            $sql.= ' GROUP BY f.rowid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc, f.multicurrency_total_ttc, f.datef';
 	            $resql = $db->query($sql);
 	            if ($resql)
 	            {
diff --git a/htdocs/product/class/api_deprecated_product.class.php b/htdocs/product/class/api_deprecated_product.class.php
index ec801c37a56eb23a7ec1771236973d7a4cea8704..2db0699d66184a15e1bf60db087df0e2e1a31b44 100644
--- a/htdocs/product/class/api_deprecated_product.class.php
+++ b/htdocs/product/class/api_deprecated_product.class.php
@@ -147,6 +147,7 @@ class ProductApi extends DolibarrApi
         $result = $db->query($sql);
         if ($result)
         {
+        	$i=0;
             $num = $db->num_rows($result);
             while ($i < $num)
             {
@@ -232,6 +233,7 @@ class ProductApi extends DolibarrApi
         $result = $db->query($sql);
         if ($result)
         {
+        	$i=0;
             $num = $db->num_rows($result);
             while ($i < $num)
             {
diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php
index e2a648872693d489eccffa498af9efc0d84b2cf0..4106b4ef93649bbe871c7138af31c303605be916 100644
--- a/htdocs/product/reassort.php
+++ b/htdocs/product/reassort.php
@@ -113,7 +113,7 @@ $htmlother=new FormOther($db);
 
 $title=$langs->trans("ProductsAndServices");
 
-$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,p.entity,';
+$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,';
 $sql.= ' p.fk_product_type, p.tms as datem,';
 $sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
 $sql.= ' SUM(s.reel) as stock_physique';
@@ -167,7 +167,7 @@ if ($search_categ)
 {
 	$sql .= " AND cp.fk_categorie = ".$db->escape($search_categ);
 }
-$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,";
+$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,";
 $sql.= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock";
 if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte";    // Not used yet
 $sql.= $db->order($sortfield,$sortorder);
@@ -278,7 +278,7 @@ if ($resql)
 			
 		}
 	} 
-	if ($virtualdiffersfromphysical) print_liste_field_titre($langs->trans("VirtualStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder);
+	if ($virtualdiffersfromphysical) print_liste_field_titre($langs->trans("VirtualStock"),$_SERVER["PHP_SELF"], "",$param,"",'align="right"',$sortfield,$sortorder);
 	print_liste_field_titre('');
 	print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder);
     print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder);
diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php
index 25dd6728df88d231d3086daa4a60a8ddc0735518..ebd9f63f1274d12c22603a27f99fadc824a4af58 100644
--- a/htdocs/product/stock/replenish.php
+++ b/htdocs/product/stock/replenish.php
@@ -114,7 +114,7 @@ if ($action == 'order' && isset($_POST['valid']))
                 $supplierpriceid = GETPOST('fourn'.$i, 'int');
                 //get all the parameters needed to create a line
                 $qty = GETPOST('tobuy'.$i, 'int');
-                $desc = GETPOST('desc'.$i, 'alpha');
+                //$desc = GETPOST('desc'.$i, 'alpha');
                 $sql = 'SELECT fk_product, fk_soc, ref_fourn';
                 $sql .= ', tva_tx, unitprice FROM ';
                 $sql .= MAIN_DB_PREFIX . 'product_fournisseur_price';
@@ -128,8 +128,20 @@ if ($action == 'order' && isset($_POST['valid']))
 	                    $obj = $db->fetch_object($resql);
 	                    $line = new CommandeFournisseurLigne($db);
 	                    $line->qty = $qty;
-	                    $line->desc = $desc;
 	                    $line->fk_product = $obj->fk_product;
+	                    
+	                    $product = new Product($db);
+	                    $product->fetch($obj->fk_product);
+	                    if (! empty($conf->global->MAIN_MULTILANGS)) 
+	                    {
+	                        $product->getMultiLangs();     
+	                    }
+	                    $line->desc = $product->description;
+                        if (! empty($conf->global->MAIN_MULTILANGS))
+                        {
+                            // TODO Get desc in language of thirdparty
+                        }
+	                    
 	                    $line->tva_tx = $obj->tva_tx;
 	                    $line->subprice = $obj->unitprice;
 	                    $line->total_ht = $obj->unitprice * $qty;
@@ -241,7 +253,7 @@ $form = new Form($db);
 
 $title = $langs->trans('Status');
 
-$sql = 'SELECT p.rowid, p.ref, p.label,p.description, p.price,';
+$sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price,';
 $sql.= ' p.price_ttc, p.price_base_type,p.fk_product_type,';
 $sql.= ' p.tms as datem, p.duration, p.tobuy,';
 $sql.= ' p.desiredstock, p.seuil_stock_alerte as alertstock,';
@@ -280,7 +292,7 @@ if ($snom) {
 }
 $sql.= ' AND p.tobuy = 1';
 if (!empty($canvas)) $sql .= ' AND p.canvas = "' . $db->escape($canvas) . '"';
-$sql.= ' GROUP BY p.rowid, p.ref, p.label, p.price';
+$sql.= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price';
 $sql.= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms';
 $sql.= ', p.duration, p.tobuy';
 $sql.= ', p.desiredstock, p.seuil_stock_alerte';
@@ -459,20 +471,20 @@ print_liste_field_titre($langs->trans('Supplier'), $_SERVER["PHP_SELF"], '', $pa
 print "</tr>\n";
 
 // Lignes des champs de filtre
-print '<tr class="liste_titre">'.
-'<td class="liste_titre">&nbsp;</td>'.
-'<td class="liste_titre"><input class="flat" type="text" name="sref" size="8" value="'.dol_escape_htmltag($sref).'"></td>'.
-'<td class="liste_titre"><input class="flat" type="text" name="snom" size="8" value="'.dol_escape_htmltag($snom).'"></td>';
+print '<tr class="liste_titre">';
+print '<td class="liste_titre">&nbsp;</td>';
+print '<td class="liste_titre"><input class="flat" type="text" name="sref" size="8" value="'.dol_escape_htmltag($sref).'"></td>';
+print '<td class="liste_titre"><input class="flat" type="text" name="snom" size="8" value="'.dol_escape_htmltag($snom).'"></td>';
 if (!empty($conf->service->enabled) && $type == 1) print '<td class="liste_titre">&nbsp;</td>';
-print '<td class="liste_titre">&nbsp;</td>'.
-	'<td class="liste_titre" align="right">&nbsp;</td>'.
-	'<td class="liste_titre" align="right">' . $langs->trans('AlertOnly') . '&nbsp;<input type="checkbox" id="salert" name="salert" ' . (!empty($alertchecked)?$alertchecked:'') . '></td>'.
-	'<td class="liste_titre" align="right">&nbsp;</td>'.
-	'<td class="liste_titre">&nbsp;</td>';
-    print '<td class="liste_titre" align="right">';
-    $searchpitco=$form->showFilterAndCheckAddButtons(0);
-    print $searchpitco;
-    print '</td>';
+print '<td class="liste_titre">&nbsp;</td>';
+print '<td class="liste_titre" align="right">&nbsp;</td>';
+print '<td class="liste_titre" align="right">' . $langs->trans('AlertOnly') . '&nbsp;<input type="checkbox" id="salert" name="salert" ' . (!empty($alertchecked)?$alertchecked:'') . '></td>';
+print '<td class="liste_titre" align="right">&nbsp;</td>';
+print '<td class="liste_titre">&nbsp;</td>';
+print '<td class="liste_titre" align="right">';
+$searchpitco=$form->showFilterAndCheckAddButtons(0);
+print $searchpitco;
+print '</td>';
 print '</tr>';
 
 $prod = new Product($db);
@@ -558,7 +570,9 @@ while ($i < ($limit ? min($num, $limit) : $num))
 
 		print '<td class="nowrap">'.$prod->getNomUrl(1, '').'</td>';
 
-		print '<td>' . $objp->label . '<input type="hidden" name="desc' . $i . '" value="' . $objp->description . '" ></td>';
+		print '<td>'.$objp->label ;
+		print '<input type="hidden" name="desc' . $i . '" value="' . dol_escape_htmltag($objp->description) . '">';  // TODO Remove this and make a fetch to get description when creating order instead of a GETPOST
+		print '</td>';
 
 		if (!empty($conf->service->enabled) && $type == 1)
 		{
diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php
index 4f08e6f4209d5a40ee5868d02f79ecbcb95720b8..0a7388463634adec59cc9c1acf09e0d1180037db 100644
--- a/htdocs/resource/class/dolresource.class.php
+++ b/htdocs/resource/class/dolresource.class.php
@@ -393,7 +393,7 @@ class Dolresource extends CommonObject
     			}
     		}
     	}
-    	$sql.= " GROUP BY t.rowid, ty.label";
+    	$sql.= " GROUP BY t.rowid, t.entity, t.ref, t.description, t.fk_code_type_resource, t.tms, ty.label";
     	$sql.= $this->db->order($sortfield,$sortorder);
         $this->num_all = 0;
         if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php
index 777bcb374d6492655c10d10bdccbd17f5054c5c8..90eed12528426db683f298f1d151d86fc74436b3 100644
--- a/htdocs/resource/list.php
+++ b/htdocs/resource/list.php
@@ -97,20 +97,18 @@ if($ret == -1) {
 } else {
     print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $ret+1, $object->num_all,'title_generic.png');
 }
-if(!$ret) {
-        print '<div class="warning">'.$langs->trans('NoResourceInDatabase').'</div>';
-}
-else
-{
-        $var=true;
 
-        print '<table class="noborder" width="100%">'."\n";
-        print '<tr class="liste_titre">';
-        print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'t.ref','',$param,'',$sortfield,$sortorder);
-        print_liste_field_titre($langs->trans('ResourceType'),$_SERVER['PHP_SELF'],'ty.code','',$param,'',$sortfield,$sortorder);
-        print_liste_field_titre('',"","","","",'width="60" align="center"',"","");
-        print "</tr>\n";
+$var=true;
 
+print '<table class="noborder" width="100%">'."\n";
+print '<tr class="liste_titre">';
+print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'t.ref','',$param,'',$sortfield,$sortorder);
+print_liste_field_titre($langs->trans('ResourceType'),$_SERVER['PHP_SELF'],'ty.code','',$param,'',$sortfield,$sortorder);
+print_liste_field_titre('',"","","","",'width="60" align="center"',"","");
+print "</tr>\n";
+
+if ($ret)
+{
         foreach ($object->lines as $resource)
         {
                 $var=!$var;
@@ -142,7 +140,10 @@ else
         }
 
         print '</table>';
-
+}
+else
+{
+    print '<tr><td class="opacitymedium">'.$langs->trans('NoResourceInDatabase').'</td></tr>';
 }
 
 llxFooter();
diff --git a/htdocs/societe/class/api_deprecated_contact.class.php b/htdocs/societe/class/api_deprecated_contact.class.php
index 9509e276f320b255e3fb02c4bd25d9eff4ee1d03..2a6a4b948b896bd058f4e0c8112954e7a2c95341 100644
--- a/htdocs/societe/class/api_deprecated_contact.class.php
+++ b/htdocs/societe/class/api_deprecated_contact.class.php
@@ -114,6 +114,7 @@ class ContactApi extends DolibarrApi
 			$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : '';
 		}
 
+		$search_sale = 0;
 		// If the internal user must only see his customers, force searching by him
 		if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid)
 			$search_sale = DolibarrApiAccess::$user->id;
@@ -164,7 +165,8 @@ class ContactApi extends DolibarrApi
 		$result = $db->query($sql);
 		if ($result)
 		{
-			$num = $db->num_rows($result);
+			$i = 0;
+		    $num = $db->num_rows($result);
 			while ($i < $num)
 			{
 				$obj = $db->fetch_object($result);
diff --git a/htdocs/societe/class/api_deprecated_thirdparty.class.php b/htdocs/societe/class/api_deprecated_thirdparty.class.php
index db270142972755b11b1095e8c1e4aed468d4cf5c..3e2f070b9de6f3de715d980d1571689de4422220 100644
--- a/htdocs/societe/class/api_deprecated_thirdparty.class.php
+++ b/htdocs/societe/class/api_deprecated_thirdparty.class.php
@@ -211,6 +211,7 @@ class ThirdpartyApi extends DolibarrApi
 		$result = $db->query($sql);
         if ($result)
         {
+			$i = 0;
             $num = $db->num_rows($result);
             while ($i < $num)
             {