Skip to content
Snippets Groups Projects
Commit 526ea743 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: the view my task must show only task you are assigned to

parent 9b308b9f
No related branches found
No related tags found
No related merge requests found
......@@ -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 '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
$total += $row->nb;
}
......@@ -138,7 +139,7 @@ else
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print '<td align="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
print "</tr>\n";
print "</table>";
......@@ -181,7 +182,7 @@ if ($db->type != 'pgsql')
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
$total += $row->nb;
}
......@@ -194,7 +195,7 @@ if ($db->type != 'pgsql')
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print '<td align="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
print "</tr>\n";
print "</table>";
}
......@@ -240,7 +241,7 @@ if ( $resql )
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
$total += $row->nb;
}
......@@ -253,7 +254,7 @@ else
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print '<td align="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
print "</tr>\n";
print "</table><br>";
......@@ -292,7 +293,7 @@ if ( $resql )
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
$var=!$var;
}
......@@ -304,7 +305,7 @@ else
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print '<td align="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
print "</tr>\n";
print "</table>";
......@@ -342,7 +343,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
$var=!$var;
}
......@@ -354,7 +355,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print '<td align="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
print "</tr>\n";
print "</table>";
}
......@@ -366,6 +367,38 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
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";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment