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 ''; @@ -146,11 +151,11 @@ print ''; print ''; print ''; print ''; -print ''; +print ''; 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 ''; - print ''; - print ''; - print ''; - print ''; - if (empty($obj->planned_workload)) { - $percentcompletion = '0'; - } else { - $percentcompletion = intval(($obj->task_duration*100)/$obj->planned_workload); - } - print ''; - print "\n"; - - $i++; + print ''; + 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 ''; + print ''; + print ''; + print ''; + print ''; + /* 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 "\n"; + + $i++; + } + + $db->free($resql); + } } else { dol_print_error($db); } -print "
'.$langs->trans('TaskRessourceLinks').''.$langs->trans('Projects').''.$langs->trans('Task').''.$langs->trans('DateStart').''.$langs->trans('DateEnd').''.$langs->trans('WorkloadOccupation').''.$langs->trans('TimeSpent').'
'.$username.'projectid.'">'.$obj->title.''.$obj->label.''.dol_print_date($db->jdate($obj->dateo)).''.dol_print_date($db->jdate($obj->datee)).''.$percentcompletion.' %
'; + print $langs->trans("TooManyDataPleaseUseMoreFilters"); + print '
'.$username.''.$obj->title.''.$obj->label.''.dol_print_date($db->jdate($obj->dateo)).''.dol_print_date($db->jdate($obj->datee)).''; + //print $percentcompletion.' %'; + print convertSecondToTime($obj->timespent, 'all'); + print '
"; +print ""; +print '';