diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 5e9fc895f0b53d5d6ee4b5621c4ea2721728ef72..bef8c6951bf69619280b70b498896cb5c6298b34 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -3,7 +3,7 @@
  * Copyright (C) 2004-2015  Laurent Destailleur     <eldy@users.sourceforge.net>
  * Copyright (C) 2004       Benoit Mortier          <benoit.mortier@opensides.be>
  * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
- * Copyright (C) 2010-2013  Juanjo Menent           <jmenent@2byte.es>
+ * Copyright (C) 2010-2016  Juanjo Menent           <jmenent@2byte.es>
  * Copyright (C) 2011-2015  Philippe Grand          <philippe.grand@atoo-net.com>
  * Copyright (C) 2011       Remy Younes             <ryounes@gmail.com>
  * Copyright (C) 2012-2015  Marcos García           <marcosgdf@gmail.com>
@@ -624,7 +624,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
         $i=0;
         foreach ($listfieldinsert as $f => $value)
         {
-            if ($value == 'price' || preg_match('/^amount/i',$value) || preg_match('/^localtax/i',$value) || $value == 'taux') {
+            if ($value == 'price' || preg_match('/^amount/i',$value) || $value == 'taux') {
             	$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
             }
             else if ($value == 'entity') {
@@ -672,7 +672,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
         $i = 0;
         foreach ($listfieldmodify as $field)
         {
-            if ($field == 'price' || preg_match('/^amount/i',$field) || preg_match('/^localtax/i',$field) || $field == 'taux') {
+            if ($field == 'price' || preg_match('/^amount/i',$field) || $field == 'taux') {
             	$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
             }
             else if ($field == 'entity') {
@@ -1290,23 +1290,12 @@ if ($id)
 							    $valuetoshow = '';
 							  $align="center";
 							}
-							else if ($fieldlist[$field]=='localtax1') {
+							else if ($fieldlist[$field]=='taux') {
                                 $valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
 							  if ($obj->localtax1 == 0)
 							    $valuetoshow = '';
 							  $align="right";
 							}
-							else if ($fieldlist[$field]=='localtax2') {
-                                $valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
-							  if ($obj->localtax2 == 0)
-							    $valuetoshow = '';
-							  $align="right";
-							}
-							else if (in_array($fieldlist[$field],array('taux','localtax1','localtax2')))
-							{
-                                $valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
-								$align="right";
-							}
 							else if (in_array($fieldlist[$field],array('recuperableonly')))
 							{
 								$align="center";
diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 51d0a6174c855470f6a81d6bbb3232b3450c04e7..3147538c8fe6d5f56a35c54890c66b193adedf8e 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -167,7 +167,7 @@ if ($action == 'edit')	// Edit
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
-	// Multilangual GUI
+	// Multilingual GUI
     $var=!$var;
     print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("EnableMultilangInterface").'</td><td>';
     print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1);
@@ -181,7 +181,7 @@ if ($action == 'edit')	// Edit
     show_theme(null,1);
     print '<br>';
 
-    // Liste des zone de recherche permanantes supportees
+    // List of permanent supported search box
     if (! empty($searchform))
     {
         print '<table summary="search" class="noborder" width="100%">';
diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php
index eef29d2edc3bf37971b90e3ae630b2f69057d984..4d6c0e289f5a47b8a9e994029a6b837324520576 100644
--- a/htdocs/comm/index.php
+++ b/htdocs/comm/index.php
@@ -69,7 +69,7 @@ if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db);
 if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db);
 if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db);
 
-llxHeader();
+llxHeader("",$langs->trans("CommercialArea"));
 
 print load_fiche_titre($langs->trans("CommercialArea"),'','title_commercial.png');
 
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index 55d8b49fa461d078e372fce197298b81b07ef35e..688cc73f84ebcc5b276e7571b2284ea0ab744d13 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -10,6 +10,7 @@
  * Copyright (C) 2012      Christophe Battarel   <christophe.battarel@altairis.fr>
  * Copyright (C) 2013      Cédric Salvador       <csalvador@gpcsolutions.fr>
  * Copyright (C) 2015      Jean-François Ferry     <jfefe@aternatik.fr>
+ * Copyright (C) 2016      Ferran Marcet	     <fmarcet@2byte.es>
  *
  * 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
@@ -255,6 +256,7 @@ if ($result)
 	}
 
 	$param='&socid='.$socid.'&viewstatut='.$viewstatut;
+	if ($sall)				 $param.='&sall='.$sall;
 	if ($month)              $param.='&month='.$month;
 	if ($year)               $param.='&year='.$year;
     if ($search_ref)         $param.='&search_ref=' .$search_ref;
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index cfb8486be6f7c8636e133ce95b1a4333033815fb..f9653c067323185f53a9a90ed3fdec24632c398e 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -259,6 +259,7 @@ if ($resql)
 	$title.=' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled)?'':$langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
 
 	$param='';
+	if ($sall)					$param.='&sall='.$sall;
 	if ($socid > 0)             $param.='&socid='.$socid;
 	if ($viewstatut != '')      $param.='&viewstatut='.$viewstatut;
 	if ($orderday)      		$param.='&orderday='.$orderday;
@@ -587,10 +588,13 @@ if ($resql)
 		print dol_print_date($db->jdate($objp->date_commande), 'day');
 		print '</td>';
 
-		// Delivery date
-		print '<td align="center">';
-		print dol_print_date($db->jdate($objp->date_delivery), 'day');
-		print '</td>';
+		if (empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)) 
+		{
+			// Delivery date
+			print '<td align="center">';
+			print dol_print_date($db->jdate($objp->date_delivery), 'day');
+			print '</td>';
+		}
 
 		// Amount HT
 		print '<td align="right" class="nowrap">'.price($objp->total_ht).'</td>';
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 659bcaae7c4613adc570b89db7f4dd20717e6615..34ed1383e14377497a60f67699ec23019beea895 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -66,7 +66,6 @@ if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
 if (! empty($conf->margin->enabled))
 	$langs->load('margins');
 
-$sall = trim(GETPOST('sall'));
 $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
 
 $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index fd0a61b638f35c581ebd521098eb6165217b140d..205f84c416f7d7a35227bba9cb91cd8172169281 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -568,6 +568,7 @@ if ($resql)
     }
 
     $param='&socid='.$socid;
+	if ($sall)				 $param.='&sall='.$sall;
     if ($day)                $param.='&day='.$day;
     if ($month)              $param.='&month='.$month;
     if ($year)               $param.='&year=' .$year;
diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php
index 98ebe63f3b7d7171e2dbacb2efd251935a652d5b..f0ef12a2e9ca922ae023f251967ebb5593480989 100644
--- a/htdocs/compta/localtax/index.php
+++ b/htdocs/compta/localtax/index.php
@@ -273,7 +273,8 @@ $sql.= " WHERE f.entity = ".$conf->entity;
 $sql.= " AND f.datev >= '".$db->idate(dol_get_first_day($y,1,false))."'";
 $sql.= " AND f.datev <= '".$db->idate(dol_get_last_day($y,12,false))."'";
 $sql.= " AND localtaxtype=".$localTaxType;
-$sql.= " GROUP BY dm ASC";
+$sql.= " GROUP BY dm";
+$sql.= " ORDER BY dm ASC";
 
 pt($db, $sql,$langs->trans("Year")." $y");
 
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 9a569a46f7c62078b44a614157f454c78dd3337c..f007fa41d2189173696df5a1d31f9192ab7d9baf 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -1558,7 +1558,7 @@ class BonPrelevement extends CommonObject
 		$XML_DEBITOR ='';
 		$XML_DEBITOR .='			<DrctDbtTxInf>'.$CrLf;
 		$XML_DEBITOR .='				<PmtId>'.$CrLf;
-		$XML_DEBITOR .='					<EndToEndId>'.('AS-'.$row_facnumber.'-'.$Rowing).'</EndToEndId>'.$CrLf;
+		$XML_DEBITOR .='					<EndToEndId>'.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).'</EndToEndId>'.$CrLf;          // ISO20022 states that EndToEndId has a MaxLength of 35 characters
 		$XML_DEBITOR .='				</PmtId>'.$CrLf;
 		$XML_DEBITOR .='				<InstdAmt Ccy="EUR">'.round($row_somme, 2).'</InstdAmt>'.$CrLf;
 		$XML_DEBITOR .='				<DrctDbtTx>'.$CrLf;
