26 if (!defined(
"NOCSRFCHECK")) define(
"NOCSRFCHECK",
'1');
28 require
"../master.inc.php";
29 require_once NUSOAP_PATH.
'/nusoap.php';
30 require_once DOL_DOCUMENT_ROOT.
"/core/lib/ws.lib.php";
32 require_once DOL_DOCUMENT_ROOT.
"/comm/action/class/actioncomm.class.php";
33 require_once DOL_DOCUMENT_ROOT.
"/comm/action/class/cactioncomm.class.php";
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
37 dol_syslog(
"Call ActionComm webservices interfaces");
40 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
42 $langs->load(
"admin");
43 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
44 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
45 print $langs->trans(
"ToActivateModule");
50 $server =
new nusoap_server();
51 $server->soap_defencoding =
'UTF-8';
52 $server->decode_utf8 =
false;
53 $ns =
'http://www.dolibarr.org/ns/';
54 $server->configureWSDL(
'WebServicesDolibarrActionComm', $ns);
55 $server->wsdl->schemaTargetNamespace = $ns;
59 $server->wsdl->addComplexType(
66 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
67 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
68 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
69 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
70 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
75 $server->wsdl->addComplexType(
82 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
83 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
88 $actioncomm_fields = array(
89 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
90 'ref' => array(
'name'=>
'ref',
'type'=>
'xsd:string'),
91 'ref_ext' => array(
'name'=>
'ref_ext',
'type'=>
'xsd:string'),
92 'type_id' => array(
'name'=>
'type_id',
'type'=>
'xsd:string'),
93 'type_code' => array(
'name'=>
'type_code',
'type'=>
'xsd:string'),
94 'type' => array(
'name'=>
'type',
'type'=>
'xsd:string'),
95 'label' => array(
'name'=>
'label',
'type'=>
'xsd:string'),
96 'datep' => array(
'name'=>
'datep',
'type'=>
'xsd:dateTime'),
97 'datef' => array(
'name'=>
'datef',
'type'=>
'xsd:dateTime'),
98 'datec' => array(
'name'=>
'datec',
'type'=>
'xsd:dateTime'),
99 'datem' => array(
'name'=>
'datem',
'type'=>
'xsd:dateTime'),
100 'note' => array(
'name'=>
'note',
'type'=>
'xsd:string'),
101 'percentage' => array(
'name'=>
'percentage',
'type'=>
'xsd:string'),
102 'author' => array(
'name'=>
'author',
'type'=>
'xsd:string'),
103 'usermod' => array(
'name'=>
'usermod',
'type'=>
'xsd:string'),
104 'userownerid' => array(
'name'=>
'userownerid',
'type'=>
'xsd:string'),
105 'priority' => array(
'name'=>
'priority',
'type'=>
'xsd:string'),
106 'fulldayevent' => array(
'name'=>
'fulldayevent',
'type'=>
'xsd:string'),
107 'location' => array(
'name'=>
'location',
'type'=>
'xsd:string'),
108 'socid' => array(
'name'=>
'socid',
'type'=>
'xsd:string'),
109 'contactid' => array(
'name'=>
'contactid',
'type'=>
'xsd:string'),
110 'projectid' => array(
'name'=>
'projectid',
'type'=>
'xsd:string'),
111 'fk_element' => array(
'name'=>
'fk_element',
'type'=>
'xsd:string'),
112 'elementtype' => array(
'name'=>
'elementtype',
'type'=>
'xsd:string'));
115 $elementtype =
'actioncomm';
120 $extrafields->fetch_name_optionals_label($elementtype,
true);
121 $extrafield_array = null;
122 if (is_array($extrafields) && count($extrafields) > 0) {
123 $extrafield_array = array();
125 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label']))
127 foreach ($extrafields->attributes[$elementtype][
'label'] as $key=>$label)
129 $type = $extrafields->attributes[$elementtype][
'type'][$key];
130 if ($type ==
'date' || $type ==
'datetime') {$type =
'xsd:dateTime'; }
131 else {$type =
'xsd:string'; }
133 $extrafield_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
136 if (is_array($extrafield_array)) $actioncomm_fields = array_merge($actioncomm_fields, $extrafield_array);
139 $server->wsdl->addComplexType(
149 $server->wsdl->addComplexType(
156 'code' => array(
'name'=>
'code',
'type'=>
'xsd:string'),
157 'libelle' => array(
'name'=>
'libelle',
'type'=>
'xsd:string')
161 $server->wsdl->addComplexType(
168 'actioncommtype' => array(
169 'name' =>
'actioncommtype',
170 'type' =>
'tns:actioncommtype',
172 'maxOccurs' =>
'unbounded'
182 $styleuse =
'encoded';
188 'getListActionCommType',
190 array(
'authentication'=>
'tns:authentication'),
192 array(
'result'=>
'tns:result',
'actioncommtypes'=>
'tns:actioncommtypes'),
194 $ns.
'#getListActionCommType',
197 'WS to get actioncommType'
204 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string'),
206 array(
'result'=>
'tns:result',
'actioncomm'=>
'tns:actioncomm'),
208 $ns.
'#getActionComm',
211 'WS to get actioncomm'
218 array(
'authentication'=>
'tns:authentication',
'actioncomm'=>
'tns:actioncomm'),
220 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
222 $ns.
'#createActionComm',
225 'WS to create a actioncomm'
232 array(
'authentication'=>
'tns:authentication',
'actioncomm'=>
'tns:actioncomm'),
234 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
236 $ns.
'#updateActionComm',
239 'WS to update a actioncomm'
254 global $db, $conf, $langs;
256 dol_syslog(
"Function: getActionComm login=".$authentication[
'login'].
" id=".$id);
258 if ($authentication[
'entity']) $conf->entity = $authentication[
'entity'];
261 $objectresp = array();
262 $errorcode =
''; $errorlabel =
'';
266 if ($error || (!$id))
269 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
276 if ($fuser->rights->agenda->allactions->read)
279 $result = $actioncomm->fetch($id);
282 $actioncomm_result_fields = array(
283 'id' => $actioncomm->id,
284 'ref'=> $actioncomm->ref,
285 'ref_ext'=> $actioncomm->ref_ext,
286 'type_id'=> $actioncomm->type_id,
287 'type_code'=> $actioncomm->type_code,
288 'type'=> $actioncomm->type,
289 'label'=> $actioncomm->label,
294 'note'=> $actioncomm->note_private,
295 'percentage'=> $actioncomm->percentage,
296 'author'=> $actioncomm->authorid,
297 'usermod'=> $actioncomm->usermodid,
298 'userownerid'=> $actioncomm->userownerid,
299 'priority'=> $actioncomm->priority,
300 'fulldayevent'=> $actioncomm->fulldayevent,
301 'location'=> $actioncomm->location,
302 'socid'=> $actioncomm->socid,
303 'contactid'=> $actioncomm->contact_id,
304 'projectid'=> $actioncomm->fk_project,
305 'fk_element'=> $actioncomm->fk_element,
306 'elementtype'=> $actioncomm->elementtype
309 $elementtype =
'actioncomm';
314 $extrafields->fetch_name_optionals_label($elementtype,
true);
316 $actioncomm->fetch_optionals();
318 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label']))
320 foreach ($extrafields->attributes[$elementtype][
'label'] as $key=>$label)
322 $actioncomm_result_fields = array_merge($actioncomm_result_fields, array(
'options_'.$key => $actioncomm->array_options[
'options_'.$key]));
328 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
329 'actioncomm'=>$actioncomm_result_fields);
333 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
338 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
344 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
359 global $db, $conf, $langs;
361 dol_syslog(
"Function: getListActionCommType login=".$authentication[
'login']);
363 if ($authentication[
'entity']) $conf->entity = $authentication[
'entity'];
366 $objectresp = array();
367 $errorcode =
''; $errorlabel =
'';
375 if ($fuser->rights->agenda->myactions->read)
378 $result = $cactioncomm->liste_array(
'',
'code');
381 $resultarray = array();
382 foreach ($cactioncomm->liste_array as $code=>$libeller) {
383 $resultarray[] = array(
'code'=>$code,
'libelle'=>$libeller);
387 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
388 'actioncommtypes'=>$resultarray);
391 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
395 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
401 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
417 global $db, $conf, $langs;
421 dol_syslog(
"Function: createActionComm login=".$authentication[
'login']);
423 if ($authentication[
'entity']) $conf->entity = $authentication[
'entity'];
426 $objectresp = array();
427 $errorcode =
''; $errorlabel =
'';
435 $newobject->datep = $actioncomm[
'datep'];
436 $newobject->datef = $actioncomm[
'datef'];
437 $newobject->type_code = $actioncomm[
'type_code'];
438 $newobject->socid = $actioncomm[
'socid'];
439 $newobject->fk_project = $actioncomm[
'projectid'];
440 $newobject->note = $actioncomm[
'note'];
441 $newobject->contact_id = $actioncomm[
'contactid'];
442 $newobject->userownerid = $actioncomm[
'userownerid'];
443 $newobject->label = $actioncomm[
'label'];
444 $newobject->percentage = $actioncomm[
'percentage'];
445 $newobject->priority = $actioncomm[
'priority'];
446 $newobject->fulldayevent = $actioncomm[
'fulldayevent'];
447 $newobject->location = $actioncomm[
'location'];
448 $newobject->fk_element = $actioncomm[
'fk_element'];
449 $newobject->elementtype = $actioncomm[
'elementtype'];
451 $elementtype =
'actioncomm';
456 $extrafields->fetch_name_optionals_label($elementtype,
true);
457 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label']))
459 foreach ($extrafields->attributes[$elementtype][
'label'] as $key=>$label)
461 $key =
'options_'.$key;
462 $newobject->array_options[$key] = $actioncomm[$key];
468 $result = $newobject->create($fuser);
477 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$newobject->id);
483 $errorlabel = $newobject->error;
489 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
504 global $db, $conf, $langs;
508 dol_syslog(
"Function: updateActionComm login=".$authentication[
'login']);
510 if ($authentication[
'entity']) $conf->entity = $authentication[
'entity'];
513 $objectresp = array();
514 $errorcode =
''; $errorlabel =
'';
518 if (empty($actioncomm[
'id'])) {
519 $error++; $errorcode =
'KO'; $errorlabel =
"Actioncomm id is mandatory.";
524 $objectfound =
false;
527 $result = $object->fetch($actioncomm[
'id']);
529 if (!empty($object->id)) {
532 $object->datep = $actioncomm[
'datep'];
533 $object->datef = $actioncomm[
'datef'];
534 $object->type_code = $actioncomm[
'type_code'];
535 $object->socid = $actioncomm[
'socid'];
536 $object->contact_id = $actioncomm[
'contactid'];
537 $object->fk_project = $actioncomm[
'projectid'];
538 $object->note = $actioncomm[
'note'];
539 $object->userownerid = $actioncomm[
'userownerid'];
540 $object->label = $actioncomm[
'label'];
541 $object->percentage = $actioncomm[
'percentage'];
542 $object->priority = $actioncomm[
'priority'];
543 $object->fulldayevent = $actioncomm[
'fulldayevent'];
544 $object->location = $actioncomm[
'location'];
545 $object->fk_element = $actioncomm[
'fk_element'];
546 $object->elementtype = $actioncomm[
'elementtype'];
548 $elementtype =
'actioncomm';
553 $extrafields->fetch_name_optionals_label($elementtype,
true);
554 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label']))
556 foreach ($extrafields->attributes[$elementtype][
'label'] as $key=>$label)
558 $key =
'options_'.$key;
559 $object->array_options[$key] = $actioncomm[$key];
565 $result = $object->update($fuser);
571 if ((!$error) && ($objectfound))
575 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
579 elseif ($objectfound)
584 $errorlabel = $object->error;
587 $errorcode =
'NOT_FOUND';
588 $errorlabel =
'Actioncomm id='.$actioncomm[
'id'].
' cannot be found';
594 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
601 $server->service(file_get_contents(
"php://input"));
Class to manage different types of events.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.
getListActionCommType($authentication)
Get getListActionCommType.
Class to manage agenda events (actions)
dol_now($mode= 'auto')
Return date for now.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
createActionComm($authentication, $actioncomm)
Create ActionComm.
getActionComm($authentication, $id)
Get ActionComm.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
updateActionComm($authentication, $actioncomm)
Create ActionComm.