diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 219cd85c2fe5f7a9d1d50febe1f2a17fc3a446e3..03cce1dff096645b5c8f0076e638d36bcd7e2d66 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -86,8 +86,8 @@ if ($action == 'update' && empty($_POST["cancel"]))
 
 // Actions to send emails
 $id=0;
-$actiontypecode='';
-$trigger_name='';
+$actiontypecode='';     // Not an event for agenda
+$trigger_name='';       // Disable triggers
 $paramname='id';
 $mode='emailfortest';
 $trackid=(($action == 'testhtml')?"testhtml":"test");
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 0ee995e478432fe5140e995ed5486be014cc6c78..df86464281ae22f5bc4404905988842d82b140b6 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -644,7 +644,7 @@ if (empty($reshook))
 	 */
 
 	// Actions to send emails
-	$actiontypecode='AC_PROP';
+    $actiontypecode='AC_OTH_AUTO';
 	$trigger_name='PROPAL_SENTBYMAIL';
 	$paramname='id';
 	$mode='emailfromproposal';
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 07f25b40ed89a86e43aec46433c1a9a5d797b743..fe91f0b6ff85265187363d18b7322ad9eda4c1df 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1259,7 +1259,6 @@ if (empty($reshook))
 
 
 	// Actions to send emails
-	$actiontypecode='AC_COM';
 	$trigger_name='ORDER_SENTBYMAIL';
 	$paramname='id';
 	$mode='emailfromorder';
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 02b67c814efed103b9bc564f7e4ecb2e1c7ee3aa..4835b53b277a4a0c507890b498ae44bdf2b6d094 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -1911,7 +1911,6 @@ if (empty($reshook))
 
 	// Actions to send emails
 	if (empty($id)) $id=$facid;
-	$actiontypecode='AC_FAC';
 	$trigger_name='BILL_SENTBYMAIL';
 	$paramname='id';
 	$mode='emailfrominvoice';
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 0e0f8c84090f10536f561442650510645224733f..f00816e9d4b862a5518b48fecec775a57bb7fb15 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -953,7 +953,6 @@ if (empty($reshook))
 	 */
 
 	// Actions to send emails
-	$actiontypecode='AC_CONT';
 	$trigger_name='CONTRACT_SENTBYMAIL';
 	$paramname='id';
 	$mode='emailfromcontract';
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 58e47a29ec86a81b9d8f169c8712d2c1241325e5..92d1011b92350f3c97313402984a5e871b9bd44c 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -274,12 +274,12 @@ if (! $error && $massaction == 'confirm_presend')
                         // Insert logs into agenda
                         foreach($listofqualifiedinvoice as $invid => $object)
                         {
-                            if ($objectclass == 'Propale') $actiontypecode='AC_PROP';
+                            /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP';
                             if ($objectclass == 'Commande') $actiontypecode='AC_COM';
                             if ($objectclass == 'Facture') $actiontypecode='AC_FAC';
                             if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO';
                             if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD';
-                            if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';
+                            if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/
                             
                             $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
                             if ($message)
@@ -289,10 +289,10 @@ if (! $error && $massaction == 'confirm_presend')
                                 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
                                 $actionmsg = dol_concatdesc($actionmsg, $message);
                             }
-
+                            $actionmsg2='';
+                            
                             // Initialisation donnees
                             $object->sendtoid		= 0;
-                            $object->actiontypecode	= $actiontypecode;
                             $object->actionmsg		= $actionmsg;  // Long text
                             $object->actionmsg2		= $actionmsg2; // Short text
                             $object->fk_element		= $invid;
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index cf50d05d6bf1b30790d7334aef21b37ec0caba7f..dded23e6cbf718c35684090e3aeda35acbd6bb1b 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -23,11 +23,11 @@
 
 // $mysoc must be defined
 // $id must be defined
-// $actiontypecode must be defined
 // $paramname must be defined
 // $mode must be defined
