[Top][All Lists]
[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:44:50 -1000 |
User-agent: |
Debian Thunderbird 1.0.2 (X11/20060423) |
Correction et amélioration Interface
import commandes OSC dans Dolibarr
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-12-13 09:23:49.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/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//
-/fiche.php/1.3/Wed Dec 13 19:23:49 2006//
-/index.php/1.2/Wed Dec 13 19:23:49 2006//
-/osc_order.class.php/1.4/Wed Dec 13 19:23:49 2006//
+/fiche.php/1.3/Wed Dec 13 22:58:22 2006//
+/index.php/1.2/Wed Dec 13 22:58:22 2006//
+/osc_order.class.php/1.4/Wed Dec 13 22:58:23 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-12-13 09:23:49.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/fiche.php
2007-01-23 11:28:37.903926568 -1000
@@ -87,7 +87,6 @@
if ( !$result )
{
$commande = $osc_order->osc2dolibarr($_GET["orderid"]);
- // print_r($commande);
}
/* utilisation de la table de transco*/
if ($osc_order->get_orderid($osc_order->osc_orderid)>0)
@@ -95,14 +94,62 @@
print '<p>Cette commande existe déjà</p>';
}
else {
+// vérifier que la société est renseignée, sinon importer le client d'abord
+ if ( ! $commande->socid)
+ {
+ $osc_cust = new Osc_customer($db,
$osc_order->osc_custid);
+ $result =
$osc_cust->fetch($osc_order->osc_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
+
+ $cl = $societe->create($user);
+ if ($cl == 0)
+ {
+ $commande->socid = $societe->id;
+ print '<p>création réussie nouveau
client/prospect : '.$societe->nom;
+ $res =
$osc_cust->transcode($osc_cust->osc_custid,$societe->id);
+ print ' : Id Dolibarr '.$societe->id.'
, Id osc : '.$osc_cust->osc_custid.'</p>';
+ }
+ else
+ {
+ print '<p>création impossible client : '.
$osc_cust->osc_custid .'</p>';
+ exit;
+ }
+ }
+ }
+
$id = $commande->create($user);
-
+
if ($id > 0)
{
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 'pour la commande osc :
'.$osc_order->osc_orderid.'</p>';
print '<a class="tabAction"
href="index.php">'.$langs->trans("Retour").'</a>';
print "\n</div><br>\n";
@@ -112,6 +159,7 @@
{
if ($id == -3)
{
+ print ("<p>$id = -3
".$commande->error."</p>");
$_error = 1;
$_GET["action"] = "create";
$_GET["type"] = $_POST["type"];
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&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/.#fiche.php.1.2
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/.#fiche.php.1.2
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/.#fiche.php.1.2
1969-12-31 14:00:00.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/.#fiche.php.1.2
2006-11-22 12:12:02.000000000 -1000
@@ -0,0 +1,143 @@
+<?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&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 "\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 "\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
+*
+*/
+ 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);
+ }
+/* 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 "\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
+ {
+ 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/18 21:28:59 $ - $Revision: 1.2 $');
+?>
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-12-13 09:23:49.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/index.php
2007-01-22 18:08:02.000000000 -1000
@@ -57,6 +57,9 @@
$var=True;
$i=0;
+// une commande osc
+ $OscOrder = new Osc_Order($db);
+
if ($num > 0) {
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\"
cellpadding=\"4\">";
print '<TR class="liste_titre">';
@@ -72,15 +75,18 @@
while ($i < $num) {
$var=!$var;
+ $ordid =
$OscOrder->get_orderid($result[$i][orders_id]);
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><a
href="../../commande/fiche.php?id='.$ordid.'">'.$ordid."</a> </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][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";
+ if ($ordid) $lib = "modifier";
+ else $lib = "<u>importer</u>";
+ print '<TD align="center"><a
href="fiche.php?action=import&orderid='.$result[$i][orders_id].'">'.$lib."</a></TD>\n";
print "</TR>\n";
$i++;
}
diff -Naur
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/.#index.php.1.1
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/.#index.php.1.1
--- /home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/.#index.php.1.1
1969-12-31 14:00:00.000000000 -1000
+++ /home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/.#index.php.1.1
2006-11-22 12:14:23.000000000 -1000
@@ -0,0 +1,101 @@
+<?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 commandes 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("orderid"=>"0");
+
+// Set the WebService URL
+$client = new soapclient(OSCWS_DIR."ws_orders.php");
+
+$result = $client->call("get_Order",$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">Commande</TD>';
+ print "<td>Client</td>";
+ 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) {
+ $var=!$var;
+
+ 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][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++;
+ }
+ print "</table></p>";
+ }
+ else {
+ dolibarr_print_error('',"Aucune commande trouvée");
+ }
+}
+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/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-12-13 09:23:49.000000000 -1000
+++
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/osc_order.class.php
2007-01-23 10:49:55.091047800 -1000
@@ -28,6 +28,7 @@
require("../clients/osc_customer.class.php");
+require("../produits/osc_product.class.php");
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
@@ -47,6 +48,7 @@
var $osc_orderdate;
var $osc_ordertotal;
var $osc_orderpaymet;
+ var $osc_orderport;
var $osc_lines = array();
@@ -109,8 +111,9 @@
$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_ordertotal = $obj[0][total];
$this->osc_orderpaymet = $obj[0][payment_method];
+ $this->osc_orderport = $obj[0][port];
for ($i=1;$i<count($obj);$i++) {
@@ -120,13 +123,14 @@
$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];
+ $this->osc_lines[$i-1][quantity] =
$obj[$i][products_quantity];
}
}
else {
$this->error = 'Erreur '.$err ;
return -1;
- }
+ }
+// print_r($this);
return 0;
}
@@ -145,6 +149,8 @@
/* initialisation */
$oscclient = new Osc_Customer($this->db);
$clientid = $oscclient->get_clientid($this->osc_custid);
+
+ $oscproduct = new Osc_product($this->db);
$commande->socid = $clientid;
$commande->ref = $this->osc_orderid;
@@ -154,14 +160,15 @@
$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]->subprice =
$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]->fk_product =
$oscproduct->get_productid($this->osc_lines[$i][products_id]);
$commande->lines[$i]->remise_percent = 0; // à
calculer avec le finalprice
}
@@ -178,18 +185,16 @@
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;
+// print "suppression ok ".$sql." * ".$result;
}
else
{
- print "suppression rate ".$sql." * ".$result;
+// print "suppression rate ".$sql." * ".$result;
dolibarr_syslog("osc_order::transcode echec suppression");
// $this->db->rollback();
// return -1;
@@ -199,11 +204,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_product::transcode echec insert");
// $this->db->rollback();
// return -1;
@@ -220,7 +225,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/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/commandes/.#osc_order.class.php.1.3
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/.#osc_order.class.php.1.3
---
/home/jean/gestion/dolibarr/htdocs/oscommerce_ws/commandes/.#osc_order.class.php.1.3
1969-12-31 14:00:00.000000000 -1000
+++
/home/jean/projets/dolibarr/htdocs/oscommerce_ws/commandes/.#osc_order.class.php.1.3
2006-11-22 12:03:27.000000000 -1000
@@ -0,0 +1,228 @@
+<?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.3 2006/09/13 18:56:37 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.3 $
+*/
+
+
+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->socid = $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;
+ }
+
+ }
+ /**
+* \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];
+ }
+
+ }
+
+?>