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
Module800Desc=Interface to show an OSCommerce or OSCSS shop via direct database access
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
Module1200Desc=Mantis integration
Module1400Name=Accounting

View File

@ -339,7 +339,7 @@ Module700Desc = Gestion des dons
Module800Name = OSCommerce direct
Module800Desc = Interface de visualisation d'une boutique OSCommerce ou OSCSS par accès direct en base.
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
Module1200Desc = Interface avec le bug tracking Mantis
Module1400Name = Comptabilité

View File

@ -44,6 +44,10 @@ $parameters = array("custid"=>"0");
// Set the WebService URL
$client = new nusoap_client(OSCWS_DIR."ws_customers.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
$result = $client->call("get_Client",$parameters );
@ -61,7 +65,7 @@ elseif (!($err = $client->getError()) )
// un client osc
$OscClient = new Osc_Customer($db);
if ($num > 0) {
print "<TABLE width=\"100%\" class=\"noborder\">";
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">Importer</TD>';
print "</TR>\n";
while ($i < $num) {
$var=!$var;
$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";
if ($custid) $lib = "modifier";
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 "</TR>\n";
$i++;
@ -101,7 +105,7 @@ elseif (!($err = $client->getError()) )
}
}
else {
dol_print_error('',"Erreur service web ".$err);
print $client->getHTTPBody($client->response);
}
print "</TABLE>";

View File

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

View File

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

View File

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

View File

@ -28,7 +28,8 @@
*/
// 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
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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
\file htdocs/oscommerce_ws/index.php
\ingroup oscommerce2
\brief Page accueil zone boutique
\version $Id$
*/
\file htdocs/oscommerce_ws/index.php
\ingroup oscommerce2
\brief Page accueil zone boutique
\version $Id$
*/
require("./pre.inc.php");
@ -37,7 +37,7 @@ print_fiche_titre($langs->trans("OSCommerceShop"));
if (! @ini_get('allow_url_fopen'))
{
$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();
// Set the WebService URL
//print OSCWS_DIR."ws_orders.php"; exit;
$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'));
@ -69,36 +75,39 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Year").'</td>';
print '<td>'.$langs->trans("Month").'</td>';
print '<td align="right">'.$langs->trans("Total").'</td></tr>';
//$client->setDebugLevel(9);
// Call the WebService and store its result in $result.
$result = $client->call("get_CAmensuel",$parameters );
if ($client->fault) {
dol_print_error('',"Erreur de connexion ");
print_r($client->faultstring);
dol_print_error('',"Erreur de connexion ");
print_r($client->faultstring);
}
elseif (!($err = $client->getError()) )
{
$num=0;
if ($result) $num = sizeof($result);
if ($result) $num = sizeof($result);
$var=True;
$i=0;
$i=0;
if ($num > 0) {
while ($i < $num)
while ($i < $num)
{
$var=!$var;
print "<tr $bc[$var]>";
print '<td align="left">'.$result[$i][an].'</td>';
print '<td align="left">'.$result[$i][mois].'</td>';
print '<td align="right">'.convert_price($result[$i][value]).'</td>';
$var=!$var;
print "<tr $bc[$var]>";
print '<td align="left">'.$result[$i][an].'</td>';
print '<td align="left">'.$result[$i][mois].'</td>';
print '<td align="right">'.convert_price($result[$i][value]).'</td>';
print "</tr>\n";
$i++;
}
print "</tr>\n";
$i++;
}
}
}
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 '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("LastOrders").'</td></tr>';
// Call the WebService and store its result in $result.
$parameters = array("limit"=>OSC_MAXNBCOM);
$result = $client->call("get_orders",$parameters );
if ($client->fault) {
dol_print_error('',"Erreur de connexion ");
dol_print_error('',"Erreur de connexion ");
}
elseif (!($err = $client->getError()) ) {
$num=0;
if ($result) $num = sizeof($result);
if ($result) $num = sizeof($result);
$var=True;
$i=0;
$i=0;
if ($num > 0) {
$num = min($num,OSC_MAXNBCOM);
while ($i < $num) {
$var=!$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>';
$i++;
}
}
if ($num > 0) {
$num = min($num,OSC_MAXNBCOM);
while ($i < $num) {
$var=!$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>';
$i++;
}
}
}
else {
dol_print_error('',"Erreur du service web ".$err);
print $client->getHTTPBody($client->response);
}
print "</table><br>";
/*
* 5 derni<EFBFBD>res commandes en attente
*/
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
@ -158,28 +167,28 @@ $parameters = array("limit"=>OSC_MAXNBCOM, "status"=>OSC_ORDWAIT);
$result = $client->call("get_orders",$parameters );
if ($client->fault) {
dol_print_error('',"Erreur webservice ".$client->faultstring);
dol_print_error('',"Erreur webservice ".$client->faultstring);
}
elseif (!($err = $client->getError()) ) {
$var=True;
$i=0;
$num=0;
if ($result) $num = sizeof($result);
$langs->load("orders");
$var=True;
$i=0;
$num=0;
if ($result) $num = sizeof($result);
$langs->load("orders");
if ($num > 0) {
$num = min($num,OSC_MAXNBCOM);
if ($num > 0) {
$num = min($num,OSC_MAXNBCOM);
while ($i < $num) {
$var=!$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>';
$i++;
while ($i < $num) {
$var=!$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>';
$i++;
}
}
}
}
else {
dol_print_error('',"Erreur du service web ".$err);
print $client->getHTTPBody($client->response);
}
print "</table><br>";
@ -190,41 +199,41 @@ print "</table><br>";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("TreatmentInProgress").'</td></tr>';
$parameters = array("limit"=>OSC_MAXNBCOM, "status"=>OSC_ORDPROCESS);
$result = $client->call("get_orders",$parameters );
if ($client->fault) {
dol_print_error('',"Erreur webservice ".$client->faultstring);
dol_print_error('',"Erreur webservice ".$client->faultstring);
}
elseif (!($err = $client->getError()) ) {
$var=True;
$i=0;
$num=0;
if ($result) $num = sizeof($result);
$langs->load("orders");
$var=True;
$i=0;
$num=0;
if ($result) $num = sizeof($result);
$langs->load("orders");
if ($num > 0) {
$num = min($num,OSC_MAXNBCOM);
if ($num > 0) {
$num = min($num,OSC_MAXNBCOM);
while ($i < $num) {
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>';
$i++;
$var=!$var;
while ($i < $num) {
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>';
$i++;
$var=!$var;
}
}
}
}
else {
dol_print_error('',"Erreur du service web ".$err);
print $client->getHTTPBody($client->response);
}
print "</table><br>";
print '</td></tr><tr>';
/*
* Derniers clients qui ont command<EFBFBD>
*/
* Derniers clients qui ont command<EFBFBD>
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
@ -234,29 +243,29 @@ $parameters = array("limit"=>OSC_MAXNBCOM);
$result = $client->call("get_lastOrderClients",$parameters );
if ($client->fault) {
dol_print_error('',"Erreur webservice ".$client->faultstring);
dol_print_error('',"Erreur webservice ".$client->faultstring);
}
elseif (!($err = $client->getError()) ) {
$var=True;
$i=0;
$num=0;
if ($result) $num = sizeof($result);
$langs->load("orders");
$var=True;
$i=0;
$num=0;
if ($result) $num = sizeof($result);
$langs->load("orders");
if ($num > 0) {
$num = min($num,OSC_MAXNBCOM);
if ($num > 0) {
$num = min($num,OSC_MAXNBCOM);
while ($i < $num) {
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>";
$i++;
$var=!$var;
while ($i < $num) {
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>";
$i++;
$var=!$var;
}
print "</table><br>";
}
print "</table><br>";
}
}
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
$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) )
{
@ -46,7 +46,7 @@ if ($_GET["action"] == 'liste' )
{
$var=!$var;
$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 '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("OscProd"),"Product").' '.$obj->oscid.'</a></td></tr>';
$i++;
@ -69,50 +69,54 @@ if ($_GET["action"] == 'vendre' )
$prod['desc'] = $product->description;
$prod['quant'] = $_POST["qty"];
$prod['prix'] = convert_backprice($product->price);
// a gerer $product->tx_tva
// a gerer $product->tx_tva
$prod['poids'] = $product->weight;
// gerer $product->weight_units
$prod['dispo'] = '';
$prod['status'] = '1';
$prod['fourn'] = '';
$prod['url'] = '';
//recherche de l'image
$pdir = get_exdir($product->id,2) . $product->id ."/photos/";
$dir = $conf->produit->dir_output . '/'. $pdir;
$img = $product->liste_photos($dir);
if (sizeof($img) ==0) $prod['image'] = '';
else
else
{
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);
}
// print_r($prod);
// print '<br/>';
set_magic_quotes_runtime(0);
//WebService Client.
require_once(NUSOAP_PATH."/nusoap.php");
// Creation
// Set the parameters to send to the WebService
$parameters = array("prod"=>$prod);
// Set the WebService URL
$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.
$result = $client->call("create_article",$parameters );
if ($client->fault)
$result = $client->call("create_article",$parameters );
if ($client->fault)
{
$this->error="Fault detected";
return -1;
}
elseif (!($err=$client->getError()) )
elseif (!($err=$client->getError()) )
{
if ($result > 0)
{
@ -151,15 +155,15 @@ if ($_GET["action"] == 'vendre' )
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
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 "\n</div>\n";
llxFooter('$Date$ - $Revision$');
?>

View File

@ -59,18 +59,18 @@ if ($_REQUEST["action"] == 'maj')
{
if ($_POST["dolicat"]) $dolicatid = $_POST["dolicat"];
if ($_POST["catMere"]) $dolicatid = $_POST["catMere"];
$myobject=new Osc_categorie($db);
if ($myobject->fetch_dolicat($dolicatid) <0)
{
$mesg = "erreur dans fetch_dolicat";
}
elseif ($myobject->id > 0)
elseif ($myobject->id > 0)
{
$myobject->dolicatid=$dolicatid;
$myobject->osccatid=$_POST["osccat"];
$result=$myobject->update($user);
if ($result > 0)
{
@ -88,7 +88,7 @@ if ($_REQUEST["action"] == 'maj')
{
$myobject->dolicatid=$dolicatid;
$myobject->osccatid=$_POST["osccat"];
$result=$myobject->create($user);
if ($result > 0)
{
@ -119,20 +119,20 @@ else if ($_REQUEST["action"] == 'create')
if ($res = 1)
{
$categorie->id_mere = $mere->dolicatid;
if (! $categorie->id_mere)
if (! $categorie->id_mere)
{
$categorie->error = $langs->trans("ErrorNoParentCategory",$langs->transnoentities("Catmere"));
$_GET["action"] = 'create';
$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"));
$_GET["action"] = 'create';
$mesg = "* catmerem ".$categorie->id_mere."* ".$_POST["nom"]. " * ".$_POST["description"]." * ".$_POST["visible"]." * ".$_POST["type"]." * ".$_POST['catMere'];
}
}
else $categorie->id_mere = -1;
@ -148,7 +148,7 @@ else if ($_REQUEST["action"] == 'create')
$_GET["action"] = 'create';
$mesg = "* ".$_POST["nom"]. " * ".$_POST["description"]." * ".$_POST["visible"]." * ".$_POST["type"]." * ".$_POST['catMere'];
}
if ($categorie->error =="")
{
if ($cat_id = $categorie->create() > 0)
@ -159,7 +159,7 @@ else if ($_REQUEST["action"] == 'create')
$myobject->dolicatid=$categorie->id;
$mesg="cat_id recu ".$cat_id." categorie ".$categorie->id." ";
$myobject->osccatid=$_POST["osccat"];
$result=$myobject->create($user);
if ($result > 0)
{
@ -174,12 +174,12 @@ else if ($_REQUEST["action"] == 'create')
}
}
$mesg .= ' sortie<br/>'.$categorie->error;
}
}
if ($_REQUEST["action"] == 'import')
{
$osccat = $_GET['catid'];
}
@ -191,7 +191,7 @@ if ($_REQUEST["action"] == 'import')
llxHeader();
$html=new Form($db);
if ($_REQUEST["action"] == 'import')
{
//titre
@ -200,16 +200,16 @@ if ($_REQUEST["action"] == 'import')
print '<td>Id</td><td>Label</td><td>Osc_id</td><td>Action</td>';
print '</tr>'."\n";
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 '<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="dolicat" value="'.$obj->dolicatid.'"/>';
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 "</form>\n";
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="nom" 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="osccat" value="'.$_POST["catid"].'"/>';
print '<td><input type="submit" name="create" value="'.$langs->trans("create").'"></td>';
print '</form>';
print '</form>';
print '</tr>';
print "</table>\n";
}
@ -280,25 +280,29 @@ else
{
dol_print_error();
}
}
}
//WebService Client.
require_once(NUSOAP_PATH."/nusoap.php");
require_once("../includes/configure.php");
// Set the parameters to send to the WebService
if ($_GET["catid"]) $catid = $_GET["catid"];
else $catid= 0;
else $catid= 0;
$parameters = array("catid"=>$catid);
// Set the WebService URL
$client = new nusoap_client(OSCWS_DIR."ws_articles.php");
if ($client)
{
$client->soap_defencoding='UTF-8';
}
$result = $client->call("get_categorylist",$parameters );
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>';
else dol_print_error('',"erreur de connexion ".$client->getError());
}
elseif ( !($err = $client->getError()) )
{
@ -318,9 +322,9 @@ elseif ( !($err = $client->getError()) )
print "<td>id dolibarr</td>";
print "<td>Importer</td>";
print "</tr>";
$dolicat = new Osc_Categorie($db);
while ($i < $num) {
$var=!$var;
print "<tr $bc[$var]>";
@ -330,7 +334,7 @@ elseif ( !($err = $client->getError()) )
$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>';
else print '<td></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 '<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="catMere" value="'.$result[$i]['parent_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 "</tr>";
$i++;

View File

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

View File

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

View File

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

View File

@ -28,32 +28,31 @@ require_once('./includes/configure.php');
// Create the soap Object
$s = new soap_server;
/* $ns='oscommerce';
$s->configureWSDL('WebServicesOSCommerceForDolibarr',$ns);
$ns='oscommerce';
$s->configureWSDL('WebServicesOSCommerceForDolibarrCustomers',$ns);
$s->wsdl->schemaTargetNamespace=$ns;
*/
// Register the methods available for clients
$s->register('get_Client');
// méthodes
// m<EFBFBD>thodes
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 (!($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 .= " 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";
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
// $result[$i] = $numrows." lignes trouvées ".$sql;
switch ($numrows = mysql_numrows($resquer)) {
case 0 :
// $result[$i] = $numrows." lignes trouv<75>es ".$sql;
switch ($numrows = mysql_numrows($resquer)) {
case 0 :
return new soap_fault("Server", "MySQL 4", "client inexistant ".$sql);
break;
default :
@ -63,10 +62,10 @@ if ($custid > 0) $sql .= "WHERE c.customers_id = ".$custid;
$i++;
}
break;
}
}
mysql_close($connexion);
/* Sends the results to the client */
return $result;
/* Sends the results to the client */
return $result;
}
// Return the results.

View File

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

View File

@ -19,6 +19,7 @@
* $Id$
*/
set_magic_quotes_runtime(0);
//if (function_exists('xdebug_disable')) xdebug_disable();
// Soap Server.
require_once('./lib/nusoap.php');
@ -27,6 +28,9 @@ require_once('./includes/configure.php');
// Create the soap Object
$s = new soap_server;
$ns='oscommerce';
$s->configureWSDL('WebServicesOSCommerceForDolibarOrders',$ns);
$s->wsdl->schemaTargetNamespace=$ns;
// Register the methods available for clients
$s->register('get_CAmensuel');
@ -35,7 +39,7 @@ $s->register('get_lastOrderClients');
$s->register('get_Order');
/*----------------------------------------------
* renvoie un tableau avec le CA mensuel réalisé
* renvoie un tableau avec le CA mensuel realise
-----------------------------------------------*/
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 (!($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 .= " FROM orders_total as t";
$sql .= " JOIN orders as o ON o.orders_id = t.orders_id";
$sql .= " WHERE t.class = 'ot_subtotal' ";
//AND YEAR(o.date_purchased) = YEAR(now()) ";
$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());
switch ($numrows = mysql_numrows($resquer)) {
case 0 :
case 0 :
return new soap_fault("Server", "MySQL 4", $sql);
break;
default :
@ -64,7 +68,7 @@ function get_CAmensuel() {
$i++;
}
break;
}
}
mysql_close($connexion);
/* Sends the results to the client */
return $result;
@ -83,12 +87,12 @@ $sql .= " WHERE t.class = 'ot_subtotal'";
if ($status > 0) $sql .= " and o.orders_status = ".$status;
$sql .= " ORDER BY o.date_purchased desc";
if ($limit > 0) $sql .= " LIMIT ".$limit;
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
$result ='';
switch ($numrows = mysql_numrows($resquer)) {
case 0 :
case 0 :
//return new soap_fault("Server", "MySQL 4", "produit inexistant");
break;
default :
@ -98,7 +102,7 @@ if ($limit > 0) $sql .= " LIMIT ".$limit;
$i++;
}
break;
}
}
mysql_close($connexion);
/* Sends the results to the client */
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 .= " WHERE t.class = 'ot_subtotal' and o.orders_status < 5 order by o.date_purchased desc";
if ($limit > 0) $sql .= " LIMIT ".$limit;
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
$result ='';
switch ($numrows = mysql_numrows($resquer)) {
case 0 :
case 0 :
return new soap_fault("Server", "MySQL 4", "produit inexistant");
break;
default :
@ -132,7 +136,7 @@ function get_lastOrderClients($id='',$name='',$limit='') {
$i++;
}
break;
}
}
mysql_close($connexion);
/* Sends the results to the client */
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 .= " 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 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 .= " 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;
$sql .= " GROUP BY p.orders_id ";
$sql .= " ORDER BY o.date_purchased desc";
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
$result ='';
switch ($numrows = mysql_numrows($resquer)) {
case 0 :
case 0 :
return new soap_fault("Server", "MySQL 4", "commande inexistante ".$sql);
break;
default :
@ -179,18 +183,18 @@ $sql .= " ORDER BY o.date_purchased desc";
}
$j = $i--;
if ($orderid > 0)
{
if ($orderid > 0)
{
//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 .= " FROM orders_products l ";
$sql .= " WHERE l.orders_id = ".$orderid;
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
switch ($numrows = mysql_numrows($resquer)) {
case 0 :
case 0 :
return new soap_fault("Server", "MySQL 5", "commande sans articles");
break;
default :

View File

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