dolibarr-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dolibarr-cvs] dolibar - OsCommerce


From: Tahiti Rimai (Jean)
Subject: [Dolibarr-cvs] dolibar - OsCommerce
Date: Fri, 24 Nov 2006 16:49:15 -1000
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

Modifcation des fonctions d'imports:

création des tables de passages pour l'import des produits, commandes, clients et modification des classes correspondantes.
modification de l'interface utilisateur


diff -Naur /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/CVS/Entries 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/CVS/Entries
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/CVS/Entries        
2006-10-10 08:09:56.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/CVS/Entries        
2006-10-10 08:21:43.000000000 -1000
@@ -1,5 +1,5 @@
 /index.php/1.1/Fri Aug 11 23:20:32 2006//
 /pre.inc.php/1.1/Fri Aug 11 23:20:32 2006//
-/fiche.php/1.2/Fri Sep  1 00:26:56 2006//
-/osc_customer.class.php/1.3/Tue Oct 10 18:09:56 2006//
+/fiche.php/1.2/Fri Sep  1 00:01:04 2006//
+/osc_customer.class.php/1.3/Tue Oct 10 18:21:43 2006//
 D
diff -Naur /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/fiche.php 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/fiche.php
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/fiche.php  
2006-08-31 14:26:56.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/fiche.php  
2006-11-22 11:30:07.473800280 -1000
@@ -54,20 +54,27 @@
          if ( $user->rights->societe->creer) {
         print '<a class="tabAction" 
href="fiche.php?action=import&amp;custid='.$osc_cust->osc_custid.'">'.$langs->trans("Import").'</a>';
        }
+    print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
        print "\n</div><br>\n";
 // seule action importer
      
        }
       else
        {
-         print "<p>ERROR 1c</p>\n";
-         dolibarr_print_error('',"erreur webservice ".$osc_cust->error);
+               print "\n<div class=\"tabsAction\">\n";
+                 print "<p>ERROR 1c</p>\n";
+                 dolibarr_print_error('',"erreur webservice 
".$osc_cust->error);
+         print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+               print "\n</div><br>\n";
        }
  }
  else
  {
-   print "<p>ERROR 1b</p>\n";
-   print "Error";
+       print "\n<div class=\"tabsAction\">\n";
+          print "<p>ERROR 1b</p>\n";
+          print "Error";
+          print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+       print "\n</div><br>\n";
  }
 }
 /* action Import création de l'objet product de dolibarr 
@@ -83,8 +90,11 @@
                        $societe = new Societe($db);
                if ($_error == 1)
                {
-                       print '<br>erreur 1</br>';
-                               exit;
+             
+                               print "\n<div class=\"tabsAction\">\n";
+                               print '<br>erreur 1</br>';
+                               print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+                               print "\n</div><br>\n";
                }
 
                /* initialisation */
@@ -105,14 +115,22 @@
                        $societe->client = 1; // mettre 0 si prospect
                 } 
 
+/* utilisation de la table de transco*/
+               if ($osc_cust->get_clientid($osc_cust->osc_custid)>0)
+               {
+                       print '<p>Ce client existe déjà</p>';
+               }
+               else {
                        $id = $societe->create($user);
               
                    if ($id == 0)
                    {
-                       print '<br>création réussie nouveau client/prospect 
'.$societe->id.' nom : '.$societe->nom.'</br>';
-                               $res = 
$osc_cust->transcode($osc_cust->osc_custid,$societe->id);
-print '<br>transcode '.$res.' | '.$societe->id.' osc : 
'.$osc_cust->osc_custid.'</br>';
-
+                       print "\n<div class=\"tabsAction\">\n";
+                               print '<p>création réussie nouveau 
client/prospect '.$societe->id.' nom : '.$societe->nom.'</p>';
+                               $res = 
$osc_cust->transcode($osc_cust->osc_custid,$societe->id);
+                                       print '<p>transcode '.$res.' | 
'.$societe->id.' osc : '.$osc_cust->osc_custid.'</p>';
+                               print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+                               print "\n</div><br>\n";
                    }
                    else
                    {
@@ -128,8 +146,10 @@
                                 $societe_control = new Societe($db);
                                 if ($_error == 1)
                         {
+                               print "\n<div class=\"tabsAction\">\n";
                                print '<br>erreur 1</br>';
-                                       exit;
+                                       print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+                                       print "\n</div><br>\n";
                         }
                             $idp = $societe_control->fetch($socid = 
$osc_cust->osc_ref);
                                        
@@ -143,6 +163,7 @@
                                        else print '<br>update impossible $id : 
'.$idp.' </br>';
                                }
                    }
