NEW Add filter on user contact or user task into task list
This commit is contained in:
parent
0e141f2c1b
commit
94ff635cc2
@ -144,3 +144,5 @@ InputPerDay=Input per day
|
||||
InputPerWeek=Input per week
|
||||
InputPerAction=Input per action
|
||||
TimeAlreadyRecorded=Time spent already recorded for this task/day and user %s
|
||||
ProjectsWithThisUserAsContact=Projects with this user as contact
|
||||
TasksWithThisUserAsContact=Tasks assigned to this user
|
||||
@ -562,9 +562,11 @@ class Task extends CommonObject
|
||||
* @param string $filteronprojref Filter on project ref
|
||||
* @param string $filteronprojstatus Filter on project status
|
||||
* @param string $morewherefilter Add more filter into where SQL request
|
||||
* @param string $filteronprojuser Filter on user that is a contact of project
|
||||
* @param string $filterontaskuse Filter on user assigned to task
|
||||
* @return array Array of tasks
|
||||
*/
|
||||
function getTasksArray($usert=0, $userp=0, $projectid=0, $socid=0, $mode=0, $filteronprojref='', $filteronprojstatus=-1, $morewherefilter='')
|
||||
function getTasksArray($usert=0, $userp=0, $projectid=0, $socid=0, $mode=0, $filteronprojref='', $filteronprojstatus=-1, $morewherefilter='',$filteronprojuser=0,$filterontaskuse=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -580,19 +582,25 @@ class Task extends CommonObject
|
||||
{
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
|
||||
$sql.= " WHERE t.fk_projet = p.rowid";
|
||||
$sql.= " AND p.entity = ".$conf->entity;
|
||||
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
|
||||
if ($projectid) $sql.= " AND p.rowid in (".$projectid.")";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
$sql.= " AND t.fk_projet = p.rowid";
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
|
||||
if ($projectid) $sql.= " AND p.rowid in (".$projectid.")";
|
||||
}
|
||||
if ($filteronprojuser)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
if ($filterontaskuser)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
|
||||
if ($projectid) $sql.= " AND p.rowid in (".$projectid.")";
|
||||
if ($filteronprojref) $sql.= " AND p.ref LIKE '%".$filteronprojref."%'";
|
||||
if ($filteronprojstatus > -1) $sql.= " AND p.fk_statut = ".$filteronprojstatus;
|
||||
if ($morewherefilter) $sql.=" AND (".$morewherefilter.")";
|
||||
|
||||
@ -38,6 +38,8 @@ if (! isset($_GET['search_status']) && ! isset($_POST['search_status'])) $search
|
||||
else $search_status=GETPOST('search_status');
|
||||
$search_task_ref=GETPOST('search_task_ref');
|
||||
$search_task_label=GETPOST('search_task_label');
|
||||
$search_project_user=GETPOST('search_project_user');
|
||||
$search_task_user=GETPOST('search_task_user');
|
||||
|
||||
|
||||
// Security check
|
||||
@ -108,7 +110,7 @@ $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$so
|
||||
$morewherefilter='';
|
||||
if ($search_task_ref) $morewherefilter.=natural_search('t.ref', $search_task_ref, 0, 1);
|
||||
if ($search_task_label) $morewherefilter.=natural_search('t.label', $search_task_label, 0, 1);
|
||||
$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_status, $morewherefilter);
|
||||
$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_status, $morewherefilter, $search_project_user, $search_task_user);
|
||||
// We load also tasks limited to a particular user
|
||||
$tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');
|
||||
|
||||
@ -116,6 +118,27 @@ print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="mode" value="'.GETPOST('mode').'">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
// If the user can view users
|
||||
if ($user->rights->user->user->lire)
|
||||
{
|
||||
$moreforfilter.=($moreforfilter?' ':'');
|
||||
$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' ';
|
||||
$moreforfilter.=$form->select_dolusers($search_project_user,'search_project_user',1);
|
||||
}
|
||||
if ($user->rights->user->user->lire)
|
||||
{
|
||||
$moreforfilter.=($moreforfilter?' ':'');
|
||||
$moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ' ';
|
||||
$moreforfilter.=$form->select_dolusers($search_task_user,'search_task_user',1);
|
||||
}
|
||||
if (! empty($moreforfilter))
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre" colspan="10">';
|
||||
print $moreforfilter;
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Project").'</td>';
|
||||
print '<td>'.$langs->trans("ProjectStatus").'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user