26if (!defined(
'NOCSRFCHECK')) {
27 define(
'NOCSRFCHECK',
'1');
29if (!defined(
'NOTOKENRENEWAL')) {
30 define(
'NOTOKENRENEWAL',
'1');
32if (!defined(
'NOREQUIREMENU')) {
33 define(
'NOREQUIREMENU',
'1');
35if (!defined(
'NOREQUIREHTML')) {
36 define(
'NOREQUIREHTML',
'1');
38if (!defined(
'NOREQUIREAJAX')) {
39 define(
'NOREQUIREAJAX',
'1');
41if (!defined(
"NOLOGIN")) {
42 define(
"NOLOGIN",
'1');
44if (!defined(
"NOSESSION")) {
45 define(
"NOSESSION",
'1');
48require
'../main.inc.php';
49require_once NUSOAP_PATH.
'/nusoap.php';
50require_once DOL_DOCUMENT_ROOT.
"/core/lib/ws.lib.php";
52require_once DOL_DOCUMENT_ROOT.
"/comm/action/class/actioncomm.class.php";
53require_once DOL_DOCUMENT_ROOT.
"/comm/action/class/cactioncomm.class.php";
54require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
57dol_syslog(
"Call ActionComm webservices interfaces");
60if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) {
61 $langs->load(
"admin");
62 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
63 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
64 print $langs->trans(
"ToActivateModule");
69$server =
new nusoap_server();
70$server->soap_defencoding =
'UTF-8';
71$server->decode_utf8 =
false;
72$ns =
'http://www.dolibarr.org/ns/';
73$server->configureWSDL(
'WebServicesDolibarrActionComm', $ns);
74$server->wsdl->schemaTargetNamespace = $ns;
78$server->wsdl->addComplexType(
85 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
86 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
87 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
88 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
89 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
94$server->wsdl->addComplexType(
101 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
102 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
107$actioncomm_fields = array(
108 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
109 'ref' => array(
'name'=>
'ref',
'type'=>
'xsd:string'),
110 'ref_ext' => array(
'name'=>
'ref_ext',
'type'=>
'xsd:string'),
111 'type_id' => array(
'name'=>
'type_id',
'type'=>
'xsd:string'),
112 'type_code' => array(
'name'=>
'type_code',
'type'=>
'xsd:string'),
113 'type' => array(
'name'=>
'type',
'type'=>
'xsd:string'),
114 'label' => array(
'name'=>
'label',
'type'=>
'xsd:string'),
115 'datep' => array(
'name'=>
'datep',
'type'=>
'xsd:dateTime'),
116 'datef' => array(
'name'=>
'datef',
'type'=>
'xsd:dateTime'),
117 'datec' => array(
'name'=>
'datec',
'type'=>
'xsd:dateTime'),
118 'datem' => array(
'name'=>
'datem',
'type'=>
'xsd:dateTime'),
119 'note' => array(
'name'=>
'note',
'type'=>
'xsd:string'),
120 'percentage' => array(
'name'=>
'percentage',
'type'=>
'xsd:string'),
121 'author' => array(
'name'=>
'author',
'type'=>
'xsd:string'),
122 'usermod' => array(
'name'=>
'usermod',
'type'=>
'xsd:string'),
123 'userownerid' => array(
'name'=>
'userownerid',
'type'=>
'xsd:string'),
124 'priority' => array(
'name'=>
'priority',
'type'=>
'xsd:string'),
125 'fulldayevent' => array(
'name'=>
'fulldayevent',
'type'=>
'xsd:string'),
126 'location' => array(
'name'=>
'location',
'type'=>
'xsd:string'),
127 'socid' => array(
'name'=>
'socid',
'type'=>
'xsd:string'),
128 'contactid' => array(
'name'=>
'contactid',
'type'=>
'xsd:string'),
129 'projectid' => array(
'name'=>
'projectid',
'type'=>
'xsd:string'),
130 'fk_element' => array(
'name'=>
'fk_element',
'type'=>
'xsd:string'),
131 'elementtype' => array(
'name'=>
'elementtype',
'type'=>
'xsd:string'));
134$elementtype =
'actioncomm';
139$extrafields->fetch_name_optionals_label($elementtype,
true);
140$extrafield_array =
null;
141if (is_array($extrafields) && count($extrafields) > 0) {
142 $extrafield_array = array();
144if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
145 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
146 $type = $extrafields->attributes[$elementtype][
'type'][$key];
147 if ($type ==
'date' || $type ==
'datetime') {
148 $type =
'xsd:dateTime';
150 $type =
'xsd:string';
153 $extrafield_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
156if (is_array($extrafield_array)) {
157 $actioncomm_fields = array_merge($actioncomm_fields, $extrafield_array);
161$server->wsdl->addComplexType(
171$server->wsdl->addComplexType(
178 'code' => array(
'name'=>
'code',
'type'=>
'xsd:string'),
179 'libelle' => array(
'name'=>
'libelle',
'type'=>
'xsd:string')
183$server->wsdl->addComplexType(
190 'actioncommtype' => array(
191 'name' =>
'actioncommtype',
192 'type' =>
'tns:actioncommtype',
194 'maxOccurs' =>
'unbounded'
204$styleuse =
'encoded';
210 'getListActionCommType',
212 array(
'authentication'=>
'tns:authentication'),
214 array(
'result'=>
'tns:result',
'actioncommtypes'=>
'tns:actioncommtypes'),
216 $ns.
'#getListActionCommType',
219 'WS to get actioncommType'
226 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string'),
228 array(
'result'=>
'tns:result',
'actioncomm'=>
'tns:actioncomm'),
230 $ns.
'#getActionComm',
233 'WS to get actioncomm'
240 array(
'authentication'=>
'tns:authentication',
'actioncomm'=>
'tns:actioncomm'),
242 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
244 $ns.
'#createActionComm',
247 'WS to create a actioncomm'
254 array(
'authentication'=>
'tns:authentication',
'actioncomm'=>
'tns:actioncomm'),
256 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
258 $ns.
'#updateActionComm',
261 'WS to update a actioncomm'
276 global $db, $conf, $langs;
278 dol_syslog(
"Function: getActionComm login=".$authentication[
'login'].
" id=".$id);
280 if ($authentication[
'entity']) {
281 $conf->entity = $authentication[
'entity'];
285 $objectresp = array();
286 $errorcode =
''; $errorlabel =
'';
290 if ($error || (!$id)) {
292 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
298 if ($fuser->rights->agenda->allactions->read) {
300 $result = $actioncomm->fetch($id);
302 $actioncomm_result_fields = array(
303 'id' => $actioncomm->id,
304 'ref'=> $actioncomm->ref,
305 'ref_ext'=> $actioncomm->ref_ext,
306 'type_id'=> $actioncomm->type_id,
307 'type_code'=> $actioncomm->type_code,
308 'type'=> $actioncomm->type,
309 'label'=> $actioncomm->label,
314 'note'=> $actioncomm->note_private,
315 'percentage'=> $actioncomm->percentage,
316 'author'=> $actioncomm->authorid,
317 'usermod'=> $actioncomm->usermodid,
318 'userownerid'=> $actioncomm->userownerid,
319 'priority'=> $actioncomm->priority,
320 'fulldayevent'=> $actioncomm->fulldayevent,
321 'location'=> $actioncomm->location,
322 'socid'=> $actioncomm->socid,
323 'contactid'=> $actioncomm->contact_id,
324 'projectid'=> $actioncomm->fk_project,
325 'fk_element'=> $actioncomm->fk_element,
326 'elementtype'=> $actioncomm->elementtype
329 $elementtype =
'actioncomm';
334 $extrafields->fetch_name_optionals_label($elementtype,
true);
336 $actioncomm->fetch_optionals();
338 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
339 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
340 $actioncomm_result_fields = array_merge($actioncomm_result_fields, array(
'options_'.$key => $actioncomm->array_options[
'options_'.$key]));
346 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
347 'actioncomm'=>$actioncomm_result_fields);
350 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id;
354 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
359 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
374 global $db, $conf, $langs;
376 dol_syslog(
"Function: getListActionCommType login=".$authentication[
'login']);
378 if ($authentication[
'entity']) {
379 $conf->entity = $authentication[
'entity'];
383 $objectresp = array();
384 $errorcode =
''; $errorlabel =
'';
391 if ($fuser->rights->agenda->myactions->read) {
393 $result = $cactioncomm->liste_array(
'',
'code');
395 $resultarray = array();
396 foreach ($cactioncomm->liste_array as $code => $libeller) {
397 $resultarray[] = array(
'code'=>$code,
'libelle'=>$libeller);
401 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
402 'actioncommtypes'=>$resultarray);
405 $errorcode =
'NOT_FOUND'; $errorlabel =
'Failed to execute liste_array';
409 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
414 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
430 global $db, $conf, $langs;
434 dol_syslog(
"Function: createActionComm login=".$authentication[
'login']);
436 if ($authentication[
'entity']) {
437 $conf->entity = $authentication[
'entity'];
441 $objectresp = array();
442 $errorcode =
''; $errorlabel =
'';
449 $newobject->datep = $actioncomm[
'datep'];
450 $newobject->datef = $actioncomm[
'datef'];
451 $newobject->type_code = $actioncomm[
'type_code'];
452 $newobject->socid = $actioncomm[
'socid'];
453 $newobject->fk_project = $actioncomm[
'projectid'];
454 $newobject->note = $actioncomm[
'note'];
455 $newobject->contact_id = $actioncomm[
'contactid'];
456 $newobject->userownerid = $actioncomm[
'userownerid'];
457 $newobject->label = $actioncomm[
'label'];
458 $newobject->percentage = $actioncomm[
'percentage'];
459 $newobject->priority = $actioncomm[
'priority'];
460 $newobject->fulldayevent = $actioncomm[
'fulldayevent'];
461 $newobject->location = $actioncomm[
'location'];
462 $newobject->fk_element = $actioncomm[
'fk_element'];
463 $newobject->elementtype = $actioncomm[
'elementtype'];
465 $elementtype =
'actioncomm';
470 $extrafields->fetch_name_optionals_label($elementtype,
true);
471 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
472 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
473 $key =
'options_'.$key;
474 $newobject->array_options[$key] = $actioncomm[$key];
480 $result = $newobject->create($fuser);
487 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$newobject->id);
492 $errorlabel = $newobject->error;
497 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
512 global $db, $conf, $langs;
516 dol_syslog(
"Function: updateActionComm login=".$authentication[
'login']);
518 if ($authentication[
'entity']) {
519 $conf->entity = $authentication[
'entity'];
523 $objectresp = array();
524 $errorcode =
''; $errorlabel =
'';
528 if (empty($actioncomm[
'id'])) {
529 $error++; $errorcode =
'KO'; $errorlabel =
"Actioncomm id is mandatory.";
533 $objectfound =
false;
536 $result = $object->fetch($actioncomm[
'id']);
538 if (!empty($object->id)) {
541 $object->datep = $actioncomm[
'datep'];
542 $object->datef = $actioncomm[
'datef'];
543 $object->type_code = $actioncomm[
'type_code'];
544 $object->socid = $actioncomm[
'socid'];
545 $object->contact_id = $actioncomm[
'contactid'];
546 $object->fk_project = $actioncomm[
'projectid'];
547 $object->note = $actioncomm[
'note'];
548 $object->userownerid = $actioncomm[
'userownerid'];
549 $object->label = $actioncomm[
'label'];
550 $object->percentage = $actioncomm[
'percentage'];
551 $object->priority = $actioncomm[
'priority'];
552 $object->fulldayevent = $actioncomm[
'fulldayevent'];
553 $object->location = $actioncomm[
'location'];
554 $object->fk_element = $actioncomm[
'fk_element'];
555 $object->elementtype = $actioncomm[
'elementtype'];
557 $elementtype =
'actioncomm';
562 $extrafields->fetch_name_optionals_label($elementtype,
true);
563 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
564 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
565 $key =
'options_'.$key;
566 $object->array_options[$key] = $actioncomm[$key];
572 $result = $object->update($fuser);
578 if ((!$error) && ($objectfound)) {
581 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
584 } elseif ($objectfound) {
588 $errorlabel = $object->error;
591 $errorcode =
'NOT_FOUND';
592 $errorlabel =
'Actioncomm id='.$actioncomm[
'id'].
' cannot be found';
597 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
604$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.