23if (!defined(
'NOCSRFCHECK')) {
24 define(
'NOCSRFCHECK',
'1');
26if (!defined(
'NOTOKENRENEWAL')) {
27 define(
'NOTOKENRENEWAL',
'1');
29if (!defined(
'NOREQUIREMENU')) {
30 define(
'NOREQUIREMENU',
'1');
32if (!defined(
'NOREQUIREHTML')) {
33 define(
'NOREQUIREHTML',
'1');
35if (!defined(
'NOREQUIREAJAX')) {
36 define(
'NOREQUIREAJAX',
'1');
38if (!defined(
"NOLOGIN")) {
39 define(
"NOLOGIN",
'1');
41if (!defined(
"NOSESSION")) {
42 define(
"NOSESSION",
'1');
45require
'../main.inc.php';
46require_once NUSOAP_PATH.
'/nusoap.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
54dol_syslog(
"Call Dolibarr webservices interfaces");
60 $langs->load(
"admin");
61 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
62 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
63 print $langs->trans(
"ToActivateModule");
68$server =
new nusoap_server();
69$server->soap_defencoding =
'UTF-8';
70$server->decode_utf8 =
false;
71$ns =
'http://www.dolibarr.org/ns/';
72$server->configureWSDL(
'WebServicesDolibarrThirdParty', $ns);
73$server->wsdl->schemaTargetNamespace = $ns;
77$server->wsdl->addComplexType(
84 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
85 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
86 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
87 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
88 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
92$server->wsdl->addComplexType(
99 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
100 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
105$thirdparty_fields = array(
106 'id' => array(
'name'=>
'id',
'type'=>
'xsd:string'),
107 'ref' => array(
'name'=>
'name',
'type'=>
'xsd:string'),
108 'ref_ext' => array(
'name'=>
'ref_ext',
'type'=>
'xsd:string'),
109 'fk_user_author' => array(
'name'=>
'fk_user_author',
'type'=>
'xsd:string'),
110 'status' => array(
'name'=>
'status',
'type'=>
'xsd:string'),
111 'client' => array(
'name'=>
'client',
'type'=>
'xsd:string'),
112 'supplier' => array(
'name'=>
'supplier',
'type'=>
'xsd:string'),
113 'customer_code' => array(
'name'=>
'customer_code',
'type'=>
'xsd:string'),
114 'supplier_code' => array(
'name'=>
'supplier_code',
'type'=>
'xsd:string'),
115 'customer_code_accountancy' => array(
'name'=>
'customer_code_accountancy',
'type'=>
'xsd:string'),
116 'supplier_code_accountancy' => array(
'name'=>
'supplier_code_accountancy',
'type'=>
'xsd:string'),
117 'date_creation' => array(
'name'=>
'date_creation',
'type'=>
'xsd:dateTime'),
118 'date_modification' => array(
'name'=>
'date_modification',
'type'=>
'xsd:dateTime'),
119 'note_private' => array(
'name'=>
'note_private',
'type'=>
'xsd:string'),
120 'note_public' => array(
'name'=>
'note_public',
'type'=>
'xsd:string'),
121 'address' => array(
'name'=>
'address',
'type'=>
'xsd:string'),
122 'zip' => array(
'name'=>
'zip',
'type'=>
'xsd:string'),
123 'town' => array(
'name'=>
'town',
'type'=>
'xsd:string'),
124 'region_code' => array(
'name'=>
'region_code',
'type'=>
'xsd:string'),
125 'country_id' => array(
'name'=>
'country_id',
'type'=>
'xsd:string'),
126 'country_code' => array(
'name'=>
'country_code',
'type'=>
'xsd:string'),
127 'country' => array(
'name'=>
'country',
'type'=>
'xsd:string'),
128 'phone' => array(
'name'=>
'phone',
'type'=>
'xsd:string'),
129 'fax' => array(
'name'=>
'fax',
'type'=>
'xsd:string'),
130 'email' => array(
'name'=>
'email',
'type'=>
'xsd:string'),
131 'url' => array(
'name'=>
'url',
'type'=>
'xsd:string'),
132 'profid1' => array(
'name'=>
'profid1',
'type'=>
'xsd:string'),
133 'profid2' => array(
'name'=>
'profid2',
'type'=>
'xsd:string'),
134 'profid3' => array(
'name'=>
'profid3',
'type'=>
'xsd:string'),
135 'profid4' => array(
'name'=>
'profid4',
'type'=>
'xsd:string'),
136 'profid5' => array(
'name'=>
'profid5',
'type'=>
'xsd:string'),
137 'profid6' => array(
'name'=>
'profid6',
'type'=>
'xsd:string'),
138 'capital' => array(
'name'=>
'capital',
'type'=>
'xsd:string'),
139 'vat_used' => array(
'name'=>
'vat_used',
'type'=>
'xsd:string'),
140 'vat_number' => array(
'name'=>
'vat_number',
'type'=>
'xsd:string'));
142$elementtype =
'societe';
147$extrafields->fetch_name_optionals_label($elementtype,
true);
148$extrafield_array =
null;
149if (is_array($extrafields) && count($extrafields) > 0) {
150 $extrafield_array = array();
152if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
153 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
155 $type = $extrafields->attributes[$elementtype][
'type'][$key];
156 if ($type ==
'date' || $type ==
'datetime') {
157 $type =
'xsd:dateTime';
159 $type =
'xsd:string';
162 $extrafield_array[
'options_'.$key] = array(
'name'=>
'options_'.$key,
'type'=>$type);
166if (is_array($extrafield_array)) {
167 $thirdparty_fields = array_merge($thirdparty_fields, $extrafield_array);
171$server->wsdl->addComplexType(
181$server->wsdl->addComplexType(
189 'client' => array(
'name'=>
'client',
'type'=>
'xsd:string'),
190 'supplier' => array(
'name'=>
'supplier',
'type'=>
'xsd:string'),
191 'category' => array(
'name'=>
'category',
'type'=>
'xsd:string')
195$server->wsdl->addComplexType(
203 array(
'ref'=>
'SOAP-ENC:arrayType',
'wsdl:arrayType'=>
'tns:thirdparty[]')
207$server->wsdl->addComplexType(
208 'ThirdPartiesArray2',
214 'thirdparty' => array(
215 'name' =>
'thirdparty',
216 'type' =>
'tns:thirdparty',
218 'maxOccurs' =>
'unbounded'
228$styleuse =
'encoded';
235 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string',
'barcode'=>
'xsd:string',
'profid1'=>
'xsd:string',
'profid2'=>
'xsd:string'),
237 array(
'result'=>
'tns:result',
'thirdparty'=>
'tns:thirdparty'),
239 $ns.
'#getThirdParty',
242 'WS to get a thirdparty from its id, ref or ref_ext'
249 array(
'authentication'=>
'tns:authentication',
'thirdparty'=>
'tns:thirdparty'),
251 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string'),
253 $ns.
'#createThirdParty',
256 'WS to create a thirdparty'
263 array(
'authentication'=>
'tns:authentication',
'thirdparty'=>
'tns:thirdparty'),
265 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
267 $ns.
'#updateThirdParty',
270 'WS to update a thirdparty'
276 'getListOfThirdParties',
278 array(
'authentication'=>
'tns:authentication',
'filterthirdparty'=>
'tns:filterthirdparty'),
280 array(
'result'=>
'tns:result',
'thirdparties'=>
'tns:ThirdPartiesArray2'),
282 $ns.
'#getListOfThirdParties',
285 'WS to get list of thirdparties id and ref'
292 array(
'authentication'=>
'tns:authentication',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
294 array(
'result'=>
'tns:result',
'id'=>
'xsd:string'),
296 $ns.
'#deleteThirdParty',
299 'WS to delete a thirdparty from its id, ref or ref_ext'
316function getThirdParty($authentication, $id =
'', $ref =
'', $ref_ext =
'', $barcode =
'', $profid1 =
'', $profid2 =
'')
320 dol_syslog(
"Function: getThirdParty login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext.
" barcode=".$barcode.
" profid1=".$profid1.
" profid2=".$profid2);
322 if ($authentication[
'entity']) {
323 $conf->entity = $authentication[
'entity'];
327 $objectresp = array();
333 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
335 $errorcode =
'BAD_PARAMETERS';
336 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
342 if ($fuser->hasRight(
'societe',
'lire')) {
343 $thirdparty =
new Societe($db);
344 $result = $thirdparty->fetch($id, $ref, $ref_ext, $barcode, $profid1, $profid2);
346 $thirdparty_result_fields = array(
347 'id' => $thirdparty->id,
348 'ref' => $thirdparty->name,
349 'ref_ext' => $thirdparty->ref_ext,
350 'status' => $thirdparty->status,
351 'client' => $thirdparty->client,
352 'supplier' => $thirdparty->fournisseur,
353 'customer_code' => $thirdparty->code_client,
354 'supplier_code' => $thirdparty->code_fournisseur,
355 'customer_code_accountancy' => $thirdparty->code_compta_client,
356 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur,
357 'user_creation_id' => $thirdparty->user_creation_id,
358 'date_creation' =>
dol_print_date($thirdparty->date_creation,
'dayhourrfc'),
359 'user_modification_id' => $thirdparty->user_modification_id,
360 'date_modification' =>
dol_print_date($thirdparty->date_modification,
'dayhourrfc'),
361 'address' => $thirdparty->address,
362 'zip' => $thirdparty->zip,
363 'town' => $thirdparty->town,
364 'region_code' => $thirdparty->region_code,
365 'country_id' => $thirdparty->country_id,
366 'country_code' => $thirdparty->country_code,
367 'country' => $thirdparty->country,
368 'phone' => $thirdparty->phone,
369 'fax' => $thirdparty->fax,
370 'email' => $thirdparty->email,
371 'url' => $thirdparty->url,
372 'profid1' => $thirdparty->idprof1,
373 'profid2' => $thirdparty->idprof2,
374 'profid3' => $thirdparty->idprof3,
375 'profid4' => $thirdparty->idprof4,
376 'profid5' => $thirdparty->idprof5,
377 'profid6' => $thirdparty->idprof6,
378 'capital' => $thirdparty->capital,
379 'barcode' => $thirdparty->barcode,
380 'vat_used' => $thirdparty->tva_assuj,
381 'vat_number' => $thirdparty->tva_intra,
382 'note_private' => $thirdparty->note_private,
383 'note_public' => $thirdparty->note_public);
385 $elementtype =
'societe';
390 $extrafields->fetch_name_optionals_label($elementtype,
true);
392 $thirdparty->fetch_optionals();
394 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
395 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
396 if (isset($thirdparty->array_options[
'options_'.$key])) {
397 $thirdparty_result_fields = array_merge($thirdparty_result_fields, array(
'options_'.$key => $thirdparty->array_options[
'options_'.$key]));
404 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
405 'thirdparty'=>$thirdparty_result_fields);
406 } elseif ($result == -2) {
408 $errorcode =
'DUPLICATE_FOUND';
409 $errorlabel =
'Object found several times for id='.$id.
' or ref='.$ref.
' or ref_ext='.$ref_ext;
412 $errorcode =
'NOT_FOUND';
413 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
417 $errorcode =
'PERMISSION_DENIED';
418 $errorlabel =
'User does not have permission for this request';
423 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
444 dol_syslog(
"Function: createThirdParty login=".$authentication[
'login']);
446 if ($authentication[
'entity']) {
447 $conf->entity = $authentication[
'entity'];
451 $objectresp = array();
457 if (empty($thirdparty[
'ref'])) {
460 $errorlabel =
"Name is mandatory.";
465 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
468 $newobject->ref = $thirdparty[
'ref'];
469 $newobject->name = $thirdparty[
'ref'];
470 $newobject->ref_ext = $thirdparty[
'ref_ext'];
471 $newobject->status = $thirdparty[
'status'];
472 $newobject->client = $thirdparty[
'client'];
473 $newobject->fournisseur = $thirdparty[
'supplier'];
474 $newobject->code_client = $thirdparty[
'customer_code'];
475 $newobject->code_fournisseur = $thirdparty[
'supplier_code'];
476 $newobject->code_compta = $thirdparty[
'customer_code_accountancy'];
477 $newobject->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
478 $newobject->date_creation = $now;
479 $newobject->note_private = $thirdparty[
'note_private'];
480 $newobject->note_public = $thirdparty[
'note_public'];
481 $newobject->address = $thirdparty[
'address'];
482 $newobject->zip = $thirdparty[
'zip'];
483 $newobject->town = $thirdparty[
'town'];
485 $newobject->country_id = $thirdparty[
'country_id'];
486 if ($thirdparty[
'country_code']) {
487 $newobject->country_id =
getCountry($thirdparty[
'country_code'], 3);
489 $newobject->region_code = empty($thirdparty[
'region_code']) ?
'' : $thirdparty[
'region_code'];
492 $newobject->phone = $thirdparty[
'phone'];
493 $newobject->fax = $thirdparty[
'fax'];
494 $newobject->email = $thirdparty[
'email'];
495 $newobject->url = $thirdparty[
'url'];
496 $newobject->idprof1 = $thirdparty[
'profid1'];
497 $newobject->idprof2 = $thirdparty[
'profid2'];
498 $newobject->idprof3 = $thirdparty[
'profid3'];
499 $newobject->idprof4 = $thirdparty[
'profid4'];
500 $newobject->idprof5 = $thirdparty[
'profid5'];
501 $newobject->idprof6 = $thirdparty[
'profid6'];
503 $newobject->capital = $thirdparty[
'capital'];
505 $newobject->barcode = empty($thirdparty[
'barcode']) ?
'' : $thirdparty[
'barcode'];
506 $newobject->tva_assuj = empty($thirdparty[
'vat_used']) ? 0 : $thirdparty[
'vat_used'];
507 $newobject->tva_intra = empty($thirdparty[
'vat_number']) ?
'' : $thirdparty[
'vat_number'];
509 $newobject->canvas = empty($thirdparty[
'canvas']) ?
'' : $thirdparty[
'canvas'];
510 $newobject->particulier = empty($thirdparty[
'individual']) ? 0 : $thirdparty[
'individual'];
512 $elementtype =
'societe';
517 $extrafields->fetch_name_optionals_label($elementtype,
true);
518 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
519 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
520 $key =
'options_'.$key;
521 if (isset($thirdparty[$key])) {
522 $newobject->array_options[$key] = $thirdparty[$key];
529 $result = $newobject->create($fuser);
530 if ($newobject->particulier && $result > 0) {
531 $newobject->firstname = $thirdparty[
'firstname'];
532 $newobject->name_bis = $thirdparty[
'lastname'];
533 $result = $newobject->create_individual($fuser);
543 if (!empty($thirdparty[
'commid']) && $thirdparty[
'commid'] > 0) {
544 $newobject->add_commercial($fuser, $thirdparty[
"commid"]);
547 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$newobject->id,
'ref'=>$newobject->ref);
552 $errorlabel = $newobject->error;
557 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
576 dol_syslog(
"Function: updateThirdParty login=".$authentication[
'login']);
578 if ($authentication[
'entity']) {
579 $conf->entity = $authentication[
'entity'];
583 $objectresp = array();
589 if (empty($thirdparty[
'id'])) {
592 $errorlabel =
"Thirdparty id is mandatory.";
596 $objectfound =
false;
598 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
601 $result = $object->fetch($thirdparty[
'id']);
603 if (!empty($object->id)) {
606 $object->ref = $thirdparty[
'ref'];
607 $object->name = $thirdparty[
'ref'];
608 $object->ref_ext = $thirdparty[
'ref_ext'];
609 $object->status = $thirdparty[
'status'];
610 $object->client = $thirdparty[
'client'];
611 $object->fournisseur = $thirdparty[
'supplier'];
612 $object->code_client = $thirdparty[
'customer_code'];
613 $object->code_fournisseur = $thirdparty[
'supplier_code'];
614 $object->code_compta = $thirdparty[
'customer_code_accountancy'];
615 $object->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
616 $object->date_creation = $now;
617 $object->note_private = $thirdparty[
'note_private'];
618 $object->note_public = $thirdparty[
'note_public'];
619 $object->address = $thirdparty[
'address'];
620 $object->zip = $thirdparty[
'zip'];
621 $object->town = $thirdparty[
'town'];
623 $object->country_id = $thirdparty[
'country_id'];
624 if ($thirdparty[
'country_code']) {
625 $object->country_id =
getCountry($thirdparty[
'country_code'], 3);
627 $object->region_code = $thirdparty[
'region_code'];
630 $object->phone = $thirdparty[
'phone'];
631 $object->fax = $thirdparty[
'fax'];
632 $object->email = $thirdparty[
'email'];
633 $object->url = $thirdparty[
'url'];
634 $object->idprof1 = $thirdparty[
'profid1'];
635 $object->idprof2 = $thirdparty[
'profid2'];
636 $object->idprof3 = $thirdparty[
'profid3'];
637 $object->idprof4 = $thirdparty[
'profid4'];
638 $object->idprof5 = $thirdparty[
'profid5'];
639 $object->idprof6 = $thirdparty[
'profid6'];
641 $object->capital = $thirdparty[
'capital'];
643 $object->barcode = $thirdparty[
'barcode'];
644 $object->tva_assuj = $thirdparty[
'vat_used'];
645 $object->tva_intra = $thirdparty[
'vat_number'];
647 $object->canvas = $thirdparty[
'canvas'];
649 $elementtype =
'societe';
654 $extrafields->fetch_name_optionals_label($elementtype,
true);
655 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
656 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
657 $key =
'options_'.$key;
658 if (isset($thirdparty[$key])) {
659 $object->array_options[$key] = $thirdparty[$key];
666 $result = $object->update($thirdparty[
'id'], $fuser);
672 if ((!$error) && ($objectfound)) {
675 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
678 } elseif ($objectfound) {
682 $errorlabel = $object->error;
685 $errorcode =
'NOT_FOUND';
686 $errorlabel =
'Thirdparty id='.$thirdparty[
'id'].
' cannot be found';
691 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
710 dol_syslog(
"Function: getListOfThirdParties login=".$authentication[
'login']);
712 if ($authentication[
'entity']) {
713 $conf->entity = $authentication[
'entity'];
717 $objectresp = array();
718 $arraythirdparties = array();
727 $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.*";
728 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
729 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON s.fk_pays = c.rowid";
730 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as extra ON s.rowid=fk_object";
732 $sql .=
" WHERE entity=".$conf->entity;
733 foreach ($filterthirdparty as $key => $val) {
734 if ($key ==
'name' && $val !=
'') {
735 $sql .=
" AND s.name LIKE '%".$db->escape($val).
"%'";
737 if ($key ==
'client' && (
int) $val > 0) {
738 $sql .=
" AND s.client = ".((int) $val);
740 if ($key ==
'supplier' && (
int) $val > 0) {
741 $sql .=
" AND s.fournisseur = ".((int) $val);
743 if ($key ==
'category' && (
int) $val > 0) {
744 $sql .=
" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe WHERE fk_categorie = ".((int) $val).
") ";
747 dol_syslog(
"Function: getListOfThirdParties", LOG_DEBUG);
749 $elementtype =
'societe';
752 $extrafields->fetch_name_optionals_label($elementtype,
true);
755 $resql = $db->query($sql);
757 $num = $db->num_rows($resql);
761 $extrafieldsOptions = array();
762 $obj = $db->fetch_object($resql);
764 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
765 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
766 if (isset($obj->{$key})) {
767 $extrafieldsOptions[
'options_'.$key] = $obj->$key;
772 $arraythirdparties[] = array(
'id'=>$obj->socRowid,
774 'ref_ext'=>$obj->ref_ext,
775 'adress'=>$obj->adress,
778 'country'=>$obj->country,
779 'phone'=>$obj->phone,
783 $arraythirdparties[$i] = array_merge($arraythirdparties[$i], $extrafieldsOptions);
789 $errorcode = $db->lasterrno();
790 $errorlabel = $db->lasterror();
796 'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel),
797 'thirdparties'=>$arraythirdparties
801 'result'=>array(
'result_code' =>
'OK',
'result_label' =>
''),
802 'thirdparties'=>$arraythirdparties
822 dol_syslog(
"Function: deleteThirdParty login=".$authentication[
'login'].
" id=".$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
824 if ($authentication[
'entity']) {
825 $conf->entity = $authentication[
'entity'];
829 $objectresp = array();
835 if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
836 dol_syslog(
"Function: deleteThirdParty checkparam");
838 $errorcode =
'BAD_PARAMETERS';
839 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
846 if ($fuser->hasRight(
'societe',
'lire') && $fuser->hasRight(
'societe',
'supprimer')) {
847 $thirdparty =
new Societe($db);
848 $result = $thirdparty->fetch($id, $ref, $ref_ext);
853 $result = $thirdparty->delete($thirdparty->id, $fuser);
858 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''));
863 $errorlabel = $thirdparty->error;
864 dol_syslog(
"Function: deleteThirdParty cant delete");
868 $errorcode =
'NOT_FOUND';
869 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
873 $errorcode =
'PERMISSION_DENIED';
874 $errorlabel =
'User does not have permission for this request';
879 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
886$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.
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.
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.