dolibarr-dev
[Top][All Lists]
Advanced

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

[Dolibarr-dev] Interface Dolibarr OSC


From: Jean
Subject: [Dolibarr-dev] Interface Dolibarr OSC
Date: Tue, 23 Jan 2007 11:45:51 -1000
User-agent: Debian Thunderbird 1.0.2 (X11/20060423)

Corrections et améliorations

Import clients OSC dans Dolibarr
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-12-13 09:23:48.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/CVS/Entries        
2006-12-14 08:07:39.000000000 -1000
@@ -1,5 +1,5 @@
 /pre.inc.php/1.1/Fri Aug 11 23:20:32 2006//
-/osc_customer.class.php/1.3/Tue Oct 10 18:09:56 2006//
-/fiche.php/1.3/Wed Dec 13 19:23:48 2006//
-/index.php/1.2/Wed Dec 13 19:23:48 2006//
+/osc_customer.class.php/1.3/Tue Oct 10 18:21:43 2006//
+/fiche.php/1.3/Wed Dec 13 22:58:22 2006//
+/index.php/1.2/Wed Dec 13 22:58:22 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-12-13 09:23:48.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/fiche.php  
2007-01-22 17:01:56.000000000 -1000
@@ -118,7 +118,10 @@
 /* utilisation de la table de transco*/
                if ($osc_cust->get_clientid($osc_cust->osc_custid)>0)
                {
-                       print '<p>Ce client existe déjà</p>';
+                       print "\n<div class=\"tabsAction\">\n";
+                       print '<p>Ce client existe déjà mise à jour à 
prévoir</p>';
+                       print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+                       print "\n</div><br>\n";
                }
                else {
                        $id = $societe->create($user);
@@ -126,9 +129,9 @@
                    if ($id == 0)
                    {
                        print "\n<div class=\"tabsAction\">\n";
-                               print '<p>création réussie nouveau 
client/prospect '.$societe->id.' nom : '.$societe->nom.'</p>';
+                               print '<p>création réussie nouveau 
client/prospect : '.$societe->nom;
                                $res = 
$osc_cust->transcode($osc_cust->osc_custid,$societe->id);
-                                       print '<p>transcode '.$res.' | 
'.$societe->id.' osc : '.$osc_cust->osc_custid.'</p>';
+                                       print ' : Id Dolibarr '.$societe->id.' 
, Id osc : '.$osc_cust->osc_custid.'</p>';
                                print '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
                                print "\n</div><br>\n";
                    }
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/.#fiche.php.1.2 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/.#fiche.php.1.2
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/.#fiche.php.1.2    
1969-12-31 14:00:00.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/.#fiche.php.1.2    
2006-11-22 11:30:07.000000000 -1000
@@ -0,0 +1,171 @@
+<?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 '<a class="tabAction" 
href="index.php">'.$langs->trans("Retour").'</a>';
+       print "\n</div><br>\n";
+// seule action importer
+     
+       }
+      else
+       {
+               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 "\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 
+*
+*/
+ 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 "\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 */
+               $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
+                } 
+
+/* 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 "\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
+                   {
+                       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 "\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";
+                        }
+                            $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/18 21:28:59 $ - $Revision: 1.2 $');
+?>
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-12-13 09:23:48.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/index.php  
2007-01-22 16:53:53.000000000 -1000
@@ -22,6 +22,7 @@
 
 $langs->load("companies");
 
+
 llxHeader();
 
 
@@ -57,10 +58,14 @@
        $var=True;
        $i=0;
 
+// un client osc
+       $OscClient = new Osc_Customer($db);
+       
        if ($num > 0) {
                print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" 
cellpadding=\"4\">";
                print '<TR class="liste_titre">';
-               print "<td>id</td>";
+               print "<td>Oscid</td>";
+               print "<td>clientId</td>";
                print '<TD align="center">Société</TD>';
                print "<td>Nom</td>";
                print "<td>Ville</td>";
@@ -71,15 +76,20 @@
           
                while ($i < $num) {
                $var=!$var;
+               $custid = $OscClient->get_clientid($result[$i][customers_id]);
 
                    print "<TR $bc[$var]>";
                    print '<TD><a 
href="fiche.php?custid='.$result[$i][customers_id].'">'.$result[$i][customers_id]."</TD>\n";
+               print "<td>".$custid."</td>";
                print "<TD>".$result[$i][entry_company]."</TD>\n";
                print "<TD>".$result[$i][entry_lastname]."</TD>\n";
                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";
+               if ($custid) $lib = "modifier";
+               else $lib = "<u>importer</u>";
+                
+               print '<TD align="center"><a 
href="fiche.php?action=import&custid='.$result[$i][customers_id].'"'.">".$lib."</a></TD>\n";
                print "</TR>\n";
                $i++;
                }
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/.#index.php.1.1 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/.#index.php.1.1
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/.#index.php.1.1    
1969-12-31 14:00:00.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/.#index.php.1.1    
2006-11-09 10:52:34.000000000 -1000
@@ -0,0 +1,100 @@
+<?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.
+ *
+ *
+ */
+
+require("./pre.inc.php");
+
+$langs->load("companies");
+
+llxHeader();
+
+
+if ($page == -1) { $page = 0 ; }
+$limit = $conf->liste_limit;
+$offset = $limit * $page ;
+
+print_barre_liste("Liste des clients de la boutique web", $page, "index.php");
+
+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"=>"0");
+
+// Set the WebService URL
+$client = new soapclient(OSCWS_DIR."ws_customers.php");
+
+$result = $client->call("get_Client",$parameters );
+
+//             echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
+
+if ($client->fault) {
+               dolibarr_print_error('',"erreur de connection ");
+}
+elseif (!($err = $client->getError()) )
+{
+       $num=0;
+       if ($result) $num = sizeof($result);
+       $var=True;
+       $i=0;
+
+       if ($num > 0) {
+               print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" 
cellpadding=\"4\">";
+               print '<TR class="liste_titre">';
+               print "<td>id</td>";
+               print '<TD align="center">Société</TD>';
+               print "<td>Nom</td>";
+               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) {
+               $var=!$var;
+
+                   print "<TR $bc[$var]>";
+                   print '<TD><a 
href="fiche.php?custid='.$result[$i][customers_id].'">'.$result[$i][customers_id]."</TD>\n";
+               print "<TD>".$result[$i][entry_company]."</TD>\n";
+               print "<TD>".$result[$i][entry_lastname]."</TD>\n";
+               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++;
+               }
+               print "</table></p>";
+       }
+       else {
+               dolibarr_print_error('',"Aucun client trouvé");
+       }
+}
+else {
+       dolibarr_print_error('',"Erreur service web ".$err); 
+}
+
+print "</TABLE>";
+
+
+llxFooter('$Date: 2006/08/11 23:20:32 $ - $Revision: 1.1 $');
+?>
diff -Naur 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/osc_customer.class.php 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/osc_customer.class.php
--- 
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/clients/osc_customer.class.php 
    2006-10-10 08:09:56.000000000 -1000
