$projectstatic = new Project($db); /* * Actions */ // Add new contact if ($action == 'addcontact' && $user->rights->projet->creer) { $result = $object->fetch($id, $ref); if ($result > 0 && $id > 0) { $idfortaskuser = GETPOST("contactid") != 0 ? GETPOST("contactid") : GETPOST("userid"); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" if ($idfortaskuser == -2) { $result = $projectstatic->fetch($object->fk_project); if ($result <= 0) { dol_print_error($db, $projectstatic->error, $projectstatic->errors); } else { $contactsofproject = $projectstatic->getListContactId('internal'); foreach ($contactsofproject as $key => $val) { $result = $object->add_contact($val, GETPOST("type"), GETPOST("source")); } } } else { $result = $object->add_contact($idfortaskuser, GETPOST("type"), GETPOST("source")); } } if ($result >= 0) { header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $object->id . ($withproject ? '&withproject=1' : '')); exit; } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
print '<input type="hidden" name="id" value="'.$id.'">'; // Ligne ajout pour contact interne print "<tr $bc[$var]>"; print '<td nowrap="nowrap">'; print img_object('','user').' '.$langs->trans("Users"); print '</td>'; print '<td colspan="1">'; print $conf->global->MAIN_INFO_SOCIETE_NOM; print '</td>'; print '<td colspan="1">'; // On recupere les id des users deja selectionnes $contactsofproject=$project->getListContactId('internal'); $html->select_users($user->id,'contactid',0,'',0,'',$contactsofproject); print '</td>'; print '<td>'; $formcompany->selectTypeContact($task, '', 'type','internal','rowid'); print '</td>'; print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>'; print '</tr>'; print '</form>'; // Line to add an external contact. Only if project linked to a third party. if ($project->socid) { print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';