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';
59dol_syslog(
"Call ActionComm webservices interfaces");
63 $langs->load(
"admin");
64 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
65 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
66 print $langs->trans(
"ToActivateModule");
71$server =
new nusoap_server();
72$server->soap_defencoding =
'UTF-8';
73$server->decode_utf8 =
false;
74$ns =
'http://www.dolibarr.org/ns/';
75$server->configureWSDL(
'WebServicesDolibarrActionComm', $ns);
76$server->wsdl->schemaTargetNamespace = $ns;
80$server->wsdl->addComplexType(
87 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
88 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
89 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
90 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
91 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string'),
96$server->wsdl->addComplexType(
103 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
104 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
109$actioncomm_fields = array(
110 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
111 'ref' => array(
'name' =>
'ref',
'type' =>
'xsd:string'),
112 'ref_ext' => array(
'name' =>
'ref_ext',
'type' =>
'xsd:string'),
113 'type_id' => array(
'name' =>
'type_id',
'type' =>
'xsd:string'),
114 'type_code' => array(
'name' =>
'type_code',
'type' =>
'xsd:string'),
115 'type' => array(
'name' =>
'type',
'type' =>
'xsd:string'),
116 'label' => array(
'name' =>
'label',
'type' =>
'xsd:string'),
117 'datep' => array(
'name' =>
'datep',
'type' =>
'xsd:dateTime'),
118 'datef' => array(
'name' =>
'datef',
'type' =>
'xsd:dateTime'),
119 'datec' => array(
'name' =>
'datec',
'type' =>
'xsd:dateTime'),
120 'datem' => array(
'name' =>
'datem',
'type' =>
'xsd:dateTime'),
121 'note' => array(
'name' =>
'note',
'type' =>
'xsd:string'),
122 'percentage' => array(
'name' =>
'percentage',
'type' =>
'xsd:string'),
123 'author' => array(
'name' =>
'author',
'type' =>
'xsd:string'),
124 'usermod' => array(
'name' =>
'usermod',
'type' =>
'xsd:string'),
125 'userownerid' => array(
'name' =>
'userownerid',
'type' =>
'xsd:string'),
126 'priority' => array(
'name' =>
'priority',
'type' =>
'xsd:string'),
127 'fulldayevent' => array(
'name' =>
'fulldayevent',
'type' =>
'xsd:string'),
128 'location' => array(
'name' =>
'location',
'type' =>
'xsd:string'),
129 'socid' => array(
'name' =>
'socid',
'type' =>
'xsd:string'),
130 'contactid' => array(
'name' =>
'contactid',
'type' =>
'xsd:string'),
131 'projectid' => array(
'name' =>
'projectid',
'type' =>
'xsd:string'),
132 'fk_element' => array(
'name' =>
'fk_element',
'type' =>
'xsd:string'),
133 'elementtype' => array(
'name' =>
'elementtype',
'type' =>
'xsd:string'));
136$elementtype =
'actioncomm';
141$extrafields->fetch_name_optionals_label($elementtype,
true);
142$extrafield_array =
null;
143if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
144 $extrafield_array = array();
146if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
147 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
148 $type = $extrafields->attributes[$elementtype][
'type'][$key];
149 if ($type ==
'date' || $type ==
'datetime') {
150 $type =
'xsd:dateTime';
152 $type =
'xsd:string';
155 $extrafield_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
158if (is_array($extrafield_array)) {
159 $actioncomm_fields = array_merge($actioncomm_fields, $extrafield_array);
163$server->wsdl->addComplexType(
173$server->wsdl->addComplexType(
180 'code' => array(
'name' =>
'code',
'type' =>
'xsd:string'),
181 'libelle' => array(
'name' =>
'libelle',
'type' =>
'xsd:string')
185$server->wsdl->addComplexType(
192 'actioncommtype' => array(
193 'name' =>
'actioncommtype',
194 'type' =>
'tns:actioncommtype',
196 'maxOccurs' =>
'unbounded'
206$styleuse =
'encoded';
212 'getListActionCommType',
214 array(
'authentication' =>
'tns:authentication'),
216 array(
'result' =>
'tns:result',
'actioncommtypes' =>
'tns:actioncommtypes'),
218 $ns.
'#getListActionCommType',
221 'WS to get actioncommType'
228 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string'),
230 array(
'result' =>
'tns:result',
'actioncomm' =>
'tns:actioncomm'),
232 $ns.
'#getActionComm',
235 'WS to get actioncomm'
242 array(
'authentication' =>
'tns:authentication',
'actioncomm' =>
'tns:actioncomm'),
244 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
246 $ns.
'#createActionComm',
249 'WS to create a actioncomm'
256 array(
'authentication' =>
'tns:authentication',
'actioncomm' =>
'tns:actioncomm'),
258 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
260 $ns.
'#updateActionComm',
263 'WS to update a actioncomm'
278 global $db, $conf, $langs;
280 dol_syslog(
"Function: getActionComm login=".$authentication[
'login'].
" id=".
$id);
282 if ($authentication[
'entity']) {
283 $conf->entity = $authentication[
'entity'];
287 $objectresp = array();
293 if ($error || (!
$id)) {
295 $errorcode =
'BAD_PARAMETERS';
296 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
300 $fuser->loadRights();
302 if ($fuser->hasRight(
'agenda',
'allactions',
'read')) {
304 $result = $actioncomm->fetch(
$id);
306 $actioncomm_result_fields = array(
307 'id' => $actioncomm->id,
308 'ref' => $actioncomm->ref,
309 'ref_ext' => $actioncomm->ref_ext,
310 'type_id' => $actioncomm->type_id,
311 'type_code' => $actioncomm->type_code,
312 'type' => $actioncomm->type,
313 'label' => $actioncomm->label,
318 'note' => $actioncomm->note_private,
319 'percentage' => $actioncomm->percentage,
320 'author' => $actioncomm->authorid,
321 'usermod' => $actioncomm->usermodid,
322 'userownerid' => $actioncomm->userownerid,
323 'priority' => $actioncomm->priority,
324 'fulldayevent' => $actioncomm->fulldayevent,
325 'location' => $actioncomm->location,
326 'socid' => $actioncomm->socid,
327 'contactid' => $actioncomm->contact_id,
328 'projectid' => $actioncomm->fk_project,
329 'fk_element' => $actioncomm->fk_element,
330 'elementtype' => $actioncomm->elementtype
333 $elementtype =
'actioncomm';
338 $extrafields->fetch_name_optionals_label($elementtype,
true);
340 $actioncomm->fetch_optionals();
342 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
343 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
344 $actioncomm_result_fields = array_merge($actioncomm_result_fields, array(
'options_'.$key => $actioncomm->array_options[
'options_'.$key]));
350 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
351 'actioncomm' => $actioncomm_result_fields);
354 $errorcode =
'NOT_FOUND';
355 $errorlabel =
'Object not found for id='.$id;
359 $errorcode =
'PERMISSION_DENIED';
360 $errorlabel =
'User does not have permission for this request';
365 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
380 global $db, $conf, $langs;
382 dol_syslog(
"Function: getListActionCommType login=".$authentication[
'login']);
384 if ($authentication[
'entity']) {
385 $conf->entity = $authentication[
'entity'];
389 $objectresp = array();
396 $fuser->loadRights();
398 if ($fuser->hasRight(
'agenda',
'myactions',
'read')) {
400 $result = $cactioncomm->liste_array(
'',
'code');
402 $resultarray = array();
403 foreach ($cactioncomm->liste_array as $code => $libeller) {
404 $resultarray[] = array(
'code' => $code,
'libelle' => $libeller);
408 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
409 'actioncommtypes' => $resultarray);
412 $errorcode =
'NOT_FOUND';
413 $errorlabel =
'Failed to execute liste_array';
417 $errorcode =
'PERMISSION_DENIED';
418 $errorlabel =
'User does not have permission for this request';
423 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
443 dol_syslog(
"Function: createActionComm login=".$authentication[
'login']);
445 if ($authentication[
'entity']) {
446 $conf->entity = $authentication[
'entity'];
450 $objectresp = array();
459 $newobject->datep = $actioncomm[
'datep'];
460 $newobject->datef = $actioncomm[
'datef'];
461 $newobject->type_code = $actioncomm[
'type_code'];
462 $newobject->socid = $actioncomm[
'socid'];
463 $newobject->fk_project = $actioncomm[
'projectid'];
464 $newobject->note = $actioncomm[
'note'];
465 $newobject->note_private = $actioncomm[
'note'];
466 $newobject->contact_id = $actioncomm[
'contactid'];
467 $newobject->userownerid = $actioncomm[
'userownerid'];
468 $newobject->label = $actioncomm[
'label'];
469 $newobject->percentage = $actioncomm[
'percentage'];
470 $newobject->priority = $actioncomm[
'priority'];
471 $newobject->fulldayevent = $actioncomm[
'fulldayevent'];
472 $newobject->location = $actioncomm[
'location'];
473 $newobject->fk_element = $actioncomm[
'fk_element'];
474 $newobject->elementtype = $actioncomm[
'elementtype'];
476 $elementtype =
'actioncomm';
481 $extrafields->fetch_name_optionals_label($elementtype,
true);
482 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
483 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
484 $key =
'options_'.$key;
485 $newobject->array_options[$key] = $actioncomm[$key];
491 $result = $newobject->create($fuser);
498 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id);
503 $errorlabel = $newobject->error;
508 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
527 dol_syslog(
"Function: updateActionComm login=".$authentication[
'login']);
529 if ($authentication[
'entity']) {
530 $conf->entity = $authentication[
'entity'];
534 $objectresp = array();
540 if (empty($actioncomm[
'id'])) {
543 $errorlabel =
"Actioncomm id is mandatory.";
547 $objectfound =
false;
550 $result =
$object->fetch($actioncomm[
'id']);
555 $object->datep = $actioncomm[
'datep'];
556 $object->datef = $actioncomm[
'datef'];
557 $object->type_code = $actioncomm[
'type_code'];
558 $object->socid = $actioncomm[
'socid'];
559 $object->contact_id = $actioncomm[
'contactid'];
560 $object->fk_project = $actioncomm[
'projectid'];
561 $object->note = $actioncomm[
'note'];
562 $object->userownerid = $actioncomm[
'userownerid'];
563 $object->label = $actioncomm[
'label'];
564 $object->percentage = $actioncomm[
'percentage'];
565 $object->priority = $actioncomm[
'priority'];
566 $object->fulldayevent = $actioncomm[
'fulldayevent'];
567 $object->location = $actioncomm[
'location'];
568 $object->fk_element = $actioncomm[
'fk_element'];
569 $object->elementtype = $actioncomm[
'elementtype'];
571 $elementtype =
'actioncomm';
576 $extrafields->fetch_name_optionals_label($elementtype,
true);
577 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
578 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
579 $key =
'options_'.$key;
580 $object->array_options[$key] = $actioncomm[$key];
586 $result =
$object->update($fuser);
591 '@phan-var-force array{id:string} $actioncomm';
593 if ((!$error) && ($objectfound)) {
596 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
599 } elseif ($objectfound) {
606 $errorcode =
'NOT_FOUND';
607 $errorlabel =
'Actioncomm id='.$actioncomm[
'id'].
' cannot be found';
612 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
619$server->service(file_get_contents(
"php://input"));
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage agenda events (actions)
Class to manage different types of events.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
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.