diff --git a/htdocs/oscommerce_ws/includes/configure.php b/htdocs/oscommerce_ws/includes/configure.php index 974336b6494..3b3ad2f5afc 100644 --- a/htdocs/oscommerce_ws/includes/configure.php +++ b/htdocs/oscommerce_ws/includes/configure.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2007 Jean Heimburger * * 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�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); +} ?> diff --git a/htdocs/oscommerce_ws/ws_server/README b/htdocs/oscommerce_ws/ws_server/README index b10a109019b..5a3f05699ea 100644 --- a/htdocs/oscommerce_ws/ws_server/README +++ b/htdocs/oscommerce_ws/ws_server/README @@ -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. diff --git a/htdocs/oscommerce_ws/ws_server/index.php b/htdocs/oscommerce_ws/ws_server/index.php index e69de29bb2d..c5a88e6d0a6 100644 --- a/htdocs/oscommerce_ws/ws_server/index.php +++ b/htdocs/oscommerce_ws/ws_server/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/htdocs/oscommerce_ws/ws_server/ws_articles.php b/htdocs/oscommerce_ws/ws_server/ws_articles.php index 4af82baf806..cd2984e6d33 100644 --- a/htdocs/oscommerce_ws/ws_server/ws_articles.php +++ b/htdocs/oscommerce_ws/ws_server/ws_articles.php @@ -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�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�'; } - -// 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); diff --git a/htdocs/oscommerce_ws/ws_server/ws_index.html b/htdocs/oscommerce_ws/ws_server/ws_index.html index 0e319a384ee..4be629c6f6e 100644 --- a/htdocs/oscommerce_ws/ws_server/ws_index.html +++ b/htdocs/oscommerce_ws/ws_server/ws_index.html @@ -15,6 +15,11 @@ your server OSCommerce.

Those pages will be called by Dolibarr using its own SOAP web service client.

-However, don't forget to edit the configure.php file in the ws_server/includes directory.
+However, don't forget to edit the
+* configure.php file in the OSCommerce server side (in ws_server/includes directory) to define +how to connect to the OSCommerce database.
+* 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.
+ \ No newline at end of file