+++ 
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/clients/osc_customer.class.php 
    2007-01-22 16:57:11.000000000 -1000
@@ -140,18 +140,16 @@
        function transcode($oscid, $socid)
        {
 
-               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;
+//                     print "suppression ok ".$sql."  * ".$result;
                }
         else
         {
-                       print "suppression rate ".$sql."  * ".$result;
+//                     print "suppression rate ".$sql."  * ".$result;
             dolibarr_syslog("osc_customer::transcode echec suppression");
 //            $this->db->rollback();
 //            return -1;
@@ -161,11 +159,11 @@
                $result=$this->db->query($sql);
         if ($result)
         {
-                       print "insertion ok ". $sql."  ". $result;
+//                     print "insertion ok ". $sql."  ". $result;
                }
         else
         {
-                       print "insertion rate ".$sql." , ".$result;
+//                     print "insertion rate ".$sql." , ".$result;
             dolibarr_syslog("osc_customer::transcode echec insert");
 //            $this->db->rollback();
 //            return -1;
@@ -182,7 +180,8 @@
                $result=$this->db->query($sql);
                $row = $this->db->fetch_row($resql);
 // test d'erreurs
-               return $row[0]; 
+               if ($row) return $row[0];       
+               else return '';
        }
 
        }
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]; 
+       }
+
+       }
+       
+?>

reply via email to

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