From 496fef63a3ab2fb7d6742f30df364b005f8282bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Tue, 23 Sep 2025 21:43:39 +0200 Subject: [PATCH] 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 --- htdocs/commande/class/api_orders.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 91252f216b4..89496742c03 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -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']); + } } } }