Merge pull request #14792 from c3do/patch-15
FIX API Order unlink contact did not work like expected
This commit is contained in:
commit
c806ae2654
@ -545,8 +545,9 @@ class Orders extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @param int $id Id of order to update
|
* @param int $id Id of order to update
|
||||||
* @param int $rowid Row key of the contact in the array contact_ids.
|
* @param int $rowid Row key of the contact in the array contact_ids.
|
||||||
|
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
|
||||||
*
|
*
|
||||||
* @url DELETE {id}/contact/{rowid}
|
* @url DELETE {id}/contact/{contactid}/{type}
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*
|
*
|
||||||
@ -554,7 +555,7 @@ class Orders extends DolibarrApi
|
|||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500
|
||||||
*/
|
*/
|
||||||
public function deleteContact($id, $rowid)
|
public function deleteContact($id, $contactid, $type)
|
||||||
{
|
{
|
||||||
if (!DolibarrApiAccess::$user->rights->commande->creer) {
|
if (!DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
@ -569,11 +570,17 @@ class Orders extends DolibarrApi
|
|||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->delete_linked_contact($rowid);
|
$contacts = $this->commande->liste_contact();
|
||||||
|
|
||||||
|
foreach ($contacts as $contact) {
|
||||||
|
if ($contact['id'] == $contactid && $contact['code'] == $type) {
|
||||||
|
$result = $this->commande->delete_contact($contact['rowid']);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new RestException(500, 'Error when deleted the contact');
|
throw new RestException(500, 'Error when deleted the contact');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'success' => array(
|
'success' => array(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user