function views_gantt_plugin_style_gantt::calculate_progress in Views Gantt 7.2
Same name and namespace in other branches
- 7 views_gantt_plugin_style_gantt.inc \views_gantt_plugin_style_gantt::calculate_progress()
1 call to views_gantt_plugin_style_gantt::calculate_progress()
- views_gantt_plugin_style_gantt::render in ./
views_gantt_plugin_style_gantt.inc - Render the given style.
File
- ./
views_gantt_plugin_style_gantt.inc, line 293 - Contains the list style plugin.
Class
- views_gantt_plugin_style_gantt
- Style plugin to render Gantt charts.
Code
function calculate_progress($task) {
$progress =& $this->tasks[$task['id']]['percentcompleted'];
$duration =& $this->tasks[$task['id']]['duration'];
if (empty($this->tasks[$task['id']]['child_hours_completed'])) {
$this->tasks[$task['id']]['child_hours_completed'] = 0;
}
$child_hours_completed =& $this->tasks[$task['id']]['child_hours_completed'];
if (isset($task['children'])) {
foreach ($task['children'] as $child) {
$child_hours_completed += $this
->calculate_progress($child);
}
if ($child_hours_completed && $duration) {
$progress = (string) ceil($child_hours_completed * 100 / $duration);
$progress = $progress > 100 ? 100 : $progress;
if (isset($this->tasks[$task['id']]['columns']['progress'])) {
$this->tasks[$task['id']]['columns']['progress'] = $progress . '%';
}
}
}
$hours_completed = $duration * $progress / 100;
return $hours_completed;
}