diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index aec3884ac150e57cca766adcca06d40f9e367d75..a78c43fca6059473af660a556ce9701f7bad7457 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -481,6 +481,8 @@ class FormOther
             {
                 $var = !$var;
 
+				//var_dump($selectedtask."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id);
+
                 // Break on a new project
                 if ($parent == 0)
                 {
@@ -508,10 +510,10 @@ class FormOther
                 }
 
                 // Print task
-                if ($lines[$i]->id > 0)
+                if ($lines[$i]->id >= 0)
                 {
                     print '<option value="'.$lines[$i]->fk_project.'_'.$lines[$i]->id.'"';
-                    if ($lines[$i]->id == $selectedtask) print ' selected="selected"';
+                    if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) print ' selected="selected"';
                     print '>';
                     print $langs->trans("Project").' '.$lines[$i]->projectref;
                     if (empty($lines[$i]->public))
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index 751ebbdfc5ffd89031551eece576d96d60ce952c..3f22eb93187be7733e51f9e2d36bf4b6e228c52a 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -268,8 +268,8 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
 					{
 						// Note that having a user assigned to a task into a project user has no permission on, should not be possible
 						// because assignement on task can be done only on contact of project.
-						// If assignement was done and after, was removed from contact of project, then we can hide the line. 
-						$showline=0;	 
+						// If assignement was done and after, was removed from contact of project, then we can hide the line.
+						$showline=0;
 					}
 				}
 			}
@@ -285,7 +285,6 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
 
 				print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n";
 
-				// Project
 				if ($showproject)
 				{
 					print "<td>";
@@ -383,7 +382,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
 				if (! $showlineingray) $inc++;
 
 				$level++;
-				if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, 0, $showalsopublicproj);
+				if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
 				$level--;
 				$total += $lines[$i]->duration;
 			}
@@ -394,7 +393,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
 		}
 	}
 
-	if ($total>0)
+	if ($total>0 && $level==0)
 	{
 		print '<tr class="liste_total">';
 		print '<td class="liste_total">'.$langs->trans("Total").'</td>';
@@ -404,9 +403,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
 		print '<td></td>';
 		print '<td></td>';
 		print '<td></td>';
-		if ($addordertick) print '<td class="hideonsmartphone"></td>';
 		print '<td align="right" class="nowrap liste_total">'.convertSecondToTime($total, 'allhourmin').'</td>';
 		print '<td></td>';
+		if ($addordertick) print '<td class="hideonsmartphone"></td>';
 		print '</tr>';
 	}
 
@@ -501,7 +500,7 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr
 
 			// Time spent
 			print '<td align="right">';
-			if ($lines[$i]->duration) 
+			if ($lines[$i]->duration)
 			{
 				print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
 				print convertSecondToTime($lines[$i]->duration,'allhourmin');
diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php
index b423abe25c4d4093eec96641eecdc6b071a6a0e7..db473165d54214bb88ed7a495562f197e31aeb86 100644
--- a/htdocs/projet/tasks.php
+++ b/htdocs/projet/tasks.php
@@ -47,17 +47,15 @@ $object = new Project($db);
 $taskstatic = new Task($db);
 $extrafields_project = new ExtraFields($db);
 $extrafields_task = new ExtraFields($db);
-if ($ref)
+if ($id > 0 || $ref)
 {
-	$object->fetch(0,$ref);
+	$object->fetch($id,$ref);
 	$id=$object->id;
-}
+	$ref=$object->ref;
 
-// fetch optionals attributes and labels
-if (!empty($id)) {
+	// fetch optionals attributes and labels
 	$extralabels_projet=$extrafields_project->fetch_name_optionals_label($object->table_element);
 	$extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->table_element);
-
 }
 
 // Security check
@@ -295,7 +293,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie
 
 	// List of projects
 	print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfTask").'</td><td>';
-	print $formother->selectProjectTasks('',$projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1);
+	print $formother->selectProjectTasks(GETPOST('task_parent'),$projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1);
 	print '</td></tr>';
 
 	print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
@@ -351,11 +349,11 @@ else
 {
 	/*
 	 * Fiche projet en mode visu
-	*/
+	 */
 
 	/*
 	 * Actions
-	*/
+	 */
 	print '<div class="tabsAction">';
 
 	if ($user->rights->projet->all->creer || $user->rights->projet->creer)
@@ -424,12 +422,12 @@ else
 	if (count($tasksarray) > 0)
 	{
 		// Show all lines in taskarray (recursive function to go down on tree)
-		$j=0;
+		$j=0; $level=0;
 		$nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $id, 1);
 	}
 	else
 	{
-		print '<tr><td colspan="'.(! empty($object->id) ? "5" : "4").'">'.$langs->trans("NoTasks").'</td></tr>';
+		print '<tr><td colspan="9">'.$langs->trans("NoTasks").'</td></tr>';
 	}
 	print "</table>";
 
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index f6532e09d31e55fe5d7d5228f604fb2197cdd6b6..304781e8309e7a25380a65c6e817b5d9e6b189e9 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -60,12 +60,12 @@ if ($action == 'addtimespent' && $user->rights->projet->creer)
 	$timespent_durationmin = GETPOST('timespent_durationmin','int');
 	if (empty($timespent_durationhour) && empty($timespent_durationmin))
 	{
-		$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")).'</div>';
+		setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")),'errors');
 		$error++;
 	}
 	if (empty($_POST["userid"]))
 	{
-		$mesg='<div class="error">'.$langs->trans('ErrorUserNotAffectedToTask').'</div>';
+		setEventMessage($langs->trans('ErrorUserNotAffectedToTask'),'errors');
 		$error++;
 	}
 
@@ -82,11 +82,12 @@ if ($action == 'addtimespent' && $user->rights->projet->creer)
 		$result=$object->addTimeSpent($user);
 		if ($result >= 0)
 		{
-
+			setEventMessage($langs->trans("RecordSaved"));
 		}
 		else
 		{
-			$mesg='<div class="error">'.$langs->trans($object->error).'</div>';
+			setEventMessage($langs->trans($object->error),'errors');
+			$error++;
 		}
 	}
 	else
@@ -101,7 +102,7 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->cree
 
 	if (empty($_POST["new_durationhour"]) && empty($_POST["new_durationmin"]))
 	{
-		$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")).'</div>';
+		setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")),'errors');
 		$error++;
 	}
 
@@ -120,11 +121,12 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->cree
 		$result=$object->updateTimeSpent($user);
 		if ($result >= 0)
 		{
-
+			setEventMessage($langs->trans("RecordSaved"));
 		}
 		else
 		{
-			$mesg='<div class="error">'.$langs->trans($object->error).'</div>';
+			setEventMessage($langs->trans($object->error),'errors');
+			$error++;
 		}
 	}
 	else
@@ -141,7 +143,8 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->c
 	if (!$result)
 	{
 		$langs->load("errors");
-		$mesg='<div class="error">'.$langs->trans($object->error).'</div>';
+		setEventMessage($langs->trans($object->error),'errors');
+		$error++;
 		$action='';
 	}
 }