@@ -1673,8 +1673,9 @@ class BonPrelevement extends CommonObject
      *	@return	string					String with SEPA Sender
      */
     function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n')
-    {	// SEPA INITIALISATION
-		global $confs;
+    {	
+        // SEPA INITIALISATION
+		global $conf;
 
 		$dateTime_YMD = dol_print_date($ladate, '%Y%m%d');
 		$dateTime_ETAD = dol_print_date($ladate, '%Y-%m-%d');
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index d9fa371e443a48161436db1bc28ffe4a8b1256ec..8d9c3f0ae644587ab68b7e018c5d11e46e84160a 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -364,6 +364,7 @@ if ($result)
 	$param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall);
     $param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_lastname='.urlencode($search_lastname).'&search_firstname='.urlencode($search_firstname).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email);
     if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ);
+    if ($sall != '') $param.='&amp;sall='.urlencode($sall);
     if ($search_lastname != '') $param.='&amp;search_lastname='.urlencode($search_lastname);
     if ($search_firstname != '') $param.='&amp;search_firstname='.urlencode($search_firstname);
     if ($search_zip != '') $param.='&amp;search_zip='.urlencode($search_zip);
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index 23df8a06593a13ca9054080f3313dc22cd1df4d3..4f808e73be38ecdd471a63227467340055ab56ef 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -6,6 +6,7 @@
  * Copyright (C) 2014      Juanjo Menent        <jmenent@2byte.es>
  * Copyright (C) 2015	   Claudio Aschieri		<c.aschieri@19.coop>
  * Copyright (C) 2015      Jean-François Ferry	<jfefe@aternatik.fr>
+ * Copyright (C) 2016      Ferran Marcet        <fmarcet@2byte.es>
  *
  * 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
@@ -222,6 +223,7 @@ if ($resql)
     $param.='&search_name='.$search_name;
     $param.='&search_ref_supplier='.$search_ref_supplier;
     $param.='&search_sale=' .$search_sale;
+    if ($sall != '') $param.='&sall='.$sall;
     if ($optioncss != '') $param.='&optioncss='.$optioncss;
 
     print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","$param",'',$sortfield,$sortorder);
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index 58c48d5b254229f1822498298cab6462a8b2a73e..d56dc28cadf51450c7e9525f5cd8de6ff38511ba 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -80,11 +80,11 @@ if(! empty($_POST['removAll']))
 	{
 		$pathtodelete = $value;
 		$filetodelete = $listofnames[$key];
-		$result = dol_delete_file($pathtodelete,1); // Delete uploded Files 
-	
+		$result = dol_delete_file($pathtodelete,1); // Delete uploded Files
+
 		$langs->load("other");
 		setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs');
-		
+
 		$formmail->remove_attached_files($key); // Update Session
 	}
 }
@@ -117,29 +117,29 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 			$dolimail = new Dolimail($db);
 			$possibleaccounts=$dolimail->get_societe_by_email($_POST['sendto'],"1");
 			$possibleuser=$dolimail->get_from_user_by_mail($_POST['sendto'],"1"); // suche in llx_societe and socpeople
-			if (!$possibleaccounts && !$possibleuser) 
+			if (!$possibleaccounts && !$possibleuser)
 			{
 					setEventMessages($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']), null, 'errors');
 			}
-			elseif (count($possibleaccounts)>1) 
+			elseif (count($possibleaccounts)>1)
 			{
 					$sendtosocid=$possibleaccounts[1]['id'];
 					$result=$object->fetch($sendtosocid);
-					
+
 					setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs');
 			}
-			else 
+			else
 			{
-				if($possibleaccounts){ 
+				if($possibleaccounts){
 					$sendtosocid=$possibleaccounts[1]['id'];
 					$result=$object->fetch($sendtosocid);
-				}elseif($possibleuser){ 
+				}elseif($possibleuser){
 					$sendtosocid=$possibleuser[0]['id'];
 
 					$result=$uobject->fetch($sendtosocid);
 					$object=$uobject;
 				}
-				
+
 			}
 		}
 	}
@@ -236,35 +236,35 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 					$mailboxconfig = new IMAP($db);
 					$mailboxconfig->fetch($mbid);
 					if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref();
-				
+
 					$mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox;
 					$mailboxconfig->userfolder_fetch();
-				
+
 					if ($mailboxconfig->mailbox_save_sent_mails == 1)
 					{
-					
+
 						$folder=str_replace($ref, '', $mailboxconfig->folder_cache_key);
 						if (!$folder) $folder = "Sent";	// Default Sent folder
-					
+
 						$mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password);
-						if (FALSE === $mailboxconfig->mbox) 
+						if (FALSE === $mailboxconfig->mbox)
 						{
 							$info = FALSE;
 							$err = $langs->trans('Error3_Imap_Connection_Error');
 							setEventMessages($err,$mailboxconfig->element, null, 'errors');
-						} 
-						else 
+						}
+						else
 						{
 							$mailboxconfig->mailboxid=$_POST['frommail'];
 							$mailboxconfig->foldername=$folder;
 							$from = $mailfromid[0] . $mailfromid[2];
 							$imap=1;
 						}
-					
-					} 
+
+					}
 				}
 			}
-			
+
 			// Send mail
 			require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
 			$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid);
@@ -278,7 +278,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 				if ($result)
 				{
 					$error=0;
-					
+
 					// FIXME This must be moved into a trigger for action $trigger_name
 					if (! empty($conf->dolimail->enabled))
 					{
@@ -289,13 +289,13 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 							$dolimail=new DoliMail($db);
 							$dolimail->id = $mid;
 							$res=$dolimail->set_prop($user, 'answered',1);
-				  		}	
+				  		}
 						if ($imap==1)
 						{
 							// write mail to IMAP Server
-							$movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile); 
+							$movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile);
 							if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs');
-							else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings'); 
+							else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings');
 				 	 	}
 				 	}
 
@@ -313,7 +313,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 					$interface=new Interfaces($db);
 					$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
 					if ($result < 0) {
-						$error++; $this->errors=$interface->errors;
+						$error++; $errors=$interface->errors;
 					}
 					// End call of triggers
 
@@ -327,8 +327,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 						// This avoid sending mail twice if going out and then back to page
 						$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
 						setEventMessages($mesg, null, 'mesgs');
