Ajout patch jean
This commit is contained in:
parent
488e0766fe
commit
0e31140e17
@ -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"]. "<br/>"."variable dolicat ".$dolicatid."<br/>";
|
||||
}
|
||||
|
||||
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<br/>'.$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 '<table width="100%" class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>Id</td><td>Label</td><td>Osc_id</td><td>Action</td>';
|
||||
print '</tr>'."\n";
|
||||
print '<tr>';
|
||||
print '<form method="post" action="categories.php">';
|
||||
|
||||
print '<td><input name="osccat" value="'.$osccat.'"></td><td>';
|
||||
print '<input type="hidden" name="action" value="maj"/>';
|
||||
// print '<input type="hidden" name="dolicat" value="'.$obj->dolicatid.'"/>';
|
||||
print $langs->trans("ChooseCategory").' ';
|
||||
print $html->select_all_categories(0,$categorie->id_mere).' <input type="submit" name="doit" class="button" value="'.$langs->trans("Classify").'"></td>';
|
||||
print "</form>\n";
|
||||
print '<form method="post" action="categories.php">';
|
||||
print '<input type="hidden" name="action" value="create"/>';
|
||||
print '<input type="hidden" name="nom" value="'.$_POST["description"].'"/>';
|
||||
print '<input type="hidden" name="description" value="'.$_POST["description"].'"/>';
|
||||
print '<input type="hidden" name="visible" value="1"/>';
|
||||
$parent = -1;
|
||||
if ($_POST["catMere"] > 0) $parent = $_POST["catMere"];
|
||||
print '<input type="hidden" name="catMere" value="'.$parent.'"/>';
|
||||
print '<input type="hidden" name="type" value="0"/>';
|
||||
print '<input type="hidden" name="osccat" value="'.$osccat.'"/>';
|
||||
print '<td><input type="submit" name="create" value="'.$langs->trans("create").'"></td>';
|
||||
print '</form>';
|
||||
print '</tr>';
|
||||
print "</table>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if ($mesg) print '<div class="ok">'.$mesg.'</div>';
|
||||
|
||||
// Put here content of your page
|
||||
// ...
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
if ($mesg) print '<div class="ok">'.$mesg.'</div>';
|
||||
|
||||
$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 '<br/>liste categories '.$catid.'<br/>';
|
||||
print_r($result);
|
||||
if ($num > 0) {
|
||||
print "<TABLE width=\"100%\" class=\"noborder\">";
|
||||
print '<TR class="liste_titre">';
|
||||
print "<td>id</td>";
|
||||
print "<td>nom</td>";
|
||||
print "<td>parent</td>";
|
||||
print '<td>desc</td>';
|
||||
print "<td>id dolibarr</td>";
|
||||
print "<td>Importer</td>";
|
||||
print "</tr>";
|
||||
|
||||
$dolicat = new Osc_Categorie($db);
|
||||
|
||||
while ($i < $num) {
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="categories.php?catid='.$result[$i]['categories_id'].'">'.$result[$i]['categories_id'].'</a></td>';
|
||||
print "<td>".$result[$i]['categories_name']."</td>";
|
||||
print '<td>'.$result[$i]['parent_id'].'</td>';
|
||||
$dolicatid = $dolicat->fetch_osccat($result[$i]['categories_id']);
|
||||
print '<td>'.$dolicat->dolicatid.'</td>';
|
||||
print '<td><a href="categories.php?action=import&catid='.$result[$i]['categories_id'].'">Importer</a></td>';
|
||||
print '<td><form method="POST" action="categorie.php">';
|
||||
print '<input type="hidden" name="description" value="'.$result[$i]['categories_name'].'"/>';
|
||||
print '<input type="hidden" name="nom" value="'.$result[$i]['categories_name'].'"/>';
|
||||
print '<input type="hidden" name="visible" value="1"/>';
|
||||
print '<input type="hidden" name="action" value="import"/>';
|
||||
print '<input type="hidden" name="catMere" value="'.$result[$i]['parent_id'].'"/>';
|
||||
print '<input type="hidden" name="catid" value="'.$result[$i]['categories_id'].'"/>';
|
||||
print '</form> </td>';
|
||||
print "</tr>";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
$db->close();
|
||||
|
||||
@ -90,6 +90,7 @@ if ($action == '' && !$cancel) {
|
||||
// exit;
|
||||
}
|
||||
$product = $osc_prod->osc2dolibarr($_GET['id']);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -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 <br>";
|
||||
|
||||
/* 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'<p>'.$x.'</p>';
|
||||
return $x ;
|
||||
}
|
||||
else return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user