23 if (!defined(
"NOCSRFCHECK")) {
24 define(
"NOCSRFCHECK",
'1');
27 require_once
'../master.inc.php';
28 require_once NUSOAP_PATH.
'/nusoap.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
36 dol_syslog(
"Call Dolibarr webservices interfaces");
41 if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) {
42 $langs->load(
"admin");
43 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
44 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
45 print $langs->trans(
"ToActivateModule");
50 $server =
new nusoap_server();
51 $server->soap_defencoding =
'UTF-8';
52 $server->decode_utf8 =
false;
53 $ns =
'http://www.dolibarr.org/ns/';
54 $server->configureWSDL(
'WebServicesDolibarrThirdParty', $ns);
55 $server->wsdl->schemaTargetNamespace = $ns;
59 $server->wsdl->addComplexType(
66 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
67 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
68 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
69 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
70 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
74 $server->wsdl->addComplexType(
81 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
82 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
87 $thirdparty_fields = array(
88 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
89 'ref' => array(
'name'=>
'name',
'type'=>
'xsd:string'),
90 'ref_ext' => array(
'name'=>
'ref_ext',
'type'=>
'xsd:string'),
91 'fk_user_author' => array(
'name'=>
'fk_user_author',
'type'=>
'xsd:string'),
92 'status' => array(
'name'=>
'status',
'type'=>
'xsd:string'),
93 'client' => array(
'name'=>
'client',
'type'=>
'xsd:string'),
94 'supplier' => array(
'name'=>
'supplier',
'type'=>
'xsd:string'),
95 'customer_code' => array(
'name'=>
'customer_code',
'type'=>
'xsd:string'),
96 'supplier_code' => array(
'name'=>
'supplier_code',
'type'=>
'xsd:string'),
97 'customer_code_accountancy' => array(
'name'=>
'customer_code_accountancy',
'type'=>
'xsd:string'),
98 'supplier_code_accountancy' => array(
'name'=>
'supplier_code_accountancy',
'type'=>
'xsd:string'),
99 'date_creation' => array(
'name'=>
'date_creation',
'type'=>
'xsd:dateTime'),
100 'date_modification' => array(
'name'=>
'date_modification',
'type'=>
'xsd:dateTime'),
101 'note_private' => array(
'name'=>
'note_private',
'type'=>
'xsd:string'),
102 'note_public' => array(
'name'=>
'note_public',
'type'=>
'xsd:string'),
103 'address' => array(
'name'=>
'address',
'type'=>
'xsd:string'),
104 'zip' => array(
'name'=>
'zip',
'type'=>
'xsd:string'),
105 'town' => array(
'name'=>
'town',
'type'=>
'xsd:string'),
106 'region_code' => array(
'name'=>
'region_code',
'type'=>
'xsd:string'),
107 'country_id' => array(
'name'=>
'country_id',
'type'=>
'xsd:string'),
108 'country_code' => array(
'name'=>
'country_code',
'type'=>
'xsd:string'),
109 'country' => array(
'name'=>
'country',
'type'=>
'xsd:string'),
110 'phone' => array(
'name'=>
'phone',
'type'=>
'xsd:string'),
111 'fax' => array(
'name'=>
'fax',
'type'=>
'xsd:string'),
112 'email' => array(
'name'=>
'email',
'type'=>
'xsd:string'),
113 'url' => array(
'name'=>
'url',
'type'=>
'xsd:string'),
114 'profid1' => array(
'name'=>
'profid1',
'type'=>
'xsd:string'),
115 'profid2' => array(
'name'=>
'profid2',
'type'=>
'xsd:string'),
116 'profid3' => array(
'name'=>
'profid3',
'type'=>
'xsd:string'),
117 'profid4' => array(
'name'=>
'profid4',
'type'=>
'xsd:string'),
118 'profid5' => array(
'name'=>
'profid5',
'type'=>
'xsd:string'),
119 'profid6' => array(
'name'=>
'profid6',
'type'=>
'xsd:string'),
120 'capital' => array(
'name'=>
'capital',
'type'=>
'xsd:string'),
121 'vat_used' => array(
'name'=>
'vat_used',
'type'=>
'xsd:string'),
122 'vat_number' => array(
'name'=>
'vat_number',
'type'=>
'xsd:string'));
124 $elementtype =
'societe';
129 $extrafields->fetch_name_optionals_label($elementtype,
true);
130 $extrafield_array =
null;
131 if (is_array($extrafields) && count($extrafields) > 0) {
132 $extrafield_array = array();
134 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
135 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
137 $type = $extrafields->attributes[$elementtype][
'type'][$key];
138 if ($type ==
'date' || $type ==
'datetime') {
139 $type =
'xsd:dateTime';
141 $type =
'xsd:string';
144 $extrafield_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
148 if (is_array($extrafield_array)) {
149 $thirdparty_fields = array_merge($thirdparty_fields, $extrafield_array);
153 $server->wsdl->addComplexType(
163 $server->wsdl->addComplexType(
171 'client' => array(
'name'=>
'client',
'type'=>
'xsd:string'),
172 'supplier' => array(
'name'=>
'supplier',
'type'=>
'xsd:string'),
173 'category' => array(
'name'=>
'category',
'type'=>
'xsd:string')
177 $server->wsdl->addComplexType(
185 array(
'ref'=>
'SOAP-ENC:arrayType',
'wsdl:arrayType'=>
'tns:thirdparty[]')
189 $server->wsdl->addComplexType(
190 'ThirdPartiesArray2',
196 'thirdparty' => array(
197 'name' =>
'thirdparty',
198 'type' =>
'tns:thirdparty',
200 'maxOccurs' =>
'unbounded'
210 $styleuse =
'encoded';
217 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string',
'barcode'=>
'xsd:string',
'profid1'=>
'xsd:string',
'profid2'=>
'xsd:string'),
219 array(
'result'=>
'tns:result',
'thirdparty'=>
'tns:thirdparty'),
221 $ns.
'#getThirdParty',
224 'WS to get a thirdparty from its id, ref or ref_ext'
231 array(
'authentication'=>
'tns:authentication',
'thirdparty'=>
'tns:thirdparty'),
233 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string'),
235 $ns.
'#createThirdParty',
238 'WS to create a thirdparty'
245 array(
'authentication'=>
'tns:authentication',
'thirdparty'=>
'tns:thirdparty'),
247 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
249 $ns.
'#updateThirdParty',
252 'WS to update a thirdparty'
258 'getListOfThirdParties',
260 array(
'authentication'=>
'tns:authentication',
'filterthirdparty'=>
'tns:filterthirdparty'),
262 array(
'result'=>
'tns:result',
'thirdparties'=>
'tns:ThirdPartiesArray2'),
264 $ns.
'#getListOfThirdParties',
267 'WS to get list of thirdparties id and ref'
274 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
276 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
278 $ns.
'#deleteThirdParty',
281 'WS to delete a thirdparty from its id, ref or ref_ext'
298 function getThirdParty($authentication, $id =
'', $ref =
'', $ref_ext =
'', $barcode =
'', $profid1 =
'', $profid2 =
'')
302 dol_syslog(
"Function: getThirdParty login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext.
" barcode=".$barcode.
" profid1=".$profid1.
" profid2=".$profid2);
304 if ($authentication[
'entity']) {
305 $conf->entity = $authentication[
'entity'];
309 $objectresp = array();
315 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
317 $errorcode =
'BAD_PARAMETERS';
318 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
324 if ($fuser->rights->societe->lire) {
325 $thirdparty =
new Societe($db);
326 $result = $thirdparty->fetch($id, $ref, $ref_ext, $barcode, $profid1, $profid2);
328 $thirdparty_result_fields = array(
329 'id' => $thirdparty->id,
330 'ref' => $thirdparty->name,
331 'ref_ext' => $thirdparty->ref_ext,
332 'status' => $thirdparty->status,
333 'client' => $thirdparty->client,
334 'supplier' => $thirdparty->fournisseur,
335 'customer_code' => $thirdparty->code_client,
336 'supplier_code' => $thirdparty->code_fournisseur,
337 'customer_code_accountancy' => $thirdparty->code_compta,
338 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur,
339 'user_creation' => $thirdparty->user_creation,
340 'date_creation' =>
dol_print_date($thirdparty->date_creation,
'dayhourrfc'),
341 'user_modification' => $thirdparty->user_modification,
342 'date_modification' =>
dol_print_date($thirdparty->date_modification,
'dayhourrfc'),
343 'address' => $thirdparty->address,
344 'zip' => $thirdparty->zip,
345 'town' => $thirdparty->town,
346 'region_code' => $thirdparty->region_code,
347 'country_id' => $thirdparty->country_id,
348 'country_code' => $thirdparty->country_code,
349 'country' => $thirdparty->country,
350 'phone' => $thirdparty->phone,
351 'fax' => $thirdparty->fax,
352 'email' => $thirdparty->email,
353 'url' => $thirdparty->url,
354 'profid1' => $thirdparty->idprof1,
355 'profid2' => $thirdparty->idprof2,
356 'profid3' => $thirdparty->idprof3,
357 'profid4' => $thirdparty->idprof4,
358 'profid5' => $thirdparty->idprof5,
359 'profid6' => $thirdparty->idprof6,
360 'capital' => $thirdparty->capital,
361 'barcode' => $thirdparty->barcode,
362 'vat_used' => $thirdparty->tva_assuj,
363 'vat_number' => $thirdparty->tva_intra,
364 'note_private' => $thirdparty->note_private,
365 'note_public' => $thirdparty->note_public);
367 $elementtype =
'societe';
372 $extrafields->fetch_name_optionals_label($elementtype,
true);
374 $thirdparty->fetch_optionals();
376 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
377 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
378 if (isset($thirdparty->array_options[
'options_'.$key])) {
379 $thirdparty_result_fields = array_merge($thirdparty_result_fields, array(
'options_'.$key => $thirdparty->array_options[
'options_'.$key]));
386 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
387 'thirdparty'=>$thirdparty_result_fields);
388 } elseif ($result == -2) {
390 $errorcode =
'DUPLICATE_FOUND'; $errorlabel =
'Object found several times for id='.$id.
' or ref='.$ref.
' or ref_ext='.$ref_ext;
393 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
397 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
402 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
423 dol_syslog(
"Function: createThirdParty login=".$authentication[
'login']);
425 if ($authentication[
'entity']) {
426 $conf->entity = $authentication[
'entity'];
430 $objectresp = array();
431 $errorcode =
''; $errorlabel =
'';
435 if (empty($thirdparty[
'ref'])) {
436 $error++; $errorcode =
'KO'; $errorlabel =
"Name is mandatory.";
441 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
444 $newobject->ref = $thirdparty[
'ref'];
445 $newobject->name = $thirdparty[
'ref'];
446 $newobject->ref_ext = $thirdparty[
'ref_ext'];
447 $newobject->status = $thirdparty[
'status'];
448 $newobject->client = $thirdparty[
'client'];
449 $newobject->fournisseur = $thirdparty[
'supplier'];
450 $newobject->code_client = $thirdparty[
'customer_code'];
451 $newobject->code_fournisseur = $thirdparty[
'supplier_code'];
452 $newobject->code_compta = $thirdparty[
'customer_code_accountancy'];
453 $newobject->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
454 $newobject->date_creation = $now;
455 $newobject->note_private = $thirdparty[
'note_private'];
456 $newobject->note_public = $thirdparty[
'note_public'];
457 $newobject->address = $thirdparty[
'address'];
458 $newobject->zip = $thirdparty[
'zip'];
459 $newobject->town = $thirdparty[
'town'];
461 $newobject->country_id = $thirdparty[
'country_id'];
462 if ($thirdparty[
'country_code']) {
463 $newobject->country_id =
getCountry($thirdparty[
'country_code'], 3);
465 $newobject->region_code = empty($thirdparty[
'region_code']) ?
'' : $thirdparty[
'region_code'];
468 $newobject->phone = $thirdparty[
'phone'];
469 $newobject->fax = $thirdparty[
'fax'];
470 $newobject->email = $thirdparty[
'email'];
471 $newobject->url = $thirdparty[
'url'];
472 $newobject->idprof1 = $thirdparty[
'profid1'];
473 $newobject->idprof2 = $thirdparty[
'profid2'];
474 $newobject->idprof3 = $thirdparty[
'profid3'];
475 $newobject->idprof4 = $thirdparty[
'profid4'];
476 $newobject->idprof5 = $thirdparty[
'profid5'];
477 $newobject->idprof6 = $thirdparty[
'profid6'];
479 $newobject->capital = $thirdparty[
'capital'];
481 $newobject->barcode = empty($thirdparty[
'barcode']) ?
'' : $thirdparty[
'barcode'];
482 $newobject->tva_assuj = empty($thirdparty[
'vat_used']) ? 0 : $thirdparty[
'vat_used'];
483 $newobject->tva_intra = empty($thirdparty[
'vat_number']) ?
'' : $thirdparty[
'vat_number'];
485 $newobject->canvas = empty($thirdparty[
'canvas']) ?
'' : $thirdparty[
'canvas'];
486 $newobject->particulier = empty($thirdparty[
'individual']) ? 0 : $thirdparty[
'individual'];
488 $elementtype =
'societe';
493 $extrafields->fetch_name_optionals_label($elementtype,
true);
494 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
495 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
496 $key =
'options_'.$key;
497 if (isset($thirdparty[$key])) {
498 $newobject->array_options[$key] = $thirdparty[$key];
505 $result = $newobject->create($fuser);
506 if ($newobject->particulier && $result > 0) {
507 $newobject->firstname = $thirdparty[
'firstname'];
508 $newobject->name_bis = $thirdparty[
'lastname'];
509 $result = $newobject->create_individual($fuser);
519 if (!empty($thirdparty[
'commid']) && $thirdparty[
'commid'] > 0) {
520 $newobject->add_commercial($fuser, $thirdparty[
"commid"]);
523 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$newobject->id,
'ref'=>$newobject->ref);
528 $errorlabel = $newobject->error;
533 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
552 dol_syslog(
"Function: updateThirdParty login=".$authentication[
'login']);
554 if ($authentication[
'entity']) {
555 $conf->entity = $authentication[
'entity'];
559 $objectresp = array();
560 $errorcode =
''; $errorlabel =
'';
564 if (empty($thirdparty[
'id'])) {
565 $error++; $errorcode =
'KO'; $errorlabel =
"Thirdparty id is mandatory.";
569 $objectfound =
false;
571 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
574 $result = $object->fetch($thirdparty[
'id']);
576 if (!empty($object->id)) {
579 $object->ref = $thirdparty[
'ref'];
580 $object->name = $thirdparty[
'ref'];
581 $object->ref_ext = $thirdparty[
'ref_ext'];
582 $object->status = $thirdparty[
'status'];
583 $object->client = $thirdparty[
'client'];
584 $object->fournisseur = $thirdparty[
'supplier'];
585 $object->code_client = $thirdparty[
'customer_code'];
586 $object->code_fournisseur = $thirdparty[
'supplier_code'];
587 $object->code_compta = $thirdparty[
'customer_code_accountancy'];
588 $object->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
589 $object->date_creation = $now;
590 $object->note_private = $thirdparty[
'note_private'];
591 $object->note_public = $thirdparty[
'note_public'];
592 $object->address = $thirdparty[
'address'];
593 $object->zip = $thirdparty[
'zip'];
594 $object->town = $thirdparty[
'town'];
596 $object->country_id = $thirdparty[
'country_id'];
597 if ($thirdparty[
'country_code']) {
598 $object->country_id =
getCountry($thirdparty[
'country_code'], 3);
600 $object->region_code = $thirdparty[
'region_code'];
603 $object->phone = $thirdparty[
'phone'];
604 $object->fax = $thirdparty[
'fax'];
605 $object->email = $thirdparty[
'email'];
606 $object->url = $thirdparty[
'url'];
607 $object->idprof1 = $thirdparty[
'profid1'];
608 $object->idprof2 = $thirdparty[
'profid2'];
609 $object->idprof3 = $thirdparty[
'profid3'];
610 $object->idprof4 = $thirdparty[
'profid4'];
611 $object->idprof5 = $thirdparty[
'profid5'];
612 $object->idprof6 = $thirdparty[
'profid6'];
614 $object->capital = $thirdparty[
'capital'];
616 $object->barcode = $thirdparty[
'barcode'];
617 $object->tva_assuj = $thirdparty[
'vat_used'];
618 $object->tva_intra = $thirdparty[
'vat_number'];
620 $object->canvas = $thirdparty[
'canvas'];
622 $elementtype =
'societe';
627 $extrafields->fetch_name_optionals_label($elementtype,
true);
628 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
629 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
630 $key =
'options_'.$key;
631 if (isset($thirdparty[$key])) {
632 $object->array_options[$key] = $thirdparty[$key];
639 $result = $object->update($thirdparty[
'id'], $fuser);
645 if ((!$error) && ($objectfound)) {
648 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
651 } elseif ($objectfound) {
655 $errorlabel = $object->error;
658 $errorcode =
'NOT_FOUND';
659 $errorlabel =
'Thirdparty id='.$thirdparty[
'id'].
' cannot be found';
664 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
683 dol_syslog(
"Function: getListOfThirdParties login=".$authentication[
'login']);
685 if ($authentication[
'entity']) {
686 $conf->entity = $authentication[
'entity'];
690 $objectresp = array();
691 $arraythirdparties = array();
693 $errorcode =
''; $errorlabel =
'';
699 $sql =
"SELECT s.rowid as socRowid, s.nom as ref, s.ref_ext, s.address, s.zip, s.town, c.label as country, s.phone, s.fax, s.url, extra.*";
700 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
701 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON s.fk_pays = c.rowid";
702 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as extra ON s.rowid=fk_object";
704 $sql .=
" WHERE entity=".$conf->entity;
705 foreach ($filterthirdparty as $key => $val) {
706 if ($key ==
'name' && $val !=
'') {
707 $sql .=
" AND s.name LIKE '%".$db->escape($val).
"%'";
709 if ($key ==
'client' && (
int) $val > 0) {
710 $sql .=
" AND s.client = ".((int) $val);
712 if ($key ==
'supplier' && (
int) $val > 0) {
713 $sql .=
" AND s.fournisseur = ".((int) $val);
715 if ($key ==
'category' && (
int) $val > 0) {
716 $sql .=
" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe WHERE fk_categorie = ".((int) $val).
") ";
719 dol_syslog(
"Function: getListOfThirdParties", LOG_DEBUG);
721 $elementtype =
'societe';
724 $extrafields->fetch_name_optionals_label($elementtype,
true);
727 $resql = $db->query($sql);
729 $num = $db->num_rows(
$resql);
733 $extrafieldsOptions = array();
734 $obj = $db->fetch_object(
$resql);
736 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
737 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
738 if (isset($obj->{$key})) {
739 $extrafieldsOptions[
'options_'.$key] = $obj->$key;
744 $arraythirdparties[] = array(
'id'=>$obj->socRowid,
746 'ref_ext'=>$obj->ref_ext,
747 'adress'=>$obj->adress,
750 'country'=>$obj->country,
751 'phone'=>$obj->phone,
755 $arraythirdparties[$i] = array_merge($arraythirdparties[$i], $extrafieldsOptions);
761 $errorcode = $db->lasterrno();
762 $errorlabel = $db->lasterror();
768 'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel),
769 'thirdparties'=>$arraythirdparties
773 'result'=>array(
'result_code' =>
'OK',
'result_label' =>
''),
774 'thirdparties'=>$arraythirdparties
794 dol_syslog(
"Function: deleteThirdParty login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
796 if ($authentication[
'entity']) {
797 $conf->entity = $authentication[
'entity'];
801 $objectresp = array();
802 $errorcode =
''; $errorlabel =
'';
806 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
807 dol_syslog(
"Function: deleteThirdParty checkparam");
809 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
816 if ($fuser->rights->societe->lire && $fuser->rights->societe->supprimer) {
817 $thirdparty =
new Societe($db);
818 $result = $thirdparty->fetch($id, $ref, $ref_ext);
823 $result = $thirdparty->delete($thirdparty->id, $fuser);
828 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''));
833 $errorlabel = $thirdparty->error;
834 dol_syslog(
"Function: deleteThirdParty cant delete");
838 $errorcode =
'NOT_FOUND'; $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
842 $errorcode =
'PERMISSION_DENIED'; $errorlabel =
'User does not have permission for this request';
847 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
854 $server->service(file_get_contents(
"php://input"));
Class to manage third parties objects (customers, suppliers, prospects...)
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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.
getThirdParty($authentication, $id='', $ref='', $ref_ext='', $barcode='', $profid1='', $profid2='')
Get a thirdparty.
deleteThirdParty($authentication, $id='', $ref='', $ref_ext='')
Delete a thirdparty.
updateThirdParty($authentication, $thirdparty)
Update a thirdparty.
getListOfThirdParties($authentication, $filterthirdparty)
getListOfThirdParties
createThirdParty($authentication, $thirdparty)
Create a thirdparty.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.