FIX : we have to check if contact doesn't already exist on add_contact() function
This commit is contained in:
parent
2aaf8b22f2
commit
a6f1e08c19
@ -600,6 +600,20 @@ abstract class CommonObject
|
|||||||
|
|
||||||
$datecreate = dol_now();
|
$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();
|
$this->db->begin();
|
||||||
|
|
||||||
// Insertion dans la base
|
// Insertion dans la base
|
||||||
@ -632,6 +646,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
$this->error=$this->db->errno();
|
$this->error=$this->db->errno();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
|
echo 'err rollback';
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -641,6 +656,7 @@ abstract class CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user