From ad19fc1ca92927d63a907ee8a34b3ff7c223b48a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Sun, 5 Dec 2010 20:33:24 +0000 Subject: [PATCH] New: Work on web services --- htdocs/compta/facture/class/facture.class.php | 16 ++- htdocs/lib/functions.lib.php | 28 ++-- htdocs/webservices/demo_client_other.php | 20 ++- htdocs/webservices/demo_invoice_other.php | 121 +++++++++++++++++ .../{client.php => demo_thirdparty_other.php} | 24 ++-- htdocs/webservices/server_invoice.php | 127 +++++++++++------- htdocs/webservices/server_other.php | 11 +- htdocs/webservices/server_thirdparty.php | 7 +- 8 files changed, 267 insertions(+), 87 deletions(-) create mode 100755 htdocs/webservices/demo_invoice_other.php rename htdocs/webservices/{client.php => demo_thirdparty_other.php} (77%) mode change 100644 => 100755 diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2a2606d0a6c..d745b486caf 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -630,7 +630,7 @@ class Facture extends CommonObject $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = '".$this->element."'"; $sql.= ' WHERE f.entity = '.$conf->entity; - if ($ref) $sql.= " AND f.facnumber='".$ref."'"; + if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'"; else $sql.= " AND f.rowid=".$rowid; dol_syslog("Facture::Fetch sql=".$sql, LOG_DEBUG); @@ -717,7 +717,7 @@ class Facture extends CommonObject } else { - $this->error='Bill with id '.$rowid.' not found sql='.$sql; + $this->error='Bill with id '.$rowid.' or ref '.$ref.' not found sql='.$sql; dol_syslog('Facture::Fetch Error '.$this->error, LOG_ERR); return -2; } @@ -3090,8 +3090,10 @@ class FactureLigne var $remise; // Montant calcule de la remise % sur PU HT (exemple 20) // From llx_product - var $ref; // Reference produit - var $libelle; // Label produit + var $ref; // Product ref (deprecated) + var $product_ref; // Product ref + var $libelle; // Product label (deprecated) + var $product_label; // Product label var $product_desc; // Description produit @@ -3151,8 +3153,10 @@ class FactureLigne $this->price = $objp->price; $this->remise = $objp->remise; - $this->ref = $objp->product_ref; - $this->libelle = $objp->product_libelle; + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_libelle; // deprecated + $this->product_label = $objp->product_libelle; $this->product_desc = $objp->product_desc; $this->db->free($result); diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index b0d9cc1ccae..b74318f7512 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -2136,8 +2136,8 @@ function print_liste_field_titre($name, $file, $field, $begin="", $options="", $ } /** - * \brief Affichage d'un titre - * \param titre Le titre a afficher + * Show a title (deprecated. use print_fiche_titre instrad) + * @param titre Title to show */ function print_titre($titre) { @@ -2145,12 +2145,12 @@ function print_titre($titre) } /** - * \brief Show a title with picto - * \param titre Title to show - * \param mesg Added message to show on right - * \param picto Icon to use before title (should be a 32x32 transparent png file) - * \param pictoisfullpath 1=Icon name is a full absolute url of image - * \param id To force an id on html objects + * Show a title with picto + * @param titre Title to show + * @param mesg Added message to show on right + * @param picto Icon to use before title (should be a 32x32 transparent png file) + * @param pictoisfullpath 1=Icon name is a full absolute url of image + * @param id To force an id on html objects */ function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='') { @@ -2158,12 +2158,12 @@ function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpat } /** - * \brief Load a title with picto - * \param titre Title to show - * \param mesg Added message to show on right - * \param picto Icon to use before title (should be a 32x32 transparent png file) - * \param pictoisfullpath 1=Icon name is a full absolute url of image - * \param id To force an id on html objects + * Load a title with picto + * @param titre Title to show + * @param mesg Added message to show on right + * @param picto Icon to use before title (should be a 32x32 transparent png file) + * @param pictoisfullpath 1=Icon name is a full absolute url of image + * @param id To force an id on html objects */ function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='') { diff --git a/htdocs/webservices/demo_client_other.php b/htdocs/webservices/demo_client_other.php index c4bbde5c30c..deb7c5c09d0 100755 --- a/htdocs/webservices/demo_client_other.php +++ b/htdocs/webservices/demo_client_other.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ */ /** - * \file htdocs/webservices/client.php - * \brief Page demo client appel WebServices Dolibarr + * \file htdocs/webservices/demo_client_other.php + * \brief Demo page to make a client call to Dolibarr WebServices "server_other" * \version $Id$ */ @@ -31,8 +31,6 @@ require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP $WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server_other.php'; $WS_METHOD = 'getVersions'; -// Set the parameters to send to the WebService -$parameters = array(); // Set the WebService URL dol_syslog("Create soapclient_nusoap for URL=".$WS_DOL_URL); @@ -43,6 +41,13 @@ if ($soapclient) } // Call the WebService method and store its result in $result. +$authentication=array( + 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, + 'sourceapplication'=>'DEMO', + 'login'=>'admin', + 'password'=>'changeme', + 'entity'=>''); +$parameters = array('authentication'=>$authentication); dol_syslog("Call method ".$WS_METHOD); $result = $soapclient->call($WS_METHOD,$parameters); if (! $result) @@ -51,7 +56,10 @@ if (! $result) exit; } -// Show page with result +/* + * View + */ + header("Content-type: text/html; charset=utf8"); print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n"; echo '<html>'."\n"; diff --git a/htdocs/webservices/demo_invoice_other.php b/htdocs/webservices/demo_invoice_other.php new file mode 100755 index 00000000000..f23c3db8fb5 --- /dev/null +++ b/htdocs/webservices/demo_invoice_other.php @@ -0,0 +1,121 @@ +<?php +/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/webservices/client.php + * \brief Demo page to make a client call to Dolibarr WebServices "server_invoice" + * \version $Id$ + */ + +// This is to make Dolibarr working with Plesk +set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); + +require_once("../master.inc.php"); +require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP + +$WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server_invoice.php'; +$WS_METHOD1 = 'getInvoice'; +$WS_METHOD2 = 'getInvoicesForThirdParty'; + + +// Set the WebService URL +dol_syslog("Create soapclient_nusoap for URL=".$WS_DOL_URL); +$soapclient1 = new soapclient_nusoap($WS_DOL_URL); +if ($soapclient1) +{ + $soapclient1->soap_defencoding='UTF-8'; +} +$soapclient2 = new soapclient_nusoap($WS_DOL_URL); +if ($soapclient2) +{ + $soapclient2->soap_defencoding='UTF-8'; +} + +// Call the WebService method and store its result in $result. +$authentication=array( + 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, + 'sourceapplication'=>'DEMO', + 'login'=>'admin', + 'password'=>'changeme', + 'entity'=>''); + +$parameters = array('authentication'=>$authentication,'id'=>1,'ref'=>''); +dol_syslog("Call method ".$WS_METHOD1); +$result1 = $soapclient1->call($WS_METHOD1,$parameters); +if (! $result1) +{ + print $soapclient1->error_str; + exit; +} + +$parameters = array('authentication'=>$authentication,'idthirdparty'=>'1'); +dol_syslog("Call method ".$WS_METHOD2); +$result2 = $soapclient2->call($WS_METHOD2,$parameters); +if (! $result2) +{ + print $soapclient2->error_str; + exit; +} + + +/* + * View + */ + +header("Content-type: text/html; charset=utf8"); +print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n"; +echo '<html>'."\n"; +echo '<head>'; +echo '<title>WebService Test: '.$WS_METHOD1.'</title>'; +echo '</head>'."\n"; + +echo '<body>'."\n"; + +echo "<h2>Request:</h2>"; +echo '<h4>Function</h4>'; +echo $WS_METHOD1; +echo '<h4>SOAP Message</h4>'; +echo '<pre>' . htmlspecialchars($soapclient1->request, ENT_QUOTES) . '</pre>'; +echo '<hr>'; +echo "<h2>Response:</h2>"; +echo '<h4>Result</h4>'; +echo '<pre>'; +print_r($result1); +echo '</pre>'; +echo '<h4>SOAP Message</h4>'; +echo '<pre>' . htmlspecialchars($soapclient1->response, ENT_QUOTES) . '</pre>'; + +print '<hr>'; + +echo "<h2>Request:</h2>"; +echo '<h4>Function</h4>'; +echo $WS_METHOD2; +echo '<h4>SOAP Message</h4>'; +echo '<pre>' . htmlspecialchars($soapclient2->request, ENT_QUOTES) . '</pre>'; +echo '<hr>'; +echo "<h2>Response:</h2>"; +echo '<h4>Result</h4>'; +echo '<pre>'; +print_r($result2); +echo '</pre>'; +echo '<h4>SOAP Message</h4>'; +echo '<pre>' . htmlspecialchars($soapclient2->response, ENT_QUOTES) . '</pre>'; + +echo '</body>'."\n";; +echo '</html>'."\n";; +?> diff --git a/htdocs/webservices/client.php b/htdocs/webservices/demo_thirdparty_other.php old mode 100644 new mode 100755 similarity index 77% rename from htdocs/webservices/client.php rename to htdocs/webservices/demo_thirdparty_other.php index e140562387f..4ee540b1916 --- a/htdocs/webservices/client.php +++ b/htdocs/webservices/demo_thirdparty_other.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ */ /** - * \file htdocs/webservices/client.php - * \brief Page demo client appel WebServices Dolibarr + * \file htdocs/webservices/demo_thirdparty_other.php + * \brief Demo page to make a client call to Dolibarr WebServices "server_other" * \version $Id$ */ @@ -28,11 +28,9 @@ set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); require_once("../master.inc.php"); require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP -$WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server.php'; -$WS_METHOD = 'getVersions'; +$WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server_thirdparty.php'; +$WS_METHOD = 'getThirdParty'; -// Set the parameters to send to the WebService -$parameters = array(); // Set the WebService URL dol_syslog("Create soapclient_nusoap for URL=".$WS_DOL_URL); @@ -43,6 +41,13 @@ if ($soapclient) } // Call the WebService method and store its result in $result. +$authentication=array( + 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, + 'sourceapplication'=>'DEMO', + 'login'=>'admin', + 'password'=>'changeme', + 'entity'=>''); +$parameters = array('authentication'=>$authentication,'id'=>0,'name'=>'aaa'); dol_syslog("Call method ".$WS_METHOD); $result = $soapclient->call($WS_METHOD,$parameters); if (! $result) @@ -51,7 +56,10 @@ if (! $result) exit; } -// Show page with result +/* + * View + */ + header("Content-type: text/html; charset=utf8"); print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n"; echo '<html>'."\n"; diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 5142e0ee7d0..a0801fa78e4 100755 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -74,11 +74,19 @@ $server->wsdl->addComplexType( '', array( 'id' => array('name'=>'id','type'=>'xsd:string'), - 'type' => array('name'=>'type','type'=>'xsd:string'), + 'type' => array('name'=>'type','type'=>'xsd:int'), 'fk_product' => array('name'=>'fk_product','type'=>'xsd:int'), - 'total_ht' => array('name'=>'total_ht','type'=>'xsd:int'), - 'total_vat' => array('name'=>'total_vat','type'=>'xsd:int'), - 'total_ttc' => array('name'=>'total_ttc','type'=>'xsd:int') + 'total_net' => array('name'=>'total_net','type'=>'xsd:double'), + 'total_vat' => array('name'=>'total_vat','type'=>'xsd:double'), + 'total' => array('name'=>'total','type'=>'xsd:double'), + 'vat_rate' => array('name'=>'vat_rate','type'=>'xsd:double'), + 'qty' => array('name'=>'qty','type'=>'xsd:double'), + 'date_start' => array('name'=>'date_start','type'=>'xsd:date'), + 'date_end' => array('name'=>'date_end','type'=>'xsd:date'), + // From product + 'product_ref' => array('name'=>'product_ref','type'=>'xsd:string'), + 'product_label' => array('name'=>'product_label','type'=>'xsd:string'), + 'product_desc' => array('name'=>'product_desc','type'=>'xsd:string') ) ); @@ -106,19 +114,19 @@ $server->wsdl->addComplexType( 'ref' => array('name'=>'ref','type'=>'xsd:string'), 'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'), 'fk_user_valid' => array('name'=>'fk_user_valid','type'=>'xsd:string'), - 'date' => array('name'=>'date','type'=>'xsd:int'), - 'date_creation' => array('name'=>'date_creation','type'=>'xsd:int'), - 'date_validation' => array('name'=>'date_validation','type'=>'xsd:int'), - 'date_modification' => array('name'=>'date_modification','type'=>'xsd:int'), + 'date' => array('name'=>'date','type'=>'xsd:date'), + 'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'), + 'date_validation' => array('name'=>'date_validation','type'=>'xsd:dateTime'), + 'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'), 'type' => array('name'=>'type','type'=>'xsd:int'), - 'total' => array('name'=>'type','type'=>'xsd:int'), - 'total_vat' => array('name'=>'type','type'=>'xsd:int'), - 'total_vat' => array('name'=>'type','type'=>'xsd:int'), - 'note' => array('name'=>'note','type'=>'xsd:int'), - 'note_public' => array('name'=>'note_public','type'=>'xsd:int'), + 'total_net' => array('name'=>'type','type'=>'xsd:double'), + 'total_vat' => array('name'=>'type','type'=>'xsd:double'), + 'total' => array('name'=>'type','type'=>'xsd:double'), + 'note' => array('name'=>'note','type'=>'xsd:string'), + 'note_public' => array('name'=>'note_public','type'=>'xsd:string'), 'status' => array('name'=>'status','type'=>'xsd:int'), - 'close_code' => array('name'=>'close_code','type'=>'xsd:int'), - 'close_note' => array('name'=>'close_note','type'=>'xsd:int'), + 'close_code' => array('name'=>'close_code','type'=>'xsd:string'), + 'close_note' => array('name'=>'close_note','type'=>'xsd:string'), 'lines' => array('name'=>'lines','type'=>'tns:LinesArray') ) ); @@ -178,7 +186,9 @@ $ns ); -// Get invoice from id +/** + * Get invoice from id + */ function getInvoice($authentication,$id,$ref) { global $db,$conf,$langs; @@ -191,6 +201,11 @@ function getInvoice($authentication,$id,$ref) $errorcode='';$errorlabel=''; $error=0; + if (! $error && empty($conf->global->WEBSERVICES_KEY)) + { + $error++; + $errorcode='SETUP_NOT_COMPLETE'; $errorlabel='Value for dolibarr security key not yet defined into Webservice module setup'; + } if (! $error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY)) { $error++; @@ -233,15 +248,15 @@ function getInvoice($authentication,$id,$ref) $i=0; foreach($invoice->lines as $line) { - //var_dump($line); + //var_dump($line); exit; $linesresp[]=array( 'id'=>$line->rowid, - 'type'=>$line->type, - 'total_ht'=>$line->total_ht, + 'type'=>$line->product_type, + 'total_net'=>$line->total_ht, 'total_vat'=>$line->total_tva, - 'total_ttc'=>$line->total_ttc, - - + 'total'=>$line->total_ttc, + 'vat_rate'=>$line->tva_tx, + 'qty'=>$line->qty ); $i++; } @@ -252,6 +267,7 @@ function getInvoice($authentication,$id,$ref) 'invoice'=>array( 'id' => $invoice->id, 'ref' => $invoice->ref, + 'status'=>$invoice->statut, 'fk_user_author' => $invoice->fk_user_author, 'fk_user_valid' => $invoice->fk_user_valid, 'lines' => $linesresp @@ -263,7 +279,7 @@ function getInvoice($authentication,$id,$ref) else { $error++; - $errorcode='FAILEDTOREAD'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref; + $errorcode='FAILED_TO_READ'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref; } } else @@ -282,12 +298,14 @@ function getInvoice($authentication,$id,$ref) } -// Get list of invoices for third party +/** + * Get list of invoices for third party + */ function getInvoicesForThirdParty($authentication,$idthirdparty) { global $db,$conf,$langs; - dol_syslog("Function: getInvoicesForThirdParty login=".$authentication['login']." id=".$idthirdparty); + dol_syslog("Function: getInvoicesForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty); if ($authentication['entity']) $conf->entity=$authentication['entity']; @@ -311,10 +329,14 @@ function getInvoicesForThirdParty($authentication,$idthirdparty) { $linesinvoice=array(); - $sql.='SELECT rowid, facnumber as ref, type, total_ttc, total, tva'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; + $sql.='SELECT f.rowid as facid, facnumber as ref, type, fk_statut as status, total_ttc, total, tva'; + $sql.=' FROM '.MAIN_DB_PREFIX.'facture as f'; + //$sql.=', '.MAIN_DB_PREFIX.'societe as s'; //$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid'; - $sql.= ' WHERE fk_soc = '.$idthirdparty; + //$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'"; + //$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'"; + $sql.=" WHERE f.fk_soc = ".$db->escape($idthirdparty); + $sql.=" AND f.entity = ".$conf->entity; $resql=$db->query($sql); if ($resql) @@ -323,32 +345,39 @@ function getInvoicesForThirdParty($authentication,$idthirdparty) $i=0; while ($i < $num) { - // En attendant remplissage par boucle + // En attendant remplissage par boucle + $obj=$db->fetch_object($resql); + + $invoice=new Facture($db); + $invoice->fetch($obj->facid); // Define lines of invoice $linesresp=array(); - $linesresp[]=array( - 'id'=>100, - 'type'=>1, - 'total_ht'=>$line->total_ht, - 'total_vat'=>$line->total_tva, - 'total_ttc'=>$line->total_ttc, - ); - $linesresp[]=array( - 'id'=>101, - 'type'=>1, - 'total_ht'=>$line->total_ht, - 'total_vat'=>$line->total_tva, - 'total_ttc'=>$line->total_ttc, - ); + foreach($invoice->lines as $line) + { + $linesresp[]=array( + 'id'=>$line->rowid, + 'type'=>$line->product_type, + 'total_net'=>$line->total_ht, + 'total_vat'=>$line->total_tva, + 'total'=>$line->total_ttc, + 'vat_rate'=>$line->tva_tx, + 'qty'=>$line->qty, + 'product_ref'=>$line->product_ref, + 'product_label'=>$line->product_label, + 'product_desc'=>$line->product_desc, + ); + } + // Now define invoice $linesinvoice[]=array( - 'id'=>'1', - 'ref'=>'aa', - 'type'=>1, - 'total_ht'=>10, - 'total_vat'=>$line->total_tva, - 'total_ttc'=>$line->total_ttc, + 'id'=>$invoice->id, + 'ref'=>$invoice->ref, + 'type'=>$invoice->type, + 'status'=>$invoice->statut, + 'total_net'=>$invoice->total_ht, + 'total_vat'=>$invoice->total_tva, + 'total'=>$invoice->total_ttc, 'lines' => $linesresp ); diff --git a/htdocs/webservices/server_other.php b/htdocs/webservices/server_other.php index 1bb24b5c645..d01643ee1db 100644 --- a/htdocs/webservices/server_other.php +++ b/htdocs/webservices/server_other.php @@ -67,8 +67,8 @@ $server->wsdl->addComplexType( )); $server->wsdl->addComplexType( - 'result', - 'complexType', + 'result', + 'complexType', 'struct', 'all', '', @@ -101,7 +101,12 @@ function getVersions($authentication) $errorcode='';$errorlabel=''; $error=0; - if ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY) + if (! $error && empty($conf->global->WEBSERVICES_KEY)) + { + $error++; + $errorcode='SETUP_NOT_COMPLETE'; $errorlabel='Value for dolibarr security key not yet defined into Webservice module setup'; + } + if (! $error && $authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY) { $error++; $errorcode='BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel='Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup'; diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index e50f3359458..a905e57599d 100755 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -133,6 +133,11 @@ function getThirdParty($authentication,$id,$name) $errorcode='';$errorlabel=''; $error=0; + if (! $error && empty($conf->global->WEBSERVICES_KEY)) + { + $error++; + $errorcode='SETUP_NOT_COMPLETE'; $errorlabel='Value for dolibarr security key not yet defined into Webservice module setup'; + } if (! $error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY)) { $error++; @@ -201,7 +206,7 @@ function getThirdParty($authentication,$id,$name) else { $error++; - $errorcode='FAILEDTOREAD'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref; + $errorcode='FAILED_TO_READ'; $errorlabel='Object not found for id='.$id.' nor name='.$name; } } else -- GitLab