diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php
index 487c763644521cf236e824b2375f8cc0cdeb3fad..24bbbec029484e5cb391bceca0999377950650e7 100644
--- a/htdocs/adherents/agenda.php
+++ b/htdocs/adherents/agenda.php
@@ -35,8 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
 $langs->load("companies");
 $langs->load("members");
 
-$mesg=isset($_GET["mesg"])?'<div class="ok">'.$_GET["mesg"].'</div>':'';
-
 $id = GETPOST('id','int');
 
 // Security check
@@ -70,7 +68,7 @@ $form = new Form($db);
 /*
  * Fiche categorie de client et/ou fournisseur
  */
-if ($id)
+if ($object->id > 0)
 {
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
 	require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@@ -133,9 +131,6 @@ if ($id)
 	print '</div>';
 
 
-	dol_htmloutput_mesg($mesg);
-
-
     /*
      * Barre d'action
      */
@@ -144,7 +139,9 @@ if ($id)
 
     if (! empty($conf->agenda->enabled))
     {
-        print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$socid.'">'.$langs->trans("AddAction").'</a>';
+    	// FIXME socid parameters is not valid, a member is not a thirparty
+        //print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$socid.'">'.$langs->trans("AddAction").'</a>';
+        print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create">'.$langs->trans("AddAction").'</a>';
     }
 
     print '</div>';
diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php
index 55c475c20421ab3875fc05e6b7197fa97aadf97c..5c278dd66f310426fbbdac65d24c6faf7629ac88 100644
--- a/htdocs/adherents/card_subscriptions.php
+++ b/htdocs/adherents/card_subscriptions.php
@@ -473,7 +473,7 @@ llxHeader('',$langs->trans("Subscriptions"),'EN:Module_Foundations|FR:Module_Adh
 
 if ($rowid)
 {
-    $res=$object->fetch($rowid,$ref);
+    $res=$object->fetch($rowid);
     if ($res < 0) { dol_print_error($db,$object->error); exit; }
     //$res=$object->fetch_optionals($object->id,$extralabels);
     //if ($res < 0) { dol_print_error($db); exit; }
@@ -558,10 +558,10 @@ if ($rowid)
         print '<table class="nobordernopadding" width="100%"><tr><td>';
         print $langs->trans("LinkedToDolibarrThirdParty");
         print '</td>';
-        if ($_GET['action'] != 'editthirdparty' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'</a></td>';
+        if ($action != 'editthirdparty' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'</a></td>';
         print '</tr></table>';
         print '</td><td class="valeur">';
-        if ($_GET['action'] == 'editthirdparty')
+        if ($action == 'editthirdparty')
         {
             $htmlname='socid';
             print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
@@ -813,7 +813,7 @@ if ($rowid)
         print '<input type="hidden" name="action" value="cotisation">';
         print '<input type="hidden" name="rowid" value="'.$rowid.'">';
         print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">';
-        print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($company->name).'">';
+        print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->name).'">';
         print "<table class=\"border\" width=\"100%\">\n";
 
         $today=dol_now();
@@ -822,16 +822,16 @@ if ($rowid)
         $paymentdate=-1;
 
         // Date payment
-        if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"])
+        if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday'))
         {
-            $paymentdate=dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]);
+            $paymentdate=dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear'));
         }
 
         // Date start subscription
         print '<tr><td width="30%" class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>';
-        if ($_POST["reday"])
+        if (GETPOST('reday'))
         {
-            $datefrom=dol_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
+            $datefrom=dol_mktime(0,0,0,GETPOST('remonth'),GETPOST('reday'),GETPOST('reyear'));
         }
         if (! $datefrom)
         {
@@ -848,9 +848,9 @@ if ($rowid)
         print "</td></tr>";
 
         // Date end subscription
-        if ($_POST["endday"])
+        if (GETPOST('endday'))
         {
-            $dateto=dol_mktime(0,0,0,$_POST["endmonth"],$_POST["endday"],$_POST["endyear"]);
+            $dateto=dol_mktime(0,0,0,GETPOST('endmonth'),GETPOST('endday'),GETPOST('endyear'));
         }
         if (! $dateto)
         {
@@ -863,7 +863,7 @@ if ($rowid)
         if ($adht->cotisation)
         {
             // Amount
-            print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="cotisation" size="6" value="'.$_POST["cotisation"].'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
+            print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="cotisation" size="6" value="'.GETPOST('cotisation').'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
 
             // Label
             print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
@@ -926,33 +926,33 @@ if ($rowid)
 
                 // Bank account
                 print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>';
-                $form->select_comptes($_POST["accountid"],'accountid',0,'',1);
+                $form->select_comptes(GETPOST('accountid'),'accountid',0,'',1);
                 print "</td></tr>\n";
 
                 // Payment mode
                 print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
-                $form->select_types_paiements($_POST["operation"],'operation','',2);
+                $form->select_types_paiements(GETPOST('operation'),'operation','',2);
                 print "</td></tr>\n";
 
                 // Date of payment
                 print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
-                $form->select_date($paymentdate?$paymentdate:-1,'payment',0,0,1,'cotisation',1,1);
+                $form->select_date(isset($paymentdate)?$paymentdate:-1,'payment',0,0,1,'cotisation',1,1);
                 print "</td></tr>\n";
 
                 print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero');
                 print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
                 print '</td>';
-                print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(empty($_POST['num_chq'])?'':$_POST['num_chq']).'"></td></tr>';
+                print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(! GETPOST('num_chq')?'':GETPOST('num_chq')).'"></td></tr>';
 
                 print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter');
                 print ' <em>('.$langs->trans("ChequeMaker").')</em>';
                 print '</td>';
-                print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(empty($_POST['chqemetteur'])?$facture->client->name:$_POST['chqemetteur']).'"></td></tr>';
+                print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(! GETPOST('chqemetteur')?'':GETPOST('chqemetteur')).'"></td></tr>';
 
                 print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank');
                 print ' <em>('.$langs->trans("ChequeBank").')</em>';
                 print '</td>';
-                print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(empty($_POST['chqbank'])?'':$_POST['chqbank']).'"></td></tr>';
+                print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(! GETPOST('chqbank')?'':GETPOST('chqbank')).'"></td></tr>';
             }
         }
 
@@ -972,7 +972,7 @@ if ($rowid)
             $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
             $texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
 
-            $tmp='<input name="sendmail" type="checkbox"'.((isset($_POST["sendmail"])?$_POST["sendmail"]:$conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked="checked"':'').'>';
+            $tmp='<input name="sendmail" type="checkbox"'.(GETPOST('sendmail')?GETPOST('sendmail'):(! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked="checked"':'')).'>';
             $helpcontent='';
             $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
             $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php
index 7e699ddd0adc1f1fa9c85eb0e5b37b2781142e30..cf1ecb8b14260d2bee8e549c89c52500543e7f09 100644
--- a/htdocs/adherents/document.php
+++ b/htdocs/adherents/document.php
@@ -196,8 +196,7 @@ if ($id > 0)
 
 
 		// List of document
-		$param='&socid='.$societe->id;
-		$formfile->list_of_documents($filearray,$member,'member',$param, 0, get_exdir($member->id,2,0,1).'/'.$member->id.'/');
+		$formfile->list_of_documents($filearray,$member,'member','', 0, get_exdir($member->id,2,0,1).'/'.$member->id.'/');
 
 		print "<br><br>";
 	}
diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index 73240518d0b37f0c4047ef20051f56fcc2fcddde..8900c37a2d9d223ae6c2ec2a3ca93377f747da21 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -52,9 +52,6 @@ $typeid=GETPOST('typeid','int');
 $userid=GETPOST('userid','int');
 $socid=GETPOST('socid','int');
 
-// Security check
-$result=restrictedArea($user,'adherent',$rowid,'','','fk_soc', 'rowid', $objcanvas);
-
 if (! empty($conf->mailmanspip->enabled))
 {
 	include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';
@@ -78,6 +75,9 @@ if (! empty($canvas))
 	$objcanvas->getCanvas('adherent', 'membercard', $canvas);
 }
 
+// Security check
+$result=restrictedArea($user,'adherent',$rowid,'','','fk_soc', 'rowid', $objcanvas);
+
 $errmsg=''; $errmsgs=array();
 
 if ($rowid > 0)
@@ -735,7 +735,7 @@ else
 		/*                                                                            */
 		/* ************************************************************************** */
 		$object->canvas=$canvas;
-		$object->fk_departement = $_POST["departement_id"];
+		$object->fk_departement = GETPOST('departement_id', 'int');
 
 		// We set country_id, country_code and country for the selected country
 		$object->country_id=GETPOST('country_id','int')?GETPOST('country_id','int'):$mysoc->country_id;
@@ -905,7 +905,7 @@ else
 		{
 			foreach($extrafields->attribute_label as $key=>$label)
 			{
-				$value=(isset($_POST["options_".$key])?GETPOST('options_'.$key,'alpha'):$object->array_options["options_".$key]);
+				$value=(isset($_POST["options_".$key])?GETPOST('options_'.$key,'alpha'):(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:''));
            		print '<tr><td';
            		if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
            		print '>'.$label.'</td><td>';
@@ -1235,7 +1235,7 @@ else
 		dol_htmloutput_errors($errmsg,$errmsgs);
 
 		// Confirm create user
-		if ($_GET["action"] == 'create_user')
+		if ($action == 'create_user')
 		{
 			$login=$object->login;
 			if (empty($login))
@@ -1261,7 +1261,7 @@ else
 		}
 
 		// Confirm create third party
-		if ($_GET["action"] == 'create_thirdparty')
+		if ($action == 'create_thirdparty')
 		{
 			$name = $object->getFullName($langs);
 			if (! empty($name))
@@ -1348,7 +1348,7 @@ else
 
 			// Cree un tableau formulaire
 			$formquestion=array();
-			if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?'true':'false'));
+			if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false'));
 			if ($backtopage)    $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
 			$ret=$form->form_confirm("fiche.php?rowid=".$rowid,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion);
 			if ($ret == 'html') print '<br>';
@@ -1495,10 +1495,10 @@ else
 			print '<table class="nobordernopadding" width="100%"><tr><td>';
 			print $langs->trans("LinkedToDolibarrThirdParty");
 			print '</td>';
-			if ($_GET['action'] != 'editthirdparty' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'</a></td>';
+			if ($action != 'editthirdparty' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'</a></td>';
 			print '</tr></table>';
 			print '</td><td colspan="2" class="valeur">';
-			if ($_GET['action'] == 'editthirdparty')
+			if ($action == 'editthirdparty')
 			{
 				$htmlname='socid';
 				print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
@@ -1533,7 +1533,7 @@ else
 		print '<table class="nobordernopadding" width="100%"><tr><td>';
 		print $langs->trans("LinkedToDolibarrUser");
 		print '</td>';
-		if ($_GET['action'] != 'editlogin' && $user->rights->adherent->creer)
+		if ($action != 'editlogin' && $user->rights->adherent->creer)
 		{
 			print '<td align="right">';
 			if ($user->rights->user->user->creer)
@@ -1544,7 +1544,7 @@ else
 		}
 		print '</tr></table>';
 		print '</td><td colspan="2" class="valeur">';
-		if ($_GET['action'] == 'editlogin')
+		if ($action == 'editlogin')
 		{
 			print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
 		}
diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php
index 7827abad53ac16f5e4552b0294284987c8df868b..a574dc0e5bd0b89adde354f3e776e6a2a35c8cdc 100644
--- a/htdocs/adherents/index.php
+++ b/htdocs/adherents/index.php
@@ -169,11 +169,11 @@ if ($conf->use_javascript_ajax)
     {
         $datalabels[]=array($i,$adhtype->getNomUrl(0,dol_size(16)));
         $dataval['draft'][]=array($i,isset($MemberToValidate[$key])?$MemberToValidate[$key]:0);
-        $dataval['notuptodate'][]=array($i,isset($MembersValidated[$key])?$MembersValidated[$key]-$MemberUpToDate[$key]:0);
+        $dataval['notuptodate'][]=array($i,isset($MembersValidated[$key])?$MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0):0);
         $dataval['uptodate'][]=array($i,isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0);
         $dataval['resiliated'][]=array($i,isset($MembersResiliated[$key])?$MembersResiliated[$key]:0);
         $SommeA+=isset($MemberToValidate[$key])?$MemberToValidate[$key]:0;
-        $SommeB+=isset($MembersValidated[$key])?$MembersValidated[$key]-$MemberUpToDate[$key]:0;
+        $SommeB+=isset($MembersValidated[$key])?$MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0):0;
         $SommeC+=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
         $SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
         $i++;
@@ -336,7 +336,7 @@ foreach ($AdherentType as $key => $adhtype)
 	print "<tr $bc[$var]>";
 	print '<td>'.$adhtype->getNomUrl(1, dol_size(32)).'</td>';
 	print '<td align="right">'.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0?$MemberToValidate[$key]:'').' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).'</td>';
-	print '<td align="right">'.(isset($MembersValidated[$key]) && ($MembersValidated[$key]-$MemberUpToDate[$key] > 0) ? $MembersValidated[$key]-$MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).'</td>';
+	print '<td align="right">'.(isset($MembersValidated[$key]) && ($MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0) > 0) ? $MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0):'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).'</td>';
 	print '<td align="right">'.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,$now,3).'</td>';
 	print '<td align="right">'.(isset($MembersResiliated[$key]) && $MembersResiliated[$key]> 0 ?$MembersResiliated[$key]:'').' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'</td>';
 	print "</tr>\n";
diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php
index 1870683a02e4505af9fd02161fc88c2a072d426a..3733d2debeedb4bfb815d4759ed1a7d1f2569398 100644
--- a/htdocs/adherents/note.php
+++ b/htdocs/adherents/note.php
@@ -57,7 +57,7 @@ if ($action == 'update' && $user->rights->adherent->creer && ! $_POST["cancel"])
 	$res=$object->update_note($_POST["note"],$user);
 	if ($res < 0)
 	{
-		$mesg='<div class="error">'.$object->error.'</div>';
+		setEventMessage($object->error, 'errors');
 		$db->rollback();
 	}
 	else
@@ -82,8 +82,6 @@ if ($id)
 
 	dol_fiche_head($head, 'note', $langs->trans("Member"), 0, 'user');
 
-	dol_htmloutput_errors($msg);
-
 	print "<form method=\"post\" action=\"note.php\">";
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 90168e4790d01042f2826c90172a815c54920e43..760651a7f2bd9c732e43d4b4e92663407bcb0a8f 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -51,6 +51,7 @@ class ActionComm extends CommonObject
 
     var $datep;			// Date action start (datep)
     var $datef;			// Date action end (datep2)
+    var $dateend;		// ??
     var $durationp = -1;      // -1=Unkown duration
     var $fulldayevent = 0;    // 1=Event on full day
     var $punctual = 1;        // Milestone
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index 48b48191c91fe41d2c6b37440f233b3eb671916b..53b0dae69abbe01d4da284c52e9755f3ad1cb08e 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -381,54 +381,45 @@ if ($action == 'create')
 
     if (! empty($conf->use_javascript_ajax))
     {
-        print "\n".'<script type="text/javascript" language="javascript">';
-        print 'jQuery(document).ready(function () {
-                     function setdatefields()
-                     {
-                            if (jQuery("#fullday:checked").val() == null)
-                            {
-                                jQuery(".fulldaystarthour").attr(\'disabled\', false);
-                                jQuery(".fulldaystartmin").attr(\'disabled\', false);
-                                jQuery(".fulldayendhour").attr(\'disabled\', false);
-                                jQuery(".fulldayendmin").attr(\'disabled\', false);
-                            }
-                            else
-                            {
-                                jQuery(".fulldaystarthour").attr(\'disabled\', true);
-                                jQuery(".fulldaystartmin").attr(\'disabled\', true);
-                                jQuery(".fulldayendhour").attr(\'disabled\', true);
-                                jQuery(".fulldayendmin").attr(\'disabled\', true);
-                                jQuery(".fulldaystarthour").val("00");
-                                jQuery(".fulldaystartmin").val("00");
-                                //jQuery(".fulldayendhour").val("00");
-                                //jQuery(".fulldayendmin").val("00");
-                                jQuery(".fulldayendhour").val("23");
-                                jQuery(".fulldayendmin").val("59");
-                        }
-                    }
+        print "\n".'<script type="text/javascript">';
+        print '$(document).ready(function () {
+        			function setdatefields()
+	            	{
+	            		if ($("#fullday:checked").val() == null) {
+	            			$(".fulldaystarthour").removeAttr("disabled");
+	            			$(".fulldaystartmin").removeAttr("disabled");
+	            			$(".fulldayendhour").removeAttr("disabled");
+	            			$(".fulldayendmin").removeAttr("disabled");
+	            		} else {
+	            			$(".fulldaystarthour").attr("disabled","disabled").val("00");
+	            			$(".fulldaystartmin").attr("disabled","disabled").val("00");
+	            			$(".fulldayendhour").attr("disabled","disabled").val("23");
+	            			$(".fulldayendmin").attr("disabled","disabled").val("59");
+	            		}
+	            	}
                     setdatefields();
-                    jQuery("#fullday").change(function() {
+                    $("#fullday").change(function() {
                         setdatefields();
                     });
-                    jQuery("#selectcomplete").change(function() {
-                        if (jQuery("#selectcomplete").val() == 100)
+                    $("#selectcomplete").change(function() {
+                        if ($("#selectcomplete").val() == 100)
                         {
-                            if (jQuery("#doneby").val() <= 0) jQuery("#doneby").val(\''.$user->id.'\');
+                            if ($("#doneby").val() <= 0) $("#doneby").val(\''.$user->id.'\');
                         }
-                        if (jQuery("#selectcomplete").val() == 0)
+                        if ($("#selectcomplete").val() == 0)
                         {
-                            jQuery("#doneby").val(-1);
+                            $("#doneby").val(-1);
                         }
                    });
-                   jQuery("#actioncode").change(function() {
-                        if (jQuery("#actioncode").val() == \'AC_RDV\') jQuery("#dateend").addClass("fieldrequired");
-                        else jQuery("#dateend").removeClass("fieldrequired");
+                   $("#actioncode").change(function() {
+                        if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
+                        else $("#dateend").removeClass("fieldrequired");
                    });
                })';
         print '</script>'."\n";
     }
 
-	print '<form name="formaction" action="'.DOL_URL_ROOT.'/comm/action/fiche.php" method="POST">';
+	print '<form name="formaction" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 	print '<input type="hidden" name="action" value="add_action">';
 	if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
@@ -647,43 +638,34 @@ if ($id)
 
 	if ($action == 'edit')
 	{
-	    if ($conf->use_javascript_ajax)
+	    if (! empty($conf->use_javascript_ajax))
         {
-            print "\n".'<script type="text/javascript" language="javascript">';
-            print 'jQuery(document).ready(function () {
-                         function setdatefields()
-                         {
-                                if (jQuery("#fullday:checked").val() == null)
-                                {
-                                    jQuery(".fulldaystarthour").attr(\'disabled\', false);
-                                    jQuery(".fulldaystartmin").attr(\'disabled\', false);
-                                    jQuery(".fulldayendhour").attr(\'disabled\', false);
-                                    jQuery(".fulldayendmin").attr(\'disabled\', false);
-                                }
-                                else
-                                {
-                                    jQuery(".fulldaystarthour").attr(\'disabled\', true);
-                                    jQuery(".fulldaystartmin").attr(\'disabled\', true);
-                                    jQuery(".fulldayendhour").attr(\'disabled\', true);
-                                    jQuery(".fulldayendmin").attr(\'disabled\', true);
-                                    jQuery(".fulldaystarthour").val("00");
-                                    jQuery(".fulldaystartmin").val("00");
-                                    //jQuery(".fulldayendhour").val("00");
-                                    //jQuery(".fulldayendmin").val("00");
-                                    jQuery(".fulldayendhour").val("23");
-                                    jQuery(".fulldayendmin").val("59");
-                            }
-                        }
-                        setdatefields();
-                        jQuery("#fullday").change(function() {
-                            setdatefields();
-                        });
+            print "\n".'<script type="text/javascript">';
+            print '$(document).ready(function () {
+	            		function setdatefields()
+	            		{
+	            			if ($("#fullday:checked").val() == null) {
+	            				$(".fulldaystarthour").removeAttr("disabled");
+	            				$(".fulldaystartmin").removeAttr("disabled");
+	            				$(".fulldayendhour").removeAttr("disabled");
+	            				$(".fulldayendmin").removeAttr("disabled");
+	            			} else {
+	            				$(".fulldaystarthour").attr("disabled","disabled").val("00");
+	            				$(".fulldaystartmin").attr("disabled","disabled").val("00");
+	            				$(".fulldayendhour").attr("disabled","disabled").val("23");
+	            				$(".fulldayendmin").attr("disabled","disabled").val("59");
+	            			}
+	            		}
+	            		setdatefields();
+	            		$("#fullday").change(function() {
+	            			setdatefields();
+	            		});
                    })';
             print '</script>'."\n";
         }
 
         // Fiche action en mode edition
-		print '<form name="formaction" action="'.DOL_URL_ROOT.'/comm/action/fiche.php" method="post">';
+		print '<form name="formaction" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 		print '<input type="hidden" name="action" value="update">';
 		print '<input type="hidden" name="id" value="'.$id.'">';
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 1de6c0678d80f47b57458294a38bb81dd5ce1eb2..bd9e94139e162a1761265f2f76f62da84054d09c 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -981,8 +981,22 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
 
                     // Define $color and $cssclass of event
                     $color=-1; $cssclass=''; $colorindex=-1;
-                    if ($event->author->id == $user->id || $event->usertodo->id == $user->id || $event->userdone->id == $user->id) { $nummytasks++; $colorindex=1; $cssclass='family_mytasks'; }
-                    else if ($event->type_code == 'ICALEVENT') { $numical++; $numicals[dol_string_nospecial($event->icalname)]++; $color=$event->icalcolor; $cssclass=($event->icalname?'family_'.dol_string_nospecial($event->icalname):'family_other'); }
+                    if ((! empty($event->author->id) && $event->author->id == $user->id)
+                    || (! empty($event->usertodo->id) && $event->usertodo->id == $user->id)
+                    || (! empty($event->userdone->id) && $event->userdone->id == $user->id)) {
+                    	$nummytasks++; $colorindex=1; $cssclass='family_mytasks';
+                    }
+                    else if ($event->type_code == 'ICALEVENT') {
+                    	$numical++;
+                    	if (! empty($event->icalname)) {
+                    		if (! isset($numicals[dol_string_nospecial($event->icalname)])) {
+                    			$numicals[dol_string_nospecial($event->icalname)] = 0;
+                    		}
+                    		$numicals[dol_string_nospecial($event->icalname)]++;
+                    	}
+                    	$color=$event->icalcolor;
+                    	$cssclass=(! empty($event->icalname)?'family_'.dol_string_nospecial($event->icalname):'family_other');
+                    }
                     else if ($event->type_code == 'BIRTHDAY')  { $numbirthday++; $colorindex=2; $cssclass='family_birthday'; }
                     else { $numother++; $colorindex=2; $cssclass='family_other'; }
                     if ($color == -1) $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]);
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 47238a3e8db7a857b05ffebd7f80359c9388cd97..48ed418a62db856cca44f0b4fec466324659e29f 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -1262,7 +1262,7 @@ else
             print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$object->fax.'"></td></tr>';
 
             // EMail / Web
-            print '<tr><td>'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').'</td><td><input type="text" name="email" size="32" value="'.$object->email.'"></td>';
+            print '<tr><td>'.$langs->trans('EMail').(! empty($conf->global->SOCIETE_MAIL_REQUIRED)?'*':'').'</td><td><input type="text" name="email" size="32" value="'.$object->email.'"></td>';
             print '<td>'.$langs->trans('Web').'</td><td><input type="text" name="url" size="32" value="'.$object->url.'"></td></tr>';
 
             // Prof ids