diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 5a6bd277618..ae53c83c61d 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -655,6 +655,41 @@ class Proposals extends DolibarrApi throw new RestException(405, $this->propal->error); } } + /** + * Get contacts of given proposal + * + * Return an array with contact information + * + * @param int $id ID of proposal + * @param string $type Type of the proposal + * @return array Array of contacts associated + * + * @url GET {id}/contacts + * + * @throws RestException + */ + public function getContacts($id, $type = '') + { + if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) { + throw new RestException(403); + } + + $result = $this->propal->fetch($id); + if (!$result) { + throw new RestException(404, 'Proposal not found'); + } + + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $contacts = $this->propal->liste_contact(-1, 'external', 0, $type); + $socpeoples = $this->propal->liste_contact(-1, 'internal', 0, $type); + + $contacts = array_merge($contacts, $socpeoples); + + return $contacts; + } /** * Add (link) a contact to a commercial proposal diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 5cba8258a8d..053d01a10e7 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -607,6 +607,9 @@ class Orders extends DolibarrApi } $contacts = $this->commande->liste_contact(-1, 'external', 0, $type); + $socpeoples = $this->commande->liste_contact(-1, 'internal', 0, $type); + + $contacts = array_merge($contacts, $socpeoples); return $contacts; } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index d9150a3620d..557e77e159a 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -732,13 +732,50 @@ class Interventions extends DolibarrApi return $this->_cleanObjectDatas($this->fichinter); } - /** + /** + * Get contacts of given interventional + * + * Return an array with contact information + * + * @param int $id ID of interventional + * @param string $type Type of the interventional + * @return array Object with cleaned properties + * + * @url GET {id}/contacts + * + * @throws RestException + */ + public function getContacts($id, $type = '') + { + if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'lire')) { + throw new RestException(403); + } + + $result = $this->fichinter->fetch($id); + if (!$result) { + throw new RestException(404, 'Interventional not found'); + } + + if (!DolibarrApi::_checkAccessToResource('ficheinter', $this->fichinter->id)) { + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $contacts = $this->fichinter->liste_contact(-1, 'external', 0, $type); + $socpeoples = $this->fichinter->liste_contact(-1, 'internal', 0, $type); + + $contacts = array_merge($contacts, $socpeoples); + + return $contacts; + } + + + /** * Delete a contact type of given interventional * - * @param int $id Id of interventional to update - * @param int $contactid Row key of the contact in the array contact_ids. - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). - * @return Object Object with cleaned properties + * @param int $id Id of interventional to update + * @param int $contactid Row key of the contact in the array contact_ids. + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @return Object Object deleted * * @url DELETE {id}/contact/{contactid}/{type} * @@ -792,7 +829,6 @@ class Interventions extends DolibarrApi */ public function updateInterventionalLine($id, $lineid, $request_data) { - $result = $this->fichinter->fetch($id); if (!$result) { throw new RestException(404, 'Interventional not found');