diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index e39221921b0bcd254a830d2f4bd7365ac67d5458..dc78424568c6862c59b53f7ce68976aac33cdb4f 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -35,7 +35,7 @@ class ActionComm extends CommonObject
     public $element='action';
     public $table_element = 'actioncomm';
     public $table_rowid = 'id';
-    protected $ismultientitymanaged = 2;	// 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+    protected $ismultientitymanaged = 1;	// 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
 
     var $id;
     var $type_id;
diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php
index 6a576c580cab149b9026911e18a9b74a38502a2e..7ad74302655729db684ab9ea01f8b125b3e6f36c 100755
--- a/htdocs/comm/action/document.php
+++ b/htdocs/comm/action/document.php
@@ -51,6 +51,8 @@ if ($user->societe_id > 0)
 	$socid = $user->societe_id;
 }
 
+$result = restrictedArea($user, 'agenda', $objectid, 'actioncomm&societe', 'myactions&allactions', '', 'id');
+
 $act = new ActionComm($db);
 
 if ($objectid > 0)
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index aa2e9a695db8d62ec11b34fabc1923d6eea30d54..dd52d5d92a2b95e48ea9fc60f92a8822e4e59d6f 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -53,7 +53,7 @@ $contactid=GETPOST('contactid','int');
 $socid = GETPOST('socid','int');
 $id = GETPOST('id','int');
 if ($user->societe_id) $socid=$user->societe_id;
-//$result = restrictedArea($user, 'agenda', $id, 'actioncomm', 'actions', '', 'id');
+$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions&allactions', '', 'id');
 
 $error=GETPOST("error");
 $mesg='';
diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php
index 7c775bf78ac034ccbe7c3835dc84620b24688174..66dc178d4b83cfbbe52fcbbdf7cbf9e82cadfe79 100644
--- a/htdocs/comm/action/info.php
+++ b/htdocs/comm/action/info.php
@@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
 
 $langs->load("commercial");
 
+$id = GETPOST('id','int');
+
 // Security check
 if ($user->societe_id > 0)
 {
@@ -38,6 +40,7 @@ if ($user->societe_id > 0)
   $socid = $user->societe_id;
 }
 
+$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions&allactions', '', 'id');
 
 
 /*
@@ -48,8 +51,8 @@ $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
 llxHeader('',$langs->trans("Agenda"),$help_url);
 
 $act = new ActionComm($db);
-$act->fetch($_GET["id"]);
-$act->info($_GET["id"]);
+$act->fetch($id);
+$act->info($act->id);
 
 $head=actions_prepare_head($act);
 dol_fiche_head($head, 'info', $langs->trans("Action"),0,'action');
diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php
index 5737c9bb99a8e53efc1b6155da3385f13b60549e..48c0f5c1e9ebf12efe4359b5cfade8b3e2e956ed 100644
--- a/htdocs/compta/facture/impayees.php
+++ b/htdocs/compta/facture/impayees.php
@@ -227,7 +227,7 @@ if ($search_societe)     $sql .= " AND s.nom LIKE '%".$search_societe."%'";
 if ($search_montant_ht)  $sql .= " AND f.total = '".$search_montant_ht."'";
 if ($search_montant_ttc) $sql .= " AND f.total_ttc = '".$search_montant_ttc."'";
 if (GETPOST('sf_ref')) $sql .= " AND f.facnumber LIKE '%".GETPOST('sf_ref') . "%'";
-$sql.= " GROUP BY f.facnumber,f.increment,f.total,f.total_ttc,f.datef, f.date_lim_reglement,f.paye, f.rowid, f.fk_statut, f.type,s.nom, s.rowid";
+$sql.= " GROUP BY s.nom, s.rowid, f.facnumber, f.increment, f.total, f.tva, f.total_ttc, f.datef, f.date_lim_reglement, f.paye, f.rowid, f.fk_statut, f.type ";
 if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user ";
 $sql.= " ORDER BY ";
 $listfield=explode(',',$sortfield);
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index 281c315eec41d6d03ba58ab6de1c61ee74d5553e..15d2e33885cbafeeb86500b3309b38ae3ea7617a 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -941,7 +941,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
 	$sql.= " AND ff.fk_statut = 1";
 	if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
 	if ($socid) $sql.= " AND ff.fk_soc = ".$socid;
-	$sql.= " GROUP BY ff.rowid, ff.facnumber, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc, s.nom, s.rowid";
+	$sql.= " GROUP BY ff.rowid, ff.facnumber, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc, ff.paye,";
+	$sql.= " s.nom, s.rowid";
 
 	$resql=$db->query($sql);
 	if ($resql)
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 8afb74a029fb63bc5cbb1e7de5687641dd9028ac..e8208fd6df6c34409912a7fdb8b38311bbd52ac2 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -35,6 +35,7 @@ class Contact extends CommonObject
 {
 	public $element='contact';
 	public $table_element='socpeople';
+	protected $ismultientitymanaged = 1;	// 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
 
 	var $id;
 	var $civilite_id;  // In fact we stor civility_code
@@ -745,7 +746,7 @@ class Contact extends CommonObject
 				$this->error=$this->db->error().' sql='.$sql;
 			}
 		}
-		
+
 		// Removed extrafields
 		 if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { // For avoid conflicts if trigger used
 			$result=$this->deleteExtraFields($this);
diff --git a/htdocs/contact/exportimport.php b/htdocs/contact/exportimport.php
index d1cb013c85f46bf6fb1eb7766f26a43d6c3c69d9..faed409e96fe9b768f4d1ff00196efd46584017d 100644
--- a/htdocs/contact/exportimport.php
+++ b/htdocs/contact/exportimport.php
@@ -29,26 +29,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
 $langs->load("companies");
 
 // Security check
-$contactid = isset($_GET["id"])?$_GET["id"]:'';
+$id = GETPOST('id', 'int');
 if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe');
+$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
 
 
 /*
  *	View
  */
 
