コード例 #1
0
ファイル: index.php プロジェクト: nrjacker4/crm-php
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n";

print '<tr class="liste_titre">';
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_product" value="'.$search_product.'" size="8">';
print '</td>';
print '<td class="liste_titre" colspan="5">';
print '&nbsp;';
print '</td>';
print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>';
print "</tr>\n";

// Show all lines in taskarray (recursive function to go down on tree)
$j=0; $level=0;
$nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 1, $tasksrole, $projectsListId);
print "</table>";

print '</form>';

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>';
}
コード例 #2
0
/**
 * Show task lines with a particular parent
 *
 * @param	string	 	$inc				Counter that count number of lines legitimate to show (for return)
 * @param 	int			$parent				Id of parent task to start
 * @param 	array		$lines				Array of all tasks
 * @param 	int			$level				Level of task
 * @param 	string		$var				Color
 * @param 	int			$showproject		Show project columns
 * @param	int			$taskrole			Array of roles of user for each tasks
 * @param	int			$projectsListId		List of id of project allowed to user (string separated with comma)
 * @param	int			$addordertick		Add a tick to move task
 * @return	void
 */
function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0)
{
    global $user, $bc, $langs;
    global $projectstatic, $taskstatic;
    $lastprojectid = 0;
    $projectsArrayId = explode(',', $projectsListId);
    $numlines = count($lines);
    // We declare counter as global because we want to edit them into recursive call
    global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned;
    if ($level == 0) {
        $total_projectlinesa_spent = 0;
        $total_projectlinesa_planned = 0;
        $total_projectlinesa_spent_if_planned = 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
                    }
                }
            } else {
                // Caller did not ask to filter on tasks of a specific user (this probably means he want also tasks of all users, into public project
                // or into all other projects if user has permission to).
                if (empty($user->rights->projet->all->lire)) {
                    // User is not allowed on this project and project is not public, so we hide line
                    if (!in_array($lines[$i]->fk_project, $projectsArrayId)) {
                        // Note that having a user assigned to a task into a project user has no permission on, should not be possible
                        // because assignement on task can be done only on contact of project.
                        // If assignement was done and after, was removed from contact of project, then we can hide the line.
                        $showline = 0;
                    }
                }
            }
            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] . ' id="row-' . $lines[$i]->id . '">' . "\n";
                if ($showproject) {
                    // Project ref
                    print "<td>";
                    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>";
                    // Project status
                    print '<td>';
                    $projectstatic->statut = $lines[$i]->projectstatus;
                    print $projectstatic->getLibStatut(2);
                    print "</td>";
                }
                // Ref of task
                print '<td>';
                if ($showlineingray) {
                    print '<i>' . img_object('', 'projecttask') . ' ' . $lines[$i]->ref . '</i>';
                } else {
                    $taskstatic->id = $lines[$i]->id;
                    $taskstatic->ref = $lines[$i]->ref;
                    $taskstatic->label = $taskrole[$lines[$i]->id] ? $langs->trans("YourRole") . ': ' . $taskrole[$lines[$i]->id] : '';
                    print $taskstatic->getNomUrl(1, $showproject ? '' : 'withproject');
                }
                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 . ($showproject ? '' : '&withproject=1') . '">';
                }
                for ($k = 0; $k < $level; $k++) {
                    print "&nbsp; &nbsp; &nbsp;";
                }
                print $lines[$i]->label;
                if ($showlineingray) {
                    print '</i>';
                } else {
                    print '</a>';
                }
                print "</td>\n";
                // Date start
                print '<td align="center">';
                print dol_print_date($lines[$i]->date_start, 'dayhour');
                print '</td>';
                // Date end
                print '<td align="center">';
                print dol_print_date($lines[$i]->date_end, 'dayhour');
                print '</td>';
                // Planned Workload (in working hours)
                print '<td align="center">';
                $fullhour = convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
                $workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7);
                // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks
                if ($lines[$i]->planned_workload) {
                    print $fullhour;
                    // TODO Add delay taking account of working hours per day and working day per week
                    //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')';
                }
                //else print '--:--';
                print '</td>';
                // Progress declared
                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 . ($showproject ? '' : '&withproject=1') . '">';
                }
                if ($lines[$i]->duration) {
                    print convertSecondToTime($lines[$i]->duration, 'allhourmin');
                } else {
                    print '--:--';
                }
                if ($showlineingray) {
                    print '</i>';
                } else {
                    print '</a>';
                }
                print '</td>';
                // Progress calculated
                // Note: ->duration is in fact time spent i think
                print '<td align="right">';
                if ($lines[$i]->planned_workload) {
                    print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2) . ' %';
                }
                print '</td>';
                // Tick to drag and drop
                if ($addordertick) {
                    print '<td align="center" class="tdlineupdown hideonsmartphone">&nbsp;</td>';
                }
                print "</tr>\n";
                if (!$showlineingray) {
                    $inc++;
                }
                $level++;
                if ($lines[$i]->id) {
                    projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
                }
                $level--;
                $total_projectlinesa_spent += $lines[$i]->duration;
                $total_projectlinesa_planned += $lines[$i]->planned_workload;
                if ($lines[$i]->planned_workload) {
                    $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
                }
            }
        } else {
            //$level--;
        }
    }
    if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0) && $level == 0) {
        print '<tr class="liste_total">';
        print '<td class="liste_total">' . $langs->trans("Total") . '</td>';
        if ($showproject) {
            print '<td></td><td></td>';
        }
        print '<td></td>';
        print '<td></td>';
        print '<td></td>';
        print '<td align="center" class="nowrap liste_total">';
        print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
        print '</td>';
        print '<td></td>';
        print '<td align="right" class="nowrap liste_total">';
        print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
        print '</td>';
        print '<td align="right" class="nowrap liste_total">';
        if ($total_projectlinesa_planned) {
            print round(100 * $total_projectlinesa_spent_if_planned / $total_projectlinesa_planned, 2) . ' %';
        }
        print '</td>';
        if ($addordertick) {
            print '<td class="hideonsmartphone"></td>';
        }
        print '</tr>';
    }
    return $inc;
}
コード例 #3
0
ファイル: tasks.php プロジェクト: ADDAdev/Dolibarr
 // print '<td>'.$langs->trans("Project").'</td>';
 print '<td width="100">' . $langs->trans("RefTask") . '</td>';
 print '<td>' . $langs->trans("LabelTask") . '</td>';
 print '<td align="center">' . $langs->trans("DateStart") . '</td>';
 print '<td align="center">' . $langs->trans("DateEnd") . '</td>';
 print '<td align="right">' . $langs->trans("PlannedWorkload") . '</td>';
 print '<td align="right">' . $langs->trans("ProgressDeclared") . '</td>';
 print '<td align="right">' . $langs->trans("TimeSpent") . '</td>';
 print '<td align="right">' . $langs->trans("ProgressCalculated") . '</td>';
 print '<td>&nbsp;</td>';
 print "</tr>\n";
 if (count($tasksarray) > 0) {
     // Show all lines in taskarray (recursive function to go down on tree)
     $j = 0;
     $level = 0;
     $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $id, 1);
 } else {
     print '<tr><td colspan="9">' . $langs->trans("NoTasks") . '</td></tr>';
 }
 print "</table>";
 // Test if database is clean. If not we clean it.
 //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'<br>';
 if (!empty($user->rights->projet->all->lire)) {
     if ($mode == 'mine') {
         if ($nboftaskshown < count($tasksrole)) {
             include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
             cleanCorruptedTree($db, 'projet_task', 'fk_task_parent');
         }
     } else {
         if ($nboftaskshown < count($tasksarray)) {
             include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
コード例 #4
0
ファイル: project.lib.php プロジェクト: nrjacker4/crm-php
/**
 * Show task lines with a particular parent
 *
 * @param	string	 	&$inc				Counter that count number of lines legitimate to show (for return)
 * @param 	int			$parent				Id of parent task to start
 * @param 	array		&$lines				Array of all tasks
 * @param 	int			&$level				Level of task
 * @param 	string		$var				Color
 * @param 	int			$showproject		Show project columns
 * @param	int			&$taskrole			Array of roles of user for each tasks
 * @param	int			$projectsListId		List of id of project allowed to user (separated with comma)
 * @return	void
 */
function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '')
{
    global $user, $bc, $langs;
    global $projectstatic, $taskstatic;
    $lastprojectid = 0;
    $projectsArrayId = explode(',', $projectsListId);
    $numlines = count($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, $showproject ? '' : 'withproject');
                }
                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 . ($showproject ? '' : '&withproject=1') . '">';
                }
                for ($k = 0; $k < $level; $k++) {
                    print "&nbsp; &nbsp; &nbsp;";
                }
                print $lines[$i]->label;
                if ($showlineingray) {
                    print '</i>';
                } else {
                    print '</a>';
                }
                print "</td>\n";
                // Date start
                print '<td align="center">';
                print dol_print_date($lines[$i]->date_start, 'day');
                print '</td>';
                // Date end
                print '<td align="center">';
                print dol_print_date($lines[$i]->date_end, 'day');
                print '</td>';
                // 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 . ($showproject ? '' : '&withproject=1') . '">';
                }
                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) {
                    projectLinesa($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>';
        if ($showproject) {
            print '<td></td>';
        }
        print '<td></td>';
        print '<td></td>';
        print '<td></td>';
        print '<td></td>';
        print '<td align="right" nowrap="nowrap" class="liste_total">' . convertSecondToTime($total) . '</td></tr>';
    }
    return $inc;
}