Skip to content

Commit

Permalink
NEW Tag the order as validated (opened) in the REST API
Browse files Browse the repository at this point in the history
Tag the order as validated (opened)
  • Loading branch information
Neil Orley committed Nov 15, 2017
1 parent 8e86968 commit 42d1072
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions htdocs/commande/class/api_orders.class.php
Expand Up @@ -511,6 +511,45 @@ function validate($id, $idwarehouse=0, $notrigger=0)
return $this->_cleanObjectDatas($this->commande);
}

/**
* Tag the order as validated (opened)
*
* Function used when order is reopend after being closed.
*
* @param int $id Id of the order
*
* @url POST {id}/reopen
*
* @return int
*
* @throws 304
* @throws 400
* @throws 401
* @throws 404
* @throws 405
*/
function reopen($id) {

if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($orderid);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}

$result = $this->commande->set_reopen(DolibarrApiAccess::$user);
if( $result < 0) {
throw new RestException(405, $this->commande->error);
}else if( $result == 0) {
throw new RestException(304);
}
return $result;
}

/**
* Close an order (Classify it as "Delivered")
*
Expand Down

0 comments on commit 42d1072

Please sign in to comment.