-llxHeader('',$langs->trans("ContactsAddresses"),'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
+$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+
+llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
 
 $form = new Form($db);
 
 $contact = new Contact($db);
-$contact->fetch($_GET["id"], $user);
+$contact->fetch($id, $user);
 
 
 $head = contact_prepare_head($contact);
 
-dol_fiche_head($head, 'exportimport', $langs->trans("ContactsAddresses"), 0, 'contact');
+dol_fiche_head($head, 'exportimport', $title, 0, 'contact');
 
 
 /*
@@ -97,7 +99,7 @@ print '</div>';
 print '<br>';
 
 print $langs->trans("ExportCardToFormat").': ';
-print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$_GET["id"].'">';
+print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$contact->id.'">';
 print img_picto($langs->trans("VCard"),'vcard.png').' ';
 print $langs->trans("VCard");
 print '</a>';
diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index 0233c367b0732648394220e1faceab98be099ca2..4392bbbe374f21b74c56f0bfb324367e369cc892 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -62,7 +62,7 @@ if (! empty($canvas))
 }
 
 // Security check
-$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', '', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission
+$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission
 
 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php
index 927d8c1c922808f79561ddb7189151496e184365..a6f913f074398c7093b3c54a73935ee2cfe480e5 100644
--- a/htdocs/contact/ldap.php
+++ b/htdocs/contact/ldap.php
@@ -35,12 +35,12 @@ $langs->load("admin");
 $action=GETPOST('action');
 
 // Security check
-$contactid = isset($_GET["id"])?$_GET["id"]:'';
+$id = GETPOST('id', 'int');
 if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe');
+$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
 
 $contact = new Contact($db);
-$contact->fetch($_GET["id"], $user);
+$contact->fetch($id, $user);
 
 
 /*
@@ -79,13 +79,15 @@ if ($action == 'dolibarr2ldap')
  *	View
  */
 
-llxHeader('',$langs->trans("ContactsAddresses"),'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas');
+$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+
+llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas');
 
 $form = new Form($db);
 
 $head = contact_prepare_head($contact);
 
-dol_fiche_head($head, 'ldap', $langs->trans("ContactsAddresses"), 0, 'contact');
+dol_fiche_head($head, 'ldap', $title, 0, 'contact');
 
 
 print '<table class="border" width="100%">';
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index d321e07a2585163c519cafb3b10dd5665dc72ff2..86462d05fae4bdeabb08fa98357679e1c138bbe7 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -69,7 +69,9 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact
 
 $now=dol_now();
 
-llxHeader('',$langs->trans("ContactsAddresses"),'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas');
+$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+
+llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas');
 
 $form = new Form($db);
 
@@ -77,7 +79,7 @@ $object->fetch($id, $user);
 
 $head = contact_prepare_head($object);
 
-dol_fiche_head($head, 'perso', $langs->trans("ContactsAddresses"), 0, 'contact');
+dol_fiche_head($head, 'perso', $title, 0, 'contact');
 
 if ($action == 'edit')
 {
diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php
index 0448bb519e0ba917aae162a26cda3bf8aa53a755..16c2e1abc22ec9dc38421060115a179e9b94b699 100644
--- a/htdocs/contact/vcard.php
+++ b/htdocs/contact/vcard.php
@@ -29,8 +29,13 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/vcard.class.php';
 
 
+$id = GETPOST('id', 'int');
+
+// Security check
+$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
+
 $contact = new Contact($db);
-$result=$contact->fetch($_GET["id"]);
+$result=$contact->fetch($id);
 
 $physicalperson=1;
 
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 896291fddef3f16c44955982ea5ec2b485fb8ab2..b4ddaf160e430ea48417043de1db844536d39009 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -112,11 +112,15 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
         if (method_exists($objcanvas->control,'restrictedArea')) return $objcanvas->control->restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select);
     }
 
