26 if (!defined(
"NOCSRFCHECK")) {
27 define(
"NOCSRFCHECK",
'1');
30 require
"../master.inc.php";
31 require_once NUSOAP_PATH.
'/nusoap.php';
32 require_once DOL_DOCUMENT_ROOT.
"/core/lib/ws.lib.php";
34 require_once DOL_DOCUMENT_ROOT.
"/comm/action/class/actioncomm.class.php";
35 require_once DOL_DOCUMENT_ROOT.
"/comm/action/class/cactioncomm.class.php";
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
39 dol_syslog(
"Call ActionComm webservices interfaces");
42 if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) {
43 $langs->load(
"admin");
44 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
45 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
46 print $langs->trans(
"ToActivateModule");
51 $server =
new nusoap_server();
52 $server->soap_defencoding =
'UTF-8';
53 $server->decode_utf8 =
false;
54 $ns =
'http://www.dolibarr.org/ns/';
55 $server->configureWSDL(
'WebServicesDolibarrActionComm', $ns);
56 $server->wsdl->schemaTargetNamespace = $ns;
60 $server->wsdl->addComplexType(
67 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
68 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
69 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
70 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
71 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
76 $server->wsdl->addComplexType(
83 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
84 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
89 $actioncomm_fields = array(
90 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
91 'ref' => array(
'name'=>
'ref',
'type'=>
'xsd:string'),
92 'ref_ext' => array(
'name'=>
'ref_ext',
'type'=>
'xsd:string'),
93 'type_id' => array(
'name'=>
'type_id',
'type'=>
'xsd:string'),
94 'type_code' => array(
'name'=>
'type_code',
'type'=>
'xsd:string'),
95 'type' => array(
'name'=>
'type',
'type'=>
'xsd:string'),
96 'label' => array(
'name'=>
'label',
'type'=>
'xsd:string'),
97 'datep' => array(
'name'=>
'datep',
'type'=>
'xsd:dateTime'),
98 'datef' => array(
'name'=>
'datef',
'type'=>
'xsd:dateTime'),
99 'datec' => array(
'name'=>
'datec',
'type'=>
'xsd:dateTime'),
100 'datem' => array(
'name'=>
'datem',
'type'=>
'xsd:dateTime'),
101 'note' => array(
'name'=>
'note',
'type'=>
'xsd:string'),
102 'percentage' => array(
'name'=>
'percentage',
'type'=>
'xsd:string'),
103 'author' => array(
'name'=>
'author',
'type'=>
'xsd:string'),
104 'usermod' => array(
'name'=>
'usermod',
'type'=>
'xsd:string'),
105 'userownerid' => array(
'name'=>
'userownerid',
'type'=>
'xsd:string'),
106 'priority' => array(
'name'=>
'priority',
'type'=>
'xsd:string'),
107 'fulldayevent' => array(
'name'=>
'fulldayevent',
'type'=>
'xsd:string'),
108 'location' => array(
'name'=>
'location',
'type'=>
'xsd:string'),
109 'socid' => array(
'name'=>
'socid',
'type'=>
'xsd:string'),
110 'contactid' => array(
'name'=>
'contactid',
'type'=>
'xsd:string'),
111 'projectid' => array(
'name'=>
'projectid',
'type'=>
'xsd:string'),
112 'fk_element' => array(
'name'=>
'fk_element',
'type'=>
'xsd:string'),
113 'elementtype' => array(
'name'=>
'elementtype',
'type'=>
'xsd:string'));
116 $elementtype =
'actioncomm';
121 $extrafields->fetch_name_optionals_label($elementtype,
true);
122 $extrafield_array =
null;
123 if (is_array($extrafields) && count($extrafields) > 0) {
124 $extrafield_array = array();
126 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) {
128 $type = $extrafields->attributes[$elementtype][
'type'][$key];
129 if ($type ==
'date' || $type ==
'datetime') {
130 $type =
'xsd:dateTime';
132 $type =
'xsd:string';
135 $extrafield_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
138 if (is_array($extrafield_array)) {
139 $actioncomm_fields = array_merge($actioncomm_fields, $extrafield_array);
143 $server->wsdl->addComplexType(
153 $server->wsdl->addComplexType(
160 'code' => array(
'name'=>
'code',
'type'=>
'xsd:string'),
161 'libelle' => array(
'name'=>
'libelle',
'type'=>
'xsd:string')
165 $server->wsdl->addComplexType(
172 'actioncommtype' => array(
173 'name' =>
'actioncommtype',
174 'type' =>
'tns:actioncommtype',
176 'maxOccurs' =>
'unbounded'
186 $styleuse =
'encoded';
192 'getListActionCommType',
194 array(
'authentication'=>
'tns:authentication'),
196 array(
'result'=>
'tns:result',
'actioncommtypes'=>
'tns:actioncommtypes'),
198 $ns.
'#getListActionCommType',
201 'WS to get actioncommType'
208 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string'),
210 array(
'result'=>
'tns:result',
'actioncomm'=>
'tns:actioncomm'),
212 $ns.
'#getActionComm',
215 'WS to get actioncomm'
222 array(
'authentication'=>
'tns:authentication',
'actioncomm'=>
'tns:actioncomm'),
224 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
226 $ns.
'#createActionComm',
229 'WS to create a actioncomm'
236 array(
'authentication'=>
'tns:authentication',
'actioncomm'=>
'tns:actioncomm'),
238 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
240 $ns.
'#updateActionComm',
243 'WS to update a actioncomm'
258 global $db, $conf, $langs;
260 dol_syslog(
"Function: getActionComm login=".$authentication[
'login'].
" id=".$id);
262 if ($authentication[
'entity']) {
263 $conf->entity = $authentication[
'entity'];
267 $objectresp = array();
268 $errorcode =
''; $errorlabel =
'';
272 if ($error || (!$id)) {
274 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
280 if ($fuser->rights->agenda->allactions->read) {
282 $result = $actioncomm->fetch($id);
284 $actioncomm_result_fields = array(
285 'id' => $actioncomm->id,
286 'ref'=> $actioncomm->ref,
287 'ref_ext'=> $actioncomm->ref_ext,
288 'type_id'=> $actioncomm->type_id,
289 'type_code'=> $actioncomm->type_code,
290 'type'=> $actioncomm->type,
291 'label'=> $actioncomm->label,
296 'note'=> $actioncomm->note_private,
297 'percentage'=> $actioncomm->percentage,
298 'author'=> $actioncomm->authorid,
299 'usermod'=> $actioncomm->usermodid,
300 'userownerid'=> $actioncomm->userownerid,
301 'priority'=> $actioncomm->priority,
302 'fulldayevent'=> $actioncomm->fulldayevent,
303 'location'=> $actioncomm->location,
304 'socid'=> $actioncomm->socid,
305 'contactid'=> $actioncomm->contact_id,
306 'projectid'=> $actioncomm->fk_project,
307 'fk_element'=> $actioncomm->fk_element,
308 'elementtype'=> $actioncomm->elementtype
311 $elementtype =
'actioncomm';
316 $extrafields->fetch_name_optionals_label($elementtype,
true);
318 $actioncomm->fetch_optionals();
320 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
321 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);
332 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
336 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
341 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
356 global $db, $conf, $langs;
358 dol_syslog(
"Function: getListActionCommType login=".$authentication[
'login']);
360 if ($authentication[
'entity']) {
361 $conf->entity = $authentication[
'entity'];
365 $objectresp = array();
366 $errorcode =
''; $errorlabel =
'';
373 if ($fuser->rights->agenda->myactions->read) {
375 $result = $cactioncomm->liste_array(
'',
'code');
377 $resultarray = array();
378 foreach ($cactioncomm->liste_array as $code => $libeller) {
379 $resultarray[] = array(
'code'=>$code,
'libelle'=>$libeller);
383 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
384 'actioncommtypes'=>$resultarray);
387 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
391 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
396 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
412 global $db, $conf, $langs;
416 dol_syslog(
"Function: createActionComm login=".$authentication[
'login']);
418 if ($authentication[
'entity']) {
419 $conf->entity = $authentication[
'entity'];
423 $objectresp = array();
424 $errorcode =
''; $errorlabel =
'';
431 $newobject->datep = $actioncomm[
'datep'];
432 $newobject->datef = $actioncomm[
'datef'];
433 $newobject->type_code = $actioncomm[
'type_code'];
434 $newobject->socid = $actioncomm[
'socid'];
435 $newobject->fk_project = $actioncomm[
'projectid'];
436 $newobject->note = $actioncomm[
'note'];
437 $newobject->contact_id = $actioncomm[
'contactid'];
438 $newobject->userownerid = $actioncomm[
'userownerid'];
439 $newobject->label = $actioncomm[
'label'];
440 $newobject->percentage = $actioncomm[
'percentage'];
441 $newobject->priority = $actioncomm[
'priority'];
442 $newobject->fulldayevent = $actioncomm[
'fulldayevent'];
443 $newobject->location = $actioncomm[
'location'];
444 $newobject->fk_element = $actioncomm[
'fk_element'];
445 $newobject->elementtype = $actioncomm[
'elementtype'];
447 $elementtype =
'actioncomm';
452 $extrafields->fetch_name_optionals_label($elementtype,
true);
453 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
454 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
455 $key =
'options_'.$key;
456 $newobject->array_options[$key] = $actioncomm[$key];
462 $result = $newobject->create($fuser);
469 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$newobject->id);
474 $errorlabel = $newobject->error;
479 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
494 global $db, $conf, $langs;
498 dol_syslog(
"Function: updateActionComm login=".$authentication[
'login']);
500 if ($authentication[
'entity']) {
501 $conf->entity = $authentication[
'entity'];
505 $objectresp = array();
506 $errorcode =
''; $errorlabel =
'';
510 if (empty($actioncomm[
'id'])) {
511 $error++; $errorcode =
'KO'; $errorlabel =
"Actioncomm id is mandatory.";
515 $objectfound =
false;
518 $result = $object->fetch($actioncomm[
'id']);
520 if (!empty($object->id)) {
523 $object->datep = $actioncomm[
'datep'];
524 $object->datef = $actioncomm[
'datef'];
525 $object->type_code = $actioncomm[
'type_code'];
526 $object->socid = $actioncomm[
'socid'];
527 $object->contact_id = $actioncomm[
'contactid'];
528 $object->fk_project = $actioncomm[
'projectid'];
529 $object->note = $actioncomm[
'note'];
530 $object->userownerid = $actioncomm[
'userownerid'];
531 $object->label = $actioncomm[
'label'];
532 $object->percentage = $actioncomm[
'percentage'];
533 $object->priority = $actioncomm[
'priority'];
534 $object->fulldayevent = $actioncomm[
'fulldayevent'];
535 $object->location = $actioncomm[
'location'];
536 $object->fk_element = $actioncomm[
'fk_element'];
537 $object->elementtype = $actioncomm[
'elementtype'];
539 $elementtype =
'actioncomm';
544 $extrafields->fetch_name_optionals_label($elementtype,
true);
545 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
546 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
547 $key =
'options_'.$key;
548 $object->array_options[$key] = $actioncomm[$key];
554 $result = $object->update($fuser);
560 if ((!$error) && ($objectfound)) {
563 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
566 } elseif ($objectfound) {
570 $errorlabel = $object->error;
573 $errorcode =
'NOT_FOUND';
574 $errorlabel =
'Actioncomm id='.$actioncomm[
'id'].
' cannot be found';
579 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
586 $server->service(file_get_contents(
"php://input"));
Class to manage agenda events (actions)
Class to manage different types of events.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
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.