26if (!defined(
'NOCSRFCHECK')) {
27 define(
'NOCSRFCHECK',
'1');
29if (!defined(
'NOTOKENRENEWAL')) {
30 define(
'NOTOKENRENEWAL',
'1');
32if (!defined(
'NOREQUIREMENU')) {
33 define(
'NOREQUIREMENU',
'1');
35if (!defined(
'NOREQUIREHTML')) {
36 define(
'NOREQUIREHTML',
'1');
38if (!defined(
'NOREQUIREAJAX')) {
39 define(
'NOREQUIREAJAX',
'1');
41if (!defined(
"NOLOGIN")) {
42 define(
"NOLOGIN",
'1');
44if (!defined(
"NOSESSION")) {
45 define(
"NOSESSION",
'1');
48require
'../main.inc.php';
49require_once NUSOAP_PATH.
'/nusoap.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
61dol_syslog(
"Call Dolibarr webservices interfaces");
67 $langs->load(
"admin");
68 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
69 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
70 print $langs->trans(
"ToActivateModule");
75$listofreferent = array(
77 'order' =>
'commande',
78 'invoice' =>
'facture',
79 'invoice_predefined' =>
'facture_rec',
80 'proposal_supplier' =>
'commande_fournisseur',
81 'order_supplier' =>
'commande_fournisseur',
82 'invoice_supplier' =>
'facture_fourn',
83 'contract' =>
'contrat',
84 'intervention' =>
'fichinter',
85 'trip' =>
'deplacement',
86 'expensereport' =>
'expensereport_det',
88 'agenda' =>
'actioncomm',
89 'project_task' =>
'projet_task',
93$server =
new nusoap_server();
94$server->soap_defencoding =
'UTF-8';
95$server->decode_utf8 =
false;
96$ns =
'http://www.dolibarr.org/ns/';
97$server->configureWSDL(
'WebServicesDolibarrOther', $ns);
99$server->wsdl->schemaTargetNamespace = $ns;
102$server->wsdl->addComplexType(
109 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
110 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
111 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
112 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
113 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string'),
118$server->wsdl->addComplexType(
125 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
126 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
131$server->wsdl->addComplexType(
138 'id' => array(
'name' =>
'id',
'type' =>
'xsd:int'),
139 'user' => array(
'name' =>
'user',
'type' =>
'xsd:int'),
143$server->wsdl->addComplexType(
151 'name' =>
'elementsArray',
152 'type' =>
'tns:element',
154 'maxOccurs' =>
'unbounded'
159$project_elements = array();
160foreach ($listofreferent as $key => $label) {
161 $project_elements[$key] = array(
'name' => $key,
'type' =>
'tns:elementsArray');
163$server->wsdl->addComplexType(
173$project_fields = array(
174 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
175 'ref' => array(
'name' =>
'ref',
'type' =>
'xsd:string'),
176 'label' => array(
'name' =>
'label',
'type' =>
'xsd:string'),
177 'thirdparty_id' => array(
'name' =>
'thirdparty_id',
'type' =>
'xsd:int'),
178 'public' => array(
'name' =>
'public',
'type' =>
'xsd:int'),
179 'status' => array(
'name' =>
'status',
'type' =>
'xsd:int'),
180 'date_start' => array(
'name' =>
'date_start',
'type' =>
'xsd:date'),
181 'date_end' => array(
'name' =>
'date_end',
'type' =>
'xsd:date'),
182 'budget' => array(
'name' =>
'budget',
'type' =>
'xsd:int'),
183 'description' => array(
'name' =>
'description',
'type' =>
'xsd:string'),
184 'elements' => array(
'name' =>
'elements',
'type' =>
'tns:elements')
187$elementtype =
'project';
192$extrafields->fetch_name_optionals_label($elementtype,
true);
193$extrafield_array =
null;
194if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
195 $extrafield_array = array();
197if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
198 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
200 $type = $extrafields->attributes[$elementtype][
'type'][$key];
201 if ($type ==
'date' || $type ==
'datetime') {
202 $type =
'xsd:dateTime';
204 $type =
'xsd:string';
206 $extrafield_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
209if (is_array($extrafield_array)) {
210 $project_fields = array_merge($project_fields, $extrafield_array);
213$server->wsdl->addComplexType(
226$styleuse =
'encoded';
233 array(
'authentication' =>
'tns:authentication',
'project' =>
'tns:project'),
235 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string'),
237 $ns.
'#createProject',
240 'WS to create project'
247 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'ref' =>
'xsd:string'),
249 array(
'result' =>
'tns:result',
'project' =>
'tns:project'),
269 dol_syslog(
"Function: createProject login=".$authentication[
'login']);
271 if ($authentication[
'entity']) {
272 $conf->entity = $authentication[
'entity'];
276 $objectresp = array();
282 if (empty($project[
'ref'])) {
285 $errorlabel =
"Name is mandatory.";
290 $fuser->loadRights();
292 if ($fuser->hasRight(
'projet',
'creer')) {
294 $newobject->ref = $project[
'ref'];
295 $newobject->title = $project[
'label'];
296 $newobject->socid = $project[
'thirdparty_id'];
297 $newobject->public = $project[
'public'];
298 $newobject->statut = $project[
'status'];
299 $newobject->date_start =
dol_stringtotime($project[
'date_start'],
'dayrfc');
301 $newobject->budget_amount = $project[
'budget'];
302 $newobject->description = $project[
'description'];
304 $elementtype =
'project';
309 $extrafields->fetch_name_optionals_label($elementtype,
true);
310 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
311 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
312 $key =
'options_'.$key;
313 $newobject->array_options[$key] = $project[$key];
319 $result = $newobject->create($fuser);
320 if (!$error && $result > 0) {
322 $result = $newobject->add_contact($fuser->id,
'PROJECTLEADER',
'internal');
332 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id,
'ref' => $newobject->ref);
337 $errorlabel = $newobject->error;
341 $errorcode =
'PERMISSION_DENIED';
342 $errorlabel =
'User does not have permission for this request';
347 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
365 dol_syslog(
"Function: getProject login=".$authentication[
'login'].
" id=".
$id.
" ref=".$ref);
367 if ($authentication[
'entity']) {
368 $conf->entity = $authentication[
'entity'];
372 $objectresp = array();
378 if (!$error && ((
$id && $ref))) {
380 $errorcode =
'BAD_PARAMETERS';
381 $errorlabel =
"Parameter id and ref can't be both provided. You must choose one or other but not both.";
385 $fuser->loadRights();
387 if ($fuser->hasRight(
'projet',
'lire')) {
389 $result = $project->fetch((
int)
$id, $ref);
391 $project_result_fields = array(
392 'id' => $project->id,
393 'ref' => $project->ref,
394 'label' => $project->title,
395 'thirdparty_id' => $project->socid,
396 'public' => $project->public,
397 'status' => $project->statut,
398 'date_start' => $project->date_start ?
dol_print_date($project->date_start,
'dayrfc') :
'',
399 'date_end' => $project->date_end ?
dol_print_date($project->date_end,
'dayrfc') :
'',
400 'budget' => $project->budget_amount,
401 'description' => $project->description,
404 $elementtype =
'project';
408 $extrafields->fetch_name_optionals_label($elementtype,
true);
411 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
412 $project->fetch_optionals();
413 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
414 $project_result_fields = array_merge($project_result_fields, array(
'options_'.$key => $project->array_options[
'options_'.$key]));
419 global $listofreferent;
421 foreach ($listofreferent as $key => $tablename) {
422 $elements[$key] = array();
423 $element_array = $project->get_element_list($key, $tablename);
424 if (is_array($element_array) && count($element_array) > 0) {
425 foreach ($element_array as $element) {
426 $tmp = explode(
'_', $element);
427 $idofelement = count($tmp) > 0 ? $tmp[0] :
"";
428 $idofelementuser = count($tmp) > 1 ? $tmp[1] :
"";
429 $elements[$key][] = array(
'id' => $idofelement,
'user' => $idofelementuser);
433 $project_result_fields[
'elements'] = $elements;
437 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
438 'project' => $project_result_fields
442 $errorcode =
'NOT_FOUND';
443 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref;
447 $errorcode =
'PERMISSION_DENIED';
448 $errorlabel =
'User does not have permission for this request';
453 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
460$server->service(file_get_contents(
"php://input"));
$id
Support class for third parties, contacts, members, users or resources.
Class to manage projects.
dol_stringtotime($string, $gm=1, $processnotimeasnoon=0)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
createProject($authentication, $project)
Create project.
getProject($authentication, $id='', $ref='')
Get a project.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.