-    if ($dbt_select != 'rowid') $objectid = "'".$objectid."'";
+    if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'";
 
     // More features to check
     $features = explode("&", $features);
 
+    // More subfeatures to check
+    if (!empty($feature2))
+    	$feature2 = explode("&", $feature2);
+
     // More parameters
     $params = explode('&', $dbtablename);
     $dbtablename=(! empty($params[0]) ? $params[0] : '');
@@ -164,8 +168,11 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
         }
         else if (! empty($feature2))	// This should be used for future changes
         {
-            if (empty($user->rights->$feature->$feature2->lire)
-            && empty($user->rights->$feature->$feature2->read)) $readok=0;
+        	foreach($feature2 as $subfeature)
+        	{
+        		if (empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) $readok=0;
+        		else { $readok=1; break; } // For bypass the second test if the first is ok
+        	}
         }
         else if (! empty($feature) && ($feature!='user' && $feature!='usergroup'))		// This is for old permissions
         {
@@ -210,8 +217,11 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
             }
             else if (! empty($feature2))	// This should be used for future changes
             {
-                if (empty($user->rights->$feature->$feature2->creer)
-                && empty($user->rights->$feature->$feature2->write)) $createok=0;
+            	foreach($feature2 as $subfeature)
+            	{
+            		if (empty($user->rights->$feature->$subfeature->creer) && empty($user->rights->$feature->$subfeature->write)) $createok=0;
+            		else { $createok=1; break; } // For bypass the second test if the first is ok
+            	}
             }
             else if (! empty($feature))		// This is for old permissions
             {
@@ -271,8 +281,11 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
             }
             else if (! empty($feature2))	// This should be used for future changes
             {
-                if (empty($user->rights->$feature->$feature2->supprimer)
-                && empty($user->rights->$feature->$feature2->delete)) $deleteok=0;
+            	foreach($feature2 as $subfeature)
+            	{
+            		if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0;
+            		else { $deleteok=1; break; } // For bypass the second test if the first is ok
+            	}
             }
             else if (! empty($feature))		// This is for old permissions
             {
diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php
index 4d482f017cf3c402be44d6cc45cbd3045e212fc2..1df48c997dc5e7c1aafc022e4141a8b62160806e 100644
--- a/htdocs/core/modules/syslog/mod_syslog_file.php
+++ b/htdocs/core/modules/syslog/mod_syslog_file.php
@@ -96,12 +96,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface
 	/**
 	 * Return the parsed logfile path
 	 *
-<<<<<<< OURS
 	 * @return string
-=======
-	 * @param	string	$suffixinfilename	When output is a file, append this suffix into default log filename.
-	 * @return	string
->>>>>>> THEIRS
 	 */
 	private function getFilename()
 	{
diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php
index 467d02e8726e0785a37b3e89ab66292db736150b..c515307663db5bf065da1c7fd1a4ff97283b989e 100644
--- a/htdocs/fourn/facture/impayees.php
+++ b/htdocs/fourn/facture/impayees.php
@@ -143,8 +143,8 @@ if ($user->rights->fournisseur->facture->lire)
 	{
 		$sql .= " AND f.facnumber LIKE '%".GETPOST('sf_re')."%'";
 	}
-	$sql.= " GROUP BY f.facnumber, f.rowid, f.total_ht, f.total_ttc, f.datef, f.date_lim_reglement, f.paye, f.fk_statut, s.rowid, s.nom";
-
+	$sql.= " GROUP BY s.rowid, s.nom, f.rowid, f.facnumber, f.total_ht, f.total_ttc, f.datef, f.date_lim_reglement,f.paye, f.rowid, f.fk_statut";
+	if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user ";
 	$sql.= " ORDER BY ";
 	$listfield=explode(',',$sortfield);
 	foreach ($listfield as $key => $value) $sql.=$listfield[$key]." ".$sortorder.",";
diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php
index 924d6eb1c4e136ab2a48325f7f3cb9e894923d81..b5e3fc4f39359bc686855737f3c9da3549d02caf 100644
--- a/htdocs/holiday/class/holiday.class.php
+++ b/htdocs/holiday/class/holiday.class.php
@@ -38,7 +38,7 @@ class Holiday extends CommonObject
     var $errors=array();
 
     var $rowid;
-    var $ref;
+    var $ref;
 
     var $fk_user;
     var $date_create='';
@@ -82,12 +82,12 @@ class Holiday extends CommonObject
      */
     function updateSold()
     {
-	    // Mets à jour les congés payés en début de mois
-	    $this->updateSoldeCP();
-
-	    // Vérifie le nombre d'utilisateur et mets à jour si besoin
-	    $this->verifNbUsers($this->countActiveUsers(),$this->getConfCP('nbUser'));
-	    return 1;
+	    // Mets à jour les congés payés en début de mois
+	    $this->updateSoldeCP();
+
+	    // Vérifie le nombre d'utilisateur et mets à jour si besoin
+	    $this->verifNbUsers($this->countActiveUsers(),$this->getConfCP('nbUser'));
+	    return 1;
     }
 
     /**
@@ -364,11 +364,11 @@ class Holiday extends CommonObject
         $sql.= " cp.fk_user_cancel,";
         $sql.= " cp.detail_refuse,";
 
-        $sql.= " uu.name as user_lastname,";
-        $sql.= " uu.firstname as user_firstname,";
+        $sql.= " uu.name as user_lastname,";
+        $sql.= " uu.firstname as user_firstname,";
 
-        $sql.= " ua.name as validator_lastname,";
-        $sql.= " ua.firstname as validator_firstname";
+        $sql.= " ua.name as validator_lastname,";
+        $sql.= " ua.firstname as validator_firstname";
 
         $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua";
         $sql.= " WHERE cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau
@@ -469,7 +469,7 @@ class Holiday extends CommonObject
         } else {
             $error++;
         }
-       	$sql.= " halfday = ".$this->halfday.",";
+       	$sql.= " halfday = ".$this->halfday.",";
         if(!empty($this->statut) && is_numeric($this->statut)) {
             $sql.= " statut = '".$this->statut."',";
         } else {
@@ -611,8 +611,8 @@ class Holiday extends CommonObject
 
         foreach($this->holiday as $infos_CP)
         {
-        	if ($infos_CP['statut'] == 4) continue;		// ignore not validated holidays
-        	if ($infos_CP['statut'] == 5) continue;		// ignore not validated holidays
+        	if ($infos_CP['statut'] == 4) continue;		// ignore not validated holidays
+        	if ($infos_CP['statut'] == 5) continue;		// ignore not validated holidays
 
         	// TODO Also use halfday for the check
             if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut'])
@@ -626,42 +626,42 @@ class Holiday extends CommonObject
     }
 
 
-    /**
-     *	Return clicable name (with picto eventually)
-     *
-     *	@param		int			$withpicto		0=_No picto, 1=Includes the picto in the linkn, 2=Picto only
-     *	@return		string						String with URL
-     */
-    function getNomUrl($withpicto=0)
-    {
-    	global $langs;
-
-    	$result='';
-
-    	$lien = '<a href="'.DOL_URL_ROOT.'/holiday/fiche.php?id='.$this->id.'">';
-    	$lienfin='</a>';
-
-    	$picto='holiday';
-
-    	$label=$langs->trans("Show").': '.$this->ref;
-
-    	if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
-    	if ($withpicto && $withpicto != 2) $result.=' ';
-    	if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
-    	return $result;
+    /**
+     *	Return clicable name (with picto eventually)
+     *
+     *	@param		int			$withpicto		0=_No picto, 1=Includes the picto in the linkn, 2=Picto only
+     *	@return		string						String with URL
+     */
+    function getNomUrl($withpicto=0)
+    {
+    	global $langs;
+
+    	$result='';
+
+    	$lien = '<a href="'.DOL_URL_ROOT.'/holiday/fiche.php?id='.$this->id.'">';
+    	$lienfin='</a>';
+
+    	$picto='holiday';
+
+    	$label=$langs->trans("Show").': '.$this->ref;
+
+    	if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
+    	if ($withpicto && $withpicto != 2) $result.=' ';
+    	if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
+    	return $result;
     }
 
 
-    /**
-     *	Returns the label status
-     *
-     *	@param      int		$mode       0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
-     *	@return     string      		Label
-     */
-    function getLibStatut($mode=0)
-    {
-    	return $this->LibStatut($this->statut, $mode, $this->date_debut);
-    }
+    /**
+     *	Returns the label status
+     *
+     *	@param      int		$mode       0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
+     *	@return     string      		Label
+     */
+    function getLibStatut($mode=0)
+    {
+    	return $this->LibStatut($this->statut, $mode, $this->date_debut);
+    }
 
 	/**
 	 *	Returns the label of a statut
@@ -683,26 +683,26 @@ class Holiday extends CommonObject
             if ($statut == 4) return $langs->trans('CancelCP');
             if ($statut == 5) return $langs->trans('RefuseCP');
 		}
-		if ($mode == 2)
-		{
+		if ($mode == 2)
+		{
 			$pictoapproved='statut6';
 			if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4';
-			if ($statut == 1) return img_picto($langs->trans('DraftCP'),'statut0').' '.$langs->trans('DraftCP');				// Draft
-			if ($statut == 2) return img_picto($langs->trans('ToValidateCP'),'statut1').' '.$langs->trans('ToValidateCP');		// Waiting approval
-			if ($statut == 3) return img_picto($langs->trans('ValidateCP'),$pictoapproved).' '.$langs->trans('ValidateCP');
-			if ($statut == 4) return img_picto($langs->trans('CancelCP'),'statut5').' '.$langs->trans('CancelCP');
-			if ($statut == 5) return img_picto($langs->trans('RefuseCP'),'statut5').' '.$langs->trans('RefuseCP');
-		}
-		if ($mode == 5)
+			if ($statut == 1) return img_picto($langs->trans('DraftCP'),'statut0').' '.$langs->trans('DraftCP');				// Draft
+			if ($statut == 2) return img_picto($langs->trans('ToValidateCP'),'statut1').' '.$langs->trans('ToValidateCP');		// Waiting approval
+			if ($statut == 3) return img_picto($langs->trans('ValidateCP'),$pictoapproved).' '.$langs->trans('ValidateCP');
+			if ($statut == 4) return img_picto($langs->trans('CancelCP'),'statut5').' '.$langs->trans('CancelCP');
+			if ($statut == 5) return img_picto($langs->trans('RefuseCP'),'statut5').' '.$langs->trans('RefuseCP');
+		}
+		if ($mode == 5)
 		{
-			$pictoapproved='statut6';
+			$pictoapproved='statut6';
 			if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4';
-			if ($statut == 1) return $langs->trans('DraftCP').' '.img_picto($langs->trans('DraftCP'),'statut0');				// Draft
-			if ($statut == 2) return $langs->trans('ToValidateCP').' '.img_picto($langs->trans('ToValidateCP'),'statut1');		// Waiting approval
-			if ($statut == 3) return $langs->trans('ValidateCP').' '.img_picto($langs->trans('ValidateCP'),$pictoapproved);
-			if ($statut == 4) return $langs->trans('CancelCP').' '.img_picto($langs->trans('CancelCP'),'statut5');
-			if ($statut == 5) return $langs->trans('RefuseCP').' '.img_picto($langs->trans('RefuseCP'),'statut5');
-		}
+			if ($statut == 1) return $langs->trans('DraftCP').' '.img_picto($langs->trans('DraftCP'),'statut0');				// Draft
+			if ($statut == 2) return $langs->trans('ToValidateCP').' '.img_picto($langs->trans('ToValidateCP'),'statut1');		// Waiting approval
+			if ($statut == 3) return $langs->trans('ValidateCP').' '.img_picto($langs->trans('ValidateCP'),$pictoapproved);
+			if ($statut == 4) return $langs->trans('CancelCP').' '.img_picto($langs->trans('CancelCP'),'statut5');
+			if ($statut == 5) return $langs->trans('RefuseCP').' '.img_picto($langs->trans('RefuseCP'),'statut5');
+		}
 
 		return $statut;
     }
@@ -897,7 +897,7 @@ class Holiday extends CommonObject
                     $new_solde = $now_holiday + $this->getConfCP('nbHolidayEveryMonth');
 
                     // On ajoute la modification dans le LOG
-                    $this->addLogCP($user->id,$users[$i]['rowid'], $langs->trans('Event').': '.$langs->trans('HolidaysMonthlyAssignment'),$new_solde);
+                    $this->addLogCP($user->id,$users[$i]['rowid'], $langs->trans('Event').': '.$langs->trans('HolidaysMonthlyUpdate'),$new_solde);
 
                     $i++;
                 }
diff --git a/htdocs/includes/nusoap/lib/nusoap.php b/htdocs/includes/nusoap/lib/nusoap.php
index 501e5669ce96739e63e82b9fd10b85da641530b3..403d74b13e9f2b3d650f4199de5ded399f900259 100644
--- a/htdocs/includes/nusoap/lib/nusoap.php
+++ b/htdocs/includes/nusoap/lib/nusoap.php
@@ -2217,7 +2217,7 @@ class soap_transport_http extends nusoap_base {
 		}
 		$this->use_curl = $use_curl;
 		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
-		$this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
+		if (isset($rev[1])) $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
 	}
 
 	/**
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 39acc88fd5cb3336d2d347a9a0f83e6217140610..f51cf7b6bd37c09e4f0d0d6734c07660ce94c9f2 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -374,7 +374,7 @@ if (! defined('NOLOGIN'))
 
         $usertotest		= (! empty($_COOKIE['login_dolibarr']) ? $_COOKIE['login_dolibarr'] : GETPOST("username","alpha",2));
         $passwordtotest	= (! empty($_COOKIE['password_dolibarr']) ? $_COOKIE['password_dolibarr'] : GETPOST('password'));
-        $entitytotest	= (GETPOST('entity','int') ? GETPOST('entity','int') : 1);
+        $entitytotest	= (GETPOST('entity','int') ? GETPOST('entity','int') : (!empty($conf->entity) ? $conf->entity : 1));
 
         // Validation of login/pass/entity
         // If ok, the variable login will be returned
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index 0dc12c468c8600eb0e52dab0730b66e53153291f..01e112652b867abb65ef119f44f1b5ff66f477e9 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -141,6 +141,10 @@ if (! defined('NOREQUIREDB'))
 	{
 		$conf->entity = DOLENTITY;
 	}
+	else if (!empty($_COOKIE['DOLENTITY']))							// For other application with MultiCompany module
+	{
+		$conf->entity = $_COOKIE['DOLENTITY'];
+	}
 	else if (! empty($conf->multicompany->force_entity) && is_int($conf->multicompany->force_entity)) // To force entity in login page
 	{
 		$conf->entity = $conf->multicompany->force_entity;