Fix: Bug into calculation of total of time for tasks
This commit is contained in:
parent
e7e5a93906
commit
8cf3d258f4
@ -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 '<tr class="liste_total">';
|
||||
print '<td class="liste_total">'.$langs->trans("Total").'</td>';
|
||||
@ -410,11 +416,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td align="center" class="nowrap liste_total">'.convertSecondToTime($total_planned, 'allhourmin').'</td>';
|
||||
print '<td align="center" class="nowrap liste_total">';
|
||||
print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
|
||||
print '</td>';
|
||||
print '<td></td>';
|
||||
print '<td align="right" class="nowrap liste_total">'.convertSecondToTime($total, 'allhourmin').'</td>';
|
||||
print '<td align="right" class="nowrap liste_total">';
|
||||
if($total_planned) print round(100 * $total / $total_planned,2).' %';
|
||||
print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
|
||||
print '</td>';
|
||||
print '<td align="right" class="nowrap liste_total">';
|
||||
if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent_if_planned / $total_projectlinesa_planned,2).' %';
|
||||
print '</td>';
|
||||
if ($addordertick) print '<td class="hideonsmartphone"></td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -98,7 +98,7 @@ print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Project").'</td>';
|
||||
print '<td>'.$langs->trans("Status").'</td>';
|
||||
print '<td width="80">'.$langs->trans("RefTask").'</td>';
|
||||
print '<td>'.$langs->trans("RefTask").'</td>';
|
||||
print '<td>'.$langs->trans("LabelTask").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateStart").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user