28if (!defined(
'NOCSRFCHECK')) {
29 define(
'NOCSRFCHECK',
'1');
31if (!defined(
'NOTOKENRENEWAL')) {
32 define(
'NOTOKENRENEWAL',
'1');
34if (!defined(
'NOREQUIREMENU')) {
35 define(
'NOREQUIREMENU',
'1');
37if (!defined(
'NOREQUIREHTML')) {
38 define(
'NOREQUIREHTML',
'1');
40if (!defined(
'NOREQUIREAJAX')) {
41 define(
'NOREQUIREAJAX',
'1');
43if (!defined(
"NOLOGIN")) {
44 define(
"NOLOGIN",
'1');
46if (!defined(
"NOSESSION")) {
47 define(
"NOSESSION",
'1');
50require
'../main.inc.php';
51require_once NUSOAP_PATH.
'/nusoap.php';
52require_once DOL_DOCUMENT_ROOT.
"/core/lib/ws.lib.php";
54require_once DOL_DOCUMENT_ROOT.
"/comm/action/class/actioncomm.class.php";
55require_once DOL_DOCUMENT_ROOT.
"/comm/action/class/cactioncomm.class.php";
56require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
62dol_syslog(
"Call ActionComm webservices interfaces");
66 $langs->load(
"admin");
67 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
68 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
69 print $langs->trans(
"ToActivateModule");
74$server =
new nusoap_server();
75$server->soap_defencoding =
'UTF-8';
76$server->decode_utf8 =
false;
77$ns =
'http://www.dolibarr.org/ns/';
78$server->configureWSDL(
'WebServicesDolibarrActionComm', $ns);
80$server->wsdl->schemaTargetNamespace = $ns;
84$server->wsdl->addComplexType(
91 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
92 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
93 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
94 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
95 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string'),
100$server->wsdl->addComplexType(
107 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
108 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
113$actioncomm_fields = array(
114 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
115 'ref' => array(
'name' =>
'ref',
'type' =>
'xsd:string'),
116 'ref_ext' => array(
'name' =>
'ref_ext',
'type' =>
'xsd:string'),
117 'type_id' => array(
'name' =>
'type_id',
'type' =>
'xsd:string'),
118 'type_code' => array(
'name' =>
'type_code',
'type' =>
'xsd:string'),
119 'type' => array(
'name' =>
'type',
'type' =>
'xsd:string'),
120 'label' => array(
'name' =>
'label',
'type' =>
'xsd:string'),
121 'datep' => array(
'name' =>
'datep',
'type' =>
'xsd:dateTime'),
122 'datef' => array(
'name' =>
'datef',
'type' =>
'xsd:dateTime'),
123 'datec' => array(
'name' =>
'datec',
'type' =>
'xsd:dateTime'),
124 'datem' => array(
'name' =>
'datem',
'type' =>
'xsd:dateTime'),
125 'note' => array(
'name' =>
'note',
'type' =>
'xsd:string'),
126 'percentage' => array(
'name' =>
'percentage',
'type' =>
'xsd:string'),
127 'author' => array(
'name' =>
'author',
'type' =>
'xsd:string'),
128 'usermod' => array(
'name' =>
'usermod',
'type' =>
'xsd:string'),
129 'userownerid' => array(
'name' =>
'userownerid',
'type' =>
'xsd:string'),
130 'priority' => array(
'name' =>
'priority',
'type' =>
'xsd:string'),
131 'fulldayevent' => array(
'name' =>
'fulldayevent',
'type' =>
'xsd:string'),
132 'location' => array(
'name' =>
'location',
'type' =>
'xsd:string'),
133 'socid' => array(
'name' =>
'socid',
'type' =>
'xsd:string'),
134 'contactid' => array(
'name' =>
'contactid',
'type' =>
'xsd:string'),
135 'projectid' => array(
'name' =>
'projectid',
'type' =>
'xsd:string'),
136 'fk_element' => array(
'name' =>
'fk_element',
'type' =>
'xsd:string'),
137 'elementtype' => array(
'name' =>
'elementtype',
'type' =>
'xsd:string'));
139$elementtype =
'actioncomm';
144$extrafields->fetch_name_optionals_label($elementtype,
true);
145$extrafield_array =
null;
146if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
147 $extrafield_array = array();
149if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
150 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
151 $type = $extrafields->attributes[$elementtype][
'type'][$key];
152 if ($type ==
'date' || $type ==
'datetime') {
153 $type =
'xsd:dateTime';
155 $type =
'xsd:string';
158 $extrafield_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
161if (is_array($extrafield_array)) {
162 $actioncomm_fields = array_merge($actioncomm_fields, $extrafield_array);
166$server->wsdl->addComplexType(
176$server->wsdl->addComplexType(
183 'code' => array(
'name' =>
'code',
'type' =>
'xsd:string'),
184 'libelle' => array(
'name' =>
'libelle',
'type' =>
'xsd:string')
188$server->wsdl->addComplexType(
195 'actioncommtype' => array(
196 'name' =>
'actioncommtype',
197 'type' =>
'tns:actioncommtype',
199 'maxOccurs' =>
'unbounded'
209$styleuse =
'encoded';
215 'getListActionCommType',
217 array(
'authentication' =>
'tns:authentication'),
219 array(
'result' =>
'tns:result',
'actioncommtypes' =>
'tns:actioncommtypes'),
221 $ns.
'#getListActionCommType',
224 'WS to get actioncommType'
231 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string'),
233 array(
'result' =>
'tns:result',
'actioncomm' =>
'tns:actioncomm'),
235 $ns.
'#getActionComm',
238 'WS to get actioncomm'
245 array(
'authentication' =>
'tns:authentication',
'actioncomm' =>
'tns:actioncomm'),
247 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
249 $ns.
'#createActionComm',
252 'WS to create a actioncomm'
259 array(
'authentication' =>
'tns:authentication',
'actioncomm' =>
'tns:actioncomm'),
261 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
263 $ns.
'#updateActionComm',
266 'WS to update a actioncomm'
281 global $db, $conf, $langs;
283 dol_syslog(
"Function: getActionComm login=".$authentication[
'login'].
" id=".
$id);
285 if ($authentication[
'entity']) {
286 $conf->entity = $authentication[
'entity'];
290 $objectresp = array();
296 if ($error || (!
$id)) {
298 $errorcode =
'BAD_PARAMETERS';
299 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
303 $fuser->loadRights();
305 if ($fuser->hasRight(
'agenda',
'allactions',
'read')) {
307 $result = $actioncomm->fetch(
$id);
309 $actioncomm_result_fields = array(
310 'id' => $actioncomm->id,
311 'ref' => $actioncomm->ref,
312 'ref_ext' => $actioncomm->ref_ext,
313 'type_id' => $actioncomm->type_id,
314 'type_code' => $actioncomm->type_code,
315 'type' => $actioncomm->type,
316 'label' => $actioncomm->label,
321 'note' => $actioncomm->note_private,
322 'percentage' => $actioncomm->percentage,
323 'author' => $actioncomm->authorid,
324 'usermod' => $actioncomm->usermodid,
325 'userownerid' => $actioncomm->userownerid,
326 'priority' => $actioncomm->priority,
327 'fulldayevent' => $actioncomm->fulldayevent,
328 'location' => $actioncomm->location,
329 'socid' => $actioncomm->socid,
330 'contactid' => $actioncomm->contact_id,
331 'projectid' => $actioncomm->fk_project,
332 'fk_element' => $actioncomm->fk_element,
333 'elementtype' => $actioncomm->elementtype
336 $elementtype =
'actioncomm';
341 $extrafields->fetch_name_optionals_label($elementtype,
true);
343 $actioncomm->fetch_optionals();
345 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
346 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
347 $actioncomm_result_fields = array_merge($actioncomm_result_fields, array(
'options_'.$key => $actioncomm->array_options[
'options_'.$key]));
353 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
354 'actioncomm' => $actioncomm_result_fields);
357 $errorcode =
'NOT_FOUND';
358 $errorlabel =
'Object not found for id='.$id;
362 $errorcode =
'PERMISSION_DENIED';
363 $errorlabel =
'User does not have permission for this request';
368 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
383 global $db, $conf, $langs;
385 dol_syslog(
"Function: getListActionCommType login=".$authentication[
'login']);
387 if ($authentication[
'entity']) {
388 $conf->entity = $authentication[
'entity'];
392 $objectresp = array();
399 $fuser->loadRights();
401 if ($fuser->hasRight(
'agenda',
'myactions',
'read')) {
403 $result = $cactioncomm->liste_array(
'',
'code');
405 $resultarray = array();
406 foreach ($cactioncomm->liste_array as $code => $libeller) {
407 $resultarray[] = array(
'code' => $code,
'libelle' => $libeller);
411 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
412 'actioncommtypes' => $resultarray);
415 $errorcode =
'NOT_FOUND';
416 $errorlabel =
'Failed to execute liste_array';
420 $errorcode =
'PERMISSION_DENIED';
421 $errorlabel =
'User does not have permission for this request';
426 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
446 dol_syslog(
"Function: createActionComm login=".$authentication[
'login']);
448 if ($authentication[
'entity']) {
449 $conf->entity = $authentication[
'entity'];
453 $objectresp = array();
462 $newobject->datep = $actioncomm[
'datep'];
463 $newobject->datef = $actioncomm[
'datef'];
464 $newobject->type_code = $actioncomm[
'type_code'];
465 $newobject->socid = (int) $actioncomm[
'socid'];
466 $newobject->fk_project = (int) $actioncomm[
'projectid'];
467 $newobject->note = $actioncomm[
'note'];
468 $newobject->note_private = $actioncomm[
'note'];
469 $newobject->contact_id = (int) $actioncomm[
'contactid'];
470 $newobject->userownerid = (int) $actioncomm[
'userownerid'];
471 $newobject->label = $actioncomm[
'label'];
472 $newobject->percentage = (int) $actioncomm[
'percentage'];
473 $newobject->priority = (int) $actioncomm[
'priority'];
474 $newobject->fulldayevent = (int) $actioncomm[
'fulldayevent'];
475 $newobject->location = $actioncomm[
'location'];
476 $newobject->fk_element = (int) $actioncomm[
'fk_element'];
477 $newobject->elementtype = $actioncomm[
'elementtype'];
479 $elementtype =
'actioncomm';
484 $extrafields->fetch_name_optionals_label($elementtype,
true);
485 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
486 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
487 $key =
'options_'.$key;
488 $newobject->array_options[$key] = $actioncomm[$key];
494 $result = $newobject->create($fuser);
501 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id);
506 $errorlabel = $newobject->error;
511 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
530 dol_syslog(
"Function: updateActionComm login=".$authentication[
'login']);
532 if ($authentication[
'entity']) {
533 $conf->entity = $authentication[
'entity'];
537 $objectresp = array();
543 if (empty($actioncomm[
'id'])) {
546 $errorlabel =
"Actioncomm id is mandatory.";
550 $objectfound =
false;
553 $result =
$object->fetch((
int) $actioncomm[
'id']);
558 $object->datep = $actioncomm[
'datep'];
559 $object->datef = $actioncomm[
'datef'];
560 $object->type_code = $actioncomm[
'type_code'];
561 $object->socid = (int) $actioncomm[
'socid'];
562 $object->contact_id = (int) $actioncomm[
'contactid'];
563 $object->fk_project = (int) $actioncomm[
'projectid'];
564 $object->note = $actioncomm[
'note'];
565 $object->userownerid = (int) $actioncomm[
'userownerid'];
566 $object->label = $actioncomm[
'label'];
567 $object->percentage = (int) $actioncomm[
'percentage'];
568 $object->priority = (int) $actioncomm[
'priority'];
569 $object->fulldayevent = (int) $actioncomm[
'fulldayevent'];
570 $object->location = $actioncomm[
'location'];
571 $object->fk_element = (int) $actioncomm[
'fk_element'];
572 $object->elementtype = $actioncomm[
'elementtype'];
574 $elementtype =
'actioncomm';
579 $extrafields->fetch_name_optionals_label($elementtype,
true);
580 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
581 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
582 $key =
'options_'.$key;
583 $object->array_options[$key] = $actioncomm[$key];
589 $result =
$object->update($fuser);
594 '@phan-var-force array{id:string} $actioncomm';
596 if ((!$error) && ($objectfound)) {
599 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
602 } elseif ($objectfound) {
609 $errorcode =
'NOT_FOUND';
610 $errorlabel =
'Actioncomm id='.$actioncomm[
'id'].
' cannot be found';
615 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
622$server->service(file_get_contents(
"php://input"));
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
Class to manage agenda events (actions)
Class to manage different types of events.
dol_now($mode='gmt')
Return date for now.
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.
createActionComm($authentication, $actioncomm)
Create ActionComm.
getListActionCommType($authentication)
Get getListActionCommType.
getActionComm($authentication, $id)
Get ActionComm.
updateActionComm($authentication, $actioncomm)
Create ActionComm.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.