diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php
index 39f728263ad..7d87dbae298 100644
--- a/htdocs/projet/activity/index.php
+++ b/htdocs/projet/activity/index.php
@@ -49,6 +49,7 @@ $now = dol_now();
$projectstatic=new Project($db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project
+$taskstatic=new Task($db);
$tasktmp=new Task($db);
$title=$langs->trans("Activities");
@@ -125,7 +126,7 @@ if ( $resql )
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '';
- print '
'.convertSecondToTime($row->nb).' | ';
+ print ''.convertSecondToTime($row->nb, 'allhourmin').' | ';
print "\n";
$total += $row->nb;
}
@@ -138,7 +139,7 @@ else
}
print '';
print '| '.$langs->trans('Total').' | ';
-print ''.convertSecondToTime($total).' | ';
+print ''.convertSecondToTime($total, 'allhourmin').' | ';
print "
\n";
print "";
@@ -181,7 +182,7 @@ if ($db->type != 'pgsql')
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '';
- print ''.convertSecondToTime($row->nb).' | ';
+ print ''.convertSecondToTime($row->nb, 'allhourmin').' | ';
print "\n";
$total += $row->nb;
}
@@ -194,7 +195,7 @@ if ($db->type != 'pgsql')
}
print '';
print '| '.$langs->trans('Total').' | ';
- print ''.convertSecondToTime($total).' | ';
+ print ''.convertSecondToTime($total, 'allhourmin').' | ';
print "
\n";
print "";
}
@@ -240,7 +241,7 @@ if ( $resql )
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '';
- print ''.convertSecondToTime($row->nb).' | ';
+ print ''.convertSecondToTime($row->nb, 'allhourmin').' | ';
print "\n";
$total += $row->nb;
}
@@ -253,7 +254,7 @@ else
}
print '';
print '| '.$langs->trans('Total').' | ';
-print ''.convertSecondToTime($total).' | ';
+print ''.convertSecondToTime($total, 'allhourmin').' | ';
print "
\n";
print "
";
@@ -292,7 +293,7 @@ if ( $resql )
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '';
- print ''.convertSecondToTime($row->nb).' | ';
+ print ''.convertSecondToTime($row->nb, 'allhourmin').' | ';
print "\n";
$var=!$var;
}
@@ -304,7 +305,7 @@ else
}
print '';
print '| '.$langs->trans('Total').' | ';
-print ''.convertSecondToTime($total).' | ';
+print ''.convertSecondToTime($total, 'allhourmin').' | ';
print "
\n";
print "";
@@ -342,7 +343,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '';
- print ''.convertSecondToTime($row->nb).' | ';
+ print ''.convertSecondToTime($row->nb, 'allhourmin').' | ';
print "\n";
$var=!$var;
}
@@ -354,7 +355,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
}
print '';
print '| '.$langs->trans('Total').' | ';
- print ''.convertSecondToTime($total).' | ';
+ print ''.convertSecondToTime($total, 'allhourmin').' | ';
print "
\n";
print "";
}
@@ -366,6 +367,38 @@ print '';
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
+ // Get id of types of contacts for projects (This list never contains a lot of elements)
+ $listofprojectcontacttype=array();
+ $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
+ $sql.= " WHERE ctc.element = '" . $projectstatic->element . "'";
+ $sql.= " AND ctc.source = 'internal'";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ while($obj = $db->fetch_object($resql))
+ {
+ $listofprojectcontacttype[$obj->rowid]=$obj->code;
+ }
+ }
+ else dol_print_error($db);
+ if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found
+ // Get id of types of contacts for tasks (This list never contains a lot of elements)
+ $listoftaskcontacttype=array();
+ $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
+ $sql.= " WHERE ctc.element = '" . $taskstatic->element . "'";
+ $sql.= " AND ctc.source = 'internal'";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ while($obj = $db->fetch_object($resql))
+ {
+ $listoftaskcontacttype[$obj->rowid]=$obj->code;
+ }
+ }
+ else dol_print_error($db);
+ if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found
+
+
// Tasks for all resources of all opened projects and time spent for each task/resource
$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
@@ -376,8 +409,16 @@ if (empty($conf->global->PROJECT_HIDE_TASKS))
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
+ if ($mine)
+ {
+ $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ect";
+ }
$sql.= " WHERE p.entity = ".$conf->entity;
- if ($mine || empty($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.")"; // project i have permission on
+ if ($mine) // this may duplicate record if we are contact twice
+ {
+ $sql.= " AND ect.fk_c_type_contact IN (".join(',',array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id;
+ }
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, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee";