Merge pull request #7126 from atm-gauthier/FIX_add_contact
FIX : we have to check if contact doesn't already exist on add_contact
This commit is contained in:
commit
efd292e8f5
@ -600,6 +600,20 @@ abstract class CommonObject
|
||||
|
||||
$datecreate = dol_now();
|
||||
|
||||
// Socpeople must have already been added by some a trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error
|
||||
$TListeContacts=$this->liste_contact(-1, $source);
|
||||
$already_added=false;
|
||||
if(!empty($TListeContacts)) {
|
||||
foreach($TListeContacts as $array_contact) {
|
||||
if($array_contact['status'] == 4 && $array_contact['id'] == $fk_socpeople && $array_contact['fk_c_type_contact'] == $id_type_contact) {
|
||||
$already_added=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$already_added) {
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Insertion dans la base
|
||||
@ -632,6 +646,7 @@ abstract class CommonObject
|
||||
{
|
||||
$this->error=$this->db->errno();
|
||||
$this->db->rollback();
|
||||
echo 'err rollback';
|
||||
return -2;
|
||||
}
|
||||
else
|
||||
@ -641,6 +656,7 @@ abstract class CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user