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);
79$server->wsdl->schemaTargetNamespace = $ns;
83$server->wsdl->addComplexType(
90 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
91 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
92 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
93 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
94 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string'),
98$server->wsdl->addComplexType(
105 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
106 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
111$thirdparty_fields = array(
112 'id' => array(
'name' =>
'id',
'type' =>
'xsd:string'),
113 'ref' => array(
'name' =>
'name',
'type' =>
'xsd:string'),
114 'ref_ext' => array(
'name' =>
'ref_ext',
'type' =>
'xsd:string'),
115 'fk_user_author' => array(
'name' =>
'fk_user_author',
'type' =>
'xsd:string'),
116 'status' => array(
'name' =>
'status',
'type' =>
'xsd:string'),
117 'client' => array(
'name' =>
'client',
'type' =>
'xsd:string'),
118 'supplier' => array(
'name' =>
'supplier',
'type' =>
'xsd:string'),
119 'customer_code' => array(
'name' =>
'customer_code',
'type' =>
'xsd:string'),
120 'supplier_code' => array(
'name' =>
'supplier_code',
'type' =>
'xsd:string'),
121 'customer_code_accountancy' => array(
'name' =>
'customer_code_accountancy',
'type' =>
'xsd:string'),
122 'supplier_code_accountancy' => array(
'name' =>
'supplier_code_accountancy',
'type' =>
'xsd:string'),
123 'date_creation' => array(
'name' =>
'date_creation',
'type' =>
'xsd:dateTime'),
124 'date_modification' => array(
'name' =>
'date_modification',
'type' =>
'xsd:dateTime'),
125 'note_private' => array(
'name' =>
'note_private',
'type' =>
'xsd:string'),
126 'note_public' => array(
'name' =>
'note_public',
'type' =>
'xsd:string'),
127 'address' => array(
'name' =>
'address',
'type' =>
'xsd:string'),
128 'zip' => array(
'name' =>
'zip',
'type' =>
'xsd:string'),
129 'town' => array(
'name' =>
'town',
'type' =>
'xsd:string'),
130 'region_code' => array(
'name' =>
'region_code',
'type' =>
'xsd:string'),
131 'country_id' => array(
'name' =>
'country_id',
'type' =>
'xsd:string'),
132 'country_code' => array(
'name' =>
'country_code',
'type' =>
'xsd:string'),
133 'country' => array(
'name' =>
'country',
'type' =>
'xsd:string'),
134 'phone' => array(
'name' =>
'phone',
'type' =>
'xsd:string'),
135 'fax' => array(
'name' =>
'fax',
'type' =>
'xsd:string'),
136 'email' => array(
'name' =>
'email',
'type' =>
'xsd:string'),
137 'url' => array(
'name' =>
'url',
'type' =>
'xsd:string'),
138 'profid1' => array(
'name' =>
'profid1',
'type' =>
'xsd:string'),
139 'profid2' => array(
'name' =>
'profid2',
'type' =>
'xsd:string'),
140 'profid3' => array(
'name' =>
'profid3',
'type' =>
'xsd:string'),
141 'profid4' => array(
'name' =>
'profid4',
'type' =>
'xsd:string'),
142 'profid5' => array(
'name' =>
'profid5',
'type' =>
'xsd:string'),
143 'profid6' => array(
'name' =>
'profid6',
'type' =>
'xsd:string'),
144 'capital' => array(
'name' =>
'capital',
'type' =>
'xsd:string'),
145 'vat_used' => array(
'name' =>
'vat_used',
'type' =>
'xsd:string'),
146 'vat_number' => array(
'name' =>
'vat_number',
'type' =>
'xsd:string'));
148$elementtype =
'societe';
153$extrafields->fetch_name_optionals_label($elementtype,
true);
154$extrafield_array =
null;
155if (is_array($extrafields->attributes) && $extrafields->attributes[$elementtype][
'count'] > 0) {
156 $extrafield_array = array();
158if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
159 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
161 $type = $extrafields->attributes[$elementtype][
'type'][$key];
162 if ($type ==
'date' || $type ==
'datetime') {
163 $type =
'xsd:dateTime';
165 $type =
'xsd:string';
168 $extrafield_array[
'options_'.$key] = array(
'name' =>
'options_'.$key,
'type' => $type);
172if (is_array($extrafield_array)) {
173 $thirdparty_fields = array_merge($thirdparty_fields, $extrafield_array);
177$server->wsdl->addComplexType(
187$server->wsdl->addComplexType(
195 'client' => array(
'name' =>
'client',
'type' =>
'xsd:string'),
196 'supplier' => array(
'name' =>
'supplier',
'type' =>
'xsd:string'),
197 'category' => array(
'name' =>
'category',
'type' =>
'xsd:string')
201$server->wsdl->addComplexType(
209 array(
'ref' =>
'SOAP-ENC:arrayType',
'wsdl:arrayType' =>
'tns:thirdparty[]')
213$server->wsdl->addComplexType(
214 'ThirdPartiesArray2',
220 'thirdparty' => array(
221 'name' =>
'thirdparty',
222 'type' =>
'tns:thirdparty',
224 'maxOccurs' =>
'unbounded'
234$styleuse =
'encoded';
241 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string',
'barcode' =>
'xsd:string',
'profid1' =>
'xsd:string',
'profid2' =>
'xsd:string'),
243 array(
'result' =>
'tns:result',
'thirdparty' =>
'tns:thirdparty'),
245 $ns.
'#getThirdParty',
248 'WS to get a thirdparty from its id, ref or ref_ext'
255 array(
'authentication' =>
'tns:authentication',
'thirdparty' =>
'tns:thirdparty'),
257 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string'),
259 $ns.
'#createThirdParty',
262 'WS to create a thirdparty'
269 array(
'authentication' =>
'tns:authentication',
'thirdparty' =>
'tns:thirdparty'),
271 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
273 $ns.
'#updateThirdParty',
276 'WS to update a thirdparty'
282 'getListOfThirdParties',
284 array(
'authentication' =>
'tns:authentication',
'filterthirdparty' =>
'tns:filterthirdparty'),
286 array(
'result' =>
'tns:result',
'thirdparties' =>
'tns:ThirdPartiesArray2'),
288 $ns.
'#getListOfThirdParties',
291 'WS to get list of thirdparties id and ref'
298 array(
'authentication' =>
'tns:authentication',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
300 array(
'result' =>
'tns:result',
'id' =>
'xsd:string'),
302 $ns.
'#deleteThirdParty',
305 'WS to delete a thirdparty from its id, ref or ref_ext'
322function getThirdParty($authentication,
$id =
'', $ref =
'', $ref_ext =
'', $barcode =
'', $profid1 =
'', $profid2 =
'')
326 dol_syslog(
"Function: getThirdParty login=".$authentication[
'login'].
" id=".
$id.
" ref=".$ref.
" ref_ext=".$ref_ext.
" barcode=".$barcode.
" profid1=".$profid1.
" profid2=".$profid2);
328 if ($authentication[
'entity']) {
329 $conf->entity = $authentication[
'entity'];
333 $objectresp = array();
339 if (!$error && ((
$id && $ref) || (
$id && $ref_ext) || ($ref && $ref_ext))) {
341 $errorcode =
'BAD_PARAMETERS';
342 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
346 $fuser->loadRights();
348 if ($fuser->hasRight(
'societe',
'lire')) {
349 $thirdparty =
new Societe($db);
350 $result = $thirdparty->fetch(
$id, $ref, $ref_ext, $barcode, $profid1, $profid2);
352 $thirdparty_result_fields = array(
353 'id' => $thirdparty->id,
354 'ref' => $thirdparty->name,
355 'ref_ext' => $thirdparty->ref_ext,
356 'status' => $thirdparty->status,
357 'client' => $thirdparty->client,
358 'supplier' => $thirdparty->fournisseur,
359 'customer_code' => $thirdparty->code_client,
360 'supplier_code' => $thirdparty->code_fournisseur,
361 'customer_code_accountancy' => $thirdparty->code_compta_client,
362 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur,
363 'user_creation_id' => $thirdparty->user_creation_id,
364 'date_creation' =>
dol_print_date($thirdparty->date_creation,
'dayhourrfc'),
365 'user_modification_id' => $thirdparty->user_modification_id,
366 'date_modification' =>
dol_print_date($thirdparty->date_modification,
'dayhourrfc'),
367 'address' => $thirdparty->address,
368 'zip' => $thirdparty->zip,
369 'town' => $thirdparty->town,
370 'region_code' => $thirdparty->region_code,
371 'country_id' => $thirdparty->country_id,
372 'country_code' => $thirdparty->country_code,
373 'country' => $thirdparty->country,
374 'phone' => $thirdparty->phone,
375 'fax' => $thirdparty->fax,
376 'email' => $thirdparty->email,
377 'url' => $thirdparty->url,
378 'profid1' => $thirdparty->idprof1,
379 'profid2' => $thirdparty->idprof2,
380 'profid3' => $thirdparty->idprof3,
381 'profid4' => $thirdparty->idprof4,
382 'profid5' => $thirdparty->idprof5,
383 'profid6' => $thirdparty->idprof6,
384 'capital' => $thirdparty->capital,
385 'barcode' => $thirdparty->barcode,
386 'vat_used' => $thirdparty->tva_assuj,
387 'vat_number' => $thirdparty->tva_intra,
388 'note_private' => $thirdparty->note_private,
389 'note_public' => $thirdparty->note_public);
391 $elementtype =
'societe';
396 $extrafields->fetch_name_optionals_label($elementtype,
true);
398 $thirdparty->fetch_optionals();
400 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
401 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
402 if (isset($thirdparty->array_options[
'options_'.$key])) {
403 $thirdparty_result_fields = array_merge($thirdparty_result_fields, array(
'options_'.$key => $thirdparty->array_options[
'options_'.$key]));
410 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
411 'thirdparty' => $thirdparty_result_fields);
412 } elseif ($result == -2) {
414 $errorcode =
'DUPLICATE_FOUND';
415 $errorlabel =
'Object found several times for id='.$id.
' or ref='.$ref.
' or ref_ext='.$ref_ext;
418 $errorcode =
'NOT_FOUND';
419 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
423 $errorcode =
'PERMISSION_DENIED';
424 $errorlabel =
'User does not have permission for this request';
429 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
450 dol_syslog(
"Function: createThirdParty login=".$authentication[
'login']);
452 if ($authentication[
'entity']) {
453 $conf->entity = $authentication[
'entity'];
457 $objectresp = array();
463 if (empty($thirdparty[
'ref'])) {
466 $errorlabel =
"Name is mandatory.";
471 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
474 $newobject->ref = $thirdparty[
'ref'];
475 $newobject->name = $thirdparty[
'ref'];
476 $newobject->ref_ext = $thirdparty[
'ref_ext'];
477 $newobject->status = (int) $thirdparty[
'status'];
478 $newobject->client = (int) $thirdparty[
'client'];
479 $newobject->fournisseur = (int) $thirdparty[
'supplier'];
480 $newobject->code_client = $thirdparty[
'customer_code'];
481 $newobject->code_fournisseur = $thirdparty[
'supplier_code'];
482 $newobject->code_compta = $thirdparty[
'customer_code_accountancy'];
483 $newobject->code_compta_client = $thirdparty[
'customer_code_accountancy'];
484 $newobject->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
485 $newobject->date_creation = $now;
486 $newobject->note_private = $thirdparty[
'note_private'];
487 $newobject->note_public = $thirdparty[
'note_public'];
488 $newobject->address = $thirdparty[
'address'];
489 $newobject->zip = $thirdparty[
'zip'];
490 $newobject->town = $thirdparty[
'town'];
492 $newobject->country_id = (int) $thirdparty[
'country_id'];
493 if ($thirdparty[
'country_code']) {
494 $newobject->country_id =
getCountry($thirdparty[
'country_code'],
'3');
496 $newobject->region_code = empty($thirdparty[
'region_code']) ?
'' : $thirdparty[
'region_code'];
499 $newobject->phone = $thirdparty[
'phone'];
500 $newobject->fax = $thirdparty[
'fax'];
501 $newobject->email = $thirdparty[
'email'];
502 $newobject->url = $thirdparty[
'url'];
503 $newobject->idprof1 = $thirdparty[
'profid1'];
504 $newobject->idprof2 = $thirdparty[
'profid2'];
505 $newobject->idprof3 = $thirdparty[
'profid3'];
506 $newobject->idprof4 = $thirdparty[
'profid4'];
507 $newobject->idprof5 = $thirdparty[
'profid5'];
508 $newobject->idprof6 = $thirdparty[
'profid6'];
510 $newobject->capital = (float) $thirdparty[
'capital'];
512 $newobject->barcode = !isset($thirdparty[
'barcode']) ?
'' : $thirdparty[
'barcode'];
513 $newobject->tva_assuj = empty($thirdparty[
'vat_used']) ? 0 : $thirdparty[
'vat_used'];
514 $newobject->tva_intra = empty($thirdparty[
'vat_number']) ?
'' : $thirdparty[
'vat_number'];
516 $newobject->canvas = !isset($thirdparty[
'canvas']) ?
'' : $thirdparty[
'canvas'];
517 $newobject->particulier = empty($thirdparty[
'individual']) ? 0 : $thirdparty[
'individual'];
519 $elementtype =
'societe';
524 $extrafields->fetch_name_optionals_label($elementtype,
true);
525 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
526 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
527 $key =
'options_'.$key;
528 if (isset($thirdparty[$key])) {
529 $newobject->array_options[$key] = $thirdparty[$key];
536 $result = $newobject->create($fuser);
537 if ($newobject->particulier && $result > 0) {
538 $newobject->firstname = isset($thirdparty[
'firstname']) ? $thirdparty[
'firstname'] :
'';
539 $newobject->name_bis = isset($thirdparty[
'lastname']) ? $thirdparty[
'lastname'] :
'';
540 $result = $newobject->create_individual($fuser);
550 if (isset($thirdparty[
'commid']) && $thirdparty[
'commid'] > 0) {
551 $newobject->add_commercial($fuser, $thirdparty[
'commid']);
554 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $newobject->id,
'ref' => $newobject->ref);
559 $errorlabel = $newobject->error;
564 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
583 dol_syslog(
"Function: updateThirdParty login=".$authentication[
'login']);
585 if ($authentication[
'entity']) {
586 $conf->entity = $authentication[
'entity'];
590 $objectresp = array();
596 if (empty($thirdparty[
'id'])) {
599 $errorlabel =
"Thirdparty id is mandatory.";
603 $objectfound =
false;
605 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
608 $result =
$object->fetch($thirdparty[
'id']);
613 $object->ref = $thirdparty[
'ref'];
614 $object->name = $thirdparty[
'ref'];
615 $object->ref_ext = $thirdparty[
'ref_ext'];
616 $object->status = (int) $thirdparty[
'status'];
617 $object->client = (int) $thirdparty[
'client'];
618 $object->fournisseur = (int) $thirdparty[
'supplier'];
619 $object->code_client = $thirdparty[
'customer_code'];
620 $object->code_fournisseur = $thirdparty[
'supplier_code'];
621 $object->code_compta = $thirdparty[
'customer_code_accountancy'];
622 $object->code_compta_client = $thirdparty[
'customer_code_accountancy'];
623 $object->code_compta_fournisseur = $thirdparty[
'supplier_code_accountancy'];
625 $object->note_private = $thirdparty[
'note_private'];
626 $object->note_public = $thirdparty[
'note_public'];
627 $object->address = $thirdparty[
'address'];
628 $object->zip = $thirdparty[
'zip'];
629 $object->town = $thirdparty[
'town'];
631 $object->country_id = (int) $thirdparty[
'country_id'];
632 if ($thirdparty[
'country_code']) {
635 $object->region_code = $thirdparty[
'region_code'];
638 $object->phone = $thirdparty[
'phone'];
639 $object->fax = $thirdparty[
'fax'];
640 $object->email = $thirdparty[
'email'];
641 $object->url = $thirdparty[
'url'];
642 $object->idprof1 = $thirdparty[
'profid1'];
643 $object->idprof2 = $thirdparty[
'profid2'];
644 $object->idprof3 = $thirdparty[
'profid3'];
645 $object->idprof4 = $thirdparty[
'profid4'];
646 $object->idprof5 = $thirdparty[
'profid5'];
647 $object->idprof6 = $thirdparty[
'profid6'];
649 $object->capital = (float) $thirdparty[
'capital'];
651 $object->barcode = !isset($thirdparty[
'barcode']) ?
'' : $thirdparty[
'barcode'];
652 $object->tva_assuj = (int) $thirdparty[
'vat_used'];
653 $object->tva_intra = $thirdparty[
'vat_number'];
655 $object->canvas = !isset($thirdparty[
'canvas']) ?
'' : $thirdparty[
'canvas'];
657 $elementtype =
'societe';
662 $extrafields->fetch_name_optionals_label($elementtype,
true);
663 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
664 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
665 $key =
'options_'.$key;
666 if (isset($thirdparty[$key])) {
667 $object->array_options[$key] = $thirdparty[$key];
674 $result =
$object->update($thirdparty[
'id'], $fuser);
680 '@phan-var-force array{id:string} $thirdparty';
682 if ((!$error) && ($objectfound)) {
685 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
688 } elseif ($objectfound) {
695 $errorcode =
'NOT_FOUND';
696 $errorlabel =
'Thirdparty id='.$thirdparty[
'id'].
' cannot be found';
701 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
720 dol_syslog(
"Function: getListOfThirdParties login=".$authentication[
'login']);
722 if ($authentication[
'entity']) {
723 $conf->entity = $authentication[
'entity'];
727 $objectresp = array();
728 $arraythirdparties = array();
737 $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.*";
738 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
739 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON s.fk_pays = c.rowid";
740 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as extra ON s.rowid=fk_object";
742 $sql .=
" WHERE entity=".$conf->entity;
743 foreach ($filterthirdparty as $key => $val) {
744 if ($key ==
'name' && $val !=
'') {
745 $sql .=
" AND s.name LIKE '%".$db->escape($val).
"%'";
747 if ($key ==
'client' && (
int) $val > 0) {
748 $sql .=
" AND s.client = ".((int) $val);
750 if ($key ==
'supplier' && (
int) $val > 0) {
751 $sql .=
" AND s.fournisseur = ".((int) $val);
753 if ($key ==
'category' && (
int) $val > 0) {
754 $sql .=
" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe WHERE fk_categorie = ".((int) $val).
") ";
757 dol_syslog(
"Function: getListOfThirdParties", LOG_DEBUG);
759 $elementtype =
'societe';
762 $extrafields->fetch_name_optionals_label($elementtype,
true);
765 $resql = $db->query($sql);
767 $num = $db->num_rows($resql);
771 $extrafieldsOptions = array();
772 $obj = $db->fetch_object($resql);
774 if (isset($extrafields->attributes[$elementtype][
'label']) && is_array($extrafields->attributes[$elementtype][
'label']) && count($extrafields->attributes[$elementtype][
'label'])) {
775 foreach ($extrafields->attributes[$elementtype][
'label'] as $key => $label) {
776 if (isset($obj->{$key})) {
777 $extrafieldsOptions[
'options_'.$key] = $obj->$key;
782 $arraythirdparties[] = array(
'id' => $obj->socRowid,
784 'ref_ext' => $obj->ref_ext,
785 'address' => $obj->address,
787 'town' => $obj->town,
788 'country' => $obj->country,
789 'phone' => $obj->phone,
793 $arraythirdparties[$i] = array_merge($arraythirdparties[$i], $extrafieldsOptions);
799 $errorcode = $db->lasterrno();
800 $errorlabel = $db->lasterror();
806 'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel),
807 'thirdparties' => $arraythirdparties
811 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
812 'thirdparties' => $arraythirdparties
832 dol_syslog(
"Function: deleteThirdParty login=".$authentication[
'login'].
" id=".
$id.
" ref=".$ref.
" ref_ext=".$ref_ext);
834 if ($authentication[
'entity']) {
835 $conf->entity = $authentication[
'entity'];
839 $objectresp = array();
845 if (!$error && ((
$id && $ref) || (
$id && $ref_ext) || ($ref && $ref_ext))) {
846 dol_syslog(
"Function: deleteThirdParty checkparam");
848 $errorcode =
'BAD_PARAMETERS';
849 $errorlabel =
"Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
854 $fuser->loadRights();
856 if ($fuser->hasRight(
'societe',
'lire') && $fuser->hasRight(
'societe',
'supprimer')) {
857 $thirdparty =
new Societe($db);
858 $result = $thirdparty->fetch(
$id, $ref, $ref_ext);
863 $result = $thirdparty->delete($thirdparty->id, $fuser);
868 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''));
873 $errorlabel = $thirdparty->error;
874 dol_syslog(
"Function: deleteThirdParty can't delete");
878 $errorcode =
'NOT_FOUND';
879 $errorlabel =
'Object not found for id='.$id.
' nor ref='.$ref.
' nor ref_ext='.$ref_ext;
883 $errorcode =
'PERMISSION_DENIED';
884 $errorlabel =
'User does not have permission for this request';
889 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
896$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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.