Пример #1
0
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);
}
Пример #2
0
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>";
}
Пример #3
0
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 . "&nbsp;" . $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;
}