-						if($conf->dolimail->enabled) header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id.'&'.($paramname2?$paramname2:'mid').'='.$parm2val);
-						else	header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id);
+						if ($conf->dolimail->enabled) header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id.'&'.($paramname2?$paramname2:'mid').'='.$parm2val);
+						else header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id);
 						exit;
 					}
 				}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index c314011874552ece1201991dbd7295f540e219fa..3279d372a0e1714374a876b51b383edfc9d5b8df 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -448,7 +448,7 @@ abstract class CommonObject
     	global $conf, $langs;
 
     	$countriesusingstate=array('AU','US','IN','GB','ES','UK','TR');    // See also option MAIN_FORCE_STATE_INTO_ADDRESS
-    	
+
     	$contactid=0;
     	$thirdpartyid=0;
     	if ($this->element == 'societe')
@@ -465,12 +465,12 @@ abstract class CommonObject
     		$contactid=$this->contact_id;
 			$thirdpartyid=$object->fk_soc;
     	}
-    	
+
 		$out='<!-- BEGIN part to show address block -->';
-		
+
 		$outdone=0;
 		$coords = $this->getFullAddress(1,', ');
-		if ($coords) 
+		if ($coords)
 		{
 			if (! empty($conf->use_javascript_ajax))
 			{
@@ -485,7 +485,7 @@ abstract class CommonObject
 		}
 
 		if (! in_array($this->country_code,$countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)   // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress
-				&& empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) 
+				&& empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state)
 		{
 			$out.=($outdone?' - ':'').$this->state;
 			$outdone++;
@@ -516,15 +516,15 @@ abstract class CommonObject
 		if (! empty($this->office_fax)) {
 			$out.=dol_print_phone($this->fax,$this->country_code,$contactid,$thirdpartyid,'AC_FAX','&nbsp;','fax',$langs->trans("Fax")); $outdone++;
 		}
-		
+
 		$out.='<div style="clear: both;"></div>';
 		$outdone=0;
-		if (! empty($this->email)) 
+		if (! empty($this->email))
 		{
 			$out.=dol_print_email($this->email,$this->id,$object->id,'AC_EMAIL',0,0,1);
 			$outdone++;
 		}
-    	if (! empty($this->url)) 
+    	if (! empty($this->url))
 		{
 			$out.=dol_print_url($this->url,'',0,1);
 			$outdone++;
@@ -535,12 +535,12 @@ abstract class CommonObject
 			if ($this->skype) $out.=dol_print_skype($this->skype,$this->id,$object->id,'AC_SKYPE');
 			$outdone++;
 		}
-		
+
 		$out.='<!-- END Part to show address block -->';
-		
+
 		return $out;
     }
-        
+
     /**
      *  Add a link between element $this->element and a contact
      *
@@ -595,50 +595,56 @@ abstract class CommonObject
             }
         }
 
-        $datecreate = dol_now();
-        
-        $this->db->begin();
 
-        // Insertion dans la base
-        $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
-        $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
-        $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
-        $sql.= "'".$this->db->idate($datecreate)."'";
-        $sql.= ", 4, '". $id_type_contact . "' ";
-        $sql.= ")";
-        dol_syslog(get_class($this)."::add_contact", LOG_DEBUG);
 
-        $resql=$this->db->query($sql);
-        if ($resql)
-        {
-            if (! $notrigger)
-            {
-            	$result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user);
-	            if ($result < 0) 
-	            { 
-	                $this->db->rollback(); 
-	                return -1;
+        if(! empty($id_type_contact)) {
+
+        	$datecreate = dol_now();
+
+        	$this->db->begin();
+
+	        // Insertion dans la base
+	        $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
+	        $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
+	        $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
+	        $sql.= "'".$this->db->idate($datecreate)."'";
+	        $sql.= ", 4, ". $id_type_contact . " ";
+	        $sql.= ")";
+	        dol_syslog(get_class($this)."::add_contact", LOG_DEBUG);
+
+	        $resql=$this->db->query($sql);
+	        if ($resql)
+	        {
+	            if (! $notrigger)
+	            {
+	            	$result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user);
+		            if ($result < 0)
+		            {
+		                $this->db->rollback();
+		                return -1;
+		            }
 	            }
-            }
 
-            $this->db->commit();
-            return 1;
-        }
-        else
-        {
-            if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
-            {
-                $this->error=$this->db->errno();
-            	$this->db->rollback();
-                return -2;
-            }
-            else
-            {
-                $this->error=$this->db->error();
-                $this->db->rollback();
-                return -1;
-            }
+	            $this->db->commit();
+	            return 1;
+	        }
+	        else
+	        {
+	            if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+	            {
+	                $this->error=$this->db->errno();
+	            	$this->db->rollback();
+	                return -2;
+	            }
+	            else
+	            {
+	                $this->error=$this->db->error();
+	                $this->db->rollback();
+	                return -1;
+	            }
+	        }
         }
+        return 1;
     }
 
     /**
@@ -1196,7 +1202,7 @@ abstract class CommonObject
 		if (!empty($id) && !empty($field) && !empty($table)) {
 	        $sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table;
 	        $sql.= " WHERE rowid = ".$id;
-	
+
 	        dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG);
 	        $resql = $this->db->query($sql);
 	        if ($resql)
@@ -2275,8 +2281,8 @@ abstract class CommonObject
      *  - all parameters empty -> we look all link to current object (current object can be source or target)
      *  - one couple id+type is provided -> this will set $justsource or $justtarget
      *  - one couple id+type is provided and other type is provided -> this will set $justsource or $justtarget + criteria on other type
-     *  
-     *  
+     *
+     *
      *	@param	int		$sourceid		Object source id (if not defined, id of object)
      *	@param  string	$sourcetype		Object source type (if not defined, element name of object)
      *	@param  int		$targetid		Object target id (if not defined, id of object)
@@ -3223,7 +3229,7 @@ abstract class CommonObject
 				$text.= ' - '.(! empty($line->label)?$line->label:$label);
 				$description.=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($line->description));	// Description is what to show on popup. We shown nothing if already into desc.
 			}
-			
+
 			$line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU');
 
 			// Output template part (modules that overwrite templates must declare this into descriptor)
@@ -3662,7 +3668,7 @@ abstract class CommonObject
                     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;
@@ -3726,13 +3732,13 @@ abstract class CommonObject
     /* For default values */
 
     /**
-     * Return the default value to use for a field when showing the create form of object. 
+     * Return the default value to use for a field when showing the create form of object.
      * Return values in this order:
      * 1) If parameter is available into POST, we return it first.
      * 2) If not but an alternate value was provided as parameter of function, we return it.
-     * 3) If not but a constant $conf->global->OBJECTELEMENT_FIELDNAME is set, we return it (It is better to use the dedicated table). 
+     * 3) If not but a constant $conf->global->OBJECTELEMENT_FIELDNAME is set, we return it (It is better to use the dedicated table).
      * 4) Return value found into database (TODO No yet implemented)
-     * 
+     *
      * @param   string      $fieldname          Name of field
      * @param   string      $alternatevalue     Alternate value to use
      * @return  string                          Default value
@@ -3743,27 +3749,27 @@ abstract class CommonObject
 
         // If param is has been posted with use this value first.
         if (isset($_POST[$fieldname])) return GETPOST($fieldname, 2);
-        
+
         if (isset($alternatevalue)) return $alternatevalue;
-        
+
         $newelement=$this->element;
         if ($newelement == 'facture') $newelement='invoice';
         if ($newelement == 'commande') $newelement='order';
-        if (empty($newelement)) 
+        if (empty($newelement))
         {
             dol_syslog("Ask a default value using common method getDefaultCreateValueForField on an object with no property ->element defined. Return empty string.", LOG_WARNING);
             return '';
         }
-        
+
         $keyforfieldname=strtoupper($newelement.'_DEFAULT_'.$fieldname);
         //var_dump($keyforfieldname);
         if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname;
-        
-        // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname 
-        
+
+        // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname
+
     }
-	
-    
+
+
 	/* For triggers */
 
 
