forked from Wavyzz/dolibarr
New: Work on web services
This commit is contained in:
@@ -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.'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.= " 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;
|
$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;
|
else $sql.= " AND f.rowid=".$rowid;
|
||||||
|
|
||||||
dol_syslog("Facture::Fetch sql=".$sql, LOG_DEBUG);
|
dol_syslog("Facture::Fetch sql=".$sql, LOG_DEBUG);
|
||||||
@@ -717,7 +717,7 @@ class Facture extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
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);
|
dol_syslog('Facture::Fetch Error '.$this->error, LOG_ERR);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
@@ -3090,8 +3090,10 @@ class FactureLigne
|
|||||||
var $remise; // Montant calcule de la remise % sur PU HT (exemple 20)
|
var $remise; // Montant calcule de la remise % sur PU HT (exemple 20)
|
||||||
|
|
||||||
// From llx_product
|
// From llx_product
|
||||||
var $ref; // Reference produit
|
var $ref; // Product ref (deprecated)
|
||||||
var $libelle; // Label produit
|
var $product_ref; // Product ref
|
||||||
|
var $libelle; // Product label (deprecated)
|
||||||
|
var $product_label; // Product label
|
||||||
var $product_desc; // Description produit
|
var $product_desc; // Description produit
|
||||||
|
|
||||||
|
|
||||||
@@ -3151,8 +3153,10 @@ class FactureLigne
|
|||||||
$this->price = $objp->price;
|
$this->price = $objp->price;
|
||||||
$this->remise = $objp->remise;
|
$this->remise = $objp->remise;
|
||||||
|
|
||||||
$this->ref = $objp->product_ref;
|
$this->ref = $objp->product_ref; // deprecated
|
||||||
$this->libelle = $objp->product_libelle;
|
$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->product_desc = $objp->product_desc;
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|||||||
@@ -2136,8 +2136,8 @@ function print_liste_field_titre($name, $file, $field, $begin="", $options="", $
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Affichage d'un titre
|
* Show a title (deprecated. use print_fiche_titre instrad)
|
||||||
* \param titre Le titre a afficher
|
* @param titre Title to show
|
||||||
*/
|
*/
|
||||||
function print_titre($titre)
|
function print_titre($titre)
|
||||||
{
|
{
|
||||||
@@ -2145,12 +2145,12 @@ function print_titre($titre)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Show a title with picto
|
* Show a title with picto
|
||||||
* \param titre Title to show
|
* @param titre Title to show
|
||||||
* \param mesg Added message to show on right
|
* @param mesg Added message to show on right
|
||||||
* \param picto Icon to use before title (should be a 32x32 transparent png file)
|
* @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 pictoisfullpath 1=Icon name is a full absolute url of image
|
||||||
* \param id To force an id on html objects
|
* @param id To force an id on html objects
|
||||||
*/
|
*/
|
||||||
function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
|
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
|
* Load a title with picto
|
||||||
* \param titre Title to show
|
* @param titre Title to show
|
||||||
* \param mesg Added message to show on right
|
* @param mesg Added message to show on right
|
||||||
* \param picto Icon to use before title (should be a 32x32 transparent png file)
|
* @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 pictoisfullpath 1=Icon name is a full absolute url of image
|
||||||
* \param id To force an id on html objects
|
* @param id To force an id on html objects
|
||||||
*/
|
*/
|
||||||
function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
|
function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/webservices/client.php
|
* \file htdocs/webservices/demo_client_other.php
|
||||||
* \brief Page demo client appel WebServices Dolibarr
|
* \brief Demo page to make a client call to Dolibarr WebServices "server_other"
|
||||||
* \version $Id$
|
* \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_DOL_URL = $dolibarr_main_url_root.'/webservices/server_other.php';
|
||||||
$WS_METHOD = 'getVersions';
|
$WS_METHOD = 'getVersions';
|
||||||
|
|
||||||
// Set the parameters to send to the WebService
|
|
||||||
$parameters = array();
|
|
||||||
|
|
||||||
// Set the WebService URL
|
// Set the WebService URL
|
||||||
dol_syslog("Create soapclient_nusoap for URL=".$WS_DOL_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.
|
// 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);
|
dol_syslog("Call method ".$WS_METHOD);
|
||||||
$result = $soapclient->call($WS_METHOD,$parameters);
|
$result = $soapclient->call($WS_METHOD,$parameters);
|
||||||
if (! $result)
|
if (! $result)
|
||||||
@@ -51,7 +56,10 @@ if (! $result)
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show page with result
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
header("Content-type: text/html; charset=utf8");
|
header("Content-type: text/html; charset=utf8");
|
||||||
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
|
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
|
||||||
echo '<html>'."\n";
|
echo '<html>'."\n";
|
||||||
|
|||||||
121
htdocs/webservices/demo_invoice_other.php
Executable file
121
htdocs/webservices/demo_invoice_other.php
Executable file
@@ -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";;
|
||||||
|
?>
|
||||||
24
htdocs/webservices/client.php → htdocs/webservices/demo_thirdparty_other.php
Normal file → Executable file
24
htdocs/webservices/client.php → htdocs/webservices/demo_thirdparty_other.php
Normal file → Executable file
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/webservices/client.php
|
* \file htdocs/webservices/demo_thirdparty_other.php
|
||||||
* \brief Page demo client appel WebServices Dolibarr
|
* \brief Demo page to make a client call to Dolibarr WebServices "server_other"
|
||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -28,11 +28,9 @@ set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
|
|||||||
require_once("../master.inc.php");
|
require_once("../master.inc.php");
|
||||||
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
|
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
|
||||||
|
|
||||||
$WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server.php';
|
$WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server_thirdparty.php';
|
||||||
$WS_METHOD = 'getVersions';
|
$WS_METHOD = 'getThirdParty';
|
||||||
|
|
||||||
// Set the parameters to send to the WebService
|
|
||||||
$parameters = array();
|
|
||||||
|
|
||||||
// Set the WebService URL
|
// Set the WebService URL
|
||||||
dol_syslog("Create soapclient_nusoap for URL=".$WS_DOL_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.
|
// 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);
|
dol_syslog("Call method ".$WS_METHOD);
|
||||||
$result = $soapclient->call($WS_METHOD,$parameters);
|
$result = $soapclient->call($WS_METHOD,$parameters);
|
||||||
if (! $result)
|
if (! $result)
|
||||||
@@ -51,7 +56,10 @@ if (! $result)
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show page with result
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
header("Content-type: text/html; charset=utf8");
|
header("Content-type: text/html; charset=utf8");
|
||||||
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
|
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
|
||||||
echo '<html>'."\n";
|
echo '<html>'."\n";
|
||||||
@@ -74,11 +74,19 @@ $server->wsdl->addComplexType(
|
|||||||
'',
|
'',
|
||||||
array(
|
array(
|
||||||
'id' => array('name'=>'id','type'=>'xsd:string'),
|
'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'),
|
'fk_product' => array('name'=>'fk_product','type'=>'xsd:int'),
|
||||||
'total_ht' => array('name'=>'total_ht','type'=>'xsd:int'),
|
'total_net' => array('name'=>'total_net','type'=>'xsd:double'),
|
||||||
'total_vat' => array('name'=>'total_vat','type'=>'xsd:int'),
|
'total_vat' => array('name'=>'total_vat','type'=>'xsd:double'),
|
||||||
'total_ttc' => array('name'=>'total_ttc','type'=>'xsd:int')
|
'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'),
|
'ref' => array('name'=>'ref','type'=>'xsd:string'),
|
||||||
'fk_user_author' => array('name'=>'fk_user_author','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'),
|
'fk_user_valid' => array('name'=>'fk_user_valid','type'=>'xsd:string'),
|
||||||
'date' => array('name'=>'date','type'=>'xsd:int'),
|
'date' => array('name'=>'date','type'=>'xsd:date'),
|
||||||
'date_creation' => array('name'=>'date_creation','type'=>'xsd:int'),
|
'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
|
||||||
'date_validation' => array('name'=>'date_validation','type'=>'xsd:int'),
|
'date_validation' => array('name'=>'date_validation','type'=>'xsd:dateTime'),
|
||||||
'date_modification' => array('name'=>'date_modification','type'=>'xsd:int'),
|
'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
|
||||||
'type' => array('name'=>'type','type'=>'xsd:int'),
|
'type' => array('name'=>'type','type'=>'xsd:int'),
|
||||||
'total' => array('name'=>'type','type'=>'xsd:int'),
|
'total_net' => array('name'=>'type','type'=>'xsd:double'),
|
||||||
'total_vat' => array('name'=>'type','type'=>'xsd:int'),
|
'total_vat' => array('name'=>'type','type'=>'xsd:double'),
|
||||||
'total_vat' => array('name'=>'type','type'=>'xsd:int'),
|
'total' => array('name'=>'type','type'=>'xsd:double'),
|
||||||
'note' => array('name'=>'note','type'=>'xsd:int'),
|
'note' => array('name'=>'note','type'=>'xsd:string'),
|
||||||
'note_public' => array('name'=>'note_public','type'=>'xsd:int'),
|
'note_public' => array('name'=>'note_public','type'=>'xsd:string'),
|
||||||
'status' => array('name'=>'status','type'=>'xsd:int'),
|
'status' => array('name'=>'status','type'=>'xsd:int'),
|
||||||
'close_code' => array('name'=>'close_code','type'=>'xsd:int'),
|
'close_code' => array('name'=>'close_code','type'=>'xsd:string'),
|
||||||
'close_note' => array('name'=>'close_note','type'=>'xsd:int'),
|
'close_note' => array('name'=>'close_note','type'=>'xsd:string'),
|
||||||
'lines' => array('name'=>'lines','type'=>'tns:LinesArray')
|
'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)
|
function getInvoice($authentication,$id,$ref)
|
||||||
{
|
{
|
||||||
global $db,$conf,$langs;
|
global $db,$conf,$langs;
|
||||||
@@ -191,6 +201,11 @@ function getInvoice($authentication,$id,$ref)
|
|||||||
$errorcode='';$errorlabel='';
|
$errorcode='';$errorlabel='';
|
||||||
$error=0;
|
$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))
|
if (! $error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY))
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@@ -233,15 +248,15 @@ function getInvoice($authentication,$id,$ref)
|
|||||||
$i=0;
|
$i=0;
|
||||||
foreach($invoice->lines as $line)
|
foreach($invoice->lines as $line)
|
||||||
{
|
{
|
||||||
//var_dump($line);
|
//var_dump($line); exit;
|
||||||
$linesresp[]=array(
|
$linesresp[]=array(
|
||||||
'id'=>$line->rowid,
|
'id'=>$line->rowid,
|
||||||
'type'=>$line->type,
|
'type'=>$line->product_type,
|
||||||
'total_ht'=>$line->total_ht,
|
'total_net'=>$line->total_ht,
|
||||||
'total_vat'=>$line->total_tva,
|
'total_vat'=>$line->total_tva,
|
||||||
'total_ttc'=>$line->total_ttc,
|
'total'=>$line->total_ttc,
|
||||||
|
'vat_rate'=>$line->tva_tx,
|
||||||
|
'qty'=>$line->qty
|
||||||
);
|
);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@@ -252,6 +267,7 @@ function getInvoice($authentication,$id,$ref)
|
|||||||
'invoice'=>array(
|
'invoice'=>array(
|
||||||
'id' => $invoice->id,
|
'id' => $invoice->id,
|
||||||
'ref' => $invoice->ref,
|
'ref' => $invoice->ref,
|
||||||
|
'status'=>$invoice->statut,
|
||||||
'fk_user_author' => $invoice->fk_user_author,
|
'fk_user_author' => $invoice->fk_user_author,
|
||||||
'fk_user_valid' => $invoice->fk_user_valid,
|
'fk_user_valid' => $invoice->fk_user_valid,
|
||||||
'lines' => $linesresp
|
'lines' => $linesresp
|
||||||
@@ -263,7 +279,7 @@ function getInvoice($authentication,$id,$ref)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$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
|
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)
|
function getInvoicesForThirdParty($authentication,$idthirdparty)
|
||||||
{
|
{
|
||||||
global $db,$conf,$langs;
|
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'];
|
if ($authentication['entity']) $conf->entity=$authentication['entity'];
|
||||||
|
|
||||||
@@ -311,10 +329,14 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
|
|||||||
{
|
{
|
||||||
$linesinvoice=array();
|
$linesinvoice=array();
|
||||||
|
|
||||||
$sql.='SELECT rowid, facnumber as ref, type, total_ttc, total, tva';
|
$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.=' 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.= ' 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);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@@ -324,31 +346,38 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
|
|||||||
while ($i < $num)
|
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
|
// Define lines of invoice
|
||||||
$linesresp=array();
|
$linesresp=array();
|
||||||
|
foreach($invoice->lines as $line)
|
||||||
|
{
|
||||||
$linesresp[]=array(
|
$linesresp[]=array(
|
||||||
'id'=>100,
|
'id'=>$line->rowid,
|
||||||
'type'=>1,
|
'type'=>$line->product_type,
|
||||||
'total_ht'=>$line->total_ht,
|
'total_net'=>$line->total_ht,
|
||||||
'total_vat'=>$line->total_tva,
|
'total_vat'=>$line->total_tva,
|
||||||
'total_ttc'=>$line->total_ttc,
|
'total'=>$line->total_ttc,
|
||||||
);
|
'vat_rate'=>$line->tva_tx,
|
||||||
$linesresp[]=array(
|
'qty'=>$line->qty,
|
||||||
'id'=>101,
|
'product_ref'=>$line->product_ref,
|
||||||
'type'=>1,
|
'product_label'=>$line->product_label,
|
||||||
'total_ht'=>$line->total_ht,
|
'product_desc'=>$line->product_desc,
|
||||||
'total_vat'=>$line->total_tva,
|
|
||||||
'total_ttc'=>$line->total_ttc,
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Now define invoice
|
// Now define invoice
|
||||||
$linesinvoice[]=array(
|
$linesinvoice[]=array(
|
||||||
'id'=>'1',
|
'id'=>$invoice->id,
|
||||||
'ref'=>'aa',
|
'ref'=>$invoice->ref,
|
||||||
'type'=>1,
|
'type'=>$invoice->type,
|
||||||
'total_ht'=>10,
|
'status'=>$invoice->statut,
|
||||||
'total_vat'=>$line->total_tva,
|
'total_net'=>$invoice->total_ht,
|
||||||
'total_ttc'=>$line->total_ttc,
|
'total_vat'=>$invoice->total_tva,
|
||||||
|
'total'=>$invoice->total_ttc,
|
||||||
'lines' => $linesresp
|
'lines' => $linesresp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,12 @@ function getVersions($authentication)
|
|||||||
$errorcode='';$errorlabel='';
|
$errorcode='';$errorlabel='';
|
||||||
$error=0;
|
$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++;
|
$error++;
|
||||||
$errorcode='BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel='Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup';
|
$errorcode='BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel='Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup';
|
||||||
|
|||||||
@@ -133,6 +133,11 @@ function getThirdParty($authentication,$id,$name)
|
|||||||
$errorcode='';$errorlabel='';
|
$errorcode='';$errorlabel='';
|
||||||
$error=0;
|
$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))
|
if (! $error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY))
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@@ -201,7 +206,7 @@ function getThirdParty($authentication,$id,$name)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$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
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user