+                }
  
     }
 
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/.#fiche.php.1.1 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/.#fiche.php.1.1
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/.#fiche.php.1.1    
1969-12-31 14:00:00.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/.#fiche.php.1.1    
2006-08-12 11:53:31.000000000 -1000
@@ -0,0 +1,150 @@
+<?php
+/*  Copyright (C) 2006      Jean Heimburger     <address@hidden>
+ *
+ *
+ * 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.
+ *
+ * $Source: 
/sources/dolibarr/dolibarr/htdocs/oscommerce_ws/clients/fiche.php,v $
+ *
+ */
+require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
+require_once("../includes/configure.php");
+
+llxHeader();
+
+if ($action == '' && !$cancel) {
+
+ if ($_GET['custid'])
+ {
+  $osc_cust = new Osc_customer($db, $_GET['custid']);
+  $result = $osc_cust->fetch($_GET['custid']);
+
+  if ( !$result)
+    { 
+      print '<div class="titre">Fiche client OSC : 
'.$osc_cust->osc_custfirstname.'  '.$osc_cust->osc_custlastname.'</div><br>';
+
+      print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
+      print '<tr></tr><td width="20%">Ville</td><td 
width="80%">'.$osc_cust->osc_custcity.'</td></tr>';
+      print '<tr></tr><td width="20%">Pays</td><td 
width="80%">'.$osc_cust->osc_custcountry.'</td></tr>';
+      print '<tr></tr><td width="20%">Id OSC</td><td 
width="80%">'.$osc_cust->osc_custid.'</td></tr>';
+      print '<tr></tr><td width="20%">Téléphone</td><td 
width="80%">'.$osc_cust->osc_custtel.'</td></tr>';
+      print '<tr></tr><td width="20%">E-mail</td><td 
width="80%">'.$osc_cust->osc_custmail.'</td></tr>';
+      print "</table>";
+
+       /* 
************************************************************************** */
+       /*                                                                      
      */ 
+       /* Barre d'action                                                       
      */ 
+       /*                                                                      
      */ 
+       /* 
************************************************************************** */
+       print "\n<div class=\"tabsAction\">\n";
+
+         if ( $user->rights->societe->creer) {
+        print '<a class="tabAction" 
href="fiche.php?action=import&amp;custid='.$osc_cust->osc_custid.'">'.$langs->trans("Import").'</a>';
+       }
+       print "\n</div><br>\n";
+// seule action importer
+     
+       }
+      else
+       {
+         print "<p>ERROR 1c</p>\n";
+         dolibarr_print_error('',"erreur webservice ".$osc_cust->error);
+       }
+ }
+ else
+ {
+   print "<p>ERROR 1b</p>\n";
+   print "Error";
+ }
+}
+/* action Import création de l'objet product de dolibarr 
+*
+*/
+ if (($_GET["action"] == 'import' ) && ( $_GET["custid"] != '' ) && 
$user->rights->produit->creer)
+    {
+                 $osc_cust = new Osc_customer($db, $_GET['custid']);
+                 $result = $osc_cust->fetch($_GET['custid']);
+       
+         if ( !$result )
+         {
+                       $societe = new Societe($db);
+               if ($_error == 1)
+               {
+                       print '<br>erreur 1</br>';
+                               exit;
+               }
+
+               /* initialisation */
+               $societe->nom = $osc_cust->osc_custsoc.' 
'.$osc_cust->osc_custlastname;
+               $societe->adresse = $osc_cust->osc_cutstreet;
+               $societe->cp = $osc_cust->osc_custpostcode;
+               $societe->ville = $osc_cust->osc_custcity;
+               $societe->departement_id = 0;
+               $societe->pays_code = $osc_cust->osc_custcodecountry;
+               $societe->tel = $osc_cust->osc_custtel; 
+               $societe->fax = $osc_cust->osc_custfax; 
+               $societe->email = $osc_cust->osc_custmail; 
+       /* on force */
+                       $societe->url = '';
+                       $societe->siren = '';
+                       $societe->siret = '';
+                       $societe->ape = '';
+                       $societe->client = 1; // mettre 0 si prospect
+                } 
+
+                       $id = $societe->create($user);
+              
+                   if ($id == 0)
+                   {
+                       print '<br>création réussie nouveau client/prospect 
'.$societe->id.' nom : '.$societe->nom.'</br>';
+                               $res = 
$osc_cust->transcode($osc_cust->osc_custid,$societe->id);
+print '<br>transcode '.$res.' | '.$societe->id.' osc : 
'.$osc_cust->osc_custid.'</br>';
+
+                   }
+                   else
+                   {
+                       if ($id == -3)
+                       {
+                           $_error = 1;
+                           $_GET["action"] = "create";
+                           $_GET["type"] = $_POST["type"];
+                       }
+                               if ($id == -2)
+                               {
+                               /* la référence existe on fait un update */
+                                $societe_control = new Societe($db);
+                                if ($_error == 1)
+                        {
+                               print '<br>erreur 1</br>';
+                                       exit;
+                        }
+                            $idp = $societe_control->fetch($socid = 
$osc_cust->osc_ref);
+                                       
+                                       if ($idp > 0) 
+                                       { 
+                                               $res = $societe->update($idp, 
$user);
+                                               if ($res < 0) print '<br>Erreur 
update '.$idp.'</br>';
+                                               $res = 
$osc_cust->transcode($osc_cust->custid,$idp );
+                                               if ($res < 0) print '<br>Erreur 
update '.$idp.'</br>';
+                                       }
+                                       else print '<br>update impossible $id : 
'.$idp.' </br>';
+                               }
+                   }
+ 
+    }
+
+llxFooter('$Date: 2006/08/11 23:20:32 $ - $Revision: 1.1 $');
+?>
diff -Naur /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/index.php 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/index.php
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/index.php  
2006-08-11 13:20:32.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/index.php  
2006-11-09 10:52:34.000000000 -1000
@@ -66,6 +66,7 @@
                print "<td>Ville</td>";
                print "<td>Pays</td>";
                print '<td align="center">Téléphone</td>';
+               print '<TD align="center">Importer</TD>';
                print "</TR>\n";
           
                while ($i < $num) {
@@ -78,6 +79,7 @@
                print "<TD>".$result[$i][entry_city]."</TD>\n";
                print '<TD 
align="center">'.$result[$i][countries_name]."</TD>\n";
                print '<TD 
align="center">'.$result[$i][customers_telephone]."</TD>\n";
+               print '<TD align="center"><a 
href="fiche.php?action=import&custid='.$result[$i][customers_id].'"'."><b>importer</b></a></TD>\n";
                print "</TR>\n";
                $i++;
                }
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/.#osc_customer.class.php.1.1
 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/.#osc_customer.class.php.1.1
