contact deletion in api_orders class for internal and external (#35455)

* contact deletion in api_orders class for internal and external

* Update api_orders.class.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Charlène Benke
2025-09-23 21:43:39 +02:00
committed by GitHub
parent ca8a6c9c45
commit 496fef63a3

View File

@@ -691,14 +691,15 @@ class Orders extends DolibarrApi
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$contacts = $this->commande->liste_contact();
foreach (array('internal', 'external') as $source) {
$contacts = $this->commande->liste_contact(-1, $source);
foreach ($contacts as $contact) {
if ($contact['id'] == $contactid && $contact['code'] == $type) {
$result = $this->commande->delete_contact($contact['rowid']);
foreach ($contacts as $contact) {
if ($contact['id'] == $contactid && $contact['code'] == $type) {
$result = $this->commande->delete_contact($contact['rowid']);
if (!$result) {
throw new RestException(500, 'Error when deleted the contact');
if (!$result) {
throw new RestException(500, 'Error when deleting the contact '.$contact['rowid']);
}
}
}
}