Exemplo n.º 1
0
 /**
  * Update invoice
  *
  * @param int   $id             Id of invoice to update
  * @param array $request_data   Datas   
  * @return int 
  * 
  * @url	PUT invoice/{id}
  */
 function put($id, $request_data = NULL)
 {
     if (!DolibarrApiAccess::$user->rights->facture->creer) {
         throw new RestException(401);
     }
     $result = $this->invoice->fetch($id);
     if (!$result) {
         throw new RestException(404, 'Facture not found');
     }
     if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     foreach ($request_data as $field => $value) {
         $this->invoice->{$field} = $value;
     }
     if ($this->invoice->update($id, DolibarrApiAccess::$user)) {
         return $this->get($id);
     }
     return false;
 }