--- 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/.#osc_customer.class.php.1.1
       1969-12-31 14:00:00.000000000 -1000
+++ 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/.#osc_customer.class.php.1.1
       2006-08-14 15:19:13.000000000 -1000
@@ -0,0 +1,188 @@
+<?php
+/*  Copyright (C) 2006      Jean Heimburger     <address@hidden>
+ *
+ * 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: osc_customer.class.php,v 1.1 2006/08/11 23:20:32 eldy Exp $
+ * $Source: 
/sources/dolibarr/dolibarr/htdocs/oscommerce_ws/clients/osc_customer.class.php,v
 $
+ */
+
+/**
+        \file       htdocs/oscommerce_ws/clients/osc_customer.class.php
+        \ingroup    oscommerce_ws/clients
+        \brief      Fichier de la classe des clients issus de OsCommerce
+        \version    $Revision: 1.1 $
+*/
+
+
+/**
+        \class      Osc_customer
+        \brief      Classe permettant la gestion des clients/prospects issus 
d'une base OSC
+*/
+
+
+class Osc_customer
+{
+       var $db;
+
+       var $osc_custid;
+       var $osc_custsoc;
+       var $osc_custfirstname;
+       var $osc_custlastname;
+       var $osc_custstreet;
+       var $osc_custpostcode;
+       var $osc_custcity;
+       var $osc_custtel;
+       var $osc_custfax;
+       var $osc_custmail;
+       var $osc_custidcountry;
+       var $osc_custcodecountry;
+       var $osc_custcountry;
+
+       var $error;
+
+    /**
+     *    \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 */
+               $this->db = $DB;
+
+       }
+
+
+/**
+*      \brief      Charge le client OsC en mémoire
+*      \param      id      Id du client dans OsC 
+*      \return     int     <0 si ko, >0 si ok
+*/
+   function fetch($id='')
+    {
+        global $langs;
+               global $conf;
+       
+               $this->error = '';
+               dolibarr_syslog("Osc_customer::fetch $id=$id ref=$ref");
+      // Verification parametres
+      if (! $id )
+        {
+            $this->error=$langs->trans('ErrorWrongParameters');
+            return -1;
+        }
+
+               set_magic_quotes_runtime(0);
+
+               //WebService Client.
+               require_once(NUSOAP_PATH."/nusoap.php");
+               require_once("../includes/configure.php");
+
+               // Set the parameters to send to the WebService
+               $parameters = array("custid"=>$id);
+
+               // Set the WebService URL
+               $client = new soapclient(OSCWS_DIR."/ws_customers.php");
+
+               // Call the WebSeclient->fault)rvice and store its result in 
$obj
+               $obj = $client->call("get_Client",$parameters );
+// Attention c'est un tableau !!
+
+               if ($client->fault) {
+                       $this->error="Fault detected ".$client->getError();
+                       return -1;
+               }
+               elseif (!($err=$client->getError()) ) {
+                       $this->osc_custid = $obj[0][customers_id];
+                       $this->osc_custsoc = $obj[0][entry_company];
+                       $this->osc_custfirstname = $obj[0][entry_firstname];
+                       $this->osc_custlastname = $obj[0][entry_lastname];
+                       $this->osc_custstreet = $obj[0][entry_street_address];
+                       $this->osc_custpostcode = $obj[0][entry_postcode];
+                       $this->osc_custcity = $obj[0][entry_city];
+                       $this->osc_custtel = $obj[0][customers_telephone];
+                       $this->osc_custfax = $obj[0][customers_fax];
+                       $this->osc_custmail = $obj[0][customers_email_address];
+                       $this->osc_custidcountry = $obj[0][entry_country_id];
+                       $this->osc_custcodecountry = 
$obj[0][countries_iso_code_2];
+                       $this->osc_custcountry = $obj[0][countries_name];
+                       }
+               else {
+                   $this->error = 'Erreur '.$err ;
+                       return -1;
+               } 
+               return 0;
+       }
+
+/**
+*      \brief      Mise à jour de la table de transition
+*      \param      oscid      Id du client dans OsC 
+*         \param          socidp         champ société.idp     
+*      \return     int     <0 si ko, >0 si ok
+*/
+       function transcode($oscid, $socidp )
+       {
+
+               print "entree transcode <br>";
+
+               /* suppression et insertion */
+               $sql = "DELETE FROM ".MAIN_DB_PREFIX."osc_customer WHERE 
osc_custid = ".$oscid.";";
+               $result=$this->db->query($sql);
+        if ($result)
+        {
+                       print "suppression ok ".$sql."  * ".$result;
+               }
+        else
+        {
+                       print "suppression rate ".$sql."  * ".$result;
+            dolibarr_syslog("osc_customer::transcode echec suppression");
+//            $this->db->rollback();
+//            return -1;
+               }
+               $sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_customer VALUES 
(".$oscid." ,  now() , ".$socidp.") ;";
+
+               $result=$this->db->query($sql);
+        if ($result)
+        {
+                       print "insertion ok ". $sql."  ". $result;
+               }
+        else
+        {
+                       print "insertion rate ".$sql." , ".$result;
+            dolibarr_syslog("osc_customer::transcode echec insert");
+//            $this->db->rollback();
+//            return -1;
+               }
+       return 0;       
+     }
+// converti le client osc en client dolibarr
+
+       function get_clientid($osc_client)
+       {
+               $sql = "SELECT doli_socidp FROM ".MAIN_DB_PREFIX."osc_customer 
WHERE osc_custid = ".$osc_client.";";
+               $result=$this->db->query($sql);
+               $row = $this->db->fetch_row($resql);
+// test d'erreurs
+               return $row[0]; 
+       }
+
+       }
+       
+?>
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/CVS/Entries 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/CVS/Entries
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/CVS/Entries      
2006-10-10 08:09:56.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/CVS/Entries      
2006-10-10 08:21:43.000000000 -1000
@@ -1,5 +1,5 @@
 /index.php/1.1/Fri Aug 11 23:20:32 2006//
 /pre.inc.php/1.1/Fri Aug 11 23:20:32 2006//
