add contacg tag on thirdparty and contact création
This commit is contained in:
parent
296c998a36
commit
27b0b0e8d5
@ -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 '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ? '' : $conf->global->SOCIETE_EMAIL_MANDATORY).'</td>';
|
||||
print '<td colspan="3">'.img_picto('', 'object_email').' <input type="text" class="maxwidth500 widthcentpercentminusx" name="email" id="email" value="'.$object->email.'"></td></tr>';
|
||||
print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_email').' <input type="text" class="maxwidth200 widthcentpercentminusx" name="email" id="email" value="'.$object->email.'"></td></tr>';
|
||||
print '<tr><td>'.$form->editfieldkey('Web', 'url', '', $object, 0).'</td>';
|
||||
print '<td colspan="3">'.img_picto('', 'globe').' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.'"></td></tr>';
|
||||
|
||||
@ -1512,6 +1513,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print "</td></tr>";
|
||||
//}
|
||||
|
||||
if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION))
|
||||
{
|
||||
print '<tr class="individualline"><td class="toptd">'.$form->editfieldkey('ContactCategoriesShort', 'contcats', '', $object, 0).'</td><td colspan="3">';
|
||||
$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 "</td></tr>";
|
||||
}
|
||||
|
||||
// Supplier
|
||||
//if ($object->fournisseur) {
|
||||
print '<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).'</td><td colspan="3">';
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user