Esempio n. 1
0
print '<td align="right">' . $langs->trans("PlannedWorkload") . '</td>';
print '<td align="right">' . $langs->trans("ProgressDeclared") . '</td>';
print '<td align="right">' . $langs->trans("TimeSpent") . '</td>';
if ($usertoprocess->id == $user->id) {
    print '<td align="right">' . $langs->trans("TimeSpentByYou") . '</td>';
} else {
    print '<td align="right">' . $langs->trans("TimeSpentByUser") . '</td>';
}
print '<td align="center">' . $langs->trans("HourStart") . '</td>';
print '<td align="center" colspan="2">' . $langs->trans("Duration") . '</td>';
print "</tr>\n";
// By default, we can edit only tasks we are assigned to
$restrictviewformytask = empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED) ? 1 : 0;
if (count($tasksarray) > 0) {
    $j = 0;
    projectLinesPerDay($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse);
} else {
    print '<tr><td colspan="10">' . $langs->trans("NoTasks") . '</td></tr>';
}
print "</table>";
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button"' . ($disabledtask ? ' disabled' : '') . ' value="' . $langs->trans("Save") . '">';
print '</div>';
print '</form>';
print '<script type="text/javascript">';
print "jQuery(document).ready(function () {\n";
print '		jQuery(".timesheetalreadyrecorded").tipTip({ maxWidth: "600px", edgeOffset: 10, delay: 50, fadeIn: 50, fadeOut: 50, content: \'' . dol_escape_js($langs->trans("TimeAlreadyRecorded", $user->getFullName($langs))) . '\'});';
print "});";
print '</script>';
// Add a new project/task
Esempio n. 2
0
/**
 * Output a task line into a pertime intput mode
 *
 * @param	string	   	$inc					Line number (start to 0, then increased by recursive call)
 * @param   string		$parent					Id of parent project to show (0 to show all)
 * @param   Task[]		$lines					Array of lines
 * @param   int			$level					Level (start to 0, then increased/decrease by recursive call)
 * @param   string		$projectsrole			Array of roles user has on project
 * @param   string		$tasksrole				Array of roles user has on task
 * @param	string		$mine					Show only task lines I am assigned to
 * @param   int			$restricteditformytask	0=No restriction, 1=Enable add time only if task is a task i am affected to
 * @param	int			$preselectedday			Preselected day
 * @return  $inc
 */
function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask = 1, $preselectedday = '')
{
    global $db, $user, $bc, $langs;
    global $form, $formother, $projectstatic, $taskstatic;
    $lastprojectid = 0;
    $var = true;
    $numlines = count($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;
                if ($preselectedday) {
                    $projectstatic->id = $lines[$i]->fk_project;
                    $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id);
                    // Load time spent into this->weekWorkLoad and this->weekWorkLoadPerTaks for all day of a week
                }
            }
            // If we want all or we have a role on task, we show it
            if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
                $projectstatic->id = $lines[$i]->fk_project;
                $projectstatic->ref = $lines[$i]->projectref;
                $projectstatic->title = $lines[$i]->projectlabel;
                $projectstatic->public = $lines[$i]->public;
                $taskstatic->id = $lines[$i]->id;
                print "<tr " . $bc[$var] . ">\n";
                // Project
                print "<td>";
                print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole") . ': ' . $projectsrole[$lines[$i]->fk_project]);
                print "</td>";
                // Ref
                print '<td>';
                $taskstatic->ref = $lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id;
                print $taskstatic->getNomUrl(1, 'withproject');
                print '</td>';
                // Label task
                print "<td>";
                for ($k = 0; $k < $level; $k++) {
                    print "&nbsp;&nbsp;&nbsp;";
                }
                $taskstatic->id = $lines[$i]->id;
                $taskstatic->ref = $lines[$i]->label;
                $taskstatic->date_start = $lines[$i]->date_start;
                $taskstatic->date_end = $lines[$i]->date_end;
                print $taskstatic->getNomUrl(0, 'withproject');
                //print "<br>";
                //for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
                //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
                print "</td>\n";
                // Planned Workload
                print '<td align="right">';
                if ($lines[$i]->planned_workload) {
                    print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
                } else {
                    print '--:--';
                }
                print '</td>';
                // Progress declared %
                print '<td align="right">';
                print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
                print '</td>';
                // Time spent by everybody
                print '<td align="right">';
                // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
                if ($lines[$i]->duration) {
                    print '<a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $lines[$i]->id . '">';
                    print convertSecondToTime($lines[$i]->duration, 'allhourmin');
                    print '</a>';
                } else {
                    print '--:--';
                }
                print "</td>\n";
                // Time spent by user
                print '<td align="right">';
                $tmptimespent = $taskstatic->getSummaryOfTimeSpent();
                if ($tmptimespent['total_duration']) {
                    print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
                } 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 $restricteditformytask is on and I have no role on task, i disable edit
                if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
                    $disabledtask = 1;
                }
                // Form to add new time
                print '<td class="nowrap" align="center">';
                $tableCell = $form->select_date($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, 1, $disabledtask);
                print $tableCell;
                print '</td><td align="right">';
                $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
                $alreadyspent = '';
                if ($dayWorkLoad > 0) {
                    $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
                }
                $tableCell = '';
                $tableCell .= '<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled id="timespent[' . $inc . '][' . $idw . ']" name="task[' . $lines[$i]->id . '][' . $idw . ']" value="' . $alreadyspent . '"></span>';
                $tableCell .= ' + ';
                //$tableCell.='&nbsp;&nbsp;&nbsp;';
                $tableCell .= $form->select_duration($lines[$i]->id . 'duration', '', $disabledtask, 'text', 0, 1);
                //$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
                print $tableCell;
                print '</td>';
                print '<td align="right">';
                if (!$lines[$i]->public && $disabledproject) {
                    print $form->textwithpicto('', $langs->trans("YouAreNotContactOfProject"));
                } else {
                    if ($disabledtask) {
                        print $form->textwithpicto('', $langs->trans("TaskIsNotAffectedToYou"));
                    }
                }
                print '</td>';
                print "</tr>\n";
            }
            $inc++;
            $level++;
            if ($lines[$i]->id) {
                projectLinesPerDay($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday);
            }
            $level--;
        } else {
            //$level--;
        }
    }
    return $inc;
}