-// $object and $uobject may be defined.
-
+// $trigger_name must be set (can be '')
+// $actiontypecode can be set
+// $object and $uobject may be defined
 
 /*
  * Add file in email form
@@ -155,7 +155,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 				}
 			}
 		}
-		else dol_print_error('','Use actions_sendmails.in.php for a type that is not supported');
+		else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported');
 	}
 	else $thirdparty = $mysoc;
 
@@ -347,7 +347,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 				{
 					$error=0;
 
-					// FIXME This must be moved into a trigger for action $trigger_name
+					// FIXME This must be moved into the trigger for action $trigger_name
 					if (! empty($conf->dolimail->enabled))
 					{
 						$mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0);	// Original mail id is set ?
@@ -370,21 +370,26 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 					// Initialisation of datas
 					if (is_object($object))
 					{
-						$object->socid			= $sendtosocid;	// To link to a company
-						$object->sendtoid		= $sendtoid;	// To link to contacts/addresses. This is an array.
-						$object->actiontypecode	= $actiontypecode;
-						$object->actionmsg		= $actionmsg;  // Long text
-						$object->actionmsg2		= $actionmsg2; // Short text
+					    if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically
+					    
+						$object->socid			= $sendtosocid;	   // To link to a company
+						$object->sendtoid		= $sendtoid;	   // To link to contacts/addresses. This is an array.
+						$object->actiontypecode	= $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
+						$object->actionmsg		= $actionmsg;      // Long text
+						$object->actionmsg2		= $actionmsg2;     // Short text
 						$object->trackid        = $trackid;
 						$object->fk_element		= $object->id;
 						$object->elementtype	= $object->element;
 
 						// Call of triggers
-						include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
-						$interface=new Interfaces($db);
-						$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
-						if ($result < 0) {
-							$error++; $errors=$interface->errors;
+						if (! empty($trigger_name))
+						{
+    						include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+    						$interface=new Interfaces($db);
+    						$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
+    						if ($result < 0) {
+    							$error++; $errors=$interface->errors;
+    						}
 						}
 					}
 						
@@ -398,8 +403,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 						// This avoid sending mail twice if going out and then back to page
 						$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
 						setEventMessages($mesg, null, 'mesgs');
-						if ($conf->dolimail->enabled) header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id.'&'.($paramname2?$paramname2:'mid').'='.$parm2val);
-						else header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id);
+						if ($conf->dolimail->enabled) 
+						{
+						    header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val);
+						    exit;
+						}
+						header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:''));
 						exit;
 					}
 				}
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 020382095a35f7f110a92546eadb9a170e593935..3641ac87cef5441d48dcf1a63ee4a200ad2ae303 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -297,7 +297,7 @@ class FormMail extends Form
         	$arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
 			//var_dump($arraydefaultmessage);
 
-        	$out.= "\n<!-- Begin form mail -->\n";
+        	$out.= "\n".'<!-- Begin form mail --><div id="mailformdiv"></div>'."\n";
         	if ($this->withform == 1)
         	{
         		$out.= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'#formmail">'."\n";
diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php
index 2cea718dcc0c0da9a30d956180eb07a5badf8845..f48974acb02bccf6f9da3d526f8a1f007ff883bb 100644
--- a/htdocs/core/lib/usergroups.lib.php
+++ b/htdocs/core/lib/usergroups.lib.php
@@ -145,7 +145,7 @@ function user_prepare_head($object)
     {
 		// Bank
     	$head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id;
-    	$head[$h][1] = $langs->trans("BankAccounts");
+    	$head[$h][1] = $langs->trans("HR");
     	$head[$h][2] = 'bank';
     	$h++;
 	}
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index 9da1ada59adc54c96bdbc97d0e0a761fd70b03d7..1160fb2625d9b6cc9ad2513f2b5ba5dc57f2b3df 100644
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -76,6 +76,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
 
 		$langs->load("agenda");
 
+		if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
+
 		// Actions
 		if ($action == 'COMPANY_CREATE')
         {
@@ -83,7 +85,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("companies");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
             $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
             if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
@@ -97,7 +98,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("orders");
 
-            if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
 
             // Parameters $object->sendtoid defined by caller
@@ -109,7 +109,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("contracts");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
 
@@ -121,7 +120,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("propal");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
 
@@ -133,7 +131,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("propal");
 
-            $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
             if (empty($object->actionmsg))
             {
@@ -149,7 +146,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("propal");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
 
@@ -161,7 +157,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("propal");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
 
@@ -173,7 +168,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("propal");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
 
@@ -184,7 +178,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("agenda");
             $langs->load("orders");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
 
@@ -196,7 +189,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("orders");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
 
@@ -208,7 +200,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("orders");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
 
@@ -220,7 +211,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("orders");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
 
@@ -232,7 +222,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("orders");
 
-            $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref);
             if (empty($object->actionmsg))
             {
@@ -248,7 +237,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("bills");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
 
@@ -260,7 +248,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("bills");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
 
@@ -272,7 +259,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("bills");
 
-            $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
             if (empty($object->actionmsg))
             {
@@ -289,7 +275,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("bills");
 
             // Values for this action can't be defined by caller.
-			$object->actiontypecode='AC_OTH_AUTO';
             $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
 
@@ -301,7 +286,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("bills");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
 
@@ -313,7 +297,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("interventions");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
 
@@ -327,7 +310,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("interventions");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
 
@@ -341,7 +323,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("interventions");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
 
@@ -355,7 +336,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("interventions");
 
-            $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
             $object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
 
@@ -368,7 +348,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("interventions");
 
-            $object->actiontypecode='AC_OTH_AUTO';
            	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
            	$object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
 
@@ -380,7 +359,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("interventions");
 
-            $object->actiontypecode='AC_OTH_AUTO';
            	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
            	$object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
 
@@ -392,7 +370,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("interventions");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
 
@@ -406,7 +383,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("sendings");
 
-        	$object->actiontypecode='AC_OTH_AUTO';
         	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
         	if (empty($object->actionmsg))
         	{
@@ -422,7 +398,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("sendings");
 
-            $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref);
             if (empty($object->actionmsg))
             {
@@ -438,7 +413,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("orders");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
 
@@ -450,7 +424,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("orders");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
 
@@ -462,7 +435,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 		    $langs->load("other");
 			$langs->load("orders");
 
-			$object->actiontypecode='AC_OTH_AUTO';
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
 
@@ -474,7 +446,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 		    $langs->load("other");
 			$langs->load("orders");
 
-			$object->actiontypecode='AC_OTH_AUTO';
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
 
@@ -486,7 +457,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("orders");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
 
@@ -498,7 +468,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("orders");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
 
@@ -511,7 +480,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("bills");
             $langs->load("orders");
 
-            $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
             if (empty($object->actionmsg))
             {
@@ -528,7 +496,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("bills");
             $langs->load("orders");
 
-            $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
             if (empty($object->actionmsg))
             {
@@ -543,7 +510,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("bills");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
 
@@ -555,7 +521,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("bills");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
 
@@ -568,7 +533,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("bills");
             $langs->load("orders");
 
-            $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
             if (empty($object->actionmsg))
             {
@@ -584,7 +548,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("bills");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
 
@@ -596,7 +559,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("bills");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
 
@@ -610,7 +572,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("members");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
@@ -624,7 +585,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("members");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
@@ -638,7 +598,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("members");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
@@ -654,7 +613,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("members");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
@@ -668,7 +626,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("members");
 
-			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
@@ -684,7 +641,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
         	$langs->load("projects");
 
-        	$object->actiontypecode='AC_OTH_AUTO';
         	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
         	$object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
         	$object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
@@ -696,8 +652,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("projects");
         
-            $object->actiontypecode='AC_OTH_AUTO';
-        
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
@@ -709,7 +663,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
             $langs->load("other");
             $langs->load("projects");
         
-            $object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
             $object->actionmsg=$langs->transnoentities("ProjectModifieddInDolibarr",$object->ref);
             $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
@@ -723,8 +676,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 		    $langs->load("other");
 			$langs->load("projects");
 
-			$object->actiontypecode='AC_OTH_AUTO';
-
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
 			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
@@ -737,7 +688,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 		    $langs->load("other");
 			$langs->load("projects");
 
-			$object->actiontypecode='AC_OTH_AUTO';
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref);
 			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
@@ -750,7 +700,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 		    $langs->load("other");
 			$langs->load("projects");
 
-			$object->actiontypecode='AC_OTH_AUTO';
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
 			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
@@ -763,7 +712,6 @@ class InterfaceActionsAuto extends DolibarrTriggers
 		    $langs->load("agenda");
 		    $langs->load("other");
 		    
-		    $object->actiontypecode='AC_OTH_AUTO';
 		    if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref);
 		    $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref);
 		    
@@ -805,7 +753,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
 		// Insertion action
 		require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
 		$actioncomm = new ActionComm($this->db);
-		$actioncomm->type_code   = $object->actiontypecode;		// code of parent table llx_c_actioncomm (will be deprecated)
+		$actioncomm->type_code   = $object->actiontypecode;		// Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
 		$actioncomm->code        = 'AC_'.$action;
 		$actioncomm->label       = $object->actionmsg2;
 		$actioncomm->note        = $object->actionmsg;          // TODO Replace with $actioncomm->email_msgid ? $object->email_content : $object->actionmsg
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index a0280ce9e397498f3da29c9cee14df132ab6b2ba..fdd477cc63d9d4afc562549e711572cb9006d79e 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -595,7 +595,6 @@ if (empty($reshook))
 
 	// Actions to send emails
 	if (empty($id)) $id=$facid;
-	$actiontypecode='AC_SHIP';
 	$trigger_name='SHIPPING_SENTBYMAIL';
 	$paramname='id';
 	$mode='emailfromshipment';
diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php
index 91e094c1a5036a4c54decf55141e81f21bafc324..51cd5a62d3f59b1f6a494a97eab424a81748dec9 100644
--- a/htdocs/fichinter/card.php
+++ b/htdocs/fichinter/card.php
@@ -719,8 +719,6 @@ if (empty($reshook))
 	 */
 
 	// Actions to send emails
-	$actiontypecode='AC_OTH_AUTO';
-	$trigger_name='FICHINTER_SENTBYMAIL';
 	$paramname='id';
 	$mode='emailfromintervention';
 	$trackid='int'.$object->id;
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 378fab9f50c754078ec029774d8ffce41eb5612a..a6f0cc248f182f495ad4154493cb0f5b32cb6abf 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -1154,7 +1154,6 @@ if (empty($reshook))
 	 */
 
 	// Actions to send emails
-	$actiontypecode='AC_SUP_ORD';
 	$trigger_name='ORDER_SUPPLIER_SENTBYMAIL';
 	$paramname='id';
 	$mode='emailfromsupplierorder';
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index bda155efe880007cf0eb40b340ec389e63889335..04e6ea98481bd41e2f4969e5786ea8fbf3336c1c 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -1188,7 +1188,6 @@ if (empty($reshook))
 	 */
 
 	// Actions to send emails
-	$actiontypecode='AC_SUP_INV';
 	$trigger_name='BILL_SUPPLIER_SENTBYMAIL';
 	$paramname='id';
 	$mode='emailfromsupplierinvoice';
diff --git a/htdocs/install/mysql/data/llx_c_actioncomm.sql b/htdocs/install/mysql/data/llx_c_actioncomm.sql
index 2b84ee6ff82af79c6e16d85f02c60c735408befc..6b89ed74dd2814eadd70b17a883bab379c6ee9a9 100644
--- a/htdocs/install/mysql/data/llx_c_actioncomm.sql
+++ b/htdocs/install/mysql/data/llx_c_actioncomm.sql
@@ -38,12 +38,12 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position)
 insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 5,'AC_RDV','system','Rendez-vous',NULL, 1, 1);
 insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values (11,'AC_INT','system','Intervention on site',NULL, 1, 4);
 -- Code kept for backward compatibility < 3.3 
-insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 3,'AC_PROP','systemauto', 'Send commercial proposal by email','propal',0,10);
-insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 8,'AC_COM','systemauto','Send customer order by email','order', 0,8);
-insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 9,'AC_FAC','systemauto', 'Send customer invoice by email','invoice',0,6);
-insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 10,'AC_SHIP','systemauto', 'Send shipping by email','shipping',0,11);
-insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 30,'AC_SUP_ORD','systemauto','Send supplier order by email','order_supplier',0,9);
-insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 31,'AC_SUP_INV','systemauto','Send supplier invoice by email','invoice_supplier',0,7);
+--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 3,'AC_PROP','systemauto', 'Send commercial proposal by email','propal',0,10);
+--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 8,'AC_COM','systemauto','Send customer order by email','order', 0,8);
+--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 9,'AC_FAC','systemauto', 'Send customer invoice by email','invoice',0,6);
+--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 10,'AC_SHIP','systemauto', 'Send shipping by email','shipping',0,11);
+--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 30,'AC_SUP_ORD','systemauto','Send supplier order by email','order_supplier',0,9);
+--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 31,'AC_SUP_INV','systemauto','Send supplier invoice by email','invoice_supplier',0,7);
 -- Code used from 3.3+ when type of event is not used
 insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 40,'AC_OTH_AUTO','systemauto','Other (automatically inserted events)',NULL, 1, 20);
 insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 50,'AC_OTH','system','Other (manually inserted events)',NULL, 1, 5);
diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
index 6ba7707b249ce1c29e06a7b3b02a44566c79e819..725eca55daa0db23277c71bb4dcd7055dc81e443 100644
--- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
+++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
@@ -296,7 +296,6 @@ ALTER TABLE llx_events MODIFY COLUMN ip varchar(250);
 
 ALTER TABLE llx_facture ADD COLUMN fk_fac_rec_source integer;
 
-
-
+DELETE from llx_c_actioncomm where code in ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV') AND id NOT IN (SELECT DISTINCT fk_action FROM llx_actioncomm);
 
 
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 79927cc888ccfdb47859bf66e101bbc1914a2dc4..a5f2ddf1e7eceaaa83bdecda996af01effeacd2c 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -771,6 +771,7 @@ ModuleBuilder=Module Builder
 SetMultiCurrencyCode=Set currency
 BulkActions=Bulk actions
 ClickToShowHelp=Click to show tooltip help
+HR=HR
 # Week day
 Monday=Monday
 Tuesday=Tuesday
diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php
index 5a53a2c6ed27b05ae5010cdf7d2272efb04b2ee4..14e8e4b4679dbc5f7e9a8d554f03c7dc882a76d6 100644
--- a/htdocs/societe/card.php
+++ b/htdocs/societe/card.php
@@ -750,7 +750,6 @@ if (empty($reshook))
 
     // Actions to send emails
     $id=$socid;
-    $actiontypecode='AC_OTH_AUTO';
     $trigger_name='COMPANY_SENTBYMAIL';
     $paramname='socid';
     $mode='emailfromthirdparty';
diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php
index d36b471a721217f48be492c4de4a63772e86b77e..86c350ecc224f31da41e8785b95629a80b0c8252 100644
--- a/htdocs/supplier_proposal/card.php
+++ b/htdocs/supplier_proposal/card.php
@@ -466,7 +466,6 @@ if (empty($reshook))
 	include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
 
 	// Actions to send emails
-	$actiontypecode='AC_ASKPRICE';
 	$trigger_name='SUPPLIER_PROPOSAL_SENTBYMAIL';
 	$paramname='id';
 	$mode='emailfromsupplierproposal';
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 66f880da78684d0d59ad3faa50aed02d80667c44..4ae7d400a09a07b266bc6b198739cde13842707c 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -1101,6 +1101,7 @@ div.nopadding {
 	padding-top: 1px;
 	padding-bottom: 1px;
 	width: 44px;
+	text-align:center;
 }
 div.attacharea {
 	padding-top: 18px;
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 04732ef03050de2c2227b62119871fe5201e559a..2beef147c02132d79fc89836c6c4398b44da490e 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -1145,6 +1145,7 @@ img.hideonsmartphone.pictoactionview {
 	padding-top: 1px;
 	padding-bottom: 1px;
 	width: 44px;
+	text-align:center;
 }
 div.attacharea {
 	padding-top: 18px;
@@ -3054,7 +3055,7 @@ div.info {
   -moz-border-radius: 4px;
   -webkit-border-radius: 4px;
   border-radius: 4px;
-  background: #EaE4Ea;
+  background: #868;
   text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
 }
 
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index d98ef682e90cb5f7d34fbbecb12e82e5a30373fa..9249e8f295efe3d1a4f4b99cfca78fcef8a97681 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -593,7 +593,6 @@ if (empty($reshook)) {
     }
 		
     // Actions to send emails
-    $actiontypecode='AC_OTH_AUTO';
     $trigger_name='USER_SENTBYMAIL';
     $paramname='id';    // Name of param key to open the card
     $mode='emailfromuser';
@@ -1005,14 +1004,6 @@ if (($action == 'create') || ($action == 'adduserldap'))
     }
     print '</td></tr>';
 
-    // Signature
-    print '<tr><td class="tdtop">'.$langs->trans("Signature").'</td>';
-    print '<td>';
-    require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor=new DolEditor('signature',GETPOST('signature'),'',138,'dolibarr_mailings','In',true,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%');
-    print $doleditor->Create(1);
-    print '</td></tr>';
-
     // Multicompany
     if (! empty($conf->multicompany->enabled))
     {
@@ -1028,6 +1019,15 @@ if (($action == 'create') || ($action == 'adduserldap'))
         }
     }
 
+    // Accountancy code
+    if ($conf->accounting->enabled)
+    {
+        print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
+        print '<td>';
+        print '<input size="30" type="text" name="accountancy_code" value="'.GETPOST('accountancy_code').'">';
+        print '</td></tr>';
+    }
+    
     // Hierarchy
     print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>';
     print '<td>';
@@ -1035,7 +1035,8 @@ if (($action == 'create') || ($action == 'adduserldap'))
     print '</td>';
     print "</tr>\n";
 
-	if ($conf->salaries->enabled && ! empty($user->rights->salaries->read))
+    if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
+       || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
 	{
 		$langs->load("salaries");
 
@@ -1081,15 +1082,6 @@ if (($action == 'create') || ($action == 'adduserldap'))
 	print '</td>';
     print "</tr>\n";
 
-	// Accountancy code
-	if ($conf->accounting->enabled)
-	{
-		print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
-		print '<td>';
-		print '<input size="30" type="text" name="accountancy_code" value="'.GETPOST('accountancy_code').'">';
-		print '</td></tr>';
-	}
-
 	// User color
 	if (! empty($conf->agenda->enabled))
 	{
@@ -1108,6 +1100,14 @@ if (($action == 'create') || ($action == 'adduserldap'))
 			null, '90%' );
 		print "</td></tr>";
 	}
+
+    // Other attributes
+    $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
+    $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
+    if (empty($reshook) && ! empty($extrafields->attribute_label))
+    {
+    	print $object->showOptionals($extrafields,'edit');
+    }
 	
     // Note
     print '<tr><td class="tdtop">';
@@ -1118,15 +1118,15 @@ if (($action == 'create') || ($action == 'adduserldap'))
     $doleditor->Create();
     print "</td></tr>\n";
 
-    // Other attributes
-    $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
-    $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-    if (empty($reshook) && ! empty($extrafields->attribute_label))
-    {
-    	print $object->showOptionals($extrafields,'edit');
-    }
-
- 	print "</table>\n";
+    // Signature
+    print '<tr><td class="tdtop">'.$langs->trans("Signature").'</td>';
+    print '<td>';
+    require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+    $doleditor=new DolEditor('signature',GETPOST('signature'),'',138,'dolibarr_mailings','In',true,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%');
+    print $doleditor->Create(1);
+    print '</td></tr>';
+    
+    print "</table>\n";
 
  	dol_fiche_end();
 
@@ -1379,11 +1379,15 @@ else
             	print '</td></tr>'."\n";
             }
 
-            // Signature
-            print '<tr><td class="tdtop">'.$langs->trans('Signature').'</td><td>';
-            print dol_htmlentitiesbr($object->signature);
-            print "</td></tr>\n";
-
+            // Accountancy code
+            if ($conf->accounting->enabled)
+            {
+                print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
+                print '<td>'.$object->accountancy_code.'</td></tr>';
+            }
+            
+            // TODO Move this into RH Tab (visible if RH module on)
+            
             // Hierarchy
             print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>';
             print '<td>';
@@ -1396,7 +1400,8 @@ else
             print '</td>';
             print "</tr>\n";
 
-            if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
+            if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
+                || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
             {
             	$langs->load("salaries");
 
@@ -1435,13 +1440,6 @@ else
 		    print '</td>';
 		    print "</tr>\n";
 
-			// Accountancy code
-			if ($conf->accounting->enabled)
-			{
-				print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
-				print '<td>'.$object->accountancy_code.'</td>';
-			}
-
 		    // Date employment
 		    print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
 		    print '<td>';
@@ -1449,7 +1447,7 @@ else
 		    print '</td>';
 		    print "</tr>\n";
 
-			print '</table>';
+		    print '</table>';
 
 	        print '</div>';
 	        print '<div class="fichehalfright"><div class="ficheaddleft">';
@@ -1567,7 +1565,12 @@ else
                 print '</tr>'."\n";
             }
 
-			print "</table>\n";
+            // Signature
+            print '<tr><td class="tdtop">'.$langs->trans('Signature').'</td><td>';
+            print dol_htmlentitiesbr($object->signature);
+            print "</td></tr>\n";
+
+            print "</table>\n";
 			print '</div>';
 
         	print '</div></div>';
@@ -1772,586 +1775,574 @@ else
     
                 dol_fiche_end();
             }
