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';
60dol_syslog(
"Call Dolibarr webservices interfaces");
66 $langs->load(
"admin");
67 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
68 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
69 print $langs->trans(
"ToActivateModule");
74$server =
new nusoap_server();
75$server->soap_defencoding =
'UTF-8';
76$server->decode_utf8 =
false;
77$ns =
'http://www.dolibarr.org/ns/';
78$server->configureWSDL(
'WebServicesDolibarrThirdParty', $ns);
80$server->wsdl->schemaTargetNamespace = $ns;
84$server->wsdl->addComplexType(
91 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
92 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
93 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
94 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
95 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string'),
99$server->wsdl->addComplexType(
106 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
107 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
112$thirdparty_fields = array(
113 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
114 'ref' => array(
'name' =>
'name',
'type' =>
'xsd:string'),
115 'ref_ext' => array(
'name' =>
'ref_ext',
'type' =>
'xsd:string'),
116 'fk_user_author' => array(
'name' =>
'fk_user_author',
'type' =>
'xsd:string'),
117 'status' => array(
'name' =>
'status',
'type' =>
'xsd:string'),
118 'client' => array(
'name' =>
'client',
'type' =>
'xsd:string'),
119 'supplier' => array(
'name' =>
'supplier',
'type' =>
'xsd:string'),
120 'customer_code' => array(
'name' =>
'customer_code',
'type' =>
'xsd:string'),
121 'supplier_code' => array(
'name' =>
'supplier_code',
'type' =>
'xsd:string'),
122 'customer_code_accountancy' => array(
'name' =>
'customer_code_accountancy',
'type' =>
'xsd:string'),
123 'supplier_code_accountancy' => array(
'name' =>
'supplier_code_accountancy',
'type' =>
'xsd:string'),
124 'date_creation' => array(
'name' =>
'date_creation',
'type' =>
'xsd:dateTime'),
125 'date_modification' => array(
'name' =>
'date_modification',
'type' =>
'xsd:dateTime'),
126 'note_private' => array(
'name' =>
'note_private',
'type' =>
'xsd:string'),
127 'note_public' => array(
'name' =>
'note_public',
'type' =>
'xsd:string'),
128 'address' => array(
'name' =>
'address',
'type' =>
'xsd:string'),
129 'zip' => array(
'name' =>
'zip',
'type' =>
'xsd:string'),
130 'town' => array(
'name' =>
'town',
'type' =>
'xsd:string'),
131 'region_code' => array(
'name' =>
'region_code',
'type' =>
'xsd:string'),
132 'country_id' => array(
'name' =>
'country_id',
'type' =>
'xsd:string'),
133 'country_code' => array(
'name' =>
'country_code',
'type' =>
'xsd:string'),
134 'country' => array(
'name' =>
'country',
'type' =>
'xsd:string'),
135 'phone' => array(
'name' =>
'phone',
'type' =>
'xsd:string'),
136 'fax' => array(
'name' =>
'fax',
'type' =>
'xsd:string'),
137 'email' => array(
'name' =>
'email',
'type' =>
'xsd:string'),
138 'url' => array(
'name' =>
'url',
'type' =>
'xsd:string'),
139 'profid1' => array(
'name' =>
'profid1',
'type' =>
'xsd:string'),
140 'profid2' => array(
'name' =>
'profid2',
'type' =>
'xsd:string'),
141 'profid3' => array(
'name' =>
'profid3',
'type' =>
'xsd:string'),
142 'profid4' => array(
'name' =>
'profid4',
'type' =>
'xsd:string'),
143 'profid5' => array(
'name' =>
'profid5',
'type' =>
'xsd:string'),
144 'profid6' => array(
'name' =>
'profid6',
'type' =>
'xsd:string'),
145 'capital' => array(
'name' =>
'capital',
'type' =>
'xsd:string'),
146 'vat_used' => array(
'name' =>
'vat_used',
'type' =>
'xsd:string'),
147 'vat_number' => array(
'name' =>
'vat_number',
'type' =>
'xsd:string'));
149$elementtype =
'societe';
154$extrafields->fetch_name_optionals_label($elementtype,
true);
155$extrafield_array =
null;
156if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
157 $extrafield_array = array();
159if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
160 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
162 $type = $extrafields->attributes[$elementtype][
'type'][$key];
163 if ($type ==
'date' || $type ==
'datetime') {
164 $type =
'xsd:dateTime';
166 $type =
'xsd:string';
169 $extrafield_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
173if (is_array($extrafield_array)) {
174 $thirdparty_fields = array_merge($thirdparty_fields, $extrafield_array);
178$server->wsdl->addComplexType(
188$server->wsdl->addComplexType(
196 'client' => array(
'name' =>
'client',
'type' =>
'xsd:string'),
197 'supplier' => array(
'name' =>
'supplier',
'type' =>
'xsd:string'),
198 'category' => array(
'name' =>
'category',
'type' =>
'xsd:string')
202$server->wsdl->addComplexType(
210 array(
'ref' =>
'SOAP-ENC:arrayType',
'wsdl:arrayType' =>
'tns:thirdparty[]')
214$server->wsdl->addComplexType(
215 'ThirdPartiesArray2',
221 'thirdparty' => array(
222 'name' =>
'thirdparty',
223 'type' =>
'tns:thirdparty',
225 'maxOccurs' =>
'unbounded'
235$styleuse =
'encoded';
242 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string',
'barcode' =>
'xsd:string',
'profid1' =>
'xsd:string',
'profid2' =>
'xsd:string'),
244 array(
'result' =>
'tns:result',
'thirdparty' =>
'tns:thirdparty'),
246 $ns.
'#getThirdParty',
249 'WS to get a thirdparty from its id, ref or ref_ext'
256 array(
'authentication' =>
'tns:authentication',
'thirdparty' =>
'tns:thirdparty'),
258 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string'),
260 $ns.
'#createThirdParty',
263 'WS to create a thirdparty'
270 array(
'authentication' =>
'tns:authentication',
'thirdparty' =>
'tns:thirdparty'),
272 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
274 $ns.
'#updateThirdParty',
277 'WS to update a thirdparty'
283 'getListOfThirdParties',
285 array(
'authentication' =>
'tns:authentication',
'filterthirdparty' =>
'tns:filterthirdparty'),
287 array(
'result' =>
'tns:result',
'thirdparties' =>
'tns:ThirdPartiesArray2'),
289 $ns.
'#getListOfThirdParties',
292 'WS to get list of thirdparties id and ref'
299 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
301 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
303 $ns.
'#deleteThirdParty',
306 'WS to delete a thirdparty from its id, ref or ref_ext'
323function getThirdParty($authentication,
$id =
'', $ref =
'', $ref_ext =
'', $barcode =
'', $profid1 =
'', $profid2 =
'')
327 dol_syslog(
"Function: getThirdParty login=".$authentication[
'login'].
" id=".
$id.
" ref=".$ref.
" ref_ext=".$ref_ext.
" barcode=".$barcode.
" profid1=".$profid1.
" profid2=".$profid2);
329 if ($authentication[
'entity']) {
330 $conf->entity = $authentication[
'entity'];
334 $objectresp = array();
340 if (!$error && ((
$id && $ref) || (
$id && $ref_ext) || ($ref && $ref_ext))) {
342 $errorcode =
'BAD_PARAMETERS';
343 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
347 $fuser->loadRights();
349 if ($fuser->hasRight(
'societe',
'lire')) {
350 $thirdparty =
new Societe($db);
351 $result = $thirdparty->fetch((
int)
$id, $ref, $ref_ext, $barcode, $profid1, $profid2);
353 $thirdparty_result_fields = array(
354 'id' => $thirdparty->id,
355 'ref' => $thirdparty->name,
356 'ref_ext' => $thirdparty->ref_ext,
357 'status' => $thirdparty->status,
358 'client' => $thirdparty->client,
359 'supplier' => $thirdparty->fournisseur,
360 'customer_code' => $thirdparty->code_client,
361 'supplier_code' => $thirdparty->code_fournisseur,
362 'customer_code_accountancy' => $thirdparty->code_compta_client,
363 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur,
364 'user_creation_id' => $thirdparty->user_creation_id,
365 'date_creation' =>
dol_print_date($thirdparty->date_creation,
'dayhourrfc'),
366 'user_modification_id' => $thirdparty->user_modification_id,
367 'date_modification' =>
dol_print_date($thirdparty->date_modification,
'dayhourrfc'),
368 'address' => $thirdparty->address,
369 'zip' => $thirdparty->zip,
370 'town' => $thirdparty->town,
371 'region_code' => $thirdparty->region_code,
372 'country_id' => $thirdparty->country_id,
373 'country_code' => $thirdparty->country_code,
374 'country' => $thirdparty->country,
375 'phone' => $thirdparty->phone,
376 'fax' => $thirdparty->fax,
377 'email' => $thirdparty->email,
378 'url' => $thirdparty->url,
379 'profid1' => $thirdparty->idprof1,
380 'profid2' => $thirdparty->idprof2,
381 'profid3' => $thirdparty->idprof3,
382 'profid4' => $thirdparty->idprof4,
383 'profid5' => $thirdparty->idprof5,
384 'profid6' => $thirdparty->idprof6,
385 'capital' => $thirdparty->capital,
386 'barcode' => $thirdparty->barcode,
387 'vat_used' => $thirdparty->tva_assuj,
388 'vat_number' => $thirdparty->tva_intra,
389 'note_private' => $thirdparty->note_private,
390 'note_public' => $thirdparty->note_public);
392 $elementtype =
'societe';
397 $extrafields->fetch_name_optionals_label($elementtype,
true);
399 $thirdparty->fetch_optionals();
401 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
402 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
403 if (isset($thirdparty->array_options[
'options_'.$key])) {
404 $thirdparty_result_fields = array_merge($thirdparty_result_fields, array(
'options_'.$key => $thirdparty->array_options[
'options_'.$key]));
411 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
412 'thirdparty' => $thirdparty_result_fields);
413 } elseif ($result == -2) {
415 $errorcode =
'DUPLICATE_FOUND';
416 $errorlabel =
'Object found several times for id='.$id.
' or ref='.$ref.
' or ref_ext='.$ref_ext;
419 $errorcode =
'NOT_FOUND';
420 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
424 $errorcode =
'PERMISSION_DENIED';
425 $errorlabel =
'User does not have permission for this request';
430 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
451 dol_syslog(
"Function: createThirdParty login=".$authentication[
'login']);
453 if ($authentication[
'entity']) {
454 $conf->entity = $authentication[
'entity'];
458 $objectresp = array();
464 if (empty($thirdparty[
'ref'])) {
467 $errorlabel =
"Name is mandatory.";
472 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
475 $newobject->ref = $thirdparty[
'ref'];
476 $newobject->name = $thirdparty[
'ref'];
477 $newobject->ref_ext = $thirdparty[
'ref_ext'];
478 $newobject->status = (int) $thirdparty[
'status'];
479 $newobject->client = (int) $thirdparty[
'client'];
480 $newobject->fournisseur = (int) $thirdparty[
'supplier'];
481 $newobject->code_client = $thirdparty[
'customer_code'];
482 $newobject->code_fournisseur = $thirdparty[
'supplier_code'];
483 $newobject->code_compta = $thirdparty[
'customer_code_accountancy'];
484 $newobject->code_compta_client = $thirdparty[
'customer_code_accountancy'];
485 $newobject->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
486 $newobject->date_creation = $now;
487 $newobject->note_private = $thirdparty[
'note_private'];
488 $newobject->note_public = $thirdparty[
'note_public'];
489 $newobject->address = $thirdparty[
'address'];
490 $newobject->zip = $thirdparty[
'zip'];
491 $newobject->town = $thirdparty[
'town'];
493 $newobject->country_id = (int) $thirdparty[
'country_id'];
494 if ($thirdparty[
'country_code']) {
495 $newobject->country_id =
getCountry($thirdparty[
'country_code'],
'3');
497 $newobject->region_code = empty($thirdparty[
'region_code']) ?
'' : $thirdparty[
'region_code'];
500 $newobject->phone = $thirdparty[
'phone'];
501 $newobject->fax = $thirdparty[
'fax'];
502 $newobject->email = $thirdparty[
'email'];
503 $newobject->url = $thirdparty[
'url'];
504 $newobject->idprof1 = $thirdparty[
'profid1'];
505 $newobject->idprof2 = $thirdparty[
'profid2'];
506 $newobject->idprof3 = $thirdparty[
'profid3'];
507 $newobject->idprof4 = $thirdparty[
'profid4'];
508 $newobject->idprof5 = $thirdparty[
'profid5'];
509 $newobject->idprof6 = $thirdparty[
'profid6'];
511 $newobject->capital = (float) $thirdparty[
'capital'];
513 $newobject->barcode = !isset($thirdparty[
'barcode']) ?
'' : $thirdparty[
'barcode'];
514 $newobject->tva_assuj = empty($thirdparty[
'vat_used']) ? 0 : $thirdparty[
'vat_used'];
515 $newobject->tva_intra = empty($thirdparty[
'vat_number']) ?
'' : $thirdparty[
'vat_number'];
517 $newobject->canvas = !isset($thirdparty[
'canvas']) ?
'' : $thirdparty[
'canvas'];
518 $newobject->particulier = empty($thirdparty[
'individual']) ? 0 : $thirdparty[
'individual'];
520 $elementtype =
'societe';
525 $extrafields->fetch_name_optionals_label($elementtype,
true);
526 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
527 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
528 $key =
'options_'.$key;
529 if (isset($thirdparty[$key])) {
530 $newobject->array_options[$key] = $thirdparty[$key];
537 $result = $newobject->create($fuser);
538 if ($newobject->particulier && $result > 0) {
539 $newobject->firstname = isset($thirdparty[
'firstname']) ? $thirdparty[
'firstname'] :
'';
540 $newobject->name_bis = isset($thirdparty[
'lastname']) ? $thirdparty[
'lastname'] :
'';
541 $result = $newobject->create_individual($fuser);
551 if (isset($thirdparty[
'commid']) && $thirdparty[
'commid'] > 0) {
552 $newobject->add_commercial($fuser, $thirdparty[
'commid']);
555 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id,
'ref' => $newobject->ref);
560 $errorlabel = $newobject->error;
565 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
584 dol_syslog(
"Function: updateThirdParty login=".$authentication[
'login']);
586 if ($authentication[
'entity']) {
587 $conf->entity = $authentication[
'entity'];
591 $objectresp = array();
597 if (empty($thirdparty[
'id'])) {
600 $errorlabel =
"Thirdparty id is mandatory.";
604 $objectfound =
false;
606 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
609 $result =
$object->fetch((
int) $thirdparty[
'id']);
614 $object->ref = $thirdparty[
'ref'];
615 $object->name = $thirdparty[
'ref'];
616 $object->ref_ext = $thirdparty[
'ref_ext'];
617 $object->status = (int) $thirdparty[
'status'];
618 $object->client = (int) $thirdparty[
'client'];
619 $object->fournisseur = (int) $thirdparty[
'supplier'];
620 $object->code_client = $thirdparty[
'customer_code'];
621 $object->code_fournisseur = $thirdparty[
'supplier_code'];
622 $object->code_compta = $thirdparty[
'customer_code_accountancy'];
623 $object->code_compta_client = $thirdparty[
'customer_code_accountancy'];
624 $object->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
626 $object->note_private = $thirdparty[
'note_private'];
627 $object->note_public = $thirdparty[
'note_public'];
628 $object->address = $thirdparty[
'address'];
629 $object->zip = $thirdparty[
'zip'];
630 $object->town = $thirdparty[
'town'];
632 $object->country_id = (int) $thirdparty[
'country_id'];
633 if ($thirdparty[
'country_code']) {
636 $object->region_code = $thirdparty[
'region_code'];
639 $object->phone = $thirdparty[
'phone'];
640 $object->fax = $thirdparty[
'fax'];
641 $object->email = $thirdparty[
'email'];
642 $object->url = $thirdparty[
'url'];
643 $object->idprof1 = $thirdparty[
'profid1'];
644 $object->idprof2 = $thirdparty[
'profid2'];
645 $object->idprof3 = $thirdparty[
'profid3'];
646 $object->idprof4 = $thirdparty[
'profid4'];
647 $object->idprof5 = $thirdparty[
'profid5'];
648 $object->idprof6 = $thirdparty[
'profid6'];
650 $object->capital = (float) $thirdparty[
'capital'];
652 $object->barcode = !isset($thirdparty[
'barcode']) ?
'' : $thirdparty[
'barcode'];
653 $object->tva_assuj = (int) $thirdparty[
'vat_used'];
654 $object->tva_intra = $thirdparty[
'vat_number'];
656 $object->canvas = !isset($thirdparty[
'canvas']) ?
'' : $thirdparty[
'canvas'];
658 $elementtype =
'societe';
663 $extrafields->fetch_name_optionals_label($elementtype,
true);
664 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
665 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
666 $key =
'options_'.$key;
667 if (isset($thirdparty[$key])) {
668 $object->array_options[$key] = $thirdparty[$key];
675 $result =
$object->update((
int) $thirdparty[
'id'], $fuser);
681 '@phan-var-force array{id:string} $thirdparty';
683 if ((!$error) && ($objectfound)) {
686 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
689 } elseif ($objectfound) {
696 $errorcode =
'NOT_FOUND';
697 $errorlabel =
'Thirdparty id='.$thirdparty[
'id'].
' cannot be found';
702 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
721 dol_syslog(
"Function: getListOfThirdParties login=".$authentication[
'login']);
723 if ($authentication[
'entity']) {
724 $conf->entity = $authentication[
'entity'];
728 $objectresp = array();
729 $arraythirdparties = array();
738 $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.*";
739 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
740 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON s.fk_pays = c.rowid";
741 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as extra ON s.rowid=fk_object";
743 $sql .=
" WHERE entity=".$conf->entity;
744 foreach ($filterthirdparty as $key => $val) {
745 if ($key ==
'name' && $val !=
'') {
746 $sql .=
" AND s.name LIKE '%".$db->escape($val).
"%'";
748 if ($key ==
'client' && (
int) $val > 0) {
749 $sql .=
" AND s.client = ".((int) $val);
751 if ($key ==
'supplier' && (
int) $val > 0) {
752 $sql .=
" AND s.fournisseur = ".((int) $val);
754 if ($key ==
'category' && (
int) $val > 0) {
755 $sql .=
" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe WHERE fk_categorie = ".((int) $val).
") ";
758 dol_syslog(
"Function: getListOfThirdParties", LOG_DEBUG);
760 $elementtype =
'societe';
763 $extrafields->fetch_name_optionals_label($elementtype,
true);
766 $resql = $db->query($sql);
768 $num = $db->num_rows($resql);
772 $extrafieldsOptions = array();
773 $obj = $db->fetch_object($resql);
775 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
776 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
777 if (isset($obj->{$key})) {
778 $extrafieldsOptions[
'options_'.$key] = $obj->$key;
783 $arraythirdparties[] = array(
'id' => $obj->socRowid,
785 'ref_ext' => $obj->ref_ext,
786 'address' => $obj->address,
788 'town' => $obj->town,
789 'country' => $obj->country,
790 'phone' => $obj->phone,
794 $arraythirdparties[$i] = array_merge($arraythirdparties[$i], $extrafieldsOptions);
800 $errorcode = $db->lasterrno();
801 $errorlabel = $db->lasterror();
807 'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel),
808 'thirdparties' => $arraythirdparties
812 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
813 'thirdparties' => $arraythirdparties
833 dol_syslog(
"Function: deleteThirdParty login=".$authentication[
'login'].
" id=".
$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
835 if ($authentication[
'entity']) {
836 $conf->entity = $authentication[
'entity'];
840 $objectresp = array();
846 if (!$error && ((
$id && $ref) || (
$id && $ref_ext) || ($ref && $ref_ext))) {
847 dol_syslog(
"Function: deleteThirdParty checkparam");
849 $errorcode =
'BAD_PARAMETERS';
850 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
855 $fuser->loadRights();
857 if ($fuser->hasRight(
'societe',
'lire') && $fuser->hasRight(
'societe',
'supprimer')) {
858 $thirdparty =
new Societe($db);
859 $result = $thirdparty->fetch((
int)
$id, $ref, $ref_ext);
864 $result = $thirdparty->delete($thirdparty->id, $fuser);
869 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''));
874 $errorlabel = $thirdparty->error;
875 dol_syslog(
"Function: deleteThirdParty can't delete");
879 $errorcode =
'NOT_FOUND';
880 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
884 $errorcode =
'PERMISSION_DENIED';
885 $errorlabel =
'User does not have permission for this request';
890 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
897$server->service(file_get_contents(
"php://input"));
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a 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.