NEW Add REST api for commercial proposals

This commit is contained in:
Laurent Destailleur
2016-09-22 12:53:44 +02:00
parent 8fa8bc7d34
commit 35dd492d19
5 changed files with 627 additions and 100 deletions

View File

@@ -449,10 +449,11 @@ class Orders extends DolibarrApi
* Error message: "Forbidden: Content type `text/plain` is not supported."
* Workaround: send this in the body
* {
* "idwarehouse": 0
* "idwarehouse": 0,
* "notrigger": 0
* }
*/
function validate($id, $idwarehouse=0)
function validate($id, $idwarehouse=0, $notrigger=0)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
@@ -466,10 +467,14 @@ class Orders extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! $this->commande->valid(DolibarrApiAccess::$user, $idwarehouse)) {
throw new RestException(500, 'Error when validate order');
}
$result = $this->commande->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
if ($result == 0) {
throw new RestException(500, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Order: '.$this->commande->error);
}
return array(
'success' => array(
'code' => 200,