-        }
-
-        if (GETPOST('action','aZ09') != 'presend' && GETPOST('action','aZ09') != 'send')
-        {
-            /*
-             * List of groups of user
-             */
 
-            if ($canreadgroup)
+            if (GETPOST('action','aZ09') != 'presend' && GETPOST('action','aZ09') != 'send')
             {
-                print load_fiche_titre($langs->trans("ListOfGroupsForUser"),'','');
-
-                // On selectionne les groupes auquel fait parti le user
-                $exclude = array();
-
-                $usergroup=new UserGroup($db);
-                $groupslist = $usergroup->listGroupsForUser($object->id);
-
-                if (! empty($groupslist))
+                /*
+                 * List of groups of user
+                 */
+    
+                if ($canreadgroup)
                 {
-                    if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)))
+                    print load_fiche_titre($langs->trans("ListOfGroupsForUser"),'','');
+    
+                    // On selectionne les groupes auquel fait parti le user
+                    $exclude = array();
+    
+                    $usergroup=new UserGroup($db);
+                    $groupslist = $usergroup->listGroupsForUser($object->id);
+    
+                    if (! empty($groupslist))
                     {
-                        foreach($groupslist as $groupforuser)
+                        if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)))
                         {
-                            $exclude[]=$groupforuser->id;
+                            foreach($groupslist as $groupforuser)
+                            {
+                                $exclude[]=$groupforuser->id;
+                            }
                         }
                     }
-                }
-
-                if ($caneditgroup)
-                {
-                    print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'."\n";
-                    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
-                    print '<input type="hidden" name="action" value="addgroup" />';
-                }
-                
-                print '<table class="noborder" width="100%">'."\n";
-                print '<tr class="liste_titre"><th class="liste_titre" width="25%">'.$langs->trans("Groups").'</th>'."\n";
-                if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
-                {
-                    print '<td class="liste_titre" width="25%">'.$langs->trans("Entity").'</td>';
-                }
-                print '<th align="right">';
-                if ($caneditgroup)
-                {
-                    print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity);
-                    print ' &nbsp; ';
-                    // Multicompany
-                    if (! empty($conf->multicompany->enabled))
+    
+                    if ($caneditgroup)
                     {
-                        if ($conf->entity == 1 && $conf->multicompany->transverse_mode)
-                        {
-                            print '</td><td>'.$langs->trans("Entity").'</td>';
-                            print "<td>".$mc->select_entities($conf->entity);
-                        }
-                        else
-                        {
-                            print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
-                        }
+                        print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'."\n";
+                        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
+                        print '<input type="hidden" name="action" value="addgroup" />';
                     }
-                    else
+                    
+                    print '<table class="noborder" width="100%">'."\n";
+                    print '<tr class="liste_titre"><th class="liste_titre" width="25%">'.$langs->trans("Groups").'</th>'."\n";
+                    if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
                     {
-                    	print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
+                        print '<td class="liste_titre" width="25%">'.$langs->trans("Entity").'</td>';
                     }