-/fiche.php/1.2/Fri Sep  1 00:26:56 2006//
-/osc_order.class.php/1.3/Tue Oct 10 18:09:56 2006//
+/fiche.php/1.2/Fri Sep  1 00:01:05 2006//
+/osc_order.class.php/1.3/Tue Oct 10 18:21:43 2006//
 D
diff -Naur /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/fiche.php 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/fiche.php
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/fiche.php        
2006-08-31 14:26:56.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/fiche.php        
2006-11-22 12:12:02.617440328 -1000
@@ -55,20 +55,26 @@
          if ( $user->rights->commande->creer) {
         print '<a class="tabAction" 
href="fiche.php?action=import&amp;orderid='.$osc_order->osc_orderid.'">'.$langs->trans("Import").'</a>';
        }
+         print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
        print "\n</div><br>\n";
 // seule action importer
      
        }
       else
        {
-         print "<p>ERROR 1c</p>\n";
-         dolibarr_print_error('',"erreur webservice ".$osc_order->error);
+         print "\n<div class=\"tabsAction\">\n";
+                 print "<p>ERROR 1c</p>\n";
+                 dolibarr_print_error('',"erreur webservice 
".$osc_order->error);
+                 print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+         print "\n</div><br>\n";
        }
  }
  else
  {
-   print "<p>ERROR 1b</p>\n";
-   print "Error";
+         print "\n<div class=\"tabsAction\">\n";
+                 print "<p>ERROR 1b</p>\n";
+                 print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+         print "\n</div><br>\n";
  }
 }
 /* action Import création de l'objet commande de dolibarr 
@@ -81,13 +87,25 @@
          if ( !$result )
          {
                        $commande = $osc_order->osc2dolibarr($_GET["orderid"]);
-                       print_r($commande);             
+       //              print_r($commande);             
                } 
+/* utilisation de la table de transco*/
+               if ($osc_order->get_orderid($osc_order->osc_orderid)>0)
+               {
+                       print '<p>Cette commande existe déjà</p>';
+               }
+               else {
                        $id = $commande->create($user);
               
                    if ($id > 0)
                    {
-                       print '<br>création réussie nouvelle commande '.$id;
+                                 print "\n<div class=\"tabsAction\">\n";
+                         print '<br>création réussie nouvelle commande '.$id;
+                            $res = 
$osc_order->transcode($osc_order->osc_orderid,$id);
+                                         print '<p>transcode '.$res.' | 
'.$id.' osc : '.$osc_order->osc_orderid.'</p>';
+                                         print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+                                 print "\n</div><br>\n";
+
                                if ($id > 0)  exit;
                    }
                    else
@@ -117,6 +135,7 @@
                                        else print '<br>update impossible $id : 
'.$id.' </br>';
                                }
                    }
+                }
  
     }
 
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/.#fiche.php.1.1 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/.#fiche.php.1.1
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/.#fiche.php.1.1  
1969-12-31 14:00:00.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/.#fiche.php.1.1  
2006-08-14 15:17:36.000000000 -1000
@@ -0,0 +1,124 @@
+<?php
+/*  Copyright (C) 2006      Jean Heimburger     <address@hidden>
+ *
+ *
+ * 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.
+ *
+ * $Source: 
/sources/dolibarr/dolibarr/htdocs/oscommerce_ws/commandes/fiche.php,v $
+ *
+ */
+require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
+require_once("../includes/configure.php");
+require_once("../clients/osc_customer.class.php");
+
+llxHeader();
+
+if ($action == '' && !$cancel) {
+
+ if ($_GET["orderid"])
+ {
+  $osc_order = new Osc_order($db, $_GET["orderid"]);
+  $result = $osc_order->fetch($_GET["orderid"]);
+
+  if ( !$result)
+    { 
+      print '<div class="titre">Fiche commande OSC : 
'.$osc_order->osc_orderid.'</div><br>';
+
+      print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
+      print '<tr></tr><td width="20%">client OSC</td><td 
width="80%">'.$osc_order->osc_custid.'</td></tr>';
+      print '<tr></tr><td width="20%">Nom client</td><td 
width="80%">'.$osc_order->osc_custname.'</td></tr>';
+      print '<tr></tr><td width="20%">Montant</td><td 
width="80%">'.$osc_order->osc_ordertotal.'</td></tr>';
+      print '<tr></tr><td width="20%">Date commande</td><td 
width="80%">'.$osc_order->osc_orderdate.'</td></tr>';
+      print '<tr></tr><td width="20%">Méthode de paiement</td><td 
width="80%">'.$osc_order->osc_orderpaymet.'</td></tr>';
+      print "</table>";
+
+       /* 
************************************************************************** */
+       /*                                                                      
      */ 
+       /* Barre d'action                                                       
      */ 
+       /*                                                                      
      */ 
+       /* 
************************************************************************** */
+       print "\n<div class=\"tabsAction\">\n";
+
+         if ( $user->rights->commande->creer) {
+        print '<a class="tabAction" 
href="fiche.php?action=import&amp;orderid='.$osc_order->osc_orderid.'">'.$langs->trans("Import").'</a>';
+       }
+       print "\n</div><br>\n";
+// seule action importer
+     
+       }
+      else
+       {
+         print "<p>ERROR 1c</p>\n";
+         dolibarr_print_error('',"erreur webservice ".$osc_order->error);
+       }
+ }
+ else
+ {
+   print "<p>ERROR 1b</p>\n";
+   print "Error";
+ }
+}
+/* action Import création de l'objet commande de dolibarr 
+*
+*/
+ if (($_GET["action"] == 'import' ) && ( $_GET["orderid"] != '' ) && 
$user->rights->commande->creer)
+    {
+                 $osc_order = new osc_order($db);
+                 $result = $osc_order->fetch($_GET["orderid"]);
+         if ( !$result )
+         {
+                       $commande = $osc_order->osc2dolibarr($_GET["orderid"]);
+                       print_r($commande);             
+               } 
+                       $id = $commande->create($user);
+              
+                   if ($id > 0)
+                   {
+                       print '<br>création réussie nouvelle commande '.$id;
+                               if ($id > 0)  exit;
+                   }
+                   else
+                   {
+                       if ($id == -3)
+                       {
+                           $_error = 1;
+                           $_GET["action"] = "create";
+                           $_GET["type"] = $_POST["type"];
+                       }
+                               if ($id == -2)
+                               {
+                               /* la référence existe on fait un update */
+                                $societe_control = new Societe($db);
+                                if ($_error == 1)
+                        {
+                               print '<br>erreur 1</br>';
+                                       exit;
+                        }
+                            $id = $societe_control->fetch($ref = 
$osc_order->osc_ref);
+                                       
+                                       if ($id > 0) 
+                                       { 
+                                               $id = $societe->update($id, 
$user);
+                                               if ($id < 0) print '<br>Erreur 
update '.$id.'</br>';
+                                       }
+                                       else print '<br>update impossible $id : 
'.$id.' </br>';
+                               }
+                   }
+ 
+    }
+
+llxFooter('$Date: 2006/08/11 23:20:32 $ - $Revision: 1.1 $');
+?>
diff -Naur /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/index.php 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/index.php
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/index.php        
2006-08-11 13:20:32.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/index.php        
2006-11-22 12:14:23.255060160 -1000
@@ -66,6 +66,7 @@
                print "<td>Date</td>";
                print "<td>Montant</td>";
                print '<td align="center">Paiement</td>';
