diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index 20d4104abfc..a3fbec0c171 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -69,8 +69,13 @@ function task_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'task'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id; $head[$h][1] = $langs->trans("TimeSpent"); - $head[$h][2] = 'tasks'; + $head[$h][2] = 'time'; $h++; $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/who.php?id='.$object->id; @@ -213,16 +218,16 @@ function PLinesb(&$inc, $parent, $lines, &$level, $tasksrole) /** - * Enter description here... - * - * @param unknown_type $inc - * @param unknown_type $parent - * @param unknown_type $lines - * @param unknown_type $level - * @param unknown_type $var - * @param unknown_type $showproject + * 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 + * @param $lines Array of all tasks + * @param $level Level of task + * @param $var Color + * @param $showproject Show project columns + * @param $linesfiltered ''=No filter on users, Array=Shown tasks filtered on a particular user, the array contains tasks filtered */ -function PLines(&$inc, $parent, $lines, &$level, $var, $showproject=1) +function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject=1, &$taskrole='') { global $user, $bc, $langs; @@ -232,6 +237,8 @@ function PLines(&$inc, $parent, $lines, &$level, $var, $showproject=1) for ($i = 0 ; $i < sizeof($lines) ; $i++) { + // Process line $lines[$i] + if ($parent == 0) $level = 0; if ($lines[$i]->fk_parent == $parent) @@ -243,39 +250,74 @@ function PLines(&$inc, $parent, $lines, &$level, $var, $showproject=1) $lastprojectid=$lines[$i]->projectid; } - print "\n"; + // Show task line. + $showline=1; + $showlineingray=0; - print ''.$lines[$i]->id.''; - - print ""; - for ($k = 0 ; $k < $level ; $k++) + // If there is filters to use + if (is_array($taskrole)) { - print "   "; + // If task not legitimate to show, search if a task exists later in tree + if (! isset($taskrole[$lines[$i]->id])) + { + // So search if task has a subtask legitimate to show + // FIXME + //SearchPLine($foundtaskforuserafter,$lines[$i]->id,$lines,$taskrole); + if ($foundtaskforuserlater) + { + $showlineingray=1; // We will show line but in gray + } + else + { + $showline=0; // No reason to show line + } + } } - print $lines[$i]->title; - print "\n"; - if ($showproject) + if ($showline) { + print "\n"; + + print ''; + if (! $showlineingray) print ''; + print $lines[$i]->id; + if (! $showlineingray) print ''; + print ''; + print ""; - $projectstatic->id=$lines[$i]->projectid; - $projectstatic->ref=$lines[$i]->projectref; - print $projectstatic->getNomUrl(1); - print ""; + for ($k = 0 ; $k < $level ; $k++) + { + print "   "; + } + print $lines[$i]->title; + print "\n"; + + if ($showproject) + { + print ""; + $projectstatic->id=$lines[$i]->projectid; + $projectstatic->ref=$lines[$i]->projectref; + print $projectstatic->getNomUrl(1); + print ""; + } + + $heure = intval($lines[$i]->duration); + $minutes = round((($lines[$i]->duration - $heure) * 60),0); + $minutes = substr("00"."$minutes", -2); + print ''; + if (! $showlineingray) print ''; + print $heure." h ".$minutes; + if (! $showlineingray) print ''; + print ''; + + print "\n"; + + if (! $showlineingray) $inc++; + + $level++; + if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole); + $level--; } - - $heure = intval($lines[$i]->duration); - $minutes = round((($lines[$i]->duration - $heure) * 60),0); - $minutes = substr("00"."$minutes", -2); - print ''.$heure." h ".$minutes.''; - - print "\n"; - - $inc++; - - $level++; - if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $var, $showproject); - $level--; } else { diff --git a/htdocs/project.class.php b/htdocs/project.class.php index 1f033538368..3232390006b 100644 --- a/htdocs/project.class.php +++ b/htdocs/project.class.php @@ -411,7 +411,7 @@ class Project extends CommonObject } /** - * Enter description here... + * Return array of role of user for each projects * * @param unknown_type $user * @return unknown @@ -457,7 +457,7 @@ class Project extends CommonObject function getTasksArray($usert=0, $userp=0, $mode=0) { global $conf; - + $tasks = array(); //print $usert.'-'.$userp; @@ -514,15 +514,15 @@ class Project extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); + $tasks[$i]->id = $obj->rowid; $tasks[$i]->projectid = $obj->projectid; $tasks[$i]->projectref = $obj->ref; $tasks[$i]->projectlabel = $obj->title; - $tasks[$i]->id = $obj->rowid; $tasks[$i]->title = $obj->title; $tasks[$i]->fk_parent = $obj->fk_task_parent; $tasks[$i]->duration = $obj->duration_effective; - $tasks[$i]->name = $obj->name; - $tasks[$i]->firstname = $obj->firstname; + $tasks[$i]->name = $obj->name; // Name of project leader + $tasks[$i]->firstname = $obj->firstname; // Firstname of project leader $i++; } $this->db->free(); diff --git a/htdocs/projet/tasks/fiche.php b/htdocs/projet/tasks/fiche.php index b5735a56708..9654c00ca54 100644 --- a/htdocs/projet/tasks/fiche.php +++ b/htdocs/projet/tasks/fiche.php @@ -223,9 +223,12 @@ else print ''; print ''; - - $tasksarray=$projet->getTasksArray($_REQUEST["mode"]=='mine'?$user:0, 0); - + // 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=$projet->getTasksArray(0, 0, 0); + // We load also tasks limited to a particular user + $tasksrole=($_REQUEST["mode"]=='mine' ? $projet->getTasksRoleForUser($user) : ''); /* * Actions @@ -250,12 +253,13 @@ else print ''; print ''; if ($projectstatic->id) print ''; - print ''; + print ''; print ''; print ''; print "\n"; + // Show all lines in taskarray (recusrive function to go down on tree) $j=0; - $nboftaskshown=PLines($j, 0, $tasksarray, $level, true, 0); + $nboftaskshown=PLines($j, 0, $tasksarray, $level, true, 0, $tasksrole); print "
'.$langs->trans("Project").''.$langs->trans("RefTask").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("TimeSpent").'
"; print ''; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 1ec34eac84f..77779b7ede1 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -86,7 +86,7 @@ if ($_GET["id"] > 0) $head=task_prepare_head($task); - dol_fiche_head($head, 'tasks', $langs->trans("Task")); + dol_fiche_head($head, 'task', $langs->trans("Task")); if ($mesg) print $mesg.'
'; @@ -158,38 +158,6 @@ if ($_GET["id"] > 0) print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - foreach ($tasks as $task_time) - { - $var=!$var; - print ""; - - // Date - print ''; - - // Time spent - $heure = intval($task_time->task_duration); - $minutes = round((($task_time->task_duration - $heure) * 60),0); - $minutes = substr("00"."$minutes", -2); - print '\n"; - - // User - $user->id=$task_time->rowid; - $user->nom=$task_time->login; - print ''; - print "\n"; - } - - print "
'.$langs->trans("Date").''.$langs->trans("TimeSpent").''.$langs->trans("By").'
'.dol_print_date($db->jdate($task_time->task_date),'day').' '.dol_print_date($db->jdate($task_time->task_date),'%A').''.$heure." h ".$minutes."'.$user->getNomUrl(1).'
"; - } } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php new file mode 100644 index 00000000000..25fb1f52ab1 --- /dev/null +++ b/htdocs/projet/tasks/time.php @@ -0,0 +1,172 @@ + + * Copyright (C) 2006-2009 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/projet/tasks/task.php + * \ingroup projet + * \brief Fiche t�ches d'un projet + * \version $Id$ + */ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); + +if (!$user->rights->projet->lire) accessforbidden(); + +/* + * Actions + */ + + + + + +/* + * View + */ + +llxHeader("",$langs->trans("Task")); + +$html = new Form($db); + +$projectstatic = new Project($db); + + +if ($_GET["id"] > 0) +{ + /* + * Fiche projet en mode visu + * + */ + $task = new Task($db); + if ($task->fetch($_GET["id"]) >= 0 ) + { + $projet = new Project($db); + $result=$projet->fetch($task->fk_projet); + if (! empty($projet->socid)) $projet->societe->fetch($projet->socid); + + $head=task_prepare_head($task); + + dol_fiche_head($head, 'time', $langs->trans("Task")); + + if ($mesg) print $mesg.'
'; + + print '
'; + print ''; + print ''; + print ''; + + print ''; + print ''; + + print ''; + + print ''; + + /* List of time spent */ + + $sql = "SELECT t.task_date, t.task_duration, t.fk_user, u.login, u.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE t.fk_task =".$task->id; + $sql .= " AND t.fk_user = u.rowid"; + $sql .= " ORDER BY t.task_date DESC"; + + $var=true; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $tasks = array(); + while ($i < $num) + { + $row = $db->fetch_object($resql); + $tasks[$i] = $row; + $i++; + } + $db->free($resql); + } + else + { + dol_print_error($db); + } + + print '
'.$langs->trans("Ref").''.$task->id.'
'.$langs->trans("Label").''.$task->title.'
'.$langs->trans("Project").''; + print $projet->getNomUrl(1); + print '
'.$langs->trans("Company").''; + if ($projet->societe->id) print $projet->societe->getNomUrl(1); + else print ' '; + print '
'; + print ''; + + + /* + * Actions + */ + print '
'; + + /* + if ($user->rights->projet->creer) + { + print ''.$langs->trans('Delete').''; + } + */ + + print '
'; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + foreach ($tasks as $task_time) + { + $var=!$var; + print ""; + + // Date + print ''; + + // Time spent + $heure = intval($task_time->task_duration); + $minutes = round((($task_time->task_duration - $heure) * 60),0); + $minutes = substr("00"."$minutes", -2); + print '\n"; + + // User + $user->id=$task_time->rowid; + $user->nom=$task_time->login; + print ''; + print "\n"; + } + + print "
'.$langs->trans("Date").''.$langs->trans("TimeSpent").''.$langs->trans("By").'
'.dol_print_date($db->jdate($task_time->task_date),'day').' '.dol_print_date($db->jdate($task_time->task_date),'%A').''.$heure." h ".$minutes."'.$user->getNomUrl(1).'
"; + + } +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?>