mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW get proposal by ref with API
This commit is contained in:
parent
760afd6838
commit
fa5aeebcd8
|
|
@ -64,11 +64,66 @@ class Proposals extends DolibarrApi
|
|||
*/
|
||||
public function get($id, $contact_list = 1)
|
||||
{
|
||||
return $this->_fetch($id, '', '', '', $contact_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of an proposal object by ref
|
||||
*
|
||||
* Return an array with proposal informations
|
||||
*
|
||||
* @param string $ref Ref of object
|
||||
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @url GET ref/{ref}
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function getByRef($ref, $contact_list = 1)
|
||||
{
|
||||
return $this->_fetch('', $ref, '', '', $contact_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of an proposal object by ref_ext
|
||||
*
|
||||
* Return an array with proposal informations
|
||||
*
|
||||
* @param string $ref_ext External reference of object
|
||||
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @url GET ref_ext/{ref_ext}
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function getByRefExt($ref_ext, $contact_list = 1)
|
||||
{
|
||||
return $this->_fetch('', '', $ref_ext, '', $contact_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of an proposal object
|
||||
*
|
||||
* Return an array with proposal informations
|
||||
*
|
||||
* @param int $id ID of order
|
||||
* @param string $ref Ref of object
|
||||
* @param string $ref_ext External reference of object
|
||||
* @param string $ref_int Internal reference of other objec
|
||||
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
private function _fetch($id, $ref = '', $ref_ext = '', $ref_int = '', $contact_list = 1)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->propal->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->propal->fetch($id);
|
||||
$result = $this->propal->fetch($id, $ref, $ref_ext, $ref_int);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Commercial Proposal not found');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user