\n";
@@ -328,6 +354,42 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject=1, &$taskro
return $inc;
}
+
+/**
+ * Search in task lines with a particular parent if there is a task for a particular user (in taskrole)
+ * @param $inc Counter that count number of lines legitimate to show (for return)
+ * @param $parent Id of parent task to start
+ * @param $lines Array of all tasks
+ * @param $taskrole Array of task filtered on a particular user
+ * @return int 1 if there is
+ */
+function SearchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
+{
+ //print 'Search in line with parent id = '.$parent.' ';
+ for ($i = 0 ; $i < sizeof($lines) ; $i++)
+ {
+ // Process line $lines[$i]
+ if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent)
+ {
+ // If task is legitimate to show, no more need to search deeper
+ if (isset($taskrole[$lines[$i]->id]))
+ {
+ //print 'Found a legitimate task id='.$lines[$i]->id.' ';
+ $inc++;
+ return $inc;
+ }
+
+ SearchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
+ //print 'Found inc='.$inc.' ';
+
+ if ($inc > 0) return $inc;
+ }
+ }
+
+ return $inc;
+}
+
+
/**
* Clean task not linked to a parent
* @param unknown_type $db
diff --git a/htdocs/project.class.php b/htdocs/project.class.php
index 3232390006b..0fa3b46065c 100644
--- a/htdocs/project.class.php
+++ b/htdocs/project.class.php
@@ -422,8 +422,10 @@ class Project extends CommonObject
/* Liste des taches et role sur la tache du user courant dans $tasksrole */
$sql = "SELECT a.fk_projet_task, a.role";
- $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_actors as a";
- $sql .= " WHERE a.fk_user = ".$user->id;
+ $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_actors as a";
+ $sql.= " WHERE pt.rowid = a.fk_projet_task";
+ $sql.= " AND a.fk_user = ".$user->id;
+ if ($this->id) $sql.= " AND pt.fk_projet =".$this->id;
$resql = $this->db->query($sql);
if ($resql)
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index 42c1efd2499..69877390f2b 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -71,7 +71,7 @@ if ($projet->user_resp_id > 0)
}
$head=project_prepare_head($projet);
-dol_fiche_head($head, 'element', $langs->trans("Project"));
+dol_fiche_head($head, 'element', $langs->trans("Project"),0,'project');
print '
';
diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php
index a2b8ba04e7d..9065b8a8617 100644
--- a/htdocs/projet/fiche.php
+++ b/htdocs/projet/fiche.php
@@ -197,7 +197,7 @@ else
if ($projet->user_resp_id > 0) $result=$projet->fetch_user($projet->user_resp_id);
$head=project_prepare_head($projet);
- dol_fiche_head($head, 'project', $langs->trans("Project"));
+ dol_fiche_head($head, 'project', $langs->trans("Project"),0,'project');
if ($_GET["action"] == 'delete')
{
diff --git a/htdocs/projet/tasks/fiche.php b/htdocs/projet/tasks/fiche.php
index 9654c00ca54..9307199e492 100644
--- a/htdocs/projet/tasks/fiche.php
+++ b/htdocs/projet/tasks/fiche.php
@@ -1,4 +1,4 @@
-
* Copyright (C) 2004-2009 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
@@ -186,7 +186,7 @@ else
if ($_REQUEST["mode"]=='mine') $tab='mytasks';
$head=project_prepare_head($projet);
- dol_fiche_head($head, $tab, $langs->trans("Project"));
+ dol_fiche_head($head, $tab, $langs->trans("Project"),0,'project');
$param=($_REQUEST["mode"]=='mine'?'&mode=mine':'');
@@ -223,13 +223,6 @@ else
print '';
print '';
- // Get list of tasks in tasksarray and taskarrayfiltered
- // We need all tasks (even not limited to a user because a task to user
- // can have a parent that is not affected to him).
- $tasksarray=$projet->getTasksArray(0, 0, 0);
- // We load also tasks limited to a particular user
- $tasksrole=($_REQUEST["mode"]=='mine' ? $projet->getTasksRoleForUser($user) : '');
-
/*
* Actions
*/
@@ -250,6 +243,14 @@ else
print '';
print ' ';
+
+ // Get list of tasks in tasksarray and taskarrayfiltered
+ // We need all tasks (even not limited to a user because a task to user
+ // can have a parent that is not affected to him).
+ $tasksarray=$projet->getTasksArray(0, 0, 0);
+ // We load also tasks limited to a particular user
+ $tasksrole=($_REQUEST["mode"]=='mine' ? $projet->getTasksRoleForUser($user) : '');
+
print '
";
+
print '';
- if ($nboftaskshown < sizeof($tasksarray))
+ // Test if database is clean. If not we clean it.
+ //print '$nboftaskshown='.$nboftaskshown.' sizeof($tasksarray)='.sizeof($tasksarray).' sizeof($tasksrole)='.sizeof($tasksrole).' ';
+ if ($_REQUEST["mode"]=='mine')
{
- clean_orphelins($db);
+ if ($nboftaskshown < sizeof($tasksrole)) clean_orphelins($db);
+ }
+ else
+ {
+ if ($nboftaskshown < sizeof($tasksarray)) clean_orphelins($db);
}
}
diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php
index 4613f292889..5d88989c4e2 100644
--- a/htdocs/projet/tasks/index.php
+++ b/htdocs/projet/tasks/index.php
@@ -79,22 +79,28 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorde
$projet = new Project($db);
-$tasksarray=$projet->getTasksArray($_GET["mode"]=='mine'?$user:0);
+// Get list of tasks in tasksarray and taskarrayfiltered
+// We need all tasks (even not limited to a user because a task to user
+// can have a parent that is not affected to him).
+$tasksarray=$projet->getTasksArray(0, 0, 0);
+// We load also tasks limited to a particular user
+$tasksrole=($_REQUEST["mode"]=='mine' ? $projet->getTasksRoleForUser($user) : '');
+
print '
';
print '
';
-print '
'.$langs->trans("Task").'
';
-print '
'.$langs->trans("Label").'
';
+print '
'.$langs->trans("RefTask").'
';
+print '
'.$langs->trans("LabelTask").'
';
print '
'.$langs->trans("Project").'
';
print '
'.$langs->trans("TimeSpent").'
';
print "
\n";
-
-$level=0;
+// Show all lines in taskarray (recusrive function to go down on tree)
$j=0;
-PLines($j, 0, $tasksarray, $level, true);
-
+$nboftaskshown=PLines($j, 0, $tasksarray, $level, true, 1, $tasksrole);
print "