diff --git a/ChangeLog b/ChangeLog
index 9509d17c800f1ca220c263bb41690724b97c4c0f..811660a00b0911815c33678652e627d28ee94d51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,7 +31,8 @@ For developers:
 - Function plimit of databases drivers accept -1 as value (it means default value set
   into conf->liste_limit).
 - New: Add option dol_hide_topmenu and dol_hide_leftmenu onto login page.
- 
+- New: dol_syslog method accept a suffix to use different log files for log. 
+
 For translators:
 - Update language files.
 
diff --git a/build/debian/changelog b/build/debian/changelog
index 1b4daf52782104f2a646630e6ec1dd960f21f317..4380b0a6b50ce2171c8d27babe61fcc4a8c85bb6 100644
--- a/build/debian/changelog
+++ b/build/debian/changelog
@@ -4,6 +4,6 @@ dolibarr (3.4.0+nmu1) unstable; urgency=low
   * New upstream release.
     closes: bug#634783
     
- -- Dolibarr team <contact@dolibarr.org>  Mon, 14 Jan 2013 12:00:00 +0100     
+ -- Dolibarr team <contact@dolibarr.org>  Thu, 28 Feb 2013 12:00:00 +0100     
 
 # For a changelog file dedicated to end users, see /usr/share/doc/dolibarr/ChangeLog.gz 
\ No newline at end of file
diff --git a/build/launchpad/README b/build/launchpad/README
index 489712e91f89b765c76e91df003de8b1b093952c..2334b01f1d72ef34a314218ace7483b5c37e3838 100644
--- a/build/launchpad/README
+++ b/build/launchpad/README
@@ -96,11 +96,11 @@ https://launchpad.net/dolibarr/stable
 		lp:dolibarr
 		merge packaging lp:~yourlogin/+junk/debian-dev
     	For beta:
-	    # bzr-builder format 0.3 deb-version {debupstream}-0~{revno}
+	    # bzr-builder format 0.3 deb-version {debupstream}-1~{revno}
 		lp:dolibarr/beta
 		merge packaging lp:~yourlogin/+junk/debian-beta
     	For stable:
-	    # bzr-builder format 0.3 deb-version {debupstream}-0~{revno}
+	    # bzr-builder format 0.3 deb-version {debupstream}-2~{revno}
 		lp:dolibarr/stable
 		merge packaging lp:~yourlogin/+junk/debian-stable
 - Run command
diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php
index 50a24ea907a3383539457f02d38982318112ceda..d57b7ea093ea3db46cabb2f08f5e46a0ad2a3345 100644
--- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php
+++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php
@@ -286,10 +286,10 @@ abstract class ActionsAdherentCardCommon
         	}
 
             // Zip
-            $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip,'zipcode',array('town','selectcountry_id','departement_id'),6);
+            $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip,'zipcode',array('town','selectcountry_id','state_id'),6);
 
             // Town
-            $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town,'town',array('zipcode','selectcountry_id','departement_id'));
+            $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town,'town',array('zipcode','selectcountry_id','state_id'));
 
             if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id;
 
@@ -300,7 +300,7 @@ abstract class ActionsAdherentCardCommon
             if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
 
             // State
-            if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->fk_departement,$this->object->country_code);
+            if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id,$this->object->country_code);
             else $this->tpl['select_state'] = $countrynotdefined;
 
             // Physical or Moral
@@ -400,10 +400,8 @@ abstract class ActionsAdherentCardCommon
         $this->object->address				=	$_POST["address"];
         $this->object->zip					=	$_POST["zipcode"];
         $this->object->town					=	$_POST["town"];
-        $this->object->fk_pays				=	$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
-        $this->object->fk_departement		=	$_POST["departement_id"];
         $this->object->country_id			=	$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
-        $this->object->state_id        		=	$_POST["departement_id"];
+        $this->object->state_id        		=	$_POST["state_id"];
         $this->object->phone_perso			= 	$_POST["phone_perso"];
         $this->object->phone_mobile			= 	$_POST["phone_mobile"];
         $this->object->email				=	$_POST["email"];
@@ -423,7 +421,6 @@ abstract class ActionsAdherentCardCommon
             {
                 dol_print_error($this->db);
             }
-            $this->object->pays			=	$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
             $this->object->country_code	=	$obj->code;
             $this->object->country		=	$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
         }
diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php
index 84cb06e20932bf4d4cf1235600f358e6f9da3d3d..58ac61c13f28e7729410109b0875d4e5a96df30c 100644
--- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php
+++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php
@@ -76,7 +76,7 @@ dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']
 
 <tr>
 	<td><?php echo $langs->trans('State'); ?></td>
-	<td colspan="3"><?php echo $this->control->tpl['departement']; ?></td>
+	<td colspan="3"><?php echo $this->control->tpl['state']; ?></td>
 </tr>
 
 <tr>
diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php
index 13fc7f2488e65fe2642a7d04c7c8cc69f018810b..c45f1aed9931495a0ea08634d2df5bb01ac6e235 100755
--- a/htdocs/adherents/cartes/carte.php
+++ b/htdocs/adherents/cartes/carte.php
@@ -62,11 +62,11 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
 
     // requete en prenant que les adherents a jour de cotisation
     $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
-    $sql.= " d.address, d.zip, d.town, d.naiss, d.email, d.photo,";
+    $sql.= " d.address, d.zip, d.town, d.country, d.naiss, d.email, d.photo,";
     $sql.= " t.libelle as type,";
     $sql.= " p.code as country_code, p.libelle as country";
     $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
-    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid";
+    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.country = p.rowid";
     $sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
     if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid;
     if ($foruserlogin) $sql.=" AND d.login='".$db->escape($foruserlogin)."'";
@@ -111,7 +111,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
             // For backward compatibility
             '%SOCIETE%'=>$objp->company,
             '%ZIP%'=>$objp->zip,
-            '%PAYS%'=>$objp->country,
+            '%COUNTRY%'=>$objp->country,
             '%ANNEE%'=>$year,
             '%SERVEUR%'=>"http://".$_SERVER["SERVER_NAME"]."/"	// deprecated
             );
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index c3be6de5ed8d2c464e0f1129b0f862b8bfeb11f4..8cced5bd052ef10eb7d5d010aec9952374150722 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -56,14 +56,10 @@ class Adherent extends CommonObject
     var $state_id;              // Id of department
     var $state_code;            // Code of department
     var $state;                 // Label of department
-    var $fk_departement;		// deprecated
-    var $departement_code;		// deprecated
-    var $departement;			// deprecated
 
     var $country_id;
     var $country_code;
     var $country;
-    var $pays;                 // deprecated
 
     var $email;
     var $phone;
@@ -225,7 +221,7 @@ class Adherent extends CommonObject
 				'%INFOS%'=>$msgishtml?dol_htmlentitiesbr($infos):$infos,
 				'%SOCIETE%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
 				'%ZIP%'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
-				'%PAYS%'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
+				'%COUNTRY%'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
 		);
 
 		complete_substitutions_array($substitutionarray, $langs);
@@ -396,8 +392,8 @@ class Adherent extends CommonObject
 		$this->address=($this->address?$this->address:$this->address);
 		$this->zip=($this->zip?$this->zip:$this->zip);
 		$this->town=($this->town?$this->town:$this->town);
-		$this->country_id=($this->country_id > 0?$this->country_id:$this->fk_pays);
-		$this->state_id=($this->state_id > 0?$this->state_id:$this->fk_departement);
+		$this->country_id=($this->country_id > 0?$this->country_id:$this->country_id);
+		$this->state_id=($this->state_id > 0?$this->state_id:$this->state_id);
 		if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords(trim($this->lastname));
         if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords(trim($this->firstname));
 
@@ -421,8 +417,8 @@ class Adherent extends CommonObject
         $sql.= ", address=" .($this->address?"'".$this->db->escape($this->address)."'":"null");
         $sql.= ", zip="      .($this->zip?"'".$this->db->escape($this->zip)."'":"null");
         $sql.= ", town="   .($this->town?"'".$this->db->escape($this->town)."'":"null");
-        $sql.= ", pays="          .($this->country_id>0?"'".$this->country_id."'":"null");
-        $sql.= ", fk_departement=".($this->state_id>0?"'".$this->state_id."'":"null");
+        $sql.= ", country=".($this->country_id>0?"'".$this->country_id."'":"null");
+        $sql.= ", state_id=".($this->state_id>0?"'".$this->state_id."'":"null");
         $sql.= ", email='".$this->email."'";
         $sql.= ", phone="   .($this->phone?"'".$this->db->escape($this->phone)."'":"null");
         $sql.= ", phone_perso="  .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null");
@@ -1014,15 +1010,15 @@ class Adherent extends CommonObject
         $sql.= " d.datefin as datefin,";
         $sql.= " d.naiss as datenaiss,";
         $sql.= " d.datevalid as datev,";
-        $sql.= " d.pays,";
-        $sql.= " d.fk_departement,";
+        $sql.= " d.country,";
+        $sql.= " d.state_id,";
         $sql.= " p.rowid as country_id, p.code as country_code, p.libelle as country,";
         $sql.= " dep.nom as state, dep.code_departement as state_code,";
         $sql.= " t.libelle as type, t.cotisation as cotisation,";
         $sql.= " u.rowid as user_id, u.login as user_login";
         $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
-        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid";
-        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.fk_departement = dep.rowid";
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.country = p.rowid";
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid";
         $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member";
         $sql.= " WHERE d.fk_adherent_type = t.rowid";
         if ($rowid) $sql.= " AND d.rowid=".$rowid;
@@ -1054,12 +1050,9 @@ class Adherent extends CommonObject
                 $this->zip				= $obj->zip;
                 $this->town				= $obj->town;
 
-                $this->state_id			= $obj->fk_departement;
-                $this->state_code		= $obj->fk_departement?$obj->state_code:'';
-                $this->state			= $obj->fk_departement?$obj->state:'';
-                $this->fk_departement	= $obj->fk_departement;                        // deprecated
-                $this->departement_code	= $obj->fk_departement?$obj->state_code:'';    // deprecated
-                $this->departement		= $obj->fk_departement?$obj->state:'';         // deprecated
+                $this->state_id			= $obj->state_id;
+                $this->state_code		= $obj->state_id?$obj->state_code:'';
+                $this->state			= $obj->state_id?$obj->state:'';
 
                 $this->country_id		= $obj->country_id;
                 $this->country_code		= $obj->country_code;
@@ -1067,7 +1060,6 @@ class Adherent extends CommonObject
                 	$this->country = $langs->transnoentitiesnoconv("Country".$obj->country_code);
                 else
                 	$this->country=$obj->country;
-                $this->pays				= $this->country;        // deprecated
 
                 $this->phone			= $obj->phone;
                 $this->phone_perso		= $obj->phone_perso;
diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index 59b2a6e24026896d68f6ebbf7e3b8023e2e0de72..0159f5d93d59509fd3e5fed5dbf9ec0e09fc0e97 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -260,9 +260,8 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
 		$object->address     = trim($_POST["address"]);
 		$object->zip         = trim($_POST["zipcode"]);
 		$object->town        = trim($_POST["town"]);
-		$object->state_id    = $_POST["departement_id"];
+		$object->state_id    = $_POST["state_id"];
 		$object->country_id  = $_POST["country_id"];
-		$object->fk_departement = $_POST["departement_id"];   // deprecated
 
 		$object->phone       = trim($_POST["phone"]);
 		$object->phone_perso = trim($_POST["phone_perso"]);
@@ -410,7 +409,7 @@ if ($action == 'add' && $user->rights->adherent->creer)
 	$address=$_POST["address"];
 	$zip=$_POST["zipcode"];
 	$town=$_POST["town"];
-	$state_id=$_POST["departement_id"];
+	$state_id=$_POST["state_id"];
 	$country_id=$_POST["country_id"];
 
 	$phone=$_POST["phone"];
@@ -435,7 +434,6 @@ if ($action == 'add' && $user->rights->adherent->creer)
 	$object->address     = $address;
 	$object->zip         = $zip;
 	$object->town        = $town;
-	$object->fk_departement = $state_id;
 	$object->state_id    = $state_id;
 	$object->country_id  = $country_id;
 	$object->phone       = $phone;
@@ -721,14 +719,13 @@ else
 		/*                                                                            */
 		/* ************************************************************************** */
 		$object->canvas=$canvas;
-		$object->fk_departement = GETPOST('departement_id', 'int');
+		$object->state_id = GETPOST('departement_id', 'int');
 
 		// We set country_id, country_code and country for the selected country
 		$object->country_id=GETPOST('country_id','int')?GETPOST('country_id','int'):$mysoc->country_id;
 		if ($object->country_id)
 		{
 			$tmparray=getCountry($object->country_id,'all');
-			$object->pays=$tmparray['code'];
 			$object->country_code=$tmparray['code'];
 			$object->country=$tmparray['label'];
 		}
@@ -834,9 +831,9 @@ else
 
 		// Zip / Town
 		print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
-		print $formcompany->select_ziptown((GETPOST('zipcode','alpha')?GETPOST('zipcode','alpha'):$object->zip),'zipcode',array('town','selectcountry_id','departement_id'),6);
+		print $formcompany->select_ziptown((GETPOST('zipcode','alpha')?GETPOST('zipcode','alpha'):$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
 		print ' ';
-		print $formcompany->select_ziptown((GETPOST('town','alpha')?GETPOST('town','alpha'):$object->town),'town',array('zipcode','selectcountry_id','departement_id'));
+		print $formcompany->select_ziptown((GETPOST('town','alpha')?GETPOST('town','alpha'):$object->town),'town',array('zipcode','selectcountry_id','state_id'));
 		print '</td></tr>';
 
 		// Country
@@ -852,7 +849,7 @@ else
 			print '<tr><td>'.$langs->trans('State').'</td><td>';
 			if ($object->country_id)
 			{
-				print $formcompany->select_state(GETPOST('departement_id','int')?GETPOST('departement_id','int'):$object->fk_departement,$object->country_code);
+				print $formcompany->select_state(GETPOST('state_id','int')?GETPOST('state_id','int'):$object->state_id,$object->country_code);
 			}
 			else
 			{
@@ -944,9 +941,9 @@ else
 		$adht->fetch($object->typeid);
 
 		// We set country_id, and country_code, country of the chosen country
-		if (isset($_POST["pays"]) || $object->country_id)
+		if (isset($_POST["country"]) || $object->country_id)
 		{
-			$sql = "SELECT rowid, code, libelle as label from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays"])?$_POST["pays"]:$object->country_id);
+			$sql = "SELECT rowid, code, libelle as label from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["country"])?$_POST["country"]:$object->country_id);
 			$resql=$db->query($sql);
 			if ($resql)
 			{
@@ -956,7 +953,6 @@ else
 			{
 				dol_print_error($db);
 			}
-			$object->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label;
 			$object->country_id=$obj->rowid;
 			$object->country_code=$obj->code;
 			$object->country=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label;
@@ -1085,9 +1081,9 @@ else
 
 		// Zip / Town
 		print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
-		print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','departement_id'),6);
+		print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
 		print ' ';
-		print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','departement_id'));
+		print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id'));
 		print '</td></tr>';
 
 		// Country
@@ -1101,7 +1097,7 @@ else
 		if (empty($conf->global->MEMBER_DISABLE_STATE))
 		{
 			print '<tr><td>'.$langs->trans('State').'</td><td>';
-			print $formcompany->select_state($object->fk_departement,isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id);
+			print $formcompany->select_state($object->state_id,isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id);
 			print '</td></tr>';
 		}
 
@@ -1434,7 +1430,7 @@ else
 		print '</td></tr>';
 
 		// State
-		print '<tr><td>'.$langs->trans('State').'</td><td class="valeur">'.$object->departement.'</td>';
+		print '<tr><td>'.$langs->trans('State').'</td><td class="valeur">'.$object->state.'</td>';
 
 		// Tel pro.
 		print '<tr><td>'.$langs->trans("PhonePro").'</td><td class="valeur">'.dol_print_phone($object->phone,$object->country_code,0,$object->fk_soc,1).'</td></tr>';
diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php
index fcb421e14fed62c7c90a404efd6209bfb9a2d917..2595136a33ed5f1dd166e574145fb4ea6d19b879 100755
--- a/htdocs/adherents/stats/geo.php
+++ b/htdocs/adherents/stats/geo.php
@@ -71,7 +71,7 @@ if ($mode)
 
         $data = array();
         $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.libelle as label";
-        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_pays as c on d.pays = c.rowid";
+        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_pays as c on d.country = c.rowid";
         $sql.=" WHERE d.entity IN (".getEntity().")";
         $sql.=" AND d.statut = 1";
         $sql.=" GROUP BY c.libelle, c.code";
@@ -85,9 +85,9 @@ if ($mode)
 
         $data = array();
         $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, c.nom as label2";
-        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.fk_departement = c.rowid";
+        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
         $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.pays = p.rowid";
+        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.country = p.rowid";
         $sql.=" WHERE d.entity IN (".getEntity().")";
         $sql.=" AND d.statut = 1";
         $sql.=" GROUP BY p.libelle, p.code, c.nom";
@@ -102,7 +102,7 @@ if ($mode)
         $data = array();
         $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, d.town as label2";
         $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
-        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.pays = p.rowid";
+        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.country = p.rowid";
         $sql.=" WHERE d.entity IN (".getEntity().")";
         $sql.=" AND d.statut = 1";
         $sql.=" GROUP BY p.libelle, p.code, d.town";
diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index 271318258eeb6d5b3842002b723891e43b94a768..55ad5902e1346a72fec00326187543786fe841f9 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -61,14 +61,14 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
         $mysoc->country_label=$tmparray['label'];
 
         $s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
-        dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS", $s,'chaine',0,'',$conf->entity);
+        dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s,'chaine',0,'',$conf->entity);
     }
 
     dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"],'chaine',0,'',$conf->entity);
     dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS",$_POST["address"],'chaine',0,'',$conf->entity);
     dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN",$_POST["town"],'chaine',0,'',$conf->entity);
     dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP",$_POST["zipcode"],'chaine',0,'',$conf->entity);
