diff --git a/htdocs/oscommerce_ws/produits/categories.php b/htdocs/oscommerce_ws/produits/categories.php
index bad23f5a233..a3da5f843ed 100644
--- a/htdocs/oscommerce_ws/produits/categories.php
+++ b/htdocs/oscommerce_ws/produits/categories.php
@@ -60,14 +60,18 @@ if ($user->societe_id > 0)
if ($_REQUEST["action"] == 'maj')
{
+ if ($_POST["dolicat"]) $dolicatid = $_POST["dolicat"];
+ if ($_POST["catMere"]) $dolicatid = $_POST["catMere"];
+
+
$myobject=new Osc_categorie($db);
- if ($myobject->fetch_dolicat($_POST["dolicat"]) <0)
+ if ($myobject->fetch_dolicat($dolicatid) <0)
{
$mesg = "erreur dans fetch_dolicat";
}
elseif ($myobject->id > 0)
{
- $myobject->dolicatid=$_POST["dolicat"];
+ $myobject->dolicatid=$dolicatid;
$myobject->osccatid=$_POST["osccat"];
$result=$myobject->update($user);
@@ -85,7 +89,7 @@ if ($_REQUEST["action"] == 'maj')
}
else
{
- $myobject->dolicatid=$_POST["dolicat"];
+ $myobject->dolicatid=$dolicatid;
$myobject->osccatid=$_POST["osccat"];
$result=$myobject->create($user);
@@ -100,35 +104,121 @@ if ($_REQUEST["action"] == 'maj')
$mesg=$myobject->error;
}
}
+// $mesg.= " ### ".$_POST["dolicat"]." - " . $_POST["osccat"]." - ".$_POST["catMere"]. "
"."variable dolicat ".$dolicatid."
";
}
+else if ($_REQUEST["action"] == 'create')
+{
+ $categorie = new Categorie($db);
+ $categorie->label = $_POST["nom"];
+ $categorie->description = $_POST["description"];
+ $categorie->visible = $_POST["visible"];
+ $categorie->type = $_POST["type"];
+ if($_POST['catMere'] != "-1")
+ $categorie->id_mere = $_POST['catMere'];
+ if (! $categorie->label)
+ {
+ $categorie->error = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
+ $_GET["action"] = 'create';
+ }
+ else if (! $categorie->description)
+ {
+ $categorie->error = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Description"));
+ $_GET["action"] = 'create';
+ }
+
+ if ($categorie->error =="")
+ {
+ if ($cat_id = $categorie->create() > 0)
+ {
+ $_GET["action"] = 'confirmed';
+ $_POST["addcat"] = '';
+ $myobject=new Osc_categorie($db);
+ $myobject->dolicatid=$cat_id;
+ $myobject->osccatid=$_POST["osccat"];
+
+ $result=$myobject->create($user);
+ if ($result > 0)
+ {
+ // Creation OK
+ $mesg="cration de ".$myobject->dolicatid.' - '.$myobject->osccatid ;
+ }
+ else
+ {
+ // Creation KO
+ $mesg=$myobject->error;
+ }
+ }
+ }
+ $mesg .= ' sortie
'.$categorie->error;
+}
+
+if ($_REQUEST["action"] == 'import')
+{
+ $osccat = $_GET['catid'];
+
+}
/***************************************************
* PAGE
*
-* Put here all code to build page
+* Put here all code to build page
****************************************************/
llxHeader();
-
$html=new Form($db);
+
+if ($_REQUEST["action"] == 'import')
+{
+ //titre
+ print '
';
+ print '';
+ print '| Id | Label | Osc_id | Action | ';
+ print '
'."\n";
+ print '';
+ print '\n";
+ print '';
+ print '
';
+ print "
\n";
+}
+else
+{
-if ($mesg) print ''.$mesg.'
';
-// Put here content of your page
-// ...
-if ($page == -1) { $page = 0 ; }
-$limit = $conf->liste_limit;
-$offset = $limit * $page ;
+ if ($mesg) print ''.$mesg.'
';
-$sql = "SELECT c.label, c.rowid dolicatid, oc.osccatid FROM ".MAIN_DB_PREFIX."categorie as c ";
-$sql .= "LEFT OUTER JOIN llx_osc_categories as oc ON oc.dolicatid = c.rowid ";
-$sql .= "WHERE c.visible = 1";
+ // Put here content of your page
+ // ...
+ if ($page == -1) { $page = 0 ; }
+ $limit = $conf->liste_limit;
+ $offset = $limit * $page ;
-print_barre_liste("Correspondance des catégories", $page, "categories.php");
+ $sql = "SELECT c.label, c.rowid dolicatid, oc.osccatid FROM ".MAIN_DB_PREFIX."categorie as c ";
+ $sql .= "LEFT OUTER JOIN llx_osc_categories as oc ON oc.dolicatid = c.rowid ";
+ $sql .= "WHERE c.visible = 1";
+
+ print_barre_liste("Correspondance des catégories", $page, "categories.php");
dolibarr_syslog("Osc_Categorie.class::get_Osccat sql=".$sql);
$resql=$db->query($sql);
@@ -166,7 +256,68 @@ print_barre_liste("Correspondance des cat
{
dolibarr_print_error();
}
+}
+ //WebService Client.
+ require_once(NUSOAP_PATH."/nusoap.php");
+ require_once("../includes/configure.php");
+// Set the parameters to send to the WebService
+if ($_GET["catid"]) $catid = $_GET["catid"];
+else $catid= 0;
+$parameters = array("catid"=>$catid);
+
+
+// Set the WebService URL
+$client = new soapclient_nusoap(OSCWS_DIR."ws_articles.php");
+
+$result = $client->call("get_categorylist",$parameters );
+if ($client->fault) {
+ dolibarr_print_error('',"erreur de connexion ".$client->getError());
+
+}
+elseif (!($err = $client->getError()) )
+{
+ $num=0;
+ if ($result) $num = sizeof($result);
+ $var=True;
+ $i=0;
+ print '
liste categories '.$catid.'
';
+ print_r($result);
+ if ($num > 0) {
+ print "";
+ print '';
+ print "| id | ";
+ print "nom | ";
+ print "parent | ";
+ print 'desc | ';
+ print "id dolibarr | ";
+ print "Importer | ";
+ print "
";
+
+ $dolicat = new Osc_Categorie($db);
+
+ while ($i < $num) {
+ $var=!$var;
+ print "";
+ print '| '.$result[$i]['categories_id'].' | ';
+ print "".$result[$i]['categories_name']." | ";
+ print ''.$result[$i]['parent_id'].' | ';
+ $dolicatid = $dolicat->fetch_osccat($result[$i]['categories_id']);
+ print ''.$dolicat->dolicatid.' | ';
+ print 'Importer | ';
+ print ' | ';
+ print "
";
+ $i++;
+ }
+ }
+}
// End of page
$db->close();
diff --git a/htdocs/oscommerce_ws/produits/fiche.php b/htdocs/oscommerce_ws/produits/fiche.php
index 0570d0578e0..629744f4785 100644
--- a/htdocs/oscommerce_ws/produits/fiche.php
+++ b/htdocs/oscommerce_ws/produits/fiche.php
@@ -90,6 +90,7 @@ if ($action == '' && !$cancel) {
// exit;
}
$product = $osc_prod->osc2dolibarr($_GET['id']);
+
}
else
{
diff --git a/htdocs/oscommerce_ws/produits/osc_product.class.php b/htdocs/oscommerce_ws/produits/osc_product.class.php
index e39fa03c3fb..7833529b6e8 100644
--- a/htdocs/oscommerce_ws/produits/osc_product.class.php
+++ b/htdocs/oscommerce_ws/produits/osc_product.class.php
@@ -50,6 +50,7 @@ class Osc_product
var $error;
+
/**
* \brief Constructeur de la classe
* \param id Id produit (0 par defaut)
@@ -103,15 +104,15 @@ class Osc_product
return -1;
}
elseif (!($err=$client->getError()) ) {
- $this->osc_id = $obj[products_id];
- $this->osc_ref = $obj[products_model];
- $this->osc_name = $obj[products_name];
- $this->osc_desc = $obj[products_description];
- $this->osc_stock = $obj[products_quantity];
- $this->osc_four = $obj[manufacturers_id];
- $this->osc_price = $obj[products_price];
- $this->osc_image = $obj[image];
- $this->osc_catid = $obj[categories_id];
+ $this->osc_id = $obj['products_id'];
+ $this->osc_ref = $obj['products_model'];
+ $this->osc_name = $obj['products_name'];
+ $this->osc_desc = $obj['products_description'];
+ $this->osc_stock = $obj['products_quantity'];
+ $this->osc_four = $obj['manufacturers_id'];
+ $this->osc_price = $obj['products_price'];
+ $this->osc_image = $obj['image'];
+ $this->osc_catid = $obj['categories_id'];
}
else {
$this->error = 'Erreur '.$client->getError();
@@ -140,9 +141,9 @@ class Osc_product
$product->price = convert_price($this->osc_price);
$product->tva_tx = $this->osc_tva;
$product->type = 0;
+ $product->catid = $this->get_catid($this->osc_catid) ;
$product->seuil_stock_alerte = 0; /* on force */
/* on force */
- /* à voir avec la gestion des catégories */
$product->status = 1; /* en vente */
return $product;
@@ -158,18 +159,14 @@ class Osc_product
function transcode($oscid, $prodid)
{
-// print "entree transcode
";
-
/* suppression et insertion */
$sql = "DELETE FROM ".MAIN_DB_PREFIX."osc_product WHERE rowid = ".$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;
@@ -179,17 +176,16 @@ class Osc_product
$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 produit osc en produit dolibarr
function get_productid($osc_product)
@@ -228,6 +224,21 @@ class Osc_product
// test d'erreurs
if ($row) return $row[0];
else return -1;
+ }
+
+ function get_catid($osccatid)
+ {
+ require_once("./osc_categories.class.php");
+ $mycat=new Osc_categorie($this->db);
+
+ if ($mycat->fetch_osccat($osccatid) > 0)
+ {
+ $x = $mycat->dolicatid;
+ print''.$x.'
';
+ return $x ;
+ }
+ else return 0;
+
}
/**