diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php
index 7fccdf994b9..c24689675ea 100644
--- a/htdocs/societe/card.php
+++ b/htdocs/societe/card.php
@@ -562,7 +562,8 @@ if (empty($reshook))
if ($object->particulier)
{
dol_syslog("We ask to create a contact/address too", LOG_DEBUG);
- $result = $object->create_individual($user);
+ $contcats = GETPOST('contcats', 'array');
+ $result = $object->create_individual($user, $contcats);
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
@@ -1356,7 +1357,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Email / Web
print '
| '.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ? '' : $conf->global->SOCIETE_EMAIL_MANDATORY).' | ';
- print ''.img_picto('', 'object_email').' |
';
+ print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_email').' | ';
print '| '.$form->editfieldkey('Web', 'url', '', $object, 0).' | ';
print ''.img_picto('', 'globe').' |
';
@@ -1512,6 +1513,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print "";
//}
+ if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION))
+ {
+ print '| '.$form->editfieldkey('ContactCategoriesShort', 'contcats', '', $object, 0).' | ';
+ $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, 'parent', null, null, 1);
+ print img_picto('', 'category').$form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
+ print " |
";
+ }
+
// Supplier
//if ($object->fournisseur) {
print '| '.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).' | ';
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 4c25a002a8f..a809fe7d10d 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -900,9 +900,10 @@ class Societe extends CommonObject
* Create a contact/address from thirdparty
*
* @param User $user Object user
+ * @param array $tags Array of tag to affect to contact
* @return int <0 if KO, >0 if OK
*/
- public function create_individual(User $user)
+ public function create_individual(User $user, $tags=array())
{
// phpcs:enable
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
@@ -923,14 +924,23 @@ class Societe extends CommonObject
$contact->town = $this->town;
$contact->phone_pro = $this->phone;
- $result = $contact->create($user);
- if ($result < 0) {
+ $contactId = $contact->create($user);
+ if ($contactId < 0) {
$this->error = $contact->error;
$this->errors = $contact->errors;
dol_syslog(get_class($this)."::create_individual ERROR:".$this->error, LOG_ERR);
+ } elseif (is_array($tags) && !empty($tags)) {
+ $result = $contact->setCategories($tags);
+ if ($result < 0)
+ {
+ $this->error = $contact->error;
+ $this->errors = array_merge($this->errors, $contact->errors);
+ dol_syslog(get_class($this)."::create_individual Affect Tag ERROR:".$this->error, LOG_ERR);
+ $contactId = $result;
+ }
}
- return $result;
+ return $contactId;
}
/**
|