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.";
342 $fuser->loadRights();
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_client = $thirdparty[
'customer_code_accountancy'];
480 $newobject->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
481 $newobject->date_creation = $now;
482 $newobject->note_private = $thirdparty[
'note_private'];
483 $newobject->note_public = $thirdparty[
'note_public'];
484 $newobject->address = $thirdparty[
'address'];
485 $newobject->zip = $thirdparty[
'zip'];
486 $newobject->town = $thirdparty[
'town'];
488 $newobject->country_id = $thirdparty[
'country_id'];
489 if ($thirdparty[
'country_code']) {
490 $newobject->country_id =
getCountry($thirdparty[
'country_code'],
'3');
492 $newobject->region_code = empty($thirdparty[
'region_code']) ?
'' : $thirdparty[
'region_code'];
495 $newobject->phone = $thirdparty[
'phone'];
496 $newobject->fax = $thirdparty[
'fax'];
497 $newobject->email = $thirdparty[
'email'];
498 $newobject->url = $thirdparty[
'url'];
499 $newobject->idprof1 = $thirdparty[
'profid1'];
500 $newobject->idprof2 = $thirdparty[
'profid2'];
501 $newobject->idprof3 = $thirdparty[
'profid3'];
502 $newobject->idprof4 = $thirdparty[
'profid4'];
503 $newobject->idprof5 = $thirdparty[
'profid5'];
504 $newobject->idprof6 = $thirdparty[
'profid6'];
506 $newobject->capital = $thirdparty[
'capital'];
508 $newobject->barcode = empty($thirdparty[
'barcode']) ?
'' : $thirdparty[
'barcode'];
509 $newobject->tva_assuj = empty($thirdparty[
'vat_used']) ? 0 : $thirdparty[
'vat_used'];
510 $newobject->tva_intra = empty($thirdparty[
'vat_number']) ?
'' : $thirdparty[
'vat_number'];
512 $newobject->canvas = empty($thirdparty[
'canvas']) ?
'' : $thirdparty[
'canvas'];
513 $newobject->particulier = empty($thirdparty[
'individual']) ? 0 : $thirdparty[
'individual'];
515 $elementtype =
'societe';
520 $extrafields->fetch_name_optionals_label($elementtype,
true);
521 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
522 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
523 $key =
'options_'.$key;
524 if (isset($thirdparty[$key])) {
525 $newobject->array_options[$key] = $thirdparty[$key];
532 $result = $newobject->create($fuser);
533 if ($newobject->particulier && $result > 0) {
534 $newobject->firstname = $thirdparty[
'firstname'];
535 $newobject->name_bis = $thirdparty[
'lastname'];
536 $result = $newobject->create_individual($fuser);
546 if (!empty($thirdparty[
'commid']) && $thirdparty[
'commid'] > 0) {
547 $newobject->add_commercial($fuser, $thirdparty[
"commid"]);
550 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id,
'ref' => $newobject->ref);
555 $errorlabel = $newobject->error;
560 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
579 dol_syslog(
"Function: updateThirdParty login=".$authentication[
'login']);
581 if ($authentication[
'entity']) {
582 $conf->entity = $authentication[
'entity'];
586 $objectresp = array();
592 if (empty($thirdparty[
'id'])) {
595 $errorlabel =
"Thirdparty id is mandatory.";
599 $objectfound =
false;
601 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
604 $result =
$object->fetch($thirdparty[
'id']);
609 $object->ref = $thirdparty[
'ref'];
610 $object->name = $thirdparty[
'ref'];
611 $object->ref_ext = $thirdparty[
'ref_ext'];
612 $object->status = $thirdparty[
'status'];
613 $object->client = $thirdparty[
'client'];
614 $object->fournisseur = $thirdparty[
'supplier'];
615 $object->code_client = $thirdparty[
'customer_code'];
616 $object->code_fournisseur = $thirdparty[
'supplier_code'];
617 $object->code_compta = $thirdparty[
'customer_code_accountancy'];
618 $object->code_compta_client = $thirdparty[
'customer_code_accountancy'];
619 $object->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
621 $object->note_private = $thirdparty[
'note_private'];
622 $object->note_public = $thirdparty[
'note_public'];
623 $object->address = $thirdparty[
'address'];
624 $object->zip = $thirdparty[
'zip'];
625 $object->town = $thirdparty[
'town'];
627 $object->country_id = $thirdparty[
'country_id'];
628 if ($thirdparty[
'country_code']) {
631 $object->region_code = $thirdparty[
'region_code'];
634 $object->phone = $thirdparty[
'phone'];
635 $object->fax = $thirdparty[
'fax'];
636 $object->email = $thirdparty[
'email'];
637 $object->url = $thirdparty[
'url'];
638 $object->idprof1 = $thirdparty[
'profid1'];
639 $object->idprof2 = $thirdparty[
'profid2'];
640 $object->idprof3 = $thirdparty[
'profid3'];
641 $object->idprof4 = $thirdparty[
'profid4'];
642 $object->idprof5 = $thirdparty[
'profid5'];
643 $object->idprof6 = $thirdparty[
'profid6'];
645 $object->capital = $thirdparty[
'capital'];
647 $object->barcode = $thirdparty[
'barcode'];
648 $object->tva_assuj = $thirdparty[
'vat_used'];
649 $object->tva_intra = $thirdparty[
'vat_number'];
651 $object->canvas = $thirdparty[
'canvas'];
653 $elementtype =
'societe';
658 $extrafields->fetch_name_optionals_label($elementtype,
true);
659 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
660 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
661 $key =
'options_'.$key;
662 if (isset($thirdparty[$key])) {
663 $object->array_options[$key] = $thirdparty[$key];
670 $result =
$object->update($thirdparty[
'id'], $fuser);
676 '@phan-var-force array{id:string} $thirdparty';
678 if ((!$error) && ($objectfound)) {
681 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
684 } elseif ($objectfound) {
691 $errorcode =
'NOT_FOUND';
692 $errorlabel =
'Thirdparty id='.$thirdparty[
'id'].
' cannot be found';
697 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
716 dol_syslog(
"Function: getListOfThirdParties login=".$authentication[
'login']);
718 if ($authentication[
'entity']) {
719 $conf->entity = $authentication[
'entity'];
723 $objectresp = array();
724 $arraythirdparties = array();
733 $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.*";
734 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
735 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON s.fk_pays = c.rowid";
736 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as extra ON s.rowid=fk_object";
738 $sql .=
" WHERE entity=".$conf->entity;
739 foreach ($filterthirdparty as $key => $val) {
740 if ($key ==
'name' && $val !=
'') {
741 $sql .=
" AND s.name LIKE '%".$db->escape($val).
"%'";
743 if ($key ==
'client' && (
int) $val > 0) {
744 $sql .=
" AND s.client = ".((int) $val);
746 if ($key ==
'supplier' && (
int) $val > 0) {
747 $sql .=
" AND s.fournisseur = ".((int) $val);
749 if ($key ==
'category' && (
int) $val > 0) {
750 $sql .=
" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe WHERE fk_categorie = ".((int) $val).
") ";
753 dol_syslog(
"Function: getListOfThirdParties", LOG_DEBUG);
755 $elementtype =
'societe';
758 $extrafields->fetch_name_optionals_label($elementtype,
true);
761 $resql = $db->query($sql);
763 $num = $db->num_rows($resql);
767 $extrafieldsOptions = array();
768 $obj = $db->fetch_object($resql);
770 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
771 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
772 if (isset($obj->{$key})) {
773 $extrafieldsOptions[
'options_'.$key] = $obj->$key;
778 $arraythirdparties[] = array(
'id' => $obj->socRowid,
780 'ref_ext' => $obj->ref_ext,
781 'address' => $obj->address,
783 'town' => $obj->town,
784 'country' => $obj->country,
785 'phone' => $obj->phone,
789 $arraythirdparties[$i] = array_merge($arraythirdparties[$i], $extrafieldsOptions);
795 $errorcode = $db->lasterrno();
796 $errorlabel = $db->lasterror();
802 'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel),
803 'thirdparties' => $arraythirdparties
807 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
808 'thirdparties' => $arraythirdparties
828 dol_syslog(
"Function: deleteThirdParty login=".$authentication[
'login'].
" id=".
$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
830 if ($authentication[
'entity']) {
831 $conf->entity = $authentication[
'entity'];
835 $objectresp = array();
841 if (!$error && ((
$id && $ref) || (
$id && $ref_ext) || ($ref && $ref_ext))) {
842 dol_syslog(
"Function: deleteThirdParty checkparam");
844 $errorcode =
'BAD_PARAMETERS';
845 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
850 $fuser->loadRights();
852 if ($fuser->hasRight(
'societe',
'lire') && $fuser->hasRight(
'societe',
'supprimer')) {
853 $thirdparty =
new Societe($db);
854 $result = $thirdparty->fetch(
$id, $ref, $ref_ext);
859 $result = $thirdparty->delete($thirdparty->id, $fuser);
864 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''));
869 $errorlabel = $thirdparty->error;
870 dol_syslog(
"Function: deleteThirdParty can't delete");
874 $errorcode =
'NOT_FOUND';
875 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
879 $errorcode =
'PERMISSION_DENIED';
880 $errorlabel =
'User does not have permission for this request';
885 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
892$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 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.