Skip to content
Snippets Groups Projects
Commit 872a91d4 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

First changes to fix pb in task list

parent f210d6c8
No related branches found
No related tags found
No related merge requests found
......@@ -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 "<tr ".$bc[$var].">\n";
// Show task line.
$showline=1;
$showlineingray=0;
print '<td><a href="task.php?id='.$lines[$i]->id.'">'.$lines[$i]->id.'</a></td>';
print "<td>";
for ($k = 0 ; $k < $level ; $k++)
// If there is filters to use
if (is_array($taskrole))
{
print "&nbsp;&nbsp;&nbsp;";
// 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 "</td>\n";
if ($showproject)
if ($showline)
{
print "<tr ".$bc[$var].">\n";
print '<td>';
if (! $showlineingray) print '<a href="task.php?id='.$lines[$i]->id.'">';
print $lines[$i]->id;
if (! $showlineingray) print '</a>';
print '</td>';
print "<td>";
$projectstatic->id=$lines[$i]->projectid;
$projectstatic->ref=$lines[$i]->projectref;
print $projectstatic->getNomUrl(1);
print "</td>";
}
for ($k = 0 ; $k < $level ; $k++)
{
print "&nbsp;&nbsp;&nbsp;";
}
print $lines[$i]->title;
print "</td>\n";
$heure = intval($lines[$i]->duration);
$minutes = round((($lines[$i]->duration - $heure) * 60),0);
$minutes = substr("00"."$minutes", -2);
print '<td align="right"><a href="task.php?id='.$lines[$i]->id.'">'.$heure."&nbsp;h&nbsp;".$minutes.'</a></td>';
if ($showproject)
{
print "<td>";
$projectstatic->id=$lines[$i]->projectid;
$projectstatic->ref=$lines[$i]->projectref;
print $projectstatic->getNomUrl(1);
print "</td>";
}
print "</tr>\n";
$heure = intval($lines[$i]->duration);
$minutes = round((($lines[$i]->duration - $heure) * 60),0);
$minutes = substr("00"."$minutes", -2);
print '<td align="right">';
if (! $showlineingray) print '<a href="task.php?id='.$lines[$i]->id.'">';
print $heure."&nbsp;h&nbsp;".$minutes;
if (! $showlineingray) print '</a>';
print '</td>';
$inc++;
print "</tr>\n";
$level++;
if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $var, $showproject);
$level--;
if (! $showlineingray) $inc++;
$level++;
if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole);
$level--;
}
}
else
{
......
......@@ -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();
......
......@@ -223,9 +223,12 @@ else
print '</form>';
print '</div>';
$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 '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
if ($projectstatic->id) print '<td>'.$langs->trans("Project").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>';
print '<td width="80">'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\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 "</table>";
print '</div>';
......
......@@ -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.'<br>';
......@@ -158,38 +158,6 @@ if ($_GET["id"] > 0)
print '</div>';
print '<br>';
print '<input type="hidden" name="action" value="addtime">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print '<td align="right">'.$langs->trans("By").'</td>';
print "</tr>\n";
foreach ($tasks as $task_time)
{
$var=!$var;
print "<tr ".$bc[$var].">";
// Date
print '<td>'.dol_print_date($db->jdate($task_time->task_date),'day').' '.dol_print_date($db->jdate($task_time->task_date),'%A').'</td>';
// Time spent
$heure = intval($task_time->task_duration);
$minutes = round((($task_time->task_duration - $heure) * 60),0);
$minutes = substr("00"."$minutes", -2);
print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n";
// User
$user->id=$task_time->rowid;
$user->nom=$task_time->login;
print '<td align="right">'.$user->getNomUrl(1).'</td>';
print "</tr>\n";
}
print "</table>";
}
}
......
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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.'<br>';
print '<form method="POST" action="fiche.php?id='.$projet->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="createtask">';
print '<table class="border" width="100%">';
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'.$task->id.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Project").'</td><td>';
print $projet->getNomUrl(1);
print '</td></tr>';
print '<td>'.$langs->trans("Company").'</td><td>';
if ($projet->societe->id) print $projet->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
/* 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 '</table></form>';
print '</div>';
/*
* Actions
*/
print '<div class="tabsAction">';
/*
if ($user->rights->projet->creer)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$task->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
*/
print '</div>';
print '<br>';
print '<input type="hidden" name="action" value="addtime">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print '<td align="right">'.$langs->trans("By").'</td>';
print "</tr>\n";
foreach ($tasks as $task_time)
{
$var=!$var;
print "<tr ".$bc[$var].">";
// Date
print '<td>'.dol_print_date($db->jdate($task_time->task_date),'day').' '.dol_print_date($db->jdate($task_time->task_date),'%A').'</td>';
// Time spent
$heure = intval($task_time->task_duration);
$minutes = round((($task_time->task_duration - $heure) * 60),0);
$minutes = substr("00"."$minutes", -2);
print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n";
// User
$user->id=$task_time->rowid;
$user->nom=$task_time->login;
print '<td align="right">'.$user->getNomUrl(1).'</td>';
print "</tr>\n";
}
print "</table>";
}
}
$db->close();
llxFooter('$Date$ - $Revision$');
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment