FIX creation of tasks must hide closed project

This commit is contained in:
Laurent Destailleur 2018-06-21 18:47:02 +02:00
parent cfcedc1170
commit 88d3bf0148
3 changed files with 13 additions and 10 deletions

View File

@ -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 $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 $useempty 0=Allow empty values
* @param int $disablechildoftaskid 1=Disable task that are child of the provided task id * @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 * @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; global $user, $langs;
@ -480,10 +482,10 @@ class FormOther
//print $modeproject.'-'.$modetask; //print $modeproject.'-'.$modetask;
$task=new Task($this->db); $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) if ($tasksarray)
{ {
print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; print '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($useempty) print '<option value="0">&nbsp;</option>'; if ($useempty) print '<option value="0">&nbsp;</option>';
$j=0; $j=0;
$level=0; $level=0;
@ -569,6 +571,7 @@ class FormOther
if ($disabled) print ' disabled'; if ($disabled) print ' disabled';
print '>'; print '>';
print $langs->trans("Project").' '.$lines[$i]->projectref; print $langs->trans("Project").' '.$lines[$i]->projectref;
print ' '.$lines[$i]->projectlabel;
if (empty($lines[$i]->public)) if (empty($lines[$i]->public))
{ {
print ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')'; print ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')';

View File

@ -687,13 +687,13 @@ class Task extends CommonObject
* @param int $socid Third party id * @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 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 $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 $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 $filteronprojuser Filter on user that is a contact of project
* @param string $filterontaskuser Filter on user assigned to task * @param string $filterontaskuser Filter on user assigned to task
* @return array Array of tasks * @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; global $conf;
@ -769,7 +769,7 @@ class Task extends CommonObject
if ($socid) $sql.= " AND p.fk_soc = ".$socid; if ($socid) $sql.= " AND p.fk_soc = ".$socid;
if ($projectid) $sql.= " AND p.rowid in (".$projectid.")"; if ($projectid) $sql.= " AND p.rowid in (".$projectid.")";
if ($filteronproj) $sql.= natural_search(array("p.ref", "p.title"), $filteronproj); 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; if ($morewherefilter) $sql.=$morewherefilter;
$sql.= " ORDER BY p.ref, t.rang, t.dateo"; $sql.= " ORDER BY p.ref, t.rang, t.dateo";

View File

@ -462,7 +462,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
// List of projects // List of projects
print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfProjectTask").'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfProjectTask").'</td><td>';
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 '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>'; print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';