Merge pull request #8173 from Ysandor/patch-1
NEW [REST API] Add the possibility to remove a category from a thirdparty
This commit is contained in:
commit
3d3e3809f4
@ -552,7 +552,45 @@ class Thirdparties extends DolibarrApi
|
|||||||
return $this->company;
|
return $this->company;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete category to a thirdparty
|
||||||
|
*
|
||||||
|
* @param int $id Id of thirdparty
|
||||||
|
* @param array $request_data Request datas
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @url POST {id}/deleteCategory
|
||||||
|
*/
|
||||||
|
function deleteCategory($id, $request_data = NULL) {
|
||||||
|
if (!isset($request_data["category_id"]))
|
||||||
|
throw new RestException(400, "category_id field missing");
|
||||||
|
$category_id = $request_data["category_id"];
|
||||||
|
|
||||||
|
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||||
|
throw new RestException(401);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->company->fetch($id);
|
||||||
|
if( ! $result ) {
|
||||||
|
throw new RestException(404, 'Thirdparty not found');
|
||||||
|
}
|
||||||
|
$category = new Categorie($this->db);
|
||||||
|
$result = $category->fetch($category_id);
|
||||||
|
if( ! $result ) {
|
||||||
|
throw new RestException(404, 'category not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
|
||||||
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
|
}
|
||||||
|
if( ! DolibarrApi::_checkAccessToResource('category',$category->id)) {
|
||||||
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
|
}
|
||||||
|
|
||||||
|
$category->del_type($this->company,'customer');
|
||||||
|
return $this->company;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get outstanding proposals of thirdparty
|
* Get outstanding proposals of thirdparty
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user