diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9b34e0ca967..5a169c17fd5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2211,7 +2211,7 @@ class Form global $action; // If no preselected user defined, we take current user - if ((is_numeric($selected) && ($selected < -3 || empty($selected))) && !getDolGlobalString('SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE')) { + if ((is_numeric($selected) && ($selected < -4 || empty($selected))) && !getDolGlobalString('SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE')) { $selected = $user->id; } @@ -2388,6 +2388,18 @@ class Form 'picto' => '' ); } + if ($showalso == 4) { + $out .= '' . "\n"; + + $outarray[-4] = '-- ' . $langs->trans("AllProjectContacts") . ' --'; + $outarray2[-4] = array( + 'id' => -4, + 'label' => '-- ' . $langs->trans("AllProjectContacts") . ' --', + 'labelhtml' => '-- ' . $langs->trans("AllProjectContacts") . ' --', + 'color' => '', + 'picto' => '' + ); + } $userstatic = new User($this->db); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index fa1d4d0dada..e9f5c6c670e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1395,3 +1395,4 @@ NeedHelpCenter=Need support? Efficiency=Efficiency AccordingToYourSetupTheFileWillBeConcatenated=According to your setup, the file %s (uploaded in module setup) will be concatenated to any generated PDF TransactionID=Transaction ID +AllProjectContacts=All project contacts \ No newline at end of file diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 43e849bfbfe..954082decd6 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -391,7 +391,21 @@ if ($action == 'createtask' && $user->hasRight('projet', 'creer')) { $taskid = $task->create($user); if ($taskid > 0) { - $result = $task->add_contact(GETPOSTINT("userid"), 'TASKEXECUTIVE', 'internal'); + $userid = GETPOSTINT("userid"); + if ($userid == -4) { + if (empty($object->id)) { + $object->fetch($projectid); + } + $contactlist = array(); + foreach (array('internal', 'external') as $source) { + $contactlist = array_merge($contactlist, $object->liste_contact(-1, $source)); + } + foreach ($contactlist as $key => $contact) { + $result = $task->add_contact(((int) $contact["id"]), ($contact["code"] == "PROJECTLEADER" ? 'TASKEXECUTIVE' : "TASKCONTRIBUTOR"), $contact["source"]); + } + } else { + $result = $task->add_contact(GETPOSTINT("userid"), 'TASKEXECUTIVE', 'internal'); + } } else { if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("projects"); @@ -819,12 +833,12 @@ if ($action == 'create' && $user->hasRight('projet', 'creer') && (empty($object- print ''.$langs->trans("AffectedTo").''; print img_picto('', 'user', 'class="pictofixedwidth"'); if (is_array($contactsofproject) && count($contactsofproject)) { - print $form->select_dolusers($user->id, 'userid', 0, null, 0, '', $contactsofproject, '0', 0, 0, '', 0, '', 'maxwidth500 widthcentpercentminusx'); + print $form->select_dolusers('-4', 'userid', 0, null, 0, '', $contactsofproject, '0', 0, 0, '(statut:=:1)', 4, '', 'maxwidth500 widthcentpercentminusx'); } else { if ((isset($projectid) && $projectid > 0) || $object->id > 0) { print ''.$langs->trans("NoUserAssignedToTheProject").''; } else { - print $form->select_dolusers($user->id, 'userid', 0, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth500 widthcentpercentminusx'); + print $form->select_dolusers('-4', 'userid', 0, null, 0, '', '', '0', 0, 0, '(statut:=:1)', 4, '', 'maxwidth500 widthcentpercentminusx'); } } print '';