25if (!defined(
'NOCSRFCHECK')) {
26 define(
'NOCSRFCHECK',
'1');
28if (!defined(
'NOTOKENRENEWAL')) {
29 define(
'NOTOKENRENEWAL',
'1');
31if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
40if (!defined(
"NOLOGIN")) {
41 define(
"NOLOGIN",
'1');
43if (!defined(
"NOSESSION")) {
44 define(
"NOSESSION",
'1');
47require
'../main.inc.php';
48require_once NUSOAP_PATH.
'/nusoap.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
56dol_syslog(
"Call Dolibarr webservices interfaces");
62 $langs->load(
"admin");
63 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
64 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
65 print $langs->trans(
"ToActivateModule");
70$listofreferent = array(
72 'order' =>
'commande',
73 'invoice' =>
'facture',
74 'invoice_predefined' =>
'facture_rec',
75 'proposal_supplier' =>
'commande_fournisseur',
76 'order_supplier' =>
'commande_fournisseur',
77 'invoice_supplier' =>
'facture_fourn',
78 'contract' =>
'contrat',
79 'intervention' =>
'fichinter',
80 'trip' =>
'deplacement',
81 'expensereport' =>
'expensereport_det',
83 'agenda' =>
'actioncomm',
84 'project_task' =>
'projet_task',
88$server =
new nusoap_server();
89$server->soap_defencoding =
'UTF-8';
90$server->decode_utf8 =
false;
91$ns =
'http://www.dolibarr.org/ns/';
92$server->configureWSDL(
'WebServicesDolibarrOther', $ns);
93$server->wsdl->schemaTargetNamespace = $ns;
96$server->wsdl->addComplexType(
103 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
104 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
105 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
106 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
107 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
112$server->wsdl->addComplexType(
119 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
120 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
125$server->wsdl->addComplexType(
132 'id' => array(
'name'=>
'id',
'type'=>
'xsd:int'),
133 'user' => array(
'name'=>
'user',
'type'=>
'xsd:int'),
137$server->wsdl->addComplexType(
145 'name' =>
'elementsArray',
146 'type' =>
'tns:element',
148 'maxOccurs' =>
'unbounded'
153$project_elements = array();
154foreach ($listofreferent as $key => $label) {
155 $project_elements[$key] = array(
'name'=>$key,
'type'=>
'tns:elementsArray');
157$server->wsdl->addComplexType(
167$project_fields = array(
168 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
169 'ref' => array(
'name'=>
'ref',
'type'=>
'xsd:string'),
170 'label' => array(
'name'=>
'label',
'type'=>
'xsd:string'),
171 'thirdparty_id' => array(
'name'=>
'thirdparty_id',
'type'=>
'xsd:int'),
172 'public' => array(
'name'=>
'public',
'type'=>
'xsd:int'),
173 'status' => array(
'name'=>
'status',
'type'=>
'xsd:int'),
174 'date_start' => array(
'name'=>
'date_start',
'type'=>
'xsd:date'),
175 'date_end' => array(
'name'=>
'date_end',
'type'=>
'xsd:date'),
176 'budget' => array(
'name'=>
'budget',
'type'=>
'xsd:int'),
177 'description' => array(
'name'=>
'description',
'type'=>
'xsd:string'),
178 'elements' => array(
'name'=>
'elements',
'type'=>
'tns:elements')
181$elementtype =
'project';
186$extrafields->fetch_name_optionals_label($elementtype,
true);
187$extrafield_array =
null;
188if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
189 $extrafield_array = array();
191if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
192 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
194 $type = $extrafields->attributes[$elementtype][
'type'][$key];
195 if ($type ==
'date' || $type ==
'datetime') {
196 $type =
'xsd:dateTime';
198 $type =
'xsd:string';
200 $extrafield_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
203if (is_array($extrafield_array)) {
204 $project_fields = array_merge($project_fields, $extrafield_array);
207$server->wsdl->addComplexType(
220$styleuse =
'encoded';
227 array(
'authentication'=>
'tns:authentication',
'project'=>
'tns:project'),
229 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string'),
231 $ns.
'#createProject',
234 'WS to create project'
241 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'ref'=>
'xsd:string'),
243 array(
'result'=>
'tns:result',
'project'=>
'tns:project'),
263 dol_syslog(
"Function: createProject login=".$authentication[
'login']);
265 if ($authentication[
'entity']) {
266 $conf->entity = $authentication[
'entity'];
270 $objectresp = array();
276 if (empty($project[
'ref'])) {
279 $errorlabel =
"Name is mandatory.";
286 if ($fuser->hasRight(
'projet',
'creer')) {
288 $newobject->ref = $project[
'ref'];
289 $newobject->title = $project[
'label'];
290 $newobject->socid = $project[
'thirdparty_id'];
291 $newobject->public = $project[
'public'];
292 $newobject->statut = $project[
'status'];
293 $newobject->date_start =
dol_stringtotime($project[
'date_start'],
'dayrfc');
295 $newobject->budget_amount = $project[
'budget'];
296 $newobject->description = $project[
'description'];
298 $elementtype =
'project';
303 $extrafields->fetch_name_optionals_label($elementtype,
true);
304 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
305 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
306 $key =
'options_'.$key;
307 $newobject->array_options[$key] = $project[$key];
313 $result = $newobject->create($fuser);
314 if (!$error && $result > 0) {
316 $result = $newobject->add_contact($fuser->id,
'PROJECTLEADER',
'internal');
326 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$newobject->id,
'ref'=>$newobject->ref);
331 $errorlabel = $newobject->error;
335 $errorcode =
'PERMISSION_DENIED';
336 $errorlabel =
'User does not have permission for this request';
341 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
359 dol_syslog(
"Function: getProject login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref);
361 if ($authentication[
'entity']) {
362 $conf->entity = $authentication[
'entity'];
366 $objectresp = array();
372 if (!$error && (($id && $ref))) {
374 $errorcode =
'BAD_PARAMETERS';
375 $errorlabel =
"Parameter id and ref can't be both provided. You must choose one or other but not both.";
381 if ($fuser->hasRight(
'projet',
'lire')) {
383 $result = $project->fetch($id, $ref);
385 $project_result_fields = array(
386 'id' => $project->id,
387 'ref' => $project->ref,
388 'label' => $project->title,
389 'thirdparty_id' => $project->socid,
390 'public' => $project->public,
391 'status' => $project->statut,
392 'date_start' => $project->date_start ?
dol_print_date($project->date_start,
'dayrfc') :
'',
393 'date_end' => $project->date_end ?
dol_print_date($project->date_end,
'dayrfc') :
'',
394 'budget' => $project->budget_amount,
395 'description' => $project->description,
398 $elementtype =
'project';
402 $extrafields->fetch_name_optionals_label($elementtype,
true);
405 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
406 $project->fetch_optionals();
407 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
408 $project_result_fields = array_merge($project_result_fields, array(
'options_'.$key => $project->array_options[
'options_'.$key]));
413 global $listofreferent;
415 foreach ($listofreferent as $key => $tablename) {
416 $elements[$key] = array();
417 $element_array = $project->get_element_list($key, $tablename);
418 if (count($element_array) > 0 && is_array($element_array)) {
419 foreach ($element_array as $element) {
420 $tmp = explode(
'_', $element);
421 $idofelement = count($tmp) > 0 ? $tmp[0] :
"";
422 $idofelementuser = count($tmp) > 1 ? $tmp[1] :
"";
423 $elements[$key][] = array(
'id' => $idofelement,
'user' => $idofelementuser);
427 $project_result_fields[
'elements'] = $elements;
431 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
432 'project'=>$project_result_fields
436 $errorcode =
'NOT_FOUND';
437 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref;
441 $errorcode =
'PERMISSION_DENIED';
442 $errorlabel =
'User does not have permission for this request';
447 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
454$server->service(file_get_contents(
"php://input"));
Class to manage projects.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
createProject($authentication, $project)
Create project.
getProject($authentication, $id='', $ref='')
Get a project.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.