@@ -3963,7 +3969,7 @@ abstract class CommonObject
     						{
     							$res=$object->fetch(0,$value);
     							if ($res > 0) $this->array_options[$key]=$object->id;
-    							else 
+    							else
     							{
     							    $this->error="Ref '".$value."' for object '".$object->element."' not found";
                                     $this->db->rollback();
@@ -4196,25 +4202,25 @@ abstract class CommonObject
 
 		return true;
 	}
-	
+
 	 /**
 	 * define buy price if not defined
 	 *	set buy price = sell price if ForceBuyingPriceIfNull configured,
 	 *	 else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, set pmp as buyprice
 	 *	 else set min buy price as buy price
-	 *	 
+	 *
 	 * @param float		$unitPrice		 product unit price
 	 * @param float		$discountPercent line discount percent
 	 * @param int		$fk_product		 product id
 	 *
 	 * @return	float <0 if ko, buyprice if ok
 	 */
-	public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0) 
+	public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0)
 	{
 		global $conf;
-	
+
 		$buyPrice = 0;
-		
+
 		if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
 		{
 			$buyPrice = $unitPrice * (1 - $discountPercent / 100);
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index cf35dd1ee5c182ace959c21627db12f3f37d8271..52c3b2f5cb988f040095755ad177a909e8da7696 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -1232,9 +1232,11 @@ class ExtraFields
 			{
 				$sql.= ' as main';
 			}
-			if ($selectkey=='rowid') {
+			if ($selectkey=='rowid' && empty($value)) {
+				$sql.= " WHERE ".$selectkey."=0";
+			} elseif ($selectkey=='rowid') {
 				$sql.= " WHERE ".$selectkey."=".$this->db->escape($value);
-			} else {
+			}else {
 				$sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
 			}
 
diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php
index 048ef2d450d55de2c5140d78ddb227f4d2a82f49..304006402c271f26cbc96993cc4a10cb0958cc6c 100644
--- a/htdocs/core/db/pgsql.class.php
+++ b/htdocs/core/db/pgsql.class.php
@@ -1093,7 +1093,7 @@ class DoliDBPgsql extends DoliDB
 	 */
 	function DDLDropField($table,$field_name)
 	{
-		$sql= "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`";
+		$sql= "ALTER TABLE ".$table." DROP COLUMN ".$field_name;
 		dol_syslog($sql,LOG_DEBUG);
 		if (! $this->query($sql))
 		{
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 1f2a9d1d8d94f7644e99c6cecd73b83de06ff61c..b1e2610426cb97c65648ba8d666c6f4f8de48344 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5195,7 +5195,7 @@ function printCommonFooter($zone='private')
 		print 'window.console && console.log("';
 		if (! empty($conf->global->MEMCACHED_SERVER)) print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - ';
 		print 'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED)?$conf->global->MAIN_OPTIMIZE_SPEED:'off');
-		if ($micro_start_time)
+		if (! empty($micro_start_time))   // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
 		{
 			$micro_end_time = microtime(true);
 			print ' - Build time: '.ceil(1000*($micro_end_time-$micro_start_time)).' ms';
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index deab2457c8be68a0106616744ccb3ea0b0c158ca..82449ac63cb8b95e1f8376a082408fceabd39ff7 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -1493,7 +1493,8 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
 
 /**
  * This function evaluates a string that should be a valid IPv4
- *
+ * Note: For ip 169.254.0.0, it returns 0 with some PHP (5.6.24) and 2 with some minor patchs of PHP (5.6.25). See https://github.com/php/php-src/pull/1954.
+ *   
  * @param	string $ip IP Address
  * @return	int 0 if not valid or reserved range, 1 if valid and public IP, 2 if valid and private range IP
  */
diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php
index ad4c2bba16afcbc711d80828a3cec8cbac8add01..02546e6af1136f78c5713627a01576d99313b2a7 100644
--- a/htdocs/core/modules/modCategorie.class.php
+++ b/htdocs/core/modules/modCategorie.class.php
@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2005      Matthieu Valleton    <mv@seeschloss.org>
  * Copyright (C) 2005-2014 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2012	   Juanjo Menent		<jmenent@2byte.es>
+ * Copyright (C) 2012-2016 Juanjo Menent		<jmenent@2byte.es>
  *
  * 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
@@ -302,6 +302,7 @@ class modCategorie extends DolibarrModules
 		$this->export_sql_end[$r]  = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p';
 		$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid';
 		$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc';
+        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople_extrafields as extra ON extra.fk_object = p.rowid';
 		$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category',1).')';
 		$this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories
 
diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php
index 1e9a13069aef91b05c6d73d418cff065477e9713..83d596dbd6192b5beabf8f7f00723c8468f4e34c 100644
--- a/htdocs/core/tpl/objectline_edit.tpl.php
+++ b/htdocs/core/tpl/objectline_edit.tpl.php
@@ -99,7 +99,7 @@ $coldisplay=-1; // We remove first td
 		$doleditor=new DolEditor('product_desc',$line->description,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%');
 		$doleditor->Create();
 	} else {
-		print '<textarea id="desc" class="flat" name="desc" readonly style="width: 200px; height:80px;">' . $line->description . '</textarea>';
+		print '<textarea id="product_desc" class="flat" name="product_desc" readonly style="width: 200px; height:80px;">' . $line->description . '</textarea>';
 	}
 	?>
 	</td>
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 39eaacd303fbf240754aef5e5e117bb191b032fc..ed7ece5bc84f89f539f30c69ca57778b3bc02908 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -1023,21 +1023,21 @@ class Cronjob extends CommonObject
 				}
 				if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
 			}
-		}
-
-		dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true), LOG_DEBUG);
 
+			dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true), LOG_DEBUG);
 
-		// Update with result
-		$this->lastoutput='';
-		if (is_array($output_arr) && count($output_arr)>0)
-		{
-			foreach($output_arr as $val)
+			// Update with result
+			$this->lastoutput='';
+			if (is_array($output_arr) && count($output_arr)>0)
 			{
-				$this->lastoutput.=$val."\n";
+				foreach($output_arr as $val)
+				{
+					$this->lastoutput.=$val."\n";
+				}
 			}
+			$this->lastresult=$retval;
 		}
-		$this->lastresult=$retval;
+
 		$this->datelastresult=dol_now();
 		$result = $this->update($user);
 		if ($result < 0)
diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php
index 36dfb1db55e423238dd21b37c20066091be64138..34b452985d523afa571f2d8285ec9dc4a36cf30c 100644
--- a/htdocs/expedition/list.php
+++ b/htdocs/expedition/list.php
@@ -2,6 +2,7 @@
 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2010 Regis Houssin        <regis.houssin@capnetworks.com>
