Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
967e8c66
Commit
967e8c66
authored
9 years ago
by
Jean-François Ferry
Browse files
Options
Downloads
Patches
Plain Diff
Add method to get each type of category with a specific uri
parent
0e4a0679
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/categories/class/api_category.class.php
+91
-11
91 additions, 11 deletions
htdocs/categories/class/api_category.class.php
with
91 additions
and
11 deletions
htdocs/categories/class/api_category.class.php
+
91
−
11
View file @
967e8c66
...
...
@@ -40,8 +40,16 @@ class CategoryApi extends DolibarrApi {
'type'
);
static
$TYPES
=
array
(
0
=>
'product'
,
1
=>
'supplier'
,
2
=>
'customer'
,
3
=>
'member'
,
4
=>
'contact'
,
);
/**
* @var
c
ategor
y
$category {@type
c
ategor
y
}
* @var
C
ategor
ie
$category {@type
C
ategor
ie
}
*/
public
$category
;
...
...
@@ -56,6 +64,7 @@ class CategoryApi extends DolibarrApi {
global
$db
,
$conf
;
$this
->
db
=
$db
;
$this
->
category
=
new
Categorie
(
$this
->
db
);
}
/**
...
...
@@ -71,7 +80,7 @@ class CategoryApi extends DolibarrApi {
*/
function
get
(
$id
)
{
if
(
!
DolibarrApiAccess
::
$user
->
rights
->
category
->
re
ad
)
{
if
(
!
DolibarrApiAccess
::
$user
->
rights
->
category
->
li
re
)
{
throw
new
RestException
(
401
);
}
...
...
@@ -94,7 +103,7 @@ class CategoryApi extends DolibarrApi {
*
* @url GET /category/list
*
* @param
int $mode Use this param to filter list
* @param
string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
...
...
@@ -102,7 +111,7 @@ class CategoryApi extends DolibarrApi {
*
* @return array Array of category objects
*/
function
getList
(
$
mode
=
0
,
$sortfield
=
"s.rowid"
,
$sortorder
=
'ASC'
,
$limit
=
0
,
$page
=
0
)
{
function
getList
(
$
type
=
'product'
,
$sortfield
=
"s.rowid"
,
$sortorder
=
'ASC'
,
$limit
=
0
,
$page
=
0
)
{
global
$db
,
$conf
;
$obj_ret
=
array
();
...
...
@@ -113,13 +122,9 @@ class CategoryApi extends DolibarrApi {
$sql
=
"SELECT s.rowid"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"categorie as s"
;
// Example of use $mode
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
$sql
.
=
' WHERE s.entity IN ('
.
getEntity
(
'categorie'
,
1
)
.
')'
;
$sql
.
=
' AND s.type='
.
array_search
(
$type
,
CategoryApi
::
$TYPES
);
$nbtotalofrecords
=
0
;
if
(
empty
(
$conf
->
global
->
MAIN_DISABLE_FULL_SCANLIST
))
{
...
...
@@ -153,7 +158,7 @@ class CategoryApi extends DolibarrApi {
}
}
else
{
throw
new
RestException
(
503
,
'Error when retrieve category list
'
);
throw
new
RestException
(
503
,
'Error when retrieve category list
: '
.
$category_static
->
error
);
}
if
(
!
count
(
$obj_ret
))
{
throw
new
RestException
(
404
,
'No category found'
);
...
...
@@ -161,6 +166,81 @@ class CategoryApi extends DolibarrApi {
return
$obj_ret
;
}
/**
* Get member categories list
*
* @url GET /category/list/member
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
*
* @return mixed
*/
function
getListCategoryMember
(
$sortfield
=
"s.rowid"
,
$sortorder
=
'ASC'
,
$limit
=
0
,
$page
=
0
)
{
return
$this
->
getList
(
'member'
,
$sortfield
,
$sortorder
,
$limit
,
$page
);
}
/**
* Get customer categories list
*
* @url GET /category/list/customer
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
*
* @return mixed
*/
function
getListCategoryCustomer
(
$sortfield
=
"s.rowid"
,
$sortorder
=
'ASC'
,
$limit
=
0
,
$page
=
0
)
{
return
$this
->
getList
(
'customer'
,
$sortfield
,
$sortorder
,
$limit
,
$page
);
}
/**
* Get supplier categories list
*
* @url GET /category/list/supplier
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
*
* @return mixed
*/
function
getListCategorySupplier
(
$sortfield
=
"s.rowid"
,
$sortorder
=
'ASC'
,
$limit
=
0
,
$page
=
0
)
{
return
$this
->
getList
(
'supplier'
,
$sortfield
,
$sortorder
,
$limit
,
$page
);
}
/**
* Get product categories list
*
* @url GET /category/list/product
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
*
* @return mixed
*/
function
getListCategoryProduct
(
$sortfield
=
"s.rowid"
,
$sortorder
=
'ASC'
,
$limit
=
0
,
$page
=
0
)
{
return
$this
->
getList
(
'product'
,
$sortfield
,
$sortorder
,
$limit
,
$page
);
}
/**
* Get contact categories list
*
* @url GET /category/list/contact
*
* @return mixed
*/
function
getListCategoryContact
(
$sortfield
=
"s.rowid"
,
$sortorder
=
'ASC'
,
$limit
=
0
,
$page
=
0
)
{
return
$this
->
getList
(
'contact'
,
$sortfield
,
$sortorder
,
$limit
,
$page
);
}
/**
* Create category object
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment