function get_tasks_gantt(&$tasks, $project_id, $project_start, $project_end, $parent_id = 0, $depth = 0, $show_actual = 0) { global $config; $id_user = $config["id_user"]; $result = mysql_query('SELECT * FROM ttask WHERE id_parent_task = ' . $parent_id . ' AND id_project = ' . $project_id); if ($result === false) { return; } while ($row = mysql_fetch_array($result)) { // ACL Check for this task // This user can see this task? $task_access = get_project_access($config["id_user"], $project_id, $row['id'], false, true); if ($task_access["read"]) { $task['id'] = $row['id']; $task['name'] = $row['name']; if ($show_actual) { $task["name"] .= " (" . __("Planned") . ")"; } $task['parent'] = $parent_id; $task['link'] = 'index.php?sec=projects&sec2=operation/projects/task_detail&id_project=' . $project_id . '&id_task=' . $row['id'] . '&operation=view'; // start > end $task['start'] = fix_date($row['start'], $project_start); $task['end'] = fix_date($row['end'], $project_end); if (date_to_epoch($task['start']) > date_to_epoch($task['end'])) { $temp = $task['start']; $task['start'] = $task['end']; $task['end'] = $temp; } $task['real_start'] = fix_date(get_db_sql('SELECT MIN(timestamp) FROM tworkunit, tworkunit_task WHERE tworkunit_task.id_workunit = tworkunit.id AND timestamp <> \'0000-00-00 00:00:00\' AND id_task = ' . $row['id']), $task['start']); $task['real_end'] = fix_date(get_db_sql('SELECT MAX(timestamp) FROM tworkunit, tworkunit_task WHERE tworkunit_task.id_workunit = tworkunit.id AND timestamp <> \'0000-00-00 00:00:00\' AND id_task = ' . $row['id']), $task['start']); $task['completion'] = $row['completion']; $task["actual_data"] = 0; $task["worked_hours"] = get_task_workunit_hours($row["id"]); $task["hours"] = $row["hours"]; array_push($tasks, $task); //Add another task to represent real effort for the task if ($show_actual) { $task_aux = array(); $task_aux["id"] = $task["id"] . "act"; $task_aux["actual_data"] = 1; $task_aux["parent"] = $task["parent"]; if ($task['real_start']) { $task_aux["start"] = $task['real_start']; } else { $task_aux["start"] = $task['start']; } if ($task['real_end']) { $task_aux["end"] = $task['real_end']; } else { $task_aux["end"] = $task['start']; } $task_aux["completion"] = 0; $task_aux["name"] = $row["name"] . " (" . __("Actual") . ")"; array_push($tasks, $task_aux); } get_tasks_gantt(&$tasks, $project_id, $project_start, $project_end, $task['id'], $depth + 1, $show_actual); } } }
function all_project_tree($id_user, $completion, $project_kind) { include "../include/config.php"; $config["id_user"] = $id_user; $dotfilename = $config["homedir"] . "/attachment/tmp/{$id_user}.all.dot"; $pngfilename = $config["homedir"] . "/attachment/tmp/{$id_user}.projectall.png"; $mapfilename = $config["homedir"] . "/attachment/tmp/{$id_user}.projectall.map"; $dotfile = fopen($dotfilename, "w"); fwrite($dotfile, "digraph Integria {\n"); fwrite($dotfile, "\t ranksep=1.8;\n"); fwrite($dotfile, "\t ratio=auto;\n"); fwrite($dotfile, "\t size=\"9,9\";\n"); fwrite($dotfile, 'URL="' . $config["base_url"] . '/index.php?sec=projects&sec2=operation/projects/project_tree";' . "\n"); fwrite($dotfile, "\t node[fontsize=" . $config['fontsize'] . "];\n"); fwrite($dotfile, "\t me [label=\"{$id_user}\", style=\"filled\", color=\"yellow\"]; \n"); $total_project = 0; $total_task = 0; if ($project_kind == "all") { $sql1 = "SELECT * FROM tproject WHERE disabled = 0"; } else { $sql1 = "SELECT * FROM tproject WHERE disabled = 0 AND end != '0000-00-00 00:00:00'"; } if ($result1 = mysql_query($sql1)) { while ($row1 = mysql_fetch_array($result1)) { if (user_belong_project($id_user, $row1["id"], 1) == 1) { $project[$total_project] = $row1["id"]; $project_name[$total_project] = $row1["name"]; if ($completion < 0) { $sql2 = "SELECT * FROM ttask WHERE id_project = " . $row1["id"]; } elseif ($completion < 101) { $sql2 = "SELECT * FROM ttask WHERE completion < {$completion} AND id_project = " . $row1["id"]; } else { $sql2 = "SELECT * FROM ttask WHERE completion = 100 AND id_project = " . $row1["id"]; } if ($result2 = mysql_query($sql2)) { while ($row2 = mysql_fetch_array($result2)) { if (user_belong_task($id_user, $row2["id"], 1) == 1) { $task[$total_task] = $row2["id"]; $task_name[$total_task] = $row2["name"]; $task_parent[$total_task] = $row2["id_parent_task"]; $task_project[$total_task] = $project[$total_project]; $task_workunit[$total_task] = get_task_workunit_hours($row2["id"]); $task_completion[$total_task] = $row2["completion"]; $total_task++; } } } $total_project++; } } } // Add project items for ($ax = 0; $ax < $total_project; $ax++) { fwrite($dotfile, 'PROY' . $project[$ax] . ' [label="' . wordwrap($project_name[$ax], 12, '\\n') . '", style="filled", color="grey", URL="' . $config["base_url"] . '/index.php?sec=projects&sec2=operation/projects/task&id_project=' . $project[$ax] . '"];'); fwrite($dotfile, "\n"); } // Add task items for ($ax = 0; $ax < $total_task; $ax++) { $temp = 'TASK' . $task[$ax] . ' [label="' . wordwrap($task_name[$ax], 12, '\\n') . '"'; if ($task_completion[$ax] < 10) { $temp .= 'color="red"'; } elseif ($task_completion[$ax] < 100) { $temp .= 'color="yellow"'; } elseif ($task_completion[$ax] == 100) { $temp .= 'color="green"'; } $temp .= "URL=\"" . $config["base_url"] . "/index.php?sec=projects&sec2=operation/projects/task_detail&id_project=" . $task_project[$ax] . "&id_task=" . $task[$ax] . "&operation=view\""; $temp .= "];"; fwrite($dotfile, $temp); fwrite($dotfile, "\n"); } // Make project attach to user "me" for ($ax = 0; $ax < $total_project; $ax++) { fwrite($dotfile, 'me -> PROY' . $project[$ax] . ';'); fwrite($dotfile, "\n"); } // Make project first parent task relation visible for ($ax = 0; $ax < $total_task; $ax++) { if ($task_parent[$ax] == 0) { fwrite($dotfile, 'PROY' . $task_project[$ax] . ' -> TASK' . $task[$ax] . ';'); fwrite($dotfile, "\n"); } } // Make task-subtask parent task relation visible for ($ax = 0; $ax < $total_task; $ax++) { if ($task_parent[$ax] != 0) { fwrite($dotfile, 'TASK' . $task_parent[$ax] . ' -> TASK' . $task[$ax] . ';'); fwrite($dotfile, "\n"); } } fwrite($dotfile, "}"); fwrite($dotfile, "\n"); // exec ("twopi -Tpng $dotfilename -o $pngfilename"); exec("twopi -Tcmapx -o{$mapfilename} -Tpng -o{$pngfilename} {$dotfilename}"); Header('Content-type: image/png'); $imgPng = imageCreateFromPng($pngfilename); imageAlphaBlending($imgPng, true); imageSaveAlpha($imgPng, true); imagePng($imgPng); require $mapfilename; //unlink ($pngfilename); unlink($dotfilename); }
function show_task_row($table, $id_project, $task, $level, $users) { global $config; $id_task = $task['id']; // Second column (Task name) $prefix = ''; for ($i = 0; $i < $level; $i++) { $prefix .= '<img src="images/small_arrow_right_green.gif" style="position: relative; top: 5px;"> '; } echo "<td>"; echo $prefix . print_input_text("name_" . $id_task, $task['name'], "", 40, 0, true); echo "</td>"; // Thrid column (Owner)Completion echo "<td style='text-align:center;'>"; $owners = get_db_value('COUNT(DISTINCT(id_user))', 'trole_people_task', 'id_task', $task['id']); if ($owners > 1) { echo combo_users_task($task['id'], 1, true); echo ' '; echo $owners; } else { $owner_id = get_db_value('id_user', 'trole_people_task', 'id_task', $task['id']); print_select($users, "owner_" . $id_task, $owner_id, '', '', 0, false, 0, true, false, false, 'width: 90px'); } echo "</td>"; // Fourth column (Start date) echo "<td style='text-align:center;'>"; print_input_text_extended("start_" . $id_task, $task['start'], "start_" . $id_task, '', 7, 15, 0, '', 'style="font-size:9px;"'); echo "</td>"; // Fifth column (End date) echo "<td style='text-align:center;'>"; print_input_text_extended("end_" . $id_task, $task['end'], "end_" . $id_task, '', 7, 15, 0, '', 'style="font-size:9px;"'); echo "</td>"; //Worked time based on workunits $worked_time = get_task_workunit_hours($id_task); echo "<td style='text-align:left;'>" . $worked_time . "</td>"; // Sixth column (Delay) //If task was completed delay is 0 if ($task['completion']) { $delay = 0; } else { //If was not completed check for time delay from end to now $end = strtotime($task['end']); $now = time(); $a_day_in_sec = 3600 * 24; if ($now > $end) { $diff = $now - $end; $delay = $diff / $a_day_in_sec; $delay = round($delay, 1); } else { $delay = 0; } } echo "<td style='text-align:left;'>" . $delay . "</td>"; // Seventh column (Delay) //Task status /* * 0%-40% = Pending * 41%-90% = In process * 91%-99% = Completed * 100% = Verified * */ //Check selected status $selected = 0; if ($task['completion'] < 40) { $selected = 0; } else { if ($task['completion'] < 90) { $selected = 45; } else { if ($task['completion'] < 100) { $selected = 95; } else { if ($task['completion'] == 100) { $selected = 100; } } } } $fields = array(); $fields[0] = __("Pending"); $fields[45] = __("In process"); $fields[95] = __("Completed"); $fields[100] = __("Verified"); echo "<td>"; print_select($fields, "status_" . $id_task, $selected, '', '', 0, false, 0, true, false, false, "width: 100px;"); echo "</td>"; // Last Edit and del column. (Del) Only for PM flag //Create new task only if PM && TM flags or PW and project manager. echo "<td style='text-align:center;'>"; echo '<a href="index.php?sec=projects&sec2=operation/projects/task_detail&id_project=' . $id_project . '&id_task=' . $task['id'] . '&operation=view">'; echo '<img style="margin-right: 6px;" src="images/wrench.png">'; echo '</a>'; echo '<a href="index.php?sec=projects&sec2=operation/projects/task_planning&id_project=' . $id_project . '&delete=' . $task["id"] . '" onClick="if (!confirm(\'' . __('Are you sure?') . '\')) return false;"><img src="images/cross.png" /></a>'; echo "</td>"; }
$external_cost = 0; $external_cost = task_cost_invoices ($id_task); if (!$external_cost) { $external_cost = 0; } $table_advanced->data[0][0] .= print_label (__("External costs"), '', '', true); $table_advanced->data[0][0] .= $external_cost . " " . $config["currency"]; // Abbreviation for "Estimated" $labela = __('Est.'); $labelb = __('Real'); $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));
echo "<li id='sidesel'>"; } else { echo "<li>"; } echo "<a href='index.php?sec=projects&sec2=operation/projects/task_emailreport&id_task={$id_task}&id_project={$id_project}'>" . __('Email report') . "</a></li>"; // Move this task if ($sec2 == "operation/projects/task_move") { echo "<li id='sidesel'>"; } else { echo "<li>"; } echo "<a href='index.php?sec=projects&sec2=operation/projects/task_move&id_task={$id_task}&id_project={$id_project}'>" . __('Move task') . "</a></li>"; } // Workunits $totalhours = get_task_workunit_hours($id_task); $totalwu = get_task_workunit_hours($id_task); if ($totalwu > 0) { if ($sec2 == "operation/projects/task_workunit" && $id_task > 0) { echo "<li id='sidesel'>"; } else { echo "<li>"; } echo "<a href='index.php?sec=projects&sec2=operation/projects/task_workunit&id_project={$id_project}&id_task={$id_task}'>" . __('Workunits'); echo " ({$totalhours} " . __('Hours') . ")"; echo "</a></li>"; } // Incidents for this task $task_incidents = get_incident_task($id_task); if ($task_incidents > 0) { $task_incidents_wu = get_incident_task_workunit_hours($id_task); if ($sec2 == "operation/projects/task_incidents") {
$result = process_sql ($sql, 'insert_id'); $id_workunit = $result; } else { // UPDATE WORKUNIT $sql = sprintf ('UPDATE tworkunit SET timestamp = "%s", duration = %.2f, description = "%s", have_cost = %d, id_profile = %d WHERE id = %d', $timestamp, $duration, $description, $have_cost, $user_role, $id_workunit); $result = process_sql ($sql); } if ($result) { $task = get_db_row ('ttask', 'id', $id_task); $current_hours = get_task_workunit_hours ($id_task); if ($insert) { mail_project (0, $config['id_user'], $id_workunit, $id_task); $sql = sprintf ('INSERT INTO tworkunit_task (id_task, id_workunit) VALUES (%d, %d)', $id_task, $id_workunit); process_sql ($sql); $result_output = ui_print_success_message (__('Workunit added'), '', true, 'h3', true); audit_db ($config["id_user"], $config["REMOTE_ADDR"], "PWU", "Inserted PWU. $description"); task_tracking ($id_task, TASK_WORKUNIT_ADDED, $id_workunit); /* Autocomplete task progress */ if ($task['completion'] < 100) { /* Get expected task completion, based on worked hours */ $expected_completion = round_number (floor ($current_hours * 100 / $task['hours']));
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); }
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; }
$belong_task = user_belong_task($id_user, $task['id'], true); $task_access = get_project_access($config['id_user'], $project['id'], $task['id'], false, true); // ACL - To see the task, you should have read access if (!$task_access['read']) { continue; // Does not show this task } $role = get_db_sql("SELECT name\n\t\t\t\t\t\t\t FROM trole\n\t\t\t\t\t\t\t WHERE id IN(SELECT id_role\n\t\t\t\t\t\t\t\t\t\t FROM trole_people_task\n\t\t\t\t\t\t\t\t\t\t WHERE id_user='******'\n\t\t\t\t\t\t\t\t\t\t\tAND id_task=" . $task['id'] . ")"); echo "<tr>"; echo "<td>"; echo "<a href='index.php?sec=projects&sec2=operation/projects/project_detail&id_project=" . $project['id'] . "'>" . $project['name'] . "</a>"; echo "<td><b><a href='index.php?sec=projects&sec2=operation/projects/task_detail&id_project=" . $project['id'] . "&id_task=" . $task['id'] . "&operation=view'>" . $task['name'] . "</a></b>"; echo "<td>" . $role; if ($belong_task) { echo "<td>" . get_task_workunit_hours_user($task["id"], $id_user); echo "<td>" . get_task_workunit_hours($task["id"]); } else { echo "<td>"; echo "<td>"; } if ($task_access['manage'] && $belong_task) { echo "<td align='center'><a href='index.php?sec=projects&sec2=operation/projects/role_user_global&id_user="******"&delete=" . $task['id'] . "' onClick='if (!confirm('" . __('Are you sure?') . "')) return false;'><img border=0 src='images/cross.png'></a>"; } else { echo "<td align='center'>"; } } $new = false; } echo "</table>"; ?>
$sql = sprintf ('SELECT ttask.id as id, ttask.name as name, SUM(tworkunit.duration) as sum FROM tproject, ttask, tworkunit_task, tworkunit WHERE tworkunit_task.id_workunit = tworkunit.id AND ttask.id_project = %d '. $user_search . ' AND tworkunit_task.id_task = ttask.id AND ttask.id_project = tproject.id AND tworkunit.timestamp >= "%s" AND tworkunit.timestamp <= "%s" '. $task_selector .' GROUP BY ttask.name', $project['id'], $start_date, $end_date); $tasks = get_db_all_rows_sql ($sql); if ($tasks) { foreach ($tasks as $task) { $total_task = get_task_workunit_hours ($task['id']); if ($only_summary == 0){ echo "<tr>"; echo "<td> <img src='images/copy.png'>"; echo "<a href='index.php?sec=users&sec2=operation/users/user_workunit_report×tamp_l=$start_date×tamp_h=$end_date&id=$user_id&id_task=".$task['id']."'>"; echo $task['name']; echo "</a>"; echo "</td><td>"; echo $task['sum']; echo "</td><td>"; echo $total_task; echo "</td><td>"; if ($total_task > 0) echo format_numeric ($task['sum'] / ($total_task / 100))."%";
function print_task_tabs($selected_tab = '', $id_task_param = false) { global $config; $id_project = get_parameter('id_project', -1); $id_task = $id_task_param !== false ? $id_task_param : get_parameter('id_task', -1); // Get id_task but not id_project if ($id_task != -1 and $id_project == -1) { $id_project = get_db_value("id_project", "ttask", "id", $id_task); } $task_permission = array(); if ($id_task > 0) { $task_permission = get_project_access($config["id_user"], $id_project, $id_task, false, true); } $t_menu = array(); $t_menu['overview_project'] = array('title' => __('Project overview'), 'link' => "operation/projects/project_detail&id_project=" . $id_project, 'img' => "images/eye.png"); $t_menu['overview'] = array('title' => __('Tasks overview'), 'link' => "operation/projects/task&id_project=" . $id_project, 'img' => "images/tree_list.png"); $t_menu['detail'] = array('title' => __('Task detail'), 'link' => "operation/projects/task_detail&id_project=" . $id_project . "&id_task=" . $id_task . "&operation=view", 'img' => "images/inventory_dark.png"); $t_menu['tracking'] = array('title' => __('Task traking'), 'link' => "operation/projects/task_tracking&id_project=" . $id_project . "&id_task=" . $id_task . "&operation=view", 'img' => "images/clock_tab.png"); if ($task_permission['write']) { $t_menu['workunit_add'] = array('title' => __('Add workunit'), 'link' => "operation/users/user_spare_workunit&id_project=" . $id_project . "&id_task=" . $id_task, 'img' => "images/multiple_workunits_tab.png"); $t_menu['costs'] = array('title' => __('View external costs'), 'link' => "operation/projects/task_cost&id_project=" . $id_project . "&id_task=" . $id_task . "&operation=list", 'img' => "images/money.png"); } if ($task_permission['manage']) { $t_menu['people'] = array('title' => __('People'), 'link' => "operation/projects/people_manager&id_project=" . $id_project . "&id_task=" . $id_task, 'img' => "images/contacts.png"); $t_menu['email'] = array('title' => __('E-mail report'), 'link' => "operation/projects/task_emailreport&id_project=" . $id_project . "&id_task=" . $id_task, 'img' => "images/email_dark.png"); $t_menu['move'] = array('title' => __('Move task'), 'link' => "operation/projects/task_move&id_project=" . $id_project . "&id_task=" . $id_task, 'img' => "images/move_task.png"); } $totalhours = get_task_workunit_hours($id_task); $totalwu = get_task_count_workunits($id_task); if ($totalwu > 0) { $t_menu['workunits'] = array('title' => __('Workunits') . " (" . $totalhours . " " . __("Hours") . ")", 'link' => "operation/projects/task_workunit&id_project=" . $id_project . "&id_task=" . $id_task, 'img' => "images/workunit_tab.png"); } else { $t_menu['workunits'] = array('title' => __('Workunit') . " (" . __("Empty") . ")", 'link' => "", 'img' => "images/workunit_disabled.png"); } $numberfiles = give_number_files_project($id_project); //if ($numberfiles > 0){ $t_menu['files'] = array('title' => __('Files') . "(" . $numberfiles . ")", 'link' => "operation/projects/task_files&id_project=" . $id_project . "&id_task=" . $id_task, 'img' => "images/products/folder.png"); /*} else { $t_menu['files'] = array ( 'title' => __('Files') . "(" . __("Empty") . ")", 'img' => "images/folder_disabled.png", ); }*/ if ($selected_tab == 'detail') { $t_menu['report'] = array('title' => __('Task report'), 'link' => "operation/projects/task_report&id_project=" . $id_project . "&id_task=" . $id_task, 'img' => "images/chart_bar_dark.png"); } if ($selected_tab == 'workunits') { $t_menu['report_gant'] = array('title' => __('Tasks report'), 'link' => "operation/projects/task_workunit&id_project=" . $id_project . "&id_task=" . $id_task . "&pure=1", 'img' => "images/chart_bar_dark.png"); } return $t_menu; }