Пример #1
0
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);
}
Пример #2
0
		echo "</h3>";
		
		$table = new StdClass();
		$table->width = '100%';
		$table->class = 'listing';
		$table->data = array ();
		$table->size = array ();
		$table->style = array ();
		$table->head = array();
		$table->head[0] = __('Project');
		$table->head[1] = __('Task');

		foreach ($tasks as $task) {
			$data = array ();
		
		if (user_belong_project ($config["id_user"], $task["project_id"])){

				$data[0] = "<a href='index.php?sec=projects&sec2=operation/projects/task&id_project=".$task["project_id"]."'>".$task["pname"]."</a>";

				$data[1] = "<a href='index.php?sec=projects&sec2=operation/projects/task_detail&id_project=".$task["project_id"]."&id_task=".$task["task_id"]."&operation=view'>".$task["tname"]."</a>";

				array_push ($table->data, $data);
			}
		}
		print_table ($table);
	}
}

// Users - Only for UM
if (give_acl($config["id_user"], 0, "UM")){