+               print '<TD align="center">Importer</TD>';
                print "</TR>\n";
           
                while ($i < $num) {
@@ -73,11 +74,13 @@
 
                    print "<TR $bc[$var]>";
                    print '<TD><a 
href="fiche.php?orderid='.$result[$i][orders_id].'">'.$result[$i][orders_id]."</TD>\n";
+               print "<TD>  </TD>\n";
                print "<TD>".$result[$i][customers_name]."</TD>\n";
                print "<TD>".$result[$i][date_purchased]."</TD>\n";
                print "<TD>".$result[$i][value]."</TD>\n";
-               print '<TD 
align="center">'.$result[$i][payment_method]."</TD>\n";
+               print '<TD align="center">'.' 
'.$result[$i][payment_method]."</TD>\n";
 //             print '<TD 
align="center">'/*.$result[$i][customers_telephone]*/."</TD>\n";
+               print '<TD align="center"><a 
href="fiche.php?action=import&orderid='.$result[$i][orders_id].'">'."<b>importer</b></a></TD>\n";
                print "</TR>\n";
                $i++;
                }
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/osc_order.class.php 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/osc_order.class.php
--- 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/osc_order.class.php  
    2006-10-10 08:09:56.000000000 -1000
+++ 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/osc_order.class.php  
    2006-11-22 12:03:27.185797848 -1000
@@ -169,7 +169,60 @@
                } 
 
        }
-       
+       /**
+*      \brief      Mise à jour de la table de transition
+*      \param      oscid      Id du produit dans OsC 
+*         \param          prodid         champ référence       
+*      \return     int     <0 si ko, >0 si ok
+*/
+       function transcode($osc_orderid, $doli_orderid)
+       {
+
+               print "entree transcode <br>";
+
+               /* suppression et insertion */
+               $sql = "DELETE FROM ".MAIN_DB_PREFIX."osc_orders WHERE 
osc_prodid = ".$osc_orderid.";";
+               $result=$this->db->query($sql);
+        if ($result)
+        {
+                       print "suppression ok ".$sql."  * ".$result;
+               }
+        else
+        {
+                       print "suppression rate ".$sql."  * ".$result;
+            dolibarr_syslog("osc_order::transcode echec suppression");
+//            $this->db->rollback();
+//            return -1;
+               }
+               $sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_order VALUES 
(".$osc_orderid." ,  now() , ".$doli_orderid.") ;";
+
+               $result=$this->db->query($sql);
+        if ($result)
+        {
+                       print "insertion ok ". $sql."  ". $result;
+               }
+        else
+        {
+                       print "insertion rate ".$sql." , ".$result;
+            dolibarr_syslog("osc_product::transcode echec insert");
+//            $this->db->rollback();
+//            return -1;
+               }
+       return 0;       
+     }
+// converti le client osc en client dolibarr
+
+       function get_orderid($osc_orderid)
+       {
+               $sql = "SELECT doli_orderidp";
+               $sql.= " FROM ".MAIN_DB_PREFIX."osc_order";
+               $sql.= " WHERE osc_orderid = ".$osc_orderid;
+               $result=$this->db->query($sql);
+               $row = $this->db->fetch_row($resql);
+// test d'erreurs
+               return $row[0]; 
+       }
+
        }
 
 ?>
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/.#osc_order.class.php.1.1
 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/.#osc_order.class.php.1.1
--- 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/.#osc_order.class.php.1.1
        1969-12-31 14:00:00.000000000 -1000
+++ 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/.#osc_order.class.php.1.1
        2006-08-14 16:00:11.000000000 -1000
