Ejemplo n.º 1
0
/**
 * Output a task line
 * @param   $inc
 * @param   $parent
 * @param   $lines
 * @param   $level
 * @param   $projectsrole
 * @param   $tasksrole
 * @param   $mytask			0 or 1 to enable only if task is a task i am affected to
 * @return  $inc
 */
function PLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mytask = 0)
{
    global $user, $bc, $langs;
    global $form;
    $lastprojectid = 0;
    $projectstatic = new Project($db);
    $taskstatic = new Task($db);
    $var = true;
    $numlines = sizeof($lines);
    for ($i = 0; $i < $numlines; $i++) {
        if ($parent == 0) {
            $level = 0;
        }
        if ($lines[$i]->fk_parent == $parent) {
            // 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
            print "<td>";
            $projectstatic->id = $lines[$i]->fk_project;
            $projectstatic->ref = $lines[$i]->projectref;
            $projectstatic->public = $lines[$i]->public;
            $projectstatic->label = $langs->transnoentitiesnoconv("YourRole") . ': ' . $projectsrole[$lines[$i]->fk_project];
            print $projectstatic->getNomUrl(1);
            print "</td>";
            // Ref
            print '<td>';
            $taskstatic->id = $lines[$i]->id;
            $taskstatic->ref = $lines[$i]->id;
            print $taskstatic->getNomUrl(1);
            print '</td>';
            // Label task
            print "<td>";
            for ($k = 0; $k < $level; $k++) {
                print "&nbsp;&nbsp;&nbsp;";
            }
            print $lines[$i]->label;
            print "</td>\n";
            // Time spent
            print '<td align="right">';
            if ($lines[$i]->duration) {
                print ConvertSecondToTime($lines[$i]->duration, 'all');
            } else {
                print '--:--';
            }
            print "</td>\n";
            $disabledproject = 1;
            $disabledtask = 1;
            //print "x".$lines[$i]->fk_project;
            //var_dump($lines[$i]);
            //var_dump($projectsrole[$lines[$i]->fk_project]);
            // If at least one role for project
            if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
                $disabledproject = 0;
                $disabledtask = 0;
            }
            // If mytask and no role on task
            if ($mytask && empty($tasksrole[$lines[$i]->id])) {
                $disabledtask = 1;
            }
            print '<td nowrap="nowrap">';
            print $form->select_date('', $lines[$i]->id, '', '', '', "addtime", 1, 0, 1, $disabledtask);
            print '&nbsp;&nbsp;&nbsp;';
            print $form->select_duration($lines[$i]->id, '', $disabledtask);
            print '&nbsp;<input type="submit" class="button"' . ($disabledtask ? ' disabled="true"' : '') . ' value="' . $langs->trans("Add") . '">';
            if ($disabledtask) {
                print '(' . $langs->trans("TaskIsNotAffectedToYou") . ')';
            }
            if (!$lines[$i]->public && $disabledproject) {
                print '(' . $langs->trans("YouAreNotContactOfProject") . ')';
            }
            print '</td>';
            print "<td>&nbsp;";
            print '</td>';
            print "</tr>\n";
            $inc++;
            $level++;
            if ($lines[$i]->id) {
                PLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mytask);
            }
            $level--;
        } else {
            //$level--;
        }
    }
    return $inc;
}
Ejemplo n.º 2
0

print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);

if ($mesg) print $mesg;


print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addtime">';

print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print '<td colspan="2">'.$langs->trans("AddDuration").'</td>';
print "</tr>\n";
PLinesb($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine);
print '</form>';


print "</table>";
print '</div>';

$db->close();

llxFooter('$Date: 2011/07/31 23:23:39 $ - $Revision: 1.31 $');
?>