diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php
index 6b1c0e7be9b..d3b0c611d13 100644
--- a/htdocs/projet/index.php
+++ b/htdocs/projet/index.php
@@ -26,6 +26,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->load("projects");
@@ -81,7 +82,7 @@ print '
';
print '
';
print '';
-print_liste_field_titre($langs->trans("ThirdParties"),"index.php","s.nom","","","",$sortfield,$sortorder);
+print_liste_field_titre($langs->trans("ThirdParties"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("NbOfProjects"),"","","","",'align="right"',$sortfield,$sortorder);
print "
\n";
@@ -132,13 +133,17 @@ else
}
print "
";
-print '';
print '
';
+// Tasks for all resources of all opened projects and time spent for each task/resource
print '';
-print '
';
+
+print '
';
+
+print_fiche_titre($langs->trans("TimeSpent"),'','').'
';
+
print '
';
print '';
print '| '.$langs->trans('TaskRessourceLinks').' | ';
@@ -146,11 +151,11 @@ print ''.$langs->trans('Projects').' | ';
print ''.$langs->trans('Task').' | ';
print ''.$langs->trans('DateStart').' | ';
print ''.$langs->trans('DateEnd').' | ';
-print ''.$langs->trans('WorkloadOccupation').' | ';
+print ''.$langs->trans('TimeSpent').' | ';
print '
';
-$sql = "SELECT p.title, p.rowid as projectid, t.label, t.rowid as taskid, u.rowid as userid, t.planned_workload, t.dateo, t.datee, tasktime.task_duration";
+$sql = "SELECT 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";
$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";
@@ -160,6 +165,7 @@ $sql.= " WHERE p.entity = ".$conf->entity;
if ($mine || ! $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.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";
$userstatic=new User($db);
@@ -171,42 +177,61 @@ if ( $resql )
$num = $db->num_rows($resql);
$i = 0;
- while ($i < $num)
+ if ($num > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA))
{
- $obj = $db->fetch_object($resql);
- $var=!$var;
-
- $username='';
- $userstatic->fetch($obj->userid);
- if (!empty($userstatic->id)) {
- $username = $userstatic->getNomUrl(0,0);
- }
-
- print "";
- print '| '.$username.' | ';
- print 'projectid.'">'.$obj->title.' | ';
- print ''.$obj->label.' | ';
- print ''.dol_print_date($db->jdate($obj->dateo)).' | ';
- print ''.dol_print_date($db->jdate($obj->datee)).' | ';
- if (empty($obj->planned_workload)) {
- $percentcompletion = '0';
- } else {
- $percentcompletion = intval(($obj->task_duration*100)/$obj->planned_workload);
- }
- print ''.$percentcompletion.' % | ';
- print "
\n";
-
- $i++;
+ print '';
+ print '| ';
+ print $langs->trans("TooManyDataPleaseUseMoreFilters");
+ print ' |
';
}
+ else
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ $var=!$var;
- $db->free($resql);
+ $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 "";
+ print '| '.$username.' | ';
+ print ''.$obj->title.' | ';
+ print ''.$obj->label.' | ';
+ print ''.dol_print_date($db->jdate($obj->dateo)).' | ';
+ print ''.dol_print_date($db->jdate($obj->datee)).' | ';
+ /* 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 '';
+ //print $percentcompletion.' %';
+ print convertSecondToTime($obj->timespent, 'all');
+ print ' | ';
+ print "
\n";
+
+ $i++;
+ }
+
+ $db->free($resql);
+ }
}
else
{
dol_print_error($db);
}
-print "
";
+print "";
+print '';