@@ -0,0 +1,175 @@
+<?php
+/*  Copyright (C) 2006      Jean Heimburger     <address@hidden>
+ *
+ * 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: osc_order.class.php,v 1.1 2006/08/11 23:20:32 eldy Exp $
+ * $Source: 
/sources/dolibarr/dolibarr/htdocs/oscommerce_ws/commandes/osc_order.class.php,v 
$
+ */
+
+/**
+        \file       htdocs/oscommerce_ws/orders/osc_order.class.php
+        \ingroup    oscommerce_ws/orders
+        \brief      Fichier de la classe des commandes issus de OsCommerce
+        \version    $Revision: 1.1 $
+*/
+
+
+require("../clients/osc_customer.class.php");
+require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
+
+
+
+/**
+        \class      Osc_order
+        \brief      Classe permettant la gestion des commandes issues d'une 
base OSC
+*/
+
+class Osc_order
+{
+       var $db;
+
+       var $osc_orderid;
+       var $osc_custid; //identifant du client osc
+       var $osc_custname;
+       var $osc_orderdate;
+       var $osc_ordertotal;
+       var $osc_orderpaymet;
+
+       var $osc_lines = array();
+
+       var $error;
+
+    /**
+     *    \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 */
+       }
+
+
+/**
+*      \brief      Charge la commande OsC en mémoire
+*      \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 = '';
+               dolibarr_syslog("Osc_order::fetch $id=$id ");
+      // Verification parametres
+      if (! $id )
+        {
+            $this->error=$langs->trans('ErrorWrongParameters');
+            return -1;
+        }
+
+               set_magic_quotes_runtime(0);
+
+               //WebService Client.
+               require_once(NUSOAP_PATH."/nusoap.php");
+               require_once("../includes/configure.php");
+
+               // Set the parameters to send to the WebService
+               $parameters = array("orderid"=>$id);
+
+               // Set the WebService URL
+               $client = new soapclient(OSCWS_DIR."/ws_orders.php");
+
+               // Call the WebSeclient->fault)rvice and store its result in 
$obj
+               $obj = $client->call("get_Order",$parameters );
+
+               if ($client->fault) {
+                       $this->error="Fault detected ".$client->getError();
+                       return -1;
+               }
+               elseif (!($err=$client->getError()) ) {
+                       $this->osc_orderid = $obj[0][orders_id];
+                       $this->osc_custname = $obj[0][customers_name];
+                       $this->osc_custid = $obj[0][customers_id];
+                       $this->osc_orderdate = $obj[0][date_purchased];
+                       $this->osc_ordertotal = $obj[0][value];
+                       $this->osc_orderpaymet = $obj[0][payment_method];
+
+
+                       for ($i=1;$i<count($obj);$i++) {
+                       // les lignes
+                               $this->osc_lines[$i-1][products_id] = 
$obj[$i][products_id];
+                               $this->osc_lines[$i-1][products_name] = 
$obj[$i][products_name];
+                               $this->osc_lines[$i-1][products_price] = 
$obj[$i][products_price];
+                               $this->osc_lines[$i-1][final_price] = 
$obj[$i][final_price];
+                               $this->osc_lines[$i-1][products_tax] = 
$obj[$i][products_tax];
+                               $this->osc_lines[$i-1][quantity] = 
$obj[$i][quantity];
+                               }
+                       }
+               else {
+                   $this->error = 'Erreur '.$err ;
+                       return -1;
+               } 
+               return 0;
+       }
+
+// renvoie un objet commande dolibarr
+       function osc2dolibarr($osc_orderid)
+       {
+         $result = $this->fetch($osc_orderid);
+         if ( !$result )
+         {
+                       $commande = new Commande($this->db);
+               if ($_error == 1)
+               {
+                       print '<br>erreur 1</br>';
+                               exit;
+               }
+               /* initialisation */
+                       $oscclient = new Osc_Customer($this->db);
+                       $clientid = $oscclient->get_clientid($this->osc_custid);
+
+                       $commande->socidp = $clientid;
+                       $commande->ref = $this->osc_orderid;
+                       $commande->date = $this->orderdate;
+                       /* on force */
+                       $commande->statut = 0; //à voir
+                       $commande->source = 0; // à vérifier
+ 
+                       //les lignes
+                       print "<br> nombre : " . count($this->osc_lines); 
+                       for ($i = 0; $i < sizeof($this->osc_lines);$i++) {
+                               $commande->lines[$i]->libelle = 
$this->osc_lines[$i][products_id];
+                               $commande->lines[$i]->desc = 
$this->osc_lines[$i][products_name];
+                               $commande->lines[$i]->price = 
$this->osc_lines[$i][products_price];
+                               $commande->lines[$i]->qty = 
$this->osc_lines[$i][quantity];
+                               $commande->lines[$i]->tva_tx = 
$this->osc_lines[$i][products_tax];
+//                             $commande->lines[$i]->fk_product;
+                               $commande->lines[$i]->remise_percent = 0; // à 
calculer avec le finalprice
+                       }
+
+               return $commande;
+               } 
+
+       }
+       
+       }
+
+?>
diff -Naur /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/CVS/Entries 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/CVS/Entries
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/CVS/Entries        
2006-08-12 09:28:43.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/CVS/Entries        
2006-08-12 09:50:22.000000000 -1000
@@ -1,8 +1,8 @@
 /.cvsignore/1.1/Thu Jul 13 12:59:00 2006//
+/index.php/1.2/Fri Aug 11 23:20:32 2006//
+/pre.inc.php/1.2/Fri Aug 11 23:20:32 2006//
+D/clients////
+D/commandes////
 D/includes////
 D/produits////
 D/ws_server////
