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.
'/user/class/user.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.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$server =
new nusoap_server();
71$server->soap_defencoding =
'UTF-8';
72$server->decode_utf8 =
false;
73$ns =
'http://www.dolibarr.org/ns/';
74$server->configureWSDL(
'WebServicesDolibarrThirdParty', $ns);
75$server->wsdl->schemaTargetNamespace = $ns;
79$server->wsdl->addComplexType(
86 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
87 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
88 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
89 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
90 '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$thirdparty_fields = array(
108 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
109 'ref' => array(
'name' =>
'name',
'type' =>
'xsd:string'),
110 'ref_ext' => array(
'name' =>
'ref_ext',
'type' =>
'xsd:string'),
111 'fk_user_author' => array(
'name' =>
'fk_user_author',
'type' =>
'xsd:string'),
112 'status' => array(
'name' =>
'status',
'type' =>
'xsd:string'),
113 'client' => array(
'name' =>
'client',
'type' =>
'xsd:string'),
114 'supplier' => array(
'name' =>
'supplier',
'type' =>
'xsd:string'),
115 'customer_code' => array(
'name' =>
'customer_code',
'type' =>
'xsd:string'),
116 'supplier_code' => array(
'name' =>
'supplier_code',
'type' =>
'xsd:string'),
117 'customer_code_accountancy' => array(
'name' =>
'customer_code_accountancy',
'type' =>
'xsd:string'),
118 'supplier_code_accountancy' => array(
'name' =>
'supplier_code_accountancy',
'type' =>
'xsd:string'),
119 'date_creation' => array(
'name' =>
'date_creation',
'type' =>
'xsd:dateTime'),
120 'date_modification' => array(
'name' =>
'date_modification',
'type' =>
'xsd:dateTime'),
121 'note_private' => array(
'name' =>
'note_private',
'type' =>
'xsd:string'),
122 'note_public' => array(
'name' =>
'note_public',
'type' =>
'xsd:string'),
123 'address' => array(
'name' =>
'address',
'type' =>
'xsd:string'),
124 'zip' => array(
'name' =>
'zip',
'type' =>
'xsd:string'),
125 'town' => array(
'name' =>
'town',
'type' =>
'xsd:string'),
126 'region_code' => array(
'name' =>
'region_code',
'type' =>
'xsd:string'),
127 'country_id' => array(
'name' =>
'country_id',
'type' =>
'xsd:string'),
128 'country_code' => array(
'name' =>
'country_code',
'type' =>
'xsd:string'),
129 'country' => array(
'name' =>
'country',
'type' =>
'xsd:string'),
130 'phone' => array(
'name' =>
'phone',
'type' =>
'xsd:string'),
131 'fax' => array(
'name' =>
'fax',
'type' =>
'xsd:string'),
132 'email' => array(
'name' =>
'email',
'type' =>
'xsd:string'),
133 'url' => array(
'name' =>
'url',
'type' =>
'xsd:string'),
134 'profid1' => array(
'name' =>
'profid1',
'type' =>
'xsd:string'),
135 'profid2' => array(
'name' =>
'profid2',
'type' =>
'xsd:string'),
136 'profid3' => array(
'name' =>
'profid3',
'type' =>
'xsd:string'),
137 'profid4' => array(
'name' =>
'profid4',
'type' =>
'xsd:string'),
138 'profid5' => array(
'name' =>
'profid5',
'type' =>
'xsd:string'),
139 'profid6' => array(
'name' =>
'profid6',
'type' =>
'xsd:string'),
140 'capital' => array(
'name' =>
'capital',
'type' =>
'xsd:string'),
141 'vat_used' => array(
'name' =>
'vat_used',
'type' =>
'xsd:string'),
142 'vat_number' => array(
'name' =>
'vat_number',
'type' =>
'xsd:string'));
144$elementtype =
'societe';
149$extrafields->fetch_name_optionals_label($elementtype,
true);
150$extrafield_array =
null;
151if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
152 $extrafield_array = array();
154if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
155 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
157 $type = $extrafields->attributes[$elementtype][
'type'][$key];
158 if ($type ==
'date' || $type ==
'datetime') {
159 $type =
'xsd:dateTime';
161 $type =
'xsd:string';
164 $extrafield_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
168if (is_array($extrafield_array)) {
169 $thirdparty_fields = array_merge($thirdparty_fields, $extrafield_array);
173$server->wsdl->addComplexType(
183$server->wsdl->addComplexType(
191 'client' => array(
'name' =>
'client',
'type' =>
'xsd:string'),
192 'supplier' => array(
'name' =>
'supplier',
'type' =>
'xsd:string'),
193 'category' => array(
'name' =>
'category',
'type' =>
'xsd:string')
197$server->wsdl->addComplexType(
205 array(
'ref' =>
'SOAP-ENC:arrayType',
'wsdl:arrayType' =>
'tns:thirdparty[]')
209$server->wsdl->addComplexType(
210 'ThirdPartiesArray2',
216 'thirdparty' => array(
217 'name' =>
'thirdparty',
218 'type' =>
'tns:thirdparty',
220 'maxOccurs' =>
'unbounded'
230$styleuse =
'encoded';
237 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string',
'barcode' =>
'xsd:string',
'profid1' =>
'xsd:string',
'profid2' =>
'xsd:string'),
239 array(
'result' =>
'tns:result',
'thirdparty' =>
'tns:thirdparty'),
241 $ns.
'#getThirdParty',
244 'WS to get a thirdparty from its id, ref or ref_ext'
251 array(
'authentication' =>
'tns:authentication',
'thirdparty' =>
'tns:thirdparty'),
253 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string'),
255 $ns.
'#createThirdParty',
258 'WS to create a thirdparty'
265 array(
'authentication' =>
'tns:authentication',
'thirdparty' =>
'tns:thirdparty'),
267 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
269 $ns.
'#updateThirdParty',
272 'WS to update a thirdparty'
278 'getListOfThirdParties',
280 array(
'authentication' =>
'tns:authentication',
'filterthirdparty' =>
'tns:filterthirdparty'),
282 array(
'result' =>
'tns:result',
'thirdparties' =>
'tns:ThirdPartiesArray2'),
284 $ns.
'#getListOfThirdParties',
287 'WS to get list of thirdparties id and ref'
294 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
296 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
298 $ns.
'#deleteThirdParty',
301 'WS to delete a thirdparty from its id, ref or ref_ext'
318function getThirdParty($authentication, $id =
'', $ref =
'', $ref_ext =
'', $barcode =
'', $profid1 =
'', $profid2 =
'')
322 dol_syslog(
"Function: getThirdParty login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext.
" barcode=".$barcode.
" profid1=".$profid1.
" profid2=".$profid2);
324 if ($authentication[
'entity']) {
325 $conf->entity = $authentication[
'entity'];
329 $objectresp = array();
335 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
337 $errorcode =
'BAD_PARAMETERS';
338 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
344 if ($fuser->hasRight(
'societe',
'lire')) {
345 $thirdparty =
new Societe($db);
346 $result = $thirdparty->fetch($id, $ref, $ref_ext, $barcode, $profid1, $profid2);
348 $thirdparty_result_fields = array(
349 'id' => $thirdparty->id,
350 'ref' => $thirdparty->name,
351 'ref_ext' => $thirdparty->ref_ext,
352 'status' => $thirdparty->status,
353 'client' => $thirdparty->client,
354 'supplier' => $thirdparty->fournisseur,
355 'customer_code' => $thirdparty->code_client,
356 'supplier_code' => $thirdparty->code_fournisseur,
357 'customer_code_accountancy' => $thirdparty->code_compta_client,
358 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur,
359 'user_creation_id' => $thirdparty->user_creation_id,
360 'date_creation' =>
dol_print_date($thirdparty->date_creation,
'dayhourrfc'),
361 'user_modification_id' => $thirdparty->user_modification_id,
362 'date_modification' =>
dol_print_date($thirdparty->date_modification,
'dayhourrfc'),
363 'address' => $thirdparty->address,
364 'zip' => $thirdparty->zip,
365 'town' => $thirdparty->town,
366 'region_code' => $thirdparty->region_code,
367 'country_id' => $thirdparty->country_id,
368 'country_code' => $thirdparty->country_code,
369 'country' => $thirdparty->country,
370 'phone' => $thirdparty->phone,
371 'fax' => $thirdparty->fax,
372 'email' => $thirdparty->email,
373 'url' => $thirdparty->url,
374 'profid1' => $thirdparty->idprof1,
375 'profid2' => $thirdparty->idprof2,
376 'profid3' => $thirdparty->idprof3,
377 'profid4' => $thirdparty->idprof4,
378 'profid5' => $thirdparty->idprof5,
379 'profid6' => $thirdparty->idprof6,
380 'capital' => $thirdparty->capital,
381 'barcode' => $thirdparty->barcode,
382 'vat_used' => $thirdparty->tva_assuj,
383 'vat_number' => $thirdparty->tva_intra,
384 'note_private' => $thirdparty->note_private,
385 'note_public' => $thirdparty->note_public);
387 $elementtype =
'societe';
392 $extrafields->fetch_name_optionals_label($elementtype,
true);
394 $thirdparty->fetch_optionals();
396 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
397 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
398 if (isset($thirdparty->array_options[
'options_'.$key])) {
399 $thirdparty_result_fields = array_merge($thirdparty_result_fields, array(
'options_'.$key => $thirdparty->array_options[
'options_'.$key]));
406 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
407 'thirdparty' => $thirdparty_result_fields);
408 } elseif ($result == -2) {
410 $errorcode =
'DUPLICATE_FOUND';
411 $errorlabel =
'Object found several times for id='.$id.
' or ref='.$ref.
' or ref_ext='.$ref_ext;
414 $errorcode =
'NOT_FOUND';
415 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
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));
446 dol_syslog(
"Function: createThirdParty login=".$authentication[
'login']);
448 if ($authentication[
'entity']) {
449 $conf->entity = $authentication[
'entity'];
453 $objectresp = array();
459 if (empty($thirdparty[
'ref'])) {
462 $errorlabel =
"Name is mandatory.";
467 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
470 $newobject->ref = $thirdparty[
'ref'];
471 $newobject->name = $thirdparty[
'ref'];
472 $newobject->ref_ext = $thirdparty[
'ref_ext'];
473 $newobject->status = $thirdparty[
'status'];
474 $newobject->client = $thirdparty[
'client'];
475 $newobject->fournisseur = $thirdparty[
'supplier'];
476 $newobject->code_client = $thirdparty[
'customer_code'];
477 $newobject->code_fournisseur = $thirdparty[
'supplier_code'];
478 $newobject->code_compta = $thirdparty[
'customer_code_accountancy'];
479 $newobject->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
480 $newobject->date_creation = $now;
481 $newobject->note_private = $thirdparty[
'note_private'];
482 $newobject->note_public = $thirdparty[
'note_public'];
483 $newobject->address = $thirdparty[
'address'];
484 $newobject->zip = $thirdparty[
'zip'];
485 $newobject->town = $thirdparty[
'town'];
487 $newobject->country_id = $thirdparty[
'country_id'];
488 if ($thirdparty[
'country_code']) {
489 $newobject->country_id =
getCountry($thirdparty[
'country_code'], 3);
491 $newobject->region_code = empty($thirdparty[
'region_code']) ?
'' : $thirdparty[
'region_code'];
494 $newobject->phone = $thirdparty[
'phone'];
495 $newobject->fax = $thirdparty[
'fax'];
496 $newobject->email = $thirdparty[
'email'];
497 $newobject->url = $thirdparty[
'url'];
498 $newobject->idprof1 = $thirdparty[
'profid1'];
499 $newobject->idprof2 = $thirdparty[
'profid2'];
500 $newobject->idprof3 = $thirdparty[
'profid3'];
501 $newobject->idprof4 = $thirdparty[
'profid4'];
502 $newobject->idprof5 = $thirdparty[
'profid5'];
503 $newobject->idprof6 = $thirdparty[
'profid6'];
505 $newobject->capital = $thirdparty[
'capital'];
507 $newobject->barcode = empty($thirdparty[
'barcode']) ?
'' : $thirdparty[
'barcode'];
508 $newobject->tva_assuj = empty($thirdparty[
'vat_used']) ? 0 : $thirdparty[
'vat_used'];
509 $newobject->tva_intra = empty($thirdparty[
'vat_number']) ?
'' : $thirdparty[
'vat_number'];
511 $newobject->canvas = empty($thirdparty[
'canvas']) ?
'' : $thirdparty[
'canvas'];
512 $newobject->particulier = empty($thirdparty[
'individual']) ? 0 : $thirdparty[
'individual'];
514 $elementtype =
'societe';
519 $extrafields->fetch_name_optionals_label($elementtype,
true);
520 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
521 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
522 $key =
'options_'.$key;
523 if (isset($thirdparty[$key])) {
524 $newobject->array_options[$key] = $thirdparty[$key];
531 $result = $newobject->create($fuser);
532 if ($newobject->particulier && $result > 0) {
533 $newobject->firstname = $thirdparty[
'firstname'];
534 $newobject->name_bis = $thirdparty[
'lastname'];
535 $result = $newobject->create_individual($fuser);
545 if (!empty($thirdparty[
'commid']) && $thirdparty[
'commid'] > 0) {
546 $newobject->add_commercial($fuser, $thirdparty[
"commid"]);
549 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id,
'ref' => $newobject->ref);
554 $errorlabel = $newobject->error;
559 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
578 dol_syslog(
"Function: updateThirdParty login=".$authentication[
'login']);
580 if ($authentication[
'entity']) {
581 $conf->entity = $authentication[
'entity'];
585 $objectresp = array();
591 if (empty($thirdparty[
'id'])) {
594 $errorlabel =
"Thirdparty id is mandatory.";
598 $objectfound =
false;
600 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
603 $result =
$object->fetch($thirdparty[
'id']);
608 $object->ref = $thirdparty[
'ref'];
609 $object->name = $thirdparty[
'ref'];
610 $object->ref_ext = $thirdparty[
'ref_ext'];
611 $object->status = $thirdparty[
'status'];
612 $object->client = $thirdparty[
'client'];
613 $object->fournisseur = $thirdparty[
'supplier'];
614 $object->code_client = $thirdparty[
'customer_code'];
615 $object->code_fournisseur = $thirdparty[
'supplier_code'];
616 $object->code_compta = $thirdparty[
'customer_code_accountancy'];
617 $object->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
619 $object->note_private = $thirdparty[
'note_private'];
620 $object->note_public = $thirdparty[
'note_public'];
621 $object->address = $thirdparty[
'address'];
622 $object->zip = $thirdparty[
'zip'];
623 $object->town = $thirdparty[
'town'];
625 $object->country_id = $thirdparty[
'country_id'];
626 if ($thirdparty[
'country_code']) {
629 $object->region_code = $thirdparty[
'region_code'];
632 $object->phone = $thirdparty[
'phone'];
633 $object->fax = $thirdparty[
'fax'];
634 $object->email = $thirdparty[
'email'];
635 $object->url = $thirdparty[
'url'];
636 $object->idprof1 = $thirdparty[
'profid1'];
637 $object->idprof2 = $thirdparty[
'profid2'];
638 $object->idprof3 = $thirdparty[
'profid3'];
639 $object->idprof4 = $thirdparty[
'profid4'];
640 $object->idprof5 = $thirdparty[
'profid5'];
641 $object->idprof6 = $thirdparty[
'profid6'];
643 $object->capital = $thirdparty[
'capital'];
645 $object->barcode = $thirdparty[
'barcode'];
646 $object->tva_assuj = $thirdparty[
'vat_used'];
647 $object->tva_intra = $thirdparty[
'vat_number'];
649 $object->canvas = $thirdparty[
'canvas'];
651 $elementtype =
'societe';
656 $extrafields->fetch_name_optionals_label($elementtype,
true);
657 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
658 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
659 $key =
'options_'.$key;
660 if (isset($thirdparty[$key])) {
661 $object->array_options[$key] = $thirdparty[$key];
668 $result =
$object->update($thirdparty[
'id'], $fuser);
674 '@phan-var-force array{id:string} $thirdparty';
676 if ((!$error) && ($objectfound)) {
679 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
682 } elseif ($objectfound) {
689 $errorcode =
'NOT_FOUND';
690 $errorlabel =
'Thirdparty id='.$thirdparty[
'id'].
' cannot be found';
695 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
714 dol_syslog(
"Function: getListOfThirdParties login=".$authentication[
'login']);
716 if ($authentication[
'entity']) {
717 $conf->entity = $authentication[
'entity'];
721 $objectresp = array();
722 $arraythirdparties = array();
731 $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.*";
732 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
733 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON s.fk_pays = c.rowid";
734 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as extra ON s.rowid=fk_object";
736 $sql .=
" WHERE entity=".$conf->entity;
737 foreach ($filterthirdparty as $key => $val) {
738 if ($key ==
'name' && $val !=
'') {
739 $sql .=
" AND s.name LIKE '%".$db->escape($val).
"%'";
741 if ($key ==
'client' && (
int) $val > 0) {
742 $sql .=
" AND s.client = ".((int) $val);
744 if ($key ==
'supplier' && (
int) $val > 0) {
745 $sql .=
" AND s.fournisseur = ".((int) $val);
747 if ($key ==
'category' && (
int) $val > 0) {
748 $sql .=
" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe WHERE fk_categorie = ".((int) $val).
") ";
751 dol_syslog(
"Function: getListOfThirdParties", LOG_DEBUG);
753 $elementtype =
'societe';
756 $extrafields->fetch_name_optionals_label($elementtype,
true);
759 $resql = $db->query($sql);
761 $num = $db->num_rows($resql);
765 $extrafieldsOptions = array();
766 $obj = $db->fetch_object($resql);
768 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
769 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
770 if (isset($obj->{$key})) {
771 $extrafieldsOptions[
'options_'.$key] = $obj->$key;
776 $arraythirdparties[] = array(
'id' => $obj->socRowid,
778 'ref_ext' => $obj->ref_ext,
779 'address' => $obj->address,
781 'town' => $obj->town,
782 'country' => $obj->country,
783 'phone' => $obj->phone,
787 $arraythirdparties[$i] = array_merge($arraythirdparties[$i], $extrafieldsOptions);
793 $errorcode = $db->lasterrno();
794 $errorlabel = $db->lasterror();
800 'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel),
801 'thirdparties' => $arraythirdparties
805 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
806 'thirdparties' => $arraythirdparties
826 dol_syslog(
"Function: deleteThirdParty login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
828 if ($authentication[
'entity']) {
829 $conf->entity = $authentication[
'entity'];
833 $objectresp = array();
839 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
840 dol_syslog(
"Function: deleteThirdParty checkparam");
842 $errorcode =
'BAD_PARAMETERS';
843 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
850 if ($fuser->hasRight(
'societe',
'lire') && $fuser->hasRight(
'societe',
'supprimer')) {
851 $thirdparty =
new Societe($db);
852 $result = $thirdparty->fetch($id, $ref, $ref_ext);
857 $result = $thirdparty->delete($thirdparty->id, $fuser);
862 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''));
867 $errorlabel = $thirdparty->error;
868 dol_syslog(
"Function: deleteThirdParty can't delete");
872 $errorcode =
'NOT_FOUND';
873 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
877 $errorcode =
'PERMISSION_DENIED';
878 $errorlabel =
'User does not have permission for this request';
883 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
890$server->service(file_get_contents(
"php://input"));
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage third parties objects (customers, suppliers, prospects...)
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
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 dolibarr global constant string value.
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.