diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 39c8cd80dd0..7838a3597d1 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -222,8 +222,14 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $numlines=count($lines); - $total=0; - $total_planned=0; + // We declare counter as global because we want to edit them into recursive call + global $total_projectlinesa_spent,$total_projectlinesa_planned,$total_projectlinesa_spent_if_planned; + if ($level == 0) + { + $total_projectlinesa_spent=0; + $total_projectlinesa_planned=0; + $total_projectlinesa_spent_if_planned=0; + } for ($i = 0 ; $i < $numlines ; $i++) { @@ -391,9 +397,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $level++; if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick); $level--; - $total += $lines[$i]->duration; - $total_planned += $lines[$i]->planned_workload; - // TODO fix totals in recursive calls + $total_projectlinesa_spent += $lines[$i]->duration; + $total_projectlinesa_planned += $lines[$i]->planned_workload; + if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration; } } else @@ -402,7 +408,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } - if ($total>0 && $level==0) + if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0) && $level==0) { print '
| '.$langs->trans("Project").' | '; print ''.$langs->trans("Status").' | '; -print ''.$langs->trans("RefTask").' | '; +print ''.$langs->trans("RefTask").' | '; print ''.$langs->trans("LabelTask").' | '; print ''.$langs->trans("DateStart").' | '; print ''.$langs->trans("DateEnd").' | ';