-                    print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />';
-                }
-                print '</th></tr>'."\n";
-
-                /*
-                 * Groups assigned to user
-                 */
-                if (! empty($groupslist))
-                {
-                    foreach($groupslist as $group)
+                    print '<th align="right">';
+                    if ($caneditgroup)
                     {
-                        
-
-                        print '<tr class="oddeven">';
-                        print '<td>';
-                        if ($caneditgroup)
-                        {
-                            print '<a href="'.DOL_URL_ROOT.'/user/group/card.php?id='.$group->id.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$group->name.'</a>';
-                        }
-                        else
-                        {
-                            print img_object($langs->trans("ShowGroup"),"group").' '.$group->name;
-                        }
-                        print '</td>';
-                        if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
+                        print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity);
+                        print ' &nbsp; ';
+                        // Multicompany
+                        if (! empty($conf->multicompany->enabled))
                         {
-                        	print '<td class="valeur">';
-                        	if (! empty($group->usergroup_entity))
-                        	{
-                        		$nb=0;
-                        		foreach($group->usergroup_entity as $group_entity)
-                        		{
-                        			$mc->getInfo($group_entity);
-                        			print ($nb > 0 ? ', ' : '').$mc->label;
-                        			print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=removegroup&amp;group='.$group->id.'&amp;entity='.$group_entity.'">';
-                        			print img_delete($langs->trans("RemoveFromGroup"));
-                        			print '</a>';
-                        			$nb++;
-                        		}
-                        	}
-                        }
-                        print '<td align="right">';
-                        if ($caneditgroup && empty($conf->multicompany->transverse_mode))
-                        {
-                            print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=removegroup&amp;group='.$group->id.'">';
-                            print img_delete($langs->trans("RemoveFromGroup"));
-                            print '</a>';
+                            if ($conf->entity == 1 && $conf->multicompany->transverse_mode)
+                            {
+                                print '</td><td>'.$langs->trans("Entity").'</td>';
+                                print "<td>".$mc->select_entities($conf->entity);
+                            }
+                            else
+                            {
+                                print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
+                            }
                         }
                         else
                         {
-                            print "&nbsp;";
+                        	print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
                         }
-                        print "</td></tr>\n";
-                    }
-                }
-                else
-                {
-                    print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
-                }
-
-                print "</table>";
-                
-                if ($caneditgroup)
-                {
-                    print '</form>';
-                }
-                print "<br>";
-            }
-    
-            /*
-             * Fiche en mode edition
-             */
-            if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id)))
-            {
-            	print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST" name="updateuser" enctype="multipart/form-data">';
-                print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-                print '<input type="hidden" name="action" value="update">';
-                print '<input type="hidden" name="entity" value="'.$object->entity.'">';
-    
-                dol_fiche_head($head, 'user', $title, 0, 'user');
-    
-                print '<table width="100%" class="border">';
-    
-                // Ref/ID
-    			if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
-    			{
-    	            print '<tr><td>'.$langs->trans("Ref").'</td>';
-    	            print '<td>';
-    	            print $object->id;
-    	            print '</td>';
-    	            print '</tr>';
-    			}
-    
-                // Lastname
-                print "<tr>";
-                print '<td class="fieldrequired">'.$langs->trans("Lastname").'</td>';
-                print '<td>';
-                if ($caneditfield && !$object->ldap_sid)
-                {
-                    print '<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.'">';
-                }
-                else
-                {
-                    print '<input type="hidden" name="lastname" value="'.$object->lastname.'">';
-                    print $object->lastname;
-                }
-                print '</td>';
-                print '</tr>';
-    
-                // Firstname
-                print "<tr>".'<td>'.$langs->trans("Firstname").'</td>';
-                print '<td>';
-                if ($caneditfield && !$object->ldap_sid)
-                {
-                    print '<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.'">';
-                }
-                else
-                {
-                    print '<input type="hidden" name="firstname" value="'.$object->firstname.'">';
-                    print $object->firstname;
-                }
-                print '</td></tr>';
-    
-                // Employee
-                print '<tr>';
-                print '<td>'.fieldLabel('Employee','employee',0).'</td><td>';
-                print $form->selectyesno("employee",$object->employee,1);
-                print '</td></tr>';
-    
-                // Position/Job
-                print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
-                print '<td>';
-                if ($caneditfield)
-                {
-                	print '<input size="30" type="text" name="job" value="'.$object->job.'">';
-                }
-                else
-    			{
-                    print '<input type="hidden" name="job" value="'.$object->job.'">';
-              		print $object->job;
-                }
-                print '</td></tr>';
-    
-    		    // Gender
-        		print '<tr><td>'.$langs->trans("Gender").'</td>';
-        		print '<td>';
-        		$arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
-        		print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1);
-        		print '</td></tr>';
-    
-                // Login
-                print "<tr>".'<td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>';
-                print '<td>';
-                if ($user->admin  && !$object->ldap_sid)
-                {
-                    print '<input size="12" maxlength="24" type="text" class="flat" name="login" value="'.$object->login.'">';
-                }
-                else
-                {
-                    print '<input type="hidden" name="login" value="'.$object->login.'">';
-                    print $object->login;
-                }
-                print '</td>';
-                print '</tr>';
-    
-                // Pass
-                print '<tr><td>'.$langs->trans("Password").'</td>';
-                print '<td>';
-                if ($object->ldap_sid)
-                {
-                    $text=$langs->trans("DomainPassword");
-                }
-                else if ($caneditpassword)
-                {
-                    $text='<input size="12" maxlength="32" type="password" class="flat" name="password" value="'.$object->pass.'" autocomplete="off">';
-                    if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http')
-                    {
-                        $text=$form->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning');
+                        print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />';
                     }
-                }
-                else
-                {
-                    $text=preg_replace('/./i','*',$object->pass);
-                }
-                print $text;
-                print "</td></tr>\n";
+                    print '</th></tr>'."\n";
     
-                // API key
-                if(! empty($conf->api->enabled) && $user->admin) {
-                    print '<tr><td>'.$langs->trans("ApiKey").'</td>';
-                    print '<td>';
-                    print '<input class="minwidth100" maxsize="32" type="text" id="api_key" name="api_key" value="'.$object->api_key.'" autocomplete="off">';
-                    if (! empty($conf->use_javascript_ajax))
-                        print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
-                    print '</td></tr>';
-                }
-    
-                // Administrator
-                print '<tr><td>'.$langs->trans("Administrator").'</td>';
-                if ($object->societe_id > 0)
-                {
-                	$langs->load("admin");
-                    print '<td>';
-                    print '<input type="hidden" name="admin" value="'.$object->admin.'">'.yn($object->admin);
-                    print ' ('.$langs->trans("ExternalUser").')';
-                    print '</td></tr>';
-                }
-                else
-                {
-                    print '<td>';
-                    $nbAdmin = $user->getNbOfUsers('active','',1);
-                    $nbSuperAdmin = $user->getNbOfUsers('active','superadmin',1);
-                    //var_dump($nbAdmin);
-                    //var_dump($nbSuperAdmin);
-                    if ($user->admin								// Need to be admin to allow downgrade of an admin
-                    && ($user->id != $object->id)                   // Don't downgrade ourself
-                    && (
-                    	(empty($conf->multicompany->enabled) && $nbAdmin >= 1)
-                    	|| (! empty($conf->multicompany->enabled) && ($object->entity > 0 || $nbSuperAdmin > 1))    // Don't downgrade a superadmin if alone
-                    	)
-                    )
+                    /*
+                     * Groups assigned to user
+                     */
+                    if (! empty($groupslist))
                     {
-                        print $form->selectyesno('admin',$object->admin,1);
-    
-                        if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode))
+                        foreach($groupslist as $group)
                         {
-                            if ($conf->use_javascript_ajax)
+                            
+    
+                            print '<tr class="oddeven">';
+                            print '<td>';
+                            if ($caneditgroup)
                             {
-                                print '<script type="text/javascript">
-    									$(function() {
-    										var admin = $("select[name=admin]").val();
-    										if (admin == 0) {
-    											$("input[name=superadmin]")
-    													.prop("disabled", true)
-    													.prop("checked", false);
-    										}
-    										if ($("input[name=superadmin]").is(":checked")) {
-    											$("select[name=entity]")
-    													.prop("disabled", true);
-    										}
-    										$("select[name=admin]").change(function() {
-    											 if ( $(this).val() == 0 ) {
-    											 	$("input[name=superadmin]")
-    													.prop("disabled", true)
-    													.prop("checked", false);
-    											 	$("select[name=entity]")
-    													.prop("disabled", false);
-    											 } else {
-    											 	$("input[name=superadmin]")
-    													.prop("disabled", false);
-    											 }
-    										});
-    										$("input[name=superadmin]").change(function() {
-    											if ( $(this).is(":checked")) {
-    												$("select[name=entity]")
-    													.prop("disabled", true);
-    											} else {
-    												$("select[name=entity]")
-    													.prop("disabled", false);
-    											}
-    										});
-    									});
-    								</script>';
+                                print '<a href="'.DOL_URL_ROOT.'/user/group/card.php?id='.$group->id.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$group->name.'</a>';
                             }
-    
-                            $checked=(($object->admin && ! $object->entity) ? ' checked' : '');
-                            print '<input type="checkbox" name="superadmin" value="1"'.$checked.' /> '.$langs->trans("SuperAdministrator");
+                            else
+                            {
+                                print img_object($langs->trans("ShowGroup"),"group").' '.$group->name;
+                            }
+                            print '</td>';
+                            if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
+                            {
+                            	print '<td class="valeur">';
+                            	if (! empty($group->usergroup_entity))
+                            	{
+                            		$nb=0;
+                            		foreach($group->usergroup_entity as $group_entity)
+                            		{
+                            			$mc->getInfo($group_entity);
+                            			print ($nb > 0 ? ', ' : '').$mc->label;
+                            			print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=removegroup&amp;group='.$group->id.'&amp;entity='.$group_entity.'">';
+                            			print img_delete($langs->trans("RemoveFromGroup"));
+                            			print '</a>';
+                            			$nb++;
+                            		}
+                            	}
+                            }
+                            print '<td align="right">';
+                            if ($caneditgroup && empty($conf->multicompany->transverse_mode))
+                            {
+                                print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=removegroup&amp;group='.$group->id.'">';
+                                print img_delete($langs->trans("RemoveFromGroup"));
+                                print '</a>';
+                            }
+                            else
+                            {
+                                print "&nbsp;";
+                            }
+                            print "</td></tr>\n";
                         }
                     }
                     else
                     {
-                        $yn = yn($object->admin);
-                        print '<input type="hidden" name="admin" value="'.$object->admin.'">';
-                        print '<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).'">';
-                        if (! empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning');
-                        else print $yn;
+                        print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
                     }
-                    print '</td></tr>';
-                }
     
