diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d8fac5e8e41..23924814d04 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1054,7 +1054,6 @@ abstract class CommonObject { $this->error = $this->db->errno(); $this->db->rollback(); - echo 'err rollback'; return -2; } else { $this->error = $this->db->error(); diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 253c2c787e4..eff772dfce9 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -57,11 +57,22 @@ $projectstatic = new Project($db); // Add new contact if ($action == 'addcontact' && $user->rights->projet->creer) { + $source = 'internal'; + if (GETPOST("addsourceexternal")) { + $source ='external'; + } + $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 ($source == 'internal') { + $idfortaskuser = ((GETPOST("userid") != 0 && GETPOST('userid') != -1) ? GETPOST("userid") : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + $typeid = GETPOST('type'); + } else { + $idfortaskuser = ((GETPOST("contactid") > 0) ? GETPOST("contactid", 'int') : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + $typeid = GETPOST('typecontact'); + } if ($idfortaskuser == -2) { $result = $projectstatic->fetch($object->fk_project); @@ -72,13 +83,11 @@ if ($action == 'addcontact' && $user->rights->projet->creer) $contactsofproject = $projectstatic->getListContactId('internal'); foreach ($contactsofproject as $key => $val) { - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($val, $type, GETPOST("source", 'aZ09')); + $result = $object->add_contact($val, $typeid, $source); } } } else { - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($idfortaskuser, $typeid, GETPOST("source", 'aZ09')); + $result = $object->add_contact($idfortaskuser, $typeid, $source); } } @@ -353,6 +362,12 @@ if ($id > 0 || !empty($ref)) /* * Add a new contact line */ + print '
'; + print ''; + print ''; + print ''; + if ($withproject) print ''; + print ''; if ($action != 'editline' && $user->rights->projet->creer) @@ -365,13 +380,6 @@ if ($id > 0 || !empty($ref)) print ''; print "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($withproject) print ''; - // Ligne ajout pour contact interne print ''; @@ -387,26 +395,17 @@ if ($id > 0 || !empty($ref)) // On recupere les id des users deja selectionnes if ($object->project->public) $contactsofproject = ''; // Everybody else $contactsofproject = $projectstatic->getListContactId('internal'); - print $form->select_dolusers((GETPOST('contactid') ?GETPOST('contactid') : $user->id), 'contactid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 1, $langs->trans("ResourceNotAssignedToProject")); + print $form->select_dolusers((GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 1, $langs->trans("ResourceNotAssignedToProject")); print ''; print ''; - print ''; + print ''; print ''; - print ''; - // Line to add an external contact. Only if project linked to a third party. if ($projectstatic->socid) { - print ''; - print ''; - print ''; - print ''; - print ''; - if ($withproject) print ''; - print ''; print ''; print ''; - print ''; print ''; - - print ""; } } @@ -535,6 +532,9 @@ if ($id > 0 || !empty($ref)) } } print "
 
'; $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid'); print '
'; @@ -421,18 +420,16 @@ if ($id > 0 || !empty($ref)) print ''; $contactofproject = $projectstatic->getListContactId('external'); - print $form->selectcontacts($selectedCompany, '', 'contactid', 0, '', $contactofproject); + print $form->selectcontacts($selectedCompany, '', 'contactid', 0, '', $contactofproject, 0, '', false, 0, 0); $nbofcontacts = $form->num; print ''; - $formcompany->selectTypeContact($object, '', 'type', 'external', 'rowid'); + $formcompany->selectTypeContact($object, '', 'typecontact', 'external', 'rowid'); print '
"; + + print ""; + } else { print "ErrorRecordNotFound"; }