Update api_orders.class.php

This commit is contained in:
Laurent Destailleur 2017-11-14 01:19:04 +01:00 committed by GitHub
parent d2a67e152b
commit bf05a0b8e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -396,16 +396,16 @@ class Orders extends DolibarrApi
* @return int
*/
function put($id, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (! $result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
if (! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
@ -414,12 +414,12 @@ class Orders extends DolibarrApi
}
// Update availability
if( isset($this->commande->availability_id) && !empty($this->commande->availability_id) ) {
if($this->commande->availability($this->commande->availability_id) < 0)
if (!empty($this->commande->availability_id)) {
if ($this->commande->availability($this->commande->availability_id) < 0)
throw new RestException(400, 'Error while updating availability');
}
if($this->commande->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
if ($this->commande->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
return $this->get($id);
return false;