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
1e3b8e56
Commit
1e3b8e56
authored
11 years ago
by
guerinaxel
Browse files
Options
Downloads
Patches
Plain Diff
Add extrafields to productorservice webservice
parent
3f96632e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/webservices/server_productorservice.php
+144
-77
144 additions, 77 deletions
htdocs/webservices/server_productorservice.php
with
144 additions
and
77 deletions
htdocs/webservices/server_productorservice.php
+
144
−
77
View file @
1e3b8e56
...
@@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
...
@@ -34,6 +34,7 @@ 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
.
'/product/class/product.class.php'
;
require_once
(
DOL_DOCUMENT_ROOT
.
"/categories/class/categorie.class.php"
);
require_once
(
DOL_DOCUMENT_ROOT
.
"/categories/class/categorie.class.php"
);
require_once
DOL_DOCUMENT_ROOT
.
'/core/class/extrafields.class.php'
;
...
@@ -88,14 +89,7 @@ $server->wsdl->addComplexType(
...
@@ -88,14 +89,7 @@ $server->wsdl->addComplexType(
)
)
);
);
// Define other specific objects
$productorservice_fields
=
array
(
$server
->
wsdl
->
addComplexType
(
'product'
,
'complexType'
,
'struct'
,
'all'
,
''
,
array
(
'id'
=>
array
(
'name'
=>
'id'
,
'type'
=>
'xsd:string'
),
'id'
=>
array
(
'name'
=>
'id'
,
'type'
=>
'xsd:string'
),
'ref'
=>
array
(
'name'
=>
'ref'
,
'type'
=>
'xsd:string'
),
'ref'
=>
array
(
'name'
=>
'ref'
,
'type'
=>
'xsd:string'
),
'ref_ext'
=>
array
(
'name'
=>
'ref_ext'
,
'type'
=>
'xsd:string'
),
'ref_ext'
=>
array
(
'name'
=>
'ref_ext'
,
'type'
=>
'xsd:string'
),
...
@@ -133,7 +127,34 @@ $server->wsdl->addComplexType(
...
@@ -133,7 +127,34 @@ $server->wsdl->addComplexType(
'dir'
=>
array
(
'name'
=>
'dir'
,
'type'
=>
'xsd:string'
),
'dir'
=>
array
(
'name'
=>
'dir'
,
'type'
=>
'xsd:string'
),
'images'
=>
array
(
'name'
=>
'images'
,
'type'
=>
'tns:ImagesArray'
)
'images'
=>
array
(
'name'
=>
'images'
,
'type'
=>
'tns:ImagesArray'
)
)
);
//Retreive all extrafield for product
// fetch optionals attributes and labels
$extrafields
=
new
ExtraFields
(
$db
);
$extralabels
=
$extrafields
->
fetch_name_optionals_label
(
'product'
,
true
);
if
(
count
(
$extrafields
)
>
0
)
{
$extrafield_array
=
array
();
}
foreach
(
$extrafields
->
attribute_label
as
$key
=>
$label
)
{
$type
=
$extrafields
->
attribute_type
[
$key
];
if
(
$type
==
'date'
||
$type
==
'datetime'
)
{
$type
=
'xsd:dateTime'
;}
else
{
$type
=
'xsd:string'
;}
$extrafield_array
[
'options_'
.
$key
]
=
array
(
'name'
=>
'options_'
.
$key
,
'type'
=>
$type
);
}
$productorservice_fields
=
array_merge
(
$productorservice_fields
,
$extrafield_array
);
// Define other specific objects
$server
->
wsdl
->
addComplexType
(
'product'
,
'complexType'
,
'struct'
,
'all'
,
''
,
$productorservice_fields
);
);
...
@@ -358,10 +379,7 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang=''
...
@@ -358,10 +379,7 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang=''
if
(
!
empty
(
$product
->
multilangs
[
$langs
->
defaultlang
][
"description"
]))
$product
->
description
=
$product
->
multilangs
[
$langs
->
defaultlang
][
"description"
];
if
(
!
empty
(
$product
->
multilangs
[
$langs
->
defaultlang
][
"description"
]))
$product
->
description
=
$product
->
multilangs
[
$langs
->
defaultlang
][
"description"
];
if
(
!
empty
(
$product
->
multilangs
[
$langs
->
defaultlang
][
"note"
]))
$product
->
note
=
$product
->
multilangs
[
$langs
->
defaultlang
][
"note"
];
if
(
!
empty
(
$product
->
multilangs
[
$langs
->
defaultlang
][
"note"
]))
$product
->
note
=
$product
->
multilangs
[
$langs
->
defaultlang
][
"note"
];
// Create
$productorservice_result_fields
=
array
(
$objectresp
=
array
(
'result'
=>
array
(
'result_code'
=>
'OK'
,
'result_label'
=>
''
),
'product'
=>
array
(
'id'
=>
$product
->
id
,
'id'
=>
$product
->
id
,
'ref'
=>
$product
->
ref
,
'ref'
=>
$product
->
ref
,
'ref_ext'
=>
$product
->
ref_ext
,
'ref_ext'
=>
$product
->
ref_ext
,
...
@@ -397,7 +415,25 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang=''
...
@@ -397,7 +415,25 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang=''
'import_key'
=>
$product
->
import_key
,
'import_key'
=>
$product
->
import_key
,
'dir'
=>
$pdir
,
'dir'
=>
$pdir
,
'images'
=>
$product
->
liste_photos
(
$dir
,
$nbmax
=
10
)
'images'
=>
$product
->
liste_photos
(
$dir
,
$nbmax
=
10
)
));
);
//Retreive all extrafield for thirdsparty
// fetch optionals attributes and labels
$extrafields
=
new
ExtraFields
(
$db
);
$extralabels
=
$extrafields
->
fetch_name_optionals_label
(
'product'
,
true
);
//Get extrafield values
$product
->
fetch_optionals
(
$product
->
id
,
$extralabels
);
foreach
(
$extrafields
->
attribute_label
as
$key
=>
$label
)
{
$productorservice_result_fields
=
array_merge
(
$productorservice_result_fields
,
array
(
'options_'
.
$key
=>
$product
->
array_options
[
'options_'
.
$key
]));
}
// Create
$objectresp
=
array
(
'result'
=>
array
(
'result_code'
=>
'OK'
,
'result_label'
=>
''
),
'product'
=>
$productorservice_result_fields
);
}
}
else
else
{
{
...
@@ -498,6 +534,14 @@ function createProductOrService($authentication,$product)
...
@@ -498,6 +534,14 @@ function createProductOrService($authentication,$product)
//var_dump($product['ref_ext']);
//var_dump($product['ref_ext']);
//var_dump($product['lines'][0]['type']);
//var_dump($product['lines'][0]['type']);
$extrafields
=
new
ExtraFields
(
$db
);
$extralabels
=
$extrafields
->
fetch_name_optionals_label
(
'product'
,
true
);
foreach
(
$extrafields
->
attribute_label
as
$key
=>
$label
)
{
$key
=
'options_'
.
$key
;
$newobject
->
array_options
[
$key
]
=
$product
[
$key
];
}
$db
->
begin
();
$db
->
begin
();
$result
=
$newobject
->
create
(
$fuser
,
0
);
$result
=
$newobject
->
create
(
$fuser
,
0
);
...
@@ -609,6 +653,14 @@ function updateProductOrService($authentication,$product)
...
@@ -609,6 +653,14 @@ function updateProductOrService($authentication,$product)
//var_dump($product['ref_ext']);
//var_dump($product['ref_ext']);
//var_dump($product['lines'][0]['type']);
//var_dump($product['lines'][0]['type']);
$extrafields
=
new
ExtraFields
(
$db
);
$extralabels
=
$extrafields
->
fetch_name_optionals_label
(
'product'
,
true
);
foreach
(
$extrafields
->
attribute_label
as
$key
=>
$label
)
{
$key
=
'options_'
.
$key
;
$newobject
->
array_options
[
$key
]
=
$product
[
$key
];
}
$db
->
begin
();
$db
->
begin
();
$result
=
$newobject
->
update
(
$newobject
->
id
,
$fuser
);
$result
=
$newobject
->
update
(
$newobject
->
id
,
$fuser
);
...
@@ -875,6 +927,7 @@ function getProductsForCategory($authentication,$id,$lang='')
...
@@ -875,6 +927,7 @@ function getProductsForCategory($authentication,$id,$lang='')
{
{
$obj
=
new
Product
(
$db
);
$obj
=
new
Product
(
$db
);
$obj
->
fetch
(
$rec
[
'fk_'
.
$field
]);
$obj
->
fetch
(
$rec
[
'fk_'
.
$field
]);
$iProduct
=
0
;
if
(
$obj
->
status
>
0
)
if
(
$obj
->
status
>
0
)
{
{
$dir
=
(
!
empty
(
$conf
->
product
->
dir_output
)
?
$conf
->
product
->
dir_output
:
$conf
->
service
->
dir_output
);
$dir
=
(
!
empty
(
$conf
->
product
->
dir_output
)
?
$conf
->
product
->
dir_output
:
$conf
->
service
->
dir_output
);
...
@@ -912,6 +965,20 @@ function getProductsForCategory($authentication,$id,$lang='')
...
@@ -912,6 +965,20 @@ function getProductsForCategory($authentication,$id,$lang='')
'dir'
=>
$pdir
,
'dir'
=>
$pdir
,
'images'
=>
$obj
->
liste_photos
(
$dir
,
$nbmax
=
10
)
'images'
=>
$obj
->
liste_photos
(
$dir
,
$nbmax
=
10
)
);
);
//Retreive all extrafield for thirdsparty
// fetch optionals attributes and labels
$extrafields
=
new
ExtraFields
(
$db
);
$extralabels
=
$extrafields
->
fetch_name_optionals_label
(
'product'
,
true
);
//Get extrafield values
$product
->
fetch_optionals
(
$obj
->
id
,
$extralabels
);
foreach
(
$extrafields
->
attribute_label
as
$key
=>
$label
)
{
$products
[
$iProduct
]
=
array_merge
(
$products
[
$iProduct
],
array
(
'options_'
.
$key
=>
$product
->
array_options
[
'options_'
.
$key
]));
}
$iProduct
++
;
}
}
}
}
...
...
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