Fix: A ton of bug on oscommerce interface by webservice

This commit is contained in:
Laurent Destailleur 2009-11-06 16:27:41 +00:00
parent b89fd29595
commit e351396f26
17 changed files with 276 additions and 233 deletions

View File

@ -339,7 +339,7 @@ Module700Desc=Donations' management
Module800Name=OSCommerce by direct database access Module800Name=OSCommerce by direct database access
Module800Desc=Interface to show an OSCommerce or OSCSS shop via direct database access Module800Desc=Interface to show an OSCommerce or OSCSS shop via direct database access
Module900Name=OSCommerce by WS Module900Name=OSCommerce by WS
Module900Desc=Interface to show an OSCommerce shop via Web services.\nThis module requiere you to install components from /oscommerce_ws/ws_server into your OSCommerce server. See README file in /oscommerce_ws/ws_server. Module900Desc=Interface to show an OSCommerce shop via Web services. This module requiere you to install components from /oscommerce_ws/ws_server into your OSCommerce server. See README file in /oscommerce_ws/ws_server.
Module1200Name=Mantis Module1200Name=Mantis
Module1200Desc=Mantis integration Module1200Desc=Mantis integration
Module1400Name=Accounting Module1400Name=Accounting

View File

@ -339,7 +339,7 @@ Module700Desc = Gestion des dons
Module800Name = OSCommerce direct Module800Name = OSCommerce direct
Module800Desc = Interface de visualisation d'une boutique OSCommerce ou OSCSS par accès direct en base. Module800Desc = Interface de visualisation d'une boutique OSCommerce ou OSCSS par accès direct en base.
Module900Name = OSCommerce by WS Module900Name = OSCommerce by WS
Module900Desc = Interface de visualisation d'une boutique OSCommerce par accès via des Web services.\nCe module requiert d'installer les fichiers de /oscommerce_ws/ws_server sur OSCommerce. Voir fichier README dans /oscommerce_ws/ws_server. Module900Desc = Interface de visualisation d'une boutique OSCommerce par accès via des Web services. Ce module requiert d'installer les fichiers de /oscommerce_ws/ws_server sur OSCommerce. Voir fichier README dans /oscommerce_ws/ws_server.
Module1200Name = Mantis Module1200Name = Mantis
Module1200Desc = Interface avec le bug tracking Mantis Module1200Desc = Interface avec le bug tracking Mantis
Module1400Name = Comptabilité Module1400Name = Comptabilité

View File

