diff --git a/htdocs/oscommerce_ws/clients/pre.inc.php b/htdocs/oscommerce_ws/clients/pre.inc.php
index 3a3c6935fdd..82ba7812017 100644
--- a/htdocs/oscommerce_ws/clients/pre.inc.php
+++ b/htdocs/oscommerce_ws/clients/pre.inc.php
@@ -41,6 +41,7 @@ function llxHeader($head = "", $urlp = "")
$menu->add(DOL_URL_ROOT."/oscommerce_ws/index.php", $langs->trans("OSCommerceShop"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/", $langs->trans("Products"));
+ $menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/categories.php", $langs->trans("Categories"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/clients/", $langs->trans("Clients"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/commandes/", $langs->trans("Commandes"));
diff --git a/htdocs/oscommerce_ws/commandes/fiche.php b/htdocs/oscommerce_ws/commandes/fiche.php
index 1d16676caaf..7ae06831d8d 100644
--- a/htdocs/oscommerce_ws/commandes/fiche.php
+++ b/htdocs/oscommerce_ws/commandes/fiche.php
@@ -157,7 +157,12 @@ if ($action == '' && !$cancel) {
for ($lig = 0; $lig < sizeof($commande->lines); $lig++)
{
- if (! $commande->lines[$lig]->fk_product) $err ++;
+// print "
traitement de ".$commande->lines[$lig]->fk_product."
";
+ if (! $commande->lines[$lig]->fk_product)
+ {
+ print "Article non trouvé ".$commande->lines[$lig]->libelle." : ".$commande->lines[$lig]->desc."
";
+ $err ++;
+ }
}
if ($err > 0) {
print (" Des produits de la commande sont inexistants
");
diff --git a/htdocs/oscommerce_ws/commandes/pre.inc.php b/htdocs/oscommerce_ws/commandes/pre.inc.php
index e722bbaa7af..8022b964674 100644
--- a/htdocs/oscommerce_ws/commandes/pre.inc.php
+++ b/htdocs/oscommerce_ws/commandes/pre.inc.php
@@ -41,6 +41,7 @@ function llxHeader($head = "", $urlp = "")
$menu->add(DOL_URL_ROOT."/oscommerce_ws/index.php", $langs->trans("OSCommerceShop"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/", $langs->trans("Products"));
+ $menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/categories.php", $langs->trans("Categories"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/clients/", $langs->trans("Clients"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/commandes/", $langs->trans("Commandes"));
diff --git a/htdocs/oscommerce_ws/includes/configure.php b/htdocs/oscommerce_ws/includes/configure.php
index b8147e37006..44a8f4727ba 100644
--- a/htdocs/oscommerce_ws/includes/configure.php
+++ b/htdocs/oscommerce_ws/includes/configure.php
@@ -1,22 +1,49 @@
+ * Copyright (C) 2004-2006 Laurent Destailleur
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Jean Heimburger jean@tiaris.info 2007
+ */
+
+/**
+ \file htdocs/oscommmerce_ws/includes/configure.php
+ \ingroup oscommerce_ws
+ \brief Configuration client Webservice
+ \version $Revision$
+*/
//base url des webservices
+
+
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(TX_CURRENCY, 1); // le taux de conversion monnaie site osc - monnaie dolibarr
+define(TX_CURRENCY, 119.33); // le taux de conversion monnaie site osc - monnaie dolibarr (1 euro = 119.33 XPF)
define(NB_DECIMALS, 0);
-define(FK_PORT, 0); // l'id du service frais de port défini.
+define(NB_DECIMALSITE, 2); // nb de décimales sur le site
+define(FK_PORT, 159); // l'id du service frais de port défini.
// fonctions
@@ -26,8 +53,20 @@ define(FK_PORT, 0); // l'id du service frais de port d
* \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);
-}
+ 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/pre.inc.php b/htdocs/oscommerce_ws/pre.inc.php
index b1606a2189c..0669f5ce8cb 100644
--- a/htdocs/oscommerce_ws/pre.inc.php
+++ b/htdocs/oscommerce_ws/pre.inc.php
@@ -40,6 +40,8 @@ function llxHeader($head = "", $urlp = "")
$menu->add(DOL_URL_ROOT."/oscommerce_ws/index.php", $langs->trans("OSCommerceShop"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/index.php", $langs->trans("Products"));
+ $menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/OSCvente.php", $langs->trans("AddProd"));
+ $menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/categories.php", $langs->trans("Categories"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/clients/index.php", $langs->trans("Clients"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/commandes/index.php", $langs->trans("Commandes"));
diff --git a/htdocs/oscommerce_ws/produits/OSCvente.php b/htdocs/oscommerce_ws/produits/OSCvente.php
new file mode 100644
index 00000000000..a0c1cb5cc14
--- /dev/null
+++ b/htdocs/oscommerce_ws/produits/OSCvente.php
@@ -0,0 +1,165 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ * $Source$
+ *
+ */
+require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/product.class.php");
+require_once(DOL_DOCUMENT_ROOT."/oscommerce_ws/includes/configure.php");
+
+llxHeader();
+$html = new Form($db);
+
+if ($_GET["action"] == 'liste' )
+{
+ // affichage des produits en vente à 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";
+
+ if ( $db->query($sql) )
+ {
+ $langs->load("products");
+ $num = $db->num_rows();
+ if ($num)
+ {
+ $i = 0;
+ print '
";
+ }
+ }
+}
+if ($_GET["action"] == 'vendre' )
+{
+ $product = new Product($db, $_POST["idprod"]);
+ $oscprod = new Osc_product($db);
+
+ $oscid = $oscprod->get_osc_productid($_POST["idprod"]);
+ if ( $oscid < 0)
+ {
+ $prod = array();
+ $prod['ref'] = $product->ref;
+ $prod['nom'] = $product->libelle;
+ $prod['desc'] = $product->description;
+ $prod['quant'] = $_POST["qty"];
+ $prod['prix'] = convert_backprice($product->price);
+ // à gèrer $product->tx_tva
+ $prod['poids'] = $product->weight;
+ // gèrer $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
+ {
+ if ($img[0]['photo_vignette']) $filename=$img[0]['photo_vignette'];
+ else $filename=$img[0]['photo'];
+ $prod['image'] = dolibarr_trunc($filename,16);
+ }
+
+// print_r($prod);
+// print '
';
+
+ set_magic_quotes_runtime(0);
+
+ //WebService Client.
+ require_once(NUSOAP_PATH."/nusoap.php");
+
+ // Création
+ // Set the parameters to send to the WebService
+ $parameters = array("prod"=>$prod);
+
+ // Set the WebService URL
+ $client = new soapclient(OSCWS_DIR."ws_articles.php");
+
+ // Call the WebService and store its result in $result.
+ $result = $client->call("create_article",$parameters );
+ if ($client->fault)
+ {
+ $this->error="Fault detected";
+ return -1;
+ }
+ elseif (!($err=$client->getError()) )
+ {
+ if ($result > 0)
+ {
+ // création de l'enregistrement dans osc_products
+ $oscprod->transcode($result,$_POST["idprod"]);
+ print "le produit ".$product->ref." ".$product->libelle.' est en vente en ligne consulter
';
+ print "\n";
+// print_r($result);
+
+ }
+ }
+ }
+ else
+ {
+ print "Le produit ".$_POST["idprod"].' est déjà en vente en ligne : consulter
';
+ print "\n";
+ }
+}
+
+/* choix du produit */
+
+ print '';
+ print '| '.$langs->trans('ProductsAndServices').' | ';
+ print ''.$langs->trans('Qty').' | ';
+ print '
';
+ print '';
+ print '
';
+
+
+ /* ************************************************************************** */
+ /* */
+ /* Barre d'action */
+ /* */
+ /* ************************************************************************** */
+ print "\n\n";
+
+llxFooter('$Date$ - $Revision$');
+?>
diff --git a/htdocs/oscommerce_ws/produits/categories.php b/htdocs/oscommerce_ws/produits/categories.php
new file mode 100644
index 00000000000..5075a7fd0b0
--- /dev/null
+++ b/htdocs/oscommerce_ws/produits/categories.php
@@ -0,0 +1,174 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ * $Source$
+ */
+
+/**
+ \file dev/skeletons/skeleton_page.php
+ \ingroup core
+ \brief Example of a php page
+ \version $Revision$
+*/
+
+require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
+require("osc_categories.class.php");
+//require_once(DOL_DOCUMENT_ROOT."/../dev/skeletons/skeleton_class.class.php");
+
+// Load traductions files
+$langs->load("companies");
+$langs->load("other");
+
+// Load permissions
+//$user->getrights("commercial");
+//if (!$user->rights->categorie->lire) accessforbidden();
+
+// Get parameters
+$socid = isset($_GET["socid"])?$_GET["socid"]:'';
+
+// Protection quand utilisateur externe
+if ($user->societe_id > 0)
+{
+ $action = '';
+ $socid = $user->societe_id;
+}
+//if ($socid == '') accessforbidden();
+
+
+
+/*******************************************************************
+* ACTIONS
+*
+* Put here all code to do according to value of "action" parameter
+********************************************************************/
+
+if ($_REQUEST["action"] == 'maj')
+{
+ $myobject=new Osc_categorie($db);
+ if ($myobject->fetch_dolicat($_POST["dolicat"]) <0)
+ {
+ $mesg = "erreur dans fetch_dolicat";
+ }
+ elseif ($myobject->id > 0)
+ {
+ $myobject->dolicatid=$_POST["dolicat"];
+ $myobject->osccatid=$_POST["osccat"];
+
+ $result=$myobject->update($user);
+ if ($result > 0)
+ {
+ // Creation OK
+ $mesg="";
+ }
+ else
+ {
+ // Creation KO
+ $mesg=$myobject->error;
+ }
+
+ }
+ else
+ {
+ $myobject->dolicatid=$_POST["dolicat"];
+ $myobject->osccatid=$_POST["osccat"];
+
+ $result=$myobject->create($user);
+ if ($result > 0)
+ {
+ // Creation OK
+ $mesg="";
+ }
+ else
+ {
+ // Creation KO
+ $mesg=$myobject->error;
+ }
+ }
+}
+
+
+
+
+
+/***************************************************
+* PAGE
+*
+* Put here all code to build page
+****************************************************/
+
+llxHeader();
+
+$html=new Form($db);
+
+if ($mesg) print "".$mesg."
";
+
+// Put here content of your page
+// ...
+if ($page == -1) { $page = 0 ; }
+$limit = $conf->liste_limit;
+$offset = $limit * $page ;
+
+$sql = "SELECT c.label, c.rowid dolicatid, oc.osccatid FROM ".MAIN_DB_PREFIX."categorie as c ";
+$sql .= "LEFT OUTER JOIN llx_osc_categories as oc ON oc.dolicatid = c.rowid ";
+$sql .= "WHERE c.visible = 1";
+
+print_barre_liste("Correspondance des catégories", $page, "categories.php");
+
+ dolibarr_syslog("Osc_Categorie.class::get_Osccat sql=".$sql);
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+
+ //titre
+ print '';
+ }
+ else
+ {
+ dolibarr_print_error();
+ }
+
+
+// End of page
+$db->close();
+llxFooter('$Date$ - $Revision$');
+?>
diff --git a/htdocs/oscommerce_ws/produits/fiche.php b/htdocs/oscommerce_ws/produits/fiche.php
index 7d2c74a5372..0570d0578e0 100644
--- a/htdocs/oscommerce_ws/produits/fiche.php
+++ b/htdocs/oscommerce_ws/produits/fiche.php
@@ -75,6 +75,7 @@ if ($action == '' && !$cancel) {
/* action Import création de l'objet product de dolibarr
*
*/
+
if (($_GET["action"] == 'import' ) && ( $_GET["id"] != '' ) && $user->rights->produit->creer)
{
$osc_prod = new Osc_product($db, $_GET['id']);
@@ -89,7 +90,11 @@ if ($action == '' && !$cancel) {
// exit;
}
$product = $osc_prod->osc2dolibarr($_GET['id']);
- }
+ }
+ else
+ {
+ print "erreur $osc_prod->fetch
";
+ }
/* utilisation de la table de transco*/
if ($osc_prod->get_productid($osc_prod->osc_id)>0)
@@ -98,15 +103,22 @@ if ($action == '' && !$cancel) {
}
else
{
+
$id = $product->create($user);
if ($id > 0)
{
print "\n\n";
+ $prod = new Product($db);
+ $res = $prod->fetch($id);
+
+ $prod->add_photo_web($conf->produit->dir_output,$osc_prod->osc_image);
print '
création réussie produit '.$id.' référence : '.$product->ref;
$res = $osc_prod->transcode($osc_prod->osc_id,$product->id);
+
print ' Id osc : '.$osc_prod->osc_id.'
';
print '
'.$langs->trans("Retour").'';
+
print "\n
\n";
$id_entrepot = OSC_ENTREPOT;
$id = $product->create_stock($id_entrepot,$osc_prod->osc_stock);
@@ -114,6 +126,7 @@ if ($action == '' && !$cancel) {
}
else
{
+ print "On a une erreur".$id."
";
if ($id == -3)
{
$_error = 1;
diff --git a/htdocs/oscommerce_ws/produits/index.php b/htdocs/oscommerce_ws/produits/index.php
index 2d34e05f314..9686b6015d6 100644
--- a/htdocs/oscommerce_ws/produits/index.php
+++ b/htdocs/oscommerce_ws/produits/index.php
@@ -88,7 +88,7 @@ elseif (!($err = $client->getError()) )
if ($prodid) $lib = "modifier";
else $lib = "importer";
print '".$lib." | \n";
- print "\n";
+ print ''."\n";
$i++;
}
print "";
@@ -98,7 +98,7 @@ elseif (!($err = $client->getError()) )
}
}
else {
- dolibarr_print_error('',"Erreur service web ".$err);
+ dolibarr_print_error('',"Erreur service web ".$client->faultstring);
}
print "";
diff --git a/htdocs/oscommerce_ws/produits/osc_categories.class.php b/htdocs/oscommerce_ws/produits/osc_categories.class.php
new file mode 100644
index 00000000000..5e766f6135f
--- /dev/null
+++ b/htdocs/oscommerce_ws/produits/osc_categories.class.php
@@ -0,0 +1,313 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ * $Source$
+ */
+
+/**
+ \file dev/skeletons/Osc_Categorie.class.class.php
+ \ingroup core
+ \brief Example for class
+ \version $Revision$
+*/
+
+// Put here all includes required by your script
+//require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
+//require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
+//require_once(DOL_DOCUMENT_ROOT."/product.class.php");
+
+
+
+/**
+ \class Osc_Categorie.class
+ \brief Class description
+*/
+
+class Osc_Categorie
+{
+ var $db;
+ var $error='';
+ var $errors=array();
+
+ var $id;
+ var $dolicatid;
+ var $osccatid;
+
+
+ /**
+ * \brief Constructor
+ * \param DB Database handler
+ */
+ function Osc_Categorie($DB)
+ {
+ $this->db = $DB;
+ return 1;
+ }
+
+
+ /**
+ * \brief Create in database
+ * \param user User that create
+ * \return int <0 si ko, >0 si ok
+ */
+ function create($user)
+ {
+ global $conf, $langs;
+
+ // Clean parameters
+ $this->dolicatid=trim($this->dolicatid);
+ $this->ocscatid=trim($this->ocscatid);
+
+ // Insert request
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_categories";
+ $sql.= "( dolicatid, osccatid)";
+ $sql.= " VALUES (";
+ $sql.= " '".$this->dolicatid."',";
+ $sql.= " '".$this->osccatid."'";
+ $sql.= ")";
+ dolibarr_syslog("Osc_Categorie.class::create sql=".$sql);
+
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."osc_categories");
+
+/* $resql=$this->update($user, 1);
+ if ($resql < 0)
+ {
+ $this->error=$this->db->lasterror();
+ return -2;
+ }
+
+ // Appel des triggers
+ include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
+ if ($result < 0) $this->errors=$interface->errors;
+ // Fin appel triggers
+
+ $this->id = $newid;
+ */
+ return $this->id;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ $this->error = $sql;
+ dolibarr_syslog("Osc_Categorie.class::create ".$this->error);
+ return -1;
+ }
+ }
+
+ /*
+ * \brief Update database
+ * \param user User that modify
+ * \param notrigger 0=no, 1=yes (no update trigger)
+ * \return int <0 if KO, >0 if OK
+ */
+ function update($user=0, $notrigger=0)
+ {
+ global $conf, $langs;
+
+ // Clean parameters
+ $this->dolicatid=trim($this->dolicatid);
+ $this->ocscatid=trim($this->ocscatid);
+
+ // Update request
+ $sql = "UPDATE ".MAIN_DB_PREFIX."osc_categories SET";
+ $sql.= " dolicatid='".addslashes($this->dolicatid)."',";
+ $sql.= " osccatid='".addslashes($this->osccatid)."'";
+ $sql.= " WHERE rowid=".$this->id;
+ dolibarr_syslog("Osc_Categorie.class::update sql=".$sql,LOG_DEBUG);
+
+ $resql = $this->db->query($sql);
+ if (! $resql)
+ {
+ $this->error=$this->db->lasterror().' sql='.$sql;
+ return -1;
+ }
+
+ if (! $notrigger)
+ {
+ // Appel des triggers
+ include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
+ if ($result < 0) $this->errors=$interface->errors;
+ // Fin appel triggers
+ }
+
+ return 1;
+ }
+
+
+ /*
+ * \brief Load object in memory from database
+ * \param id id object
+ * \param user User that load
+ * \return int <0 if KO, >0 if OK
+ */
+ function fetch($id, $user=0)
+ {
+ global $langs;
+ $sql = "SELECT t.rowid, t.dolicatid, t.osccatid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."osc_categories as t";
+ $sql.= " WHERE c.rowid = ".$id;
+
+ dolibarr_syslog("Osc_Categorie.class::fetch sql=".$sql);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+ $this->dolicatid = $obj->dolicatid;
+ $this->ocscatid = $obj->osccatid;
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dolibarr_syslog("Osc_Categorie.class::fetch ".$this->error);
+ return -1;
+ }
+ }
+
+ /*
+ * \brief Load object in memory from database
+ * \param id id object
+ * \param user User that load
+ * \return int <0 if KO, >0 if OK
+ */
+ function fetch_osccat($oscid, $user=0)
+ {
+ global $langs;
+ $sql = "SELECT t.rowid, t.dolicatid, t.osccatid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."osc_categories as t";
+ $sql.= " WHERE t.osccatid = ".$oscid;
+
+ dolibarr_syslog("Osc_Categorie.class::fetch_osccat sql=".$sql);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+ $this->dolicatid = $obj->dolicatid;
+ $this->osccatid = $obj->osccatid;
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dolibarr_syslog("Osc_Categorie.class::fetch_osccat ".$this->error);
+ return -1;
+ }
+ }
+
+ /*
+ * \brief Load object in memory from database
+ * \param id id object
+ * \param user User that load
+ * \return int <0 if KO, >0 if OK
+ */
+ function fetch_dolicat($doliid, $user=0)
+ {
+ global $langs;
+ $sql = "SELECT t.rowid, t.dolicatid, t.osccatid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."osc_categories as t";
+ $sql.= " WHERE t.dolicatid = ".$doliid;
+
+ dolibarr_syslog("Osc_Categorie.class::fetch_dolicat sql=".$sql);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+ $this->dolicatid = $obj->dolicatid;
+ $this->ocscatid = $obj->osccatid;
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dolibarr_syslog("Osc_Categorie.class::fetch_dolicat ".$this->error);
+ return -1;
+ }
+ }
+
+ /*
+ * \brief Delete object in database
+ * \param user User that delete
+ * \return int <0 if KO, >0 if OK
+ */
+ function delete($user)
+ {
+ global $conf, $langs;
+
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."osc_categories";
+ $sql.= " WHERE rowid=".$this->id;
+
+ dolibarr_syslog("Osc_Categorie.class::delete sql=".$sql);
+ $resql = $this->db->query($sql);
+ if (! $resql)
+ {
+ $this->error=$this->db->lasterror().' sql='.$sql;
+ return -1;
+ }
+
+ // Appel des triggers
+ include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ if ($result < 0) $this->errors=$interface->errors;
+ // Fin appel triggers
+
+ return 1;
+ }
+
+
+ /**
+ * \brief Initialise object with example values
+ * \remarks id must be 0 if object instance is a specimen.
+ */
+ function initAsSpecimen()
+ {
+ $this->id=0;
+ $this->dolicatid=0;
+ $this->osccatid=0;
+ }
+
+}
+?>
diff --git a/htdocs/oscommerce_ws/produits/osc_product.class.php b/htdocs/oscommerce_ws/produits/osc_product.class.php
index f4aeed1037f..bf69ca35e86 100644
--- a/htdocs/oscommerce_ws/produits/osc_product.class.php
+++ b/htdocs/oscommerce_ws/produits/osc_product.class.php
@@ -45,6 +45,7 @@ class Osc_product
var $osc_stockmini;
var $osc_stock;
var $osc_four;
+ var $osc_image;
var $error;
@@ -108,6 +109,7 @@ class Osc_product
$this->osc_stock = $obj[products_quantity];
$this->osc_four = $obj[manufacturers_id];
$this->osc_price = $obj[products_price];
+ $this->osc_image = $obj[image];
}
else {
$this->error = 'Erreur '.$err ;
@@ -200,7 +202,17 @@ class Osc_product
else return '';
}
-
+ function get_osc_productid($productidp)
+ {
+ $sql = "SELECT osc_prodid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."osc_product";
+ $sql.= " WHERE doli_prodidp = ".$productidp;
+ $result=$this->db->query($sql);
+ $row = $this->db->fetch_row($resql);
+// test d'erreurs
+ if ($row) return $row[0];
+ else return -1;
+ }
/**
* \brief création d'un article dans base OSC
diff --git a/htdocs/oscommerce_ws/produits/pre.inc.php b/htdocs/oscommerce_ws/produits/pre.inc.php
index a81913dbeea..a9e585fc214 100644
--- a/htdocs/oscommerce_ws/produits/pre.inc.php
+++ b/htdocs/oscommerce_ws/produits/pre.inc.php
@@ -41,6 +41,8 @@ function llxHeader($head = "", $urlp = "")
$menu->add(DOL_URL_ROOT."/oscommerce_ws/index.php", $langs->trans("OSCommerceShop"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/", $langs->trans("Products"));
+ $menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/OSCvente.php", $langs->trans("AddProd"));
+ $menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/categories.php", $langs->trans("Categories"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/clients/", $langs->trans("Clients"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/commandes/", $langs->trans("Commandes"));
diff --git a/htdocs/oscommerce_ws/ws_server/includes/configure.php b/htdocs/oscommerce_ws/ws_server/includes/configure.php
index da209f33675..568e490c072 100644
--- a/htdocs/oscommerce_ws/ws_server/includes/configure.php
+++ b/htdocs/oscommerce_ws/ws_server/includes/configure.php
@@ -11,8 +11,11 @@ define("DB_SERVER","localhost");
define("DB_SERVER_USERNAME", "root");
define("DB_SERVER_PASSWORD", "");
define("DB_DATABASE", "tahitirimai");
+// chemin vers sources OSC admin
+define('OSCADMIN', '/home/jean/projets/osc_tiaris/admin/');
/* constantes utiles */
define("OSC_LANGUAGE_ID",1);
+define(OSC_URL, 'http://osc-tiaris/'); // url du site OSC
?>
diff --git a/htdocs/oscommerce_ws/ws_server/ws_articles.php b/htdocs/oscommerce_ws/ws_server/ws_articles.php
index ce0a146f66e..3f226aace10 100644
--- a/htdocs/oscommerce_ws/ws_server/ws_articles.php
+++ b/htdocs/oscommerce_ws/ws_server/ws_articles.php
@@ -24,8 +24,11 @@ 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/jean/projets/osc_tiaris/admin/');
+define('OSCIMAGES', '/home/jean/projets/osc_tiaris/images/');
require(OSCADMIN.'includes/configure.php');
require(OSCADMIN.DIR_WS_CLASSES . 'object_info.php');
@@ -49,6 +52,8 @@ $s->register('get_article');
$s->register('get_listearticles');
$s->register('create_article');
+
+
function create_article($prod)
{
// make a connection to the database... now
@@ -98,7 +103,7 @@ function get_article($id='',$ref='') {
if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error());
//on recherche
- $sql = "SELECT p.products_id, p.products_model, p.products_quantity, p.products_status, p.products_price, d.products_name, d.products_description, m.manufacturers_name, m.manufacturers_id";
+ $sql = "SELECT p.products_id, p.products_model, p.products_quantity, p.products_status, concat('".OSC_IMG_URL."',p.products_image) as image, p.products_price, d.products_name, d.products_description, m.manufacturers_name, 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";
$sql .= " WHERE d.language_id =" . OSC_LANGUAGE_ID;
@@ -130,7 +135,7 @@ function get_listearticles() {
if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error());
//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, d.products_name as name, m.manufacturers_name as manufacturer, m.manufacturers_id";
+ $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";
$sql .= " WHERE d.language_id =" . OSC_LANGUAGE_ID;
@@ -154,6 +159,14 @@ function get_listearticles() {
return $liste_articles;
}
+function saveImage($name,$content)
+{
+ $fich = fopen(OSCIMAGES.$name, 'wb');
+ fwrite($fich,base64_decode($content));
+ fclose($fich);
+ return $name.' enregistré';
+}
+
// Return the results.
$s->service($HTTP_RAW_POST_DATA);
diff --git a/htdocs/oscommerce_ws/ws_server/ws_test.php b/htdocs/oscommerce_ws/ws_server/ws_test.php
index d53f8f4bdac..b24f29c115c 100644
--- a/htdocs/oscommerce_ws/ws_server/ws_test.php
+++ b/htdocs/oscommerce_ws/ws_server/ws_test.php
@@ -7,15 +7,16 @@ 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('hello');
function hello($name){
-$returnedString = "Hello de Tetiaroa ".$name." !";
+$returnedString = "Coucou ** de Tetiaroa ".$name." !";
return $returnedString;
}
@@ -23,3 +24,4 @@ return $returnedString;
// Return the results.
$s->service($HTTP_RAW_POST_DATA);
?>
+