-    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_DEPARTEMENT",$_POST["departement_id"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE",$_POST["state_id"],'chaine',0,'',$conf->entity);
     dolibarr_set_const($db, "MAIN_MONNAIE",$_POST["currency"],'chaine',0,'',$conf->entity);
     dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL",$_POST["tel"],'chaine',0,'',$conf->entity);
     dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX",$_POST["fax"],'chaine',0,'',$conf->entity);
@@ -289,14 +289,14 @@ if ($action == 'edit' || $action == 'updateedit')
     // Country
     $var=!$var;
     print '<tr '.$bc[$var].'><td class="fieldrequired">'.$langs->trans("Country").'</td><td>';
-    //if (empty($pays_selected)) $pays_selected=substr($langs->defaultlang,-2);    // Par defaut, pays de la localisation
+    //if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2);    // Par defaut, pays de la localisation
     print $form->select_country($mysoc->country_id,'country_id');
     if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
     print '</td></tr>'."\n";
 
     $var=!$var;
     print '<tr '.$bc[$var].'><td>'.$langs->trans("State").'</td><td>';
-    $formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT,$mysoc->country_code,'departement_id');
+    $formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_STATE,$mysoc->country_code,'state_id');
     print '</td></tr>'."\n";
 
     $var=!$var;
@@ -366,7 +366,7 @@ if ($action == 'edit' || $action == 'updateedit')
 
     print '<br>';
 
-    // Identifiants de la societe (propre au pays)
+    // Identifiants de la societe (country-specific)
     print '<table class="noborder" width="100%">';
     print '<tr class="liste_titre"><td>'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
     $var=true;
@@ -667,7 +667,7 @@ else
 
     $var=!$var;
     print '<tr '.$bc[$var].'><td>'.$langs->trans("State").'</td><td>';
-    if (! empty($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT)) print getState($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT);
+    if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) print getState($conf->global->MAIN_INFO_SOCIETE_STATE);
     else print '&nbsp;';
     print '</td></tr>';
 
@@ -731,7 +731,7 @@ else
     print '<br>';
 
 
-    // Identifiants de la societe (propre au pays)
+    // Identifiants de la societe (country-specific)
     print '<form name="formsoc" method="post">';
     print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
     print '<table class="noborder" width="100%">';
@@ -860,7 +860,7 @@ else
             }
             else
             {
-                $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$soc->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
+                $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$soc->id_country).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
             }
         }
         print $s;
diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php
index 77534fd0d768a015d34092ce323906eeddc53eb9..a2b07ca2d11855b92d642698f87aee87ba351c09 100644
--- a/htdocs/admin/const.php
+++ b/htdocs/admin/const.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2003		Rodolphe Quiedeville	<rodolphe@quiedeville.org>
- * Copyright (C) 2004-2011	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2013	Laurent Destailleur		<eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012	Regis Houssin			<regis.houssin@capnetworks.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -157,7 +157,7 @@ jQuery(document).ready(function() {
 		jQuery("#delconst").show();
 		jQuery("#action").val('delete');
 	});
-	jQuery(".inputforupdate").keypress(function() {
+	jQuery(".inputforupdate").keyup(function() {	// keypress does not support back
 		var field_id = jQuery(this).attr("id");
 		var row_num = field_id.split("_");
 		jQuery("#updateconst").show();
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 4bd5a1029c801d7dee9407343b60dea63db69347..3a8605f232b35e1766d10900a50bc2f74b66b175 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -128,20 +128,20 @@ $tablib[24]= "DictionnaryAccountancysystem";
 
 // Requete pour extraction des donnees des dictionnaires
 $tabsql=array();
-$tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, p.code as country_code, p.libelle as pays, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_pays as p WHERE f.fk_pays=p.rowid";
-$tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, p.code as country_code, p.libelle as pays, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid and r.active=1 and p.active=1";
-$tabsql[3] = "SELECT r.rowid as rowid, code_region as code, nom as libelle, r.fk_pays as country_id, p.code as country_code, p.libelle as pays, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE r.fk_pays=p.rowid and p.active=1";
+$tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, p.code as country_code, p.libelle as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_pays as p WHERE f.fk_pays=p.rowid";
+$tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, p.code as country_code, p.libelle as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid and r.active=1 and p.active=1";
+$tabsql[3] = "SELECT r.rowid as rowid, code_region as code, nom as libelle, r.fk_pays as country_id, p.code as country_code, p.libelle as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE r.fk_pays=p.rowid and p.active=1";
 $tabsql[4] = "SELECT rowid   as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_pays";
 $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.civilite AS libelle, c.active FROM ".MAIN_DB_PREFIX."c_civilite AS c";
 $tabsql[6] = "SELECT a.id    as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
-$tabsql[7] = "SELECT a.id    as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, p.code as country_code, p.libelle as pays, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_pays as p WHERE a.fk_pays=p.rowid and p.active=1";
+$tabsql[7] = "SELECT a.id    as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, p.code as country_code, p.libelle as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_pays as p WHERE a.fk_pays=p.rowid and p.active=1";
 $tabsql[8] = "SELECT id      as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent";
 $tabsql[9] = "SELECT code_iso as code, label, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies";
-$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, p.libelle as pays, p.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid";
+$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, p.libelle as country, p.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid";
 $tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
 $tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c';
 $tabsql[13]= "SELECT id      as rowid, code, c.libelle, type, active FROM ".MAIN_DB_PREFIX."c_paiement AS c";
-$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, p.code as country_code, p.libelle as pays, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_pays as p WHERE e.fk_pays=p.rowid and p.active=1";
+$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, p.code as country_code, p.libelle as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_pays as p WHERE e.fk_pays=p.rowid and p.active=1";
 $tabsql[15]= "SELECT rowid   as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format";
 $tabsql[16]= "SELECT code, label as libelle, active FROM ".MAIN_DB_PREFIX."c_prospectlevel";
 $tabsql[17]= "SELECT id      as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_fees";
@@ -155,20 +155,20 @@ $tabsql[24]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, p.c
 
 // Critere de tri du dictionnaire
 $tabsqlsort=array();
-$tabsqlsort[1] ="pays ASC, code ASC";
-$tabsqlsort[2] ="pays ASC, code ASC";
-$tabsqlsort[3] ="pays ASC, code ASC";
+$tabsqlsort[1] ="country ASC, code ASC";
+$tabsqlsort[2] ="country ASC, code ASC";
+$tabsqlsort[3] ="country ASC, code ASC";
 $tabsqlsort[4] ="code ASC";
 $tabsqlsort[5] ="libelle ASC";
 $tabsqlsort[6] ="a.type ASC, a.module ASC, a.position ASC, a.code ASC";
-$tabsqlsort[7] ="pays ASC, code ASC, a.libelle ASC";
+$tabsqlsort[7] ="country ASC, code ASC, a.libelle ASC";
 $tabsqlsort[8] ="libelle ASC";
 $tabsqlsort[9] ="label ASC";
-$tabsqlsort[10]="pays ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC";
+$tabsqlsort[10]="country ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC";
 $tabsqlsort[11]="element ASC, source ASC, code ASC";
 $tabsqlsort[12]="sortorder ASC, code ASC";
 $tabsqlsort[13]="code ASC";
-$tabsqlsort[14]="pays ASC, e.organization ASC, code ASC";
+$tabsqlsort[14]="country ASC, e.organization ASC, code ASC";
 $tabsqlsort[15]="rowid ASC";
 $tabsqlsort[16]="sortorder ASC";
 $tabsqlsort[17]="code ASC";
@@ -182,20 +182,20 @@ $tabsqlsort[24]="pcg_version ASC";
 
 // Nom des champs en resultat de select pour affichage du dictionnaire
 $tabfield=array();
-$tabfield[1] = "code,libelle,pays";
-$tabfield[2] = "code,libelle,region_id,region,pays";   // "code,libelle,region,country_code-pays"
-$tabfield[3] = "code,libelle,country_id,pays";
+$tabfield[1] = "code,libelle,country";
+$tabfield[2] = "code,libelle,region_id,region,country";   // "code,libelle,region,country_code-country"
+$tabfield[3] = "code,libelle,country_id,country";
 $tabfield[4] = "code,libelle";
 $tabfield[5] = "code,libelle";
 $tabfield[6] = "code,libelle,type,position";
-$tabfield[7] = "code,libelle,country_id,pays,accountancy_code,deductible";
+$tabfield[7] = "code,libelle,country_id,country,accountancy_code,deductible";
 $tabfield[8] = "code,libelle";
 $tabfield[9] = "code,label,unicode";
-$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note";
+$tabfield[10]= "country_id,country,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note";
 $tabfield[11]= "element,source,code,libelle";
 $tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
 $tabfield[13]= "code,libelle,type";
-$tabfield[14]= "code,libelle,price,organization,country_id,pays";
+$tabfield[14]= "code,libelle,price,organization,country_id,country";
 $tabfield[15]= "code,libelle,width,height,unit";
 $tabfield[16]= "code,libelle";
 $tabfield[17]= "code,libelle";
@@ -205,24 +205,24 @@ $tabfield[20]= "code,libelle";
 $tabfield[21]= "code,label";
 $tabfield[22]= "code,label";
 $tabfield[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label";
-$tabfield[24]= "pcg_version,country_id,pays,label";
+$tabfield[24]= "pcg_version,country_id,country,label";
 
 // Nom des champs d'edition pour modification d'un enregistrement
 $tabfieldvalue=array();
-$tabfieldvalue[1] = "code,libelle,pays";
+$tabfieldvalue[1] = "code,libelle,country";
 $tabfieldvalue[2] = "code,libelle,region";   // "code,libelle,region"
-$tabfieldvalue[3] = "code,libelle,pays";
+$tabfieldvalue[3] = "code,libelle,country";
 $tabfieldvalue[4] = "code,libelle";
 $tabfieldvalue[5] = "code,libelle";
 $tabfieldvalue[6] = "code,libelle,type,position";
-$tabfieldvalue[7] = "code,libelle,pays,accountancy_code,deductible";
+$tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible";
 $tabfieldvalue[8] = "code,libelle";
 $tabfieldvalue[9] = "code,label,unicode";
-$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note";
+$tabfieldvalue[10]= "country,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note";
 $tabfieldvalue[11]= "element,source,code,libelle";
 $tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
 $tabfieldvalue[13]= "code,libelle,type";
-$tabfieldvalue[14]= "code,libelle,price,organization,pays";
+$tabfieldvalue[14]= "code,libelle,price,organization,country";
 $tabfieldvalue[15]= "code,libelle,width,height,unit";
 $tabfieldvalue[16]= "code,libelle";
 $tabfieldvalue[17]= "code,libelle";
@@ -232,7 +232,7 @@ $tabfieldvalue[20]= "code,libelle";
 $tabfieldvalue[21]= "code,label";
 $tabfieldvalue[22]= "code,label";
 $tabfieldvalue[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label";
-$tabfieldvalue[24]= "pcg_version,pays,label";
+$tabfieldvalue[24]= "pcg_version,country,label";
 
 // Nom des champs dans la table pour insertion d'un enregistrement
 $tabfieldinsert=array();
@@ -390,9 +390,9 @@ if (GETPOST("id") == 10)
 			"3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)",	//$langs->trans("%ageOnProductsWithoutVAT"),
 			"4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)",	//$langs->trans("%ageOnProductsBeforeVAT"),
 			"5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)",	//$langs->trans("%ageOnServiceWithoutVAT"),
-			"6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)",	//$langs->trans("%ageOnServiceBeforeVAT"),
-			"7" => $langs->trans("Yes").' ('.$langs->trans("Type")." 7)"	//$langs->trans("AmountOnOrder")	// We will enable this later. For the moment, work only of invoice localtype
+			"6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)"	//$langs->trans("%ageOnServiceBeforeVAT"),
 	);
+	if (! empty($conf->global->MAIN_USE_LOCALTAX_TYPE_7)) $localtax_typeList["7"]= $langs->trans("Yes").' ('.$langs->trans("Type")." 7)";	//$langs->trans("AmountOnOrder")	// We will enable this later. For the moment, work only of invoice localtype
 }
 $msg='';
 
@@ -409,7 +409,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
     $ok=1;
     foreach ($listfield as $f => $value)
     {
-        if ($value == 'pays' && in_array('region_id',$listfield)) continue;		// For region page, we do not require the country input
+        if ($value == 'country' && in_array('region_id',$listfield)) continue;		// For region page, we do not require the country input
         if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue;
         if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue;
         if ((! isset($_POST[$value]) || $_POST[$value]=='')
@@ -443,7 +443,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
         $ok=0;
         $msg.="Code can't contains value 0<br>";
     }
-    if (isset($_POST["pays"]) && $_POST["pays"]=='0') {
+    if (isset($_POST["country"]) && $_POST["country"]=='0') {
         $ok=0;
         $msg.=$langs->trans("ErrorFieldRequired",$langs->trans("Country")).'<br>';
     }
@@ -673,8 +673,8 @@ if ($id)
 
     if ($sortfield)
     {
-        // If sort order is "pays", we use country_code instead
-    	if ($sortfield == 'pays') $sortfield='country_code';
+        // If sort order is "country", we use country_code instead
+    	if ($sortfield == 'country') $sortfield='country_code';
         $sql.= " ORDER BY ".$sortfield;
         if ($sortorder)
         {
@@ -728,7 +728,7 @@ if ($id)
             if ($fieldlist[$field]=='code')            { $valuetoshow=$langs->trans("Code"); }
             if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; }
             if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
-            if ($fieldlist[$field]=='pays')            {
+            if ($fieldlist[$field]=='country')         {
                 if (in_array('region_id',$fieldlist)) { print '<td>&nbsp;</td>'; continue; }		// For region page, we do not show the country input
                 $valuetoshow=$langs->trans("Country");
             }
@@ -845,7 +845,7 @@ if ($id)
                 if ($fieldlist[$field]=='code')            { $valuetoshow=$langs->trans("Code"); }
                 if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; }
                 if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
-                if ($fieldlist[$field]=='pays')            { $valuetoshow=$langs->trans("Country"); }
+                if ($fieldlist[$field]=='country')         { $valuetoshow=$langs->trans("Country"); }
                 if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
                 if ($fieldlist[$field]=='nbjour')          { $valuetoshow=$langs->trans("NbOfDays"); }
                 if ($fieldlist[$field]=='fdm')             { $valuetoshow=$langs->trans("AtEndOfMonth"); }
@@ -922,7 +922,7 @@ if ($id)
                             else if ($valuetoshow=='all') {
                                 $valuetoshow=$langs->trans('All');
                             }
-                            else if ($fieldlist[$field]=='pays') {
+                            else if ($fieldlist[$field]=='country') {
                                 if (empty($obj->country_code))
                                 {
                                     $valuetoshow='-';
@@ -930,7 +930,7 @@ if ($id)
                                 else
                                 {
                                     $key=$langs->trans("Country".strtoupper($obj->country_code));
-                                    $valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->pays);
+                                    $valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country);
                                 }
                             }
                             else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm' || $fieldlist[$field] == 'deductible') {
@@ -1193,10 +1193,10 @@ function fieldList($fieldlist,$obj='',$tabname='')
 
 	foreach ($fieldlist as $field => $value)
 	{
-		if ($fieldlist[$field] == 'pays') {
+		if ($fieldlist[$field] == 'country') {
 			if (in_array('region_id',$fieldlist)) { print '<td>&nbsp;</td>'; continue; }	// For region page, we do not show the country input
 			print '<td>';
-			print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->pays)?$obj->pays:'')), 'pays', '', 28);
+			print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), 'country', '', 28);
 			print '</td>';
 		}
 		elseif ($fieldlist[$field] == 'country_id') {
diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php
index a559b4f580ecb564785fc7fcfe21ef84c3a9f582..457a32ec4ce02acce0889e2dacb3192a075d3ed5 100644
--- a/htdocs/admin/index.php
+++ b/htdocs/admin/index.php
@@ -55,7 +55,7 @@ print $langs->trans("SetupDescription2")."<br><br>";
 
 print '<br>';
 //print '<hr style="color: #DDDDDD;">';
-if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_PAYS)) $setupcompanynotcomplete=1;
+if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1;
 print img_picto('','puce').' '.$langs->trans("SetupDescription3",DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'));
 if (! empty($setupcompanynotcomplete))
 {
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 464cf608e8c9ff803f99ff4b4697f458053e54a7..fa4aa52bfc8a9f0652af3c598f65cb2d19473769 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -140,6 +140,9 @@ if (($action == 'send' || $action == 'sendhtml') && GETPOST('cancel'))
 if (($action == 'send' || $action == 'sendhtml') && ! GETPOST('addfile') && ! GETPOST('addfilehtml') && ! GETPOST('removedfile') && ! GETPOST('cancel'))
 {
 	$error=0;
+	
+	
+	
 
 	$email_from='';
 	if (! empty($_POST["fromname"])) $email_from=$_POST["fromname"].' ';
@@ -152,7 +155,12 @@ if (($action == 'send' || $action == 'sendhtml') && ! GETPOST('addfile') && ! GE
 	$subject    = $_POST['subject'];
 	$body       = $_POST['message'];
 	$deliveryreceipt= $_POST["deliveryreceipt"];
-
+	
+	//Check if we have to decode HTML
+	if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401))) {
+		$body=dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401);
+	}
+	
 	// Create form object
 	include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
 	$formmail = new FormMail($db);
diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php
index 9da1d910c0f8d4fce86533dfec1a481a067cc396..b1532f5d7d7042643d64576a1643d59cf220d000 100644
--- a/htdocs/categories/categorie.php
+++ b/htdocs/categories/categorie.php
@@ -247,12 +247,12 @@ if ($socid)
 	print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->town."</td></tr>";
 
 	// Country
-	if ($soc->pays)
+	if ($soc->country)
 	{
 		print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
 		$img=picto_from_langcode($soc->country_code);
 		print ($img?$img.' ':'');
-		print $soc->pays;
+		print $soc->country;
 		print '</td></tr>';
 	}
 
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index cf3be8898d73c305d72f2403eef00677f6b5c7af..802ebc5951423c4fe92ca0e2399413ce27c8a27e 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -457,7 +457,8 @@ class ActionComm extends CommonObject
 
         //print 'eeea'.$this->datep.'-'.(strval($this->datep) != '').'-'.$this->db->idate($this->datep);
         $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm ";
-        $sql.= " SET percent='".$this->percentage."'";
+        $sql.= " SET percent = '".$this->percentage."'";
+        if ($this->fk_action > 0) $sql.= ", fk_action = '".$this->fk_action."'";
         $sql.= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'":"null");
         $sql.= ", datep = ".(strval($this->datep)!='' ? "'".$this->db->idate($this->datep)."'" : 'null');
         $sql.= ", datep2 = ".(strval($this->datef)!='' ? "'".$this->db->idate($this->datef)."'" : 'null');
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index f5fdb2cfabb82522ffd110eb33e3c0040d9e11dc..c7ac95111b1cd43d049f848f8524d30604228c63 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -309,6 +309,7 @@ if ($action == 'update')
 		$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
 		$datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
 
+		$actioncomm->fk_action   = dol_getIdFromCode($db, $_POST["actioncode"], 'c_actioncomm');
 		$actioncomm->label       = $_POST["label"];
 		$actioncomm->datep       = $datep;
 		$actioncomm->datef       = $datef;
@@ -467,16 +468,7 @@ if ($action == 'create')
 	if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
 	{
 		print '<tr><td width="30%"><span class="fieldrequired">'.$langs->trans("Type").'</span></b></td><td>';
-		if (GETPOST("actioncode"))
-		{
-			print '<input type="hidden" name="actioncode" value="'.GETPOST("actioncode").'">'."\n";
-			$cactioncomm->fetch(GETPOST("actioncode"));
-			print $cactioncomm->getNomUrl();
-		}
-		else
-		{
-			$htmlactions->select_type_actions($actioncomm->type_code, "actioncode","systemauto");
-		}
+		$htmlactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$actioncomm->type_code, "actioncode","systemauto");
 		print '</td></tr>';
 	}
 	else print '<input type="hidden" name="actioncode" value="AC_OTH">';
@@ -739,7 +731,9 @@ if ($id > 0)
 		// Type
 		if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
 		{
-			print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td colspan="3">'.$act->type.'</td></tr>';
+			print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td colspan="3">';
+			$htmlactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$act->type_code, "actioncode","systemauto");
+			print '</td></tr>';
 		}
 
 		// Title
