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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
dc775c44
Commit
dc775c44
authored
Nov 18, 2012
by
Regis Houssin
Browse files
Options
Downloads
Plain Diff
Merge pull request #486 from jfefe/webservices
Webservices
parents
fe86b5d2
0f789f6a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/webservices/server_productorservice.php
+145
-0
145 additions, 0 deletions
htdocs/webservices/server_productorservice.php
htdocs/webservices/server_user.php
+118
-0
118 additions, 0 deletions
htdocs/webservices/server_user.php
with
263 additions
and
0 deletions
htdocs/webservices/server_productorservice.php
+
145
−
0
View file @
dc775c44
...
...
@@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once
DOL_DOCUMENT_ROOT
.
'/user/class/user.class.php'
;
require_once
DOL_DOCUMENT_ROOT
.
'/product/class/product.class.php'
;
require_once
(
DOL_DOCUMENT_ROOT
.
"/categories/class/categorie.class.php"
);
dol_syslog
(
"Call Dolibarr webservices interfaces"
);
...
...
@@ -255,6 +257,20 @@ $server->register(
'WS to get list of all products or services id and ref'
);
// Register WSDL
$server
->
register
(
'getProductsForCategory'
,
// Entry values
array
(
'authentication'
=>
'tns:authentication'
,
'id'
=>
'xsd:string'
),
// Exit values
array
(
'result'
=>
'tns:result'
,
'products'
=>
'ProductsArray'
),
$ns
,
$ns
.
'#getProductsForCategory'
,
$styledoc
,
$styleuse
,
'WS to get list of all products or services for a category'
);
/**
* Get produt or service
...
...
@@ -541,6 +557,135 @@ function getListOfProductsOrServices($authentication,$filterproduct)
}
// return category infos and children
function
getProductsForCategory
(
$authentication
,
$id
)
{
global
$db
,
$conf
,
$langs
;
dol_syslog
(
"Function: getProductsForCategory login="
.
$authentication
[
'login'
]
.
" id="
.
$id
);
if
(
$authentication
[
'entity'
])
$conf
->
entity
=
$authentication
[
'entity'
];
$objectresp
=
array
();
$errorcode
=
''
;
$errorlabel
=
''
;
$error
=
0
;
$fuser
=
check_authentication
(
$authentication
,
$error
,
$errorcode
,
$errorlabel
);
if
(
!
$error
&&
!
$id
)
{
$error
++
;
$errorcode
=
'BAD_PARAMETERS'
;
$errorlabel
=
"Parameter id must be provided."
;
}
if
(
!
$error
)
{
$fuser
->
getrights
();
if
(
$fuser
->
rights
->
produit
->
lire
)
{
$categorie
=
new
Categorie
(
$db
);
$result
=
$categorie
->
fetch
(
$id
);
if
(
$result
>
0
)
{
$table
=
"product"
;
$field
=
"product"
;
$sql
=
"SELECT fk_"
.
$field
.
" FROM "
.
MAIN_DB_PREFIX
.
"categorie_"
.
$table
;
$sql
.
=
" WHERE fk_categorie = "
.
$id
;
$sql
.
=
" ORDER BY fk_"
.
$field
.
" ASC"
;
dol_syslog
(
"GetProductsForCategory::get_type sql="
.
$sql
);
$res
=
$db
->
query
(
$sql
);
if
(
$res
)
{
while
(
$rec
=
$db
->
fetch_array
(
$res
))
{
$obj
=
new
Product
(
$db
);
$obj
->
fetch
(
$rec
[
'fk_'
.
$field
]);
if
(
$obj
->
status
>
0
)
{
$dir
=
(
!
empty
(
$conf
->
product
->
dir_output
)
?
$conf
->
product
->
dir_output
:
$conf
->
service
->
dir_output
);
$pdir
=
get_exdir
(
$obj
->
id
,
2
)
.
$obj
->
id
.
"/photos/"
;
$dir
=
$dir
.
'/'
.
$pdir
;
$products
[]
=
array
(
'id'
=>
$obj
->
id
,
'ref'
=>
$obj
->
ref
,
'ref_ext'
=>
$obj
->
ref_ext
,
'label'
=>
$obj
->
label
,
'description'
=>
$obj
->
description
,
'date_creation'
=>
dol_print_date
(
$obj
->
date_creation
,
'dayhourrfc'
),
'date_modification'
=>
dol_print_date
(
$obj
->
date_modification
,
'dayhourrfc'
),
'note'
=>
$obj
->
note
,
'status_tosell'
=>
$obj
->
status
,
'status_tobuy'
=>
$obj
->
status_buy
,
'type'
=>
$obj
->
type
,
'barcode'
=>
$obj
->
barcode
,
'barcode_type'
=>
$obj
->
barcode_type
,
'country_id'
=>
$obj
->
country_id
>
0
?
$obj
->
country_id
:
''
,
'country_code'
=>
$obj
->
country_code
,
'custom_code'
=>
$obj
->
customcode
,
'price_net'
=>
$obj
->
price
,
'price'
=>
(
$obj
->
price_ttc
-
$obj
->
price
),
'vat_rate'
=>
$obj
->
tva_tx
,
'price_ttc'
=>
$obj
->
price_ttc
,
'price_base_type'
=>
$obj
->
price_base_type
,
'stock_real'
=>
$obj
->
stock_reel
,
'stock_alert'
=>
$obj
->
seuil_stock_alerte
,
'pmp'
=>
$obj
->
pmp
,
'import_key'
=>
$obj
->
import_key
,
'dir'
=>
$pdir
,
'photos'
=>
$obj
->
liste_photos
(
$dir
,
$nbmax
=
10
)
);
}
}
// Retour
$objectresp
=
array
(
'result'
=>
array
(
'result_code'
=>
'OK'
,
'result_label'
=>
''
),
'products'
=>
$products
);
}
else
{
$errorcode
=
'NORECORDS_FOR_ASSOCIATION'
;
$errorlabel
=
'No products associated'
.
$sql
;
$objectresp
=
array
(
'result'
=>
array
(
'result_code'
=>
$errorcode
,
'result_label'
=>
$errorlabel
));
dol_syslog
(
"getProductsForCategory:: "
.
$c
->
error
,
LOG_DEBUG
);
}
}
else
{
$error
++
;
$errorcode
=
'NOT_FOUND'
;
$errorlabel
=
'Object not found for id='
.
$id
;
}
}
else
{
$error
++
;
$errorcode
=
'PERMISSION_DENIED'
;
$errorlabel
=
'User does not have permission for this request'
;
}
}
if
(
$error
)
{
$objectresp
=
array
(
'result'
=>
array
(
'result_code'
=>
$errorcode
,
'result_label'
=>
$errorlabel
));
}
return
$objectresp
;
}
// Return the results.
...
...
This diff is collapsed.
Click to expand it.
htdocs/webservices/server_user.php
+
118
−
0
View file @
dc775c44
...
...
@@ -120,6 +120,34 @@ $server->wsdl->addComplexType(
)
);
// Define other specific objects
$server
->
wsdl
->
addComplexType
(
'group'
,
'complexType'
,
'struct'
,
'all'
,
''
,
array
(
'nom'
=>
array
(
'name'
=>
'nom'
,
'type'
=>
'xsd:string'
),
'id'
=>
array
(
'name'
=>
'id'
,
'type'
=>
'xsd:string'
),
'datec'
=>
array
(
'name'
=>
'datec'
,
'type'
=>
'xsd:string'
),
'nb'
=>
array
(
'name'
=>
'nb'
,
'type'
=>
'xsd:string'
)
)
);
$server
->
wsdl
->
addComplexType
(
'GroupsArray'
,
'complexType'
,
'array'
,
''
,
'SOAP-ENC:Array'
,
array
(),
array
(
array
(
'ref'
=>
'SOAP-ENC:arrayType'
,
'wsdl:arrayType'
=>
'tns:group[]'
)
),
'tns:group'
);
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
...
...
@@ -144,6 +172,19 @@ $server->register(
'WS to get user'
);
$server
->
register
(
'getListOfGroups'
,
// Entry values
array
(
'authentication'
=>
'tns:authentication'
),
// Exit values
array
(
'result'
=>
'tns:result'
,
'groups'
=>
'tns:GroupsArray'
),
$ns
,
$ns
.
'#getListOfGroups'
,
$styledoc
,
$styleuse
,
'WS to get list of groups'
);
...
...
@@ -246,6 +287,83 @@ function getUser($authentication,$id,$ref='',$ref_ext='')
return
$objectresp
;
}
/**
* getListOfGroups
*
* @param array $authentication Array of authentication information
* @return array Array result
*/
function
getListOfGroups
(
$authentication
)
{
global
$db
,
$conf
,
$langs
;
$now
=
dol_now
();
dol_syslog
(
"Function: getListOfGroups login="
.
$authentication
[
'login'
]);
if
(
$authentication
[
'entity'
])
$conf
->
entity
=
$authentication
[
'entity'
];
// Init and check authentication
$objectresp
=
array
();
$arraygroups
=
array
();
$errorcode
=
''
;
$errorlabel
=
''
;
$error
=
0
;
$fuser
=
check_authentication
(
$authentication
,
$error
,
$errorcode
,
$errorlabel
);
// Check parameters
if
(
!
$error
)
{
$sql
=
"SELECT g.rowid, g.nom, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"usergroup as g"
;
$sql
.
=
" LEFT JOIN "
.
MAIN_DB_PREFIX
.
"usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"
;
if
(
!
empty
(
$conf
->
multicompany
->
enabled
)
&&
$conf
->
entity
==
1
&&
(
$conf
->
multicompany
->
transverse_mode
||
(
$user
->
admin
&&
!
$user
->
entity
)))
{
$sql
.
=
" WHERE g.entity IS NOT NULL"
;
}
else
{
$sql
.
=
" WHERE g.entity IN (0,"
.
$conf
->
entity
.
")"
;
}
$sql
.
=
" GROUP BY g.rowid, g.nom, g.entity, g.datec"
;
$resql
=
$db
->
query
(
$sql
);
if
(
$resql
)
{
$num
=
$db
->
num_rows
(
$resql
);
$i
=
0
;
while
(
$i
<
$num
)
{
$obj
=
$db
->
fetch_object
(
$resql
);
$arraygroups
[]
=
array
(
'id'
=>
$obj
->
rowid
,
'nom'
=>
$obj
->
nom
,
'datec'
=>
$obj
->
datec
,
'nb'
=>
$obj
->
nb
);
$i
++
;
}
}
else
{
$error
++
;
$errorcode
=
$db
->
lasterrno
();
$errorlabel
=
$db
->
lasterror
();
}
}
if
(
$error
)
{
$objectresp
=
array
(
'result'
=>
array
(
'result_code'
=>
$errorcode
,
'result_label'
=>
$errorlabel
),
'groups'
=>
$arraygroups
);
}
else
{
$objectresp
=
array
(
'result'
=>
array
(
'result_code'
=>
'OK'
,
'result_label'
=>
''
),
'groups'
=>
$arraygroups
);
}
return
$objectresp
;
}
// Return the results.
...
...
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