Example #1
0
/**
 * Show task lines with a particular parent
 * @param 	$inc				Counter that count number of lines legitimate to show (for return)
 * @param 	$parent				Id of parent task to start
 * @param 	$lines				Array of all tasks
 * @param 	$level				Level of task
 * @param 	$var				Color
 * @param 	$showproject		Show project columns
 * @param	$taskrole			Array of roles of user for each tasks
 * @param	$projectsListId		List of id of project allowed to user (separated with comma)
 */
function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '')
{
    global $user, $bc, $langs;
    $lastprojectid = 0;
    $projectstatic = new Project($db);
    $taskstatic = new Task($db);
    $projectsArrayId = explode(',', $projectsListId);
    $numlines = sizeof($lines);
    $total = 0;
    for ($i = 0; $i < $numlines; $i++) {
        if ($parent == 0) {
            $level = 0;
        }
        // Process line
        // print "i:".$i."-".$lines[$i]->fk_project.'<br>';
        if ($lines[$i]->fk_parent == $parent) {
            // Show task line.
            $showline = 1;
            $showlineingray = 0;
            // If there is filters to use
            if (is_array($taskrole)) {
                // If task not legitimate to show, search if a legitimate task exists later in tree
                if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) {
                    // So search if task has a subtask legitimate to show
                    $foundtaskforuserdeeper = 0;
                    SearchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole);
                    //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>';
                    if ($foundtaskforuserdeeper > 0) {
                        $showlineingray = 1;
                        // We will show line but in gray
                    } else {
                        $showline = 0;
                        // No reason to show line
                    }
                }
            }
            if ($showline) {
                // Break on a new project
                if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
                    $var = !$var;
                    $lastprojectid = $lines[$i]->fk_project;
                }
                print "<tr " . $bc[$var] . ">\n";
                // Project
                if ($showproject) {
                    print "<td>";
                    //var_dump($taskrole);
                    if ($showlineingray) {
                        print '<i>';
                    }
                    $projectstatic->id = $lines[$i]->fk_project;
                    $projectstatic->ref = $lines[$i]->projectref;
                    $projectstatic->public = $lines[$i]->public;
                    if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId)) {
                        print $projectstatic->getNomUrl(1);
                    } else {
                        print $projectstatic->getNomUrl(1, 'nolink');
                    }
                    if ($showlineingray) {
                        print '</i>';
                    }
                    print "</td>";
                }
                // Ref of task
                print '<td>';
                if ($showlineingray) {
                    print '<i>' . img_object('', 'projecttask') . ' ' . $lines[$i]->id . '</i>';
                } else {
                    $taskstatic->id = $lines[$i]->id;
                    $taskstatic->ref = $lines[$i]->id;
                    $taskstatic->label = $taskrole[$lines[$i]->id] ? $langs->trans("YourRole") . ': ' . $taskrole[$lines[$i]->id] : '';
                    print $taskstatic->getNomUrl(1);
                }
                print '</td>';
                // Title of task
                print "<td>";
                if ($showlineingray) {
                    print '<i>';
                } else {
                    print '<a href="' . DOL_URL_ROOT . '/projet/tasks/task.php?id=' . $lines[$i]->id . '">';
                }
                for ($k = 0; $k < $level; $k++) {
                    print "&nbsp; &nbsp; &nbsp;";
                }
                print $lines[$i]->label;
                if ($showlineingray) {
                    print '</i>';
                } else {
                    print '</a>';
                }
                print "</td>\n";
                // Progress
                print '<td align="right">';
                print $lines[$i]->progress . ' %';
                print '</td>';
                // Time spent
                print '<td align="right">';
                if ($showlineingray) {
                    print '<i>';
                } else {
                    print '<a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $lines[$i]->id . '">';
                }
                if ($lines[$i]->duration) {
                    print ConvertSecondToTime($lines[$i]->duration, 'all');
                } else {
                    print '--:--';
                }
                if ($showlineingray) {
                    print '</i>';
                } else {
                    print '</a>';
                }
                print '</td>';
                print "</tr>\n";
                if (!$showlineingray) {
                    $inc++;
                }
                $level++;
                if ($lines[$i]->id) {
                    PLines($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId);
                }
                $level--;
                $total += $lines[$i]->duration;
            }
        } else {
            //$level--;
        }
    }
    if ($total > 0) {
        print '<tr class="liste_total"><td class="liste_total">' . $langs->trans("Total") . '</td>';
        print '<td></td>';
        print '<td></td>';
        print '<td align="right" nowrap="nowrap" class="liste_total">' . ConvertSecondToTime($total) . '</td></tr>';
    }
    return $inc;
}
Example #2
0
	//var_dump($tasksarray);
	//var_dump($tasksrole);

	print '<table class="noborder" width="100%">';
	print '<tr class="liste_titre">';
	if ($projectstatic->id) print '<td>'.$langs->trans("Project").'</td>';
	print '<td width="80">'.$langs->trans("RefTask").'</td>';
	print '<td>'.$langs->trans("LabelTask").'</td>';
	print '<td align="right">'.$langs->trans("Progress").'</td>';
	print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
	print "</tr>\n";
	if (sizeof($tasksarray) > 0)
	{
		// Show all lines in taskarray (recursive function to go down on tree)
		$j=0;
		$nboftaskshown=PLines($j, 0, $tasksarray, $level, true, 0, $tasksrole);
	}
	else
	{
		print '<tr><td colspan="'.($projectstatic->id?"5":"4").'">'.$langs->trans("NoTasks").'</td></tr>';
	}
	print "</table>";


	// Test if database is clean. If not we clean it.
	//print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' sizeof($tasksarray)='.sizeof($tasksarray).' sizeof($tasksrole)='.sizeof($tasksrole).'<br>';
	if ($_REQUEST["mode"]=='mine')
	{
		if ($nboftaskshown < sizeof($tasksrole)) clean_orphelins($db);
	}
	else
Example #3
0
// can have a parent that is not affected to him).
$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
// We load also tasks limited to a particular user
$tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');

print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>';
print '<td width="80">'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="right">'.$langs->trans("Progress").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n";
// Show all lines in taskarray (recursive function to go down on tree)
$j=0; $level=0;
$nboftaskshown=PLines($j, 0, $tasksarray, $level, true, 1, $tasksrole, $projectsListId);
print "</table>";

print '</div>';

/*
 * Actions
 */
if ($user->rights->projet->creer)
{
	print '<div class="tabsAction">';
	print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/tasks.php?action=create">'.$langs->trans('AddTask').'</a>';
	print '</div>';
}

$db->close();