function show_task_row ($table, $id_project, $task, $level) { global $config; global $graph_ttl; $data = array (); // Task name $data[0] = ''; for ($i = 0; $i < $level; $i++) $data[0] .= '<img src="images/small_arrow_right_green.gif" style="position: relative; top: 5px;"> '; $data[0] .= '<a href="index.php?sec=projects&sec2=operation/projects/task_detail&id_project='. $id_project.'&id_task='.$task['id'].'&operation=view">'. $task['name'].'</a>'; // Priority $data[1] = print_priority_flag_image ($task['priority'], true); // Completion $data[2] = progress_bar($task["completion"], 70, 20, $graph_ttl); // Estimation $imghelp = "Estimated hours = ".$task["hours"]; $taskhours = get_task_workunit_hours ($task["id"]); $imghelp .= ", Worked hours = $taskhours"; $a = round ($task["hours"]); $b = round ($taskhours); $mode = 2; if ($a > 0) $data[3] = histogram_2values($a, $b, __("Planned"), __("Real"), $mode, 60, 18, $imghelp, $graph_ttl); else $data[3] = '--'; // Time used on all child tasks + this task $recursive_timeused = task_duration_recursive ($task["id"]); if ($taskhours == 0) $data[4] = "--"; elseif ($taskhours == $recursive_timeused) $data[4] = $taskhours; else $data[4] = $taskhours . "<span title='Subtasks WU/HR'> (".$recursive_timeused. ")</span>"; $wu_incidents = get_incident_task_workunit_hours ($task["id"]); if ($wu_incidents > 0) $data[4] .= "<span title='".__("Time spent in related tickets")."'> ($wu_incidents) </span>"; // People $data[5] = combo_users_task ($task['id'], 1, true); $data[5] .= ' '; $data[5] .= get_db_value ('COUNT(DISTINCT(id_user))', 'trole_people_task', 'id_task', $task['id']); if ($task["start"] == $task["end"]){ $data[6] = date ('Y-m-d', strtotime ($task['start'])) . "<br>"; $data[6] .= __('Recurrence').': '.get_periodicity ($task['periodicity']); } else { // Start $start = strtotime ($task['start']); $end = strtotime ($task['end']); $now = time (); $data[6] = date ('Y-m-d', $start) ."<br>"; if ($task['completion'] == 100) { $data[6] .= '<span style="color: green">'; } else { if ($now > $end) $data[6] .= '<span style="color: red">'; else $data[6] .= '<span>'; } $data[6] .= date ('Y-m-d', $end); $data[6] .= '</span>'; } array_push ($table->data, $data); }
$a = round ($hours); $b = round (get_task_workunit_hours ($id_task)); $image = histogram_2values($a, $b, $labela, $labelb); $table_advanced->data[0][1] = print_label (__('Estimated hours'), '', '', true, $image); $labela = __('Total'); $labelb = __('Imp'); $a = round (task_workunit_cost ($id_task, 0)); $b = round (task_workunit_cost ($id_task, 1)); $image = histogram_2values($a, $b, $labela, $labelb); $table_advanced->data[0][1] .= print_label (__('Imputable estimation'), '', '', true, $image); $labela = __('Est.'); $labelb = __('Real'); $a = $estimated_cost; $b = round (task_workunit_cost ($id_task, 1)); $image = histogram_2values($a, $b, $labela, $labelb); $table_advanced->data[0][1] .= print_label (__('Cost estimation'), '', '', true, $image); //Workload distribution chart $image = graph_workunit_task (200, 170, $id_task, true); $image = '<div class="graph_frame">' . $image . '</div>'; $table_advanced->data[0][2] = print_label (__('Workunit distribution'), '', '', true, $image); $table->colspan['row_task_stats'][0] = 3; $table->data['row_task_stats'][0] = print_container_div('task_stats', __('Task statitics'), print_table($table_advanced, true), 'open', true, true); print_table ($table); ?>
function tasks_print_tree($id_project, $sql_search = '') { global $config; global $pdf_output; if ($pdf_output) { $graph_ttl = 2; } else { $graph_ttl = 1; } echo "<table class='blank' style='width:98%'>"; echo "<tr><td style='width:60%' valign='top'>"; $sql = "SELECT t.*\n\t\t\tFROM ttask t\n\t\t\tWHERE t.id_parent_task=0\n\t\t\t\tAND t.id>0\n\t\t\t\tAND t.id_project={$id_project}\n\t\t\t\t{$sql_search}\n\t\t\tORDER BY t.name"; //$sql_search = base64_encode($sql_search); $sql_count = "SELECT COUNT(*) AS num\n\t\t\tFROM ttask t\n\t\t\tWHERE t.id_parent_task=0\n\t\t\t\tAND t.id>0\n\t\t\t\tAND t.id_project={$id_project}\n\t\t\t\t{$sql_search}"; $countRows = process_sql($sql_count); if ($countRows === false) { $countRows = 0; } else { $countRows = (int) $countRows[0]['num']; } if ($countRows == 0) { echo '<h3 class="error">' . __('No tasks found') . '</h3>'; return; } $new = true; $count = 0; echo "<ul style='margin: 0; margin-top: 20px; padding: 0;'>\n"; $first = true; while ($task = get_db_all_row_by_steps_sql($new, $result, $sql)) { $new = false; $count++; echo "<li style='margin: 0; padding: 0;'>"; echo "<span style='display: inline-block;'>"; $branches = array(); if ($first) { if ($count != $countRows) { $branches[] = true; $img = print_image("images/tree/first_closed.png", true, array("style" => 'vertical-align: middle;', "id" => "tree_image" . $task['id'] . "_task_" . $task['id'], "pos_tree" => "0")); $first = false; } else { $branches[] = false; $img = print_image("images/tree/one_closed.png", true, array("style" => 'vertical-align: middle;', "id" => "tree_image" . $task['id'] . "_task_" . $task['id'], "pos_tree" => "1")); } } else { if ($count != $countRows) { $branches[] = true; $img = print_image("images/tree/closed.png", true, array("style" => 'vertical-align: middle;', "id" => "tree_image" . $task['id'] . "_task_" . $task['id'], "pos_tree" => "2")); } else { $branches[] = false; $img = print_image("images/tree/last_closed.png", true, array("style" => 'vertical-align: middle;', "id" => "tree_image" . $task['id'] . "_task_" . $task['id'], "pos_tree" => "3")); } } $task_access = get_project_access($config["id_user"], $id_project, $task["id"], false, true); if ($task_access["read"]) { // Background color if ($task["completion"] < 40) { $background_color = "background: #FFFFFF;"; } else { if ($task["completion"] < 90) { $background_color = "background: #FFE599;"; } else { if ($task["completion"] < 100) { $background_color = "background: #A4BCFA;"; } else { if ($task["completion"] == 100) { $background_color = "background: #B6D7A8;"; } else { $background_color = ""; } } } } // Priority $priority = print_priority_flag_image($task['priority'], true); // Task name $name = safe_output($task['name']); if (strlen($name) > 30) { $name = substr($name, 0, 30) . "..."; $name = "<a title='" . safe_output($task['name']) . "' href='index.php?sec=projects&sec2=operation/projects/task_detail\n\t\t\t\t\t&id_project=" . $task['id_project'] . "&id_task=" . $task['id'] . "&operation=view'>" . $name . "</a>"; } else { $name = "<a href='index.php?sec=projects&sec2=operation/projects/task_detail\n\t\t\t\t\t&id_project=" . $task['id_project'] . "&id_task=" . $task['id'] . "&operation=view'>" . $name . "</a>"; } if ($task["completion"] == 100) { $name = "<s>{$name}</s>"; } // Completion $progress = progress_bar($task['completion'], 70, 20, $graph_ttl); // Estimation $imghelp = "Estimated hours = " . $task['hours']; $taskhours = get_task_workunit_hours($task['id']); $imghelp .= ", Worked hours = {$taskhours}"; $a = round($task["hours"]); $b = round($taskhours); $mode = 2; if ($a > 0) { $estimation = histogram_2values($a, $b, __("Planned"), __("Real"), $mode, 60, 18, $imghelp, $graph_ttl); } else { $estimation = "--"; } // Time used on all child tasks + this task $recursive_timeused = task_duration_recursive($task["id"]); $time_used = _('Time used') . ": "; if ($taskhours == 0) { $time_used .= "--"; } elseif ($taskhours == $recursive_timeused) { $time_used .= $taskhours; } else { $time_used .= $taskhours . "<span title='Subtasks WU/HR'> (" . $recursive_timeused . ")</span>"; } $wu_incidents = get_incident_task_workunit_hours($task["id"]); if ($wu_incidents > 0) { $time_used .= "<span title='" . __("Time spent in related tickets") . "'> ({$wu_incidents})</span>"; } // People $people = combo_users_task($task['id'], 1, true); $people .= ' '; $people .= get_db_value('COUNT(DISTINCT(id_user))', 'trole_people_task', 'id_task', $task['id']); // Branches $branches_json = json_encode($branches); // New WO / Incident $wo_icon = print_image("images/paste_plain.png", true, array("style" => 'vertical-align: middle;', "id" => "wo_icon", "title" => __('Work order'))); $incident_icon = print_image("images/incident.png", true, array("style" => 'vertical-align: middle; height:19px; width:20px;', "id" => "incident_icon", "title" => __('Ticket'))); $wo_icon = "<a href='index.php?sec=projects&sec2=operation/workorders/wo&operation=create&id_task=" . $task['id'] . "'>{$wo_icon}</a>"; $incident_icon = "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_detail&id_task=" . $task['id'] . "'>{$incident_icon}</a>"; $launch_icons = $wo_icon . " " . $incident_icon; echo "<a onfocus='JavaScript: this.blur()' href='javascript: loadTasksSubTree(" . $task['id_project'] . "," . $task['id'] . ",\"" . $branches_json . "\", " . $task['id'] . ",\"" . $sql_search . "\")'>"; echo "<script type=\"text/javascript\">\n\t\t\t\t\t \$(document).ready (function () {\n\t\t\t\t\t\t loadTasksSubTree(" . $task['id_project'] . "," . $task['id'] . ",\"" . $branches_json . "\", " . $task['id'] . ",\"" . $sql_search . "\");\n\t\t\t\t\t });\n\t\t\t\t </script>"; echo $img; echo "</a>"; echo "<span style='" . $background_color . " padding: 4px;'>"; echo "<span style='vertical-align:middle; display: inline-block;'>" . $priority . "</span>"; echo "<span style='margin-left: 5px; min-width: 250px; vertical-align:middle; display: inline-block;'>" . $name . "</span>"; echo "<span title='" . __('Progress') . "' style='margin-left: 15px; vertical-align:middle; display: inline-block;'>" . $progress . "</span>"; echo "<span style='margin-left: 15px; min-width: 70px; vertical-align:middle; display: inline-block;'>" . $estimation . "</span>"; echo "<span style='margin-left: 15px; vertical-align:middle; display: inline-block;'>" . $people . "</span>"; echo "<span style='margin-left: 15px; min-width: 200px; display: inline-block;'>" . $time_used . "</span>"; echo "<span style='margin-left: 15px; vertical-align:middle; display: inline-block;'>" . __('New') . ": " . $launch_icons . "</span>"; echo "</span>"; } else { // Task name $name = safe_output($task['name']); if (strlen($name) > 60) { $name = substr($name, 0, 60) . "..."; $name = "<div title='" . safe_output($task['name']) . "'>" . $name . "</a>"; } if ($task["completion"] == 100) { $name = "<s>{$name}</s>"; } // Priority $priority = print_priority_flag_image($task['priority'], true); // Branches $branches_json = json_encode($branches); echo "<a onfocus='JavaScript: this.blur()' href='javascript: loadTasksSubTree(" . $task['id_project'] . "," . $task['id'] . ",\"" . $branches_json . "\", " . $task['id'] . ",\"" . $sql_search . "\")'>"; echo "<script type=\"text/javascript\">\n\t\t\t\t\t \$(document).ready (function () {\n\t\t\t\t\t\t loadTasksSubTree(" . $task['id_project'] . "," . $task['id'] . ",\"" . $branches_json . "\", " . $task['id'] . ",\"" . $sql_search . "\");\n\t\t\t\t\t });\n\t\t\t\t </script>"; echo $img; echo "</a>"; echo "<span title='" . __('You are not assigned to this task') . "' style='padding: 4px;'>"; echo "<span style='vertical-align:middle; display: inline-block;'>" . $priority . "</span>"; echo "<span style='color: #D8D8D8; margin-left: 5px; display: inline-block;'>" . $name . "</span>"; echo "</span>"; } echo "<div hiddenDiv='1' loadDiv='0' style='display: none; margin: 0px; padding: 0px;' class='tree_view tree_div_" . $task['id'] . "' id='tree_div" . $task['id'] . "_task_" . $task['id'] . "'></div>"; echo "</li>"; } echo "</ul>"; echo "</td></tr>"; echo "</table>"; return; }