@ -44,6 +44,10 @@ $parameters = array("custid"=>"0");
// Set the WebService URL // Set the WebService URL
$client = new nusoap_client(OSCWS_DIR."ws_customers.php"); $client = new nusoap_client(OSCWS_DIR."ws_customers.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
$result = $client->call("get_Client",$parameters ); $result = $client->call("get_Client",$parameters );
@ -61,7 +65,7 @@ elseif (!($err = $client->getError()) )
// un client osc // un client osc
$OscClient = new Osc_Customer($db); $OscClient = new Osc_Customer($db);
if ($num > 0) { if ($num > 0) {
print "<TABLE width=\"100%\" class=\"noborder\">"; print "<TABLE width=\"100%\" class=\"noborder\">";
print '<TR class="liste_titre">'; print '<TR class="liste_titre">';
@ -74,7 +78,7 @@ elseif (!($err = $client->getError()) )
print '<td align="center">'.$langs->trans("Phone").'</td>'; print '<td align="center">'.$langs->trans("Phone").'</td>';
print '<TD align="center">Importer</TD>'; print '<TD align="center">Importer</TD>';
print "</TR>\n"; print "</TR>\n";
while ($i < $num) { while ($i < $num) {
$var=!$var; $var=!$var;
$custid = $OscClient->get_clientid($result[$i][customers_id]); $custid = $OscClient->get_clientid($result[$i][customers_id]);
@ -89,7 +93,7 @@ elseif (!($err = $client->getError()) )
print '<TD align="center">'.$result[$i][customers_telephone]."</TD>\n"; print '<TD align="center">'.$result[$i][customers_telephone]."</TD>\n";
if ($custid) $lib = "modifier"; if ($custid) $lib = "modifier";
else $lib = "<u>importer</u>"; else $lib = "<u>importer</u>";
print '<TD align="center"><a href="fiche.php?action=import&custid='.$result[$i][customers_id].'"'.">".$lib."</a></TD>\n"; print '<TD align="center"><a href="fiche.php?action=import&custid='.$result[$i][customers_id].'"'.">".$lib."</a></TD>\n";
print "</TR>\n"; print "</TR>\n";
$i++; $i++;
@ -101,7 +105,7 @@ elseif (!($err = $client->getError()) )
} }
} }
else { else {
dol_print_error('',"Erreur service web ".$err); print $client->getHTTPBody($client->response);
} }
print "</TABLE>"; print "</TABLE>";

View File

@ -55,12 +55,12 @@ class Osc_customer
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param id Id client (0 par defaut) * \param id Id client (0 par defaut)
*/ */
function Osc_customer($DB, $id=0) { function Osc_customer($DB, $id=0) {
global $langs; global $langs;
global $conf; global $conf;
$this->osc_custid = $id ; $this->osc_custid = $id ;
/* les initialisations n<>cessaires */ /* les initialisations n<>cessaires */
@ -71,14 +71,14 @@ class Osc_customer
/** /**
* \brief Charge le client OsC en m<EFBFBD>moire * \brief Charge le client OsC en m<EFBFBD>moire
* \param id Id du client dans OsC * \param id Id du client dans OsC
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function fetch($id='') function fetch($id='')
{ {
global $langs; global $langs;
global $conf; global $conf;
$this->error = ''; $this->error = '';
dol_syslog("Osc_customer::fetch $id=$id ref=$ref"); dol_syslog("Osc_customer::fetch $id=$id ref=$ref");
// Verification parametres // Verification parametres
@ -99,6 +99,10 @@ class Osc_customer
// Set the WebService URL // Set the WebService URL
$client = new nusoap_client(OSCWS_DIR."/ws_customers.php"); $client = new nusoap_client(OSCWS_DIR."/ws_customers.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
// Call the WebSeclient->fault)rvice and store its result in $obj // Call the WebSeclient->fault)rvice and store its result in $obj
$obj = $client->call("get_Client",$parameters ); $obj = $client->call("get_Client",$parameters );
@ -126,14 +130,14 @@ class Osc_customer
else { else {
$this->error = 'Erreur '.$err ; $this->error = 'Erreur '.$err ;
return -1; return -1;
} }
return 0; return 0;
} }
/** /**
* \brief Mise <EFBFBD> jour de la table de transition * \brief Mise <EFBFBD> jour de la table de transition
* \param oscid Id du client dans OsC * \param oscid Id du client dans OsC
* \param socid champ soci<EFBFBD>t<EFBFBD>.rowid * \param socid champ soci<EFBFBD>t<EFBFBD>.rowid
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function transcode($oscid, $socid) function transcode($oscid, $socid)
@ -167,7 +171,7 @@ class Osc_customer
// $this->db->rollback(); // $this->db->rollback();
// return -1; // return -1;
} }
return 0; return 0;
} }
// converti le client osc en client dolibarr // converti le client osc en client dolibarr
@ -179,10 +183,10 @@ class Osc_customer
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
// test d'erreurs // test d'erreurs
if ($obj) return $obj->fk_soc[0]; if ($obj) return $obj->fk_soc[0];
else return ''; else return '';
} }
} }
?> ?>

View File

@ -45,6 +45,10 @@ $parameters = array("orderid"=>"0");
// Set the WebService URL // Set the WebService URL
$client = new nusoap_client(OSCWS_DIR."ws_orders.php"); $client = new nusoap_client(OSCWS_DIR."ws_orders.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
$result = $client->call("get_Order",$parameters ); $result = $client->call("get_Order",$parameters );
@ -62,7 +66,7 @@ elseif (!($err = $client->getError()) )
// une commande osc // une commande osc
$OscOrder = new Osc_Order($db); $OscOrder = new Osc_Order($db);
if ($num > 0) { if ($num > 0) {
print "<TABLE width=\"100%\" class=\"noborder\">"; print "<TABLE width=\"100%\" class=\"noborder\">";
print '<TR class="liste_titre">'; print '<TR class="liste_titre">';
@ -75,7 +79,7 @@ elseif (!($err = $client->getError()) )
print '<td align="center">Statut</td>'; print '<td align="center">Statut</td>';
print '<TD align="center">Importer</TD>'; print '<TD align="center">Importer</TD>';
print "</TR>\n"; print "</TR>\n";
while ($i < $num) { while ($i < $num) {
$var=!$var; $var=!$var;
@ -102,7 +106,7 @@ elseif (!($err = $client->getError()) )
} }
} }
else { else {
dol_print_error('',"Erreur service web ".$err); print $client->getHTTPBody($client->response);
} }
print "</TABLE>"; print "</TABLE>";

View File

@ -57,11 +57,11 @@ class Osc_order
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param id Id client (0 par defaut) * \param id Id client (0 par defaut)
*/ */
function Osc_order($DB, $id=0) { function Osc_order($DB, $id=0) {
global $langs; global $langs;
$this->osc_orderid = $id ; $this->osc_orderid = $id ;
$this->db = $DB; $this->db = $DB;
/* les initialisations n<>cessaires */ /* les initialisations n<>cessaires */
@ -70,14 +70,14 @@ class Osc_order
/** /**
* \brief Charge la commande OsC en m<EFBFBD>moire * \brief Charge la commande OsC en m<EFBFBD>moire
* \param id Id de la commande dans OsC * \param id Id de la commande dans OsC
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function fetch($id='') function fetch($id='')
{ {
global $langs; global $langs;
global $conf; global $conf;
$this->error = ''; $this->error = '';
dol_syslog("Osc_order::fetch $id=$id "); dol_syslog("Osc_order::fetch $id=$id ");
// Verification parametres // Verification parametres
@ -98,6 +98,10 @@ class Osc_order
// Set the WebService URL // Set the WebService URL
$client = new nusoap_client(OSCWS_DIR."/ws_orders.php"); $client = new nusoap_client(OSCWS_DIR."/ws_orders.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
// Call the WebSeclient->fault)rvice and store its result in $obj // Call the WebSeclient->fault)rvice and store its result in $obj
$obj = $client->call("get_Order",$parameters ); $obj = $client->call("get_Order",$parameters );
@ -130,7 +134,7 @@ class Osc_order
$this->error = 'Erreur '.$err ; $this->error = 'Erreur '.$err ;
return -1; return -1;
} }
// print_r($this); // print_r($this);
return 0; return 0;
} }
@ -149,7 +153,7 @@ class Osc_order
/* initialisation */ /* initialisation */
$oscclient = new Osc_Customer($this->db); $oscclient = new Osc_Customer($this->db);
$clientid = $oscclient->get_clientid($this->osc_custid); $clientid = $oscclient->get_clientid($this->osc_custid);
$oscproduct = new Osc_product($this->db); $oscproduct = new Osc_product($this->db);
$commande->socid = $clientid; $commande->socid = $clientid;
@ -159,7 +163,7 @@ class Osc_order
/* on force */ /* on force */
$commande->statut = 0; //<2F> voir $commande->statut = 0; //<2F> voir
$commande->source = 0; // <20> v<>rifier $commande->source = 0; // <20> v<>rifier
//les lignes //les lignes
for ($i = 0; $i < sizeof($this->osc_lines);$i++) { for ($i = 0; $i < sizeof($this->osc_lines);$i++) {
@ -184,15 +188,15 @@ class Osc_order
$commande->lines[$fp]->remise_percent = 0; $commande->lines[$fp]->remise_percent = 0;
return $commande; return $commande;
} }
} }
/** /**
* \brief Mise <EFBFBD> jour de la table de transition * \brief Mise <EFBFBD> jour de la table de transition
* \param oscid Id du produit dans OsC * \param oscid Id du produit dans OsC
* \param prodid champ r<EFBFBD>f<EFBFBD>rence * \param prodid champ r<EFBFBD>f<EFBFBD>rence
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function transcode($osc_orderid, $doli_orderid) function transcode($osc_orderid, $doli_orderid)
@ -226,7 +230,7 @@ class Osc_order
// $this->db->rollback(); // $this->db->rollback();
// return -1; // return -1;
} }
return 0; return 0;
} }
// converti le client osc en client dolibarr // converti le client osc en client dolibarr
@ -238,7 +242,7 @@ class Osc_order
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
// test d'erreurs // test d'erreurs
if ($obj) return $obj->fk_commande; if ($obj) return $obj->fk_commande;
else return ''; else return '';
} }

View File

@ -28,7 +28,8 @@
*/ */
// URL To reach web services // URL To reach web services
define(OSCWS_DIR,'http://myoscserver/ws_server/'); //define(OSCWS_DIR,'http://myoscserver/ws_server/');
define(OSCWS_DIR,'http://127.0.0.1/oscommerce_ws/ws_server/');
// URL To reach OSCommerce // URL To reach OSCommerce
define(OSC_URL, 'http://myoscserver/'); // url du site OSC define(OSC_URL, 'http://myoscserver/'); // url du site OSC

View File

@ -16,13 +16,13 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/** /**
\file htdocs/oscommerce_ws/index.php \file htdocs/oscommerce_ws/index.php
\ingroup oscommerce2 \ingroup oscommerce2
\brief Page accueil zone boutique \brief Page accueil zone boutique
\version $Id$ \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -37,7 +37,7 @@ print_fiche_titre($langs->trans("OSCommerceShop"));
if (! @ini_get('allow_url_fopen')) if (! @ini_get('allow_url_fopen'))
{ {
$langs->load("errors"); $langs->load("errors");
print '<div class="warning">'.$langs->trans("WarningAllowUrlFopenMustBeOn").'</div><br>'; print '<div class="warning">'.$langs->trans("WarningAllowUrlFopenMustBeOn").'</div><br>';
} }
@ -56,11 +56,17 @@ require_once("./includes/configure.php");
$parameters = array(); $parameters = array();
// Set the WebService URL // Set the WebService URL
//print OSCWS_DIR."ws_orders.php"; exit;
$client = new nusoap_client(OSCWS_DIR."ws_orders.php"); $client = new nusoap_client(OSCWS_DIR."ws_orders.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
/*
/* Chiffre d'affaire /*
*/ /* Chiffre d'affaire
*/
print_titre($langs->trans('SalesTurnover')); print_titre($langs->trans('SalesTurnover'));
@ -69,36 +75,39 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Year").'</td>';
print '<td>'.$langs->trans("Month").'</td>'; print '<td>'.$langs->trans("Month").'</td>';
print '<td align="right">'.$langs->trans("Total").'</td></tr>'; print '<td align="right">'.$langs->trans("Total").'</td></tr>';
//$client->setDebugLevel(9);
// Call the WebService and store its result in $result. // Call the WebService and store its result in $result.
$result = $client->call("get_CAmensuel",$parameters ); $result = $client->call("get_CAmensuel",$parameters );
if ($client->fault) { if ($client->fault) {
dol_print_error('',"Erreur de connexion "); dol_print_error('',"Erreur de connexion ");
print_r($client->faultstring); print_r($client->faultstring);
} }
elseif (!($err = $client->getError()) ) elseif (!($err = $client->getError()) )
{ {
$num=0; $num=0;
if ($result) $num = sizeof($result); if ($result) $num = sizeof($result);
$var=True; $var=True;
$i=0; $i=0;
if ($num > 0) { if ($num > 0) {
while ($i < $num) while ($i < $num)
{ {
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td align="left">'.$result[$i][an].'</td>'; print '<td align="left">'.$result[$i][an].'</td>';
print '<td align="left">'.$result[$i][mois].'</td>'; print '<td align="left">'.$result[$i][mois].'</td>';
print '<td align="right">'.convert_price($result[$i][value]).'</td>'; print '<td align="right">'.convert_price($result[$i][value]).'</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
} }
} }
else else
{ {
dol_print_error('',"Erreur du service web ".$err); print $client->getHTTPBody($client->response);
} }
@ -115,40 +124,40 @@ print_titre($langs->trans("Orders"));
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("LastOrders").'</td></tr>'; print '<td colspan="4">'.$langs->trans("LastOrders").'</td></tr>';
// Call the WebService and store its result in $result. // Call the WebService and store its result in $result.
$parameters = array("limit"=>OSC_MAXNBCOM); $parameters = array("limit"=>OSC_MAXNBCOM);
$result = $client->call("get_orders",$parameters ); $result = $client->call("get_orders",$parameters );
if ($client->fault) { if ($client->fault) {
dol_print_error('',"Erreur de connexion "); dol_print_error('',"Erreur de connexion ");
} }
elseif (!($err = $client->getError()) ) { elseif (!($err = $client->getError()) ) {
$num=0; $num=0;
if ($result) $num = sizeof($result); if ($result) $num = sizeof($result);
$var=True; $var=True;
$i=0; $i=0;
if ($num > 0) { if ($num > 0) {
$num = min($num,OSC_MAXNBCOM); $num = min($num,OSC_MAXNBCOM);
while ($i < $num) { while ($i < $num) {
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.convert_price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>'; print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.convert_price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>';
$i++; $i++;
} }
} }
} }
else { else {
dol_print_error('',"Erreur du service web ".$err); print $client->getHTTPBody($client->response);
} }
print "</table><br>"; print "</table><br>";
/* /*
* 5 derni<EFBFBD>res commandes en attente * 5 derni<EFBFBD>res commandes en attente
*/ */
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -158,28 +167,28 @@ $parameters = array("limit"=>OSC_MAXNBCOM, "status"=>OSC_ORDWAIT);
$result = $client->call("get_orders",$parameters ); $result = $client->call("get_orders",$parameters );
if ($client->fault) { if ($client->fault) {
dol_print_error('',"Erreur webservice ".$client->faultstring); dol_print_error('',"Erreur webservice ".$client->faultstring);
} }
elseif (!($err = $client->getError()) ) { elseif (!($err = $client->getError()) ) {
$var=True; $var=True;
$i=0; $i=0;
$num=0; $num=0;
if ($result) $num = sizeof($result); if ($result) $num = sizeof($result);
$langs->load("orders"); $langs->load("orders");
if ($num > 0) { if ($num > 0) {
$num = min($num,OSC_MAXNBCOM); $num = min($num,OSC_MAXNBCOM);
while ($i < $num) { while ($i < $num) {
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.convert_price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>'; print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.convert_price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>';
$i++; $i++;
} }
} }
} }
else { else {
dol_print_error('',"Erreur du service web ".$err); print $client->getHTTPBody($client->response);
} }
print "</table><br>"; print "</table><br>";
@ -190,41 +199,41 @@ print "</table><br>";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("TreatmentInProgress").'</td></tr>'; print '<td colspan="4">'.$langs->trans("TreatmentInProgress").'</td></tr>';
$parameters = array("limit"=>OSC_MAXNBCOM, "status"=>OSC_ORDPROCESS); $parameters = array("limit"=>OSC_MAXNBCOM, "status"=>OSC_ORDPROCESS);
$result = $client->call("get_orders",$parameters ); $result = $client->call("get_orders",$parameters );
if ($client->fault) { if ($client->fault) {
dol_print_error('',"Erreur webservice ".$client->faultstring); dol_print_error('',"Erreur webservice ".$client->faultstring);
} }
elseif (!($err = $client->getError()) ) { elseif (!($err = $client->getError()) ) {
$var=True; $var=True;
$i=0; $i=0;
$num=0; $num=0;
if ($result) $num = sizeof($result); if ($result) $num = sizeof($result);
$langs->load("orders"); $langs->load("orders");
if ($num > 0) { if ($num > 0) {
$num = min($num,OSC_MAXNBCOM); $num = min($num,OSC_MAXNBCOM);
while ($i < $num) { while ($i < $num) {
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.convert_price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>'; print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.convert_price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>';
$i++; $i++;
$var=!$var; $var=!$var;
} }
} }
} }
else { else {
dol_print_error('',"Erreur du service web ".$err); print $client->getHTTPBody($client->response);
} }
print "</table><br>"; print "</table><br>";
print '</td></tr><tr>'; print '</td></tr><tr>';
/* /*
* Derniers clients qui ont command<EFBFBD> * Derniers clients qui ont command<EFBFBD>
*/ */
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -234,29 +243,29 @@ $parameters = array("limit"=>OSC_MAXNBCOM);
$result = $client->call("get_lastOrderClients",$parameters ); $result = $client->call("get_lastOrderClients",$parameters );
if ($client->fault) { if ($client->fault) {
dol_print_error('',"Erreur webservice ".$client->faultstring); dol_print_error('',"Erreur webservice ".$client->faultstring);
} }
elseif (!($err = $client->getError()) ) { elseif (!($err = $client->getError()) ) {
$var=True; $var=True;
$i=0; $i=0;
$num=0; $num=0;
if ($result) $num = sizeof($result); if ($result) $num = sizeof($result);
$langs->load("orders"); $langs->load("orders");
if ($num > 0) { if ($num > 0) {
$num = min($num,OSC_MAXNBCOM); $num = min($num,OSC_MAXNBCOM);
while ($i < $num) { while ($i < $num) {
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print "<td>".$result[$i][date_purchased]."</td><td>".$result[$i][customers_name]."</td><td>".$result[$i][delivery_country]."</td><td>".convert_price($result[$i][value])."</td><td>".$result[$i][payment_method]."</td><td>".$result[$i][orders_id]."</td><td>".$result[$i][statut]."</td></tr>"; print "<td>".$result[$i][date_purchased]."</td><td>".$result[$i][customers_name]."</td><td>".$result[$i][delivery_country]."</td><td>".convert_price($result[$i][value])."</td><td>".$result[$i][payment_method]."</td><td>".$result[$i][orders_id]."</td><td>".$result[$i][statut]."</td></tr>";
$i++; $i++;
$var=!$var; $var=!$var;
} }
print "</table><br>"; print "</table><br>";
} }
} }
else { else {
dol_print_error('',"Erreur du service web ".$err); print $client->getHTTPBody($client->response);
} }

View File

@ -29,7 +29,7 @@ if ($_GET["action"] == 'liste' )
{ {
// affichage des produits en vente a partir de la tavle de transco // affichage des produits en vente a partir de la tavle de transco
$sql = "SELECT o.doli_prodidp as idp, o.osc_prodid as oscid, o.osc_lastmodif as date "; $sql = "SELECT o.doli_prodidp as idp, o.osc_prodid as oscid, o.osc_lastmodif as date ";
$sql .= "FROM ".MAIN_DB_PREFIX."osc_product as o"; $sql .= "FROM ".MAIN_DB_PREFIX."osc_product as o";
if ( $db->query($sql) ) if ( $db->query($sql) )
{ {
@ -46,7 +46,7 @@ if ($_GET["action"] == 'liste' )
{ {
$var=!$var; $var=!$var;
$obj = $db->fetch_object(); $obj = $db->fetch_object();
print '<tr $bc[$var]><td nowrap><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$obj->idp.'">'.img_object($langs->trans("ShowProduct"),"Product").' '.$obj->idp.'</a></td>'; print '<tr $bc[$var]><td nowrap><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$obj->idp.'">'.img_object($langs->trans("ShowProduct"),"Product").' '.$obj->idp.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("OscProd"),"Product").' '.$obj->oscid.'</a></td></tr>'; print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("OscProd"),"Product").' '.$obj->oscid.'</a></td></tr>';
$i++; $i++;
@ -69,50 +69,54 @@ if ($_GET["action"] == 'vendre' )
$prod['desc'] = $product->description; $prod['desc'] = $product->description;
$prod['quant'] = $_POST["qty"]; $prod['quant'] = $_POST["qty"];
$prod['prix'] = convert_backprice($product->price); $prod['prix'] = convert_backprice($product->price);
// a gerer $product->tx_tva // a gerer $product->tx_tva
$prod['poids'] = $product->weight; $prod['poids'] = $product->weight;
// gerer $product->weight_units // gerer $product->weight_units
$prod['dispo'] = ''; $prod['dispo'] = '';
$prod['status'] = '1'; $prod['status'] = '1';
$prod['fourn'] = ''; $prod['fourn'] = '';
$prod['url'] = ''; $prod['url'] = '';
//recherche de l'image //recherche de l'image
$pdir = get_exdir($product->id,2) . $product->id ."/photos/"; $pdir = get_exdir($product->id,2) . $product->id ."/photos/";
$dir = $conf->produit->dir_output . '/'. $pdir; $dir = $conf->produit->dir_output . '/'. $pdir;
$img = $product->liste_photos($dir); $img = $product->liste_photos($dir);
if (sizeof($img) ==0) $prod['image'] = ''; if (sizeof($img) ==0) $prod['image'] = '';
else else
{ {
if ($img[0]['photo_vignette']) $filename=$img[0]['photo_vignette']; if ($img[0]['photo_vignette']) $filename=$img[0]['photo_vignette'];
else $filename=$img[0]['photo']; else $filename=$img[0]['photo'];
$prod['image'] = dol_trunc($filename,16); $prod['image'] = dol_trunc($filename,16);
} }
// print_r($prod); // print_r($prod);
// print '<br/>'; // print '<br/>';
set_magic_quotes_runtime(0); set_magic_quotes_runtime(0);
//WebService Client. //WebService Client.
require_once(NUSOAP_PATH."/nusoap.php"); require_once(NUSOAP_PATH."/nusoap.php");
// Creation // Creation
// Set the parameters to send to the WebService // Set the parameters to send to the WebService
$parameters = array("prod"=>$prod); $parameters = array("prod"=>$prod);
// Set the WebService URL // Set the WebService URL
$client = new nusoap_client(OSCWS_DIR."ws_articles.php"); $client = new nusoap_client(OSCWS_DIR."ws_articles.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
// Call the WebService and store its result in $result. // Call the WebService and store its result in $result.
$result = $client->call("create_article",$parameters ); $result = $client->call("create_article",$parameters );
if ($client->fault) if ($client->fault)
{ {
$this->error="Fault detected"; $this->error="Fault detected";
return -1; return -1;
} }
elseif (!($err=$client->getError()) ) elseif (!($err=$client->getError()) )
{ {
if ($result > 0) if ($result > 0)
{ {
@ -151,15 +155,15 @@ if ($_GET["action"] == 'vendre' )
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Barre d'action */ /* Barre d'action */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";
print '<a class="tabAction" href="../index.php">'.$langs->trans("Retour").'</a>'; print '<a class="tabAction" href="../index.php">'.$langs->trans("Retour").'</a>';
print '<a class="tabAction" href="OSCvente.php?action=liste">'.$langs->trans("Liste").'</a>'; print '<a class="tabAction" href="OSCvente.php?action=liste">'.$langs->trans("Liste").'</a>';
print "\n</div>\n"; print "\n</div>\n";
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -59,18 +59,18 @@ if ($_REQUEST["action"] == 'maj')
{ {
if ($_POST["dolicat"]) $dolicatid = $_POST["dolicat"]; if ($_POST["dolicat"]) $dolicatid = $_POST["dolicat"];
if ($_POST["catMere"]) $dolicatid = $_POST["catMere"]; if ($_POST["catMere"]) $dolicatid = $_POST["catMere"];
$myobject=new Osc_categorie($db); $myobject=new Osc_categorie($db);
if ($myobject->fetch_dolicat($dolicatid) <0) if ($myobject->fetch_dolicat($dolicatid) <0)
{ {
$mesg = "erreur dans fetch_dolicat"; $mesg = "erreur dans fetch_dolicat";
} }
elseif ($myobject->id > 0) elseif ($myobject->id > 0)
{ {
$myobject->dolicatid=$dolicatid; $myobject->dolicatid=$dolicatid;
$myobject->osccatid=$_POST["osccat"]; $myobject->osccatid=$_POST["osccat"];
$result=$myobject->update($user); $result=$myobject->update($user);
if ($result > 0) if ($result > 0)
{ {
@ -88,7 +88,7 @@ if ($_REQUEST["action"] == 'maj')
{ {
$myobject->dolicatid=$dolicatid; $myobject->dolicatid=$dolicatid;
$myobject->osccatid=$_POST["osccat"]; $myobject->osccatid=$_POST["osccat"];
$result=$myobject->create($user); $result=$myobject->create($user);
if ($result > 0) if ($result > 0)
{ {
@ -119,20 +119,20 @@ else if ($_REQUEST["action"] == 'create')
if ($res = 1) if ($res = 1)
{ {
$categorie->id_mere = $mere->dolicatid; $categorie->id_mere = $mere->dolicatid;
if (! $categorie->id_mere) if (! $categorie->id_mere)
{ {
$categorie->error = $langs->trans("ErrorNoParentCategory",$langs->transnoentities("Catmere")); $categorie->error = $langs->trans("ErrorNoParentCategory",$langs->transnoentities("Catmere"));
$_GET["action"] = 'create'; $_GET["action"] = 'create';
$mesg = "* catmerem ".$categorie->id_mere."* ".$_POST["nom"]. " * ".$_POST["description"]." * ".$_POST["visible"]." * ".$_POST["type"]." * ".$_POST['catMere']; $mesg = "* catmerem ".$categorie->id_mere."* ".$_POST["nom"]. " * ".$_POST["description"]." * ".$_POST["visible"]." * ".$_POST["type"]." * ".$_POST['catMere'];
} }
} }
else else
{ {
$categorie->error = $langs->trans("ErrorParent",$langs->transnoentities("Catmere")); $categorie->error = $langs->trans("ErrorParent",$langs->transnoentities("Catmere"));
$_GET["action"] = 'create'; $_GET["action"] = 'create';
$mesg = "* catmerem ".$categorie->id_mere."* ".$_POST["nom"]. " * ".$_POST["description"]." * ".$_POST["visible"]." * ".$_POST["type"]." * ".$_POST['catMere']; $mesg = "* catmerem ".$categorie->id_mere."* ".$_POST["nom"]. " * ".$_POST["description"]." * ".$_POST["visible"]." * ".$_POST["type"]." * ".$_POST['catMere'];
} }
} }
else $categorie->id_mere = -1; else $categorie->id_mere = -1;
@ -148,7 +148,7 @@ else if ($_REQUEST["action"] == 'create')
$_GET["action"] = 'create'; $_GET["action"] = 'create';
$mesg = "* ".$_POST["nom"]. " * ".$_POST["description"]." * ".$_POST["visible"]." * ".$_POST["type"]." * ".$_POST['catMere']; $mesg = "* ".$_POST["nom"]. " * ".$_POST["description"]." * ".$_POST["visible"]." * ".$_POST["type"]." * ".$_POST['catMere'];
} }
if ($categorie->error =="") if ($categorie->error =="")
{ {
if ($cat_id = $categorie->create() > 0) if ($cat_id = $categorie->create() > 0)
@ -159,7 +159,7 @@ else if ($_REQUEST["action"] == 'create')
$myobject->dolicatid=$categorie->id; $myobject->dolicatid=$categorie->id;
$mesg="cat_id recu ".$cat_id." categorie ".$categorie->id." "; $mesg="cat_id recu ".$cat_id." categorie ".$categorie->id." ";
$myobject->osccatid=$_POST["osccat"]; $myobject->osccatid=$_POST["osccat"];
$result=$myobject->create($user); $result=$myobject->create($user);
if ($result > 0) if ($result > 0)
{ {
@ -174,12 +174,12 @@ else if ($_REQUEST["action"] == 'create')
} }
} }
$mesg .= ' sortie<br/>'.$categorie->error; $mesg .= ' sortie<br/>'.$categorie->error;
} }
if ($_REQUEST["action"] == 'import') if ($_REQUEST["action"] == 'import')
{ {
$osccat = $_GET['catid']; $osccat = $_GET['catid'];
} }
@ -191,7 +191,7 @@ if ($_REQUEST["action"] == 'import')
llxHeader(); llxHeader();
$html=new Form($db); $html=new Form($db);
if ($_REQUEST["action"] == 'import') if ($_REQUEST["action"] == 'import')
{ {
//titre //titre
@ -200,16 +200,16 @@ if ($_REQUEST["action"] == 'import')
print '<td>Id</td><td>Label</td><td>Osc_id</td><td>Action</td>'; print '<td>Id</td><td>Label</td><td>Osc_id</td><td>Action</td>';
print '</tr>'."\n"; print '</tr>'."\n";
print '<tr>'; print '<tr>';
print '<form method="post" action="categories.php">'; print '<form method="post" action="categories.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<td><input name="osccat" value="'.$_POST["catid"].'"></td><td>'; print '<td><input name="osccat" value="'.$_POST["catid"].'"></td><td>';
print '<input type="hidden" name="action" value="maj"/>'; print '<input type="hidden" name="action" value="maj"/>';
// print '<input type="hidden" name="dolicat" value="'.$obj->dolicatid.'"/>'; // print '<input type="hidden" name="dolicat" value="'.$obj->dolicatid.'"/>';
print $langs->trans("ChooseCategory").' '; print $langs->trans("ChooseCategory").' ';
print $html->select_all_categories(0,$categorie->id_mere).' <input type="submit" name="doit" class="button" value="'.$langs->trans("Classify").'"></td>'; print $html->select_all_categories(0,$categorie->id_mere).' <input type="submit" name="doit" class="button" value="'.$langs->trans("Classify").'"></td>';
print "</form>\n"; print "</form>\n";
print '<form method="post" action="categories.php">'; print '<form method="post" action="categories.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="create"/>'; print '<input type="hidden" name="action" value="create"/>';
print '<input type="hidden" name="nom" value="'.$_POST["description"].'"/>'; print '<input type="hidden" name="nom" value="'.$_POST["description"].'"/>';
print '<input type="hidden" name="description" value="'.$_POST["description"].'"/>'; print '<input type="hidden" name="description" value="'.$_POST["description"].'"/>';
@ -220,7 +220,7 @@ if ($_REQUEST["action"] == 'import')
print '<input type="hidden" name="type" value="0"/>'; print '<input type="hidden" name="type" value="0"/>';
print '<input type="hidden" name="osccat" value="'.$_POST["catid"].'"/>'; print '<input type="hidden" name="osccat" value="'.$_POST["catid"].'"/>';
print '<td><input type="submit" name="create" value="'.$langs->trans("create").'"></td>'; print '<td><input type="submit" name="create" value="'.$langs->trans("create").'"></td>';
print '</form>'; print '</form>';
print '</tr>'; print '</tr>';
print "</table>\n"; print "</table>\n";
} }
@ -280,25 +280,29 @@ else
{ {
dol_print_error(); dol_print_error();
} }
} }
//WebService Client. //WebService Client.
require_once(NUSOAP_PATH."/nusoap.php"); require_once(NUSOAP_PATH."/nusoap.php");
require_once("../includes/configure.php"); require_once("../includes/configure.php");
// Set the parameters to send to the WebService // Set the parameters to send to the WebService
if ($_GET["catid"]) $catid = $_GET["catid"]; if ($_GET["catid"]) $catid = $_GET["catid"];
else $catid= 0; else $catid= 0;
$parameters = array("catid"=>$catid); $parameters = array("catid"=>$catid);
// Set the WebService URL // Set the WebService URL
$client = new nusoap_client(OSCWS_DIR."ws_articles.php"); $client = new nusoap_client(OSCWS_DIR."ws_articles.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
$result = $client->call("get_categorylist",$parameters ); $result = $client->call("get_categorylist",$parameters );
if ($client->fault) { if ($client->fault) {
if ($client->faultcode == 'Server') print '<p>Il n\'y a pas de cat<61>gorie fille pour la cat<61>gorie '.$catid.'</p>'; if ($client->faultcode == 'Server') print '<p>Il n\'y a pas de cat<61>gorie fille pour la cat<61>gorie '.$catid.'</p>';
else dol_print_error('',"erreur de connexion ".$client->getError()); else dol_print_error('',"erreur de connexion ".$client->getError());
} }
elseif ( !($err = $client->getError()) ) elseif ( !($err = $client->getError()) )
{ {
@ -318,9 +322,9 @@ elseif ( !($err = $client->getError()) )
print "<td>id dolibarr</td>"; print "<td>id dolibarr</td>";
print "<td>Importer</td>"; print "<td>Importer</td>";
print "</tr>"; print "</tr>";
$dolicat = new Osc_Categorie($db); $dolicat = new Osc_Categorie($db);
while ($i < $num) { while ($i < $num) {
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
@ -330,7 +334,7 @@ elseif ( !($err = $client->getError()) )
$dolicatid = $dolicat->fetch_osccat($result[$i]['categories_id']); $dolicatid = $dolicat->fetch_osccat($result[$i]['categories_id']);
if ($dolicat->dolicatid) print '<td><a href="../../categories/viewcat.php?id='.$dolicat->dolicatid.'">'.$dolicat->dolicatid.'</a></td>'; if ($dolicat->dolicatid) print '<td><a href="../../categories/viewcat.php?id='.$dolicat->dolicatid.'">'.$dolicat->dolicatid.'</a></td>';
else print '<td></td>'; else print '<td></td>';
//print '<td><a href="categories.php?action=import&catid='.$result[$i]['categories_id'].'">Importer</a></td>'; //print '<td><a href="categories.php?action=import&catid='.$result[$i]['categories_id'].'">Importer</a></td>';
print '<form method="POST" action="categories.php">'; print '<form method="POST" action="categories.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -340,7 +344,7 @@ elseif ( !($err = $client->getError()) )
print '<input type="hidden" name="action" value="import"/>'; print '<input type="hidden" name="action" value="import"/>';
print '<input type="hidden" name="catMere" value="'.$result[$i]['parent_id'].'"/>'; print '<input type="hidden" name="catMere" value="'.$result[$i]['parent_id'].'"/>';
print '<input type="hidden" name="catid" value="'.$result[$i]['categories_id'].'"/>'; print '<input type="hidden" name="catid" value="'.$result[$i]['categories_id'].'"/>';
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans('Import').'"></td>'; print '<td align="center"><input type="submit" class="button" value="'.$langs->trans('Import').'"></td>';
print '</form> '; print '</form> ';
print "</tr>"; print "</tr>";
$i++; $i++;

View File

@ -43,6 +43,10 @@ $parameters = array();
// Set the WebService URL // Set the WebService URL
$client = new nusoap_client(OSCWS_DIR."ws_articles.php"); $client = new nusoap_client(OSCWS_DIR."ws_articles.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
$result = $client->call("get_listearticles",$parameters ); $result = $client->call("get_listearticles",$parameters );
if ($client->fault) { if ($client->fault) {
@ -96,7 +100,7 @@ elseif (!($err = $client->getError()) )
} }
} }
else { else {
dol_print_error('',"Erreur service web ".$client->faultstring); print $client->getHTTPBody($client->response);
} }
print "</TABLE>"; print "</TABLE>";

View File

@ -34,7 +34,7 @@
class Osc_product class Osc_product
{ {
var $db; var $db;
var $osc_id; var $osc_id;
var $osc_ref; var $osc_ref;
var $osc_name; var $osc_name;
@ -46,18 +46,18 @@ class Osc_product
var $osc_four; var $osc_four;
var $osc_image; var $osc_image;
var $osc_catid; var $osc_catid;
var $error; var $error;
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param id Id produit (0 par defaut) * \param id Id produit (0 par defaut)
*/ */
function Osc_product($DB, $id=0) { function Osc_product($DB, $id=0) {
global $langs; global $langs;
$this->osc_id = $id ; $this->osc_id = $id ;
/* les initialisations n<>cessaires */ /* les initialisations n<>cessaires */
@ -66,7 +66,7 @@ class Osc_product
/** /**
* \brief Charge le produit OsC en m<EFBFBD>moire * \brief Charge le produit OsC en m<EFBFBD>moire
* \param id Id du produit dans OsC * \param id Id du produit dans OsC
* \param ref Ref du produit dans OsC (doit <EFBFBD>tre unique dans OsC) * \param ref Ref du produit dans OsC (doit <EFBFBD>tre unique dans OsC)
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
@ -74,7 +74,7 @@ class Osc_product
{ {
global $langs; global $langs;
global $conf; global $conf;
$this->error = ''; $this->error = '';
dol_syslog("Osc_product::fetch $id=$id ref=$ref"); dol_syslog("Osc_product::fetch $id=$id ref=$ref");
// Verification parametres // Verification parametres
@ -95,6 +95,10 @@ class Osc_product
// Set the WebService URL // Set the WebService URL
$client = new nusoap_client(OSCWS_DIR."/ws_articles.php"); $client = new nusoap_client(OSCWS_DIR."/ws_articles.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
// Call the WebSeclient->fault)rvice and store its result in $obj // Call the WebSeclient->fault)rvice and store its result in $obj
$obj = $client->call("get_article",$parameters ); $obj = $client->call("get_article",$parameters );
@ -116,7 +120,7 @@ class Osc_product
else { else {
$this->error = 'Erreur '.$client->getError(); $this->error = 'Erreur '.$client->getError();
return -1; return -1;
} }
return 0; return 0;
} }
@ -145,14 +149,14 @@ class Osc_product
/* on force */ /* on force */
$product->status = 1; /* en vente */ $product->status = 1; /* en vente */
return $product; return $product;
} }
} }
/** /**
* \brief Mise <EFBFBD> jour de la table de transition * \brief Mise <EFBFBD> jour de la table de transition
* \param oscid Id du produit dans OsC * \param oscid Id du produit dans OsC
* \param prodid champ r<EFBFBD>f<EFBFBD>rence * \param prodid champ r<EFBFBD>f<EFBFBD>rence
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function transcode($oscid, $prodid) function transcode($oscid, $prodid)
@ -182,7 +186,7 @@ class Osc_product
// $this->db->rollback(); // $this->db->rollback();
// return -1; // return -1;
} }
return 0; return 0;
} }
// converti le produit osc en produit dolibarr // converti le produit osc en produit dolibarr
@ -195,22 +199,22 @@ class Osc_product
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
// test d'erreurs // test d'erreurs
if ($obj) return $obj->fk_product; if ($obj) return $obj->fk_product;
else return ''; else return '';
} }
function get_catid($osccatid) function get_catid($osccatid)
{ {
require_once(DOL_DOCUMENT_ROOT."/oscommerce_ws/produits/osc_categories.class.php"); require_once(DOL_DOCUMENT_ROOT."/oscommerce_ws/produits/osc_categories.class.php");
$mycat=new Osc_categorie($this->db); $mycat=new Osc_categorie($this->db);
if ($mycat->fetch_osccat($osccatid) > 0) if ($mycat->fetch_osccat($osccatid) > 0)
{ {
return $mycat->dolicatid; return $mycat->dolicatid;
} }
else return 0; else return 0;
} }
function get_osc_productid($productidp) function get_osc_productid($productidp)
{ {
$sql = "SELECT rowid"; $sql = "SELECT rowid";
@ -219,24 +223,24 @@ class Osc_product
$result=$this->db->query($sql); $result=$this->db->query($sql);
$row = $this->db->fetch_row($result); $row = $this->db->fetch_row($result);
// test d'erreurs // test d'erreurs
if ($row) return $row[0]; if ($row) return $row[0];
else return -1; else return -1;
} }
/** /**
* \brief cr<EFBFBD>ation d'un article dans base OSC * \brief cr<EFBFBD>ation d'un article dans base OSC
* \param $user utilisateur * \param $user utilisateur
*/ */
function create($user) function create($user)
{ {
/* non impl<70>ment<6E>e */ /* non impl<70>ment<6E>e */
} }
/** /**
* \brief modification d'un article dans base OSC * \brief modification d'un article dans base OSC
* \param $user utilisateur * \param $user utilisateur
*/ */
function update($id, $user) function update($id, $user)
{ {
/* non impl<70>ment<6E>e */ /* non impl<70>ment<6E>e */

View File

@ -29,10 +29,9 @@ require_once('./lib/nusoap.php');
// Create the soap Object // Create the soap Object
$s = new soap_server; $s = new soap_server;
/* $ns='oscommerce'; $ns='oscommerce';
$s->configureWSDL('WebServicesOSCommerceForDolibarr',$ns); $s->configureWSDL('WebServicesOSCommerceForDolibarrProducts',$ns);
$s->wsdl->schemaTargetNamespace=$ns; $s->wsdl->schemaTargetNamespace=$ns;
*/
// Register a method available for clients // Register a method available for clients
$s->register('get_article'); $s->register('get_article');

View File

@ -28,32 +28,31 @@ require_once('./includes/configure.php');
// Create the soap Object // Create the soap Object
$s = new soap_server; $s = new soap_server;
/* $ns='oscommerce'; $ns='oscommerce';
$s->configureWSDL('WebServicesOSCommerceForDolibarr',$ns); $s->configureWSDL('WebServicesOSCommerceForDolibarrCustomers',$ns);
$s->wsdl->schemaTargetNamespace=$ns; $s->wsdl->schemaTargetNamespace=$ns;
*/
// Register the methods available for clients // Register the methods available for clients
$s->register('get_Client'); $s->register('get_Client');
// méthodes // m<EFBFBD>thodes
function get_Client($custid='') { function get_Client($custid='') {
//on se connecte //on se connecte
if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connexion impossible"); if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connexion impossible");
if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error()); if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error());
//la requête //la requ<71>te
$sql = "SELECT c.customers_id, a.entry_company, a.entry_firstname, a.entry_lastname, a.entry_street_address, a.entry_postcode, a.entry_city, c.customers_telephone, c.customers_fax, c.customers_email_address, a.entry_country_id, b.countries_iso_code_2, b.countries_name "; $sql = "SELECT c.customers_id, a.entry_company, a.entry_firstname, a.entry_lastname, a.entry_street_address, a.entry_postcode, a.entry_city, c.customers_telephone, c.customers_fax, c.customers_email_address, a.entry_country_id, b.countries_iso_code_2, b.countries_name ";
$sql .= " from customers c JOIN address_book a ON a.customers_id = c.customers_id JOIN countries b ON b.countries_id = a.entry_country_id JOIN orders o ON o.customers_id = c.customers_id "; $sql .= " from customers c JOIN address_book a ON a.customers_id = c.customers_id JOIN countries b ON b.countries_id = a.entry_country_id JOIN orders o ON o.customers_id = c.customers_id ";
if ($custid > 0) $sql .= "WHERE c.customers_id = ".$custid; if ($custid > 0) $sql .= "WHERE c.customers_id = ".$custid;
$sql .= " GROUP BY c.customers_id ORDER BY c.customers_id"; $sql .= " GROUP BY c.customers_id ORDER BY c.customers_id";
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error()); if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
// $result[$i] = $numrows." lignes trouvées ".$sql; // $result[$i] = $numrows." lignes trouv<75>es ".$sql;
switch ($numrows = mysql_numrows($resquer)) { switch ($numrows = mysql_numrows($resquer)) {
case 0 : case 0 :
return new soap_fault("Server", "MySQL 4", "client inexistant ".$sql); return new soap_fault("Server", "MySQL 4", "client inexistant ".$sql);
break; break;
default : default :
@ -63,10 +62,10 @@ if ($custid > 0) $sql .= "WHERE c.customers_id = ".$custid;
$i++; $i++;
} }
break; break;
} }
mysql_close($connexion); mysql_close($connexion);
/* Sends the results to the client */ /* Sends the results to the client */
return $result; return $result;
} }
// Return the results. // Return the results.

View File

@ -7,10 +7,10 @@ This page show list of public webservices, now available on
your server OSCommerce.<br> your server OSCommerce.<br>
<br> <br>
* ws_articles<br> * <a href="ws_articles.php">ws_articles</a><br>
* ws_customers<br> * <a href="ws_customers.php">ws_customers</a><br>
* ws_orders<br> * <a href="ws_orders.php">ws_orders</a><br>
* ws_test<br> * <a href="ws_test.php">ws_test</a><br>
<br> <br>
Those pages will be called by Dolibarr using its own SOAP web service client.<br> Those pages will be called by Dolibarr using its own SOAP web service client.<br>

View File

@ -19,6 +19,7 @@
* $Id$ * $Id$
*/ */
set_magic_quotes_runtime(0); set_magic_quotes_runtime(0);
//if (function_exists('xdebug_disable')) xdebug_disable();
// Soap Server. // Soap Server.
require_once('./lib/nusoap.php'); require_once('./lib/nusoap.php');
@ -27,6 +28,9 @@ require_once('./includes/configure.php');
// Create the soap Object // Create the soap Object
$s = new soap_server; $s = new soap_server;
$ns='oscommerce';
$s->configureWSDL('WebServicesOSCommerceForDolibarOrders',$ns);
$s->wsdl->schemaTargetNamespace=$ns;
// Register the methods available for clients // Register the methods available for clients
$s->register('get_CAmensuel'); $s->register('get_CAmensuel');
@ -35,7 +39,7 @@ $s->register('get_lastOrderClients');
$s->register('get_Order'); $s->register('get_Order');
/*---------------------------------------------- /*----------------------------------------------
* renvoie un tableau avec le CA mensuel réalisé * renvoie un tableau avec le CA mensuel realise
-----------------------------------------------*/ -----------------------------------------------*/
function get_CAmensuel() { function get_CAmensuel() {
@ -43,18 +47,18 @@ function get_CAmensuel() {
if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connexion impossible"); if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connexion impossible");
if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error()); if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error());
//la requête //la requ<EFBFBD>te
$sql = "SELECT sum(t.value) as value, MONTH(o.date_purchased) as mois, YEAR(o.date_purchased) as an"; $sql = "SELECT sum(t.value) as value, MONTH(o.date_purchased) as mois, YEAR(o.date_purchased) as an";
$sql .= " FROM orders_total as t"; $sql .= " FROM orders_total as t";
$sql .= " JOIN orders as o ON o.orders_id = t.orders_id"; $sql .= " JOIN orders as o ON o.orders_id = t.orders_id";
$sql .= " WHERE t.class = 'ot_subtotal' "; $sql .= " WHERE t.class = 'ot_subtotal' ";
//AND YEAR(o.date_purchased) = YEAR(now()) "; //AND YEAR(o.date_purchased) = YEAR(now()) ";
$sql .= " GROUP BY an, mois ORDER BY an desc ,mois desc limit 1,12"; $sql .= " GROUP BY an, mois ORDER BY an desc ,mois desc limit 1,12";
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error()); if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
switch ($numrows = mysql_numrows($resquer)) { switch ($numrows = mysql_numrows($resquer)) {
case 0 : case 0 :
return new soap_fault("Server", "MySQL 4", $sql); return new soap_fault("Server", "MySQL 4", $sql);
break; break;
default : default :
@ -64,7 +68,7 @@ function get_CAmensuel() {
$i++; $i++;
} }
break; break;
} }
mysql_close($connexion); mysql_close($connexion);
/* Sends the results to the client */ /* Sends the results to the client */
return $result; return $result;
@ -83,12 +87,12 @@ $sql .= " WHERE t.class = 'ot_subtotal'";
if ($status > 0) $sql .= " and o.orders_status = ".$status; if ($status > 0) $sql .= " and o.orders_status = ".$status;
$sql .= " ORDER BY o.date_purchased desc"; $sql .= " ORDER BY o.date_purchased desc";
if ($limit > 0) $sql .= " LIMIT ".$limit; if ($limit > 0) $sql .= " LIMIT ".$limit;
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error()); if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
$result =''; $result ='';
switch ($numrows = mysql_numrows($resquer)) { switch ($numrows = mysql_numrows($resquer)) {
case 0 : case 0 :
//return new soap_fault("Server", "MySQL 4", "produit inexistant"); //return new soap_fault("Server", "MySQL 4", "produit inexistant");
break; break;
default : default :
@ -98,7 +102,7 @@ if ($limit > 0) $sql .= " LIMIT ".$limit;
$i++; $i++;
} }
break; break;
} }
mysql_close($connexion); mysql_close($connexion);
/* Sends the results to the client */ /* Sends the results to the client */
return $result; return $result;
@ -117,12 +121,12 @@ function get_lastOrderClients($id='',$name='',$limit='') {
$sql .= " JOIN orders_status as s on o.orders_status = s.orders_status_id and s.language_id = 1"; $sql .= " JOIN orders_status as s on o.orders_status = s.orders_status_id and s.language_id = 1";
$sql .= " WHERE t.class = 'ot_subtotal' and o.orders_status < 5 order by o.date_purchased desc"; $sql .= " WHERE t.class = 'ot_subtotal' and o.orders_status < 5 order by o.date_purchased desc";
if ($limit > 0) $sql .= " LIMIT ".$limit; if ($limit > 0) $sql .= " LIMIT ".$limit;
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error()); if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
$result =''; $result ='';
switch ($numrows = mysql_numrows($resquer)) { switch ($numrows = mysql_numrows($resquer)) {
case 0 : case 0 :
return new soap_fault("Server", "MySQL 4", "produit inexistant"); return new soap_fault("Server", "MySQL 4", "produit inexistant");
break; break;
default : default :
@ -132,7 +136,7 @@ function get_lastOrderClients($id='',$name='',$limit='') {
$i++; $i++;
} }
break; break;
} }
mysql_close($connexion); mysql_close($connexion);
/* Sends the results to the client */ /* Sends the results to the client */
return $result; return $result;
@ -155,18 +159,18 @@ $sql .= " WHERE t.class = 'ot_subtotal'";
$sql = "SELECT o.orders_id, o.customers_name, o.customers_id, o.date_purchased, o.payment_method, t.value as total, sum(p.value) as port, s.orders_status_name as statut "; $sql = "SELECT o.orders_id, o.customers_name, o.customers_id, o.date_purchased, o.payment_method, t.value as total, sum(p.value) as port, s.orders_status_name as statut ";
$sql .= " FROM orders as o "; $sql .= " FROM orders as o ";
$sql .= " JOIN orders_total as t on o.orders_id = t.orders_id and t.class = 'ot_subtotal' "; $sql .= " JOIN orders_total as t on o.orders_id = t.orders_id and t.class = 'ot_subtotal' ";
$sql .= " JOIN orders_total as p on o.orders_id = p.orders_id and (p.class = 'ot_shipping' OR p.class = 'ot_fixed_payment_chg') "; $sql .= " JOIN orders_total as p on o.orders_id = p.orders_id and (p.class = 'ot_shipping' OR p.class = 'ot_fixed_payment_chg') ";
$sql .= " JOIN orders_status as s on o.orders_status = s.orders_status_id and s.language_id = 1"; $sql .= " JOIN orders_status as s on o.orders_status = s.orders_status_id and s.language_id = 1";
$sql .= " WHERE o.orders_status < 5 "; // élimine les commandes annulées, remboursées $sql .= " WHERE o.orders_status < 5 "; // <EFBFBD>limine les commandes annul<75>es, rembours<72>es
if ($orderid > 0) $sql .= " AND o.orders_id = ".$orderid; if ($orderid > 0) $sql .= " AND o.orders_id = ".$orderid;
$sql .= " GROUP BY p.orders_id "; $sql .= " GROUP BY p.orders_id ";
$sql .= " ORDER BY o.date_purchased desc"; $sql .= " ORDER BY o.date_purchased desc";
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error()); if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
$result =''; $result ='';
switch ($numrows = mysql_numrows($resquer)) { switch ($numrows = mysql_numrows($resquer)) {
case 0 : case 0 :
return new soap_fault("Server", "MySQL 4", "commande inexistante ".$sql); return new soap_fault("Server", "MySQL 4", "commande inexistante ".$sql);
break; break;
default : default :
@ -179,18 +183,18 @@ $sql .= " ORDER BY o.date_purchased desc";
} }
$j = $i--; $j = $i--;
if ($orderid > 0) if ($orderid > 0)
{ {
//on recherche les lignes de la commande //on recherche les lignes de la commande
$sql = "SELECT l.products_id, l.products_name, l.products_price, l.final_price, l.products_tax, l.products_quantity "; $sql = "SELECT l.products_id, l.products_name, l.products_price, l.final_price, l.products_tax, l.products_quantity ";
$sql .= " FROM orders_products l "; $sql .= " FROM orders_products l ";
$sql .= " WHERE l.orders_id = ".$orderid; $sql .= " WHERE l.orders_id = ".$orderid;
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error()); if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
switch ($numrows = mysql_numrows($resquer)) { switch ($numrows = mysql_numrows($resquer)) {
case 0 : case 0 :
return new soap_fault("Server", "MySQL 5", "commande sans articles"); return new soap_fault("Server", "MySQL 5", "commande sans articles");
break; break;
default : default :

View File

@ -7,9 +7,8 @@ require_once('./lib/nusoap.php');
// Create the soap Object // Create the soap Object
$s = new soap_server; $s = new soap_server;
$ns='oscommerce'; $ns='oscommerce';
$s->configureWSDL('WebServicesOSCommerceForDolibarrTest',$ns);
#$s->configureWSDL('WebServicesOSCommerceForDolibarr',$ns); $s->wsdl->schemaTargetNamespace=$ns;
#$s->wsdl->schemaTargetNamespace=$ns;
// Register a method available for clients // Register a method available for clients
$s->register('hello'); $s->register('hello');