diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d70719c4d4f22591b4351f8cdc7ae1cc224d1677..ab4ded9f296b4f6cff03076e0163cc434c3ecd77 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2965,7 +2965,7 @@ function print_fiche_titre($title, $mesg='', $picto='title_generic.png', $pictoi * @param int $pictoisfullpath 1=Icon name is a full absolute url of image * @param int $id To force an id on html objects * @return string - * @see print_barre_list + * @see print_barre_liste */ function load_fiche_titre($titre, $mesg='', $picto='title_generic.png', $pictoisfullpath=0, $id=0) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 3d4c059420898fc596329a84cd32cba6d44657bd..92229a72d237730399e5c01d1afefe598a611a41 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -260,9 +260,10 @@ function project_admin_prepare_head() * @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 + * @param int $projectidfortotallink 0 or Id of project to use on total line (link to see all time consumed for project) * @return void */ -function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='', $addordertick=0) +function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='', $addordertick=0, $projectidfortotallink=0) { global $user, $bc, $langs; global $projectstatic, $taskstatic; @@ -492,7 +493,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); print '</td>'; print '<td align="right" class="nowrap liste_total">'; + if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">'; print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); + if ($projectidfortotallink > 0) print '</a>'; print '</td>'; print '<td align="right" class="nowrap liste_total">'; if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %'; diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 0e4dfe82b9c88b78494d2681808e2eff256e7629..5470374b5e44f2177faaac11c70da5f8b2fa7e85 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -74,6 +74,9 @@ Progress=Progress ProgressDeclared=Declared progress ProgressCalculated=Calculated progress Time=Time +ListOfTasks=List of tasks +GoToListOfTimeConsumed=Go to list of time consumed +GoToListOfTasks=Go to list of tasks ListProposalsAssociatedProject=List of the commercial proposals associated with the project ListOrdersAssociatedProject=List of customer's orders associated with the project ListInvoicesAssociatedProject=List of customer's invoices associated with the project diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 4abb9122eb2d849a500ef3b677633b86844eab83..434b8e798860c86e88252d8fdf96bf11e496da22 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -207,7 +207,7 @@ if ($id > 0 || ! empty($ref)) print '<table class="border" width="100%">'; $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>'; - + // Ref print '<tr><td width="30%">'; print $langs->trans("Ref"); @@ -391,25 +391,12 @@ else if ($id > 0 || ! empty($ref)) print '</div>'; - print '<br>'; - - - // Link to switch in "my task" / "all task" - print '<table width="100%"><tr><td align="right">'; - if ($mode == 'mine') - { - print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'.$langs->trans("DoNotShowMyTasksOnly").'</a>'; - //print ' - '; - //print $langs->trans("ShowMyTaskOnly"); - } - else - { - //print $langs->trans("DoNotShowMyTaskOnly"); - //print ' - '; - print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mode=mine">'.$langs->trans("ShowMyTasksOnly").'</a>'; - } - print '</td></tr></table>'; + $title=$langs->trans("ListOfTasks"); + $linktotasks='<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$object->id.'&withproject=1">'.$langs->trans("GoToListOfTimeConsumed").'</a>'; + //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); + print load_fiche_titre($title,$linktotasks,'title_generic.png'); + // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); @@ -436,11 +423,24 @@ else if ($id > 0 || ! empty($ref)) print '<td align="right">'.$langs->trans("ProgressDeclared").'</td>'; print '<td> </td>'; print "</tr>\n"; + if (count($tasksarray) > 0) { - // Show all lines in taskarray (recursive function to go down on tree) + // Link to switch in "my task" / "all task" + print '<tr class="liste_titre nodrag nodrop"><td colspan="9">'; + if ($mode == 'mine') + { + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'.$langs->trans("DoNotShowMyTasksOnly").'</a>'; + } + else + { + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mode=mine">'.$langs->trans("ShowMyTasksOnly").'</a>'; + } + print '</td></tr>'; + + // 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); + $nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id); } else { diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 3804715cb7c221b8aee133ebbabc082504194dc2..1a3b1921713f2de8535823b9a8329745a8949288 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -220,6 +220,8 @@ if ($id > 0 || ! empty($ref)) print '<table class="border" width="100%">'; + $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>'; + // Ref print '<tr><td width="30%">'; print $langs->trans("Ref"); @@ -230,7 +232,7 @@ if ($id > 0 || ! empty($ref)) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")"; } - print $form->showrefnav($projectstatic,'project_ref','',1,'ref','ref','',$param.'&withproject=1'); + print $form->showrefnav($projectstatic,'project_ref',$linkback,1,'ref','ref','',$param.'&withproject=1'); print '</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projectstatic->title.'</td></tr>'; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 5ed3655615e95796acf44ce1fd6fe110d90b2204..976e0013431cc7c21c526f75f5688627e7b42f55 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -194,7 +194,16 @@ if (! empty($project_ref) && ! empty($withproject)) } } +// To show all time lines for project +$projectidforalltimes=0; +if (GETPOST('projectid')) +{ + $projectidforalltimes=GETPOST('projectid','int'); + +} + + /* * View */ @@ -205,20 +214,28 @@ $form = new Form($db); $formother = new FormOther($db); $userstatic = new User($db); -if ($id > 0 || ! empty($ref)) +if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { /* * Fiche projet en mode visu */ - if ($object->fetch($id, $ref) >= 0) + if ($projectidforalltimes) + { + $result=$projectstatic->fetch($projectidforalltimes); + if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + } + elseif ($object->fetch($id, $ref) >= 0) { $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = clone $projectstatic; + } + + $userWrite = $projectstatic->restrictedProjectArea($user,'write'); - $userWrite = $projectstatic->restrictedProjectArea($user,'write'); - + if ($projectstatic->id > 0) + { if ($withproject) { // Tabs for project @@ -230,6 +247,8 @@ if ($id > 0 || ! empty($ref)) print '<table class="border" width="100%">'; + $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>'; + // Ref print '<tr><td width="30%">'; print $langs->trans("Ref"); @@ -240,7 +259,7 @@ if ($id > 0 || ! empty($ref)) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")"; } - print $form->showrefnav($projectstatic,'project_ref','',1,'ref','ref','',$param.'&withproject=1'); + print $form->showrefnav($projectstatic,'project_ref',$linkback,1,'ref','ref','',$param.'&withproject=1'); print '</td></tr>'; // Label @@ -275,8 +294,35 @@ if ($id > 0 || ! empty($ref)) print '</table>'; dol_fiche_end(); + + + /* + * Actions + */ + print '<div class="tabsAction">'; + + if ($user->rights->projet->all->creer || $user->rights->projet->creer) + { + if ($object->public || $userWrite > 0) + { + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans('AddTask').'</a>'; + } + else + { + print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>'; + } + } + else + { + print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'</a>'; + } + + print '</div>'; } - + } + + if (empty($projectidforalltimes)) + { $head=task_prepare_head($object); dol_fiche_head($head, 'task_time', $langs->trans("Task"),0,'projecttask'); @@ -423,21 +469,24 @@ if ($id > 0 || ! empty($ref)) print '</td></tr>'; print '</table></form>'; + + print '<br>'; } - - print '<br>'; - + } + + if ($projectstatic->id > 0) + { /* * List of time spent */ $tasks = array(); - $sql = "SELECT t.rowid, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm"; + $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm"; $sql.= ", u.lastname, u.firstname"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE t.fk_task =".$object->id; - $sql .= " AND t.fk_user = u.rowid"; + $sql .= " WHERE t.fk_user = u.rowid"; + if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; $sql .= " ORDER BY t.task_date DESC, t.task_datehour DESC, t.rowid DESC"; $var=true; @@ -445,6 +494,16 @@ if ($id > 0 || ! empty($ref)) if ($resql) { $num = $db->num_rows($resql); + $totalnboflines=$num; + + if (! empty($projectidforalltimes)) + { + $title=$langs->trans("ListTaskTimeUserProject"); + $linktotasks='<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("GoToListOfTasks").'</a>'; + //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); + print load_fiche_titre($title,$linktotasks,'title_generic.png'); + } + $i = 0; while ($i < $num) { @@ -569,12 +628,12 @@ if ($id > 0 || ! empty($ref)) else if ($user->rights->projet->creer) { print ' '; - print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editline&lineid='.$task_time->rowid.($withproject?'&withproject=1':'').'">'; + print '<a href="'.$_SERVER["PHP_SELF"].'?'.($projectidforalltimes?'projectid='.$projectidforalltimes.'&':'').'id='.$task_time->fk_task.'&action=editline&lineid='.$task_time->rowid.($withproject?'&withproject=1':'').'">'; print img_edit(); print '</a>'; print ' '; - print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deleteline&lineid='.$task_time->rowid.($withproject?'&withproject=1':'').'">'; + print '<a href="'.$_SERVER["PHP_SELF"].'?'.($projectidforalltimes?'projectid='.$projectidforalltimes.'&':'').'id='.$task_time->fk_task.'&action=deleteline&lineid='.$task_time->rowid.($withproject?'&withproject=1':'').'">'; print img_delete(); print '</a>'; }