-/index.php/1.2/Sat Aug 12 19:28:39 2006//
-/pre.inc.php/1.2/Sat Aug 12 19:28:39 2006//
-D/clients////
-D/commandes////
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/includes/configure.php 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/includes/configure.php
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/includes/configure.php     
2006-08-12 09:28:40.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/includes/configure.php     
2006-11-09 10:33:02.000000000 -1000
@@ -7,8 +7,8 @@
 ----------------------------------------------*/
 
 //base url des webservices
-//define(OSCWS_DIR,'http://osc-tiaris/ws_OSC/');
-define(OSCWS_DIR,'http://osc.tiaris.info/ws_OSC/');
+define(OSCWS_DIR,'http://osc-tiaris/ws_OSC/');
+//define(OSCWS_DIR,'http://osc.tiaris.info/ws_OSC/');
 //affichages dans la page d'accueil
 define(OSC_MAXNBCOM, 5);
 define(OSC_ORDWAIT,'4'); // code du statut de commande en attente
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/includes/CVS/Entries 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/includes/CVS/Entries
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/includes/CVS/Entries       
2006-08-12 09:28:40.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/includes/CVS/Entries       
2006-08-12 09:49:57.000000000 -1000
@@ -1,2 +1,2 @@
-/configure.php/1.3/Sat Aug 12 19:28:40 2006//
+/configure.php/1.3/Sat Aug 12 15:32:57 2006//
 D
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/produits/CVS/Entries 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/produits/CVS/Entries
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/produits/CVS/Entries       
2006-08-12 09:28:40.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/produits/CVS/Entries       
2006-08-12 09:49:59.000000000 -1000
@@ -1,5 +1,5 @@
-/fiche.php/1.2/Sat Aug 12 19:28:40 2006//
-/index.php/1.2/Sat Aug 12 19:28:40 2006//
-/osc_product.class.php/1.2/Sat Aug 12 19:28:40 2006//
-/pre.inc.php/1.2/Sat Aug 12 19:28:40 2006//
+/fiche.php/1.2/Fri Aug 11 23:20:32 2006//
+/index.php/1.2/Fri Aug 11 23:20:32 2006//
+/osc_product.class.php/1.2/Fri Aug 11 23:20:32 2006//
+/pre.inc.php/1.2/Fri Aug 11 23:20:32 2006//
 D
diff -Naur /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/produits/fiche.php 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/produits/fiche.php
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/produits/fiche.php 
2006-08-12 09:28:40.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/produits/fiche.php 
2006-11-22 11:52:17.786562000 -1000
@@ -29,7 +29,7 @@
 
  if ($_GET['id'])
  {
-  $osc_prod = new Osc_product();
+  $osc_prod = new Osc_product($db, $_GET['id']);
   $result = $osc_prod->fetch($_GET['id']);
 
   if ( !$result)
@@ -54,6 +54,8 @@
          if ( $user->rights->produit->creer) {
         print '<a class="tabAction" 
href="fiche.php?action=import&amp;id='.$osc_prod->osc_id.'">'.$langs->trans("Import").'</a>';
        }
+
+               print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
        print "\n</div><br>\n";
 // seule action importer
      
@@ -75,7 +77,7 @@
 */
  if (($_GET["action"] == 'import' ) && ( $_GET["id"] != '' ) && 
$user->rights->produit->creer)
     {
-                 $osc_prod = new Osc_product();
+                 $osc_prod = new Osc_product($db, $_GET['id']);
                  $result = $osc_prod->fetch($_GET['id']);
   
          if ( !$result )
@@ -99,11 +101,22 @@
                        $product->status = 1; /* en vente */
                 } 
 
+/* utilisation de la table de transco*/
+               if ($osc_prod->get_productid($osc_prod->osc_id)>0)
+               {
+                       print '<p>Ce produit existe déjà</p>';
+               }
+               else {
                        $id = $product->create($user);
               
                    if ($id > 0)
                    {
-                       print '<br>création réussie produit '.$id.' référence : 
'.$product->ref.'</br>';
+               print "\n<div class=\"tabsAction\">\n";
+               print '<p>création réussie produit '.$id.' référence : 
'.$product->ref.'</p>';
+                               $res = 
$osc_prod->transcode($osc_prod->osc_id,$product->id);
+                               print '<p>transcode '.$res.' | '.$product->id.' 
osc : '.$osc_prod->osc_id.'</p>';
+                       print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+                               print "\n</div><br>\n";
                                $id_entrepot = OSC_ENTREPOT;
                                $id = 
$product->create_stock($id_entrepot,$osc_prod->osc_stock);
                                if ($id > 0)  exit;
@@ -139,6 +152,7 @@
                                        else print '<br>update impossible $id : 
'.$id.' </br>';
                                }
                    }
+                }
  
     }
 
diff -Naur /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/produits/index.php 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/produits/index.php
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/produits/index.php 
2006-08-12 09:28:40.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/produits/index.php 
2006-11-09 10:45:45.000000000 -1000
@@ -66,6 +66,7 @@
                print "<td>Groupe</td>";
                print '<td align="center">Stock</td>';
                print '<TD align="center">Status</TD>';
+               print '<TD align="center">Importer</TD>';
                print "</TR>\n";
           
                while ($i < $num) {
@@ -78,6 +79,7 @@
                print "<TD>".$result[$i][manufacturer]."</TD>\n";
                print '<TD align="center">'.$result[$i][quantity]."</TD>\n";
                print '<TD align="center">'.$result[$i][status]."</TD>\n";
+               print '<TD align="center"><a 
href="fiche.php?action=import&id='.$result[$i][OSC_id].'"'."><b>importer</b></a></TD>\n";
                print "</TR>\n";
                $i++;
                }
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/produits/osc_product.class.php 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/produits/osc_product.class.php
--- 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/produits/osc_product.class.php 
    2006-08-12 09:28:40.000000000 -1000
