Skip to content

Commit

Permalink
Merge pull request #7660 from atm-gauthier/fix_project_time_spent
Browse files Browse the repository at this point in the history
FIX : wrong personnal project time spent
  • Loading branch information
eldy committed Oct 22, 2017
2 parents d5d337c + 3793ae3 commit 8ac7dd8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion htdocs/core/lib/project.lib.php
Expand Up @@ -762,7 +762,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$

// Time spent by user
print '<td align="right">';
$tmptimespent=$taskstatic->getSummaryOfTimeSpent();
$tmptimespent=$taskstatic->getSummaryOfTimeSpent('', $fuser->id);
if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
else print '--:--';
print "</td>\n";
Expand Down
4 changes: 3 additions & 1 deletion htdocs/projet/class/task.class.php
Expand Up @@ -911,9 +911,10 @@ function addTimeSpent($user, $notrigger=0)
* Calculate total of time spent for task
*
* @param int $id Id of object (here task)
* @param int $user_id Filter on user time
* @return array Array of info for task array('min_date', 'max_date', 'total_duration')
*/
function getSummaryOfTimeSpent($id='')
function getSummaryOfTimeSpent($id='', $user_id='')
{
global $langs;

Expand All @@ -927,6 +928,7 @@ function getSummaryOfTimeSpent($id='')
$sql.= " SUM(t.task_duration) as total_duration";
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
$sql.= " WHERE t.fk_task = ".$id;
if(!empty($user_id)) $sql.= " AND t.fk_user = ".$user_id;

dol_syslog(get_class($this)."::getSummaryOfTimeSpent", LOG_DEBUG);
$resql=$this->db->query($sql);
Expand Down

0 comments on commit 8ac7dd8

Please sign in to comment.