diff --git a/htdocs/comm/address.php b/htdocs/comm/address.php
index 0c09c953d9df6363e079a03827cf26074f9bd1e8..f996bb1cd93793354f8cb52276bbd99d477d5252 100644
--- a/htdocs/comm/address.php
+++ b/htdocs/comm/address.php
@@ -205,7 +205,7 @@ if ($action == 'create')
             $object->note		=	$_POST["note"];
         }
 
-        // On positionne country_id, country_code et libelle du pays choisi
+        // On positionne country_id, country_code and label of the chosen country
         $object->country_id = (GETPOST('country_id','int') ? GETPOST('country_id','int') : $mysoc->country_id);
         if ($object->country_id)
         {
@@ -333,7 +333,7 @@ elseif ($action == 'edit')
             $object->fax		=	$_POST["fax"];
             $object->note		=	$_POST["note"];
 
-            // On positionne country_id, country_code et libelle du pays choisi
+            // On positionne country_id, country_code and label of the chosen country
             if ($object->country_id)
             {
 	        	$tmparray=getCountry($object->country_id,'all');
diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php
index ecae8acadac330458285c2aae786e67f16ac9aca..896d29f05dd937bb426336f6766671dc36c25ff1 100644
--- a/htdocs/comm/mailing/class/mailing.class.php
+++ b/htdocs/comm/mailing/class/mailing.class.php
@@ -179,6 +179,8 @@ class Mailing extends CommonObject
 	 */
 	function fetch($rowid)
 	{
+		global $conf;
+		
 		$sql = "SELECT m.rowid, m.titre, m.sujet, m.body, m.bgcolor, m.bgimage";
 		$sql.= ", m.email_from, m.email_replyto, m.email_errorsto";
 		$sql.= ", m.statut, m.nbemail";
@@ -203,8 +205,14 @@ class Mailing extends CommonObject
 				$this->statut			= $obj->statut;
 				$this->nbemail			= $obj->nbemail;
 				$this->titre			= $obj->titre;
-				$this->sujet			= $obj->sujet;
-				$this->body				= $obj->body;
+				
+				$this->sujet			= $obj->sujet;				
+				if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401))) {
+					$this->body				= dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401);
+				}else {
+					$this->body				= $obj->body;
+				}
+				
 				$this->bgcolor			= $obj->bgcolor;
 				$this->bgimage			= $obj->bgimage;
 
diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php
index 727932c0f40f7aff738e3529c7ad47e34f9888e9..6684b2d0f0de56a441f278a8db5075d505c55430 100755
--- a/htdocs/comm/prospect/list.php
+++ b/htdocs/comm/prospect/list.php
@@ -41,8 +41,8 @@ $socname            = GETPOST("socname",'alpha');
 $stcomm             = GETPOST("stcomm",'int');
 $search_nom         = GETPOST("search_nom");
 $search_zipcode     = GETPOST("search_zipcode");
-$search_town       = GETPOST("search_town");
-$search_departement = GETPOST("search_departement");
+$search_town        = GETPOST("search_town");
+$search_state       = GETPOST("search_state");
 $search_datec       = GETPOST("search_datec");
 $search_categ       = GETPOST("search_categ",'int');
 $catid              = GETPOST("catid",'int');
@@ -195,7 +195,7 @@ if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
 if ($search_nom)   $sql .= " AND s.nom LIKE '%".$db->escape(strtolower($search_nom))."%'";
 if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape(strtolower($search_zipcode))."%'";
 if ($search_town) $sql .= " AND s.town LIKE '%".$db->escape(strtolower($search_town))."%'";
-if ($search_departement) $sql .= " AND d.nom LIKE '%".$db->escape(strtolower($search_departement))."%'";
+if ($search_state) $sql .= " AND d.nom LIKE '%".$db->escape(strtolower($search_state))."%'";
 if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'";
 // Insert levels filters
 if ($search_levels)
@@ -318,7 +318,7 @@ if ($resql)
 	print '<input type="text" class="flat" name="search_town" size="10" value="'.$search_town.'">';
 	print '</td>';
  	print '<td class="liste_titre" align="center">';
-    print '<input type="text" class="flat" name="search_departement" size="10" value="'.$search_departement.'">';
+    print '<input type="text" class="flat" name="search_state" size="10" value="'.$search_state.'">';
     print '</td>';
     print '<td align="center" class="liste_titre">';
 	print '<input class="flat" type="text" size="10" name="search_datec" value="'.$search_datec.'">';
diff --git a/htdocs/compta/bank/bankid_fr.php b/htdocs/compta/bank/bankid_fr.php
index 6e4dbbeba0cc97342f9dd4669ffc25160b51a5b9..31d929dfed537d391970935a632152a80ac676f6 100644
--- a/htdocs/compta/bank/bankid_fr.php
+++ b/htdocs/compta/bank/bankid_fr.php
@@ -65,8 +65,8 @@ if ($action == 'update' && ! $_POST["cancel"])
 	$account->domiciliation   = trim($_POST["domiciliation"]);
 	$account->proprio 	      = trim($_POST["proprio"]);
 	$account->owner_address   = trim($_POST["owner_address"]);
