diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index f73b4917d78c51e938a9eb20efbd79a1fdede1e4..7a9e230119127484644c4ebd173dd516e80fbd01 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -2056,7 +2056,7 @@ class Propal extends CommonObject
                     {
                         // We remove directory
                         $ref = dol_sanitizeFileName($this->ref);
-                        if ($conf->propal->dir_output)
+                        if ($conf->propal->dir_output && !empty($this->ref))
                         {
                             $dir = $conf->propal->dir_output . "/" . $ref ;
                             $file = $dir . "/" . $ref . ".pdf";
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 2341f5e4ff7624c3a5cb2db1b0e5a4d2e71d3a18..5566ce4d90db7625d8660e73b0f663b96a0ec5e2 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -2457,7 +2457,7 @@ class Commande extends CommonOrder
 
         	// On efface le repertoire de pdf provisoire
         	$comref = dol_sanitizeFileName($this->ref);
-        	if ($conf->commande->dir_output)
+        	if ($conf->commande->dir_output && !empty($this->ref))
         	{
         		$dir = $conf->commande->dir_output . "/" . $comref ;
         		$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 521a8f63e803775957137421f51d663408ed980a..53adade47ab81418cf44bc4e1e3489828f065f2f 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1323,7 +1323,7 @@ class Facture extends CommonInvoice
 				{
 					// On efface le repertoire de pdf provisoire
 					$ref = dol_sanitizeFileName($this->ref);
-					if ($conf->facture->dir_output)
+					if ($conf->facture->dir_output && !empty($this->ref))
 					{
 						$dir = $conf->facture->dir_output . "/" . $ref;
 						$file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf";
diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php
index a368561d8af2c62b07c6499e85496e40334eb0e6..de21a157c7449b7f3e0eb196239abbd5609897a6 100644
--- a/htdocs/core/lib/tax.lib.php
+++ b/htdocs/core/lib/tax.lib.php
@@ -49,8 +49,12 @@ function tax_prepare_head($object)
     // $this->tabs = array('entity:-tabname);   												to remove a tab
     complete_head_from_modules($conf,$langs,$object,$head,$h,'tax');
 
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+	$upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref);
+	$nbFiles = count(dol_dir_list($upload_dir,'files'));
 	$head[$h][0] = DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id;
 	$head[$h][1] = $langs->trans("Documents");
+	if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')';
 	$head[$h][2] = 'documents';
 	$h++;
 
diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php
index b9c5d89a72e4d4cbe67aa1988734ffa1b5db0ec0..07c568d41fc64d4c485f1d01405bd0b960b3955c 100644
--- a/htdocs/core/login/functions_ldap.php
+++ b/htdocs/core/login/functions_ldap.php
@@ -168,6 +168,15 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
 					{
 						dol_syslog("functions_ldap::check_user_password_ldap Sync user found id=".$user->id);
 						// On verifie si le login a change et on met a jour les attributs dolibarr
+						
+						if ($conf->multicompany->enabled) {
+							global $mc;		
+								
+							$ret=$mc->checkRight($user->id, $entitytotest);
+							if ($ret < 0) $login=false; // provoque l'echec de l'identification
+						}
+						
+						
 						if ($user->login != $ldap->login && $ldap->login)
 						{
 							$user->login = $ldap->login;
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index 5ac8438f2ad7225d7be5a6c3dc87d8abdec62ddb..dba0d7c8acc6eedb6de39d94d812fc5d8c76eb52 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -701,38 +701,37 @@ elseif ($action == 'update_extras')
 	// Fill array 'array_options' with data from add form
 	$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
 	$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
-	
-	if($ret < 0)
-		$error++;
-	
-	if(!$error) {
-	
+
+	if($ret < 0) $error++;
+
+	if (!$error)
+	{
 		// Actions on extra fields (by external module or standard code)
 		// FIXME le hook fait double emploi avec le trigger !!
 		$hookmanager->initHooks(array('supplierorderdao'));
 		$parameters=array('id'=>$object->id);
-		
+
 		$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
-		
+
 		if (empty($reshook))
 		{
 			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
 			{
-			
+
 				$result=$object->insertExtraFields();
-				
+
 				if ($result < 0)
 				{
 					$error++;
 				}
-			
+
 			}
 		}
 		else if ($reshook < 0) $error++;
 	}
 	else
 	{
-	$action = 'edit_extras';
+		$action = 'edit_extras';
 	}
 }
 
@@ -1119,12 +1118,12 @@ if ($action=="create")
 	// Other options
     $parameters=array();
     $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
-	
+
 	if (empty($reshook) && ! empty($extrafields->attribute_label))
     {
 		print $object->showOptionals($extrafields,'edit');
     }
-	
+
 	// Bouton "Create Draft"
     print "</table>\n";
 
@@ -1141,9 +1140,9 @@ elseif (! empty($object->id))
 
 	$title=$langs->trans("SupplierOrder");
 	dol_fiche_head($head, 'card', $title, 0, 'order');
-	
+
 	$res=$object->fetch_optionals($object->id,$extralabels);
-	
+
 	/*
 	 * Confirmation de la suppression de la commande
 	 */
@@ -1408,7 +1407,6 @@ elseif (! empty($object->id))
 	// Other attributes
 	$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"');
 	$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-
 	if (empty($reshook) && ! empty($extrafields->attribute_label))
 	{
 		if ($action == 'edit_extras')
@@ -1418,7 +1416,7 @@ elseif (! empty($object->id))
 			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 			print '<input type="hidden" name="id" value="'.$object->id.'">';
 		}
-		
+
 		foreach($extrafields->attribute_label as $key=>$label)
 		{
 			if ($action == 'edit_extras') {
@@ -1426,7 +1424,7 @@ elseif (! empty($object->id))
 			} else {
 				$value=$object->array_options["options_".$key];
 			}
-			
+
 			if ($extrafields->attribute_type[$key] == 'separate')
 			{
 				print $extrafields->showSeparator($key);
@@ -1441,7 +1439,7 @@ elseif (! empty($object->id))
 				{
 					$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$db->jdate($object->array_options['options_'.$key]);
 				}
-				
+
 				if ($action == 'edit_extras' && $user->rights->fournisseur->commande->creer)
 				{
 		  			print $extrafields->showInputField($key,$value);
@@ -1450,12 +1448,13 @@ elseif (! empty($object->id))
 				{
 		  			print $extrafields->showOutputField($key,$value);
 				}
-				
+
 				print '</td></tr>'."\n";
 		  	}
 		}
 
-		if(count($extrafields->attribute_label) > 0) {
+		if(count($extrafields->attribute_label) > 0)
+		{
 			if ($action == 'edit_extras' && $user->rights->fournisseur->commande->creer)
 			{
 				print '<tr><td></td><td colspan="5">';
@@ -1463,7 +1462,8 @@ elseif (! empty($object->id))
 				print '</form>';
 				print '</td></tr>';
 			}
-			else {
+			else
+			{
 				if ($object->statut == 0 && $user->rights->fournisseur->commande->creer)
 				{
 					print '<tr><td></td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras">'.img_picto('','edit').' '.$langs->trans('Modify').'</a></td></tr>';
@@ -1471,7 +1471,7 @@ elseif (! empty($object->id))
 			}
 		}
 	}
-	
+
 	// Ligne de	3 colonnes
 	print '<tr><td>'.$langs->trans("AmountHT").'</td>';
 	print '<td align="right"><b>'.price($object->total_ht).'</b></td>';
diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang
index 05fd7432c3e07aaf5237093c2350b5be67491135..37112051348f3d5c77f0a27a3690503a270d53b7 100644
--- a/htdocs/langs/es_ES/admin.lang
+++ b/htdocs/langs/es_ES/admin.lang
@@ -1010,7 +1010,6 @@ AddRefInList=Mostrar el código de cliente/proveedor en los listados (lista desp
 FieldEdition=Edición del campo %s
 FixTZ=Ajueste TimeZone
 FillThisOnlyIfRequired=Ejemplo: +2 (Rellene únicamente si se experimentan problemas de offset de zona horaria)
-
 ##### Module password generation
 PasswordGenerationStandard=Devuelve una contraseña generada por el algoritmo interno Dolibarr: 8 caracteres, números y caracteres en minúsculas mezcladas.
 PasswordGenerationNone=No ofrece contraseñas. La contraseña se introduce manualmente.
diff --git a/htdocs/langs/es_ES/main.lang b/htdocs/langs/es_ES/main.lang
index 49e9a94be4b51b8a06eee5c6c54c96417f0d0c43..0bf342a7c5a15741c15840051748986d78c97e63 100644
--- a/htdocs/langs/es_ES/main.lang
+++ b/htdocs/langs/es_ES/main.lang
@@ -666,7 +666,6 @@ SaveUploadedFileWithMask=Guardar el archivo con el nombre "<strong>%s</strong>"
 OriginFileName=Nombre del archivo origen
 SetDemandReason=Definir origen
 ViewPrivateNote=Ver notas
-
 # Week day
 Monday=Lunes
 Tuesday=Martes