debug sousproduits
This commit is contained in:
parent
1249e684f4
commit
6fda3ac741
@ -1100,7 +1100,7 @@ class Product
|
|||||||
|
|
||||||
function add_sousproduit($id_pere, $id_fils,$qty)
|
function add_sousproduit($id_pere, $id_fils,$qty)
|
||||||
{
|
{
|
||||||
$sql = 'delete from '.MAIN_DB_PREFIX.'product_association';
|
$sql = 'delete from '.MAIN_DB_PREFIX.'product_association';
|
||||||
$sql .= ' WHERE fk_product_pere = "'.$id_pere.'" and fk_product_fils = "'.$id_fils.'"';
|
$sql .= ' WHERE fk_product_pere = "'.$id_pere.'" and fk_product_fils = "'.$id_fils.'"';
|
||||||
if (! $this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
@ -1109,8 +1109,8 @@ class Product
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = 'insert into '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty)';
|
$sql = 'select fk_product_pere from '.MAIN_DB_PREFIX.'product_association';
|
||||||
$sql .= ' VALUES ("'.$id_pere.'","'.$id_fils.'","'.$qty.'")';
|
$sql .= ' WHERE fk_product_pere = "'.$id_fils.'" and fk_product_fils = "'.$id_pere.'"';
|
||||||
if (! $this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
@ -1118,8 +1118,32 @@ class Product
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 1;
|
$result = $this->db->query($sql) ;
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows($result);
|
||||||
|
if($num > 0)
|
||||||
|
{
|
||||||
|
$this->error="isFatherOfThis";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql = 'insert into '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty)';
|
||||||
|
$sql .= ' VALUES ("'.$id_pere.'","'.$id_fils.'","'.$qty.'")';
|
||||||
|
if (! $this->db->query($sql))
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user