/**
  * Delete skeleton
  *
  * @param   int     $id   Skeleton ID
  * @return  array
  * 
  * @url	DELETE skeleton/{id}
  */
 function delete($id)
 {
     if (!DolibarrApiAccess::$user->rights->skeleton->supprimer) {
         throw new RestException(401);
     }
     $result = $this->skeleton->fetch($id);
     if (!$result) {
         throw new RestException(404, 'Skeleton not found');
     }
     if (!DolibarrApi::_checkAccessToResource('skeleton', $this->skeleton->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     if (!$this->skeleton->delete($id)) {
         throw new RestException(500);
     }
     return array('success' => array('code' => 200, 'message' => 'Skeleton deleted'));
 }
示例#2
0
 /**
  * Delete category
  *
  * @param int $id   Category ID
  * @return array
  * 
  * @url	DELETE category/{id}
  */
 function delete($id)
 {
     if (!DolibarrApiAccess::$user->rights->categorie->supprimer) {
         throw new RestException(401);
     }
     $result = $this->category->fetch($id);
     if (!$result) {
         throw new RestException(404, 'category not found');
     }
     if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     if (!$this->category->delete(DolibarrApiAccess::$user)) {
         throw new RestException(401, 'error when delete category');
     }
     return array('success' => array('code' => 200, 'message' => 'Category deleted'));
 }
示例#3
0
 /**
  * Delete product
  * 
  * @param   int     $id   Product ID
  * @return  array
  *
  * @url	DELETE product/{id}
  */
 function delete($id)
 {
     if (!DolibarrApiAccess::$user->rights->product->supprimer) {
         throw new RestException(401);
     }
     $result = $this->product->fetch($id);
     if (!$result) {
         throw new RestException(404, 'Product not found');
     }
     if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     return $this->product->delete($id);
 }
示例#4
0
 /**
  * Validate an order
  * 
  * @param   int $id             Order ID
  * @param   int $idwarehouse    Warehouse ID
  * 
  * @url GET     order/{id}/validate
  * @url POST    order/{id}/validate
  *  
  * @return  array
  * 
  */
 function validOrder($id, $idwarehouse = 0)
 {
     if (!DolibarrApiAccess::$user->rights->commande->creer) {
         throw new RestException(401);
     }
     $result = $this->commande->fetch($id);
     if (!$result) {
         throw new RestException(404, 'Order not found');
     }
     if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
         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');
     }
     return array('success' => array('code' => 200, 'message' => 'Order validated'));
 }