-	$account->fk_departement  = trim($_POST["fk_departement"]);
-	//$account->fk_pays         = trim($_POST["fk_pays"]);		// We do not change this.
+	$account->state_id  	  = trim($_POST["state_id"]);
+	//$account->country_id       = trim($_POST["country_id"]);		// We do not change this.
 
 	if ($account->id)
 	{
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index fa6b412c457dc5dbdb5acc3b6010bd2c78bd4365..21a669d618a105d27c9ea4904d788dcf71ca2ea7 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -62,16 +62,10 @@ class Account extends CommonObject
     var $proprio;
     var $owner_address;
 
-
-    var $fk_departement;    // deprecated
-    var $departement_code;    // deprecated
-    var $departement;        // deprecated
     var $state_id;
     var $state_code;
     var $state;
 
-    var $fk_pays;            // deprecated
-    var $pays;                // deprecated
     var $country_id;
     var $country_code;
     var $country;
@@ -353,8 +347,8 @@ class Account extends CommonObject
         // Clean parameters
         if (! $this->min_allowed) $this->min_allowed=0;
         if (! $this->min_desired) $this->min_desired=0;
-        $this->state_id = ($this->state_id?$this->state_id:$this->fk_departement);
-        $this->country_id = ($this->country_id?$this->country_id:$this->fk_pays);
+        $this->state_id = ($this->state_id?$this->state_id:$this->state_id);
+        $this->country_id = ($this->country_id?$this->country_id:$this->country_id);
 
         // Check parameters
         if (empty($this->country_id))
@@ -392,7 +386,7 @@ class Account extends CommonObject
         $sql.= ", min_allowed";
         $sql.= ", min_desired";
         $sql.= ", comment";
-        $sql.= ", fk_departement";
+        $sql.= ", state_id";
         $sql.= ", fk_pays";
         $sql.= ") VALUES (";
         $sql.= "'".$this->db->idate($now)."'";
@@ -477,8 +471,8 @@ class Account extends CommonObject
         // Clean parameters
         if (! $this->min_allowed) $this->min_allowed=0;
         if (! $this->min_desired) $this->min_desired=0;
-        $this->state_id = ($this->state_id?$this->state_id:$this->fk_departement);
-        $this->country_id = ($this->country_id?$this->country_id:$this->fk_pays);
+        $this->state_id = ($this->state_id?$this->state_id:$this->state_id);
+        $this->country_id = ($this->country_id?$this->country_id:$this->country_id);
 
         // Check parameters
         if (empty($this->country_id))
@@ -512,7 +506,7 @@ class Account extends CommonObject
         $sql.= ",min_desired = '".price2num($this->min_desired)."'";
         $sql.= ",comment     = '".$this->db->escape($this->comment)."'";
 
-        $sql.= ",fk_departement = ".($this->state_id>0?"'".$this->state_id."'":"null");
+        $sql.= ",state_id = ".($this->state_id>0?"'".$this->state_id."'":"null");
         $sql.= ",fk_pays = ".$this->country_id;
 
         $sql.= " WHERE rowid = ".$this->id;
@@ -544,8 +538,8 @@ class Account extends CommonObject
         global $conf,$langs;
 
         // Clean parameters
-        $this->state_id = ($this->state_id?$this->state_id:$this->fk_departement);
-        $this->country_id = ($this->country_id?$this->country_id:$this->fk_pays);
+        $this->state_id = ($this->state_id?$this->state_id:$this->state_id);
+        $this->country_id = ($this->country_id?$this->country_id:$this->country_id);
 
         // Chargement librairie pour acces fonction controle RIB
         require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
@@ -570,7 +564,7 @@ class Account extends CommonObject
         $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
         $sql.= ",proprio = '".$this->db->escape($this->proprio)."'";
         $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'";
-        $sql.= ",fk_departement = ".($this->state_id>0?"'".$this->state_id."'":"null");
+        $sql.= ",state_id = ".($this->state_id>0?"'".$this->state_id."'":"null");
         $sql.= ",fk_pays = ".$this->country_id;
         $sql.= " WHERE rowid = ".$this->id;
         $sql.= " AND entity = ".$conf->entity;
@@ -610,14 +604,14 @@ class Account extends CommonObject
 
         $sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,";
         $sql.= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,";
-        $sql.= " ba.domiciliation, ba.proprio, ba.owner_address, ba.fk_departement, ba.fk_pays as country_id,";
+        $sql.= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,";
         $sql.= " ba.account_number, ba.currency_code,";
         $sql.= " ba.min_allowed, ba.min_desired, ba.comment,";
         $sql.= ' p.code as country_code, p.libelle as country,';
         $sql.= ' d.code_departement as state_code, d.nom as state';
         $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
         $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON ba.fk_pays = p.rowid';
-        $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ba.fk_departement = d.rowid';
+        $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ba.state_id = d.rowid';
         $sql.= " WHERE entity = ".$conf->entity;
         if ($id)  $sql.= " AND ba.rowid  = ".$id;
         if ($ref) $sql.= " AND ba.ref = '".$this->db->escape($ref)."'";
@@ -652,15 +646,10 @@ class Account extends CommonObject
                 $this->proprio       = $obj->proprio;
                 $this->owner_address = $obj->owner_address;
 
-                $this->fk_departement  = $obj->fk_departement;    // deprecated
-                $this->departement_code= $obj->state_code;        // deprecated
-                $this->departement     = $obj->state;             // deprecated
-                $this->state_id        = $obj->fk_departement;
+                $this->state_id        = $obj->state_id;
                 $this->state_code      = $obj->state_code;
                 $this->state           = $obj->state;
 
-                $this->fk_pays       = $obj->country_id;          // deprecated
-                $this->pays          = $obj->country;             // deprecated
                 $this->country_id    = $obj->country_id;
                 $this->country_code  = $obj->country_code;
                 $this->country       = $obj->country;
diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php
index fe251cae5cb856470d5d17768be757554c6acd53..b811e35f7d7a8c8c46a0c5dd5db1df3b2f4e007c 100644
--- a/htdocs/compta/bank/fiche.php
+++ b/htdocs/compta/bank/fiche.php
@@ -69,8 +69,8 @@ if ($_POST["action"] == 'add')
 
     $account->currency_code   = trim($_POST["account_currency_code"]);
 
-    $account->fk_departement  = $_POST["account_departement_id"];
-    $account->fk_pays         = $_POST["account_country_id"];
+    $account->state_id  	  = $_POST["account_departement_id"];
+    $account->country_id      = $_POST["account_country_id"];
 
     $account->min_allowed     = $_POST["account_min_allowed"];
     $account->min_desired     = $_POST["account_min_desired"];
@@ -140,7 +140,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
 
     $account->currency_code   = trim($_POST["account_currency_code"]);
 
-    $account->state_id        = $_POST["account_departement_id"];
+    $account->state_id        = $_POST["account_state_id"];
     $account->country_id      = $_POST["account_country_id"];
 
     $account->min_allowed     = $_POST["account_min_allowed"];
@@ -282,7 +282,7 @@ if ($action == 'create')
 	print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
 	if ($selectedcode)
 	{
-		$formcompany->select_departement(isset($_POST["account_departement_id"])?$_POST["account_departement_id"]:'',$selectedcode,'account_departement_id');
+		$formcompany->select_departement(isset($_POST["account_state_id"])?$_POST["account_state_id"]:'',$selectedcode,'account_state_id');
 	}
 	else
 	{
@@ -407,7 +407,7 @@ else
 
 		// Country
 		print '<tr><td>'.$langs->trans("BankAccountCountry").'</td><td>';
-		if ($account->fk_pays > 0)
+		if ($account->country_id > 0)
 		{
 			$img=picto_from_langcode($account->country_code);
 			print $img?$img.' ':'';
@@ -555,7 +555,7 @@ else
 		print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
 		if ($selectedcode)
 		{
-			print $formcompany->select_state(isset($_POST["account_departement_id"])?$_POST["account_departement_id"]:$account->fk_departement,$selectedcode,'account_departement_id');
+			print $formcompany->select_state(isset($_POST["account_state_id"])?$_POST["account_state_id"]:$account->state_id,$selectedcode,'account_state_id');
 		}
 		else
 		{
diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php
index a03f2cd8f5e672342e3d67df91ae43cb09029668..9ca97617db6fd453195318e0f5881155ccdb39d2 100644
--- a/htdocs/compta/dons/class/don.class.php
+++ b/htdocs/compta/dons/class/don.class.php
@@ -45,7 +45,7 @@ class Don extends CommonObject
     var $address;
     var $zip;
     var $town;
-    var $pays;
+    var $country;
     var $email;
     var $public;
     var $fk_project;
@@ -300,8 +300,8 @@ class Don extends CommonObject
         $this->address=($this->address>0?$this->address:$this->address);
         $this->zip=($this->zip>0?$this->zip:$this->zip);
         $this->town=($this->town>0?$this->town:$this->town);
-        $this->country_id=($this->country_id>0?$this->country_id:$this->fk_pays);
-        $this->country=($this->country?$this->country:$this->pays);
+        $this->country_id=($this->country_id>0?$this->country_id:$this->country_id);
+        $this->country=($this->country?$this->country:$this->country);
 
         $now=dol_now();
 
@@ -316,7 +316,7 @@ class Don extends CommonObject
         $sql.= ", address";
         $sql.= ", zip";
         $sql.= ", town";
-        $sql.= ", pays";
+        $sql.= ", country";
         $sql.= ", public";
         $sql.= ", fk_don_projet";
         $sql.= ", note";
@@ -385,8 +385,8 @@ class Don extends CommonObject
         $this->address=($this->address>0?$this->address:$this->address);
         $this->zip=($this->zip>0?$this->zip:$this->zip);
         $this->town=($this->town>0?$this->town:$this->town);
-        $this->country_id=($this->country_id>0?$this->country_id:$this->fk_pays);
-        $this->country=($this->country?$this->country:$this->pays);
+        $this->country_id=($this->country_id>0?$this->country_id:$this->country_id);
+        $this->country=($this->country?$this->country:$this->country);
 
         $sql = "UPDATE ".MAIN_DB_PREFIX."don SET ";
         $sql .= "amount = " . price2num($this->amount);
@@ -397,7 +397,7 @@ class Don extends CommonObject
         $sql .= ",address='".$this->db->escape($this->address)."'";
         $sql .= ",zip='".$this->db->escape($this->zip)."'";
         $sql .= ",town='".$this->db->escape($this->town)."'";
-        $sql .= ",pays='".$this->db->escape($this->country)."'"; // TODO use country_id
+        $sql .= ",country='".$this->db->escape($this->country)."'"; // TODO use country_id
         $sql .= ",public=".$this->public;
         $sql .= ",fk_don_projet=".($this->fk_project>0?$this->fk_project:'null');
         $sql .= ",note='".$this->db->escape($this->note)."'";
@@ -463,7 +463,7 @@ class Don extends CommonObject
         global $conf;
 
         $sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,";
-        $sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.phone, d.phone_mobile, d.fk_don_projet,";
+        $sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, d.country, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.phone, d.phone_mobile, d.fk_don_projet,";
         $sql.= " p.title as project_label";
         $sql.= " FROM ".MAIN_DB_PREFIX."don as d";
         $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_don_projet";
@@ -491,10 +491,10 @@ class Don extends CommonObject
                 $this->town           = $obj->town;
                 $this->zip            = $obj->zip;
                 $this->town           = $obj->town;
+                $this->country        = $obj->country;
                 $this->email          = $obj->email;
                 $this->phone          = $obj->phone;
                 $this->phone_mobile   = $obj->phone_mobile;
-                $this->pays           = $obj->pays;
                 $this->projet         = $obj->project_label;
                 $this->fk_project     = $obj->fk_don_projet;
                 $this->public         = $obj->public;
diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php
index 9c4715cc406f2b21a67bd9215163e522e2240736..7057b97f21ecbb2e47463f9616c15dbf1817557d 100644
--- a/htdocs/compta/dons/fiche.php
+++ b/htdocs/compta/dons/fiche.php
@@ -92,11 +92,10 @@ if ($action == 'update')
 		$don->amount      = price2num($_POST["amount"]);
 		$don->town        = $_POST["town"];
         $don->zip         = $_POST["zipcode"];
-        $don->town        = $_POST["town"];
+        $don->country     = $_POST["country"];
 		$don->email       = $_POST["email"];
 		$don->date        = $donation_date;
 		$don->note        = $_POST["note"];
-		$don->pays        = $_POST["pays"];
 		$don->public      = $_POST["public"];
 		$don->fk_project  = $_POST["projectid"];
 		$don->note        = $_POST["comment"];
@@ -144,10 +143,10 @@ if ($action == 'add')
 		$don->town        = $_POST["town"];
         $don->zip         = $_POST["zipcode"];
         $don->town        = $_POST["town"];
+        $don->country     = $_POST["country"];
 		$don->email       = $_POST["email"];
 		$don->date        = $donation_date;
 		$don->note        = $_POST["note"];
-		$don->pays        = $_POST["pays"];
 		$don->public      = $_POST["public"];
 		$don->fk_project  = $_POST["projectid"];
 		$don->note        = $_POST["comment"];
@@ -302,12 +301,12 @@ if ($action == 'create')
 
     // Zip / Town
     print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
-	print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$don->zip),'zipcode',array('town','selectcountry_id','departement_id'),6);
+	print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$don->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
     print ' ';
-    print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$don->town),'town',array('zipcode','selectcountry_id','departement_id'));
+    print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$don->town),'town',array('zipcode','selectcountry_id','state_id'));
     print '</tr>';
 
-	print "<tr>".'<td>'.$langs->trans("Country").'</td><td><input type="text" name="pays" value="'.$_POST["pays"].'" size="40"></td></tr>';
+	print "<tr>".'<td>'.$langs->trans("Country").'</td><td><input type="text" name="country" value="'.$_POST["country"].'" size="40"></td></tr>';
 	print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" value="'.$_POST["email"].'" size="40"></td></tr>';
 
     print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
@@ -392,12 +391,12 @@ if (! empty($id) && $action == 'edit')
 
     // Zip / Town
     print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
-    print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$don->zip),'zipcode',array('town','selectcountry_id','departement_id'),6);
+    print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$don->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
     print ' ';
-    print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$don->town),'town',array('zipcode','selectcountry_id','departement_id'));
+    print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$don->town),'town',array('zipcode','selectcountry_id','state_id'));
     print '</tr>';
 
-	print "<tr>".'<td>'.$langs->trans("Country").'</td><td><input type="text" name="pays" size="40" value="'.$don->pays.'"></td></tr>';
+	print "<tr>".'<td>'.$langs->trans("Country").'</td><td><input type="text" name="country" size="40" value="'.$don->country.'"></td></tr>';
 	print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" size="40" value="'.$don->email.'"></td></tr>';
 
     print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
@@ -489,7 +488,7 @@ if (! empty($id) && $action != 'edit')
 	print "<tr>".'<td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>'.$don->zip.($don->zip && $don->town?' / ':'').$don->town.'</td></tr>';
 
 	// Country
-	print "<tr>".'<td>'.$langs->trans("Country").'</td><td>'.$don->pays.'</td></tr>';
+	print "<tr>".'<td>'.$langs->trans("Country").'</td><td>'.$don->country.'</td></tr>';
 
 	// EMail
 	print "<tr>".'<td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($don->email).'</td></tr>';
diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php
index 1521802a580c58abd6a04fc6d88106e460595089..f1977f9f01a7528f010cb6c2ccb006bf8920ab87 100755
--- a/htdocs/compta/journal/purchasesjournal.php
+++ b/htdocs/compta/journal/purchasesjournal.php
@@ -90,7 +90,7 @@ else  $description.= $langs->trans("DepositsAreIncluded");
 $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
 report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
 
-$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_PAYS);
+$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
 $idpays = $p[0];
 
 $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.libelle,";
diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php
index cbdb8b4da29642bc019d4ff0df7a81af70b367cb..c3cb58526adc60be93a2f83020146a9b079a16d0 100755
--- a/htdocs/compta/journal/sellsjournal.php
+++ b/htdocs/compta/journal/sellsjournal.php
@@ -92,7 +92,7 @@ else  $description.= $langs->trans("DepositsAreIncluded");
 $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
 report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
 
-$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_PAYS);
+$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
 $idpays = $p[0];
 
 $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.ref_client,";
diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php
index bc918816dc6a76fba6924b3ff828e0e030523935..a0fb97d715876219602cf0b3ba348c693f316fcd 100644
--- a/htdocs/contact/canvas/actions_contactcard_common.class.php
+++ b/htdocs/contact/canvas/actions_contactcard_common.class.php
@@ -432,7 +432,6 @@ abstract class ActionsContactCardCommon
         $this->object->address				=	$_POST["address"];
         $this->object->zip					=	$_POST["zipcode"];
         $this->object->town					=	$_POST["town"];
-        $this->object->fk_pays				=	$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
         $this->object->fk_departement		=	$_POST["departement_id"];
         $this->object->country_id			=	$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
         $this->object->state_id        		=	$_POST["departement_id"];
@@ -459,7 +458,7 @@ abstract class ActionsContactCardCommon
             {
                 dol_print_error($this->db);
             }
-            $this->object->pays			=	$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
+            $this->object->country_id	=	$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
             $this->object->country_code	=	$obj->code;
             $this->object->country		=	$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
         }
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 7b605130995896acfff2597ed219820b993df50c..58183a3df251154861815f2b047ed1bcf671a640 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -53,8 +53,6 @@ class Contact extends CommonObject
 	var $state_code;		    // Code of department
 	var $state;			        // Label of department
 
-	var $fk_pays;				// deprecated
-	var $pays;					// deprecated
 	var $country_id;			// Id of country
 	var $country_code;			// Code of country
 	var $country;				// Label of country
@@ -222,7 +220,7 @@ class Contact extends CommonObject
 		$this->fax=trim($this->fax);
 		$this->zip=($this->zip?$this->zip:$this->zip);
 		$this->town=($this->town?$this->town:$this->town);
-		$this->country_id=($this->country_id > 0?$this->country_id:$this->fk_pays);
+		$this->country_id=($this->country_id > 0?$this->country_id:$this->country_id);
 		$this->state_id=($this->state_id > 0?$this->state_id:$this->fk_departement);
 
 		$this->db->begin();
@@ -490,7 +488,7 @@ class Contact extends CommonObject
 		$sql.= " p.libelle as country, p.code as country_code,";
 		$sql.= " d.nom as state, d.code_departement as state_code,";
 		$sql.= " u.rowid as user_id, u.login as user_login,";
-		$sql.= " s.nom as socname, s.address as socaddress, s.cp as soccp, s.town as soccity, s.default_lang as socdefault_lang";
+		$sql.= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
 		$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c";
 		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON c.fk_pays = p.rowid";
 		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid";
@@ -522,10 +520,8 @@ class Contact extends CommonObject
 				$this->departement		= $obj->state;	           // deprecated
 				$this->state			= $obj->state;
 
-				$this->fk_pays			= $obj->country_id;
 				$this->country_id 		= $obj->country_id;
 				$this->country_code		= $obj->country_id?$obj->country_code:'';
-				$this->pays				= ($obj->country_id > 0)?$langs->transnoentitiesnoconv("Country".$obj->country_code):'';
 				$this->country			= ($obj->country_id > 0)?$langs->transnoentitiesnoconv("Country".$obj->country_code):'';
 
 				$this->socid			= $obj->fk_soc;
diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index 1bd291b5f2594164d1dc1766bd8fe5821c71f6e9..80277c904ade8087c7778f41b3161b535cf8bb86 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -585,7 +585,6 @@ else
             if (isset($_POST["country_id"]) || $object->country_id)
             {
 	            $tmparray=getCountry($object->country_id,'all');
-	            $object->pays         =	$tmparray['label'];
 	            $object->country_code =	$tmparray['code'];
 	            $object->country      =	$tmparray['label'];
             }
@@ -890,7 +889,7 @@ else
         print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
         $img=picto_from_langcode($object->country_code);
         if ($img) print $img.' ';
-        print $object->pays;
+        print $object->country_id;
         print '</td></tr>';
 
         // State
diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php
index be1b820cb60244c315456fb092d7814c08a5d32e..683be86bb0873d188752e6baccf8bacb77cca6e5 100644
--- a/htdocs/contact/vcard.php
+++ b/htdocs/contact/vcard.php
@@ -54,8 +54,8 @@ $v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE");
 $v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE");
 $v->setPhoneNumber($contact->fax, "WORK;FAX");
 
