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);
79$server->wsdl->schemaTargetNamespace = $ns;
83$server->wsdl->addComplexType(
90 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
91 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
92 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
93 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
94 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string'),
99$server->wsdl->addComplexType(
106 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
107 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
112$actioncomm_fields = array(
113 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
114 'ref' => array(
'name' =>
'ref',
'type' =>
'xsd:string'),
115 'ref_ext' => array(
'name' =>
'ref_ext',
'type' =>
'xsd:string'),
116 'type_id' => array(
'name' =>
'type_id',
'type' =>
'xsd:string'),
117 'type_code' => array(
'name' =>
'type_code',
'type' =>
'xsd:string'),
118 'type' => array(
'name' =>
'type',
'type' =>
'xsd:string'),
119 'label' => array(
'name' =>
'label',
'type' =>
'xsd:string'),
120 'datep' => array(
'name' =>
'datep',
'type' =>
'xsd:dateTime'),
121 'datef' => array(
'name' =>
'datef',
'type' =>
'xsd:dateTime'),
122 'datec' => array(
'name' =>
'datec',
'type' =>
'xsd:dateTime'),
123 'datem' => array(
'name' =>
'datem',
'type' =>
'xsd:dateTime'),
124 'note' => array(
'name' =>
'note',
'type' =>
'xsd:string'),
125 'percentage' => array(
'name' =>
'percentage',
'type' =>
'xsd:string'),
126 'author' => array(
'name' =>
'author',
'type' =>
'xsd:string'),
127 'usermod' => array(
'name' =>
'usermod',
'type' =>
'xsd:string'),
128 'userownerid' => array(
'name' =>
'userownerid',
'type' =>
'xsd:string'),
129 'priority' => array(
'name' =>
'priority',
'type' =>
'xsd:string'),
130 'fulldayevent' => array(
'name' =>
'fulldayevent',
'type' =>
'xsd:string'),
131 'location' => array(
'name' =>
'location',
'type' =>
'xsd:string'),
132 'socid' => array(
'name' =>
'socid',
'type' =>
'xsd:string'),
133 'contactid' => array(
'name' =>
'contactid',
'type' =>
'xsd:string'),
134 'projectid' => array(
'name' =>
'projectid',
'type' =>
'xsd:string'),
135 'fk_element' => array(
'name' =>
'fk_element',
'type' =>
'xsd:string'),
136 'elementtype' => array(
'name' =>
'elementtype',
'type' =>
'xsd:string'));
138$elementtype =
'actioncomm';
143$extrafields->fetch_name_optionals_label($elementtype,
true);
144$extrafield_array =
null;
145if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
146 $extrafield_array = array();
148if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
149 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
150 $type = $extrafields->attributes[$elementtype][
'type'][$key];
151 if ($type ==
'date' || $type ==
'datetime') {
152 $type =
'xsd:dateTime';
154 $type =
'xsd:string';
157 $extrafield_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
160if (is_array($extrafield_array)) {
161 $actioncomm_fields = array_merge($actioncomm_fields, $extrafield_array);
165$server->wsdl->addComplexType(
175$server->wsdl->addComplexType(
182 'code' => array(
'name' =>
'code',
'type' =>
'xsd:string'),
183 'libelle' => array(
'name' =>
'libelle',
'type' =>
'xsd:string')
187$server->wsdl->addComplexType(
194 'actioncommtype' => array(
195 'name' =>
'actioncommtype',
196 'type' =>
'tns:actioncommtype',
198 'maxOccurs' =>
'unbounded'
208$styleuse =
'encoded';
214 'getListActionCommType',
216 array(
'authentication' =>
'tns:authentication'),
218 array(
'result' =>
'tns:result',
'actioncommtypes' =>
'tns:actioncommtypes'),
220 $ns.
'#getListActionCommType',
223 'WS to get actioncommType'
230 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string'),
232 array(
'result' =>
'tns:result',
'actioncomm' =>
'tns:actioncomm'),
234 $ns.
'#getActionComm',
237 'WS to get actioncomm'
244 array(
'authentication' =>
'tns:authentication',
'actioncomm' =>
'tns:actioncomm'),
246 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
248 $ns.
'#createActionComm',
251 'WS to create a actioncomm'
258 array(
'authentication' =>
'tns:authentication',
'actioncomm' =>
'tns:actioncomm'),
260 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
262 $ns.
'#updateActionComm',
265 'WS to update a actioncomm'
280 global $db,
$conf, $langs;
282 dol_syslog(
"Function: getActionComm login=".$authentication[
'login'].
" id=".
$id);
284 if ($authentication[
'entity']) {
285 $conf->entity = $authentication[
'entity'];
289 $objectresp = array();
295 if ($error || (!
$id)) {
297 $errorcode =
'BAD_PARAMETERS';
298 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
302 $fuser->loadRights();
304 if ($fuser->hasRight(
'agenda',
'allactions',
'read')) {
306 $result = $actioncomm->fetch(
$id);
308 $actioncomm_result_fields = array(
309 'id' => $actioncomm->id,
310 'ref' => $actioncomm->ref,
311 'ref_ext' => $actioncomm->ref_ext,
312 'type_id' => $actioncomm->type_id,
313 'type_code' => $actioncomm->type_code,
314 'type' => $actioncomm->type,
315 'label' => $actioncomm->label,
320 'note' => $actioncomm->note_private,
321 'percentage' => $actioncomm->percentage,
322 'author' => $actioncomm->authorid,
323 'usermod' => $actioncomm->usermodid,
324 'userownerid' => $actioncomm->userownerid,
325 'priority' => $actioncomm->priority,
326 'fulldayevent' => $actioncomm->fulldayevent,
327 'location' => $actioncomm->location,
328 'socid' => $actioncomm->socid,
329 'contactid' => $actioncomm->contact_id,
330 'projectid' => $actioncomm->fk_project,
331 'fk_element' => $actioncomm->fk_element,
332 'elementtype' => $actioncomm->elementtype
335 $elementtype =
'actioncomm';
340 $extrafields->fetch_name_optionals_label($elementtype,
true);
342 $actioncomm->fetch_optionals();
344 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
345 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
346 $actioncomm_result_fields = array_merge($actioncomm_result_fields, array(
'options_'.$key => $actioncomm->array_options[
'options_'.$key]));
352 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
353 'actioncomm' => $actioncomm_result_fields);
356 $errorcode =
'NOT_FOUND';
357 $errorlabel =
'Object not found for id='.$id;
361 $errorcode =
'PERMISSION_DENIED';
362 $errorlabel =
'User does not have permission for this request';
367 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
382 global $db,
$conf, $langs;
384 dol_syslog(
"Function: getListActionCommType login=".$authentication[
'login']);
386 if ($authentication[
'entity']) {
387 $conf->entity = $authentication[
'entity'];
391 $objectresp = array();
398 $fuser->loadRights();
400 if ($fuser->hasRight(
'agenda',
'myactions',
'read')) {
402 $result = $cactioncomm->liste_array(
'',
'code');
404 $resultarray = array();
405 foreach ($cactioncomm->liste_array as $code => $libeller) {
406 $resultarray[] = array(
'code' => $code,
'libelle' => $libeller);
410 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
411 'actioncommtypes' => $resultarray);
414 $errorcode =
'NOT_FOUND';
415 $errorlabel =
'Failed to execute liste_array';
419 $errorcode =
'PERMISSION_DENIED';
420 $errorlabel =
'User does not have permission for this request';
425 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
445 dol_syslog(
"Function: createActionComm login=".$authentication[
'login']);
447 if ($authentication[
'entity']) {
448 $conf->entity = $authentication[
'entity'];
452 $objectresp = array();
461 $newobject->datep = $actioncomm[
'datep'];
462 $newobject->datef = $actioncomm[
'datef'];
463 $newobject->type_code = $actioncomm[
'type_code'];
464 $newobject->socid = (int) $actioncomm[
'socid'];
465 $newobject->fk_project = (int) $actioncomm[
'projectid'];
466 $newobject->note = $actioncomm[
'note'];
467 $newobject->note_private = $actioncomm[
'note'];
468 $newobject->contact_id = (int) $actioncomm[
'contactid'];
469 $newobject->userownerid = (int) $actioncomm[
'userownerid'];
470 $newobject->label = $actioncomm[
'label'];
471 $newobject->percentage = (int) $actioncomm[
'percentage'];
472 $newobject->priority = (int) $actioncomm[
'priority'];
473 $newobject->fulldayevent = (int) $actioncomm[
'fulldayevent'];
474 $newobject->location = $actioncomm[
'location'];
475 $newobject->fk_element = (int) $actioncomm[
'fk_element'];
476 $newobject->elementtype = $actioncomm[
'elementtype'];
478 $elementtype =
'actioncomm';
483 $extrafields->fetch_name_optionals_label($elementtype,
true);
484 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
485 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
486 $key =
'options_'.$key;
487 $newobject->array_options[$key] = $actioncomm[$key];
493 $result = $newobject->create($fuser);
500 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id);
505 $errorlabel = $newobject->error;
510 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
529 dol_syslog(
"Function: updateActionComm login=".$authentication[
'login']);
531 if ($authentication[
'entity']) {
532 $conf->entity = $authentication[
'entity'];
536 $objectresp = array();
542 if (empty($actioncomm[
'id'])) {
545 $errorlabel =
"Actioncomm id is mandatory.";
549 $objectfound =
false;
552 $result =
$object->fetch($actioncomm[
'id']);
557 $object->datep = $actioncomm[
'datep'];
558 $object->datef = $actioncomm[
'datef'];
559 $object->type_code = $actioncomm[
'type_code'];
560 $object->socid = (int) $actioncomm[
'socid'];
561 $object->contact_id = (int) $actioncomm[
'contactid'];
562 $object->fk_project = (int) $actioncomm[
'projectid'];
563 $object->note = $actioncomm[
'note'];
564 $object->userownerid = (int) $actioncomm[
'userownerid'];
565 $object->label = $actioncomm[
'label'];
566 $object->percentage = (int) $actioncomm[
'percentage'];
567 $object->priority = (int) $actioncomm[
'priority'];
568 $object->fulldayevent = (int) $actioncomm[
'fulldayevent'];
569 $object->location = $actioncomm[
'location'];
570 $object->fk_element = (int) $actioncomm[
'fk_element'];
571 $object->elementtype = $actioncomm[
'elementtype'];
573 $elementtype =
'actioncomm';
578 $extrafields->fetch_name_optionals_label($elementtype,
true);
579 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
580 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
581 $key =
'options_'.$key;
582 $object->array_options[$key] = $actioncomm[$key];
588 $result =
$object->update($fuser);
593 '@phan-var-force array{id:string} $actioncomm';
595 if ((!$error) && ($objectfound)) {
598 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
601 } elseif ($objectfound) {
608 $errorcode =
'NOT_FOUND';
609 $errorlabel =
'Actioncomm id='.$actioncomm[
'id'].
' cannot be found';
614 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
621$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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.