mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 09:08:09 +01:00
Refactor contact deletion logic in API proposals (#35668)
* Refactor contact deletion logic in API proposals * Fix formatting issue in delete contact logic --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -782,19 +782,18 @@ class Proposals extends DolibarrApi
|
||||
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
|
||||
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
foreach (array('internal', 'external') as $source) {
|
||||
$contacts = $this->propal->liste_contact(-1, $source);
|
||||
foreach ($contacts as $contact) {
|
||||
if ($contact['id'] == $contactid && $contact['code'] == $type) {
|
||||
$result = $this->propal->delete_contact($contact['rowid']);
|
||||
|
||||
$contacts = $this->propal->liste_contact();
|
||||
|
||||
foreach ($contacts as $contact) {
|
||||
if ($contact['id'] == $contactid && $contact['code'] == $type) {
|
||||
$result = $this->propal->delete_contact($contact['rowid']);
|
||||
|
||||
if (!$result) {
|
||||
throw new RestException(500, 'Error when deleted the contact');
|
||||
if (!$result) {
|
||||
throw new RestException(500, 'Error when deleted the contact');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($this->propal);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user