New all project contact in task creation (#35862)

Co-authored-by: Lucas Marcouiller <lmarcouiller@dolicloud.com>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Lucas Marcouiller
2025-10-21 02:13:10 +02:00
committed by GitHub
parent cdd4dde166
commit ad67faa01d
3 changed files with 31 additions and 4 deletions

View File

@@ -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 .= '<option value="-4"' . ((in_array(-4, $selected)) ? ' selected' : '') . '>-- ' . $langs->trans("AllProjectContacts") . ' --</option>' . "\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);

View File

@@ -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

View File

@@ -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 '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
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 '<span class="opacitymedium">'.$langs->trans("NoUserAssignedToTheProject").'</span>';
} 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 '</td></tr>';