-               	// Type
-               	print '<tr><td>'.$langs->trans("Type").'</td>';
-               	print '<td>';
-               	if ($user->id == $object->id || ! $user->admin)
-               	{
-    	           	$type=$langs->trans("Internal");
-        	       	if ($object->societe_id) $type=$langs->trans("External");
-            	   	print $form->textwithpicto($type,$langs->trans("InternalExternalDesc"));
-    	           	if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')';
-               	}
-               	else
-    			{
-    				$type=0;
-    	            if ($object->contact_id) $type=$object->contact_id;
-    	            print $form->selectcontacts(0,$type,'contactid',2,'','',1,'',false,1);
-    	           	if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')';
+                    print "</table>";
+                    
+                    if ($caneditgroup)
+                    {
+                        print '</form>';
+                    }
+                    print "<br>";
                 }
-               	print '</td></tr>';
-    
-    			// Address
-                print '<tr><td class="tdtop">'.fieldLabel('Address','address').'</td>';
-    	        print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
-                print $object->address;
-                print '</textarea></td></tr>';
-    
-                // Zip
-                print '<tr><td>'.fieldLabel('Zip','zipcode').'</td><td>';
-                print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
-                print '</td></tr>';
-    
-    			// Town
-    			print '<tr><td>'.fieldLabel('Town','town').'</td><td>';
-                print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
-                print '</td></tr>';
-    
-                // Country
-                print '<tr><td>'.fieldLabel('Country','selectcounty_id').'</td><td>';
-                print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id');
-                if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
-                print '</td></tr>';
-    
-                // State
-                if (empty($conf->global->USER_DISABLE_STATE))
+            }
+        }
+        
+        /*
+         * Fiche en mode edition
+         */
+        if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id)))
+        {
+        	print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST" name="updateuser" enctype="multipart/form-data">';
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+            print '<input type="hidden" name="action" value="update">';
+            print '<input type="hidden" name="entity" value="'.$object->entity.'">';
+
+            dol_fiche_head($head, 'user', $title, 0, 'user');
+
+            print '<table width="100%" class="border">';
+
+            // Ref/ID
+			if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
+			{
+	            print '<tr><td>'.$langs->trans("Ref").'</td>';
+	            print '<td>';
+	            print $object->id;
+	            print '</td>';
+	            print '</tr>';
+			}
+
+            // Lastname
+            print "<tr>";
+            print '<td class="fieldrequired">'.$langs->trans("Lastname").'</td>';
+            print '<td>';
+            if ($caneditfield && !$object->ldap_sid)
+            {
+                print '<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.'">';
+            }
+            else
+            {
+                print '<input type="hidden" name="lastname" value="'.$object->lastname.'">';
+                print $object->lastname;
+            }
+            print '</td>';
+            print '</tr>';
+
+            // Firstname
+            print "<tr>".'<td>'.$langs->trans("Firstname").'</td>';
+            print '<td>';
+            if ($caneditfield && !$object->ldap_sid)
+            {
+                print '<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.'">';
+            }
+            else
+            {
+                print '<input type="hidden" name="firstname" value="'.$object->firstname.'">';
+                print $object->firstname;
+            }
+            print '</td></tr>';
+
+            // Employee
+            print '<tr>';
+            print '<td>'.fieldLabel('Employee','employee',0).'</td><td>';
+            print $form->selectyesno("employee",$object->employee,1);
+            print '</td></tr>';
+
+            // Position/Job
+            print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
+            print '<td>';
+            if ($caneditfield)
+            {
+            	print '<input size="30" type="text" name="job" value="'.$object->job.'">';
+            }
+            else
+			{
+                print '<input type="hidden" name="job" value="'.$object->job.'">';
+          		print $object->job;
+            }
+            print '</td></tr>';
+
+		    // Gender
+    		print '<tr><td>'.$langs->trans("Gender").'</td>';
+    		print '<td>';
+    		$arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
+    		print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1);
+    		print '</td></tr>';
+
+            // Login
+            print "<tr>".'<td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>';
+            print '<td>';
+            if ($user->admin  && !$object->ldap_sid)
+            {
+                print '<input size="12" maxlength="24" type="text" class="flat" name="login" value="'.$object->login.'">';
+            }
+            else
+            {
+                print '<input type="hidden" name="login" value="'.$object->login.'">';
+                print $object->login;
+            }
+            print '</td>';
+            print '</tr>';
+
+            // Pass
+            print '<tr><td>'.$langs->trans("Password").'</td>';
+            print '<td>';
+            if ($object->ldap_sid)
+            {
+                $text=$langs->trans("DomainPassword");
+            }
+            else if ($caneditpassword)
+            {
+                $text='<input size="12" maxlength="32" type="password" class="flat" name="password" value="'.$object->pass.'" autocomplete="off">';
+                if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http')
                 {
-                    print '<tr><td class="tdoverflow">'.fieldLabel('State','state_id').'</td><td>';
-                    print $formcompany->select_state($object->state_id,$object->country_code, 'state_id');
-                    print '</td></tr>';
+                    $text=$form->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning');
                 }
-    
-                // Tel pro
-                print "<tr>".'<td>'.$langs->trans("PhonePro").'</td>';
+            }
+            else
+            {
+                $text=preg_replace('/./i','*',$object->pass);
+            }
+            print $text;
+            print "</td></tr>\n";
+
+            // API key
+            if(! empty($conf->api->enabled) && $user->admin) 
+            {
+                print '<tr><td>'.$langs->trans("ApiKey").'</td>';
                 print '<td>';
-                if ($caneditfield  && empty($object->ldap_sid))
-                {
-                    print '<input size="20" type="text" name="office_phone" class="flat" value="'.$object->office_phone.'">';
-                }
-                else
-                {
-                    print '<input type="hidden" name="office_phone" value="'.$object->office_phone.'">';
-                    print $object->office_phone;
-                }
+                print '<input class="minwidth300" maxsize="32" type="text" id="api_key" name="api_key" value="'.$object->api_key.'" autocomplete="off">';
+                if (! empty($conf->use_javascript_ajax))
+                    print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
                 print '</td></tr>';
-    
-                // Tel mobile
-                print "<tr>".'<td>'.$langs->trans("PhoneMobile").'</td>';
+            }
+
+            // Administrator
+            print '<tr><td>'.$langs->trans("Administrator").'</td>';
+            if ($object->societe_id > 0)
+            {
+            	$langs->load("admin");
                 print '<td>';
-                if ($caneditfield && empty($object->ldap_sid))
-                {
-                    print '<input size="20" type="text" name="user_mobile" class="flat" value="'.$object->user_mobile.'">';
-                }
-                else
-                {
-                    print '<input type="hidden" name="user_mobile" value="'.$object->user_mobile.'">';
-                    print $object->user_mobile;
-                }
+                print '<input type="hidden" name="admin" value="'.$object->admin.'">'.yn($object->admin);
+                print ' ('.$langs->trans("ExternalUser").')';
                 print '</td></tr>';
-    
-                // Fax
-                print "<tr>".'<td>'.$langs->trans("Fax").'</td>';
+            }
+            else
+            {
                 print '<td>';
-                if ($caneditfield  && empty($object->ldap_sid))
+                $nbAdmin = $user->getNbOfUsers('active','',1);
+                $nbSuperAdmin = $user->getNbOfUsers('active','superadmin',1);
+                //var_dump($nbAdmin);
+                //var_dump($nbSuperAdmin);
+                if ($user->admin								// Need to be admin to allow downgrade of an admin
+                && ($user->id != $object->id)                   // Don't downgrade ourself
+                && (
+                	(empty($conf->multicompany->enabled) && $nbAdmin >= 1)
+                	|| (! empty($conf->multicompany->enabled) && ($object->entity > 0 || $nbSuperAdmin > 1))    // Don't downgrade a superadmin if alone
+                	)
+                )
                 {
-                    print '<input size="20" type="text" name="office_fax" class="flat" value="'.$object->office_fax.'">';
+                    print $form->selectyesno('admin',$object->admin,1);
+
+                    if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode))
+                    {
+                        if ($conf->use_javascript_ajax)
+                        {
+                            print '<script type="text/javascript">
+									$(function() {
+										var admin = $("select[name=admin]").val();
+										if (admin == 0) {
+											$("input[name=superadmin]")
+													.prop("disabled", true)
+													.prop("checked", false);
+										}
+										if ($("input[name=superadmin]").is(":checked")) {
+											$("select[name=entity]")
+													.prop("disabled", true);
+										}
+										$("select[name=admin]").change(function() {
+											 if ( $(this).val() == 0 ) {
+											 	$("input[name=superadmin]")
+													.prop("disabled", true)
+													.prop("checked", false);
+											 	$("select[name=entity]")
+													.prop("disabled", false);
+											 } else {
+											 	$("input[name=superadmin]")
+													.prop("disabled", false);
+											 }
+										});
+										$("input[name=superadmin]").change(function() {
+											if ( $(this).is(":checked")) {
+												$("select[name=entity]")
+													.prop("disabled", true);
+											} else {
+												$("select[name=entity]")
+													.prop("disabled", false);
+											}
+										});
+									});
+								</script>';
+                        }
+
+                        $checked=(($object->admin && ! $object->entity) ? ' checked' : '');
+                        print '<input type="checkbox" name="superadmin" value="1"'.$checked.' /> '.$langs->trans("SuperAdministrator");
+                    }
                 }
                 else
                 {
-                    print '<input type="hidden" name="office_fax" value="'.$object->office_fax.'">';
-                    print $object->office_fax;
+                    $yn = yn($object->admin);
+                    print '<input type="hidden" name="admin" value="'.$object->admin.'">';
+                    print '<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).'">';
+                    if (! empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning');
+                    else print $yn;
                 }
                 print '</td></tr>';
-    
-                // Skype
-                if (! empty($conf->skype->enabled))
-                {
-                    print '<tr><td>'.$langs->trans("Skype").'</td>';
-                    print '<td>';
-                    if ($caneditfield  && empty($object->ldap_sid))
-                    {
-                        print '<input size="40" type="text" name="skype" class="flat" value="'.$object->skype.'">';
-                    }
-                    else
-                    {
-                        print '<input type="hidden" name="skype" value="'.$object->skype.'">';
-                        print $object->skype;
-                    }
-                    print '</td></tr>';
-                }
-    
-                // EMail
-                print "<tr>".'<td'.(! empty($conf->global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").'</td>';
+            }
+
+           	// Type
+           	print '<tr><td>'.$langs->trans("Type").'</td>';
+           	print '<td>';
+           	if ($user->id == $object->id || ! $user->admin)
+           	{
+	           	$type=$langs->trans("Internal");
+    	       	if ($object->societe_id) $type=$langs->trans("External");
+        	   	print $form->textwithpicto($type,$langs->trans("InternalExternalDesc"));
+	           	if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')';
+           	}
+           	else
+			{
+				$type=0;
+	            if ($object->contact_id) $type=$object->contact_id;
+	            print $form->selectcontacts(0,$type,'contactid',2,'','',1,'',false,1);
+	           	if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')';
+            }
+           	print '</td></tr>';
+
+			// Address
+            print '<tr><td class="tdtop">'.fieldLabel('Address','address').'</td>';
+	        print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
+            print $object->address;
+            print '</textarea></td></tr>';
+
+            // Zip
+            print '<tr><td>'.fieldLabel('Zip','zipcode').'</td><td>';
+            print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
+            print '</td></tr>';
+
+			// Town
+			print '<tr><td>'.fieldLabel('Town','town').'</td><td>';
+            print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
+            print '</td></tr>';
+
+            // Country
+            print '<tr><td>'.fieldLabel('Country','selectcounty_id').'</td><td>';
+            print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id');
+            if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
+            print '</td></tr>';
+
+            // State
+            if (empty($conf->global->USER_DISABLE_STATE))
+            {
+                print '<tr><td class="tdoverflow">'.fieldLabel('State','state_id').'</td><td>';
+                print $formcompany->select_state($object->state_id,$object->country_code, 'state_id');
+                print '</td></tr>';
+            }
+
+            // Tel pro
+            print "<tr>".'<td>'.$langs->trans("PhonePro").'</td>';
+            print '<td>';
+            if ($caneditfield  && empty($object->ldap_sid))
+            {
+                print '<input size="20" type="text" name="office_phone" class="flat" value="'.$object->office_phone.'">';
+            }
+            else
+            {
+                print '<input type="hidden" name="office_phone" value="'.$object->office_phone.'">';
+                print $object->office_phone;
+            }
+            print '</td></tr>';
+
+            // Tel mobile
+            print "<tr>".'<td>'.$langs->trans("PhoneMobile").'</td>';
+            print '<td>';
+            if ($caneditfield && empty($object->ldap_sid))
+            {
+                print '<input size="20" type="text" name="user_mobile" class="flat" value="'.$object->user_mobile.'">';
+            }
+            else
+            {
+                print '<input type="hidden" name="user_mobile" value="'.$object->user_mobile.'">';
+                print $object->user_mobile;
+            }
+            print '</td></tr>';
+
+            // Fax
+            print "<tr>".'<td>'.$langs->trans("Fax").'</td>';
+            print '<td>';
+            if ($caneditfield  && empty($object->ldap_sid))
+            {
+                print '<input size="20" type="text" name="office_fax" class="flat" value="'.$object->office_fax.'">';
+            }
+            else
+            {
+                print '<input type="hidden" name="office_fax" value="'.$object->office_fax.'">';
+                print $object->office_fax;
+            }
+            print '</td></tr>';
+
+            // Skype
+            if (! empty($conf->skype->enabled))
+            {
+                print '<tr><td>'.$langs->trans("Skype").'</td>';
                 print '<td>';
                 if ($caneditfield  && empty($object->ldap_sid))
                 {
-                    print '<input class="minwidth100" type="text" name="email" class="flat" value="'.$object->email.'">';
+                    print '<input size="40" type="text" name="skype" class="flat" value="'.$object->skype.'">';
                 }
                 else
                 {
-                    print '<input type="hidden" name="email" value="'.$object->email.'">';
-                    print $object->email;
+                    print '<input type="hidden" name="skype" value="'.$object->skype.'">';
+                    print $object->skype;
                 }
                 print '</td></tr>';
-    
-                // Signature
-                print "<tr>".'<td class="tdtop">'.$langs->trans("Signature").'</td>';
+            }
+
+            // EMail
+            print "<tr>".'<td'.(! empty($conf->global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").'</td>';
+            print '<td>';
+            if ($caneditfield  && empty($object->ldap_sid))
+            {
+                print '<input class="minwidth100" type="text" name="email" class="flat" value="'.$object->email.'">';
+            }
+            else
+            {
+                print '<input type="hidden" name="email" value="'.$object->email.'">';
+                print $object->email;
+            }
+            print '</td></tr>';
+
+            // OpenID url
+            if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER))
+            {
+                print "<tr>".'<td>'.$langs->trans("OpenIDURL").'</td>';
                 print '<td>';
                 if ($caneditfield)
                 {
-    	            require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    	            $doleditor=new DolEditor('signature',$object->signature,'',138,'dolibarr_mailings','In',false,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%');
-    	            print $doleditor->Create(1);
+                    print '<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.'">';
                 }
                 else
-    			{
-              		print dol_htmlentitiesbr($object->signature);
-                }
-                print '</td></tr>';
-    
-                // OpenID url
-                if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER))
                 {
-                    print "<tr>".'<td>'.$langs->trans("OpenIDURL").'</td>';
-                    print '<td>';
-                    if ($caneditfield)
-                    {
-                        print '<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.'">';
-                    }
-                    else
-                  {
-                        print '<input type="hidden" name="openid" value="'.$object->openid.'">';
-                        print $object->openid;
-                    }
-                    print '</td></tr>';
+                    print '<input type="hidden" name="openid" value="'.$object->openid.'">';
+                    print $object->openid;
                 }
-    
-                // Hierarchy
-                print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>';
+                print '</td></tr>';
+            }
+
+            // Accountancy code
+            if ($conf->accounting->enabled)
+            {
+                print "<tr>";
+                print '<td>'.$langs->trans("AccountancyCode").'</td>';
                 print '<td>';
                 if ($caneditfield)
                 {
-                	print $form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300');
+                				print '<input size="30" type="text" class="flat" name="accountancy_code" value="'.$object->accountancy_code.'">';
                 }
                 else
                 {
-              		print '<input type="hidden" name="fk_user" value="'.$object->fk_user.'">';
-                	$huser=new User($db);
-                	$huser->fetch($object->fk_user);
-                	print $huser->getNomUrl(1);
+                				print '<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.'">';
+                				print $object->accountancy_code;
                 }
                 print '</td>';
-                print "</tr>\n";
-    
-                if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
-                {
-                	$langs->load("salaries");
-    
-                	// THM
-    			    print '<tr><td>';
-    			    $text=$langs->trans("THM");
-    			    print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
-    			    print '</td>';
-    			    print '<td>';
-    			    print '<input size="8" type="text" name="thm" value="'.price2num(GETPOST('thm')?GETPOST('thm'):$object->thm).'">';
-    			    print '</td>';
-    			    print "</tr>\n";
-    
-    			    // TJM
-    			    print '<tr><td>';
-    			    $text=$langs->trans("TJM");
-    			    print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm');
-    			    print '</td>';
-    			    print '<td>';
-    			    print '<input size="8" type="text" name="tjm" value="'.price2num(GETPOST('tjm')?GETPOST('tjm'):$object->tjm).'">';
-    			    print '</td>';
-    			    print "</tr>\n";
-    
-    			    // Salary
-    			    print '<tr><td>'.$langs->trans("Salary").'</td>';
-    			    print '<td>';
-    			    print '<input size="8" type="text" name="salary" value="'.price2num(GETPOST('salary')?GETPOST('salary'):$object->salary).'">';
-    			    print '</td>';
-    			    print "</tr>\n";
-                }
-    
-    		    // Weeklyhours
-    		    print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
-    		    print '<td>';
-    		    print '<input size="8" type="text" name="weeklyhours" value="'.price2num(GETPOST('weeklyhours')?GETPOST('weeklyhours'):$object->weeklyhours).'">';
-    		    print '</td>';
-    		    print "</tr>\n";
-    
-    		    // Date employment
-    		    print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
-    		    print '<td>';
-    			echo $form->select_date(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment,'dateemployment',0,0,1,'form'.'dateemployment',1,0,1);
-    			print '</td>';
-    		    print "</tr>\n";
-    
-    		    // Accountancy code
-    			if ($conf->accounting->enabled)
-        		{
-    			print "<tr>";
-    			print '<td>'.$langs->trans("AccountancyCode").'</td>';
-    			print '<td>';
-    			if ($caneditfield)
-    			{
-    				print '<input size="30" type="text" class="flat" name="accountancy_code" value="'.$object->accountancy_code.'">';
-    			}
-    			else
-    			{
-    				print '<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.'">';
-    				print $object->accountancy_code;
-    			}
-    			print '</td>';
-    			print "</tr>";
-    		}
-    
+                print "</tr>";
+            }
+            
+            // Hierarchy
+            print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>';
+            print '<td>';
+            if ($caneditfield)
+            {
+            	print $form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300');
+            }
+            else
+            {
+          		print '<input type="hidden" name="fk_user" value="'.$object->fk_user.'">';
+            	$huser=new User($db);
+            	$huser->fetch($object->fk_user);
+            	print $huser->getNomUrl(1);
+            }
+            print '</td>';
+            print "</tr>\n";
+
+            if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
+               || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
+            {
+            	$langs->load("salaries");
+
+            	// THM
+			    print '<tr><td>';
+			    $text=$langs->trans("THM");
+			    print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
+			    print '</td>';
+			    print '<td>';
+			    print '<input size="8" type="text" name="thm" value="'.price2num(GETPOST('thm')?GETPOST('thm'):$object->thm).'">';
+			    print '</td>';
+			    print "</tr>\n";
+
+			    // TJM
+			    print '<tr><td>';
+			    $text=$langs->trans("TJM");
+			    print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm');
+			    print '</td>';
+			    print '<td>';
+			    print '<input size="8" type="text" name="tjm" value="'.price2num(GETPOST('tjm')?GETPOST('tjm'):$object->tjm).'">';
+			    print '</td>';
+			    print "</tr>\n";
+
+			    // Salary
+			    print '<tr><td>'.$langs->trans("Salary").'</td>';
+			    print '<td>';
+			    print '<input size="8" type="text" name="salary" value="'.price2num(GETPOST('salary')?GETPOST('salary'):$object->salary).'">';
+			    print '</td>';
+			    print "</tr>\n";
+            }
+
+		    // Weeklyhours
+		    print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
+		    print '<td>';
+		    print '<input size="8" type="text" name="weeklyhours" value="'.price2num(GETPOST('weeklyhours')?GETPOST('weeklyhours'):$object->weeklyhours).'">';
+		    print '</td>';
+		    print "</tr>\n";
+
+		    // Date employment
+		    print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
+		    print '<td>';
+			echo $form->select_date(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment,'dateemployment',0,0,1,'form'.'dateemployment',1,0,1);
+			print '</td>';
+		    print "</tr>\n";
+
     		// User color
     		if (! empty($conf->agenda->enabled))
     	    {
@@ -2461,6 +2452,21 @@ else
             	print $object->showOptionals($extrafields,'edit');
             }
 
+            // Signature
+            print "<tr>".'<td class="tdtop">'.$langs->trans("Signature").'</td>';
+            print '<td>';
+            if ($caneditfield)
+            {
+                require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+                $doleditor=new DolEditor('signature',$object->signature,'',138,'dolibarr_mailings','In',false,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%');
+                print $doleditor->Create(1);
+            }
+            else
+            {
+                print dol_htmlentitiesbr($object->signature);
+            }
+            print '</td></tr>';
+            
             print '</table>';
 
             dol_fiche_end();
@@ -2501,8 +2507,6 @@ else
             
             
             print '</div></div></div>';
-        }
-        
         }
         
 		if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) $ldap->close();