+ * Copyright (C) 2016	   Ferran Marcet        <fmarcet@2byte.es>
  *
  * 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
@@ -124,6 +125,7 @@ if ($resql)
 	$expedition = new Expedition($db);
 
 	$param="";
+	if ($sall) $param.= "&amp;sall=".$sall;
 	if ($search_ref_exp) $param.= "&amp;search_ref_exp=".$search_ref_exp;
 	if ($search_ref_liv) $param.= "&amp;search_ref_liv=".$search_ref_liv;
 	if ($search_company) $param.= "&amp;search_company=".$search_company;
diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php
index efa6572dd10ff8fa954e2408ea39ccec893d87a2..b24f5fcfe0118610197fa4e36b00bb1118d4864b 100644
--- a/htdocs/expensereport/list.php
+++ b/htdocs/expensereport/list.php
@@ -193,6 +193,7 @@ if ($resql)
 	$i = 0;
 
 	$param="";
+	if ($sall)					$param.="&sall=".$sall;
 	if ($search_ref)			$param.="&search_ref=".$search_ref;
 	if ($search_user)			$param.="&search_user=".$search_user;
 	if ($search_amount_ht)		$param.="&search_amount_ht=".$search_amount_ht;
diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php
index 74edaf72099fb0005501a0ccc1a8605e43e2c340..d01911df6ff244a272335a6b2fd3127f7cd6d6ad 100644
--- a/htdocs/fichinter/list.php
+++ b/htdocs/fichinter/list.php
@@ -139,6 +139,7 @@ if ($result)
 	$num = $db->num_rows($result);
 
 	$urlparam='';
+	if ($sall) $urlparam.="&sall=".$sall;
 	if ($socid) $urlparam.="&socid=".$socid;
 	if ($search_ref) $urlparam.="&search_ref=".urlencode($search_ref);
 	if ($search_company) $urlparam.="&search_company=".urlencode($search_company);
diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php
index 80b02718878a9d391cc3204888860a8b6bb5974b..870b52667dcd806654821076a9c19e9acb21fde1 100644
--- a/htdocs/fourn/card.php
+++ b/htdocs/fourn/card.php
@@ -383,7 +383,6 @@ if ($object->id > 0)
 		$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p ";
 		$sql.= " WHERE p.fk_soc =".$object->id;
 		$sql.= " AND p.entity =".$conf->entity;
-		$sql.= " ORDER BY p.date_commande DESC";
 		$resql=$db->query($sql);
 		if ($resql)
 		{
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 19395db756c3fa9629cd20d71f27a4976f87e2c0..80566e9c1cb9980fade18230e214b09eb68b51fd 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -65,7 +65,7 @@ class CommandeFournisseur extends CommonOrder
     //  		                                      -> 9=Refused  -> (reopen) 1=Validated
     //  Note: billed or not is on another field "billed"
     var $statuts;           // List of status
-    
+
     var $socid;
     var $fourn_id;
     var $date;
@@ -254,6 +254,8 @@ class CommandeFournisseur extends CommonOrder
 
 			$this->fetchObjectLinked();
 
+            $this->lines=array();
+
             $sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description,";
             $sql.= " l.qty,";
             $sql.= " l.tva_tx, l.remise_percent, l.subprice,";
@@ -517,7 +519,7 @@ class CommandeFournisseur extends CommonOrder
         $billedtext='';
 		//if ($statut==5 && $this->billed == 1) $statut = 8;
         if ($billed == 1) $billedtext=$langs->trans("Billed");
-        
+
         // List of language codes for status
         $statutshort[0] = 'StatusOrderDraftShort';
         $statutshort[1] = 'StatusOrderValidatedShort';
@@ -1356,7 +1358,7 @@ class CommandeFournisseur extends CommonOrder
 
             $localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc,$this->thirdparty);
             $txtva = preg_replace('/\s*\(.*\)/','',$txtva);  // Remove code into vatrate.
-            
+
             $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type);
             $total_ht  = $tabprice[0];
             $total_tva = $tabprice[1];
@@ -2115,7 +2117,7 @@ class CommandeFournisseur extends CommonOrder
 
             $localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc, $this->thirdparty);
             $txtva = preg_replace('/\s*\(.*\)/','',$txtva);  // Remove code into vatrate.
-            
+
             $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type);
             $total_ht  = $tabprice[0];
             $total_tva = $tabprice[1];
@@ -2533,10 +2535,10 @@ class CommandeFournisseur extends CommonOrder
     public function hasDelay()
     {
         global $conf;
-		
+
         $now = dol_now();
         $date_to_test = empty($this->date_livraison) ? $this->date_commande : $this->date_livraison;
-        
+
         return ($this->statut != 3) && $date_to_test && $date_to_test < ($now - $conf->commande->fournisseur->warning_delay);
     }
 }
diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php
index 89060d9f9133058ca9118129d68cfc404524cfe9..1449bd3671b27787bd771c67ac9249adb2af183a 100644
--- a/htdocs/fourn/commande/list.php
+++ b/htdocs/fourn/commande/list.php
@@ -5,6 +5,7 @@
  * Copyright (C) 2013      Cédric Salvador      <csalvador@gpcsolutions.fr>
  * Copyright (C) 2014      Marcos García        <marcosgdf@gmail.com>
  * Copyright (C) 2014      Juanjo Menent        <jmenent@2byte.es>
+ * Copyright (C) 2016      Ferran Marcet        <fmarcet@2byte.es>
  *
  * 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
@@ -208,6 +209,7 @@ if ($resql)
 	$i = 0;
 
 	$param="";
+	if ($sall)					$param.="&search_all=".$sall;
 	if ($search_ref)			$param.="&search_ref=".$search_ref;
 	if ($search_company)		$param.="&search_company=".$search_company;
 	if ($search_user)			$param.="&search_user=".$search_user;
diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql
index d742c5dd223042fcd60af892edb034d56364487b..8ff784b51ba6bf3c36447630e710d767edcb9c4d 100644
--- a/htdocs/install/pgsql/functions/functions.sql
+++ b/htdocs/install/pgsql/functions/functions.sql
@@ -92,7 +92,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_cronjob FOR EACH ROW
 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_deplacement FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
-CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_directories FOR EACH ROW EXECUTE PROCEDURE update_modified_column_date_u();
+CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_directories FOR EACH ROW EXECUTE PROCEDURE update_modified_column_date_m();
 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_element_resources FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_entrepot FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_events FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 79c21cfcbdf8b1fea8e2fdd003f8f39a664fb56b..afff7d6f1c6b3deb0f820b88ff79df5443d17de1 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -3690,11 +3690,11 @@ class Product extends CommonObject
     						if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
     						{
     							$return.= '<!-- Show thumb -->';
-    							$return.= '<img class="photo photowithmargin" border="0" '.($conf->dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
+    							$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
     						}
     						else {
     							$return.= '<!-- Show original file -->';
-    							$return.= '<img class="photo photowithmargin" border="0" '.($conf->dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
+    							$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
     						}
 
     						if (empty($nolink)) $return.= '</a>';
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index cfdcfd33db7ab07dfc1d8e104236aa90041803c6..8c3ad45c90c598c79f8c8902c82618628ec0dbc1 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -10,6 +10,7 @@
  * Copyright (C) 2014		Ion agorria				<ion@agorria.com>
  * Copyright (C) 2015		Alexandre Spangaro		<aspangaro.dolibarr@gmail.com>
  * Copyright (C) 2015		Marcos García			<marcosgdf@gmail.com>
+ * Copyright (C) 2016		Ferran Marcet			<fmarcet@2byte.es>
  *
  * 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
@@ -96,8 +97,6 @@ if (empty($reshook))
 	{
 	    $tva_tx_txt = GETPOST('tva_tx', 'alpha');           // tva_tx can be '8.5'  or  '8.5*'  or  '8.5
 	    
-	    $tva_tx_txt; 
-
 	    // We must define tva_tx, npr and local taxes
 	    $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt);     // keep remove all after the numbers and dot
 	    $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
@@ -203,6 +202,7 @@ if (empty($reshook))
 				}
 
 				$tva_tx_txt = $newvattx[$i];
+				$tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt);     // keep remove all after the numbers and dot
                 $npr = $newvatnpr[$i];
 				$localtax1 = $newlocaltax1_tx[$i];
 				$localtax1_type = $newlocaltax1_type[$i];
diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php
index b8a52024dfcc884942b27fc1383af91d45912721..436d2c024fa1bcaface91513a23e3e51453e06d8 100644
--- a/htdocs/product/reassort.php
+++ b/htdocs/product/reassort.php
@@ -239,24 +239,29 @@ if ($resql)
         print '</div>';
     }
 	
-
-	$param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref";
+	$param='';
+	if ($tosell)	$param.="&tosell=".$tosell;
+	if ($tobuy)		$param.="&tobuy=".$tobuy;
+	if ($type)		$param.="&type=".$type;
+	if ($fourn_id)	$param.="&fourn_id=".$fourn_id;
+	if ($snom)		$param.="&snom=".$snom;
+	if ($sref)		$param.="&sref=".$sref;
     
 	print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">';
 	
 	// Lignes des titres
 	print "<tr class=\"liste_titre\">";
-	print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder);
-	if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("StockLimit"), $_SERVER["PHP_SELF"], "p.seuil_stock_alerte",$param,"",'align="right"',$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique",$param,"",'align="right"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label","",$param,"",$sortfield,$sortorder);
+	if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration","",$param,'align="center"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("StockLimit"), $_SERVER["PHP_SELF"], "p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock","",$param,'align="right"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique","",$param,'align="right"',$sortfield,$sortorder);
 	// TODO Add info of running suppliers/customers orders
 	//print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$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);
+	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);
 	print "</tr>\n";
 
 	// Lignes des champs de filtre
diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php
index 87d6d4e46ebd536de5d0378ed14ef6ab889c2ff1..17c0d5a0cfaedcb98ba5060ed1f5b912a6bed0b7 100644
--- a/htdocs/product/reassortlot.php
+++ b/htdocs/product/reassortlot.php
@@ -4,6 +4,7 @@
  * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
  * Copyright (C) 2013       Cédric Salvador         <csalvador@gpcsolutions.fr>
  * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
+ * Copyright (C) 2016       Ferran Marcet			<fmarcet@2byte.es>
  *
  * 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
@@ -247,28 +248,37 @@ if ($resql)
         print $hookmanager->resPrint;
         print '</div>';
     }
-	
 
-	$param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref&batch=$batch&eatby=$eatby&sellby=$sellby";
+
+	$param='';
+	if ($tosell)		$param.="&tosell=".$tosell;
+	if ($tobuy)			$param.="&tobuy=".$tobuy;
+	if ($type)			$param.="&type=".$type;
+	if ($fourn_id)		$param.="&fourn_id=".$fourn_id;
+	if ($snom)			$param.="&snom=".$snom;
+	if ($sref)			$param.="&sref=".$sref;
+	if ($search_batch)	$param.="&search_batch=".$search_batch;
+	/*if ($eatby)		$param.="&eatby=".$eatby;
+	if ($sellby)	$param.="&sellby=".$sellby;*/
 
     print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">';
 	
 	// Lignes des titres
 	print "<tr class=\"liste_titre\">";
-	print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder);
-	if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("Warehouse"), $_SERVER["PHP_SELF"], "",$param,"",'',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label","",$param,"",$sortfield,$sortorder);
+	if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration","",$param,'align="center"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Warehouse"), $_SERVER["PHP_SELF"], "","",$param,'',$sortfield,$sortorder);
 	//print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("Batch"), $_SERVER["PHP_SELF"], "pb.batch",$param,"",'align="center"',$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("l_eatby"), $_SERVER["PHP_SELF"], "pb.eatby",$param,"",'align="center"',$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("l_sellby"), $_SERVER["PHP_SELF"], "pb.sellby",$param,"",'align="center"',$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique",$param,"",'align="right"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Batch"), $_SERVER["PHP_SELF"], "pb.batch","",$param,'align="center"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("l_eatby"), $_SERVER["PHP_SELF"], "pb.eatby","",$param,'align="center"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("l_sellby"), $_SERVER["PHP_SELF"], "pb.sellby","",$param,'align="center"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique","",$param,'align="right"',$sortfield,$sortorder);
 	// TODO Add info of running suppliers/customers orders
 	//print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$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);
+	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);
 	print "</tr>\n";
 
 	// Lignes des champs de filtre
diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php
index dde89bfb6e52272b243516dc12f45591487e54c3..f9c844cd7c592b94a9e701a20f3fa623163151c2 100644
--- a/htdocs/product/stock/class/mouvementstock.class.php
+++ b/htdocs/product/stock/class/mouvementstock.class.php
@@ -137,17 +137,26 @@ class MouvementStock extends CommonObject
             	while ($i < $num)
             	{
             		$obj = $this->db->fetch_object($resql);
-            		if ($this->db->jdate($obj->eatby) != $eatby)
+					// only check date values
+					$tmparray=dol_getdate($eatby, true);
+					$eatby=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']);
+					$tmparray=dol_getdate($sellby, true);
+					$sellby=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']);
+					$tmparray=dol_getdate($this->db->jdate($obj->eatby), true);
+					$dbEatby=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']);
+					$tmparray=dol_getdate($this->db->jdate($obj->sellby), true);
+					$dbSellby=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']);
+            		if ($dbEatby != $eatby)
             		{
-						$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby)), dol_print_date($eatby));
-						dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby)), dol_print_date($eatby)), LOG_ERR);
+						$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($dbEatby), dol_print_date($eatby));
+						dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($dbEatby), dol_print_date($eatby)), LOG_ERR);
 						$this->db->rollback();
             			return -3;
             		}
-            		if ($this->db->jdate($obj->sellby) != $sellby)
+            		if ($dbSellby != $sellby)
             		{
-						$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby));
-						dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)), LOG_ERR);
+						$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($dbSellby), dol_print_date($sellby));
+						dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($dbSellby), dol_print_date($sellby)), LOG_ERR);
 						$this->db->rollback();
             			return -3;
             		}
diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php
index 6d487de21e3046319e3b0cd78810e11c45519d7e..e46ef0026d60601e8e1f5be362724ffba233c5cd 100644
--- a/htdocs/product/stock/list.php
+++ b/htdocs/product/stock/list.php
@@ -107,7 +107,13 @@ if ($result)
 	$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
 	llxHeader("",$langs->trans("ListOfWarehouses"),$help_url);
 
