From b6b9b91f19829b96dbe7639a7418576717708c70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Feb 2007 22:23:29 +0000 Subject: [PATCH] Ajout patch os commerce de jean --- htdocs/oscommerce_ws/clients/fiche.php | 9 ++-- htdocs/oscommerce_ws/clients/index.php | 14 ++++- .../clients/osc_customer.class.php | 13 +++-- htdocs/oscommerce_ws/commandes/fiche.php | 54 +++++++++++++++++-- htdocs/oscommerce_ws/commandes/index.php | 10 +++- .../commandes/osc_order.class.php | 30 ++++++----- htdocs/oscommerce_ws/includes/configure.php | 4 +- htdocs/oscommerce_ws/produits/fiche.php | 12 ++--- htdocs/oscommerce_ws/produits/index.php | 12 ++++- .../produits/osc_product.class.php | 13 ++--- 10 files changed, 126 insertions(+), 45 deletions(-) diff --git a/htdocs/oscommerce_ws/clients/fiche.php b/htdocs/oscommerce_ws/clients/fiche.php index 7fb6b937473..acae47d72f0 100644 --- a/htdocs/oscommerce_ws/clients/fiche.php +++ b/htdocs/oscommerce_ws/clients/fiche.php @@ -118,7 +118,10 @@ if ($action == '' && !$cancel) { /* utilisation de la table de transco*/ if ($osc_cust->get_clientid($osc_cust->osc_custid)>0) { - print '

Ce client existe déjà

'; + print "\n
\n"; + print '

Ce client existe déjà mise à jour à prévoir

'; + print ''.$langs->trans("Retour").''; + print "\n

\n"; } else { $id = $societe->create($user); @@ -126,9 +129,9 @@ if ($action == '' && !$cancel) { if ($id == 0) { print "\n
\n"; - print '

création réussie nouveau client/prospect '.$societe->id.' nom : '.$societe->nom.'

'; + print '

création réussie nouveau client/prospect : '.$societe->nom; $res = $osc_cust->transcode($osc_cust->osc_custid,$societe->id); - print '

transcode '.$res.' | '.$societe->id.' osc : '.$osc_cust->osc_custid.'

'; + print ' : Id Dolibarr '.$societe->id.' , Id osc : '.$osc_cust->osc_custid.'

'; print ''.$langs->trans("Retour").''; print "\n

\n"; } diff --git a/htdocs/oscommerce_ws/clients/index.php b/htdocs/oscommerce_ws/clients/index.php index 9ac39127389..76301cee8ac 100644 --- a/htdocs/oscommerce_ws/clients/index.php +++ b/htdocs/oscommerce_ws/clients/index.php @@ -22,6 +22,7 @@ require("./pre.inc.php"); $langs->load("companies"); + llxHeader(); @@ -57,10 +58,14 @@ elseif (!($err = $client->getError()) ) $var=True; $i=0; +// un client osc + $OscClient = new Osc_Customer($db); + if ($num > 0) { print "

"; print ''; - print ""; + print ""; + print ""; print ''; print ""; print ""; @@ -71,15 +76,20 @@ elseif (!($err = $client->getError()) ) while ($i < $num) { $var=!$var; + $custid = $OscClient->get_clientid($result[$i][customers_id]); print ""; print '\n"; + print ""; print "\n"; print "\n"; print "\n"; print '\n"; print '\n"; - print '\n"; + if ($custid) $lib = "modifier"; + else $lib = "importer"; + + print '\n"; print "\n"; $i++; } diff --git a/htdocs/oscommerce_ws/clients/osc_customer.class.php b/htdocs/oscommerce_ws/clients/osc_customer.class.php index 642c8460ed5..6c7fc1fe149 100644 --- a/htdocs/oscommerce_ws/clients/osc_customer.class.php +++ b/htdocs/oscommerce_ws/clients/osc_customer.class.php @@ -140,18 +140,16 @@ class Osc_customer function transcode($oscid, $socid) { - print "entree transcode
"; - /* 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 @@ class Osc_customer $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 @@ class Osc_customer $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 --git a/htdocs/oscommerce_ws/commandes/fiche.php b/htdocs/oscommerce_ws/commandes/fiche.php index be2f8b6609b..722fec0a760 100644 --- a/htdocs/oscommerce_ws/commandes/fiche.php +++ b/htdocs/oscommerce_ws/commandes/fiche.php @@ -87,7 +87,6 @@ if ($action == '' && !$cancel) { 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 @@ if ($action == '' && !$cancel) { print '

Cette commande existe déjà

'; } 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
\n"; + print '
erreur 1
'; + print ''.$langs->trans("Retour").''; + print "\n

\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 '

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.'

'; + } + else + { + print '

création impossible client : '. $osc_cust->osc_custid .'

'; + exit; + } + } + } + $id = $commande->create($user); - + if ($id > 0) { print "\n
\n"; print '
création réussie nouvelle commande '.$id; $res = $osc_order->transcode($osc_order->osc_orderid,$id); - print '

transcode '.$res.' | '.$id.' osc : '.$osc_order->osc_orderid.'

'; + print 'pour la commande osc : '.$osc_order->osc_orderid.'

'; print ''.$langs->trans("Retour").''; print "\n

\n"; @@ -112,6 +159,7 @@ if ($action == '' && !$cancel) { { if ($id == -3) { + print ("

$id = -3 ".$commande->error."

"); $_error = 1; $_GET["action"] = "create"; $_GET["type"] = $_POST["type"]; diff --git a/htdocs/oscommerce_ws/commandes/index.php b/htdocs/oscommerce_ws/commandes/index.php index bd0dc9e8487..d93db02bc74 100644 --- a/htdocs/oscommerce_ws/commandes/index.php +++ b/htdocs/oscommerce_ws/commandes/index.php @@ -57,6 +57,9 @@ elseif (!($err = $client->getError()) ) $var=True; $i=0; +// une commande osc + $OscOrder = new Osc_Order($db); + if ($num > 0) { print "

idOscidclientIdSociétéNomVille
'.$result[$i][customers_id]."".$custid."".$result[$i][entry_company]."".$result[$i][entry_lastname]."".$result[$i][entry_city]."'.$result[$i][countries_name]."'.$result[$i][customers_telephone]."importer".$lib."
"; print ''; @@ -72,15 +75,18 @@ elseif (!($err = $client->getError()) ) while ($i < $num) { $var=!$var; + $ordid = $OscOrder->get_orderid($result[$i][orders_id]); print ""; print '\n"; - print "\n"; + print '\n"; print "\n"; print "\n"; print "\n"; print '\n"; // print '\n"; - print '\n"; + if ($ordid) $lib = "modifier"; + else $lib = "importer"; + print '\n"; print "\n"; $i++; } diff --git a/htdocs/oscommerce_ws/commandes/osc_order.class.php b/htdocs/oscommerce_ws/commandes/osc_order.class.php index ff70a900b93..0244e618ffa 100644 --- a/htdocs/oscommerce_ws/commandes/osc_order.class.php +++ b/htdocs/oscommerce_ws/commandes/osc_order.class.php @@ -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 @@ class Osc_order var $osc_orderdate; var $osc_ordertotal; var $osc_orderpaymet; + var $osc_orderport; var $osc_lines = array(); @@ -109,8 +111,9 @@ class Osc_order $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;$iosc_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 @@ class Osc_order /* 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 @@ class Osc_order $commande->source = 0; // à vérifier //les lignes - print "
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 @@ class Osc_order function transcode($osc_orderid, $doli_orderid) { - print "entree transcode
"; - /* 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 @@ class Osc_order $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 @@ class Osc_order $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 --git a/htdocs/oscommerce_ws/includes/configure.php b/htdocs/oscommerce_ws/includes/configure.php index 1e957d53185..7e4ce8384c2 100644 --- a/htdocs/oscommerce_ws/includes/configure.php +++ b/htdocs/oscommerce_ws/includes/configure.php @@ -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://www.tiaris.info/ws_OSC'); +//define(OSCWS_DIR,'http://www.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 --git a/htdocs/oscommerce_ws/produits/fiche.php b/htdocs/oscommerce_ws/produits/fiche.php index 5af49b2a0e1..119a12a911f 100644 --- a/htdocs/oscommerce_ws/produits/fiche.php +++ b/htdocs/oscommerce_ws/produits/fiche.php @@ -79,14 +79,14 @@ if ($action == '' && !$cancel) { { $osc_prod = new Osc_product($db, $_GET['id']); $result = $osc_prod->fetch($_GET['id']); - + if ( !$result ) { $product = new Product($db); if ($_error == 1) { print '
erreur 1
'; - exit; + // exit; } /* initialisation */ $product->ref = $osc_prod->osc_ref; @@ -108,18 +108,18 @@ if ($action == '' && !$cancel) { } else { $id = $product->create($user); - + if ($id > 0) { print "\n
\n"; - print '

création réussie produit '.$id.' référence : '.$product->ref.'

'; + print '

création réussie produit '.$id.' référence : '.$product->ref; $res = $osc_prod->transcode($osc_prod->osc_id,$product->id); - print '

transcode '.$res.' | '.$product->id.' osc : '.$osc_prod->osc_id.'

'; + print ' Id osc : '.$osc_prod->osc_id.'

'; print ''.$langs->trans("Retour").''; print "\n

\n"; $id_entrepot = OSC_ENTREPOT; $id = $product->create_stock($id_entrepot,$osc_prod->osc_stock); - if ($id > 0) exit; +// if ($id > 0) exit; } else { diff --git a/htdocs/oscommerce_ws/produits/index.php b/htdocs/oscommerce_ws/produits/index.php index 7b2d803bf3a..2d34e05f314 100644 --- a/htdocs/oscommerce_ws/produits/index.php +++ b/htdocs/oscommerce_ws/produits/index.php @@ -57,11 +57,15 @@ elseif (!($err = $client->getError()) ) $var=True; $i=0; +// un produit osc + $OscProd = new Osc_Product($db); + if ($num > 0) { print "

'.$result[$i][orders_id]." '.$ordid." ".$result[$i][customers_name]."".$result[$i][date_purchased]."".$result[$i][value]."'.' '.$result[$i][payment_method]."'/*.$result[$i][customers_telephone]*/."'."importer'.$lib."
"; print ''; print ""; print ""; + print ""; print ""; print ""; print ''; @@ -71,15 +75,19 @@ elseif (!($err = $client->getError()) ) while ($i < $num) { $var=!$var; + $prodid = $OscProd->get_productid($result[$i][OSC_id]); print ""; print '\n"; - print "\n"; + print '\n"; + print ''; print "\n"; print "\n"; print '\n"; print '\n"; - print '\n"; + if ($prodid) $lib = "modifier"; + else $lib = "importer"; + print '\n"; print "\n"; $i++; } diff --git a/htdocs/oscommerce_ws/produits/osc_product.class.php b/htdocs/oscommerce_ws/produits/osc_product.class.php index e062feb8607..2a6b752887a 100644 --- a/htdocs/oscommerce_ws/produits/osc_product.class.php +++ b/htdocs/oscommerce_ws/produits/osc_product.class.php @@ -125,18 +125,18 @@ class Osc_product function transcode($oscid, $prodid) { - print "entree transcode
"; +// print "entree transcode
"; /* 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; +// print "suppression ok ".$sql." * ".$result; } else { - print "suppression rate ".$sql." * ".$result; +// print "suppression rate ".$sql." * ".$result; dolibarr_syslog("osc_product::transcode echec suppression"); // $this->db->rollback(); // return -1; @@ -146,11 +146,11 @@ class Osc_product $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; @@ -167,7 +167,8 @@ class Osc_product $result=$this->db->query($sql); $row = $this->db->fetch_row($resql); // test d'erreurs - return $row[0]; + if ($row) return $row[0]; + else return ''; }
idRefProductIdTitreGroupeStock
'.$result[$i][OSC_id]."".$result[$i][model]."'.$result[$i][model]."'.$prodid.'".$result[$i][name]."".$result[$i][manufacturer]."'.$result[$i][quantity]."'.$result[$i][status]."importer".$lib."