-$v->setAddress("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->pays:''), "WORK;POSTAL");
-$v->setLabel("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->pays:''), "WORK");
+$v->setAddress("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->country_id:''), "WORK;POSTAL");
+$v->setLabel("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->country_id:''), "WORK");
 $v->setEmail($contact->email,'internet,pref');
 $v->setNote($contact->note);
 
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index 99f7560a15eb8f84193ecd30058970afe1cf6f14..08202a597ec544e749851e52589ce37fa3b6799e 100755
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -99,7 +99,7 @@ class box_contacts extends ModeleBoxes
                     'url' => DOL_URL_ROOT."/contact/fiche.php?id=".$objp->rowid);
 
 					$this->info_box_contents[$i][1] = array('td' => 'align="left"',
-                    'text' => $contactstatic->getFullName($langs,1),
+                    'text' => $contactstatic->getFullName($langs,0),
                     'url' => DOL_URL_ROOT."/contact/fiche.php?id=".$objp->rowid);
 
                     $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"',
diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php
index 84b59c1667fda8bcf1768b9a360f9bb0bc9d91f7..9256e08318cc62c3e0e24053b51c87ab9e132b48 100644
--- a/htdocs/core/class/doleditor.class.php
+++ b/htdocs/core/class/doleditor.class.php
@@ -169,6 +169,9 @@ class DolEditor
             	//$skin='office2003';
             	//$skin='v2';
             	$skin='kama';
+            	
+            	if ($this->toolbarname=='dolibarr_mailings') {$htmlencode_force='true';}
+            	else {$htmlencode_force='false';}
 
             	$out.= '<script type="text/javascript">
             			$(document).ready(function () {
@@ -177,6 +180,7 @@ class DolEditor
                             CKEDITOR.replace(\''.$this->htmlname.'\',
             					{
             						customConfig : ckeditorConfig,
+                            		htmlEncodeOutput :'.$htmlencode_force.',
             						toolbar: \''.$this->toolbarname.'\',
             						toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').',
             						width: '.($this->width ? '\''.$this->width.'\'' : '\'\'').',
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index 0dd2217fa4dd382bfeffc2fd18f8356df26cc37a..59b69e1265c7b05d9905bd0771d75410976977d8 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -238,7 +238,7 @@ class FormCompany
 			dol_syslog(get_class($this)."::select_departement num=".$num,LOG_DEBUG);
 			if ($num)
 			{
-				$pays='';
+				$country='';
 				while ($i < $num)
 				{
 					$obj = $this->db->fetch_object($result);
@@ -247,13 +247,13 @@ class FormCompany
 						$out.= '<option value="0">&nbsp;</option>';
 					}
 					else {
-						if (! $pays || $pays != $obj->country)
+						if (! $country || $country != $obj->country)
 						{
 							// Affiche la rupture si on est en mode liste multipays
 							if (! $country_codeid && $obj->country_code)
 							{
 								$out.= '<option value="-1" disabled="disabled">----- '.$obj->country." -----</option>\n";
-								$pays=$obj->country;
+								$country=$obj->country;
 							}
 						}
 
@@ -312,7 +312,7 @@ class FormCompany
 			$i = 0;
 			if ($num)
 			{
-				$pays='';
+				$country='';
 				while ($i < $num)
 				{
 					$obj = $this->db->fetch_object($resql);
@@ -320,13 +320,13 @@ class FormCompany
 						print '<option value="0">&nbsp;</option>';
 					}
 					else {
-						if ($pays == '' || $pays != $obj->country)
+						if ($country == '' || $country != $obj->country)
 						{
 							// Show break
 							$key=$langs->trans("Country".strtoupper($obj->country_code));
 							$valuetoshow=($key != "Country".strtoupper($obj->country_code))?$obj->country_code." - ".$key:$obj->country;
 							print '<option value="-1" disabled="disabled">----- '.$valuetoshow." -----</option>\n";
-							$pays=$obj->country;
+							$country=$obj->country;
 						}
 
 						if ($selected > 0 && $selected == $obj->code)
@@ -454,7 +454,7 @@ class FormCompany
 			$i = 0;
 			if ($num)
 			{
-				$pays='';
+				$country='';
 				while ($i < $num)
 				{
 					$obj = $this->db->fetch_object($result);
@@ -462,11 +462,11 @@ class FormCompany
 						$out.= '<option value="0">&nbsp;</option>';
 					}
 					else {
-						if (! $pays || $pays != $obj->country) {
+						if (! $country || $country != $obj->country) {
 							// Affiche la rupture si on est en mode liste multipays
 							if (! $country_codeid && $obj->country_code) {
 								$out.= '<option value="0">----- '.$obj->country." -----</option>\n";
-								$pays=$obj->country;
+								$country=$obj->country;
 							}
 						}
 
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 36cf943c51ba7c66b280f61f5c6c364e3c3821ee..99df1e73053623ce8a10bee8700ded2e34798909 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -485,15 +485,16 @@ function dol_strtoupper($utf8_string)
  *  This function works only if syslog module is enabled.
  * 	This must not use any call to other function calling dol_syslog (avoid infinite loop).
  *
- * 	@param  string		$message	Line to log. Ne doit pas etre traduit si level = LOG_ERR
- *  @param  int			$level		Log level
- *                                  0=Show nothing
- *									On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr
- *									On Linux   LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7
- *  @param	int			$ident		1=Increase ident of 1, -1=Decrease ident of 1
+ * 	@param  string		$message			Line to log. Ne doit pas etre traduit si level = LOG_ERR
+ *  @param  int			$level				Log level
+ *                                  		0=Show nothing
+ *											On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr
+ *											On Linux   LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7
+ *  @param	int			$ident				1=Increase ident of 1, -1=Decrease ident of 1
+ *  @param	string		$suffixinfilename	When output is a file, append this suffix into default log filename. 	
  *  @return	void
  */
-function dol_syslog($message, $level = LOG_INFO, $ident = 0)
+function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='')
 {
 	global $conf, $user;
 
@@ -543,7 +544,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0)
 		// Loop on each log handler and send output
 		foreach ($conf->loghandlers as $loghandlerinstance)
 		{
-			$loghandlerinstance->export($data);
+			$loghandlerinstance->export($data,$suffixinfilename);
 		}
 		unset($data);
 	}
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 596e8320671b360e728dacd7ac2cd2557d4ee89a..8adbb1f9afc6dd0f0b10ddd3c2f75d68927fd4ae 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -293,7 +293,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
 			$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs,1));
 			$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact))."\n";
 			// Country
-			if ($targetcontact->country_code && $targetcontact->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->pays_code))."\n";
+			if ($targetcontact->country_code && $targetcontact->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code))."\n";
 
 			if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS))
     		{
@@ -311,7 +311,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
 		{
 			$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
 			// Country
-			if ($targetcompany->country_code && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->pays_code))."\n";
+			if ($targetcompany->country_code && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
 
 			if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS))
     		{
@@ -851,7 +851,7 @@ function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hide
 	{
 		$labelproductservice=pdf_getlinedesc($object,$i,$outputlangs,$hideref,$hidedesc,$issupplierline);
 		// Description
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1);
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J',true);
 		return $labelproductservice;
 	}
 }
diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php
index 1fd6882caa941eacc7c898c71d210b22a9eb6bb7..03141313182f84e84a9954d87e73ce7a347ff43e 100644
--- a/htdocs/core/menus/standard/auguria.lib.php
+++ b/htdocs/core/menus/standard/auguria.lib.php
@@ -41,6 +41,7 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu)
 	$mainmenu=$_SESSION["mainmenu"];
 	$leftmenu=$_SESSION["leftmenu"];
 
+	$id='mainmenu';
 	$listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
 
 	//$tabMenu=array();
@@ -79,23 +80,12 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu)
 			if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname='class="tmenusel"';
 			else if (! empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname='class="tmenusel"';
 			else $classname='class="tmenu"';
-
-			print_start_menu_entry_auguria($idsel,$classname);
-			print '<div class="mainmenu '.$idsel.'"><span class="mainmenu_'.$idsel.'" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($newTabMenu[$i]['target']?' target="'.$newTabMenu[$i]['target'].'"':($atarget?' target="'.$atarget.'"':'')).'>';
-			print_text_menu_entry_auguria($newTabMenu[$i]['titre']);
-			print '</a>';
-			print_end_menu_entry_auguria();
-		}
-		else if ($showmode == 2)
-		{
-			print_start_menu_entry_auguria($idsel,'class="tmenu"');
-			print '<div class="mainmenu '.$idsel.'"><span class="mainmenu_'.$idsel.'" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
-			print_text_menu_entry_auguria($newTabMenu[$i]['titre']);
-			print '</a>';
-			print_end_menu_entry_auguria();
 		}
+		else if ($showmode == 2) $classname='class="tmenu"';
+
+		print_start_menu_entry_auguria($idsel,$classname);
+		print_text_menu_entry_auguria($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, $atarget, $newTabMenu[$i]['target']);
+		print_end_menu_entry_auguria();
 	}
 
 	print_end_menu_array_auguria();
@@ -111,7 +101,6 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu)
  */
 function print_start_menu_array_auguria()
 {
-	global $conf;
 	print '<div class="tmenudiv">';
 	print '<ul class="tmenu">';
 }
@@ -133,13 +122,35 @@ function print_start_menu_entry_auguria($idsel,$classname)
  * Output menu entry
  *
  * @param	string	$text		Text
+ * @param	int		$showmode	1 or 2
+ * @param	string	$url		Url
+ * @param	string	$id			Id
+ * @param	string	$idsel		Id sel
+ * @param	string	$classname	Class name
+ * @param	string	$atarget	Target
+ * @param	string	$menutarget	Menu target (may be empty)
  * @return	void
  */
-function print_text_menu_entry_auguria($text)
+function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menutarget='')
 {
-	print '<span class="mainmenuaspan">';
-	print $text;
-	print '</span>';
+	global $langs;
+
+	if ($showmode == 1)
+	{
+		print '<a class="tmenuimage" href="'.$url.'"'.($menutarget?" target='".$menutarget."'":($atarget?' target="'.$atarget.'"':'')).'>';
+		print '<div class="'.$id.' '.$idsel.'"><span class="mainmenu_'.$idsel.' '.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
+		print '</a>';
+		print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($menutarget?" target='".$menutarget."'":($atarget?' target="'.$atarget.'"':'')).'>';
+		print '<span class="mainmenuaspan">';
+		print $text;
+		print '</span>';
+		print '</a>';
+	}
+	if ($showmode == 2)
+	{
+		print '<div class="'.$id.' '.$idsel.'"><span class="mainmenu_'.$idsel.' '.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
+		print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
+	}
 }
 
 /**
@@ -149,8 +160,7 @@ function print_text_menu_entry_auguria($text)
  */
 function print_end_menu_entry_auguria()
 {
-	print '</div>';
-	print '</li>';
+	print '</div></li>';
 	print "\n";
 }
 
diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php
index a7af0727301a7ac210a90a274c08a3bf2778d3fb..36ca12697611582d8411db57b157b39fbf503f6f 100644
--- a/htdocs/core/menus/standard/auguria_menu.php
+++ b/htdocs/core/menus/standard/auguria_menu.php
@@ -30,15 +30,15 @@ class MenuManager
 {
 	var $db;
 	var $type_user;								// Put 0 for internal users, 1 for external users
-	var $atarget="";                            // Valeur du target a utiliser dans les liens
+	var $atarget="";                            // To store default target to use onto links
 	var $name="auguria";
-	
+
 	var $menu_array;
 	var $menu_array_after;
 
 	var $tabMenu;
-	
-	
+
+
     /**
      *  Constructor
      *
@@ -48,14 +48,14 @@ class MenuManager
     function __construct($db, $type_user)
     {
     	global $conf, $user, $langs;
-    	
+
     	$this->type_user=$type_user;
     	$this->db=$db;
-    	
+
     	// On sauve en session le menu principal choisi
     	if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"];
     	if (isset($_GET["idmenu"]))   $_SESSION["idmenu"]=$_GET["idmenu"];
-    	
+
     	// Read mainmenu and leftmenu that define which menu to show
     	if (isset($_GET["mainmenu"]))
     	{
@@ -69,13 +69,13 @@ class MenuManager
     		// On va le chercher en session si non defini par le lien
     		$mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:'';
     	}
-    	
+
     	if (isset($_GET["leftmenu"]))
     	{
     		// On sauve en session le menu principal choisi
     		$leftmenu=$_GET["leftmenu"];
     		$_SESSION["leftmenu"]=$leftmenu;
-    	
+
     		if ($_SESSION["leftmenuopened"]==$leftmenu)	// To collapse
     		{
     			//$leftmenu="";
@@ -89,12 +89,12 @@ class MenuManager
     		// On va le chercher en session si non defini par le lien
     		$leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:'';
     	}
-    	
+
     	require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
     	$tabMenu=array();
     	$menuArbo = new Menubase($db,'auguria');
     	$menuArbo->menuLoad($mainmenu, $leftmenu, $type_user, 'auguria', $tabMenu);
-    	
+
     	// Modules system tools
     	// TODO Find a way to add parent menu only if child menu exists. For the moment, no other method than hard coded methods.
     	if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->global->MAIN_MENU_ENABLE_MODULETOOLS))
@@ -134,10 +134,10 @@ class MenuManager
 				));
     		}
     	}
-    	
+
     	$this->tabMenu=$tabMenu;
     }
-	
+
 
     /**
      *  Show menu
@@ -148,7 +148,7 @@ class MenuManager
 	function showmenu($mode)
 	{
     	global $conf;
-    	
+
         require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php';
 
         if ($this->type_user == 1)
@@ -156,7 +156,7 @@ class MenuManager
         	$conf->global->MAIN_SEARCHFORM_SOCIETE=0;
 	        $conf->global->MAIN_SEARCHFORM_CONTACT=0;
         }
-            
+
         $res='ErrorBadParameterForMode';
         if ($mode == 'top')  $res=print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu);
         if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu);
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 98db3212d44c7e5ed6544fab7e37dcd7179802de..c6aaa2e392cd330f76f6cf05eff266a763e148f5 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -48,25 +48,14 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 
 	// Home
 	$classname="";
-	if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home")
-	{
-		$classname='class="tmenusel"'; $_SESSION['idmenu']='';
-	}
-	else
-	{
-		$classname = 'class="tmenu"';
-	}
+	if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
+	else $classname = 'class="tmenu"';
 	$idsel='home';
+
 	print_start_menu_entry($idsel,$classname);
-	print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/index.php?mainmenu=home&amp;leftmenu="'.($atarget?" target=$atarget":"").'>';
-	print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-	print '</a>';
-	print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/index.php?mainmenu=home&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-	print_text_menu_entry($langs->trans("Home"));
-	print '</a>';
+	print_text_menu_entry($langs->trans("Home"), 1, DOL_URL_ROOT.'/index.php?mainmenu=home&amp;leftmenu=', $id, $idsel, $classname, $atarget);
 	print_end_menu_entry();
 
-
 	// Third parties
 	$tmpentry=array('enabled'=>(! empty($conf->societe->enabled) || ! empty($conf->fournisseur->enabled)), 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), 'module'=>'societe|fournisseur');
 	$showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal);
@@ -76,37 +65,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 		$langs->load("suppliers");
 
 		$classname="";
-		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies")
-		{
-			$classname='class="tmenusel"'; $_SESSION['idmenu']='';
-		}
-		else
-		{
-			$classname = 'class="tmenu"';
-		}
-
+		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
+		else $classname = 'class="tmenu"';
 		$idsel='companies';
 
-		if ($showmode == 1)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '</a>';
-			print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print_text_menu_entry($langs->trans("ThirdParties"));
-			print '</a>';
-			print_end_menu_entry();
-		}
-		else if ($showmode == 2)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
-			print_text_menu_entry($langs->trans("ThirdParties"));
-			print '</a>';
-			print_end_menu_entry();
-		}
+		print_start_menu_entry($idsel,$classname);
+		print_text_menu_entry($langs->trans("ThirdParties"), $showmode, DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&amp;leftmenu=', $id, $idsel, $classname, $atarget);
+		print_end_menu_entry();
 	}
 
 	// Products-Services
@@ -117,14 +82,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 		$langs->load("products");
 
 		$classname="";
-		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products")
-		{
-			$classname='class="tmenusel"'; $_SESSION['idmenu']='';
-		}
-		else
-		{
-			$classname = 'class="tmenu"';
-		}
+		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
+		else $classname = 'class="tmenu"';
+		$idsel='products';
+
 		$chaine="";
 		if (! empty($conf->product->enabled)) {
 			$chaine.=$langs->trans("Products");
@@ -136,27 +97,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 			$chaine.=$langs->trans("Services");
 		}
 
-		$idsel='products';
-		if ($showmode == 1)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/product/index.php?mainmenu=products&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage"  id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '</a>';
-			print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/product/index.php?mainmenu=products&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print_text_menu_entry($chaine);
-			print '</a>';
-			print_end_menu_entry();
-		}
-		else if ($showmode == 2)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
-			print_text_menu_entry($chaine);
-			print '</a>';
-			print_end_menu_entry();
-		}
+		print_start_menu_entry($idsel,$classname);
+		print_text_menu_entry($chaine, $showmode, DOL_URL_ROOT.'/product/index.php?mainmenu=products&amp;leftmenu=', $id, $idsel, $classname, $atarget);
+		print_end_menu_entry();
 	}
 
 	// Commercial
@@ -173,36 +116,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 		$langs->load("commercial");
 
 		$classname="";
-		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial")
-		{
-			$classname='class="tmenusel"'; $_SESSION['idmenu']='';
-		}
-		else
-		{
-			$classname = 'class="tmenu"';
-		}
-
+		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
+		else $classname = 'class="tmenu"';
 		$idsel='commercial';
-		if ($showmode == 1)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="'.$id.'"></span></div>';
-			print '</a>';
-			print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print_text_menu_entry($langs->trans("Commercial"));
-			print '</a>';
-			print_end_menu_entry();
-		}
-		else if ($showmode == 2)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
-			print print_text_menu_entry($langs->trans("Commercial"));
-			print '</a>';
-			print_end_menu_entry();
-		}
+
+		print_start_menu_entry($idsel,$classname);
+		print_text_menu_entry($langs->trans("Commercial"), $showmode, DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&amp;leftmenu=', $id, $idsel, $classname, $atarget);
+		print_end_menu_entry();
 	}
 
 	// Financial
@@ -215,36 +135,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 		$langs->load("compta");
 
 		$classname="";
-		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy")
-		{
-			$classname='class="tmenusel"'; $_SESSION['idmenu']='';
-		}
-		else
-		{
-			$classname = 'class="tmenu"';
-		}
-
+		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
+		else $classname = 'class="tmenu"';
 		$idsel='accountancy';
-		if ($showmode == 1)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '</a>';
-			print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print_text_menu_entry($langs->trans("MenuFinancial"));
-			print '</a>';
-			print_end_menu_entry();
-		}
-		else if ($showmode == 2)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
-			print_text_menu_entry($langs->trans("MenuFinancial"));
-			print '</a>';
-			print_end_menu_entry();
-		}
+
+		print_start_menu_entry($idsel,$classname);
+		print_text_menu_entry($langs->trans("MenuFinancial"), $showmode, DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&amp;leftmenu=', $id, $idsel, $classname, $atarget);
+		print_end_menu_entry();
 	}
 
 	// Bank
@@ -258,36 +155,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 		$langs->load("banks");
 
 		$classname="";
-		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank")
-		{
-			$classname='class="tmenusel"'; $_SESSION['idmenu']='';
-		}
-		else
-		{
-			$classname = 'class="tmenu"';
-		}
-
+		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
+		else $classname = 'class="tmenu"';
 		$idsel='bank';
-		if ($showmode == 1)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '</a>';
-			print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print_text_menu_entry($langs->trans("MenuBankCash"));
-			print '</a>';
-			print_end_menu_entry();
-		}
-		else if ($showmode == 2)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
-			print_text_menu_entry($langs->trans("MenuBankCash"));
-			print '</a>';
-			print_end_menu_entry();
-		}
+
+		print_start_menu_entry($idsel,$classname);
+		print_text_menu_entry($langs->trans("MenuBankCash"), $showmode, DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&amp;leftmenu=', $id, $idsel, $classname, $atarget);
+		print_end_menu_entry();
 	}
 
 	// Projects
@@ -300,36 +174,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 		$langs->load("projects");
 
 		$classname="";
-		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project")
-		{
-			$classname='class="tmenusel"'; $_SESSION['idmenu']='';
-		}
-		else
-		{
-			$classname = 'class="tmenu"';
-		}
-
+		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
+		else $classname = 'class="tmenu"';
 		$idsel='project';
-		if ($showmode == 1)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/projet/index.php?mainmenu=project&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '</a>';
-			print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/projet/index.php?mainmenu=project&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print_text_menu_entry($langs->trans("Projects"));
-			print '</a>';
-			print_end_menu_entry();
-		}
-		else if ($showmode == 2)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
-			print_text_menu_entry($langs->trans("Projects"));
-			print '</a>';
-			print_end_menu_entry();
-		}
+
+		print_start_menu_entry($idsel,$classname);
+		print_text_menu_entry($langs->trans("Projects"), $showmode, DOL_URL_ROOT.'/projet/index.php?mainmenu=project&amp;leftmenu=', $id, $idsel, $classname, $atarget);
+		print_end_menu_entry();
 	}
 
 	// Tools
@@ -342,36 +193,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 		$langs->load("other");
 
 		$classname="";
-		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools")
-		{
-			$classname='class="tmenusel"'; $_SESSION['idmenu']='';
-		}
-		else
-		{
-			$classname = 'class="tmenu"';
-		}
-
+		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
+		else $classname = 'class="tmenu"';
 		$idsel='tools';
-		if ($showmode == 1)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '</a>';
-			print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print_text_menu_entry($langs->trans("Tools"));
-			print '</a>';
-			print_end_menu_entry();
-		}
-		else if ($showmode == 2)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a class="tmenudisabled"  id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
-			print_text_menu_entry($langs->trans("Tools"));
-			print '</a>';
-			print_end_menu_entry();
-		}
+
+		print_start_menu_entry($idsel,$classname);
+		print_text_menu_entry($langs->trans("Tools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&amp;leftmenu=', $id, $idsel, $classname, $atarget);
+		print_end_menu_entry();
 	}
 
 	// OSCommerce 1
@@ -384,23 +212,12 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 		$langs->load("shop");
 
 		$classname="";
-		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop")
-		{
-			$classname='class="tmenusel"'; $_SESSION['idmenu']='';
-		}
-		else
-		{
-			$classname = 'class="tmenu"';
-		}
-
+		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
+		else $classname = 'class="tmenu"';
 		$idsel='shop';
+
 		print_start_menu_entry($idsel,$classname);
-		print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-		print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-		print '</a>';
-		print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-		print_text_menu_entry($langs->trans("OSCommerce"));
-		print '</a>';
+		print_text_menu_entry($langs->trans("OSCommerce"), $showmode, DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&amp;leftmenu=', $id, $idsel, $classname, $atarget);
 		print_end_menu_entry();
 	}
 
@@ -412,36 +229,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 	if ($showmode)
 	{
 		$classname="";
-		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members")
-		{
-			$classname='class="tmenusel"'; $_SESSION['idmenu']='';
-		}
-		else
-		{
-			$classname = 'class="tmenu"';
-		}
-
+		if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
+		else $classname = 'class="tmenu"';
 		$idsel='members';
-		if ($showmode == 1)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<a class="tmenuimage" href="'.DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '</a>';
-			print '<a '.$classname.'  id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&amp;leftmenu="'.($atarget?' target="'.$atarget.'"':'').'>';
-			print_text_menu_entry($langs->trans("MenuMembers"));
-			print '</a>';
-			print_end_menu_entry();
-		}
-		else if ($showmode == 2)
-		{
-			print_start_menu_entry($idsel,$classname);
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
-			print_text_menu_entry($langs->trans("MenuMembers"));
-			print '</a>';
-			print_end_menu_entry();
-		}
+
+		print_start_menu_entry($idsel,$classname);
+		print_text_menu_entry($langs->trans("MenuMembers"), $showmode, DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&amp;leftmenu=', $id, $idsel, $classname, $atarget);
+		print_end_menu_entry();
 	}
 
 
@@ -478,25 +272,12 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu)
 			if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname='class="tmenusel"';
 			else if (! empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname='class="tmenusel"';
 			else $classname='class="tmenu"';
-
-			print_start_menu_entry($idsel,$classname);
-			print '<a class="tmenuimage" href="'.$url.'"'.($newTabMenu[$i]['target']?" target='".$newTabMenu[$i]['target']."'":($atarget?' target="'.$atarget.'"':'')).'>';
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '</a>';
-			print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($newTabMenu[$i]['target']?" target='".$newTabMenu[$i]['target']."'":($atarget?' target="'.$atarget.'"':'')).'>';
-			print_text_menu_entry($newTabMenu[$i]['titre']);
-			print '</a>';
-			print_end_menu_entry();
-		}
-		else if ($showmode == 2)
-		{
-			print_start_menu_entry($idsel,'class="tmenu"');
-			print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
-			print_text_menu_entry($newTabMenu[$i]['titre']);
-			print '</a>';
-			print_end_menu_entry();
 		}
+		else if ($showmode == 2) $classname='class="tmenu"';
+
+		print_start_menu_entry($idsel,$classname);
+		print_text_menu_entry($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, $atarget, $newTabMenu[$i]['target']);
+		print_end_menu_entry();
 	}
 
 	print_end_menu_array();
@@ -531,13 +312,35 @@ function print_start_menu_entry($idsel,$classname)
  * Output menu entry
  *
  * @param	string	$text		Text
+ * @param	int		$showmode	1 or 2
+ * @param	string	$url		Url
+ * @param	string	$id			Id
+ * @param	string	$idsel		Id sel
+ * @param	string	$classname	Class name
+ * @param	string	$atarget	Target
+ * @param	string	$menutarget	Menu target (may be empty)
  * @return	void
  */
-function print_text_menu_entry($text)
+function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menutarget='')
 {
-	print '<span class="mainmenuaspan">';
-	print $text;
-	print '</span>';
+	global $langs;
+
+	if ($showmode == 1)
+	{
+		print '<a class="tmenuimage" href="'.$url.'"'.($menutarget?" target='".$menutarget."'":($atarget?' target="'.$atarget.'"':'')).'>';
+		print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
+		print '</a>';
+		print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($menutarget?" target='".$menutarget."'":($atarget?' target="'.$atarget.'"':'')).'>';
+		print '<span class="mainmenuaspan">';
+		print $text;
+		print '</span>';
+		print '</a>';
+	}
+	if ($showmode == 2)
+	{
+		print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
+		print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
+	}
 }
 
 /**
@@ -625,7 +428,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
 				if ($leftmenu=="setup")
 				{
 					$warnpicto='';
-					if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_PAYS))
+					if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY))
 					{
 						$langs->load("errors");
 						$warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete"));
diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php
index c9902b4009f8b275ade32b768daa44e65e337827..afebe8d9e6abda6636dcdd35097b891417b04a77 100644
--- a/htdocs/core/menus/standard/eldy_menu.php
+++ b/htdocs/core/menus/standard/eldy_menu.php
@@ -29,7 +29,7 @@ class MenuManager
 {
 	var $db;
 	var $type_user;									// Put 0 for internal users, 1 for external users
-	var $atarget="";                                // Valeur du target a utiliser dans les liens
+	var $atarget="";                                // To store default target to use onto links
 	var $name="eldy";
 
     var $menu_array;
diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php
index 705dc2cf293b2e146303c360f37778d02948e389..35e8500e74698872e26962dbfceac5c9b2e303f0 100644
--- a/htdocs/core/menus/standard/empty.php
+++ b/htdocs/core/menus/standard/empty.php
@@ -27,7 +27,7 @@ class MenuManager
 {
 	var $db;
 	var $type_user=0;					// Put 0 for internal users, 1 for external users
-	var $atarget="";               		// To store arget to use in menu links
+	var $atarget="";               		// To store default target to use onto links
 
 	var $menu_array;
 	var $menu_array_after;
@@ -36,10 +36,12 @@ class MenuManager
 	/**
 	 *  Constructor
 	 *
-	 *  @param	DoliDB		$db     			Database handler
+	 *  @param	DoliDB		$db     		Database handler
+     *  @param	int			$type_user		Type of user
 	 */
-	function __construct($db)
+	function __construct($db, $type_user)
 	{
+		$this->type_user=$type_user;
 		$this->db=$db;
 	}
 