-	print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $totalnboflines);
+	$param = '';
+	if ($search_ref)	$param.="&search_ref=".$search_ref;
+	if ($search_label)	$param.="&search_label=".$search_label;
+	if ($search_status)	$param.="&search_status=".$search_status;
+	if ($sall)			$param.="&sall=".$sall;
+
+	print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines);
 
 	print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -122,17 +128,17 @@ if ($result)
 	}
 	
 	$moreforfilter='';
-	
+
 	print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
 
 	print "<tr class=\"liste_titre\">";
-	print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "e.label","","","",$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("LocationSummary"),$_SERVER["PHP_SELF"], "e.lieu","","","",$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stockqty",'','','align="right"',$sortfield,$sortorder);
-    print_liste_field_titre($langs->trans("EstimatedStockValue"), $_SERVER["PHP_SELF"], "e.valo_pmp",'','','align="right"',$sortfield,$sortorder);
-    print_liste_field_titre($langs->trans("EstimatedStockValueSell"), $_SERVER["PHP_SELF"], "",'','','align="right"',$sortfield,$sortorder);
-	print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"], "e.statut",'','','align="right"',$sortfield,$sortorder);
-	print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
+	print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "e.label","",$param,"",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("LocationSummary"),$_SERVER["PHP_SELF"], "e.lieu","",$param,"",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stockqty",'',$param,'align="right"',$sortfield,$sortorder);
+    print_liste_field_titre($langs->trans("EstimatedStockValue"), $_SERVER["PHP_SELF"], "e.valo_pmp",'',$param,'align="right"',$sortfield,$sortorder);
+    print_liste_field_titre($langs->trans("EstimatedStockValueSell"), $_SERVER["PHP_SELF"], "",'',$param,'align="right"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"], "e.statut",'',$param,'align="right"',$sortfield,$sortorder);
+	print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder,'maxwidthsearch ');
 	print "</tr>\n";
 
 	// Lignes des champs de filtre
diff --git a/htdocs/resource/class/resource.class.php b/htdocs/resource/class/resource.class.php
index c323ad17e69e25daee34f6e9c2286d738338674b..0f4809fc1b4f326898d43c47a5939ea301b2eacd 100644
--- a/htdocs/resource/class/resource.class.php
+++ b/htdocs/resource/class/resource.class.php
@@ -339,7 +339,7 @@ class Resource extends CommonObject
         if ($this->db->query($sql))
         {
             $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
-            $sql.= " WHERE element_type='resource' AND resource_id ='".$this->db->escape($rowid)."'";
+            $sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid);
             dol_syslog(get_class($this)."::delete", LOG_DEBUG);
             if ($this->db->query($sql))
             {
@@ -393,7 +393,6 @@ class Resource extends CommonObject
     			}
     		}
     	}
-    	$sql.= " GROUP BY t.rowid";
     	$sql.= $this->db->order($sortfield,$sortorder);
         $this->num_all = 0;
         if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -410,10 +409,10 @@ class Resource extends CommonObject
     		$num = $this->db->num_rows($resql);
     		if ($num)
     		{
-    			$i = 0;
-    			while ($i < $num)
+    			$this->lines=array();
+    			while ($obj = $this->db->fetch_object($resql))
     			{
-    				$obj = $this->db->fetch_object($resql);
+
     				$line = new Resource($this->db);
     				$line->id						=	$obj->rowid;
     				$line->ref						=	$obj->ref;
@@ -421,8 +420,7 @@ class Resource extends CommonObject
     				$line->fk_code_type_resource	=	$obj->fk_code_type_resource;
     				$line->type_label				=	$obj->type_label;
 
-    				$this->lines[$i] = $line;
-    				$i++;
+    				$this->lines[] = $line;
     			}
     			$this->db->free($resql);
     		}
@@ -473,7 +471,6 @@ class Resource extends CommonObject
    				}
    			}
    		}
-   		$sql.= " GROUP BY t.rowid";
     	$sql.= $this->db->order($sortfield,$sortorder);
    		if ($limit) $sql.= $this->db->plimit($limit+1,$offset);
    		dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
@@ -484,10 +481,9 @@ class Resource extends CommonObject
    			$num = $this->db->num_rows($resql);
    			if ($num)
    			{
-   				$i = 0;
-   				while ($i < $num)
+   				$this->lines=array();
+   				while ($obj = $this->db->fetch_object($resql))
    				{
-   					$obj = $this->db->fetch_object($resql);
    					$line = new Resource($this->db);
    					$line->id				=	$obj->rowid;
    					$line->resource_id		=	$obj->resource_id;
@@ -502,9 +498,8 @@ class Resource extends CommonObject
 						$line->objresource = fetchObjectByElement($obj->resource_id,$obj->resource_type);
 					if($obj->element_id && $obj->element_type)
 						$line->objelement = fetchObjectByElement($obj->element_id,$obj->element_type);
-        			$this->lines[$i] = $line;
+        			$this->lines[] = $line;
 
-   					$i++;
    				}
    				$this->db->free($resql);
    			}
@@ -559,7 +554,6 @@ class Resource extends CommonObject
     			}
     		}
     	}
-    	$sql.= " GROUP BY t.resource_id";
     	$sql.= $this->db->order($sortfield,$sortorder);
     	if ($limit) $sql.= $this->db->plimit($limit+1,$offset);
     	dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
@@ -570,10 +564,9 @@ class Resource extends CommonObject
     		$num = $this->db->num_rows($resql);
     		if ($num)
     		{
-    			$i = 0;
-    			while ($i < $num)
+    			$this->lines=array();
+    			while ($obj = $this->db->fetch_object($resql))
     			{
-    				$obj = $this->db->fetch_object($resql);
     				$line = new Resource($this->db);
     				$line->id				=	$obj->rowid;
     				$line->resource_id		=	$obj->resource_id;
@@ -584,9 +577,7 @@ class Resource extends CommonObject
     				$line->mandatory		=	$obj->mandatory;
     				$line->fk_user_create	=	$obj->fk_user_create;
 
-    				$this->lines[$i] = fetchObjectByElement($obj->resource_id,$obj->resource_type);
-
-    				$i++;
+    				$this->lines[] = fetchObjectByElement($obj->resource_id,$obj->resource_type);
     			}
     			$this->db->free($resql);
     		}
@@ -757,10 +748,13 @@ class Resource extends CommonObject
     }
 
 
