Esempio n. 1
0
 /**
  * Update order
  *
  * @param int   $id             Id of commande to update
  * @param array $request_data   Datas   
  * 
  * @url	PUT order/{id}
  * 
  * @return int 
  */
 function put($id, $request_data = NULL)
 {
     if (!DolibarrApiAccess::$user->rights->commande->creer) {
         throw new RestException(401);
     }
     $result = $this->commande->fetch($id);
     if (!$result) {
         throw new RestException(404, 'Commande not found');
     }
     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) {
         $this->commande->{$field} = $value;
     }
     if ($this->commande->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) {
         return $this->get($id);
     }
     return false;
 }