+++ 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/produits/osc_product.class.php 
    2006-11-22 11:44:58.335368736 -1000
@@ -34,6 +34,8 @@
 
 class Osc_product
 {
+       var $db;
+       
        var $osc_id;
        var $osc_ref;
        var $osc_name;
@@ -50,13 +52,14 @@
      *    \brief      Constructeur de la classe
      *    \param      id          Id produit (0 par defaut)
      */        
-       function Osc_product($id=0) {
+       function Osc_product($DB, $id=0) {
 
         global $langs;
       
         $this->osc_id = $id ;
 
         /* les initialisations nécessaires */
+        $this->db = $DB;
        }
 
 /**
@@ -113,6 +116,60 @@
                return 0;
        }
 
+/**
+*      \brief      Mise à jour de la table de transition
+*      \param      oscid      Id du produit dans OsC 
+*         \param          prodid         champ référence       
+*      \return     int     <0 si ko, >0 si ok
+*/
+       function transcode($oscid, $prodid)
+       {
+
+               print "entree transcode <br>";
+
+               /* suppression et insertion */
+               $sql = "DELETE FROM ".MAIN_DB_PREFIX."osc_product WHERE 
osc_prodid = ".$oscid.";";
+               $result=$this->db->query($sql);
+        if ($result)
+        {
+                       print "suppression ok ".$sql."  * ".$result;
+               }
+        else
+        {
+                       print "suppression rate ".$sql."  * ".$result;
+            dolibarr_syslog("osc_product::transcode echec suppression");
+//            $this->db->rollback();
+//            return -1;
+               }
+               $sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_product VALUES 
(".$oscid." ,  now() , ".$prodid.") ;";
+
+               $result=$this->db->query($sql);
+        if ($result)
+        {
+                       print "insertion ok ". $sql."  ". $result;
+               }
+        else
+        {
+                       print "insertion rate ".$sql." , ".$result;
+            dolibarr_syslog("osc_product::transcode echec insert");
+//            $this->db->rollback();
+//            return -1;
+               }
+       return 0;       
+     }
+// converti le client osc en client dolibarr
+
+       function get_productid($osc_product)
+       {
+               $sql = "SELECT doli_prodidp";
+               $sql.= " FROM ".MAIN_DB_PREFIX."osc_product";
+               $sql.= " WHERE osc_prodid = ".$osc_product;
+               $result=$this->db->query($sql);
+               $row = $this->db->fetch_row($resql);
+// test d'erreurs
+               return $row[0]; 
+       }
+
        
        
          /**
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/ws_server/CVS/Entries 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/ws_server/CVS/Entries
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/ws_server/CVS/Entries      
2006-08-12 09:28:41.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/ws_server/CVS/Entries      
2006-08-12 09:50:22.000000000 -1000
@@ -1,7 +1,7 @@
 /README.txt/1.1/Thu Jul 13 12:59:00 2006//
+/ws_articles.php/1.2/Fri Aug 11 23:20:32 2006//
+/ws_customers.php/1.1/Fri Aug 11 23:20:32 2006//
+/ws_orders.php/1.2/Fri Aug 11 23:20:32 2006//
 /ws_test.php/1.1/Thu Jul 13 12:59:00 2006//
 D/includes////
 D/lib////
-/ws_articles.php/1.2/Sat Aug 12 19:28:40 2006//
-/ws_customers.php/1.1/Fri Aug 11 23:20:32 2006//
-/ws_orders.php/1.2/Sat Aug 12 19:28:41 2006//
-- phpMyAdmin SQL Dump
-- version 2.6.2-Debian-3sarge1
-- http://www.phpmyadmin.net
-- 
-- Serveur: localhost
-- Généré le : Samedi 05 Août 2006 à 17:25
-- Version du serveur: 4.0.24
-- Version de PHP: 4.3.10-16
-- 
-- Base de données: `dolidev`
-- 

-- --------------------------------------------------------

-- 
-- Structure de la table `llx_osc_customer`
-- 

DROP TABLE IF EXISTS `llx_osc_order`;
CREATE TABLE IF NOT EXISTS `llx_osc_order` (
  `osc_orderid` int(11) NOT NULL default '0',
  `osc_lastmodif` datetime default NULL,
  `doli_orderidp` int(11) NOT NULL default '0',
  PRIMARY KEY  (`osc_orderid`),
  UNIQUE KEY `doli_orderidp` (`doli_orderidp`)
) TYPE=InnoDB COMMENT='Table transition commande OSC - commande Dolibarr';
-- phpMyAdmin SQL Dump
-- version 2.6.2-Debian-3sarge1
-- http://www.phpmyadmin.net
-- 
-- Serveur: localhost
-- Généré le : Samedi 05 Août 2006 à 17:25
-- Version du serveur: 4.0.24
-- Version de PHP: 4.3.10-16
-- 
-- Base de données: `dolidev`
-- 

-- --------------------------------------------------------

-- 
-- Structure de la table `llx_osc_customer`
-- 

DROP TABLE IF EXISTS `llx_osc_product`;
CREATE TABLE IF NOT EXISTS `llx_osc_product` (
  `osc_prodid` int(11) NOT NULL default '0',
  `osc_lastmodif` datetime default NULL,
  `doli_prodidp` int(11) NOT NULL default '0',
  PRIMARY KEY  (`osc_prodid`),
  UNIQUE KEY `doli_prodidp` (`doli_prodidp`)
) TYPE=InnoDB COMMENT='Table transition produit OSC - produit Dolibarr';


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.14.15/550 - Release Date: 24/11/2006


reply via email to

[Prev in Thread] Current Thread [Next in Thread]