From 88d3bf0148f1ca002c4ce6bf64ece709a5bc2720 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Jun 2018 18:47:02 +0200 Subject: [PATCH] FIX creation of tasks must hide closed project --- htdocs/core/class/html.formother.class.php | 9 ++++++--- htdocs/projet/class/task.class.php | 12 ++++++------ htdocs/projet/tasks.php | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index fcc2ddf049c..4eb59a1c1ce 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -470,9 +470,11 @@ class FormOther * @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists * @param int $useempty 0=Allow empty values * @param int $disablechildoftaskid 1=Disable task that are child of the provided task id + * @param string $filteronprojstatus Filter on project status ('-1'=no filter, '0,1'=Draft+Validated status) + * @param string $morecss More css * @return void */ - function selectProjectTasks($selectedtask='', $projectid=0, $htmlname='task_parent', $modeproject=0, $modetask=0, $mode=0, $useempty=0, $disablechildoftaskid=0) + function selectProjectTasks($selectedtask='', $projectid=0, $htmlname='task_parent', $modeproject=0, $modetask=0, $mode=0, $useempty=0, $disablechildoftaskid=0, $filteronprojstatus='', $morecss='') { global $user, $langs; @@ -480,10 +482,10 @@ class FormOther //print $modeproject.'-'.$modetask; $task=new Task($this->db); - $tasksarray=$task->getTasksArray($modetask?$user:0, $modeproject?$user:0, $projectid, 0, $mode); + $tasksarray=$task->getTasksArray($modetask?$user:0, $modeproject?$user:0, $projectid, 0, $mode, '', $filteronprojstatus); if ($tasksarray) { - print ''; if ($useempty) print ''; $j=0; $level=0; @@ -569,6 +571,7 @@ class FormOther if ($disabled) print ' disabled'; print '>'; print $langs->trans("Project").' '.$lines[$i]->projectref; + print ' '.$lines[$i]->projectlabel; if (empty($lines[$i]->public)) { print ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')'; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 4177895bc7c..46f04b08932 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -687,13 +687,13 @@ class Task extends CommonObject * @param int $socid Third party id * @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists * @param string $filteronproj Filter on project ref or label - * @param string $filteronprojstatus Filter on project status + * @param string $filteronprojstatus Filter on project status ('-1'=no filter, '0,1'=Draft+Validated only) * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') * @param string $filteronprojuser Filter on user that is a contact of project * @param string $filterontaskuser Filter on user assigned to task * @return array Array of tasks */ - function getTasksArray($usert=null, $userp=null, $projectid=0, $socid=0, $mode=0, $filteronproj='', $filteronprojstatus=-1, $morewherefilter='',$filteronprojuser=0,$filterontaskuser=0) + function getTasksArray($usert=null, $userp=null, $projectid=0, $socid=0, $mode=0, $filteronproj='', $filteronprojstatus='-1', $morewherefilter='',$filteronprojuser=0,$filterontaskuser=0) { global $conf; @@ -769,7 +769,7 @@ class Task extends CommonObject if ($socid) $sql.= " AND p.fk_soc = ".$socid; if ($projectid) $sql.= " AND p.rowid in (".$projectid.")"; if ($filteronproj) $sql.= natural_search(array("p.ref", "p.title"), $filteronproj); - if ($filteronprojstatus > -1) $sql.= " AND p.fk_statut IN (".$filteronprojstatus.")"; + if ($filteronprojstatus && $filteronprojstatus != '-1') $sql.= " AND p.fk_statut IN (".$filteronprojstatus.")"; if ($morewherefilter) $sql.=$morewherefilter; $sql.= " ORDER BY p.ref, t.rang, t.dateo"; @@ -1828,10 +1828,10 @@ class Task extends CommonObject // For external user, no check is done on company because readability is managed by public status of project and assignement. //$socid=$user->societe_id; - + $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid); - + // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; @@ -1850,7 +1850,7 @@ class Task extends CommonObject if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser // if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - + //print $sql; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 4adcb95d207..5af0d6da9e5 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -462,7 +462,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // List of projects print ''.$langs->trans("ChildOfProjectTask").''; - print $formother->selectProjectTasks(GETPOST('task_parent'),$projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1); + print $formother->selectProjectTasks(GETPOST('task_parent'), $projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1, 0, '0,1', 'maxwidth500'); print ''; print ''.$langs->trans("AffectedTo").'';