Fixed: A lot of fixed on project views (info on project area). Also add
a limit to avoid problem with very large database.
This commit is contained in:
parent
fe33a2a42e
commit
76bd7dd512
@ -357,7 +357,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
print '</td>';
|
||||
|
||||
// Planned Workload (in working hours)
|
||||
print '<td align="center">';
|
||||
print '<td align="right">';
|
||||
$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)
|
||||
@ -422,7 +422,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td align="center" class="nowrap liste_total">';
|
||||
print '<td align="right" class="nowrap liste_total">';
|
||||
print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
|
||||
print '</td>';
|
||||
print '<td></td>';
|
||||
|
||||
@ -36,6 +36,8 @@ TaskTimeSpent=Time spent on tasks
|
||||
TaskTimeUser=User
|
||||
TaskTimeNote=Note
|
||||
TaskTimeDate=Date
|
||||
TasksOnOpenedProject=Tasks on opened projects
|
||||
WorkloadNotDefined=Workload not defined
|
||||
NewTimeSpent=New time spent
|
||||
MyTimeSpent=My time spent
|
||||
MyTasks=My tasks
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -49,6 +49,7 @@ $sortorder = GETPOST("sortorder",'alpha');
|
||||
|
||||
$socstatic=new Societe($db);
|
||||
$projectstatic=new Project($db);
|
||||
$userstatic=new User($db);
|
||||
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$mine:(empty($user->rights->projet->all->lire)?0:2)),1);
|
||||
//var_dump($projectsListId);
|
||||
@ -156,20 +157,23 @@ print '</div></div></div>';
|
||||
// Tasks for all resources of all opened projects and time spent for each task/resource
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
$sql = "SELECT p.ref, p.title, p.rowid as projectid, t.label, t.rowid as taskid, u.rowid as userid, t.planned_workload, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
|
||||
$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
|
||||
|
||||
$sql = "SELECT p.ref, p.title, p.rowid as projectid, t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
|
||||
if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")";
|
||||
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
$sql.= " AND p.fk_statut=1";
|
||||
$sql.= " GROUP BY p.ref, p.title, p.rowid, t.label, t.rowid, u.rowid, t.planned_workload, t.dateo, t.datee";
|
||||
$sql.= " ORDER BY u.rowid, t.dateo, t.datee";
|
||||
$sql.= " GROUP BY p.ref, p.title, p.rowid, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee";
|
||||
$sql.= " ORDER BY t.rowid, t.dateo, t.datee";
|
||||
$sql.= $db->plimit($max+1); // We want more to know if we have more than limit
|
||||
|
||||
$userstatic=new User($db);
|
||||
$var=true;
|
||||
|
||||
dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
@ -178,75 +182,78 @@ if ( $resql )
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
if ($num > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA))
|
||||
print '<br>';
|
||||
|
||||
print_fiche_titre($langs->trans("TasksOnOpenedProject"),'','').'<br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
//print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
|
||||
print '<th>'.$langs->trans('Projects').'</th>';
|
||||
print '<th>'.$langs->trans('Task').'</th>';
|
||||
print '<th>'.$langs->trans('DateStart').'</th>';
|
||||
print '<th>'.$langs->trans('DateEnd').'</th>';
|
||||
print '<th align="right">'.$langs->trans('PlannedWorkload').'</th>';
|
||||
print '<th align="right">'.$langs->trans("ProgressDeclared").'</td>';
|
||||
print '<th align="right">'.$langs->trans('TimeSpent').'</th>';
|
||||
print '<th align="right">'.$langs->trans("ProgressCalculated").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
while ($i < $num && $i < $max)
|
||||
{
|
||||
/* $langs->load("errors");
|
||||
print '<tr '.$bc[0].'>';
|
||||
print '<td colspan="9">';
|
||||
print $langs->trans("WarningTooManyDataPleaseUseMoreFilters");
|
||||
print '</td></tr>';*/
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<br>';
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
|
||||
print_fiche_titre($langs->trans("TimeSpent"),'','').'<br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
|
||||
print '<th>'.$langs->trans('Projects').'</th>';
|
||||
print '<th>'.$langs->trans('Task').'</th>';
|
||||
print '<th>'.$langs->trans('DateStart').'</th>';
|
||||
print '<th>'.$langs->trans('DateEnd').'</th>';
|
||||
print '<th>'.$langs->trans('TimeSpent').'</th>';
|
||||
print '</tr>';
|
||||
|
||||
while ($i < $num)
|
||||
$username='';
|
||||
if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
|
||||
$username='';
|
||||
if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user
|
||||
{
|
||||
$result=$userstatic->fetch($obj->userid);
|
||||
if (! $result) $userstatic->id=0;
|
||||
}
|
||||
if ($userstatic->id) $username = $userstatic->getNomUrl(0,0);
|
||||
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td>'.$username.'</td>';
|
||||
print '<td>';
|
||||
$projectstatic->id=$obj->projectid;
|
||||
$projectstatic->ref=$obj->ref;
|
||||
$projectstatic->title=$obj->title;
|
||||
print $projectstatic->getNomUrl(1,'',16);
|
||||
//print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$obj->projectid.'">'.$obj->title.'</a>';
|
||||
print '</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$obj->taskid.'&withproject=1">'.$obj->label.'</a></td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->dateo)).'</td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->datee)).'</td>';
|
||||
/* I disable this because information is wrong. This percent has no meaning for a particular resource. What do we want ?
|
||||
* Percent of completion ?
|
||||
* If we want to show completion, we must remove "user" into list,
|
||||
if (empty($obj->planned_workload)) {
|
||||
$percentcompletion = $langs->trans("Unknown");
|
||||
} else {
|
||||
$percentcompletion = intval($obj->task_duration*100/$obj->planned_workload);
|
||||
}*/
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
|
||||
//print $percentcompletion.' %';
|
||||
print convertSecondToTime($obj->timespent, 'all');
|
||||
print '</a></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
$result=$userstatic->fetch($obj->userid);
|
||||
if (! $result) $userstatic->id=0;
|
||||
}
|
||||
if ($userstatic->id) $username = $userstatic->getNomUrl(0,0);
|
||||
|
||||
print "</table>";
|
||||
print "<tr ".$bc[$var].">";
|
||||
//print '<td>'.$username.'</td>';
|
||||
print '<td>';
|
||||
$projectstatic->id=$obj->projectid;
|
||||
$projectstatic->ref=$obj->ref;
|
||||
$projectstatic->title=$obj->title;
|
||||
print $projectstatic->getNomUrl(1,'',16);
|
||||
//print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$obj->projectid.'">'.$obj->title.'</a>';
|
||||
print '</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$obj->taskid.'&withproject=1">'.$obj->label.'</a></td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->dateo),'day').'</td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->datee),'day').'</td>';
|
||||
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
|
||||
print convertSecondToTime($obj->planned_workload, 'all');
|
||||
print '</a></td>';
|
||||
print '<td align="right">';
|
||||
print $obj->progress.'%';
|
||||
print '</td>';
|
||||
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
|
||||
print convertSecondToTime($obj->timespent, 'all');
|
||||
print '</a></td>';
|
||||
print '<td align="right">';
|
||||
if (empty($obj->planned_workload) > 0) {
|
||||
$percentcompletion = $langs->trans("WorkloadNotDefined");
|
||||
} else {
|
||||
$percentcompletion = intval($obj->duration_effective*100/$obj->planned_workload).'%';
|
||||
}
|
||||
print $percentcompletion;
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($num > $max)
|
||||
{
|
||||
print '<tr><td colspan="6">'.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
|
||||
@ -417,7 +417,7 @@ else
|
||||
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="center">'.$langs->trans("PlannedWorkload").'</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>';
|
||||
|
||||
@ -86,7 +86,7 @@ else
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
|
||||
|
||||
// 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).
|
||||
// We need all tasks (even not limited to a user because a task assigned to a user can have a parent that is not assigned to him and we need such parents).
|
||||
$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_status);
|
||||
// We load also tasks limited to a particular user
|
||||
$tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');
|
||||
@ -126,7 +126,9 @@ print '</td>';
|
||||
print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if (count($tasksarray) > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA))
|
||||
$max=1000;
|
||||
|
||||
if (count($tasksarray) > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?$max:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA))
|
||||
{
|
||||
$langs->load("errors");
|
||||
print '<tr '.$bc[0].'>';
|
||||
|
||||
@ -337,30 +337,6 @@ if ($id > 0 || ! empty($ref))
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Date start
|
||||
print '<tr><td>'.$langs->trans("DateStart").'</td><td colspan="3">';
|
||||
print dol_print_date($object->date_start,'dayhour');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date end
|
||||
print '<tr><td>'.$langs->trans("DateEnd").'</td><td colspan="3">';
|
||||
print dol_print_date($object->date_end,'dayhour');
|
||||
print '</td></tr>';
|
||||
|
||||
// Planned workload
|
||||
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">'.convertSecondToTime($object->planned_workload,'allhourmin').'</td></tr>';
|
||||
|
||||
// Declared progress
|
||||
print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
|
||||
print $object->progress.' %';
|
||||
print '</td></tr>';
|
||||
|
||||
// Calculated progress
|
||||
print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">';
|
||||
if ($object->planned_workload) print round(100 * $object->duration_effective / $object->planned_workload,2).' %';
|
||||
else print '';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
@ -412,7 +388,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Note
|
||||
print '<td class="nowrap">';
|
||||
print '<textarea name="timespent_note" cols="80" rows="'.ROWS_3.'">'.($_POST['timespent_note']?$_POST['timespent_note']:'').'</textarea>';
|
||||
print '<textarea name="timespent_note" cols="80" rows="'.ROWS_2.'">'.($_POST['timespent_note']?$_POST['timespent_note']:'').'</textarea>';
|
||||
print '</td>';
|
||||
|
||||
// Progress declared
|
||||
@ -469,7 +445,8 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="updateline">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
print '<input type="hidden" name="withproject" value="'.$withproject.'">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="100">'.$langs->trans("Date").'</td>';
|
||||
@ -524,7 +501,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<td align="left">';
|
||||
if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid)
|
||||
{
|
||||
print '<textarea name="timespent_note_line" cols="80" rows="'.ROWS_3.'">'.$task_time->note.'</textarea>';
|
||||
print '<textarea name="timespent_note_line" cols="80" rows="'.ROWS_2.'">'.$task_time->note.'</textarea>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user