/** * prints a milestone summary of an assoc. array * * For more details about the available information, see Task->getMilestoneTasksSummary() */ private function render_milestoneGraph($milestone_task_summary) { global $PH; $width = 220; if ($milestone_task_summary['num_open'] + $milestone_task_summary['num_closed']) { $width_closed = floor($width * $milestone_task_summary['num_closed'] / ($milestone_task_summary['num_open'] + $milestone_task_summary['num_closed'])); $width_completed = floor($width * $milestone_task_summary['num_need_approval'] / ($milestone_task_summary['num_open'] + $milestone_task_summary['num_closed'])); if ($width_completed + $width_closed > $width) { $width_completed = $width - $width_closed; } } else { $width_closed = 0; $width_completed = 0; } echo "<div style='width:" . ($width + 2) . "px;height:10px;border:1px solid #ccc;background-color:#fff;'>"; if ($width_closed) { echo "<div style='float:left;width:{$width_closed}px;height:10px;background-color:#90BC54;'></div>"; } if ($width_completed) { echo "<div style='float:left;width:{$width_completed}px;height:10px;background-color:#CEE98B;;border-left:1px solid #fff;'></div>"; } echo "</div>"; echo $PH->getLink('projViewTasks', sprintf(__("%s completed task"), $milestone_task_summary['num_closed']), array('prj' => $this->project->id, 'for_milestone' => $this->current_milestone->id, 'preset' => 'closed_tasks')) . $PH->getLink('projViewTasks', sprintf(__("%s open"), $milestone_task_summary['num_open'] - $milestone_task_summary['num_need_approval']), array('prj' => $this->project->id, 'for_milestone' => $this->current_milestone->id, 'preset' => 'next_milestone'), "open_task_count") . '<br>'; if ($milestone_task_summary['num_need_approval']) { echo $PH->getLink('projViewTasks', $milestone_task_summary['num_need_approval'] < 2 ? sprintf(__("%s needs approval"), $milestone_task_summary['num_need_approval']) : sprintf(__("%s need approval"), $milestone_task_summary['num_need_approval']), array('prj' => $this->project->id, 'for_milestone' => $this->current_milestone->id, 'preset' => 'approve_tasks')); } if ($milestone_task_summary['sum_estimated_min']) { echo renderEstimationGraph($milestone_task_summary['sum_estimated_min'], $milestone_task_summary['sum_estimated_max'], $milestone_task_summary['sum_completion_min'] / $milestone_task_summary['sum_estimated_min'] * 100); } }
function render_tr(&$obj, $style = "nowrap") { if (!isset($obj) || !$obj instanceof Task) { return; } $str = renderEstimationGraph($obj->estimated, $obj->estimated_max, $obj->completion); print "<td>{$str}</td>"; }
function render_tr(&$obj, $style = "") { if (!isset($obj) || !$obj instanceof Task) { trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING); return; } global $PH; /** * we need to get the open tasks here */ if ($this->parent_block->num_open == 0 && $this->parent_block->num_closed == 0) { echo "<td></td>"; } else { $width = 150; if ($this->parent_block->num_open + $this->parent_block->num_closed) { $width_closed = floor($width * $this->parent_block->num_closed / ($this->parent_block->num_open + $this->parent_block->num_closed)); $width_completed = floor($width * $this->parent_block->num_completed / ($this->parent_block->num_open + $this->parent_block->num_closed)); if ($width_completed + $width_closed > $width) { $width_completed = $width - $width_closed; } } else { $width_closed = 0; $width_completed = 0; } echo "<td>"; echo "<div style='width:" . ($width + 2) . "px;height:10px;border:1px solid #ccc;background-color:#fff;'>"; if ($width_closed) { echo "<div style='float:left;width:{$width_closed}px;height:10px;background-color:#90BC54;'></div>"; } if ($width_completed) { echo "<div style='float:left;width:{$width_completed}px;height:10px;background-color:#CEE98B;;border-left:1px solid #fff;'></div>"; } echo "</div>"; if (!$obj->view_collapsed) { echo $PH->getLink('projViewTasks', $this->parent_block->num_closed . " " . __("closed"), array('prj' => $obj->project, 'for_milestone' => $obj->id, 'preset' => 'closed_tasks')) . " / " . $PH->getLink('projViewTasks', $this->parent_block->num_open - $this->parent_block->num_completed . " " . __("open"), array('prj' => $obj->project, 'for_milestone' => $obj->id, 'preset' => 'next_milestone')) . '<br>'; if ($this->parent_block->sum_estimated_min) { echo renderEstimationGraph($this->parent_block->sum_estimated_min, $this->parent_block->sum_estimated_max, $this->parent_block->sum_completion_min / $this->parent_block->sum_estimated_min * 100); } } echo "</td>"; } }