Fix: Help for ws service is more clear.
This commit is contained in:
parent
658c95a3e6
commit
c82425c488
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007 Jean Heimburger <jean@tiaris.info>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -19,55 +19,55 @@
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
\file htdocs/oscommmerce_ws/includes/configure.php
|
||||
\ingroup oscommerce_ws
|
||||
\brief Configuration client Webservice
|
||||
\version $Revision$
|
||||
*/
|
||||
* \file htdocs/oscommmerce_ws/includes/configure.php
|
||||
* \ingroup oscommerce_ws
|
||||
* \brief Configuration client Webservice
|
||||
* \version $Revision$
|
||||
*/
|
||||
|
||||
//base url des webservices
|
||||
// URL To reach web services
|
||||
define(OSCWS_DIR,'http://myoscserver/ws_server/');
|
||||
|
||||
// URL To reach OSCommerce
|
||||
define(OSC_URL, 'http://myoscserver/'); // url du site OSC
|
||||
|
||||
|
||||
define(OSCWS_DIR,'http://www.tiaris.info/catalog/ws_OSC/');
|
||||
|
||||
define(OSC_URL, 'http://www.tiaris.info/catalog/'); // url du site OSC
|
||||
|
||||
//affichages dans la page d'accueil
|
||||
define(OSC_MAXNBCOM, 5);
|
||||
define(OSC_ORDWAIT,'4'); // code du statut de commande en attente
|
||||
define(OSC_ORDPROCESS,'1'); // code du statut de commande en traitement
|
||||
//
|
||||
|
||||
define(OSC_ENTREPOT, 1); //l'entrepot lié au stock du site web
|
||||
define(OSC_ENTREPOT, 1); //l'entrepot lie au stock du site web
|
||||
define(TX_CURRENCY, 1); // le taux de conversion monnaie site osc - monnaie dolibarr (1 euro = 119.33 XPF)
|
||||
define(NB_DECIMALS, 2);
|
||||
define(NB_DECIMALSITE, 2); // nb de décimales sur le site
|
||||
define(FK_PORT, 2); // l'id du service frais de port défini.
|
||||
define(NB_DECIMALSITE, 2); // nb de decimales sur le site
|
||||
define(FK_PORT, 2); // l'id du service frais de port defini.
|
||||
|
||||
// fonctions
|
||||
|
||||
/**
|
||||
* \brief assure la conversion en monnaie de dolibarr
|
||||
* \param oscid Id du produit dans OsC
|
||||
* \param prodid champ référence
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function convert_price($price)
|
||||
{
|
||||
return round($price * TX_CURRENCY, NB_DECIMALS);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief assure la conversion en monnaie de dolibarr
|
||||
* \param oscid Id du produit dans OsC
|
||||
* \param prodid champ référence
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function convert_backprice($price)
|
||||
{
|
||||
return round($price / TX_CURRENCY, NB_DECIMALSITE);
|
||||
}
|
||||
* \brief assure la conversion en monnaie de dolibarr
|
||||
* \param oscid Id du produit dans OsC
|
||||
* \param prodid champ r<EFBFBD>f<EFBFBD>rence
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function convert_price($price)
|
||||
{
|
||||
return round($price * TX_CURRENCY, NB_DECIMALS);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief assure la conversion en monnaie de dolibarr
|
||||
* \param oscid Id du produit dans OsC
|
||||
* \param prodid champ r<EFBFBD>f<EFBFBD>rence
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function convert_backprice($price)
|
||||
{
|
||||
return round($price / TX_CURRENCY, NB_DECIMALSITE);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -3,7 +3,7 @@ OSCommerce interface and Dolibarr
|
||||
|
||||
TODO ON THE OSCOMMERCE WEBSITE INSTALLATION :
|
||||
|
||||
Copy the contents of the ws_server directory on the OSCommerce web server.
|
||||
Copy the directory ws_server and its content on the OSCommerce web server.
|
||||
This includes the lib directory which contains the nusoap library, the
|
||||
includes directory which contains the configure.php file and the ws_* files.
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
header("Location: ws_index.html");
|
||||
?>
|
||||
@ -23,19 +23,6 @@ set_magic_quotes_runtime(0);
|
||||
|
||||
require_once("./includes/configure.php");
|
||||
|
||||
define(OSC_IMG_URL, 'http://www.tiaris.info/catalog/images/'); // url du site OSC
|
||||
|
||||
// OSC
|
||||
|
||||
define('OSCADMIN', '/home/tiaris.info/catalog/admin/');
|
||||
define('OSCIMAGES', '/home/tiaris.info/catalog/images/');
|
||||
|
||||
require(OSCADMIN.'includes/configure.php');
|
||||
require(OSCADMIN.DIR_WS_CLASSES . 'object_info.php');
|
||||
require(OSCADMIN.DIR_WS_INCLUDES . 'database_tables.php');
|
||||
require(OSCADMIN.DIR_WS_FUNCTIONS . 'database.php');
|
||||
require(OSCADMIN.DIR_WS_FUNCTIONS . 'general.php');
|
||||
|
||||
|
||||
// Soap Server.
|
||||
require_once('./lib/nusoap.php');
|
||||
@ -43,9 +30,9 @@ 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('WebServicesOSCommerceForDolibarr',$ns);
|
||||
$s->wsdl->schemaTargetNamespace=$ns;
|
||||
*/
|
||||
|
||||
// Register a method available for clients
|
||||
$s->register('get_article');
|
||||
@ -56,11 +43,11 @@ $s->register('get_categorylist');
|
||||
|
||||
function create_article($prod)
|
||||
{
|
||||
// make a connection to the database... now
|
||||
tep_db_connect() or die('Unable to connect to database server!');
|
||||
|
||||
// vérifier les paramètres
|
||||
$sql_data_array = array('products_quantity' => $prod['quant'],
|
||||
// make a connection to the database... now
|
||||
tep_db_connect() or die('Unable to connect to database server!');
|
||||
|
||||
// v<>rifier les param<61>tres
|
||||
$sql_data_array = array('products_quantity' => $prod['quant'],
|
||||
'products_model' => $prod['ref'],
|
||||
'products_image' => $prod['image'],
|
||||
'products_price' => $prod['prix'],
|
||||
@ -72,29 +59,29 @@ $sql_data_array = array('products_quantity' => $prod['quant'],
|
||||
'products_tax_class_id' => $prod['ttax'],
|
||||
'manufacturers_id' => $prod['fourn']);
|
||||
|
||||
tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
|
||||
$products_id = tep_db_insert_id();
|
||||
tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
|
||||
$products_id = tep_db_insert_id();
|
||||
|
||||
$category_id = 2;
|
||||
tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$category_id . "')");
|
||||
$category_id = 2;
|
||||
tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$category_id . "')");
|
||||
|
||||
$languages = tep_get_languages();
|
||||
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
|
||||
$language_id = $languages[$i]['id'];
|
||||
$sql_data_array = array('products_name' => $prod['nom'],
|
||||
$languages = tep_get_languages();
|
||||
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
|
||||
$language_id = $languages[$i]['id'];
|
||||
$sql_data_array = array('products_name' => $prod['nom'],
|
||||
'products_description' => $prod['desc'],
|
||||
'products_url' => $prod['url'],
|
||||
//'products_head_title_tag' => $prod['nom'],
|
||||
//'products_head_desc_tag' => $prod['desc'],
|
||||
//'products_head_keywords_tag' => '',
|
||||
//'products_head_title_tag' => $prod['nom'],
|
||||
//'products_head_desc_tag' => $prod['desc'],
|
||||
//'products_head_keywords_tag' => '',
|
||||
'products_id' => $products_id,
|
||||
'language_id' => $language_id
|
||||
);
|
||||
tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
|
||||
}
|
||||
);
|
||||
tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
|
||||
}
|
||||
|
||||
return $products_id;
|
||||
}
|
||||
return $products_id;
|
||||
}
|
||||
|
||||
|
||||
function get_article($id='',$ref='')
|
||||
@ -116,16 +103,16 @@ function get_article($id='',$ref='')
|
||||
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
|
||||
|
||||
switch (mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL 4", "produit inexistant");
|
||||
break;
|
||||
case 1 :
|
||||
$res_article = @mysql_fetch_array($resquer, MYSQL_ASSOC);
|
||||
$res_article["time"] = time();
|
||||
break;
|
||||
default :
|
||||
return new soap_fault("Server", "MySQL 5", "erreur requete");
|
||||
}
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL 4", "produit inexistant");
|
||||
break;
|
||||
case 1 :
|
||||
$res_article = @mysql_fetch_array($resquer, MYSQL_ASSOC);
|
||||
$res_article["time"] = time();
|
||||
break;
|
||||
default :
|
||||
return new soap_fault("Server", "MySQL 5", "erreur requete");
|
||||
}
|
||||
mysql_close($connexion);
|
||||
/* Sends the results to the client */
|
||||
return $res_article;
|
||||
@ -133,11 +120,11 @@ function get_article($id='',$ref='')
|
||||
|
||||
function get_listearticles() {
|
||||
|
||||
//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());
|
||||
|
||||
//on recherche
|
||||
//on recherche
|
||||
$sql = "SELECT p.products_id as OSC_id, p.products_model as model, p.products_quantity as quantity, p.products_status as status, concat('".OSC_IMG_URL."',p.products_image) as image, d.products_name as name, m.manufacturers_name as manufacturer, m.manufacturers_id";
|
||||
$sql .= " FROM products as p";
|
||||
$sql .= " JOIN products_description as d ON p.products_id = d.products_id "; $sql .= " LEFT JOIN manufacturers as m ON p.manufacturers_id=m.manufacturers_id";
|
||||
@ -145,21 +132,21 @@ function get_listearticles() {
|
||||
|
||||
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
|
||||
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL 4", "produit inexistant");
|
||||
break;
|
||||
default :
|
||||
default :
|
||||
$i = 0;
|
||||
while ( $i < $numrows) {
|
||||
$liste_articles[$i] = mysql_fetch_array($resquer, MYSQL_ASSOC);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mysql_close($connexion);
|
||||
/* Sends the results to the client */
|
||||
return $liste_articles;
|
||||
/* Sends the results to the client */
|
||||
return $liste_articles;
|
||||
}
|
||||
|
||||
function saveImage($name,$content)
|
||||
@ -167,41 +154,41 @@ function saveImage($name,$content)
|
||||
$fich = fopen(OSCIMAGES.$name, 'wb');
|
||||
fwrite($fich,base64_decode($content));
|
||||
fclose($fich);
|
||||
return $name.' enregistré';
|
||||
return $name.' enregistr<EFBFBD>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// OSC categories list from $catid
|
||||
|
||||
// OSC categories list from $catid
|
||||
function get_categorylist($catid)
|
||||
{
|
||||
//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());
|
||||
|
||||
$sql = "select c.categories_id, cd.categories_name, c.parent_id ";
|
||||
$sql .= " FROM categories c, categories_description cd ";
|
||||
$sql .= " WHERE c.parent_id = '".$catid."' and c.categories_id = cd.categories_id and cd.language_id='" . OSC_LANGUAGE_ID ."' order by sort_order, cd.categories_name";
|
||||
|
||||
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL gey_categorylist ".$sql, mysql_error());
|
||||
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL gey_categorylist", "pas de categories");
|
||||
break;
|
||||
default :
|
||||
$i = 0;
|
||||
while ( $i < $numrows)
|
||||
{
|
||||
$liste_cat[$i] = mysql_fetch_array($resquer, MYSQL_ASSOC);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
mysql_close($connexion);
|
||||
/* Sends the results to the client */
|
||||
return $liste_cat;
|
||||
//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());
|
||||
|
||||
$sql = "select c.categories_id, cd.categories_name, c.parent_id ";
|
||||
$sql .= " FROM categories c, categories_description cd ";
|
||||
$sql .= " WHERE c.parent_id = '".$catid."' and c.categories_id = cd.categories_id and cd.language_id='" . OSC_LANGUAGE_ID ."' order by sort_order, cd.categories_name";
|
||||
|
||||
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL gey_categorylist ".$sql, mysql_error());
|
||||
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL gey_categorylist", "pas de categories");
|
||||
break;
|
||||
default :
|
||||
$i = 0;
|
||||
while ( $i < $numrows)
|
||||
{
|
||||
$liste_cat[$i] = mysql_fetch_array($resquer, MYSQL_ASSOC);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
mysql_close($connexion);
|
||||
/* Sends the results to the client */
|
||||
return $liste_cat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Return the results.
|
||||
$s->service($HTTP_RAW_POST_DATA);
|
||||
|
||||
@ -15,6 +15,11 @@ your server OSCommerce.<br>
|
||||
<br>
|
||||
Those pages will be called by Dolibarr using its own SOAP web service client.<br>
|
||||
<br>
|
||||
However, don't forget to edit the configure.php file in the ws_server/includes directory.<br>
|
||||
However, don't forget to edit the <br>
|
||||
* configure.php file in the OSCommerce server side (in ws_server/includes directory) to define
|
||||
how to connect to the OSCommerce database.<br>
|
||||
* configure.php file in the Dolibarr server side (in oscommerce_ws/includes directory) to define
|
||||
how to connect to the OSCommerce server side web services.<br>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user