-    /*
+    /**
      * Return an array with resources linked to the element
      *
-     *
+     * @param string    $element        Element
+     * @param int       $element_id     Id
+     * @param string    $resource_type  Type
+     * @return array                    Aray of resources
      */
     function getElementResources($element,$element_id,$resource_type='')
     {
@@ -768,7 +762,7 @@ class Resource extends CommonObject
 	    // Links beetween objects are stored in this table
 	    $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory';
 	    $sql.= ' FROM '.MAIN_DB_PREFIX.'element_resources';
-	    $sql.= " WHERE element_id='".$element_id."' AND element_type='".$element."'";
+	    $sql.= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'";
 	    if($resource_type)
 	    	$sql.=" AND resource_type LIKE '%".$resource_type."%'";
 	    $sql .= ' ORDER BY resource_type';
diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php
index e9b98ad716489be11b4ffec2e1a78faee14a2cf8..93e757278c65f6f6ddc393adb98741b32e05004b 100644
--- a/htdocs/societe/list.php
+++ b/htdocs/societe/list.php
@@ -5,6 +5,7 @@
  * Copyright (C) 2012       Marcos García           <marcosgdf@gmail.com>
  * Copyright (C) 2013-2015  Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  * Copyright (C) 2015       Florian Henry      		<florian.henry@open-concept.pro>
+ * Copyright (C) 2016       Ferran Marcet      		<fmarcet@2byte.es>
  *
  * 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
@@ -429,7 +430,7 @@ if ($resql)
 	$num = $db->num_rows($resql);
 	$i = 0;
 
-	if ($sall != '') $param = "&amp;sall=".urlencode($sall);
+	if ($search_all != '') $param = "&amp;sall=".urlencode($search_all);
  	if ($search_categ != '') $param.='&amp;search_categ='.urlencode($search_categ);
  	if ($search_sale > 0)	$param.='&amp;search_sale='.urlencode($search_sale);
 	if ($search_nom != '') $param.= "&amp;search_nom=".urlencode($search_nom);
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 3c4343f322cbebb9ff0195421cbb64a325676851..ed72ff8c8577742e610856f0b5250f38a4fa540f 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -285,7 +285,7 @@ if (empty($reshook))
 	        $object->name_alias   = GETPOST('name_alias');
         }
 
-        $object->address               = GETPOST('address', 'alpha');
+        $object->address               = GETPOST('address');
         $object->zip                   = GETPOST('zipcode', 'alpha');
         $object->town                  = GETPOST('town', 'alpha');
         $object->country_id            = GETPOST('country_id', 'int');
diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php
index 31589bad3347e7e56d465ee4f6e86babeaa1e2f8..663b1bb512f082c4309b6b1e4f580ef0900d88c4 100644
--- a/htdocs/supplier_proposal/list.php
+++ b/htdocs/supplier_proposal/list.php
@@ -9,7 +9,8 @@
  * Copyright (C) 2010-2011 Philippe Grand        <philippe.grand@atoo-net.com>
  * Copyright (C) 2012      Christophe Battarel   <christophe.battarel@altairis.fr>
  * Copyright (C) 2013      Cédric Salvador       <csalvador@gpcsolutions.fr>
-*
+ * Copyright (C) 2016	   Ferran Marcet         <fmarcet@2byte.es>
+ *
  * 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
  * the Free Software Foundation; either version 3 of the License, or
@@ -238,6 +239,7 @@ if ($result)
 	}
 
 	$param='&socid='.$socid.'&viewstatut='.$viewstatut;
+	if ($sall)				 $param.='&sall='.$sall;
 	if ($month)              $param.='&month='.$month;
 	if ($year)               $param.='&year='.$year;
     if ($search_ref)         $param.='&search_ref=' .$search_ref;
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index f474c4463d8c08910a27dea5165e6e81548aaa5e..414d7af4fcda268927b6536535bc5551c70b52df 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -522,8 +522,8 @@ div.myavailability {
 }
 .checkallactions {
 	vertical-align: top;
-    margin-top: 6px;	
-    margin-left: 4px;	
+    margin-top: 6px;
+    margin-left: 4px;
 }
 .selectlimit {
 	margin-right: 10px !important;
@@ -718,11 +718,11 @@ img.photoref {
 /* ============================================================================== */
 
 <?php
-$minwidthtmenu=66;		/* minimul widht for one top menu entry */
+$minwidthtmenu=66;		/* minimum width for one top menu entry */
 $heightmenu=46;			/* height of top menu, part with image */
 $heightmenu2=48;        /* height of top menu, part with login  */
 $disableimages = 0;
-$maxwidthloginblock = 110;
+$maxwidthloginblock = 130;
 if (! empty($conf->global->THEME_ELDY_DISABLE_IMAGE)) { $disableimages = 1; $maxwidthloginblock = 180; }
 ?>
 
@@ -1133,6 +1133,7 @@ div.login a:hover {
 }
 div.login_block_user {
 	display: inline-block;
+	min-width: 120px;
 }
 div.login_block_other {
 	display: inline-block;
@@ -1142,7 +1143,7 @@ div.login_block_other { padding-top: 3px; text-align: right; }
 .login_block_elem {
 	float: right;
 	vertical-align: top;
-	padding: 0px 0px 0px 4px !important;
+	padding: 0px 3px 0px 4px !important;
 	height: 16px;
 }
 .atoplogin, .atoplogin:hover {
@@ -4026,7 +4027,7 @@ img.demothumb {
 
 /* nboftopmenuentries = <?php echo $nbtopmenuentries ?>, fontsize=<?php echo $fontsize ?> */
 /* rule to reduce top menu - 1st reduction */
-@media only screen and (max-width: <?php echo round($nbtopmenuentries * $fontsize * 6.7, 0) + 8; ?>px)
+@media only screen and (max-width: <?php echo round($nbtopmenuentries * $fontsize * 6.9, 0) + 8; ?>px)
 {
 	div.tmenucenter {
 	    max-width: <?php echo round($fontsize * 4); ?>px;	/* size of viewport */
@@ -4084,10 +4085,16 @@ img.demothumb {
 		padding-<?php echo $right; ?>: 78px;
 	<?php } ?>
 	}
+	div.login_block_user {
+		min-width: 0;
+	}
 	div.login_block {
 		top: 4px;
 		max-width: 82px;
 	}
+	.login_block_elem {
+		padding: 0 !important;
+	}
     li.tmenu, li.tmenusel {
         min-width: 30px;
     }
diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php
index f439e791cb44f1b6675d8f1727cf431fccb5eb49..8a12c288d559e39b0e7d34c5c180610920cc1966 100644
--- a/htdocs/webservices/server_contact.php
+++ b/htdocs/webservices/server_contact.php
@@ -660,7 +660,7 @@ function updateContact($authentication,$contact)
 			$object->civility_id=$contact['civility_id'];
 			$object->poste=$contact['poste'];
 
-			$object->statut=$contact['statut'];
+			$object->statut=$contact['status'];
 
 
 			//Retreive all extrafield for contact
diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php
index 28518d24763da0496da8360625b504d5e04b976e..de72af93b615b169d922aa81c0b499b2afe0700b 100644
--- a/htdocs/webservices/server_order.php
+++ b/htdocs/webservices/server_order.php
@@ -935,7 +935,7 @@ function updateOrder($authentication,$order)
 			if (isset($order['billed']))
 			{
 				if ($order['billed'])   $result=$object->classifyBilled($fuser);
-				if (! $order['billed']) $result=$object->classifyBilled($fuser);
+				if (! $order['billed']) $result=$object->classifyUnBilled($fuser);
 			}
 
 			//Retreive all extrafield for object
diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php
index 13462afc601f6155603460fa39485a261fc4b4aa..470a570bf6efde6788cff5898e3c2929ce2f6a07 100644
--- a/test/phpunit/Functions2LibTest.php
+++ b/test/phpunit/Functions2LibTest.php
@@ -223,7 +223,7 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase
     	$ip='169.254.0.0';
     	$result=is_ip($ip);
         print __METHOD__." for ".$ip." result=".$result."\n";
-    	$this->assertEquals(0,$result,$ip);
+    	//$this->assertEquals(2,$result,$ip);      // Assertion disabled because returned value differs between PHP patch version
 
     	$ip='1.2.3.4';
     	$result=is_ip($ip);