@@ -54,20 +56,17 @@ class MenuManager
 	{
 		global $user,$conf,$langs,$dolibarr_main_db_name;
 
+		$id='mainmenu';
+
 		if ($mode == 'top')
 		{
 			print_start_menu_array_empty();
 
 			$idsel='home';
-			$classname='class="tmenu"';
-
-			print_start_menu_entry_empty($idsel);
-			print '<a class="tmenuimage" href="'.dol_buildpath('/index.php',1).'?mainmenu=home&amp;leftmenu="'.($this->atarget?' target="'.$this->atarget.'"':'').'>';
-			print '<div class="mainmenu '.$idsel.'"><span class="mainmenu_'.$idsel.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
-			print '</a>';
-			print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'"'.($this->atarget?' target="'.$this->atarget.'"':'').'>';
-			print_text_menu_entry_empty($langs->trans("Home"));
-			print '</a>';
+			$classname='class="tmenusel"';
+
+			print_start_menu_entry_empty($idsel, $classname);
+			print_text_menu_entry_empty($langs->trans("Home"), 1, dol_buildpath('/index.php',1).'?mainmenu=home&amp;leftmenu=', $id, $idsel, $classname, $this->atarget);
 			print_end_menu_entry_empty();
 
 			print_end_menu_array_empty();
@@ -173,36 +172,56 @@ class MenuManager
  */
 function print_start_menu_array_empty()
 {
-	global $conf;
-	if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '<table class="tmenu" summary="topmenu"><tr class="tmenu">';
-	else print '<ul class="tmenu">';
+	print '<div class="tmenudiv">';
+	print '<ul class="tmenu">';
 }
 
 /**
  * Output start menu entry
  *
  * @param	string	$idsel		Text
+ * @param	string	$classname	String to add a css class
  * @return	void
  */
-function print_start_menu_entry_empty($idsel)
+function print_start_menu_entry_empty($idsel,$classname)
 {
-	global $conf;
-	if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '<td class="tmenu" id="mainmenutd_'.$idsel.'">';
-	else print '<li class="tmenu" id="mainmenutd_'.$idsel.'">';
+	print '<li '.$classname.' id="mainmenutd_'.$idsel.'">';
+	print '<div class="tmenuleft"></div><div class="tmenucenter">';
 }
 
 /**
  * Output menu entry
  *
  * @param	string	$text		Text
+ * @param	int		$showmode	1 or 2
+ * @param	string	$url		Url
+ * @param	string	$id			Id
+ * @param	string	$idsel		Id sel
+ * @param	string	$classname	Class name
+ * @param	string	$atarget	Target
+ * @param	string	$menutarget	Menu target (may be empty)
  * @return	void
  */
-function print_text_menu_entry_empty($text)
+function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menutarget='')
 {
 	global $conf;
-	print '<span class="mainmenuaspan">';
-	print $text;
-	print '</span>';
+
+	if ($showmode == 1)
+	{
+		print '<a class="tmenuimage" href="'.$url.'"'.($menutarget?" target='".$menutarget."'":($atarget?' target="'.$atarget.'"':'')).'>';
+		print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
+		print '</a>';
+		print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($menutarget?" target='".$menutarget."'":($atarget?' target="'.$atarget.'"':'')).'>';
+		print '<span class="mainmenuaspan">';
+		print $text;
+		print '</span>';
+		print '</a>';
+	}
+	if ($showmode == 2)
+	{
+		print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
+		print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
+	}
 }
 
 /**
@@ -212,9 +231,7 @@ function print_text_menu_entry_empty($text)
  */
 function print_end_menu_entry_empty()
 {
-	global $conf;
-	if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '</td>';
-	else print '</li>';
+	print '</div></li>';
 	print "\n";
 }
 
@@ -225,9 +242,8 @@ function print_end_menu_entry_empty()
  */
 function print_end_menu_array_empty()
 {
-	global $conf;
-	if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '</tr></table>';
-	else print '</ul>';
+	print '</ul>';
+	print '</div>';
 	print "\n";
 }
 
diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php
index 5ad1648001ea6fa144d8446cacdc6f65e79cd0ac..20d57fda97c77ce230541e6ff89b072457945e32 100644
--- a/htdocs/core/modules/export/export_csv.modules.php
+++ b/htdocs/core/modules/export/export_csv.modules.php
@@ -26,8 +26,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php';
 
 
 /**
- *	    \class      ExportCsv
- *		\brief      Class to build export files with format CSV
+ *	Class to build export files with format CSV
  */
 class ExportCsv extends ModeleExports
 {
@@ -239,7 +238,8 @@ class ExportCsv extends ModeleExports
 		$this->col=0;
 		foreach($array_selected_sorted as $code => $value)
 		{
-			$alias=str_replace(array('.','-'),'_',$code);
+			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
+			else $alias=substr($code, strpos($code, ' as ') + 4);
 			if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
 			$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
 
diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php
index e6c7972633e564961b96e8b363e5d78ad3a60c3f..9e489f0b3e82abd993eab13b871336d2da3cde3a 100644
--- a/htdocs/core/modules/export/export_excel.modules.php
+++ b/htdocs/core/modules/export/export_excel.modules.php
@@ -28,8 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
 
 
 /**
- *	\class      ExportExcel
- *	\brief      Class to build export files with Excel format
+ *	Class to build export files with Excel format
  */
 class ExportExcel extends ModeleExports
 {
@@ -276,7 +275,8 @@ class ExportExcel extends ModeleExports
 
 		foreach($array_selected_sorted as $code => $value)
 		{
-			$alias=str_replace(array('.','-'),'_',$code);
+			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
+			else $alias=substr($code, strpos($code, ' as ') + 4);
             if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
             $newvalue=$objp->$alias;
 
diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php
index 82e2e99e2a200d4548db91d3c21d80e2f08c6a1d..d0b17be331da4ee33a66f62cebe5405937161210 100755
--- a/htdocs/core/modules/export/export_excel2007.modules.php
+++ b/htdocs/core/modules/export/export_excel2007.modules.php
@@ -29,8 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
 
 
 /**
- *	\class      ExportExcel2007
- *	\brief      Class to build export files with Excel format
+ *	Class to build export files with Excel format
  */
 class ExportExcel2007 extends ExportExcel
 {
@@ -277,7 +276,8 @@ class ExportExcel2007 extends ExportExcel
 
 		foreach($array_selected_sorted as $code => $value)
 		{
-			$alias=str_replace(array('.','-'),'_',$code);
+			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
+			else $alias=substr($code, strpos($code, ' as ') + 4);
             if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
             $newvalue=$objp->$alias;
 
diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php
index 07c475e7cc231235e4d6703a616b9ef0ec512d88..c0b8eb5f6177b131dad6e05eeef19132ffb97e50 100644
--- a/htdocs/core/modules/export/export_tsv.modules.php
+++ b/htdocs/core/modules/export/export_tsv.modules.php
@@ -27,8 +27,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php';
 
 
 /**
- *	    \class      ExportTsv
- *		\brief      Class to build export files with format TSV
+ *	Class to build export files with format TSV
  */
 class ExportTsv extends ModeleExports
 {
@@ -212,7 +211,8 @@ class ExportTsv extends ModeleExports
 		$this->col=0;
  		foreach($array_selected_sorted as $code => $value)
         {
-            $alias=str_replace(array('.','-'),'_',$code);
+			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
+			else $alias=substr($code, strpos($code, ' as ') + 4);
             if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
             $newvalue=$objp->$alias;
 
diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php
index 0b9530a9fae1b0fae6cbcea4f340a2cf4f4a212a..3757e424ada5234004c3e657e65402c9e78bd3ff 100644
--- a/htdocs/core/modules/modAdherent.class.php
+++ b/htdocs/core/modules/modAdherent.class.php
@@ -172,9 +172,9 @@ class modAdherent extends DolibarrModules
         $this->export_code[$r]=$this->rights_class.'_'.$r;
         $this->export_label[$r]='MembersAndSubscriptions';
         $this->export_permission[$r]=array(array("adherent","export"));
-        $this->export_fields_array[$r]=array('a.rowid'=>'Id','a.civilite'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation','a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel','c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.cotisation'=>'Amount');
-        $this->export_TypeFields_array[$r]=array('a.civilite'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",'a.zip'=>"Text",'a.town'=>"Text",'a.pays'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.naiss'=>"Date",'a.statut'=>"Status",'a.note'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:fk_adherent_type:libelle','ta.libelle'=>'Text','c.dateadh'=>'Date','c.cotisation'=>'Number');
-        $this->export_entities_array[$r]=array('a.rowid'=>'member','a.civilite'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'a.pays'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.naiss'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.cotisation'=>'subscription');
+        $this->export_fields_array[$r]=array('a.rowid'=>'Id','a.civilite'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'a.country'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation','a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel','c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.cotisation'=>'Amount');
+        $this->export_TypeFields_array[$r]=array('a.civilite'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",'a.zip'=>"Text",'a.town'=>"Text",'a.country'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.naiss'=>"Date",'a.statut'=>"Status",'a.note'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:fk_adherent_type:libelle','ta.libelle'=>'Text','c.dateadh'=>'Date','c.cotisation'=>'Number');
+        $this->export_entities_array[$r]=array('a.rowid'=>'member','a.civilite'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'a.country'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.naiss'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.cotisation'=>'subscription');
 		// Add extra fields
 		$sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'member'";
 		$resql=$this->db->query($sql);
@@ -207,7 +207,7 @@ class modAdherent extends DolibarrModules
         $this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
         $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields');
         $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author');    // Fields to store import user id
-        $this->import_fields_array[$r]=array('a.civilite'=>"UserTitle",'a.nom'=>"Lastname*",'a.firstname'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription');
+        $this->import_fields_array[$r]=array('a.civilite'=>"UserTitle",'a.nom'=>"Lastname*",'a.firstname'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'a.country'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription');
 		// Add extra fields
 		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'member'";
 		$resql=$this->db->query($sql);
@@ -223,7 +223,7 @@ class modAdherent extends DolibarrModules
 		// End add extra fields
 		$this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
 		$this->import_regex_array[$r]=array('a.civilite'=>'code@'.MAIN_DB_PREFIX.'c_civilite','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
-        $this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.nom'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.pays'=>'1','a.email'=>'jsmith@example.com','a.naiss'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d'));
+        $this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.nom'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.naiss'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d'));
     }
 
 
diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php
index b0e1bd550b428f42efd5bcd3bfcd773beae02324..f5315f064ae364dcf7e691e33c09b5069795ba22 100644
--- a/htdocs/core/modules/syslog/mod_syslog_file.php
+++ b/htdocs/core/modules/syslog/mod_syslog_file.php
@@ -96,22 +96,25 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface
 	/**
 	 * Return the parsed logfile path
 	 *
-	 * @return string
+	 * @param	string	$suffixinfilename	When output is a file, append this suffix into default log filename. 	
+	 * @return	string
 	 */
-	private function getFilename()
+	private function getFilename($suffixinfilename='')
 	{
-		return str_replace('DOL_DATA_ROOT', DOL_DATA_ROOT, SYSLOG_FILE);
+		$tmp=str_replace('DOL_DATA_ROOT', DOL_DATA_ROOT, SYSLOG_FILE);
+		return $suffixinfilename?preg_replace('/\.log$/i', $suffixinfilename.'.log', $tmp):$tmp;
 	}
 
 	/**
 	 * Export the message
 	 *
-	 * @param  	array 	$content 	Array containing the info about the message
+	 * @param  	array 	$content 			Array containing the info about the message
+	 * @param	string	$suffixinfilename	When output is a file, append this suffix into default log filename. 	
 	 * @return	void
 	 */
-	public function export($content)
+	public function export($content, $suffixinfilename='')
 	{
-		$logfile = $this->getFilename();
+		$logfile = $this->getFilename($suffixinfilename);
 
 		if (defined("SYSLOG_FILE_NO_ERROR")) $filefd = @fopen($logfile, 'a+');
 		else $filefd = fopen($logfile, 'a+');
diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
index a8f862b52f4fa2a136f19903972db909581f1191..18e984858ed92ba1323dc6b57df3ab20024807be 100755
--- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
+++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
@@ -31,9 +31,11 @@ UPDATE llx_const set value='auguria_menu.php' where value='auguria_backoffice.ph
 UPDATE llx_const set value='auguria_menu.php' where value='auguria_frontoffice.php';
 UPDATE llx_const set value='smartphone_menu.php' where value='smartphone_backoffice.php';
 UPDATE llx_const set value='smartphone_menu.php' where value='smartphone_frontoffice.php';
-UPDATE llx_const set value='MAIN_INFO_SOCIETE_ADDRESS' where value='MAIN_INFO_SOCIETE_ADRESSE';
-UPDATE llx_const set value='MAIN_INFO_SOCIETE_TOWN' where value='MAIN_INFO_SOCIETE_VILLE';
-UPDATE llx_const set value='MAIN_INFO_SOCIETE_ZIP' where value='MAIN_INFO_SOCIETE_CP';
+UPDATE llx_const set name='MAIN_INFO_SOCIETE_ADDRESS' where name='MAIN_INFO_SOCIETE_ADRESSE';
+UPDATE llx_const set name='MAIN_INFO_SOCIETE_TOWN' where name='MAIN_INFO_SOCIETE_VILLE';
+UPDATE llx_const set name='MAIN_INFO_SOCIETE_ZIP' where name='MAIN_INFO_SOCIETE_CP';
+UPDATE llx_const set name='MAIN_INFO_SOCIETE_COUNTRY' where name='MAIN_INFO_SOCIETE_PAYS';
+UPDATE llx_const set name='MAIN_INFO_SOCIETE_STATE' where name='MAIN_INFO_SOCIETE_DEPARTEMENT';
 
 ALTER TABLE llx_user add COLUMN fk_user integer;
 
@@ -52,11 +54,14 @@ alter table llx_don      CHANGE COLUMN ville town text;
 alter table llx_don      CHANGE COLUMN prenom firstname varchar(50);
 alter table llx_don      CHANGE COLUMN nom lastname varchar(50);
 alter table llx_don 	 CHANGE COLUMN cp zip varchar(10);
+alter table llx_don      CHANGE COLUMN pays country varchar(50);
 alter table llx_adherent CHANGE COLUMN adresse address text;
 alter table llx_adherent CHANGE COLUMN nom lastname varchar(50);
 alter table llx_adherent CHANGE COLUMN prenom firstname varchar(50);
 alter table llx_adherent CHANGE COLUMN ville town text;
 alter table llx_adherent CHANGE COLUMN cp zip varchar(10);
+alter table llx_adherent CHANGE COLUMN pays country varchar(50);
+alter table llx_adherent CHANGE COLUMN fk_departement state_id varchar(50);
 alter table llx_mailing_cibles CHANGE COLUMN nom lastname varchar(50);
 alter table llx_mailing_cibles CHANGE COLUMN prenom firstname varchar(50);
 alter table llx_user     CHANGE COLUMN name lastname varchar(50);
@@ -68,6 +73,7 @@ alter table llx_socpeople  CHANGE COLUMN name lastname varchar(50);
 alter table llx_socpeople  CHANGE COLUMN ville town text;
 alter table llx_socpeople  CHANGE COLUMN cp zip varchar(10);
 alter table llx_bank_account CHANGE COLUMN adresse_proprio owner_address text;
+alter table llx_bank_account CHANGE COLUMN fk_departement state_id varchar(50);
 alter table llx_societe_rib CHANGE COLUMN adresse_proprio owner_address text;
 alter table llx_societe_address CHANGE COLUMN ville town text;
 alter table llx_societe_address CHANGE COLUMN cp zip varchar(10);
diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang
index f06ce5f6309cd8b02a9fedfa115549aa4b810954..ca47b924f5dc93501b9f854e4129df171caf7956 100644
--- a/htdocs/langs/en_US/paypal.lang
+++ b/htdocs/langs/en_US/paypal.lang
@@ -16,5 +16,5 @@ PAYPAL_CSS_URL=Optionnal Url of CSS style sheet on payment page
 ThisIsTransactionId=This is id of transaction: <b>%s</b>
 PAYPAL_ADD_PAYMENT_URL=Add the url of Paypal payment when you send a document by mail
 PAYPAL_IPN_MAIL_ADDRESS=E-mail address for the instant notification of payment (IPN)
-PredefinedMailContentLink=You can click on the secure link below to make your payment via PayPal\n\n%s\n\n
+PredefinedMailContentLink=You can click on the secure link below to make your payment (PayPal) if it is not already done.\n\n%s\n\n
 YouAreCurrentlyInSandboxMode=You are currently in the "sandbox" mode
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/paypal.lang b/htdocs/langs/fr_FR/paypal.lang
index 74d8a76804a9056ee9c01112d04c27d5d93cac1e..0567644a92db8eb21a8d595d285b3def78884fde 100644
--- a/htdocs/langs/fr_FR/paypal.lang
+++ b/htdocs/langs/fr_FR/paypal.lang
@@ -16,5 +16,5 @@ PAYPAL_CSS_URL=Url optionnelle de la feuille de style CSS de la page de paiement
 ThisIsTransactionId=Voici l'identifiant de la transaction: <b>%s</b>
 PAYPAL_ADD_PAYMENT_URL=Ajouter l'url de paiement Paypal lors de l'envoi d'un document par mail
 PAYPAL_IPN_MAIL_ADDRESS=Adresse e-mail pour les notifications instantanées de paiement (IPN)
-PredefinedMailContentLink=Vous pouvez cliquer sur le lien sécurisé ci-dessous pour effectuer votre paiement via Paypal\n\n%s\n\n
+PredefinedMailContentLink=Vous pouvez cliquer sur le lien sécurisé ci-dessous pour effectuer votre paiement (Paypal) si ce dernier n'a pas encore été fait.\n\n%s\n\n
 YouAreCurrentlyInSandboxMode=Vous êtes actuellement dans le mode "sandbox"
\ No newline at end of file
diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php
index d26d20059fcf27156a120bb70d3bf8aac904b8cc..580b729c8c3342c5a5184044fc66c2be677084dd 100644
--- a/htdocs/product/stock/class/entrepot.class.php
+++ b/htdocs/product/stock/class/entrepot.class.php
@@ -279,7 +279,6 @@ class Entrepot extends CommonObject
 	
 				include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
 	            $tmp=getCountry($this->country_id,'all');
-				$this->pays=$tmp['label'];                // deprecated
 				$this->country=$tmp['label'];
 				$this->country_code=$tmp['code'];
 	
diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php
index b8da31aa889841ab7ef3d8b4b9b95354ce3135f5..de0a8df9c7c93f116a358c29e58d6864abc5839c 100644
--- a/htdocs/product/stock/fiche-valo.php
+++ b/htdocs/product/stock/fiche-valo.php
@@ -81,7 +81,7 @@ if ($_GET["id"])
 	print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->town.'</td></tr>';
 
 	print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
-	print $entrepot->pays;
+	print $entrepot->country;
 	print '</td></tr>';
 
 	// Statut
diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php
index e3dac2b2e85b5f5591a6592a19e29b511730c49b..d61198c8183fa79c60b4b25fd37a49a4df4dbbbb 100644
--- a/htdocs/projet/tasks/index.php
+++ b/htdocs/projet/tasks/index.php
@@ -33,7 +33,7 @@ $langs->load('projects');
 $langs->load('users');
 
 $id=GETPOST('id','int');
-$search_product=GETPOST('search_product');
+$search_project=GETPOST('search_project');
 
 
 // Security check
@@ -85,7 +85,7 @@ $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$so
 
 // Get list of tasks in tasksarray and taskarrayfiltered
 // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him).
-$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_product);
+$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project);
 // We load also tasks limited to a particular user
 $tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');
 
@@ -106,7 +106,7 @@ print "</tr>\n";
 
 print '<tr class="liste_titre">';
 print '<td class="liste_titre">';
-print '<input type="text" class="flat" name="search_product" value="'.$search_product.'" size="8">';
+print '<input type="text" class="flat" name="search_project" value="'.$search_project.'" size="8">';
 print '</td>';
 print '<td class="liste_titre" colspan="5">';
 print '&nbsp;';
diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php
index beca4a88b56541eabeabf52d5f451bb1bb14dbfc..a5423468a2e005ef0a47348bdac4be8424f33343 100644
--- a/htdocs/public/members/public_card.php
+++ b/htdocs/public/members/public_card.php
@@ -93,7 +93,7 @@ if ($id > 0)
 		print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'&nbsp;</td></tr>';
 		print '<tr><td>'.$langs->trans("Address").'</td><td class="valeur">'.nl2br($object->address).'&nbsp;</td></tr>';
 		print '<tr><td>'.$langs->trans("Zip").' '.$langs->trans("Town").'</td><td class="valeur">'.$object->zip.' '.$object->town.'&nbsp;</td></tr>';
-		print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.$object->pays.'&nbsp;</td></tr>';
+		print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.$object->country.'&nbsp;</td></tr>';
 		print '<tr><td>'.$langs->trans("EMail").'</td><td class="valeur">'.$object->email.'&nbsp;</td></tr>';
 		print '<tr><td>'.$langs->trans("Birthday").'</td><td class="valeur">'.$object->naiss.'&nbsp;</td></tr>';
 
diff --git a/htdocs/public/paybox/paymentko.php b/htdocs/public/paybox/paymentko.php
index ec5c915b7896830264e718b8030a2333d291e52c..0b6635fa3903eabd813262511a3957e98fbb38fc 100644
--- a/htdocs/public/paybox/paymentko.php
+++ b/htdocs/public/paybox/paymentko.php
@@ -56,7 +56,11 @@ $langs->load("paypal");
  * View
  */
 
-dol_syslog("Callback url when a PayBox payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]));
+dol_syslog("Callback url when a PayBox payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_paybox');
+
+$tracepost = "";
+foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n";
+dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox');
 
 llxHeaderPayBox($langs->trans("PaymentForm"));
 
diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php
index 41fc96c19d6ad4692eecfcc9f4009f15093a11f5..d46ae4f33a71b2112c03e5a3aaf3ea98d1737159 100644
--- a/htdocs/public/paybox/paymentok.php
+++ b/htdocs/public/paybox/paymentok.php
@@ -55,7 +55,11 @@ $langs->load("paypal");
  * View
  */
 
-dol_syslog("Callback url when a PayBox payment was done. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]));
+dol_syslog("Callback url when a PayBox payment was done. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_paybox');
+
+$tracepost = "";
+foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n";
+dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox');
 
 llxHeaderPayBox($langs->trans("PaymentForm"));
 
diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php
index 3af51addec90c139d05597c7a686c5bc9979b163..610e68c93e399fa8fc0f81573e52331ffe0b8b53 100755
--- a/htdocs/public/paypal/paymentko.php
+++ b/htdocs/public/paypal/paymentko.php
@@ -64,7 +64,12 @@ $langs->load("paypal");
  * View
  */
 
-dol_syslog("Callback url when a PayPal payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]));
+dol_syslog("Callback url when a PayPal payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_paypal');
+
+$tracepost = "";
+foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n";
+dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paypal');
+
 
 llxHeaderPaypal($langs->trans("PaymentForm"));
 
diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php
index 3a0b56f62a1e96961907aca5d1b2c7c04ece372a..45cd6f460147614eba769e25d438fbc881ebf337 100755
--- a/htdocs/public/paypal/paymentok.php
+++ b/htdocs/public/paypal/paymentok.php
@@ -92,7 +92,12 @@ if (empty($PAYPAL_API_SIGNATURE))
  * View
  */
 
-dol_syslog("Callback url when a PayPal payment was done. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]));
+dol_syslog("Callback url when a PayPal payment was done. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_paypal');
+
+$tracepost = "";
+foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n";
+dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paypal');
+
 
 llxHeaderPaypal($langs->trans("PaymentForm"));
 
diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php
index fc275858e94f26ddb6f66ad4aba55b121c562a5a..d6539f917cca7b4075cd563aec98f56b99e20b6a 100644
--- a/htdocs/societe/agenda.php
+++ b/htdocs/societe/agenda.php
@@ -123,11 +123,11 @@ if ($socid)
 	print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->town."</td></tr>";
 
 	// Country
-	if ($soc->pays) {
+	if ($soc->country) {
 		print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
 		$img=picto_from_langcode($soc->country_code);
 		print ($img?$img.' ':'');
-		print $soc->pays;
+		print $soc->country;
 		print '</td></tr>';
 	}
 
diff --git a/htdocs/societe/ajaxcountries.php b/htdocs/societe/ajaxcountries.php
index f71da96fed4db21af0f992e677cfb37539e5fd88..82dda71e042242c32ab2bc9d6971db39ef14f1d2 100644
--- a/htdocs/societe/ajaxcountries.php
+++ b/htdocs/societe/ajaxcountries.php
@@ -65,12 +65,12 @@ if (! empty($country))
 	if ($resql)
 	{
 		print '<ul>';
-		while($pays = $db->fetch_object($resql))
+		while($country = $db->fetch_object($resql))
 		{
 			print '<li>';
 			// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
-			print ($pays->code && $langs->trans("Country".$pays->code)!="Country".$pays->code?$langs->trans("Country".$pays->code):($pays->libelle!='-'?$pays->libelle:'&nbsp;'));
-			print '<span class="informal" style="display:none">'.$pays->rowid.'-idcache</span>';
+			print ($country->code && $langs->trans("Country".$country->code)!="Country".$country->code?$langs->trans("Country".$country->code):($country->libelle!='-'?$country->libelle:'&nbsp;'));
+			print '<span class="informal" style="display:none">'.$country->rowid.'-idcache</span>';
 			print '</li>';
 		}
 		print '</ul>';
diff --git a/htdocs/societe/canvas/company/actions_card_company.class.php b/htdocs/societe/canvas/company/actions_card_company.class.php
index 2fdfe9e744e74d4926aa29132dc19a1a26cde8c2..13ad2739efc09d8e092e765d3650dad2f1bd000b 100644
--- a/htdocs/societe/canvas/company/actions_card_company.class.php
+++ b/htdocs/societe/canvas/company/actions_card_company.class.php
@@ -154,7 +154,7 @@ class ActionsCardCompany extends ActionsCardCommon
 				}
 				else
 				{
-					$this->tpl['tva_intra'] =  $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->object->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
+					$this->tpl['tva_intra'] =  $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
 				}
 			}
 			else
@@ -193,7 +193,7 @@ class ActionsCardCompany extends ActionsCardCommon
 					}
 					else
 					{
-						$this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->object->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
+						$this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
 					}
 				}
 				else
diff --git a/htdocs/societe/class/address.class.php b/htdocs/societe/class/address.class.php
index 911a69c710cde7cc956865307880eed8d68fb94b..4c3e7cc45ae7fb57dde58e100cf99bbdc0e94701 100644
--- a/htdocs/societe/class/address.class.php
+++ b/htdocs/societe/class/address.class.php
@@ -375,8 +375,6 @@ class Address
 				$this->note				= $obj->note;
 
 				// deprecated
-				$this->pays_code		= $this->country_code;
-				$this->pays				= $this->country;
 				$this->tel				= $this->phone;
 
 				$result = 1;
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 73395fdec1e828e4d98fadda8da7bdd11e8751e3..8d39c99462c89acf755830751a9523b11cec8c32 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -2500,11 +2500,11 @@ class Societe extends CommonObject
     	   
     	// We define country_id, country_code and country
     	$country_id=$country_code=$country_label='';
-    	if (! empty($conf->global->MAIN_INFO_SOCIETE_PAYS))
+    	if (! empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY))
     	{
-    		$tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_PAYS);
+    		$tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_COUNTRY);
     		$country_id=$tmp[0];
-    		if (! empty($tmp[1]))   // If $conf->global->MAIN_INFO_SOCIETE_PAYS is "id:code:label"
+    		if (! empty($tmp[1]))   // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label"
     		{
     			$country_code=$tmp[1];
     			$country_label=$tmp[2];
@@ -2521,7 +2521,6 @@ class Societe extends CommonObject
     	$this->country_code=$country_code;
     	$this->country=$country_label;
     	if (is_object($langs)) $this->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label;
-    	$this->pays=$this->country;    	// TODO deprecated
 
     	$this->tel=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL;   // TODO deprecated
     	$this->phone=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL;
diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php
index ca21354e8e3791d18e05129c6e687cced98bc5e4..5f0f7af2410f0c247f1ca1ed947bad29ac10f8b9 100644
--- a/htdocs/societe/commerciaux.php
+++ b/htdocs/societe/commerciaux.php
@@ -37,6 +37,7 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:'';
 if ($user->societe_id) $socid=$user->societe_id;
 $result = restrictedArea($user, 'societe','','');
 
+$hookmanager->initHooks(array('salesrepresentativescard'));
 
 /*
  *	Actions
@@ -44,12 +45,22 @@ $result = restrictedArea($user, 'societe','','');
 
 if($_GET["socid"] && $_GET["commid"])
 {
+	$action = 'add';
+	
 	if ($user->rights->societe->creer)
 	{
+
 		$soc = new Societe($db);
 		$soc->id = $_GET["socid"];
 		$soc->fetch($_GET["socid"]);
-		$soc->add_commercial($user, $_GET["commid"]);
+
+	
+		$parameters=array('id'=>$_GET["commid"]);
+		$reshook=$hookmanager->executeHooks('doActions',$parameters,$soc,$action);    // Note that $action and $object may have been modified by some hooks
+		$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors);		
+
+
+		if (empty($reshook)) $soc->add_commercial($user, $_GET["commid"]);
 
 		header("Location: commerciaux.php?socid=".$soc->id);
 		exit;
@@ -63,12 +74,20 @@ if($_GET["socid"] && $_GET["commid"])
 
 if($_GET["socid"] && $_GET["delcommid"])
 {
+	$action = 'delete';	
+	
 	if ($user->rights->societe->creer)
 	{
 		$soc = new Societe($db);
 		$soc->id = $_GET["socid"];
 		$soc->fetch($_GET["socid"]);
-		$soc->del_commercial($user, $_GET["delcommid"]);
+		
+		$parameters=array('id'=>$_GET["delcommid"]);
+		$reshook=$hookmanager->executeHooks('doActions',$parameters,$soc,$action);    // Note that $action and $object may have been modified by some hooks
+		$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors);		
+		
+		
+		if (empty($reshook)) $soc->del_commercial($user, $_GET["delcommid"]);
 
 		header("Location: commerciaux.php?socid=".$soc->id);
 		exit;
@@ -96,6 +115,8 @@ if ($_GET["socid"])
 	$soc->id = $_GET["socid"];
 	$result=$soc->fetch($_GET["socid"]);
 
+	$action='view';
+	
 	$head=societe_prepare_head2($soc);
 
 	dol_fiche_head($head, 'salesrepresentative', $langs->trans("ThirdParty"),0,'company');
@@ -128,7 +149,7 @@ if ($_GET["socid"])
 	print '<tr><td>'.$langs->trans('Zip').'</td><td width="20%">'.$soc->zip."</td>";
 	print '<td>'.$langs->trans('Town').'</td><td>'.$soc->town."</td></tr>";
 
-	print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$soc->pays.'</td>';
+	print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$soc->country.'</td>';
 
 	print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->tel,$soc->country_code,0,$soc->id,'AC_TEL').'</td>';
 	print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->country_code,0,$soc->id,'AC_FAX').'</td></tr>';
@@ -158,6 +179,13 @@ if ($_GET["socid"])
 		{
 			$obj = $db->fetch_object($resql);
 
+ 			$parameters=array('socid'=>$soc->id);
+        	$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$obj,$action);    // Note that $action and $object may have been modified by hook
+      		if (empty($reshook)) {
+      			
+				null; // actions in normal case
+      		}
+
 			print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
 			print img_object($langs->trans("ShowUser"),"user").' ';
 			print $obj->firstname." " .$obj->name."\n";
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 6ddb35b270b84fe714481bb90b5310adb6c63cf3..1908e145b2e52cd1a15dd8875fd0e4d4d7416a51 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -894,7 +894,7 @@ else
             }
             else
             {
-                $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
+                $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
             }
         }
         print $s;
@@ -1339,7 +1339,7 @@ else
                 }
                 else
                 {
-                    $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
+                    $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
                 }
             }
             print $s;
@@ -1673,7 +1673,7 @@ else
                 }
                 else
                 {
-                    $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
+                    $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
                 }
             }
             print $s;
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 84d9f147d054a50e3c960b47aa24f3a4dd1fa3b0..e0abb1e71fccb5116afbfbff053765e01c9b7415 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -1874,7 +1874,7 @@ div.titre {
 	font-weight: bold;
 	color: rgb(<?php print $colortext; ?>);
 	text-decoration: none;
-	text-shadow: 1px 1px 2px #FFFFfF;
+	text-shadow: 1px 1px 2px #FFFFFF;
 }
 
 #dolpaymenttable { width: 600px; font-size: 13px; }
diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php
index fefb218114b0c86729bdcc4ae7e85fc02141f728..c10c4183468e333e7a9dddd0ef7ec6b1ab01e370 100644
--- a/htdocs/webservices/server_contact.php
+++ b/htdocs/webservices/server_contact.php
@@ -533,10 +533,8 @@ function getContactsForThirdParty($authentication,$idthirdparty)
 				'state_code' => $contact->state_code?$contact->state_code:'',
 				'state' => $contact->state?$contact->state:'',
 				
-				'fk_pays' => $contact->fk_pays?$contact->fk_pays:'',
 				'country_id' => $contact->country_id?$contact->country_id:'',
 				'country_code' => $contact->country_code?$contact->country_code:'',
-				'pays' => $contact->pays?$contact->pays:'',
 				'country' => $contact->country?$contact->country:'',
 				
 				'socid' => $contact->socid?$contact->socid:'',
diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php
index 91feba6bddf9f830009ced93f91f028498bbb142..91b70713914ab2cc98bbea0911963c2dcec78e2c 100755
--- a/scripts/members/sync_members_ldap2dolibarr.php
+++ b/scripts/members/sync_members_ldap2dolibarr.php
@@ -196,7 +196,6 @@ if ($result >= 0)
 			$member->address=$ldapuser[$conf->global->LDAP_FIELD_ADDRESS];
 			$member->zip=$ldapuser[$conf->global->LDAP_FIELD_ZIP];
 			$member->town=$ldapuser[$conf->global->LDAP_FIELD_TOWN];
-			$member->pays=$ldapuser[$conf->global->LDAP_FIELD_COUNTRY];	     // deprecated
 			$member->country=$ldapuser[$conf->global->LDAP_FIELD_COUNTRY];
 			$member->country_id=$countries[$hashlib2rowid[strtolower($member->country)]]['rowid'];
 			$member->country_code=$countries[$hashlib2rowid[strtolower($member->country)]]['code'];
diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php
index 07c7703605a67a61fd990e5dd48ce4b255d8b44d..a0ee0efac83053c8bb01e13920656a9c54ebb48c 100644
--- a/test/phpunit/AdherentTest.php
+++ b/test/phpunit/AdherentTest.php
@@ -282,7 +282,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
 
         $template = '%DOL_MAIN_URL_ROOT%,%ID%,%CIVILITE%,%FIRSTNAME%,%LASTNAME%,%FULLNAME%,%COMPANY%,'.
                     '%ADDRESS%,%ZIP%,%TOWN%,%COUNTRY%,%EMAIL%,%NAISS%,%PHOTO%,%LOGIN%,%PASSWORD%,%PRENOM%,'.
-                    '%NOM%,%SOCIETE%,%ADDRESS%,%CP%,%TOWN%,%PAYS%';
+                    '%NOM%,%SOCIETE%,%ADDRESS%,%ZIP%,%TOWN%,%COUNTRY%';
 
         $expected = DOL_MAIN_URL_ROOT.','.$localobject->id.',0,New firstname,New name,New firstname New name,'.
                     'New company,New address,New zip,New town,Belgium,newemail@newemail.com,'.dol_print_date($localobject->naiss,'day').',,'.